@design.estate/dees-document 1.1.0 → 1.3.1

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.
Files changed (97) hide show
  1. package/dist_bundle/bundle.js +148 -144
  2. package/dist_bundle/bundle.js.map +4 -4
  3. package/dist_ts/00_commitinfo_data.js +3 -3
  4. package/dist_ts/interfaces/document.d.ts +2 -0
  5. package/dist_ts/interfaces/document.js +2 -2
  6. package/dist_ts/interfaces/translation.d.ts +17 -2
  7. package/dist_ts/shared/demoletter.d.ts +4 -0
  8. package/dist_ts/shared/demoletter.js +214 -0
  9. package/{dist_ts_web/elements → dist_ts}/shared/index.d.ts +2 -0
  10. package/dist_ts/shared/index.js +8 -0
  11. package/dist_ts/shared/translation.d.ts +15 -0
  12. package/dist_ts/shared/translation.js +73 -0
  13. package/dist_ts_web/ts/interfaces/document.d.ts +7 -0
  14. package/dist_ts_web/ts/interfaces/document.js +2 -0
  15. package/dist_ts_web/ts/interfaces/index.d.ts +2 -0
  16. package/dist_ts_web/ts/interfaces/index.js +3 -0
  17. package/dist_ts_web/ts/interfaces/translation.d.ts +19 -0
  18. package/dist_ts_web/ts/interfaces/translation.js +2 -0
  19. package/dist_ts_web/ts/shared/demoletter.d.ts +4 -0
  20. package/dist_ts_web/ts/shared/demoletter.js +214 -0
  21. package/dist_ts_web/ts/shared/index.d.ts +7 -0
  22. package/dist_ts_web/ts/shared/index.js +8 -0
  23. package/dist_ts_web/ts/shared/translation.d.ts +15 -0
  24. package/dist_ts_web/ts/shared/translation.js +73 -0
  25. package/dist_ts_web/{00_commitinfo_data.d.ts → ts_web/00_commitinfo_data.d.ts} +1 -1
  26. package/dist_ts_web/ts_web/00_commitinfo_data.js +9 -0
  27. package/dist_ts_web/{elements → ts_web/elements}/contentinvoice.d.ts +3 -1
  28. package/dist_ts_web/{elements → ts_web/elements}/contentinvoice.js +21 -14
  29. package/dist_ts_web/{elements → ts_web/elements}/document.d.ts +5 -2
  30. package/dist_ts_web/ts_web/elements/document.demo.js +6 -0
  31. package/dist_ts_web/ts_web/elements/document.js +226 -0
  32. package/dist_ts_web/{elements → ts_web/elements}/index.d.ts +1 -1
  33. package/dist_ts_web/{elements → ts_web/elements}/index.js +2 -2
  34. package/dist_ts_web/{elements → ts_web/elements}/letterheader.js +2 -2
  35. package/dist_ts_web/{elements → ts_web/elements}/page.d.ts +2 -0
  36. package/dist_ts_web/ts_web/elements/page.js +221 -0
  37. package/dist_ts_web/{elements → ts_web/elements}/pagecontainer.js +2 -2
  38. package/dist_ts_web/{elements → ts_web/elements}/pagecontent.js +2 -2
  39. package/dist_ts_web/{elements → ts_web/elements}/pagefooter.d.ts +2 -0
  40. package/dist_ts_web/{elements → ts_web/elements}/pagefooter.js +15 -8
  41. package/dist_ts_web/{elements → ts_web/elements}/pageheader.d.ts +2 -0
  42. package/dist_ts_web/{elements → ts_web/elements}/pageheader.js +20 -7
  43. package/dist_ts_web/{elements → ts_web/elements}/viewer.d.ts +2 -0
  44. package/dist_ts_web/ts_web/elements/viewer.demo.js +6 -0
  45. package/dist_ts_web/{elements → ts_web/elements}/viewer.js +3 -2
  46. package/dist_ts_web/{index.js → ts_web/index.js} +1 -1
  47. package/dist_ts_web/{pages → ts_web/pages}/index.js +1 -1
  48. package/dist_ts_web/ts_web/pages/page1.js +18 -0
  49. package/dist_ts_web/{pages → ts_web/pages}/page2.js +1 -1
  50. package/dist_ts_web/ts_web/plugins.js +11 -0
  51. package/npmextra.json +13 -12
  52. package/package.json +16 -14
  53. package/readme.md +129 -121
  54. package/ts/00_commitinfo_data.ts +2 -2
  55. package/ts/interfaces/document.ts +3 -0
  56. package/ts/interfaces/translation.ts +17 -2
  57. package/{ts_web/elements → ts}/shared/demoletter.ts +10 -1
  58. package/{ts_web/elements → ts}/shared/index.ts +1 -1
  59. package/ts/shared/translation.ts +82 -0
  60. package/ts_web/00_commitinfo_data.ts +2 -2
  61. package/ts_web/elements/contentinvoice.ts +15 -9
  62. package/ts_web/elements/document.demo.ts +1 -1
  63. package/ts_web/elements/document.ts +3 -1
  64. package/ts_web/elements/index.ts +1 -1
  65. package/ts_web/elements/letterheader.ts +1 -1
  66. package/ts_web/elements/page.ts +6 -2
  67. package/ts_web/elements/pagecontainer.ts +1 -1
  68. package/ts_web/elements/pagecontent.ts +1 -1
  69. package/ts_web/elements/pagefooter.ts +14 -6
  70. package/ts_web/elements/pageheader.ts +10 -2
  71. package/ts_web/elements/viewer.demo.ts +2 -2
  72. package/ts_web/elements/viewer.ts +4 -1
  73. package/ts_web/pages/page1.ts +1 -1
  74. package/dist_ts_web/00_commitinfo_data.js +0 -9
  75. package/dist_ts_web/elements/document.demo.js +0 -6
  76. package/dist_ts_web/elements/document.js +0 -193
  77. package/dist_ts_web/elements/page.js +0 -195
  78. package/dist_ts_web/elements/shared/demoletter.d.ts +0 -2
  79. package/dist_ts_web/elements/shared/demoletter.js +0 -117
  80. package/dist_ts_web/elements/shared/index.js +0 -6
  81. package/dist_ts_web/elements/viewer.demo.js +0 -6
  82. package/dist_ts_web/pages/page1.js +0 -18
  83. package/dist_ts_web/plugins.js +0 -11
  84. package/dist_watch/bundle.js +0 -40041
  85. package/dist_watch/bundle.js.map +0 -7
  86. package/dist_watch/index.html +0 -28
  87. package/ts_web/elements/shared/translation.ts +0 -31
  88. /package/dist_ts_web/{elements → ts_web/elements}/document.demo.d.ts +0 -0
  89. /package/dist_ts_web/{elements → ts_web/elements}/letterheader.d.ts +0 -0
  90. /package/dist_ts_web/{elements → ts_web/elements}/pagecontainer.d.ts +0 -0
  91. /package/dist_ts_web/{elements → ts_web/elements}/pagecontent.d.ts +0 -0
  92. /package/dist_ts_web/{elements → ts_web/elements}/viewer.demo.d.ts +0 -0
  93. /package/dist_ts_web/{index.d.ts → ts_web/index.d.ts} +0 -0
  94. /package/dist_ts_web/{pages → ts_web/pages}/index.d.ts +0 -0
  95. /package/dist_ts_web/{pages → ts_web/pages}/page1.d.ts +0 -0
  96. /package/dist_ts_web/{pages → ts_web/pages}/page2.d.ts +0 -0
  97. /package/dist_ts_web/{plugins.d.ts → ts_web/plugins.d.ts} +0 -0
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@design.estate/dees-document",
3
- "version": "1.1.0",
3
+ "version": "1.3.1",
4
4
  "private": false,
