@design.estate/dees-document 1.0.99 → 1.0.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/npmextra.json CHANGED
@@ -2,19 +2,40 @@
2
2
  "gitzone": {
3
3
  "projectType": "wcc",
4
4
  "module": {
5
- "githost": "gitlab.com",
5
+ "githost": "code.foss.global",
6
6
  "gitscope": "designestate/private",
7
7
  "gitrepo": "dedocument-catalog",
8
- "description": "a catalog for creating documents like invoices",
8
+ "description": "A comprehensive solution for generating documents like invoices, integrating elements, templates, and services to streamline document creation.",
9
9
  "npmPackagename": "@designestate_private/dedocument-catalog",
10
10
  "license": "MIT",
11
11
  "projectDomain": "design.estate",
12
- "shortDescription": "undefined variable"
12
+ "shortDescription": "undefined variable",
13
+ "keywords": [
14
+ "document generation",
15
+ "invoices",
16
+ "PDF creation",
17
+ "typescript",
18
+ "web components",
19
+ "custom elements",
20
+ "QR code",
21
+ "smart contracts",
22
+ "templating",
23
+ "dynamic rendering",
24
+ "responsive design",
25
+ "modular development",
26
+ "lightweight",
27
+ "efficient",
28
+ "finance",
29
+ "business"
30
+ ]
13
31
  }
14
32
  },
15
33
  "npmci": {
16
34
  "npmGlobalTools": [],
17
35
  "npmAccessLevel": "private",
18
36
  "npmRegistryUrl": "verdaccio2.lossless.one"
37
+ },
38
+ "tsdoc": {
39
+ "legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
19
40
  }
20
41
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@design.estate/dees-document",
3
- "version": "1.0.99",
3
+ "version": "1.0.101",
4
4
  "private": false,
5
- "description": "a catalog for creating documents like invoices",
5
+ "description": "A comprehensive solution for generating documents like invoices, integrating elements, templates, and services to streamline document creation.",
6
6
  "main": "dist_ts_web/index.js",
7
7
  "typings": "dist_ts_web/index.d.ts",
8
8
  "exports": {
@@ -12,26 +12,26 @@
12
12
  "author": "Lossless GmbH",
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@design.estate/dees-domtools": "^2.0.55",
16
- "@design.estate/dees-element": "^2.0.33",
17
- "@design.estate/dees-wcctools": "^1.0.85",
18
- "@git.zone/tsrun": "^1.2.46",
19
- "@push.rocks/smartfile": "^11.0.4",
20
- "@push.rocks/smartjson": "^5.0.10",
21
- "@push.rocks/smartpath": "^5.0.11",
22
- "@push.rocks/smartpdf": "^3.0.16",
23
- "@push.rocks/smarttime": "^4.0.6",
24
- "@tsclass/tsclass": "^4.0.46",
15
+ "@design.estate/dees-domtools": "^2.0.65",
16
+ "@design.estate/dees-element": "^2.0.39",
17
+ "@design.estate/dees-wcctools": "^1.0.90",
18
+ "@git.zone/tsrun": "^1.3.3",
19
+ "@push.rocks/smartfile": "^11.0.21",
20
+ "@push.rocks/smartjson": "^5.0.20",
21
+ "@push.rocks/smartpath": "^5.0.18",
22
+ "@push.rocks/smartpdf": "^3.1.7",
23
+ "@push.rocks/smarttime": "^4.0.8",
24
+ "@tsclass/tsclass": "^4.1.2",
25
25
  "@types/qrcode": "^1.5.5",
26
- "qrcode": "^1.5.3"
26
+ "qrcode": "^1.5.4"
27
27
  },
28
28
  "devDependencies": {
29
- "@git.zone/tsbuild": "^2.1.72",
30
- "@git.zone/tsbundle": "^2.0.15",
31
- "@git.zone/tstest": "^1.0.84",
32
- "@git.zone/tswatch": "^2.0.21",
29
+ "@git.zone/tsbuild": "^2.2.0",
30
+ "@git.zone/tsbundle": "^2.1.0",
31
+ "@git.zone/tstest": "^1.0.90",
32
+ "@git.zone/tswatch": "^2.0.25",
33
33
  "@push.rocks/projectinfo": "^5.0.2",
34
- "@push.rocks/tapbundle": "^5.0.15"
34
+ "@push.rocks/tapbundle": "^5.5.3"
35
35
  },
36
36
  "files": [
37
37
  "ts/**/*",
@@ -57,6 +57,24 @@
57
57
  "url": "https://gitlab.com/designestate/private/dedocument-catalog/issues"
58
58
  },
