Compare commits

..

4 Commits

7 changed files with 104 additions and 28 deletions

View File

@ -1,5 +1,17 @@
# Changelog
## 2024-11-27 - 1.0.103 - fix(DeDocument)
Fix rendering of documents by properly moving new pages back to the document container
- Resolved an issue in the DeDocument component where new pages were wrongly managed, causing errors in the rendering of documents.
- Added a documentBuildContainer for temporary storage during page setup, ensuring correct page ordering.
## 2024-11-27 - 1.0.102 - fix(contentinvoice)
Fixed currency display issues in invoice content rendering.
- Corrected the usage of currency property to consistently pull from letterData content for invoice items.
- Ensured currency is correctly displayed in the invoice PDF generation.
## 2024-11-27 - 1.0.101 - fix(shared)
Fixed the demo letter item details by replacing `currency` with `position` to correctly define the item position.

View File

@ -1,6 +1,6 @@
{
"name": "@design.estate/dees-document",
"version": "1.0.101",
"version": "1.0.103",
"private": false,
"description": "A comprehensive solution for generating documents like invoices, integrating elements, templates, and services to streamline document creation.",
"main": "dist_ts_web/index.js",

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@design.estate/dees-document',
version: '1.0.101',
version: '1.0.103',
description: 'A comprehensive solution for generating documents like invoices, integrating elements, templates, and services to streamline document creation.'
}

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@design.estate/dees-document',
version: '1.0.101',
version: '1.0.103',
description: 'A comprehensive solution for generating documents like invoices, integrating elements, templates, and services to streamline document creation.'
}

View File