5
- "description": "A versatile tool for dynamically generating and rendering business documents, such as invoices, using modern web technologies and elements.",
5
+ "description": "A sophisticated framework for dynamically generating and rendering business documents like invoices with modern web technologies, featuring PDF creation, templating, and automation.",
6
6
  "main": "dist_ts_web/index.js",
7
7
  "typings": "dist_ts_web/index.d.ts",
8
8
  "exports": {
@@ -22,6 +22,7 @@
22
22
  "@push.rocks/smartpdf": "^3.1.8",
23
23
  "@push.rocks/smarttime": "^4.0.8",
24
24
  "@tsclass/tsclass": "^4.1.2",
25
+ "@types/node": "^22.10.1",
25
26
  "@types/qrcode": "^1.5.5",
26
27
  "qrcode": "^1.5.4"
27
28
  },
@@ -59,26 +60,27 @@
59
60
  "homepage": "https://gitlab.com/designestate/private/dedocument-catalog#readme",
60
61
  "keywords": [
61
62
  "document generation",
62
- "invoices",
63
+ "invoice automation",
64
+ "business documentation",
65
+ "dynamic rendering",
63
66
  "PDF creation",
64
- "TypeScript",
65
67
  "web components",
68
+ "Node.js",
69
+ "TypeScript",
66
70
  "templating",
67
- "dynamic rendering",
71
+ "modern web technologies",
68
72
  "responsive design",
69
- "business documentation",
70
- "automated workflows",
71
- "modular architecture",
72
- "smart contracts",
73
- "javascript",
74
73
  "QR code",
75
- "custom elements",
76
- "nodejs",
77
- "data-driven"
74
+ "modular architecture",
75
+ "automated workflows",
76
+ "localization",
77
+ "digital signatures",
78
+ "security",
79
+ "interactive documents"
78
80
  ],