59
59
  "homepage": "https://gitlab.com/designestate/private/dedocument-catalog#readme",
60
+ "keywords": [
61
+ "document generation",
62
+ "invoices",
63
+ "PDF creation",
64
+ "typescript",
65
+ "web components",
66
+ "custom elements",
67
+ "QR code",
68
+ "smart contracts",
69
+ "templating",
70
+ "dynamic rendering",
71
+ "responsive design",
72
+ "modular development",
73
+ "lightweight",
74
+ "efficient",
75
+ "finance",
76
+ "business"
77
+ ],
60
78
  "scripts": {
61
79
  "test": "npm run build && tstest test/",
62
80
  "build": "tsbuild --allowimplicitany && tsbuild element --allowimplicitany && tsbundle element --production",
@@ -0,0 +1 @@
1
+
package/readme.md CHANGED
@@ -1,7 +1,144 @@
1
- # @design.estate/private/dedocument-catalog
1
+ # @design.estate/dees-document
2
2
  a catalog for creating documents like invoices
3
3
 
4
+ ## Install
5
+ To install `@design.estate/dees-document`, run the following command in your project directory:
6
+ ```shell
7
+ npm install @design.estate/dees-document --save
8
+ ```
9
+
10
+ This will add `@design.estate/dees-document` to your project's dependencies and ensure it's installed into your `node_modules` folder.
11
+
4
12
  ## Usage
13
+ The `@design.estate/dees-document` package is a comprehensive toolkit for creating various types of documents, such as invoices, with ease. It leverages modern ECMAScript (ES) modules and TypeScript for a type-safe, developer-friendly experience. Below, you'll find detailed examples covering how to utilize the package to its full potential.
14
+
15
+ ### Setting Up the Document Service
16
+ Before diving into creating documents, you first need to set up the document service. This involves importing the necessary modules and initializing the service instance.
17
+
18
+ ```typescript
19
+ import { PdfService, IPdfServiceConstructorOptions } from '@design.estate/dees-document';
20
+
21
+ async function setupPdfService() {
22
+ const options: IPdfServiceConstructorOptions = {
23
+ // Configuration options here
24
+ };
25
+
26
+ const pdfService = await PdfService.createAndStart(options);
27
+ console.log('PDF Service started successfully.');
28
+ return pdfService;
29
+ }
30
+ ```
31
+
32
+ In the example above, we import `PdfService` from the package and use its `createAndStart` method to initialize it with optional configuration settings. Replace `// Configuration options here` with any specific options your project may require.
33
+
34
+ ### Creating a Simple Invoice
35
+ After setting up the document service, you can proceed to create documents such as invoices. Here, we'll demonstrate how to create a basic invoice.
36
+
37
+ #### Define the Invoice Data Structure
38
+ First, define the basic structure of your invoice. This involves specifying details like the sender, recipient, items, and more.
39
+
40
+ ```typescript
41
+ import { ILetter } from '@design.estate/dees-document';
42
+
43
+ const invoiceData: ILetter = {
44
+ from: {
45
+ name: "Your Company Name",
46
+ address: {
47
+ streetName: "Your Street",
48
+ houseNumber: "123",
49
+ city: "Your City",
50
+ country: "Your Country",
51
+ postalCode: "12345",
52
+ },
53
+ email: "your-email@example.com",
54
+ phone: "123-456-7890",
55
+ },
56
+ to: {
57
+ name: "Recipient Company Name",
58
+ address: {
59
+ streetName: "Recipient Street",
60
+ houseNumber: "456",
61
+ city: "Recipient City",
62
+ country: "Recipient Country",
63
+ postalCode: "67890",
64
+ },
65
+ email: "recipient-email@example.com",
66
+ phone: "098-765-4321",
67
+ },
68
+ content: {
69
+ invoiceData: {
70
+ items: [
71
+ {
72
+ name: "Service or Product Name",
73
+ unitQuantity: 2,
74
+ unitNetPrice: 100.00,
75
+ unitType: 'service',
76
+ vatPercentage: 19,
77
+ currency: 'EUR',
78
+ }
79
+ ]
80
+ }
81
+ },
82
+ subject: "Invoice for Services Rendered",
83
+ date: new Date().getTime(),
84
+ versionInfo: {
85
+ type: "final",
86
+ version: "1.0.0"
87
+ },
88
+ };
89
+ ```
90
+
91
+ In this structure, `invoiceData` outlines essential details for an invoice document, using the `ILetter` interface. It includes information about both the sender (`from`) and the recipient (`to`), as well as the invoiced items under `content.invoiceData.items`.
92
+
93
+ #### Generate the Invoice PDF
94
+ With the invoice data ready, you can now generate the PDF using the `PdfService` instance.
95
+
96
+ ```typescript
97
+ async function generateInvoice(pdfService: PdfService, invoiceData: ILetter) {
98
+ const pdfBuffer = await pdfService.createPdfFromLetterObject(invoiceData);
99
+ console.log('Invoice PDF generated successfully.');
100
+
101
+ // Here, you can save the PDF to a file, send it over a network, etc.
102
+ }
103
+ ```
104
+
105
+ The method `createPdfFromLetterObject` receives the invoice data and returns a `Buffer` containing the PDF. You can then save this PDF to the filesystem, send it over email, or perform any other required actions.
106
+
107
+ #### Complete Example Integration
108
+ Combining everything, your complete script to set up the service, define invoice data, and generate a PDF invoice might look something like this:
109
+
110
+ ```typescript
111
+ async function main() {
112
+ const pdfService = await setupPdfService();
113
+ await generateInvoice(pdfService, invoiceData);
114
+ }
115
+
116
+ main().then(() => console.log('Invoice generation process completed.'));
117
+ ```
118
+
119
+ ### Beyond Invoices
120
+ The `@design.estate/dees-document` package is not limited to invoices alone. It's designed to handle a wide range of document types. The modular architecture allows for the customizable construction of documents, enabling you to tailor the output to meet precise requirements.
121
+
122
+ For instance, you can create contracts, reports, and other document types using a similar approach—by defining the content structure and utilizing the PDF service to generate the document. The package's flexibility and extensibility make it an invaluable tool in any document generation workflow.
123
+
124
+ ### Advanced Usage
125
+ For more advanced scenarios, such as custom styling, embedding images, and handling more complex document structures, refer to the package's documentation. It provides comprehensive details and examples to help you fully leverage the capabilities of `@design.estate/dees-document`.
126
+
127
+ ## License and Legal Information
128
+
129
+ This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
130
+
131
+ **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
132
+
133
+ ### Trademarks
134
+
135
+ This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
136
+
137
+ ### Company Information
138
+
139
+ Task Venture Capital GmbH
140
+ Registered at District court Bremen HRB 35230 HB, Germany
141
+
142
+ For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
5
143
 
6
- Use TypeScript for best in class intellisense
7
- For further information read the linked docs at the top of this readme.
144
+ By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
@@ -1,8 +1,8 @@
1
1
  /**
2
- * autocreated commitinfo by @pushrocks/commitinfo
2
+ * autocreated commitinfo by @push.rocks/commitinfo
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@design.estate/dees-document',
6
- version: '1.0.99',
7
- description: 'a catalog for creating documents like invoices'
6
+ version: '1.0.101',
7
+ description: 'A comprehensive solution for generating documents like invoices, integrating elements, templates, and services to streamline document creation.'
8
8
  }
@@ -1,8 +1,8 @@
1
1
  /**
2
- * autocreated commitinfo by @pushrocks/commitinfo
2
+ * autocreated commitinfo by @push.rocks/commitinfo
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@design.estate/dees-document',
6
- version: '1.0.99',
7
- description: 'a catalog for creating documents like invoices'
6
+ version: '1.0.101',
7
+ description: 'A comprehensive solution for generating documents like invoices, integrating elements, templates, and services to streamline document creation.'
8
8
  }
@@ -32,21 +32,25 @@ export class DeDocument extends DeesElement {
32
32
 
33
33
  @property({
34
34
  type: String,
35
+ reflect: true,
35
36
  })
36
37
  public format: 'a4' = 'a4';
37
38
 
38
39
  @property({
39
40
  type: Number,
41
+ reflect: true,
40
42
  })
41
43
  public viewWidth: number = null;
42
44
 
43
45
  @property({
44
46
  type: Number,
47
+ reflect: true,
45
48
  })
46
49
  public viewHeight: number = null;
47
50
 
48
51
  @property({
49
52
  type: Boolean,
53
+ reflect: true,
50
54
  })
51
55
  printMode = false;
52
56
 
@@ -60,7 +64,6 @@ export class DeDocument extends DeesElement {
60
64
  return valueArg;
61
65
  }
62
66
  },
63
-
64
67
  })
65
68
  public letterData: plugins.tsclass.business.ILetter;
66
69
 
@@ -117,6 +120,7 @@ export class DeDocument extends DeesElement {
117
120
  this.renderDocument();
118
121
  }
119
122
 
123
+ public latestRenderedLetterData: plugins.tsclass.business.ILetter = null;
120
124
  public async renderDocument() {
121
125
  const domtools = await this.domtoolsPromise;
122
126
  const documentContainer = this.shadowRoot.querySelector('.documentContainer');
@@ -172,10 +176,16 @@ export class DeDocument extends DeesElement {
172
176
  page.pageTotalNumber = pageCounter;
173
177
  }
174
178
  this.adjustDePageScaling();
179
+ this.latestRenderedLetterData = this.letterData;
175
180
  }
176
181
 
177
- updated(changedProperties: Map<string | number | symbol, unknown>): void {
182
+ async updated(changedProperties: Map<string | number | symbol, unknown>): void {
178
183
  super.updated(changedProperties);
184
+ const domtools = await this.domtoolsPromise;
185
+ const renderedDocIsUpToDate = domtools.convenience.smartjson.deepEqualObjects(this.letterData, this.latestRenderedLetterData);
186
+ if (!renderedDocIsUpToDate) {
187
+ this.renderDocument();
188
+ }
179
189
 
180
190
  if (changedProperties.has('viewHeight') || changedProperties.has('viewWidth')) {
181
191
  this.adjustDePageScaling();
@@ -65,8 +65,6 @@ export class DePage extends DeesElement {
65
65
  css`
66
66
  :host {
67
67
  display: block;
68
- max-height: ${shared.a4Height}px;
69
- max-width: ${shared.a4Width}px;
70
68
  }
71
69
 
72
70
  #scaleWrapper {
@@ -67,7 +67,7 @@ export const demoLetter: tsclass.business.ILetter = {
67
67
  unitNetPrice: 100,
68
68
  unitType: 'hours',
69
69
  vatPercentage: 19,
70
- currency: 'EUR',
70
+ position: 0,
71
71
  },
72
72
  {
73
73
  name: 'Item with 7% VAT',
@@ -75,7 +75,7 @@ export const demoLetter: tsclass.business.ILetter = {
75
75
  unitNetPrice: 100,
76
76
  unitType: 'hours',
77
77
  vatPercentage: 7,
78
- currency: 'EUR',
78
+ position: 1,
79
79
  },
80
80
  {
81
81
  name: 'Item with 7% VAT',
@@ -83,7 +83,7 @@ export const demoLetter: tsclass.business.ILetter = {
83
83
  unitNetPrice: 230,
84
84
  unitType: 'hours',
85
85
  vatPercentage: 7,
86
- currency: 'EUR',
86
+ position: 2,
87
87
  },
88
88
  {
89
89
  name: 'Item with 21% VAT',
@@ -91,7 +91,7 @@ export const demoLetter: tsclass.business.ILetter = {
91
91
  unitNetPrice: 230,
92
92
  unitType: 'hours',
93
93
  vatPercentage: 21,
94
- currency: 'EUR',
94
+ position: 3,
95
95
  },
96
96
  {
97
97
  name: 'Item with 0% VAT',
@@ -99,7 +99,46 @@ export const demoLetter: tsclass.business.ILetter = {
99
99
  unitNetPrice: 230,
100
100
  unitType: 'hours',
101
101
  vatPercentage: 0,
102
- currency: 'EUR',
102
+ position: 4,
103
+ },{
104
+ name: 'Item with 19% VAT',
105
+ unitQuantity: 1,
106
+ unitNetPrice: 100,
107
+ unitType: 'hours',
108
+ vatPercentage: 19,
109
+ position: 5,
110
+ },
111
+ {
112
+ name: 'Item with 7% VAT',
113
+ unitQuantity: 1,
114
+ unitNetPrice: 100,
115
+ unitType: 'hours',
116
+ vatPercentage: 7,
117
+ position: 6,
118
+ },
119
+ {
120
+ name: 'Item with 7% VAT',
121
+ unitQuantity: 1,
122
+ unitNetPrice: 230,
123
+ unitType: 'hours',
124
+ vatPercentage: 7,
125
+ position: 8,
126
+ },
127
+ {
128
+ name: 'Item with 21% VAT',
129
+ unitQuantity: 1,
130
+ unitNetPrice: 230,
131
+ unitType: 'hours',
132
+ vatPercentage: 21,
133
+ position: 9,
134
+ },
135
+ {
136
+ name: 'Item with 0% VAT',
137
+ unitQuantity: 1,
138
+ unitNetPrice: 230,
139
+ unitType: 'hours',
140
+ vatPercentage: 0,
141
+ position: 10,
103
142
  },
104
143
  ],
105
144
  }