@ -292,9 +292,9 @@ export class DeContentInvoice extends DeesElement {
<div class="lineItem">${invoiceItem.name}</div>
<div class="lineItem">${invoiceItem.unitQuantity}</div>
<div class="lineItem">${invoiceItem.unitType}</div>
<div class="lineItem">${invoiceItem.unitNetPrice} ${invoiceItem.currency}</div>
<div class="lineItem">${invoiceItem.unitNetPrice} ${this.letterData?.content.invoiceData.currency}</div>
<div class="lineItem">
${invoiceItem.unitQuantity * invoiceItem.unitNetPrice} ${invoiceItem.currency}
${invoiceItem.unitQuantity * invoiceItem.unitNetPrice} ${this.letterData?.content.invoiceData.currency}
</div>
</div>
`
@ -343,7 +343,7 @@ export class DeContentInvoice extends DeesElement {
IBAN: ${this.letterData?.from?.sepaConnection?.iban}<br />
BIC: ${this.letterData?.from?.sepaConnection?.bic}<br />
Description: ${this.letterData?.content.invoiceData?.id}<br />
Amount: ${this.getTotalGross()} ${this.letterData?.content.invoiceData.items[0].currency}
Amount: ${this.getTotalGross()} ${this.letterData?.content.invoiceData.currency}
</div>
${this.letterData?.content?.contractData?.contractDate
? html`

View File

@ -117,21 +117,27 @@ export class DeDocument extends DeesElement {
const response = await fetch(this.letterDataUrl);
this.letterData = await response.json();
}
this.renderDocument();
}
public latestRenderedLetterData: plugins.tsclass.business.ILetter = null;
public async renderDocument() {
const domtools = await this.domtoolsPromise;
const documentContainer = this.shadowRoot.querySelector('.documentContainer');
const documentBuildContainer = document.createElement('div');
document.body.appendChild(documentBuildContainer);
let pages: DePage[] = [];
let pageCounter = 0;
let complete = false;
const content: DeContentInvoice = document.createElement(
'dedocument-contentinvoice'
) as DeContentInvoice;
// lets append the content
const content: DeContentInvoice = new DeContentInvoice();
content.letterData = this.letterData;
document.body.appendChild(content);
await domtools.convenience.smartdelay.delayFor(0);
let overallContentOffset: number = 0;
let currentContentOffset: number;
@ -146,13 +152,8 @@ export class DeDocument extends DeesElement {
newPage.pageNumber = pageCounter;
newPage.append(currentContent);
newPage.pageTotalNumber = pageCounter;
documentContainer.append(newPage);
// betweenPagesSpacer
if (!this.printMode) {
const betweenPagesSpacerDiv = document.createElement('div');
betweenPagesSpacerDiv.classList.add('betweenPagesSpacer');
documentContainer.append(betweenPagesSpacerDiv);
}
documentBuildContainer.append(newPage);
await currentContent.elementDomReady;
await currentContent.trimStartToOffset(overallContentOffset);
let newPageOverflows = await newPage.checkOverflow();
@ -171,15 +172,28 @@ export class DeDocument extends DeesElement {
console.log(currentContentOffset);
}
document.body.removeChild(content);
document.body.removeChild(documentBuildContainer);
const documentContainer = this.shadowRoot.querySelector('.documentContainer');
if (documentContainer) {
const children = Array.from(documentContainer.children);
children.forEach((child) => documentContainer.removeChild(child));
}
for (const page of pages) {
page.pageTotalNumber = pageCounter;
documentContainer.append(page);
// betweenPagesSpacer
if (!this.printMode) {
const betweenPagesSpacerDiv = document.createElement('div');
betweenPagesSpacerDiv.classList.add('betweenPagesSpacer');
documentContainer.appendChild(betweenPagesSpacerDiv);
}
}
this.adjustDePageScaling();
this.latestRenderedLetterData = this.letterData;
}
async updated(changedProperties: Map<string | number | symbol, unknown>): void {
async updated(changedProperties: Map<string | number | symbol, unknown>): Promise<void> {
super.updated(changedProperties);
const domtools = await this.domtoolsPromise;
const renderedDocIsUpToDate = domtools.convenience.smartjson.deepEqualObjects(this.letterData, this.latestRenderedLetterData);

View File

@ -59,11 +59,13 @@ export const demoLetter: tsclass.business.ILetter = {
deliveryDate: new Date().getTime(),
periodOfPerformance: null,
printResult: null,
currency: 'EUR',
notes: [],
type: 'debitnote',
items: [
{
name: 'Item with 19% VAT',
unitQuantity: 1,
unitQuantity: 2,
unitNetPrice: 100,
unitType: 'hours',
vatPercentage: 19,
@ -71,7 +73,7 @@ export const demoLetter: tsclass.business.ILetter = {
},
{
name: 'Item with 7% VAT',
unitQuantity: 1,
unitQuantity: 4,
unitNetPrice: 100,
unitType: 'hours',
vatPercentage: 7,
@ -79,7 +81,7 @@ export const demoLetter: tsclass.business.ILetter = {
},
{
name: 'Item with 7% VAT',
unitQuantity: 1,
unitQuantity: 3,
unitNetPrice: 230,
unitType: 'hours',
vatPercentage: 7,
@ -95,14 +97,14 @@ export const demoLetter: tsclass.business.ILetter = {
},
{
name: 'Item with 0% VAT',
unitQuantity: 1,
unitQuantity: 6,
unitNetPrice: 230,
unitType: 'hours',
vatPercentage: 0,
position: 4,
},{
name: 'Item with 19% VAT',
unitQuantity: 1,
unitQuantity: 8,
unitNetPrice: 100,
unitType: 'hours',
vatPercentage: 19,
@ -110,7 +112,7 @@ export const demoLetter: tsclass.business.ILetter = {
},
{
name: 'Item with 7% VAT',
unitQuantity: 1,
unitQuantity: 9,
unitNetPrice: 100,
unitType: 'hours',
vatPercentage: 7,
@ -118,7 +120,7 @@ export const demoLetter: tsclass.business.ILetter = {
},
{
name: 'Item with 7% VAT',
unitQuantity: 1,
unitQuantity: 4,
unitNetPrice: 230,
unitType: 'hours',
vatPercentage: 7,
@ -126,7 +128,7 @@ export const demoLetter: tsclass.business.ILetter = {
},
{
name: 'Item with 21% VAT',
unitQuantity: 1,
unitQuantity: 3,
unitNetPrice: 230,
unitType: 'hours',
vatPercentage: 21,
@ -140,6 +142,54 @@ export const demoLetter: tsclass.business.ILetter = {
vatPercentage: 0,
position: 10,
},
{
name: 'Item with 0% VAT',
unitQuantity: 1,
unitNetPrice: 230,
unitType: 'hours',
vatPercentage: 0,
position: 10,
},
{
name: 'Item with 0% VAT',
unitQuantity: 1,
unitNetPrice: 230,
unitType: 'hours',
vatPercentage: 0,
position: 10,
},
{
name: 'Item with 0% VAT',
unitQuantity: 1,
unitNetPrice: 230,
unitType: 'hours',
vatPercentage: 0,
position: 10,
},
{
name: 'Item with 0% VAT',
unitQuantity: 1,
unitNetPrice: 230,
unitType: 'hours',
vatPercentage: 0,
position: 10,
},
{
name: 'Item with 0% VAT',
unitQuantity: 1,
unitNetPrice: 230,
unitType: 'hours',
vatPercentage: 0,
position: 10,
},
{
name: 'Item with 0% VAT',
unitQuantity: 1,
unitNetPrice: 230,
unitType: 'hours',
vatPercentage: 0,
position: 10,
},
],
}
},