79
81
  "scripts": {
80
82
  "test": "npm run build && tstest test/",
81
- "build": "tsbuild --allowimplicitany && tsbuild element --allowimplicitany && tsbundle element --production",
83
+ "build": "tsbuild tsfolders --allowimplicitany && tsbuild element --allowimplicitany && tsbundle element --production",
82
84
  "watch": "tswatch element",
83
85
  "buildDocs": "tsdoc"
84
86
  }
package/readme.md CHANGED
@@ -1,169 +1,177 @@
1
1
  # @design.estate/dees-document
2
2
 
3
- A comprehensive solution for generating documents like invoices, integrating elements, templates, and services to streamline document creation.
3
+ A comprehensive tool for dynamically generating and rendering business documents like invoices using modern web technologies.
4
4
 
5
5
  ## Install
6
6
 
7
- To add `@design.estate/dees-document` to your project, run the following command in your terminal:
7
+ To incorporate `@design.estate/dees-document` into your project, execute the following command in your terminal:
8
8
 
9
9
  ```shell
10
10
  npm install @design.estate/dees-document --save
11
11
  ```
12
12
 
13
- This will install the package and add it to your project's dependencies, ensuring all required modules are available in your `node_modules` directory.
13
+ This command will install the package and add it to your project's dependencies, thus making all the necessary modules available within your `node_modules` directory.
14
14
 
15
15
  ## Usage
16
16
 
17
- The `@design.estate/dees-document` package provides a robust framework for creating documents including invoices, contracts, and various other business-related documents. It is built on modern web technologies including TypeScript and ES modules to ensure a type-safe and easy-to-integrate experience. Below, we will guide you through the comprehensive usage of this package, from setting up your environment to generating PDF documents.
17
+ The `@design.estate/dees-document` package serves as a robust framework to facilitate the generation of business documents, such as invoices, contracts, and reports. Leveraging modern web technologies, this package integrates seamlessly with TypeScript and ES modules, offering a type-safe environment conducive to efficient, dynamic document creation.
18
18
 
19
- ### Getting Started
19
+ Below, we provide a detailed guide for utilizing this package, from initializing your environment to generating complete PDF documents.
20
20
 
21
- Before creating documents, initialize the document service which is central to this package. This is typically done at the beginning of your application.
21
+ ### Setting Up the Environment
22
+
23
+ Before diving into document creation, ensure your environment is properly configured. Make sure to import necessary dependencies and setup configurations:
22
24
 
23
25
  ```typescript
24
26
  import { PdfService, IPdfServiceConstructorOptions } from '@design.estate/dees-document';
25
27
 
26
28
  async function setupPdfService() {
27
29
  const options: IPdfServiceConstructorOptions = {
28
- // Add necessary configuration here
30
+ // Configure your options here
29
31
  };
30
-
32
+
31
33
  const pdfService = await PdfService.createAndStart(options);
32
34
  console.log('PDF Service started successfully.');
33
35
  return pdfService;
34
36
  }
35
37
  ```
36
38
 
