@design.estate/dees-document 1.0.101 → 1.1.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 +187 -176
- 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 +5 -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 +4 -0
- package/dist_ts/interfaces/translation.js +2 -0
- package/dist_watch/bundle.js +184 -397
- package/dist_watch/bundle.js.map +4 -4
- package/npmextra.json +11 -10
- package/package.json +13 -12
- package/readme.md +128 -87
- package/ts/00_commitinfo_data.ts +2 -2
- package/ts/classes.pdfservice.ts +6 -2
- package/ts/interfaces/document.ts +5 -0
- package/ts/interfaces/index.ts +2 -0
- package/ts/interfaces/translation.ts +4 -0
- package/ts_web/00_commitinfo_data.ts +2 -2
- package/ts_web/elements/contentinvoice.ts +7 -8
- package/ts_web/elements/document.ts +44 -20
- package/ts_web/elements/page.ts +45 -20
- package/ts_web/elements/pageheader.ts +9 -3
- package/ts_web/elements/shared/demoletter.ts +59 -9
- package/ts_web/elements/shared/index.ts +3 -0
- package/ts_web/elements/shared/translation.ts +31 -0
package/npmextra.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"githost": "code.foss.global",
|
|
6
6
|
"gitscope": "designestate/private",
|
|
7
7
|
"gitrepo": "dedocument-catalog",
|
|
8
|
-
"description": "A
|
|
8
|
+
"description": "A versatile tool for dynamically generating and rendering business documents, such as invoices, using modern web technologies and elements.",
|
|
9
9
|
"npmPackagename": "@designestate_private/dedocument-catalog",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"projectDomain": "design.estate",
|
|
@@ -14,19 +14,20 @@
|
|
|
14
14
|
"document generation",
|
|
15
15
|
"invoices",
|
|
16
16
|
"PDF creation",
|
|
17
|
-
"
|
|
17
|
+
"TypeScript",
|
|
18
18
|
"web components",
|
|
19
|
-
"custom elements",
|
|
20
|
-
"QR code",
|
|
21
|
-
"smart contracts",
|
|
22
19
|
"templating",
|
|
23
20
|
"dynamic rendering",
|
|
24
21
|
"responsive design",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
22
|
+
"business documentation",
|
|
23
|
+
"automated workflows",
|
|
24
|
+
"modular architecture",
|
|
25
|
+
"smart contracts",
|
|
26
|
+
"javascript",
|
|
27
|
+
"QR code",
|
|
28
|
+
"custom elements",
|
|
29
|
+
"nodejs",
|
|
30
|
+
"data-driven"
|
|
30
31
|
]
|
|
31
32
|
}
|
|
32
33
|
},
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@design.estate/dees-document",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "A
|
|
5
|
+
"description": "A versatile tool for dynamically generating and rendering business documents, such as invoices, using modern web technologies and elements.",
|
|
6
6
|
"main": "dist_ts_web/index.js",
|
|
7
7
|
"typings": "dist_ts_web/index.d.ts",
|
|
8
8
|
"exports": {
|
|
@@ -19,7 +19,7 @@
|
|
|
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
25
|
"@types/qrcode": "^1.5.5",
|
|
@@ -61,19 +61,20 @@
|
|
|
61
61
|
"document generation",
|
|
62
62
|
"invoices",
|
|
63
63
|
"PDF creation",
|
|
64
|
-
"
|
|
64
|
+
"TypeScript",
|
|
65
65
|
"web components",
|
|
66
|
-
"custom elements",
|
|
67
|
-
"QR code",
|
|
68
|
-
"smart contracts",
|
|
69
66
|
"templating",
|
|
70
67
|
"dynamic rendering",
|
|
71
68
|
"responsive design",
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
69
|
+
"business documentation",
|
|
70
|
+
"automated workflows",
|
|
71
|
+
"modular architecture",
|
|
72
|
+
"smart contracts",
|
|
73
|
+
"javascript",
|
|
74
|
+
"QR code",
|
|
75
|
+
"custom elements",
|
|
76
|
+
"nodejs",
|
|
77
|
+
"data-driven"
|
|
77
78
|
],
|
|
78
79
|
"scripts": {
|
|
79
80
|
"test": "npm run build && tstest test/",
|
package/readme.md
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
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
4
|
|
|
4
5
|
## Install
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
To add `@design.estate/dees-document` to your project, run the following command in your terminal:
|
|
8
|
+
|
|
6
9
|
```shell
|
|
7
10
|
npm install @design.estate/dees-document --save
|
|
8
11
|
```
|
|
9
12
|
|
|
10
|
-
This will add
|
|
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.
|
|
11
14
|
|
|
12
15
|
## 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
16
|
|
|
15
|
-
|
|
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.
|
|
18
|
+
|
|
19
|
+
### Getting Started
|
|
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.
|
|
17
22
|
|
|
18
23
|
```typescript
|
|
19
24
|
import { PdfService, IPdfServiceConstructorOptions } from '@design.estate/dees-document';
|
|
20
25
|
|
|
21
26
|
async function setupPdfService() {
|
|
22
27
|
const options: IPdfServiceConstructorOptions = {
|
|
23
|
-
//
|
|
28
|
+
// Add necessary configuration here
|
|
24
29
|
};
|
|
25
30
|
|
|
26
31
|
const pdfService = await PdfService.createAndStart(options);
|
|
@@ -29,100 +34,136 @@ async function setupPdfService() {
|
|
|
29
34
|
}
|
|
30
35
|
```
|
|
31
36
|
|
|
32
|
-
|
|
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
|
+
```
|
|
33
97
|
|
|
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.
|
|
98
|
+
Here, `ILetter` interface details all components of an invoice including sender (`from`) and recipient (`to`) information, as well as the invoiced items.
|
|
36
99
|
|
|
37
|
-
|
|
38
|
-
First, define the basic structure of your invoice. This involves specifying details like the sender, recipient, items, and more.
|
|
100
|
+
2. **Generate the PDF**: Transform the invoice details into a PDF.
|
|
39
101
|
|
|
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
|
-
```
|
|
102
|
+
```typescript
|
|
103
|
+
async function generateInvoice(pdfService: PdfService, invoiceData: ILetter) {
|
|
104
|
+
const pdfBuffer = await pdfService.createPdfFromLetterObject(invoiceData);
|
|
105
|
+
console.log('Invoice PDF generated successfully.');
|
|
90
106
|
|
|
91
|
-
|
|
107
|
+
// Save the PDF, send it via email, etc.
|
|
108
|
+
}
|
|
109
|
+
```
|
|
92
110
|
|
|
93
|
-
|
|
94
|
-
With the invoice data ready, you can now generate the PDF using the `PdfService` instance.
|
|
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.
|
|
95
112
|
|
|
96
|
-
|
|
97
|
-
async function generateInvoice(pdfService: PdfService, invoiceData: ILetter) {
|
|
98
|
-
const pdfBuffer = await pdfService.createPdfFromLetterObject(invoiceData);
|
|
99
|
-
console.log('Invoice PDF generated successfully.');
|
|
113
|
+
3. **Integrate It All**: Here's how everything ties together into a complete script for generating an invoice:
|
|
100
114
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
115
|
+
```typescript
|
|
116
|
+
async function main() {
|
|
117
|
+
const pdfService = await setupPdfService();
|
|
118
|
+
await generateInvoice(pdfService, invoiceData);
|
|
119
|
+
}
|
|
104
120
|
|
|
105
|
-
|
|
121
|
+
main().then(() => console.log('Invoice generation process completed.'));
|
|
122
|
+
```
|
|
106
123
|
|
|
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:
|
|
124
|
+
This script initiates the PDF service and generates the invoice PDF with the provided information.
|
|
109
125
|
|
|
110
|
-
|
|
111
|
-
async function main() {
|
|
112
|
-
const pdfService = await setupPdfService();
|
|
113
|
-
await generateInvoice(pdfService, invoiceData);
|
|
114
|
-
}
|
|
126
|
+
### Advanced Document Features
|
|
115
127
|
|
|
116
|
-
|
|
117
|
-
|
|
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
|
+
|
|
130
|
+
#### Advanced Scenarios
|
|
131
|
+
|
|
132
|
+
1. **Custom Styling**: Customize the appearance of elements within your documents, such as headers, footers, and more.
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import { DeDocumentViewer } from '@design.estate/dees-element';
|
|
118
136
|
|
|
119
|
-
|
|
120
|
-
|
|
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.
|
|
121
163
|
|
|
122
|
-
|
|
164
|
+
### Concluding Remarks
|
|
123
165
|
|
|
124
|
-
|
|
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`.
|
|
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.
|
|
126
167
|
|
|
127
168
|
## License and Legal Information
|
|
128
169
|
|
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
|
|
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.'
|
|
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);
|
|
@@ -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
|
|
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.'
|
|
8
8
|
}
|
|
@@ -12,14 +12,13 @@ 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
18
|
import * as shared from './shared/index.js';
|
|
21
19
|
|
|
22
20
|
|
|
21
|
+
|
|
23
22
|
declare global {
|
|
24
23
|
interface HTMLElementTagNameMap {
|
|
25
24
|
'dedocument-contentinvoice': DeContentInvoice;
|
|
@@ -277,8 +276,8 @@ export class DeContentInvoice extends DeesElement {
|
|
|
277
276
|
<div>We hereby invoice products and services provided to you by Lossless GmbH:</div>
|
|
278
277
|
<div class="grid topLine dataHeader">
|
|
279
278
|
<div class="lineItem">Item Pos.</div>
|
|
280
|
-
<div class="lineItem"
|
|
281
|
-
<div class="lineItem"
|
|
279
|
+
<div class="lineItem">${shared.translation.translate('DE', 'description', 'Description')}</div>
|
|
280
|
+
<div class="lineItem">${shared.translation.translate('DE', 'quantity', 'Quantity')}</div>
|
|
282
281
|
<div class="lineItem">Unit Type</div>
|
|
283
282
|
<div class="lineItem">Unit Net Price</div>
|
|
284
283
|
<div class="lineItem">Total Net Price</div>
|
|
@@ -292,9 +291,9 @@ export class DeContentInvoice extends DeesElement {
|
|
|
292
291
|
<div class="lineItem">${invoiceItem.name}</div>
|
|
293
292
|
<div class="lineItem">${invoiceItem.unitQuantity}</div>
|
|
294
293
|
<div class="lineItem">${invoiceItem.unitType}</div>
|
|
295
|
-
<div class="lineItem">${invoiceItem.unitNetPrice} ${
|
|
294
|
+
<div class="lineItem">${invoiceItem.unitNetPrice} ${this.letterData?.content.invoiceData.currency}</div>
|
|
296
295
|
<div class="lineItem">
|
|
297
|
-
${invoiceItem.unitQuantity * invoiceItem.unitNetPrice} ${
|
|
296
|
+
${invoiceItem.unitQuantity * invoiceItem.unitNetPrice} ${this.letterData?.content.invoiceData.currency}
|
|
298
297
|
</div>
|
|
299
298
|
</div>
|
|
300
299
|
`
|
|
@@ -343,7 +342,7 @@ export class DeContentInvoice extends DeesElement {
|
|
|
343
342
|
IBAN: ${this.letterData?.from?.sepaConnection?.iban}<br />
|
|
344
343
|
BIC: ${this.letterData?.from?.sepaConnection?.bic}<br />
|
|
345
344
|
Description: ${this.letterData?.content.invoiceData?.id}<br />
|
|
346
|
-
Amount: ${this.getTotalGross()} ${this.letterData?.content.invoiceData.
|
|
345
|
+
Amount: ${this.getTotalGross()} ${this.letterData?.content.invoiceData.currency}
|
|
347
346
|
</div>
|
|
348
347
|
${this.letterData?.content?.contractData?.contractDate
|
|
349
348
|
? html`
|
|
@@ -11,8 +11,15 @@ import {
|
|
|
11
11
|
domtools,
|
|
12
12
|
} from '@design.estate/dees-element';
|
|
13
13
|
|
|
14
|
+
import * as interfaces from '../../ts/interfaces/index.js';
|
|
14
15
|
import * as plugins from '../plugins.js';
|
|
15
16
|
|
|
17
|
+
export const defaultDocumentSettings: interfaces.IDocumentSettings = {
|
|
18
|
+
enableTopDraftText: true,
|
|
19
|
+
enableDefaultHeader: true,
|
|
20
|
+
enableDefaultFooter: true,
|
|
21
|
+
};
|
|
22
|
+
|
|
16
23
|
|
|
17
24
|
import { DePage } from './page.js';
|
|
18
25
|
import { DeContentInvoice } from './contentinvoice.js';
|
|
@@ -68,9 +75,17 @@ export class DeDocument extends DeesElement {
|
|
|
68
75
|
public letterData: plugins.tsclass.business.ILetter;
|
|
69
76
|
|
|
70
77
|
@property({
|
|
71
|
-
type:
|
|
78
|
+
type: Object,
|
|
79
|
+
reflect: true,
|
|
80
|
+
converter: (valueArg) => {
|
|
81
|
+
if (typeof valueArg === 'string') {
|
|
82
|
+
return plugins.smartjson.parseBase64(valueArg)
|
|
83
|
+
} else {
|
|
84
|
+
return valueArg;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
72
87
|
})
|
|
73
|
-
public
|
|
88
|
+
public documentSettings: interfaces.IDocumentSettings = defaultDocumentSettings;
|
|
74
89
|
|
|
75
90
|
constructor() {
|
|
76
91
|
super();
|
|
@@ -112,26 +127,27 @@ export class DeDocument extends DeesElement {
|
|
|
112
127
|
this.registerGarbageFunction(() => {
|
|
113
128
|
resizeObserver.disconnect();
|
|
114
129
|
})
|
|
115
|
-
|
|
116
|
-
if (this.letterDataUrl) {
|
|
117
|
-
const response = await fetch(this.letterDataUrl);
|
|
118
|
-
this.letterData = await response.json();
|
|
119
|
-
}
|
|
120
|
-
this.renderDocument();
|
|
121
130
|
}
|
|
122
131
|
|
|
123
132
|
public latestRenderedLetterData: plugins.tsclass.business.ILetter = null;
|
|
133
|
+
|
|
134
|
+
|
|
124
135
|
public async renderDocument() {
|
|
125
136
|
const domtools = await this.domtoolsPromise;
|
|
126
|
-
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
const documentBuildContainer = document.createElement('div');
|
|
140
|
+
document.body.appendChild(documentBuildContainer);
|
|
141
|
+
|
|
127
142
|
let pages: DePage[] = [];
|
|
128
143
|
let pageCounter = 0;
|
|
129
144
|
let complete = false;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
145
|
+
|
|
146
|
+
// lets append the content
|
|
147
|
+
const content: DeContentInvoice = new DeContentInvoice();
|
|
133
148
|
content.letterData = this.letterData;
|
|
134
149
|
document.body.appendChild(content);
|
|
150
|
+
|
|
135
151
|
await domtools.convenience.smartdelay.delayFor(0);
|
|
136
152
|
let overallContentOffset: number = 0;
|
|
137
153
|
let currentContentOffset: number;
|
|
@@ -146,13 +162,8 @@ export class DeDocument extends DeesElement {
|
|
|
146
162
|
newPage.pageNumber = pageCounter;
|
|
147
163
|
newPage.append(currentContent);
|
|
148
164
|
newPage.pageTotalNumber = pageCounter;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (!this.printMode) {
|
|
152
|
-
const betweenPagesSpacerDiv = document.createElement('div');
|
|
153
|
-
betweenPagesSpacerDiv.classList.add('betweenPagesSpacer');
|
|
154
|
-
documentContainer.append(betweenPagesSpacerDiv);
|
|
155
|
-
}
|
|
165
|
+
documentBuildContainer.append(newPage);
|
|
166
|
+
|
|
156
167
|
await currentContent.elementDomReady;
|
|
157
168
|
await currentContent.trimStartToOffset(overallContentOffset);
|
|
158
169
|
let newPageOverflows = await newPage.checkOverflow();
|
|
@@ -171,15 +182,28 @@ export class DeDocument extends DeesElement {
|
|
|
171
182
|
console.log(currentContentOffset);
|
|
172
183
|
}
|
|
173
184
|
document.body.removeChild(content);
|
|
185
|
+
document.body.removeChild(documentBuildContainer);
|
|
174
186
|
|
|
187
|
+
const documentContainer = this.shadowRoot.querySelector('.documentContainer');
|
|
188
|
+
if (documentContainer) {
|
|
189
|
+
const children = Array.from(documentContainer.children);
|
|
190
|
+
children.forEach((child) => documentContainer.removeChild(child));
|
|
191
|
+
}
|
|
175
192
|
for (const page of pages) {
|
|
176
193
|
page.pageTotalNumber = pageCounter;
|
|
194
|
+
documentContainer.append(page);
|
|
195
|
+
// betweenPagesSpacer
|
|
196
|
+
if (!this.printMode) {
|
|
197
|
+
const betweenPagesSpacerDiv = document.createElement('div');
|
|
198
|
+
betweenPagesSpacerDiv.classList.add('betweenPagesSpacer');
|
|
199
|
+
documentContainer.appendChild(betweenPagesSpacerDiv);
|
|
200
|
+
}
|
|
177
201
|
}
|
|
178
202
|
this.adjustDePageScaling();
|
|
179
203
|
this.latestRenderedLetterData = this.letterData;
|
|
180
204
|
}
|
|
181
205
|
|
|
182
|
-
async updated(changedProperties: Map<string | number | symbol, unknown>): void {
|
|
206
|
+
async updated(changedProperties: Map<string | number | symbol, unknown>): Promise<void> {
|
|
183
207
|
super.updated(changedProperties);
|
|
184
208
|
const domtools = await this.domtoolsPromise;
|
|
185
209
|
const renderedDocIsUpToDate = domtools.convenience.smartjson.deepEqualObjects(this.letterData, this.latestRenderedLetterData);
|