@design.estate/dees-document 1.0.101 → 1.0.103

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@design.estate/dees-document",
3
- "version": "1.0.101",
3
+ "version": "1.0.103",
4
4
  "private": false,
5
5
  "description": "A comprehensive solution for generating documents like invoices, integrating elements, templates, and services to streamline document creation.",
6
6
  "main": "dist_ts_web/index.js",
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@design.estate/dees-document',
6
- version: '1.0.101',
6
+ version: '1.0.103',
7
7
  description: 'A comprehensive solution for generating documents like invoices, integrating elements, templates, and services to streamline document creation.'
8
8
  }
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@design.estate/dees-document',
6
- version: '1.0.101',
6
+ version: '1.0.103',
7
7
  description: 'A comprehensive solution for generating documents like invoices, integrating elements, templates, and services to streamline document creation.'
8
8
  }
@@ -292,9 +292,9 @@ export class DeContentInvoice extends DeesElement {
292
292
  <div class="lineItem">${invoiceItem.name}</div>
293
293
  <div class="lineItem">${invoiceItem.unitQuantity}</div>
294
294
  <div class="lineItem">${invoiceItem.unitType}</div>
295
- <div class="lineItem">${invoiceItem.unitNetPrice} ${invoiceItem.currency}</div>
295
+ <div class="lineItem">${invoiceItem.unitNetPrice} ${this.letterData?.content.invoiceData.currency}</div>
296
296
  <div class="lineItem">
297
- ${invoiceItem.unitQuantity * invoiceItem.unitNetPrice} ${invoiceItem.currency}
297
+ ${invoiceItem.unitQuantity * invoiceItem.unitNetPrice} ${this.letterData?.content.invoiceData.currency}
298
298
  </div>
299
299
  </div>
300
300
  `
@@ -343,7 +343,7 @@ export class DeContentInvoice extends DeesElement {
343
343
  IBAN: ${this.letterData?.from?.sepaConnection?.iban}<br />
344
344
  BIC: ${this.letterData?.from?.sepaConnection?.bic}<br />
345
345
  Description: ${this.letterData?.content.invoiceData?.id}<br />
346
- Amount: ${this.getTotalGross()} ${this.letterData?.content.invoiceData.items[0].currency}
346
+ Amount: ${this.getTotalGross()} ${this.letterData?.content.invoiceData.currency}
347
347
  </div>
348
348
  ${this.letterData?.content?.contractData?.contractDate
349
349
  ? html`
@@ -117,21 +117,27 @@ export class DeDocument extends DeesElement {
117
117
  const response = await fetch(this.letterDataUrl);
118
118
  this.letterData = await response.json();
119
119
  }
120
- this.renderDocument();
121
120
  }
122
121
 
123
122
  public latestRenderedLetterData: plugins.tsclass.business.ILetter = null;