37
- This script initializes `PdfService`. Modify the options to tailor the service to your needs.
38
-
39
- ### Creating Documents
40
-
41
- With the PDF service ready, you can proceed to generate documents. The following section provides a detailed example of creating an invoice. This example is applicable to various document types with necessary adjustments.
42
-
43
- #### Step-by-Step: Create an Invoice
44
-
45
- 1. **Define the Data Structure**: Describe the invoice details. This includes sender and recipient information, the items being invoiced, and more.
46
-
47
- ```typescript
48
- import { ILetter } from '@design.estate/dees-document';
49
-
50
- const invoiceData: ILetter = {
51
- from: {
52
- name: "Your Company Name",
53
- address: {
54
- streetName: "Your Street",
55
- houseNumber: "123",
56
- city: "Your City",
57
- country: "Your Country",
58
- postalCode: "12345",
59
- },
60
- email: "your-email@example.com",
61
- phone: "123-456-7890",
62
- },
63
- to: {
64
- name: "Recipient Company Name",
65
- address: {
66
- streetName: "Recipient Street",
67
- houseNumber: "456",
68
- city: "Recipient City",
69
- country: "Recipient Country",
70
- postalCode: "67890",
71
- },
72
- email: "recipient-email@example.com",
73
- phone: "098-765-4321",
74
- },
75
- content: {
76
- invoiceData: {
77
- items: [
78
- {
79
- name: "Service or Product Name",
80
- unitQuantity: 2,
81
- unitNetPrice: 100.00,
82
- unitType: 'service',
83
- vatPercentage: 19,
84
- currency: 'EUR',
85
- }
86
- ]
87
- }
88
- },
89
- subject: "Invoice for Services Rendered",
90
- date: new Date().getTime(),
91
- versionInfo: {
92
- type: "final",
93
- version: "1.0.0"
94
- },
95
- };
96
- ```
39
+ In this setup snippet, you set up the `PdfService` which is the core component for PDF generation. The configuration options should be adjusted to fit your needs, especially considering options such as file paths, languages, and template directories.
40
+
41
+ ### Creating a Document Template
42
+
43
+ To create documents, particularly invoices, you'll first need to define a template. This template describes the structure of your document:
44
+
45
+ ```typescript
46
+ import { ILetter } from '@design.estate/dees-document';
47
+
48
+ const invoiceTemplate: ILetter = {
49
+ from: {
50
+ name: "Your Company Name",
51
+ address: {
52
+ streetName: "Your Street",
53
+ houseNumber: "123",
54
+ city: "Your City",
55
+ country: "Your Country",
56
+ postalCode: "12345",
57
+ },
58
+ email: "your-email@example.com",
59
+ phone: "123-456-7890",
60
+ },
61
+ to: {
62
+ name: "Recipient Company Name",
63
+ address: {
64
+ streetName: "Recipient Street",
65
+ houseNumber: "456",
66
+ city: "Recipient City",
67
+ country: "Recipient Country",
68
+ postalCode: "67890",
69
+ },
70
+ email: "recipient-email@example.com",
71
+ phone: "098-765-4321",
72
+ },
73
+ content: {
74
+ invoiceData: {
75
+ items: [
76
+ {
77
+ name: "Service or Product Name",
78
+ unitQuantity: 2,
79
+ unitNetPrice: 100.00,
80
+ unitType: 'service',
81
+ vatPercentage: 19,
82
+ currency: 'EUR',
83
+ }
84
+ ]
85
+ }
86
+ },
87
+ subject: "Invoice for Services Rendered",
88
+ date: new Date().getTime(),
89
+ versionInfo: {
90
+ type: "final",
91
+ version: "1.0.0"
92
+ },
93
+ };
94
+ ```
97
95
 
98
- Here, `ILetter` interface details all components of an invoice including sender (`from`) and recipient (`to`) information, as well as the invoiced items.
96
+ The `invoiceTemplate` object utilizes the `ILetter` interface which specifies the structure for invoice data, including sender and recipient details, itemization, and pricing.
99
97
 
100
- 2. **Generate the PDF**: Transform the invoice details into a PDF.
98
+ ### Generating the Document
101
99
 
102
- ```typescript
103
- async function generateInvoice(pdfService: PdfService, invoiceData: ILetter) {
104
- const pdfBuffer = await pdfService.createPdfFromLetterObject(invoiceData);
105
- console.log('Invoice PDF generated successfully.');
100
+ Once a template is established, the next step is generating a PDF:
106
101
 
107
- // Save the PDF, send it via email, etc.
108
- }
109
- ```
102
+ ```typescript
103
+ async function generateInvoice(pdfService: PdfService, invoiceData: ILetter) {
104
+ const pdfBuffer = await pdfService.createPdfFromLetterObject(invoiceData);
105
+ console.log('Invoice PDF generated successfully.');
110
106
 
111
- The function `createPdfFromLetterObject` returns a `Buffer` containing the generated PDF. From here, you can save this PDF to a file, send it to clients, or archive it.
107
+ // Here you could save the PDF to your filesystem, send it via email, etc.
108
+ }
109
+ ```
112
110
 
