fix(contentinvoice): Fixed currency display issues in invoice content rendering.

This commit is contained in:
Philipp Kunz 2024-11-27 19:15:29 +01:00
parent 60e6d935d6
commit a5ff39d306
6 changed files with 77 additions and 18 deletions

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## 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) ## 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. Fixed the demo letter item details by replacing `currency` with `position` to correctly define the item position.

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@design.estate/dees-document', name: '@design.estate/dees-document',
version: '1.0.101', version: '1.0.102',
description: 'A comprehensive solution for generating documents like invoices, integrating elements, templates, and services to streamline document creation.' 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 = { export const commitinfo = {
name: '@design.estate/dees-document', name: '@design.estate/dees-document',
version: '1.0.101', version: '1.0.102',
description: 'A comprehensive solution for generating documents like invoices, integrating elements, templates, and services to streamline document creation.' 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.name}</div>
<div class="lineItem">${invoiceItem.unitQuantity}</div> <div class="lineItem">${invoiceItem.unitQuantity}</div>
<div class="lineItem">${invoiceItem.unitType}</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"> <div class="lineItem">
${invoiceItem.unitQuantity * invoiceItem.unitNetPrice} ${invoiceItem.currency} ${invoiceItem.unitQuantity * invoiceItem.unitNetPrice} ${this.letterData?.content.invoiceData.currency}
</div> </div>
</div> </div>
` `
@ -343,7 +343,7 @@ export class DeContentInvoice extends DeesElement {
IBAN: ${this.letterData?.from?.sepaConnection?.iban}<br /> IBAN: ${this.letterData?.from?.sepaConnection?.iban}<br />
BIC: ${this.letterData?.from?.sepaConnection?.bic}<br /> BIC: ${this.letterData?.from?.sepaConnection?.bic}<br />
Description: ${this.letterData?.content.invoiceData?.id}<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> </div>
${this.letterData?.content?.contractData?.contractDate ${this.letterData?.content?.contractData?.contractDate
? html` ? html`

View File

@ -121,17 +121,20 @@ export class DeDocument extends DeesElement {
} }
public latestRenderedLetterData: plugins.tsclass.business.ILetter = null; public latestRenderedLetterData: plugins.tsclass.business.ILetter = null;
public async renderDocument() { public async renderDocument() {
const domtools = await this.domtoolsPromise; const domtools = await this.domtoolsPromise;
const documentContainer = this.shadowRoot.querySelector('.documentContainer'); const documentContainer = this.shadowRoot.querySelector('.documentContainer');
let pages: DePage[] = []; let pages: DePage[] = [];
let pageCounter = 0; let pageCounter = 0;
let complete = false; let complete = false;
const content: DeContentInvoice = document.createElement(
'dedocument-contentinvoice' // lets append the content
) as DeContentInvoice; const content: DeContentInvoice = new DeContentInvoice();
content.letterData = this.letterData; content.letterData = this.letterData;
document.body.appendChild(content); document.body.appendChild(content);
await domtools.convenience.smartdelay.delayFor(0); await domtools.convenience.smartdelay.delayFor(0);
let overallContentOffset: number = 0; let overallContentOffset: number = 0;
let currentContentOffset: number; let currentContentOffset: number;
@ -179,7 +182,7 @@ export class DeDocument extends DeesElement {
this.latestRenderedLetterData = this.letterData; 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); super.updated(changedProperties);
const domtools = await this.domtoolsPromise; const domtools = await this.domtoolsPromise;
const renderedDocIsUpToDate = domtools.convenience.smartjson.deepEqualObjects(this.letterData, this.latestRenderedLetterData); 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(), deliveryDate: new Date().getTime(),
periodOfPerformance: null, periodOfPerformance: null,
printResult: null, printResult: null,
currency: 'EUR',
notes: [],
type: 'debitnote',
items: [ items: [
{ {
name: 'Item with 19% VAT', name: 'Item with 19% VAT',
unitQuantity: 1, unitQuantity: 2,
unitNetPrice: 100, unitNetPrice: 100,
unitType: 'hours', unitType: 'hours',
vatPercentage: 19, vatPercentage: 19,
@ -71,7 +73,7 @@ export const demoLetter: tsclass.business.ILetter = {
}, },
{ {
name: 'Item with 7% VAT', name: 'Item with 7% VAT',
unitQuantity: 1, unitQuantity: 4,
unitNetPrice: 100, unitNetPrice: 100,
unitType: 'hours', unitType: 'hours',
vatPercentage: 7, vatPercentage: 7,
@ -79,7 +81,7 @@ export const demoLetter: tsclass.business.ILetter = {
}, },
{ {
name: 'Item with 7% VAT', name: 'Item with 7% VAT',
unitQuantity: 1, unitQuantity: 3,
unitNetPrice: 230, unitNetPrice: 230,
unitType: 'hours', unitType: 'hours',
vatPercentage: 7, vatPercentage: 7,
@ -95,14 +97,14 @@ export const demoLetter: tsclass.business.ILetter = {
}, },
{ {
name: 'Item with 0% VAT', name: 'Item with 0% VAT',
unitQuantity: 1, unitQuantity: 6,
unitNetPrice: 230, unitNetPrice: 230,
unitType: 'hours', unitType: 'hours',
vatPercentage: 0, vatPercentage: 0,
position: 4, position: 4,
},{ },{
name: 'Item with 19% VAT', name: 'Item with 19% VAT',
unitQuantity: 1, unitQuantity: 8,
unitNetPrice: 100, unitNetPrice: 100,
unitType: 'hours', unitType: 'hours',
vatPercentage: 19, vatPercentage: 19,
@ -110,7 +112,7 @@ export const demoLetter: tsclass.business.ILetter = {
}, },
{ {
name: 'Item with 7% VAT', name: 'Item with 7% VAT',
unitQuantity: 1, unitQuantity: 9,
unitNetPrice: 100, unitNetPrice: 100,
unitType: 'hours', unitType: 'hours',
vatPercentage: 7, vatPercentage: 7,
@ -118,7 +120,7 @@ export const demoLetter: tsclass.business.ILetter = {
}, },
{ {
name: 'Item with 7% VAT', name: 'Item with 7% VAT',
unitQuantity: 1, unitQuantity: 4,
unitNetPrice: 230, unitNetPrice: 230,
unitType: 'hours', unitType: 'hours',
vatPercentage: 7, vatPercentage: 7,
@ -126,7 +128,7 @@ export const demoLetter: tsclass.business.ILetter = {
}, },
{ {
name: 'Item with 21% VAT', name: 'Item with 21% VAT',
unitQuantity: 1, unitQuantity: 3,
unitNetPrice: 230, unitNetPrice: 230,
unitType: 'hours', unitType: 'hours',
vatPercentage: 21, vatPercentage: 21,
@ -140,6 +142,54 @@ export const demoLetter: tsclass.business.ILetter = {
vatPercentage: 0, vatPercentage: 0,
position: 10, 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,
},
], ],
} }
}, },