123
+
124
+
124
125
  public async renderDocument() {
125
126
  const domtools = await this.domtoolsPromise;
126
- const documentContainer = this.shadowRoot.querySelector('.documentContainer');
127
+
128
+
129
+ const documentBuildContainer = document.createElement('div');
130
+ document.body.appendChild(documentBuildContainer);
131
+
127
132
  let pages: DePage[] = [];
128
133
  let pageCounter = 0;
129
134
  let complete = false;
130
- const content: DeContentInvoice = document.createElement(
131
- 'dedocument-contentinvoice'
132
- ) as DeContentInvoice;
135
+
136
+ // lets append the content
137
+ const content: DeContentInvoice = new DeContentInvoice();
133
138
  content.letterData = this.letterData;
134
139
  document.body.appendChild(content);
140
+
135
141
  await domtools.convenience.smartdelay.delayFor(0);
136
142
  let overallContentOffset: number = 0;
137
143
  let currentContentOffset: number;
@@ -146,13 +152,8 @@ export class DeDocument extends DeesElement {
146
152
  newPage.pageNumber = pageCounter;
147
153
  newPage.append(currentContent);
148
154
  newPage.pageTotalNumber = pageCounter;
149
- documentContainer.append(newPage);
150
- // betweenPagesSpacer
151
- if (!this.printMode) {
152
- const betweenPagesSpacerDiv = document.createElement('div');
153
- betweenPagesSpacerDiv.classList.add('betweenPagesSpacer');
154
- documentContainer.append(betweenPagesSpacerDiv);
155
- }
155
+ documentBuildContainer.append(newPage);
156
+
156
157
  await currentContent.elementDomReady;
157
158
  await currentContent.trimStartToOffset(overallContentOffset);
158
159
  let newPageOverflows = await newPage.checkOverflow();
@@ -171,15 +172,28 @@ export class DeDocument extends DeesElement {
171
172
  console.log(currentContentOffset);
172
173
  }
173
174
  document.body.removeChild(content);
175
+ document.body.removeChild(documentBuildContainer);
174
176
 
177
+ const documentContainer = this.shadowRoot.querySelector('.documentContainer');
178
+ if (documentContainer) {
179
+ const children = Array.from(documentContainer.children);
180
+ children.forEach((child) => documentContainer.removeChild(child));
181
+ }
175
182
  for (const page of pages) {
176
183
  page.pageTotalNumber = pageCounter;
184
+ documentContainer.append(page);
185
+ // betweenPagesSpacer
186
+ if (!this.printMode) {
187
+ const betweenPagesSpacerDiv = document.createElement('div');
188
+ betweenPagesSpacerDiv.classList.add('betweenPagesSpacer');
189
+ documentContainer.appendChild(betweenPagesSpacerDiv);
190
+ }
177
191
  }
178
192
  this.adjustDePageScaling();
179
193
  this.latestRenderedLetterData = this.letterData;
180
194
  }
181
195
 
182
- async updated(changedProperties: Map<string | number | symbol, unknown>): void {
196
+ async updated(changedProperties: Map<string | number | symbol, unknown>): Promise<void> {
183
197
  super.updated(changedProperties);
184
198
  const domtools = await this.domtoolsPromise;
185
199
  const renderedDocIsUpToDate = domtools.convenience.smartjson.deepEqualObjects(this.letterData, this.latestRenderedLetterData);
@@ -59,11 +59,13 @@ export const demoLetter: tsclass.business.ILetter = {
59
59
  deliveryDate: new Date().getTime(),
60
60
  periodOfPerformance: null,
61
61
  printResult: null,
62
-
62
+ currency: 'EUR',
63
+ notes: [],
64
+ type: 'debitnote',
63
65
  items: [
64
66
  {
65
67
  name: 'Item with 19% VAT',
66
- unitQuantity: 1,
68
+ unitQuantity: 2,
67
69
  unitNetPrice: 100,
68
70
  unitType: 'hours',
69
71
  vatPercentage: 19,
@@ -71,7 +73,7 @@ export const demoLetter: tsclass.business.ILetter = {
71
73
  },
72
74
  {
73
75
  name: 'Item with 7% VAT',
74
- unitQuantity: 1,
76
+ unitQuantity: 4,
75
77
  unitNetPrice: 100,
76
78
  unitType: 'hours',
77
79
  vatPercentage: 7,
@@ -79,7 +81,7 @@ export const demoLetter: tsclass.business.ILetter = {
79
81
  },
80
82
  {
81
83
  name: 'Item with 7% VAT',
82
- unitQuantity: 1,
84
+ unitQuantity: 3,
83
85
  unitNetPrice: 230,
84
86
  unitType: 'hours',
85
87
  vatPercentage: 7,
@@ -95,14 +97,14 @@ export const demoLetter: tsclass.business.ILetter = {
95
97
  },
96
98
  {
97
99
  name: 'Item with 0% VAT',
98
- unitQuantity: 1,
100
+ unitQuantity: 6,
99
101
  unitNetPrice: 230,
100
102
  unitType: 'hours',
101
103
  vatPercentage: 0,
102
104
  position: 4,
103
105
  },{
104
106
  name: 'Item with 19% VAT',
105
- unitQuantity: 1,
107
+ unitQuantity: 8,
106
108
  unitNetPrice: 100,
107
109
  unitType: 'hours',
108
110
  vatPercentage: 19,
@@ -110,7 +112,7 @@ export const demoLetter: tsclass.business.ILetter = {
110
112
  },
111
113
  {
112
114
  name: 'Item with 7% VAT',
113
- unitQuantity: 1,
115
+ unitQuantity: 9,
114
116
  unitNetPrice: 100,
115
117
  unitType: 'hours',
116
118
  vatPercentage: 7,
@@ -118,7 +120,7 @@ export const demoLetter: tsclass.business.ILetter = {
118
120
  },
119
121
  {
120
122
  name: 'Item with 7% VAT',
121
- unitQuantity: 1,
123
+ unitQuantity: 4,
122
124
  unitNetPrice: 230,
123
125
  unitType: 'hours',
124
126
  vatPercentage: 7,
@@ -126,7 +128,7 @@ export const demoLetter: tsclass.business.ILetter = {
126
128
  },
127
129
  {
128
130
  name: 'Item with 21% VAT',
129
- unitQuantity: 1,
131
+ unitQuantity: 3,
130
132
  unitNetPrice: 230,
131
133
  unitType: 'hours',
132
134
  vatPercentage: 21,
@@ -140,6 +142,54 @@ export const demoLetter: tsclass.business.ILetter = {
140
142
  vatPercentage: 0,
141
143
  position: 10,
142
144
  },
145
+ {
146
+ name: 'Item with 0% VAT',
147
+ unitQuantity: 1,
148
+ unitNetPrice: 230,
149
+ unitType: 'hours',
150
+ vatPercentage: 0,
151
+ position: 10,
152
+ },
153
+ {
154
+ name: 'Item with 0% VAT',
155
+ unitQuantity: 1,
156
+ unitNetPrice: 230,
157
+ unitType: 'hours',
158
+ vatPercentage: 0,
159
+ position: 10,
160
+ },
161
+ {
162
+ name: 'Item with 0% VAT',
163
+ unitQuantity: 1,
164
+ unitNetPrice: 230,
165
+ unitType: 'hours',
166
+ vatPercentage: 0,
167
+ position: 10,
168
+ },
169
+ {
170
+ name: 'Item with 0% VAT',
171
+ unitQuantity: 1,
172
+ unitNetPrice: 230,
173
+ unitType: 'hours',
174
+ vatPercentage: 0,
175
+ position: 10,
176
+ },
177
+ {
178
+ name: 'Item with 0% VAT',
179
+ unitQuantity: 1,
180
+ unitNetPrice: 230,
181
+ unitType: 'hours',
182
+ vatPercentage: 0,
183
+ position: 10,
184
+ },
185
+ {
186
+ name: 'Item with 0% VAT',
187
+ unitQuantity: 1,
188
+ unitNetPrice: 230,
189
+ unitType: 'hours',
190
+ vatPercentage: 0,
191
+ position: 10,
192
+ },
143
193
  ],
144
194
  }
145
195
  },