113
- 3. **Integrate It All**: Here's how everything ties together into a complete script for generating an invoice:
111
+ In this function, the `createPdfFromLetterObject` method converts your invoice data into a `Buffer` containing the PDF. This `Buffer` can subsequently be saved as a file or sent over HTTP.
114
112
 
115
- ```typescript
116
- async function main() {
117
- const pdfService = await setupPdfService();
118
- await generateInvoice(pdfService, invoiceData);
119
- }
113
+ ### Comprehensive Example
120
114
 
121
- main().then(() => console.log('Invoice generation process completed.'));
122
- ```
115
+ Below is an example integrating all previous steps into a single coherent script:
123
116
 
124
- This script initiates the PDF service and generates the invoice PDF with the provided information.
117
+ ```typescript
118
+ async function main() {
119
+ const pdfService = await setupPdfService();
120
+ const invoiceData: ILetter = {
121
+ // Populate your invoice object
122
+ };
123
+ await generateInvoice(pdfService, invoiceData);
124
+ }
125
125
 
126
- ### Advanced Document Features
126
+ main().then(() => console.log('Invoice generation process completed.'));
127
+ ```
127
128
 
128
- The package is designed to create not only invoices but a wide range of document types. Leverage its modular architecture to build and customize documents to fit specific needs.
129
+ This script encompasses initializing services and generating a PDF in a streamlined, efficient workflow.
129
130
 
130
- #### Advanced Scenarios
131
+ ### Advanced Features
131
132
 
132
- 1. **Custom Styling**: Customize the appearance of elements within your documents, such as headers, footers, and more.
133
+ `@design.estate/dees-document` provides several advanced functionalities, enabling rich document creation:
134
+
135
+ 1. **Custom Templates & Styling**
136
+ - Customize the styling through CSS or using inline styles in TypeScript.
137
+ - Templates can be adjusted to present different document types (e.g., contracts, reports).
138
+
139
+ 2. **Modular Components and Reuse**
140
+ - Utilize modular components to create reusable parts across different documents, enhancing maintainability and reducing redundancy.
141
+
142
+ 3. **Interactive Documents**
143
+ - Integrate interactivities like forms, buttons, and interactive charts within your documents.
144
+
145
+ 4. **Localization Support**
146
+ - Documents can be localized to support multiple languages, enhancing accessibility and usability.
147
+
148
+ 5. **Responsive and Adaptive Designs**
149
+ - Create documents that adjust layout dynamically depending on print or digital medium, maintaining consistency across platforms.
150
+
151
+ 6. **Security Features**
152
+ - Apply digital signatures and encrypt sensitive documents to ensure secure and authentic document distribution.
153
+
154
+ 7. **Complex Business Logic**
155
+ - Implement complex logic for feature-rich documents such as inventory systems, automatic tax calculations, or real-time pricing adjustments.
156
+
157
+ ### Utilize Translation for Localization
158
+
159
+ The package offers a translation mechanism to adapt your documents for international clients:
160
+
161
+ ```typescript
162
+ import { translate } from '@design.estate/dees-document/shared';
163
+
164
+ const languageCode: 'DE' | 'EN' | 'ES' = 'EN'; // Set required language code
165
+ console.log(translate(languageCode, 'invoice', 'Invoice')); // Translated output
166
+ ```
133
167
 
134
- ```typescript
135
- import { DeDocumentViewer } from '@design.estate/dees-element';
168
+ Different language settings can be applied, enabling the seamless presentation of document contents tailored to regional and linguistic preferences.
136
169
 
137
- const customStyledViewer = new DeDocumentViewer();
138
- customStyledViewer.style.setProperty('--main-bg-color', 'lightblue');
139
- document.body.appendChild(customStyledViewer);
140
- ```
141
-
142
- Customize via CSS or dynamically through TypeScript where necessary.
143
-
144
- 2. **Interactive Document Elements**: Incorporate UI components like buttons, input fields, or visualizations tailored for your document needs.
145
-
146
- 3. **Multi-page Document Generation**: Handle overflow of content and automatic page generation while maintaining headers and footers.
147
-
148
- ```typescript
149
- pdfService.adjustDePageScaling();
150
- ```
151
-
152
- Toggle between print and digital formats and handle scaling.
153
-
154
- 4. **Embedding Images and Logos**: Add company logos, graphics, or auxiliary content to enhance document presentation.
155
-
156
- ### Additional Capabilities
157
-
158
- Beyond these examples, delve deeper into advanced functionalities such as:
159
-
160
- - **Document Management**: Manage multiple document templates, manage versions, and add annotations or notes.
161
- - **Dynamic Rendering**: Use templating for dynamic content rendering based on variable inputs.
162
- - **Responsive Design for Digital Documents**: Ensure documents are displayed correctly across devices.
170
+ ### Conclusion
163
171
 
