@design.estate/dees-document 1.0.103 → 1.3.0
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 +213 -198
- package/dist_bundle/bundle.js.map +4 -4
- package/dist_ts/00_commitinfo_data.js +3 -3
- package/dist_ts/classes.pdfservice.d.ts +5 -1
- package/dist_ts/classes.pdfservice.js +4 -3
- package/dist_ts/interfaces/document.d.ts +7 -0
- package/dist_ts/interfaces/document.js +2 -0
- package/dist_ts/interfaces/index.d.ts +2 -0
- package/dist_ts/interfaces/index.js +3 -0
- package/dist_ts/interfaces/translation.d.ts +19 -0
- package/dist_ts/interfaces/translation.js +2 -0
- package/dist_ts/shared/demoletter.d.ts +4 -0
- package/dist_ts/shared/demoletter.js +214 -0
- package/dist_ts/shared/index.d.ts +7 -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_watch/bundle.js +200 -55
- package/dist_watch/bundle.js.map +4 -4
- package/npmextra.json +10 -12
- package/package.json +13 -14
- package/readme.md +131 -87
- package/ts/00_commitinfo_data.ts +2 -2
- package/ts/classes.pdfservice.ts +6 -2
- package/ts/interfaces/document.ts +8 -0
- package/ts/interfaces/index.ts +2 -0
- package/ts/interfaces/translation.ts +19 -0
- package/{ts_web/elements → ts}/shared/demoletter.ts +10 -1
- package/{ts_web/elements → ts}/shared/index.ts +4 -1
- package/ts/shared/translation.ts +82 -0
- package/ts_web/00_commitinfo_data.ts +2 -2
- package/ts_web/elements/contentinvoice.ts +16 -11
- package/ts_web/elements/document.demo.ts +1 -1
- package/ts_web/elements/document.ts +20 -8
- package/ts_web/elements/index.ts +1 -1
- package/ts_web/elements/letterheader.ts +1 -1
- package/ts_web/elements/page.ts +51 -22
- 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 +19 -5
- 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/npmextra.json
CHANGED
|
@@ -5,28 +5,26 @@
|
|
|
5
5
|
"githost": "code.foss.global",
|
|
6
6
|
"gitscope": "designestate/private",
|
|
7
7
|
"gitrepo": "dedocument-catalog",
|
|
8
|
-
"description": "A comprehensive
|
|
8
|
+
"description": "A comprehensive tool for dynamically generating and rendering business documents like invoices using modern web technologies.",
|
|
9
9
|
"npmPackagename": "@designestate_private/dedocument-catalog",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"projectDomain": "design.estate",
|
|
12
12
|
"shortDescription": "undefined variable",
|
|
13
13
|
"keywords": [
|
|
14
14
|
"document generation",
|
|
15
|
-
"
|
|
15
|
+
"invoice automation",
|
|
16
|
+
"business documentation",
|
|
17
|
+
"dynamic rendering",
|
|
16
18
|
"PDF creation",
|
|
17
|
-
"typescript",
|
|
18
19
|
"web components",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"smart contracts",
|
|
20
|
+
"Node.js",
|
|
21
|
+
"TypeScript",
|
|
22
22
|
"templating",
|
|
23
|
-
"
|
|
23
|
+
"modern web technologies",
|
|
24
24
|
"responsive design",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"finance",
|
|
29
|
-
"business"
|
|
25
|
+
"QR code",
|
|
26
|
+
"modular architecture",
|
|
27
|
+
"automated workflows"
|
|
30
28
|
]
|
|
31
29
|
}
|
|
32
30
|
},
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@design.estate/dees-document",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "A comprehensive
|
|
5
|
+
"description": "A comprehensive tool for dynamically generating and rendering business documents like invoices using modern web technologies.",
|
|
6
6
|
"main": "dist_ts_web/index.js",
|
|
7
7
|
"typings": "dist_ts_web/index.d.ts",
|
|
8
8
|
"exports": {
|
|
@@ -19,9 +19,10 @@
|
|
|
19
19
|
"@push.rocks/smartfile": "^11.0.21",
|
|
20
20
|
"@push.rocks/smartjson": "^5.0.20",
|
|
21
21
|
"@push.rocks/smartpath": "^5.0.18",
|
|
22
|
-
"@push.rocks/smartpdf": "^3.1.
|
|
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,21 +60,19 @@
|
|
|
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",
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"smart contracts",
|
|
68
|
+
"Node.js",
|
|
69
|
+
"TypeScript",
|
|
69
70
|
"templating",
|
|
70
|
-
"
|
|
71
|
+
"modern web technologies",
|
|
71
72
|
"responsive design",
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"finance",
|
|
76
|
-
"business"
|
|
73
|
+
"QR code",
|
|
74
|
+
"modular architecture",
|
|
75
|
+
"automated workflows"
|
|
77
76
|
],
|
|
78
77
|
"scripts": {
|
|
79
78
|
"test": "npm run build && tstest test/",
|
package/readme.md
CHANGED
|
@@ -1,26 +1,32 @@
|
|
|
1
|
+
```markdown
|
|
1
2
|
# @design.estate/dees-document
|
|
2
|
-
|
|
3
|
+
|
|
4
|
+
A versatile tool for dynamically generating and rendering business documents, such as invoices, using modern web technologies and elements.
|
|
3
5
|
|
|
4
6
|
## Install
|
|
5
|
-
|
|
7
|
+
|
|
8
|
+
To incorporate `@design.estate/dees-document` into your project, execute the following command in your terminal:
|
|
9
|
+
|
|
6
10
|
```shell
|
|
7
11
|
npm install @design.estate/dees-document --save
|
|
8
12
|
```
|
|
9
13
|
|
|
10
|
-
This will add
|
|
14
|
+
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.
|
|
11
15
|
|
|
12
16
|
## 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
17
|
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
The `@design.estate/dees-document` package serves as a robust framework to facilitate the generation of business documents, such as invoices and contracts. Leveraging modern web technologies, this package integrates seamlessly with TypeScript and ES modules, offering a type-safe environment conducive to efficient, dynamic document creation. Presented here is a comprehensive guide to utilizing this package, ranging from initializing your environment to generating complete PDF documents.
|
|
19
|
+
|
|
20
|
+
### Getting Started
|
|
21
|
+
|
|
22
|
+
To embark on a document creation journey, initiate the document service. This service constitutes the core of this package and is typically started at the application's outset.
|
|
17
23
|
|
|
18
24
|
```typescript
|
|
19
25
|
import { PdfService, IPdfServiceConstructorOptions } from '@design.estate/dees-document';
|
|
20
26
|
|
|
21
27
|
async function setupPdfService() {
|
|
22
28
|
const options: IPdfServiceConstructorOptions = {
|
|
23
|
-
//
|
|
29
|
+
// configure your options here
|
|
24
30
|
};
|
|
25
31
|
|
|
26
32
|
const pdfService = await PdfService.createAndStart(options);
|
|
@@ -29,100 +35,138 @@ async function setupPdfService() {
|
|
|
29
35
|
}
|
|
30
36
|
```
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
The above code initializes the `PdfService`. Tailor the configuration options to suit your specific requirements.
|
|
39
|
+
|
|
40
|
+
### Creating Documents
|
|
41
|
+
|
|
42
|
+
With the PDF service initialized, you can now proceed to generate your documents. In the following section, you will find a detailed walkthrough for creating an invoice. This method can be adapted to other document types with necessary modifications.
|
|
43
|
+
|
|
44
|
+
#### Step-by-Step: Create an Invoice
|
|
45
|
+
|
|
46
|
+
1. **Define the Data Structure**: Construct the details of the invoice, including the sender, recipient information, and the details of the items being invoiced.
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { ILetter } from '@design.estate/dees-document';
|
|
50
|
+
|
|
51
|
+
const invoiceData: ILetter = {
|
|
52
|
+
from: {
|
|
53
|
+
name: "Your Company Name",
|
|
54
|
+
address: {
|
|
55
|
+
streetName: "Your Street",
|
|
56
|
+
houseNumber: "123",
|
|
57
|
+
city: "Your City",
|
|
58
|
+
country: "Your Country",
|
|
59
|
+
postalCode: "12345",
|
|
60
|
+
},
|
|
61
|
+
email: "your-email@example.com",
|
|
62
|
+
phone: "123-456-7890",
|
|
63
|
+
},
|
|
64
|
+
to: {
|
|
65
|
+
name: "Recipient Company Name",
|
|
66
|
+
address: {
|
|
67
|
+
streetName: "Recipient Street",
|
|
68
|
+
houseNumber: "456",
|
|
69
|
+
city: "Recipient City",
|
|
70
|
+
country: "Recipient Country",
|
|
71
|
+
postalCode: "67890",
|
|
72
|
+
},
|
|
73
|
+
email: "recipient-email@example.com",
|
|
74
|
+
phone: "098-765-4321",
|
|
75
|
+
},
|
|
76
|
+
content: {
|
|
77
|
+
invoiceData: {
|
|
78
|
+
items: [
|
|
79
|
+
{
|
|
80
|
+
name: "Service or Product Name",
|
|
81
|
+
unitQuantity: 2,
|
|
82
|
+
unitNetPrice: 100.00,
|
|
83
|
+
unitType: 'service',
|
|
84
|
+
vatPercentage: 19,
|
|
85
|
+
currency: 'EUR',
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
subject: "Invoice for Services Rendered",
|
|
91
|
+
date: new Date().getTime(),
|
|
92
|
+
versionInfo: {
|
|
93
|
+
type: "final",
|
|
94
|
+
version: "1.0.0"
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
```
|
|
33
98
|
|
|
34
|
-
|
|
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.
|
|
99
|
+
The `ILetter` interface captures all the components of an invoice, including both the sender (`from`) and recipient (`to`) information, alongside the details of the invoiced items.
|
|
36
100
|
|
|
37
|
-
|
|
38
|
-
First, define the basic structure of your invoice. This involves specifying details like the sender, recipient, items, and more.
|
|
101
|
+
2. **Generate the PDF**: Convert the invoice details into a PDF file.
|
|
39
102
|
|
|
40
|
-
```typescript
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
```
|
|
103
|
+
```typescript
|
|
104
|
+
async function generateInvoice(pdfService: PdfService, invoiceData: ILetter) {
|
|
105
|
+
const pdfBuffer = await pdfService.createPdfFromLetterObject(invoiceData);
|
|
106
|
+
console.log('Invoice PDF generated successfully.');
|
|
90
107
|
|
|
91
|
-
|
|
108
|
+
// Here you could save the PDF to your filesystem, send it via email, etc.
|
|
109
|
+
}
|
|
110
|
+
```
|
|
92
111
|
|
|
93
|
-
|
|
94
|
-
With the invoice data ready, you can now generate the PDF using the `PdfService` instance.
|
|
112
|
+
The `createPdfFromLetterObject` function returns a `Buffer` that contains the generated PDF, enabling you to save it to a file, send it to clients, or store it for record-keeping.
|
|
95
113
|
|
|
96
|
-
|
|
97
|
-
async function generateInvoice(pdfService: PdfService, invoiceData: ILetter) {
|
|
98
|
-
const pdfBuffer = await pdfService.createPdfFromLetterObject(invoiceData);
|
|
99
|
-
console.log('Invoice PDF generated successfully.');
|
|
114
|
+
3. **Integrate It All**: The following script ties together the PDF service and generates the invoice with the described data.
|
|
100
115
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
116
|
+
```typescript
|
|
117
|
+
async function main() {
|
|
118
|
+
const pdfService = await setupPdfService();
|
|
119
|
+
await generateInvoice(pdfService, invoiceData);
|
|
120
|
+
}
|
|
104
121
|
|
|
105
|
-
|
|
122
|
+
main().then(() => console.log('Invoice generation process completed.'));
|
|
123
|
+
```
|
|
106
124
|
|
|
107
|
-
|
|
108
|
-
Combining everything, your complete script to set up the service, define invoice data, and generate a PDF invoice might look something like this:
|
|
125
|
+
This example initiates the PDF service and utilizes it to generate a PDF invoice with specified parameters.
|
|
109
126
|
|
|
110
|
-
|
|
111
|
-
async function main() {
|
|
112
|
-
const pdfService = await setupPdfService();
|
|
113
|
-
await generateInvoice(pdfService, invoiceData);
|
|
114
|
-
}
|
|
127
|
+
### Advanced Document Features
|
|
115
128
|
|
|
116
|
-
|
|
117
|
-
|
|
129
|
+
The package is designed to create a broad range of documents, far beyond simple invoices. Utilize the modular architecture to customize documents to your specific business requirements.
|
|
130
|
+
|
|
131
|
+
#### Advanced Scenarios
|
|
118
132
|
|
|
119
|
-
|
|
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.
|
|
133
|
+
1. **Custom Styling**: Alter the visual styles of various elements within your documents, like headers, footers, and more through CSS or inline styles.
|
|
121
134
|
|
|
122
|
-
|
|
135
|
+
```typescript
|
|
136
|
+
import { DeDocumentViewer } from '@design.estate/dees-element';
|
|
137
|
+
|
|
138
|
+
const customStyledViewer = new DeDocumentViewer();
|
|
139
|
+
customStyledViewer.style.setProperty('--main-bg-color', 'lightblue');
|
|
140
|
+
document.body.appendChild(customStyledViewer);
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Adjust styles either with standard CSS or via dynamic TypeScript changes.
|
|
144
|
+
|
|
145
|
+
2. **Interactive Document Elements**: Integrate interactive UI components, like buttons or input fields, fitting seamlessly into your documents.
|
|
146
|
+
|
|
147
|
+
3. **Multi-page Document Generation**: Handle content overflow elegantly through automatic page creation, keeping headers and footers intact.
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
pdfService.adjustDePageScaling();
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Adapt between print and digital formats, managing scaling effectively.
|
|
154
|
+
|
|
155
|
+
4. **Embedding Images and Logos**: Enhance your document's appearance with company logos, graphics, and other auxiliary content.
|
|
156
|
+
|
|
157
|
+
### Additional Capabilities
|
|
158
|
+
|
|
159
|
+
Beyond basic functionality, this package offers a range of advanced features:
|
|
160
|
+
|
|
161
|
+
- **Document Management**: Manage multiple document templates, maintain version control, and append annotations or notes.
|
|
162
|
+
- **Dynamic Rendering**: Utilize templating engines to render dynamic content based on input variables.
|
|
163
|
+
- **Responsive Design for Digital Documents**: Ensure your documents are consistently displayed across various devices.
|
|
164
|
+
|
|
165
|
+
### Concluding Remarks
|
|
166
|
+
|
|
167
|
+
The `@design.estate/dees-document` package presents a powerful solution within the modern document generation realm. From basic invoices to intricate templates, this package provides the essential tools for businesses to streamline their document workflows and enhance their presentation quality and accuracy. Explore further depth by consulting the package’s detailed documentation or by reviewing the examples included within the module.
|
|
168
|
+
```
|
|
123
169
|
|
|
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
170
|
|
|
127
171
|
## License and Legal Information
|
|
128
172
|
|
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.0
|
|
7
|
-
description: 'A comprehensive
|
|
6
|
+
version: '1.3.0',
|
|
7
|
+
description: 'A comprehensive tool for dynamically generating and rendering business documents like invoices using modern web technologies.'
|
|
8
8
|
}
|
package/ts/classes.pdfservice.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as plugins from './plugins.js';
|
|
2
2
|
import * as paths from './paths.js';
|
|
3
3
|
import * as helpers from './helpers.js';
|
|
4
|
+
import * as interfaces from '../ts/interfaces/index.js';
|
|
4
5
|
|
|
5
6
|
export interface IPdfServiceConstructorOptions {
|
|
6
7
|
|
|
@@ -44,12 +45,15 @@ export class PdfService {
|
|
|
44
45
|
/**
|
|
45
46
|
* creates an letter
|
|
46
47
|
*/
|
|
47
|
-
public async createPdfFromLetterObject(
|
|
48
|
+
public async createPdfFromLetterObject(optionsArg: {
|
|
49
|
+
letterData: plugins.tsclass.business.ILetter,
|
|
50
|
+
documentSettings: interfaces.IDocumentSettings
|
|
51
|
+
}) {
|
|
48
52
|
const html = `
|
|
49
53
|
<script type="module">
|
|
50
54
|
${await helpers.getBundleAsString()}
|
|
51
55
|
</script>
|
|
52
|
-
<dedocument-dedocument printMode letterData="${plugins.smartjson.stringifyBase64(
|
|
56
|
+
<dedocument-dedocument printMode documentSettings="${plugins.smartjson.stringifyBase64(optionsArg.documentSettings)}" letterData="${plugins.smartjson.stringifyBase64(optionsArg.letterData)}"></dedocument-dedocument>
|
|
53
57
|
`;
|
|
54
58
|
// console.log(html);
|
|
55
59
|
const pdfResult = await this.smartpdfInstance.getA4PdfResultForHtmlString(html);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface IDeDocumentTranslations {
|
|
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;
|
|
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.0
|
|
7
|
-
description: 'A comprehensive
|
|
6
|
+
version: '1.3.0',
|
|
7
|
+
description: 'A comprehensive tool for dynamically generating and rendering business documents like invoices using modern web technologies.'
|
|
8
8
|
}
|
|
@@ -12,12 +12,11 @@ import {
|
|
|
12
12
|
cssManager,
|
|
13
13
|
unsafeCSS,
|
|
14
14
|
render,
|
|
15
|
+
domtools,
|
|
15
16
|
} from '@design.estate/dees-element';
|
|
16
|
-
import * as domtools from '@design.estate/dees-domtools';
|
|
17
|
-
|
|
18
17
|
import * as plugins from '../plugins.js';
|
|
19
|
-
|
|
20
|
-
import * as
|
|
18
|
+
import * as shared from '../../ts/shared/index.js';
|
|
19
|
+
import * as interfaces from '../../ts/interfaces/index.js';
|
|
21
20
|
|
|
22
21
|
|
|
23
22
|
declare global {
|
|
@@ -46,6 +45,12 @@ export class DeContentInvoice extends DeesElement {
|
|
|
46
45
|
})
|
|
47
46
|
public letterData: plugins.tsclass.business.ILetter;
|
|
48
47
|
|
|
48
|
+
@property({
|
|
49
|
+
type: Object,
|
|
50
|
+
reflect: true,
|
|
51
|
+
})
|
|
52
|
+
public documentSettings: interfaces.IDocumentSettings;
|
|
53
|
+
|
|
49
54
|
constructor() {
|
|
50
55
|
super();
|
|
51
56
|
domtools.DomTools.setupDomTools();
|
|
@@ -276,12 +281,12 @@ export class DeContentInvoice extends DeesElement {
|
|
|
276
281
|
</style>
|
|
277
282
|
<div>We hereby invoice products and services provided to you by Lossless GmbH:</div>
|
|
278
283
|
<div class="grid topLine dataHeader">
|
|
279
|
-
<div class="lineItem"
|
|
280
|
-
<div class="lineItem"
|
|
281
|
-
<div class="lineItem"
|
|
282
|
-
<div class="lineItem"
|
|
283
|
-
<div class="lineItem"
|
|
284
|
-
<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>
|
|
285
290
|
</div>
|
|
286
291
|
${(() => {
|
|
287
292
|
let counter = 1;
|
|
@@ -330,7 +335,7 @@ export class DeContentInvoice extends DeesElement {
|
|
|
330
335
|
${this.letterData?.content.invoiceData.reverseCharge
|
|
331
336
|
? html`
|
|
332
337
|
<div class="taxNote">
|
|
333
|
-
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.')}
|
|
334
339
|
</div>
|
|
335
340
|
`
|
|
336
341
|
: ``}
|