@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.
- package/dist_bundle/bundle.js +148 -144
- package/dist_bundle/bundle.js.map +4 -4
- package/dist_ts/00_commitinfo_data.js +3 -3
- package/dist_ts/interfaces/document.d.ts +2 -0
- package/dist_ts/interfaces/document.js +2 -2
- package/dist_ts/interfaces/translation.d.ts +17 -2
- package/dist_ts/shared/demoletter.d.ts +4 -0
- package/dist_ts/shared/demoletter.js +214 -0
- package/{dist_ts_web/elements → dist_ts}/shared/index.d.ts +2 -0
- package/dist_ts/shared/index.js +8 -0
- package/dist_ts/shared/translation.d.ts +15 -0
- package/dist_ts/shared/translation.js +73 -0
- package/dist_ts_web/ts/interfaces/document.d.ts +7 -0
- package/dist_ts_web/ts/interfaces/document.js +2 -0
- package/dist_ts_web/ts/interfaces/index.d.ts +2 -0
- package/dist_ts_web/ts/interfaces/index.js +3 -0
- package/dist_ts_web/ts/interfaces/translation.d.ts +19 -0
- package/dist_ts_web/ts/interfaces/translation.js +2 -0
- package/dist_ts_web/ts/shared/demoletter.d.ts +4 -0
- package/dist_ts_web/ts/shared/demoletter.js +214 -0
- package/dist_ts_web/ts/shared/index.d.ts +7 -0
- package/dist_ts_web/ts/shared/index.js +8 -0
- package/dist_ts_web/ts/shared/translation.d.ts +15 -0
- package/dist_ts_web/ts/shared/translation.js +73 -0
- package/dist_ts_web/{00_commitinfo_data.d.ts → ts_web/00_commitinfo_data.d.ts} +1 -1
- package/dist_ts_web/ts_web/00_commitinfo_data.js +9 -0
- package/dist_ts_web/{elements → ts_web/elements}/contentinvoice.d.ts +3 -1
- package/dist_ts_web/{elements → ts_web/elements}/contentinvoice.js +21 -14
- package/dist_ts_web/{elements → ts_web/elements}/document.d.ts +5 -2
- package/dist_ts_web/ts_web/elements/document.demo.js +6 -0
- package/dist_ts_web/ts_web/elements/document.js +226 -0
- package/dist_ts_web/{elements → ts_web/elements}/index.d.ts +1 -1
- package/dist_ts_web/{elements → ts_web/elements}/index.js +2 -2
- package/dist_ts_web/{elements → ts_web/elements}/letterheader.js +2 -2
- package/dist_ts_web/{elements → ts_web/elements}/page.d.ts +2 -0
- package/dist_ts_web/ts_web/elements/page.js +221 -0
- package/dist_ts_web/{elements → ts_web/elements}/pagecontainer.js +2 -2
- package/dist_ts_web/{elements → ts_web/elements}/pagecontent.js +2 -2
- package/dist_ts_web/{elements → ts_web/elements}/pagefooter.d.ts +2 -0
- package/dist_ts_web/{elements → ts_web/elements}/pagefooter.js +15 -8
- package/dist_ts_web/{elements → ts_web/elements}/pageheader.d.ts +2 -0
- package/dist_ts_web/{elements → ts_web/elements}/pageheader.js +20 -7
- package/dist_ts_web/{elements → ts_web/elements}/viewer.d.ts +2 -0
- package/dist_ts_web/ts_web/elements/viewer.demo.js +6 -0
- package/dist_ts_web/{elements → ts_web/elements}/viewer.js +3 -2
- package/dist_ts_web/{index.js → ts_web/index.js} +1 -1
- package/dist_ts_web/{pages → ts_web/pages}/index.js +1 -1
- package/dist_ts_web/ts_web/pages/page1.js +18 -0
- package/dist_ts_web/{pages → ts_web/pages}/page2.js +1 -1
- package/dist_ts_web/ts_web/plugins.js +11 -0
- package/npmextra.json +13 -12
- package/package.json +16 -14
- package/readme.md +129 -121
- package/ts/00_commitinfo_data.ts +2 -2
- package/ts/interfaces/document.ts +3 -0
- package/ts/interfaces/translation.ts +17 -2
- package/{ts_web/elements → ts}/shared/demoletter.ts +10 -1
- package/{ts_web/elements → ts}/shared/index.ts +1 -1
- package/ts/shared/translation.ts +82 -0
- package/ts_web/00_commitinfo_data.ts +2 -2
- package/ts_web/elements/contentinvoice.ts +15 -9
- package/ts_web/elements/document.demo.ts +1 -1
- package/ts_web/elements/document.ts +3 -1
- package/ts_web/elements/index.ts +1 -1
- package/ts_web/elements/letterheader.ts +1 -1
- package/ts_web/elements/page.ts +6 -2
- package/ts_web/elements/pagecontainer.ts +1 -1
- package/ts_web/elements/pagecontent.ts +1 -1
- package/ts_web/elements/pagefooter.ts +14 -6
- package/ts_web/elements/pageheader.ts +10 -2
- package/ts_web/elements/viewer.demo.ts +2 -2
- package/ts_web/elements/viewer.ts +4 -1
- package/ts_web/pages/page1.ts +1 -1
- package/dist_ts_web/00_commitinfo_data.js +0 -9
- package/dist_ts_web/elements/document.demo.js +0 -6
- package/dist_ts_web/elements/document.js +0 -193
- package/dist_ts_web/elements/page.js +0 -195
- package/dist_ts_web/elements/shared/demoletter.d.ts +0 -2
- package/dist_ts_web/elements/shared/demoletter.js +0 -117
- package/dist_ts_web/elements/shared/index.js +0 -6
- package/dist_ts_web/elements/viewer.demo.js +0 -6
- package/dist_ts_web/pages/page1.js +0 -18
- package/dist_ts_web/plugins.js +0 -11
- package/dist_watch/bundle.js +0 -40041
- package/dist_watch/bundle.js.map +0 -7
- package/dist_watch/index.html +0 -28
- package/ts_web/elements/shared/translation.ts +0 -31
- /package/dist_ts_web/{elements → ts_web/elements}/document.demo.d.ts +0 -0
- /package/dist_ts_web/{elements → ts_web/elements}/letterheader.d.ts +0 -0
- /package/dist_ts_web/{elements → ts_web/elements}/pagecontainer.d.ts +0 -0
- /package/dist_ts_web/{elements → ts_web/elements}/pagecontent.d.ts +0 -0
- /package/dist_ts_web/{elements → ts_web/elements}/viewer.demo.d.ts +0 -0
- /package/dist_ts_web/{index.d.ts → ts_web/index.d.ts} +0 -0
- /package/dist_ts_web/{pages → ts_web/pages}/index.d.ts +0 -0
- /package/dist_ts_web/{pages → ts_web/pages}/page1.d.ts +0 -0
- /package/dist_ts_web/{pages → ts_web/pages}/page2.d.ts +0 -0
- /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
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "A
|
|
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
|
-
"
|
|
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
|
-
"
|
|
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
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
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
|
-
|
|
19
|
+
Below, we provide a detailed guide for utilizing this package, from initializing your environment to generating complete PDF documents.
|
|
20
20
|
|
|
21
|
-
|
|
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
|
-
//
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
### Creating
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
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
|
-
|
|
98
|
+
### Generating the Document
|
|
101
99
|
|
|
102
|
-
|
|
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
|
-
|
|
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
|
-
|
|
107
|
+
// Here you could save the PDF to your filesystem, send it via email, etc.
|
|
108
|
+
}
|
|
109
|
+
```
|
|
112
110
|
|
|
113
|
-
|
|
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
|
-
|
|
116
|
-
async function main() {
|
|
117
|
-
const pdfService = await setupPdfService();
|
|
118
|
-
await generateInvoice(pdfService, invoiceData);
|
|
119
|
-
}
|
|
113
|
+
### Comprehensive Example
|
|
120
114
|
|
|
121
|
-
|
|
122
|
-
```
|
|
115
|
+
Below is an example integrating all previous steps into a single coherent script:
|
|
123
116
|
|
|
124
|
-
|
|
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
|
-
|
|
126
|
+
main().then(() => console.log('Invoice generation process completed.'));
|
|
127
|
+
```
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
This script encompasses initializing services and generating a PDF in a streamlined, efficient workflow.
|
|
129
130
|
|
|
130
|
-
|
|
131
|
+
### Advanced Features
|
|
131
132
|
|
|
132
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@design.estate/dees-document',
|
|
6
|
-
version: '1.1
|
|
7
|
-
description: 'A
|
|
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,4 +1,19 @@
|
|
|
1
1
|
export interface IDeDocumentTranslations {
|
|
2
|
-
|
|
3
|
-
|
|
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
|
+
};
|
|
@@ -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
|
|
7
|
-
description: 'A
|
|
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 '
|
|
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"
|
|
279
|
-
<div class="lineItem">${shared.translation.translate(
|
|
280
|
-
<div class="lineItem">${shared.translation.translate(
|
|
281
|
-
<div class="lineItem"
|
|
282
|
-
<div class="lineItem"
|
|
283
|
-
<div class="lineItem"
|
|
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
|
: ``}
|
|
@@ -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 '
|
|
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);
|
package/ts_web/elements/index.ts
CHANGED
|
@@ -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 '
|
|
13
|
+
import * as shared from '../../ts/shared/index.js';
|
|
14
14
|
import * as tsclass from '@tsclass/tsclass';
|
|
15
15
|
|
|
16
16
|
declare global {
|