164
- ### Concluding Remarks
172
+ The `@design.estate/dees-document` package is a versatile and powerful solution for businesses seeking to automate and streamline their document generation processes using modern web technologies. By integrating seamlessly with TypeScript, it offers robust capabilities for creating complex, customizable, and interactive documents that can meet a variety of business needs.
165
173
 
166
- The `@design.estate/dees-document` package is an essential tool in the modern document generation ecosystem. Its expansive capabilities, from basic invoices to complex document templates, make it a versatile solution for businesses of all scales. Implementing this service broadly simplifies document management workflows and enhances document presentation precision and quality. For further depth, consult the package's documentation or explore the examples included in the module.
174
+ From custom templates to localization and advanced security features, this module provides the flexibility and power to create polished and professional documents efficiently. Whether you're generating invoices, contracts, or detailed reports, `@design.estate/dees-document` has the tools to support your enterprise workflows with ease and precision.
167
175
 
168
176
  ## License and Legal Information
169
177
 
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@design.estate/dees-document',
6
- version: '1.1.0',
7
- description: 'A versatile tool for dynamically generating and rendering business documents, such as invoices, using modern web technologies and elements.'
6
+ version: '1.3.1',
7
+ description: 'A sophisticated framework for dynamically generating and rendering business documents like invoices with modern web technologies, featuring PDF creation, templating, and automation.'
8
8
  }
@@ -1,5 +1,8 @@
1
+ import * as shared from '../shared/index.js';
2
+
1
3
  export interface IDocumentSettings {
2
4
  enableTopDraftText?: boolean;
3
5
  enableDefaultHeader?: boolean;
4
6
  enableDefaultFooter?: boolean;
7
+ languageCode?: shared.translation.TLanguageCode;
5
8
  }
@@ -1,4 +1,19 @@
1
1
  export interface IDeDocumentTranslations {
2
- "invoice": string;
3
- "quantity": string;
2
+ address: string;
3
+ bankConnection: string;
4
+ contactInfo: string;
5
+ description: string;
6
+ invoice: string;
7
+ itemPos: string;
8
+ quantity: string;
9
+ registrationInfo: string;
10
+ reverseVatNote: string;
11
+ totalNetPrice: string;
12
+ unitNetPrice: string;
13
+ unitType: string;
14
+ yourCustomerId: string;
15
+ yourVatId: string;
16
+ continuesOnPage: string;
17
+ finalPageStatement: string;
18
+ page: string;
4
19
  }
@@ -1,4 +1,6 @@
1
1
  import * as tsclass from '@tsclass/tsclass';
2
+ import * as interfaces from '../interfaces/index.js';
3
+
2
4
  const fromContact: tsclass.business.IContact = {
3
5
  name: 'Awesome From Company',
4
6
  type: 'company',
@@ -207,4 +209,11 @@ export const demoLetter: tsclass.business.ILetter = {
207
209
  logoUrl: null,
208
210
  pdfAttachments: null,
209
211
  subject: 'Invoice: LL-INV-48765',
210
- }
212
+ }
213
+
214
+ export const demoDocumentSettings: interfaces.IDocumentSettings = {
215
+ enableTopDraftText: true,
216
+ enableDefaultHeader: true,
217
+ enableDefaultFooter: true,
218
+ languageCode: 'DE',
219
+ };
@@ -6,4 +6,4 @@ export const leftMargin = 90;
6
6
  import * as translation from './translation.js';
7
7
  export { translation };
8
8
 
9
- export * from './demoletter.js';
9
+ export * from './demoletter.js';
@@ -0,0 +1,82 @@
1
+ import * as interfaces from '../interfaces/index.js';
2
+
3
+ type TTranslationImplementation = {
4
+ [key in keyof interfaces.IDeDocumentTranslations]: string;
5
+ }
6
+
7
+ export const EN_translations: TTranslationImplementation = {
8
+ address: 'Address',
9
+ bankConnection: 'Bank Connection',
10
+ contactInfo: 'Contact Info',
11
+ description: 'Description',
12
+ invoice: 'Invoice',
13
+ itemPos: 'Item Pos.',
14
+ quantity: 'Quantity',
15
+ registrationInfo: 'Registration Info',
16
+ reverseVatNote: 'VAT arises on a reverse charge basis and is payable by the customer.',
17
+ totalNetPrice: 'Total Net Price',
18
+ unitNetPrice: 'Unit Net Price',
19
+ unitType: 'Unit Type',
20
+ yourCustomerId: 'Your Customer ID:',
21
+ yourVatId: 'Your vat id on file:',
22
+ continuesOnPage: 'Continues on page',
23
+ finalPageStatement: 'This is the final page of this document.',
24
+ page: 'Page',
25
+ };
26
+
27
+ export const DE_translations: TTranslationImplementation = {
28
+ address: 'Adresse',
29
+ bankConnection: 'Bankverbindung',
30
+ contactInfo: 'Kontaktinformationen',
31
+ description: 'Beschreibung',
32
+ invoice: 'Rechnung',
33
+ itemPos: 'Pos.',
34
+ quantity: 'Anzahl',
35
+ registrationInfo: 'HRA/HRB Info',
36
+ reverseVatNote: 'Umkehr der Umsatzsteuerpflicht: Der Rechnungsempfänger ist für die korrekte Abrechnung der Umsatzsteuer zuständig.',
37
+ totalNetPrice: 'Nettopreis Summe',
38
+ unitNetPrice: 'Nettopreis',
39
+ unitType: 'Einheit',
40
+ yourCustomerId: 'Ihre Kundennummer:',
41
+ yourVatId: 'Ihre Umsatzsteuer-ID:',
42
+ continuesOnPage: 'Fortsetzung auf Seite',
43
+ finalPageStatement: 'Diese ist die letzte Seite einer Dokumente.',
44
+ page: 'Seite',
45
+ };
46
+
47
+ export const ES_translations: TTranslationImplementation = {
48
+ address: 'Dirección',
49
+ bankConnection: 'Conexión bancaria',
50
+ contactInfo: 'Información de contacto',
51
+ description: 'Descripción',
52
+ invoice: 'Factura',
53
+ itemPos: 'Pos.',
54
+ quantity: 'Cantidad',
55
+ registrationInfo: 'Información de registro',
56
+ reverseVatNote: 'La declaración de IVA se aplica en base a la factura de venta, y se paga por el cliente.',
57
+ totalNetPrice: 'Precio total neto',
58
+ unitNetPrice: 'Precio unitario neto',
59
+ unitType: 'Tipo de unidad',
60
+ yourCustomerId: 'Su número de cliente:',
61
+ yourVatId: 'Su ID de IVA:',
62
+ continuesOnPage: 'Continues on page',
63
+ finalPageStatement: 'This is the final page of this document.',
64
+ page: 'Page',
65
+ };
66
+
67
+ export const languageCodeMap = {
68
+ 'DE': DE_translations,
69
+ 'EN': EN_translations,
70
+ 'ES': ES_translations,
71
+ };
72
+
73
+ export type TLanguageCode = keyof typeof languageCodeMap;
74
+
75
+ export const translate = (languageCode: TLanguageCode, key: string, defaultValue: string) => {
76
+ const translations = languageCodeMap[languageCode] || EN_translations;
77
+ if (translations && translations[key]) {
78
+ return translations[key];
79
+ } else {
80
+ return defaultValue;
81
+ }
82
+ };
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@design.estate/dees-document',
6
- version: '1.1.0',
7
- description: 'A versatile tool for dynamically generating and rendering business documents, such as invoices, using modern web technologies and elements.'
6
+ version: '1.3.1',
7
+ description: 'A sophisticated framework for dynamically generating and rendering business documents like invoices with modern web technologies, featuring PDF creation, templating, and automation.'
8
8
  }
@@ -15,8 +15,8 @@ import {
15
15
  domtools,
16
16
  } from '@design.estate/dees-element';
17
17
  import * as plugins from '../plugins.js';
18
- import * as shared from './shared/index.js';
19
-
18
+ import * as shared from '../../ts/shared/index.js';
19
+ import * as interfaces from '../../ts/interfaces/index.js';
20
20
 
21
21
 
22
22
  declare global {
@@ -45,6 +45,12 @@ export class DeContentInvoice extends DeesElement {
45
45
  })
46
46
  public letterData: plugins.tsclass.business.ILetter;
47
47
 
48
+ @property({
49
+ type: Object,
50
+ reflect: true,
51
+ })
52
+ public documentSettings: interfaces.IDocumentSettings;
53
+
48
54
  constructor() {
49
55
  super();
50
56
  domtools.DomTools.setupDomTools();
@@ -275,12 +281,12 @@ export class DeContentInvoice extends DeesElement {
275
281
  </style>
276
282
  <div>We hereby invoice products and services provided to you by Lossless GmbH:</div>
277
283
  <div class="grid topLine dataHeader">
278
- <div class="lineItem">Item Pos.</div>
279
- <div class="lineItem">${shared.translation.translate('DE', 'description', 'Description')}</div>
280
- <div class="lineItem">${shared.translation.translate('DE', 'quantity', 'Quantity')}</div>
281
- <div class="lineItem">Unit Type</div>
282
- <div class="lineItem">Unit Net Price</div>
283
- <div class="lineItem">Total Net Price</div>
284
+ <div class="lineItem">${shared.translation.translate(this.documentSettings.languageCode, 'itemPos', 'Item Pos.')}</div>
285
+ <div class="lineItem">${shared.translation.translate(this.documentSettings.languageCode, 'description', 'Description')}</div>
286
+ <div class="lineItem">${shared.translation.translate(this.documentSettings.languageCode, 'quantity', 'Quantity')}</div>
287
+ <div class="lineItem">${shared.translation.translate(this.documentSettings.languageCode, 'unitType', 'Unit Type')}</div>
288
+ <div class="lineItem">${shared.translation.translate(this.documentSettings.languageCode, 'unitNetPrice', 'Unit Net Price')}</div>
289
+ <div class="lineItem">${shared.translation.translate(this.documentSettings.languageCode, 'totalNetPrice', 'Total Net Price')}</div>
284
290
  </div>
285
291
  ${(() => {
286
292
  let counter = 1;
@@ -329,7 +335,7 @@ export class DeContentInvoice extends DeesElement {
329
335
  ${this.letterData?.content.invoiceData.reverseCharge
330
336
  ? html`
331
337
  <div class="taxNote">
332
- VAT arises on a reverse charge basis and is payable by the customer.
338
+ ${shared.translation.translate(this.documentSettings.languageCode, 'reverseVatNote', 'VAT arises on a reverse charge basis and is payable by the customer.')}
333
339
  </div>
334
340
  `
335
341
  : ``}
@@ -1,4 +1,4 @@
1
- import * as shared from './shared/index.js';
1
+ import * as shared from '../../ts/shared/index.js';
2
2
  import { html } from '@design.estate/dees-element';
3
3
 
4
4
  export const demoFunc = () => html`
@@ -24,7 +24,7 @@ export const defaultDocumentSettings: interfaces.IDocumentSettings = {
24
24
  import { DePage } from './page.js';
25
25
  import { DeContentInvoice } from './contentinvoice.js';
26
26
 
27
- import * as shared from './shared/index.js';
27
+ import * as shared from '../../ts/shared/index.js';
28
28
  import { demoFunc } from './document.demo.js';
29
29
 
30
30
  declare global {
@@ -146,6 +146,7 @@ export class DeDocument extends DeesElement {
146
146
  // lets append the content
147
147
  const content: DeContentInvoice = new DeContentInvoice();
148
148
  content.letterData = this.letterData;
149
+ content.documentSettings = this.documentSettings;
149
150
  document.body.appendChild(content);
150
151
 
151
152
  await domtools.convenience.smartdelay.delayFor(0);
@@ -158,6 +159,7 @@ export class DeDocument extends DeesElement {
158
159
  const newPage = new DePage();
159
160
  newPage.printMode = this.printMode;
160
161
  newPage.letterData = this.letterData;
162
+ newPage.documentSettings = this.documentSettings;
161
163
  pages.push(newPage);
162
164
  newPage.pageNumber = pageCounter;
163
165
  newPage.append(currentContent);
@@ -8,4 +8,4 @@ export * from './pagefooter.js';
8
8
  export * from './pageheader.js';
9
9
  export * from './viewer.js';
10
10
 
11
- export * from './shared/index.js';
11
+ export * from '../../ts/shared/index.js';
@@ -10,7 +10,7 @@ import {
10
10
  } from '@design.estate/dees-element';
11
11
  import * as domtools from '@design.estate/dees-domtools';
12
12
 
13
- import * as shared from './shared/index.js';
13
+ import * as shared from '../../ts/shared/index.js';
14
14
  import * as tsclass from '@tsclass/tsclass';
15
15
 
16
16
  declare global {