feat: migrate to new tsclass schema

This commit is contained in:
Dominik Schwank 2025-03-26 14:51:14 +00:00
parent 256cf74a45
commit bfa223a0f0
13 changed files with 2516 additions and 2617 deletions

View File

@ -22,28 +22,28 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@design.estate/dees-catalog": "^1.4.1", "@design.estate/dees-catalog": "^1.4.1",
"@design.estate/dees-domtools": "^2.0.65", "@design.estate/dees-domtools": "^2.3.2",
"@design.estate/dees-element": "^2.0.39", "@design.estate/dees-element": "^2.0.39",
"@design.estate/dees-wcctools": "^1.0.90", "@design.estate/dees-wcctools": "^1.0.90",
"@git.zone/tsrun": "^1.3.3", "@git.zone/tsrun": "^1.3.3",
"@push.rocks/smartfile": "^11.0.21", "@push.rocks/smartfile": "^11.2.0",
"@push.rocks/smartjson": "^5.0.20", "@push.rocks/smartjson": "^5.0.20",
"@push.rocks/smartpath": "^5.0.18", "@push.rocks/smartpath": "^5.0.18",
"@push.rocks/smartpdf": "^3.1.8", "@push.rocks/smartpdf": "^3.2.2",
"@push.rocks/smarttime": "^4.0.8", "@push.rocks/smarttime": "^4.1.1",
"@tsclass/tsclass": "^4.4.3", "@tsclass/tsclass": "^8.0.3",
"@types/node": "^22.10.1", "@types/node": "^22.13.13",
"@types/qrcode": "^1.5.5", "@types/qrcode": "^1.5.5",
"puppeteer": "^24.3.0", "puppeteer": "^24.4.0",
"qrcode": "^1.5.4" "qrcode": "^1.5.4"
}, },
"devDependencies": { "devDependencies": {
"@git.zone/tsbuild": "^2.2.0", "@git.zone/tsbuild": "^2.3.2",
"@git.zone/tsbundle": "^2.1.0", "@git.zone/tsbundle": "^2.2.5",
"@git.zone/tstest": "^1.0.90", "@git.zone/tstest": "^1.0.96",
"@git.zone/tswatch": "^2.0.34", "@git.zone/tswatch": "^2.1.0",
"@push.rocks/projectinfo": "^5.0.2", "@push.rocks/projectinfo": "^5.0.2",
"@push.rocks/tapbundle": "^5.5.3" "@push.rocks/tapbundle": "^5.6.0"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",

4355
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1,119 +1,107 @@
import * as plugins from './plugins.js'; import * as plugins from "./plugins.js";
import * as paths from './paths.js'; import * as paths from "./paths.js";
import * as interfaces from '../ts_shared/interfaces/index.js'; import * as interfaces from "../ts_shared/interfaces/index.js";
import { expect, tap } from '@push.rocks/tapbundle'; import { expect, tap } from "@push.rocks/tapbundle";
import * as deesDocumentServer from '../ts/index.js'; import * as deesDocumentServer from "../ts/index.js";
let testPdfServiceInstance: deesDocumentServer.PdfService; let testPdfServiceInstance: deesDocumentServer.PdfService;
const testLetterData: plugins.tsclass.business.ILetter = { const testLetterData: plugins.tsclass.finance.TInvoice = {
accentColor: null, type: "invoice",
type: 'invoice', invoiceType: "debitnote",
date: null, date: null,
needsCoverSheet: true,
objectActions: [], objectActions: [],
pdf: null, pdf: null,
content: { id: "XX-CLIENT-48765",
invoiceData: { invoiceId: "XX-CLIENT-48765",
id: 'XX-CLIENT-48765', reverseCharge: true,
reverseCharge: true, dueInDays: 30,
dueInDays: 30, currency: "EUR",
currency: 'EUR', notes: [],
notes: [], status: null,
type: 'debitnote', deliveryDate: new Date().getTime(),
billedBy: { periodOfPerformance: null,
address: null, printResult: null,
description: null, items: [
name: 'Some Service GmbH', {
type: null, name: "Website Creation",
customerNumber: null, unitQuantity: 1,
email: null, unitNetPrice: 1200,
facebookUrl: null, unitType: "item",
fax: null, vatPercentage: 0,
legalEntity: null, position: 1,
sepaConnection: {
bic: 'BPOTBEB1',
iban: 'BE72000000001616',
},
},
billedTo: null,
status: null,
deliveryDate: new Date().getTime(),
periodOfPerformance: null,
printResult: null,
items: [
{
name: 'Website Creation',
unitQuantity: 1,
unitNetPrice: 1200,
unitType: 'item',
vatPercentage: 0,
position: 1,
},
],
}, },
contractData: { ],
contractDate: Date.now(),
id: 'LL-CONTRACT-48765',
},
textData: [],
timesheetData: '',
},
from: { from: {
name: 'PdfService Test Company', name: "PdfService Test Company",
type: 'company', type: "company",
description: 'doing pdf stuff', status: "active",
foundedDate: { day: 1, month: 1, year: 2025 },
description: "doing pdf stuff",
address: { address: {
streetName: 'Awesome Street', streetName: "Awesome Street",
houseNumber: '5', houseNumber: "5",
city: 'Bremen', city: "Bremen",
country: 'Germany', country: "Germany",
postalCode: '28359', postalCode: "28359",
}, },
sepaConnection: { sepaConnection: {
bic: 'BPOTBEB1', bic: "BPOTBEB1",
iban: 'BE72000000001616', iban: "BE72000000001616",
},
registrationDetails: {
vatId: "",
registrationName: "",
registrationId: "",
}, },
}, },
to: { to: {
name: 'Awesome To Company', name: "Awesome To Company",
type: 'company', type: "company",
description: 'a company that does stuff', status: "active",
foundedDate: { day: 1, month: 1, year: 2025 },
description: "a company that does stuff",
address: { address: {
streetName: 'Awesome Street', streetName: "Awesome Street",
houseNumber: '5', houseNumber: "5",
city: 'Bremen', city: "Bremen",
country: 'Germany', country: "Germany",
postalCode: '28359', postalCode: "28359",
},
registrationDetails: {
vatId: "",
registrationName: "",
registrationId: "",
}, },
}, },
incidenceId: null, incidenceId: null,
language: null, language: null,
legalContact: null, legalContact: null,
logoUrl: null,
pdfAttachments: null, pdfAttachments: null,
subject: 'Invoice XX-CLIENT-48765', subject: "Invoice XX-CLIENT-48765",
versionInfo: { versionInfo: {
type: 'final', type: "final",
version: '1.0.0', version: "1.0.0",
}, },
}; };
tap.test('should create a document from an invoice', async () => { tap.test("should create a document from an invoice", async () => {
testPdfServiceInstance = new deesDocumentServer.PdfService({}); testPdfServiceInstance = new deesDocumentServer.PdfService({});
await testPdfServiceInstance.start(); await testPdfServiceInstance.start();
expect(testPdfServiceInstance).toBeInstanceOf(deesDocumentServer.PdfService); expect(testPdfServiceInstance).toBeInstanceOf(deesDocumentServer.PdfService);
}); });
tap.test('should create an invoice', async () => { tap.test("should create an invoice", async () => {
let counter = 0; let counter = 0;
const saveResult = async (optionsArg: { const saveResult = async (optionsArg: {
letterData: plugins.tsclass.business.ILetter; letterData: plugins.tsclass.finance.TInvoice;
documentSettings: interfaces.IDocumentSettings; documentSettings: interfaces.IDocumentSettings;
}) => { }) => {
const pdfResult = await testPdfServiceInstance.createPdfFromLetterObject(optionsArg); const pdfResult = await testPdfServiceInstance.createPdfFromLetterObject(
optionsArg
);
await plugins.smartfile.memory.toFs( await plugins.smartfile.memory.toFs(
Buffer.from(pdfResult.buffer), Buffer.from(pdfResult.buffer),
plugins.path.join(paths.nogitDir, `test-${counter++}.pdf`), plugins.path.join(paths.nogitDir, `test-${counter++}.pdf`)
); );
}; };
await saveResult({ await saveResult({
@ -124,106 +112,106 @@ tap.test('should create an invoice', async () => {
letterData: { letterData: {
...testLetterData, ...testLetterData,
versionInfo: { versionInfo: {
type: 'draft', type: "draft",
version: '1.0.0', version: "1.0.0",
}, },
}, },
documentSettings: {}, documentSettings: {},
}); });
(testLetterData.content.invoiceData.items = [ (testLetterData.items = [
{ {
name: 'Website Creation', name: "Website Creation",
unitQuantity: 1, unitQuantity: 1,
unitNetPrice: 1200, unitNetPrice: 1200,
unitType: 'item', unitType: "item",
vatPercentage: 0, vatPercentage: 0,
position: 1, position: 1,
}, },
{ {
name: 'Hosting', name: "Hosting",
unitQuantity: 1, unitQuantity: 1,
unitNetPrice: 1200, unitNetPrice: 1200,
unitType: 'item', unitType: "item",
vatPercentage: 19, vatPercentage: 19,
position: 2, position: 2,
}, },
{ {
name: 'Overnight Shipping', name: "Overnight Shipping",
unitQuantity: 1, unitQuantity: 1,
unitNetPrice: 1200, unitNetPrice: 1200,
unitType: 'item', unitType: "item",
vatPercentage: 24, vatPercentage: 24,
position: 3, position: 3,
}, },
{ {
name: 'Website Creation', name: "Website Creation",
unitQuantity: 1, unitQuantity: 1,
unitNetPrice: 1200, unitNetPrice: 1200,
unitType: 'item', unitType: "item",
vatPercentage: 0, vatPercentage: 0,
position: 4, position: 4,
}, },
{ {
name: 'Hosting', name: "Hosting",
unitQuantity: 1, unitQuantity: 1,
unitNetPrice: 1200, unitNetPrice: 1200,
unitType: 'item', unitType: "item",
vatPercentage: 19, vatPercentage: 19,
position: 5, position: 5,
}, },
{ {
name: 'Overnight Shipping', name: "Overnight Shipping",
unitQuantity: 1, unitQuantity: 1,
unitNetPrice: 1200, unitNetPrice: 1200,
unitType: 'item', unitType: "item",
vatPercentage: 24, vatPercentage: 24,
position: 6, position: 6,
}, },
{ {
name: 'Website Creation', name: "Website Creation",
unitQuantity: 1, unitQuantity: 1,
unitNetPrice: 1200, unitNetPrice: 1200,
unitType: 'item', unitType: "item",
vatPercentage: 0, vatPercentage: 0,
position: 7, position: 7,
}, },
{ {
name: 'Hosting', name: "Hosting",
unitQuantity: 1, unitQuantity: 1,
unitNetPrice: 1200, unitNetPrice: 1200,
unitType: 'item', unitType: "item",
vatPercentage: 19, vatPercentage: 19,
position: 8, position: 8,
}, },
{ {
name: 'Overnight Shipping', name: "Overnight Shipping",
unitQuantity: 1, unitQuantity: 1,
unitNetPrice: 1200, unitNetPrice: 1200,
unitType: 'item', unitType: "item",
vatPercentage: 24, vatPercentage: 24,
position: 9, position: 9,
}, },
{ {
name: 'Website Creation', name: "Website Creation",
unitQuantity: 1, unitQuantity: 1,
unitNetPrice: 1200, unitNetPrice: 1200,
unitType: 'item', unitType: "item",
vatPercentage: 0, vatPercentage: 0,
position: 10, position: 10,
}, },
{ {
name: 'Hosting', name: "Hosting",
unitQuantity: 1, unitQuantity: 1,
unitNetPrice: 1200, unitNetPrice: 1200,
unitType: 'item', unitType: "item",
vatPercentage: 19, vatPercentage: 19,
position: 11, position: 11,
}, },
{ {
name: 'Overnight Shipping', name: "Overnight Shipping",
unitQuantity: 1, unitQuantity: 1,
unitNetPrice: 1200, unitNetPrice: 1200,
unitType: 'item', unitType: "item",
vatPercentage: 24, vatPercentage: 24,
position: 12, position: 12,
}, },
@ -234,7 +222,7 @@ tap.test('should create an invoice', async () => {
}); });
}); });
tap.test('should stop the service', async () => { tap.test("should stop the service", async () => {
await testPdfServiceInstance.stop(); await testPdfServiceInstance.stop();
}); });

View File

@ -1,9 +1,11 @@
import * as plugins from "./plugins.js"; import * as plugins from "./plugins.js";
import * as interfaces from "./interfaces/index.js"; import * as interfaces from "./interfaces/index.js";
const fromContact: plugins.tsclass.business.IContact = { const fromContact: plugins.tsclass.business.TContact = {
name: "Awesome From Company", name: "Awesome From Company",
type: "company", type: "company",
status: "active",
foundedDate: { day: 1, month: 1, year: 2025 },
description: "a company that does stuff", description: "a company that does stuff",
address: { address: {
streetName: "Awesome Street", streetName: "Awesome Street",
@ -12,7 +14,6 @@ const fromContact: plugins.tsclass.business.IContact = {
country: "Germany", country: "Germany",
postalCode: "28359", postalCode: "28359",
}, },
vatId: "DE12345678",
sepaConnection: { sepaConnection: {
bic: "BPOTBEB1", bic: "BPOTBEB1",
iban: "BE01234567891616", iban: "BE01234567891616",
@ -20,11 +21,18 @@ const fromContact: plugins.tsclass.business.IContact = {
email: "hello@awesome.company", email: "hello@awesome.company",
phone: "+49 421 1234567", phone: "+49 421 1234567",
fax: "+49 421 1234568", fax: "+49 421 1234568",
registrationDetails: {
registrationId: "HRB 35230 HB",
registrationName: "Amtsgericht Bremen",
vatId: "DE12345678",
},
}; };
const toContact: plugins.tsclass.business.IContact = { const toContact: plugins.tsclass.business.TContact = {
name: "Awesome To GmbH", name: "Awesome To GmbH",
type: "company", type: "company",
status: "active",
foundedDate: { day: 1, month: 1, year: 2025 },
customerNumber: "LL-CLIENT-123", customerNumber: "LL-CLIENT-123",
description: "a company that does stuff", description: "a company that does stuff",
address: { address: {
@ -34,217 +42,201 @@ const toContact: plugins.tsclass.business.IContact = {
country: "Germany", country: "Germany",
postalCode: "28359", postalCode: "28359",
}, },
vatId: "BE12345678", registrationDetails: {
registrationId: "HRB 35230 HB",
registrationName: "Amtsgericht Bremen",
vatId: "DE12345678",
},
}; };
export const demoLetter: plugins.tsclass.business.ILetter = { export const demoLetter: plugins.tsclass.finance.TInvoice = {
versionInfo: {
type: "draft",
version: "1.0.0",
},
accentColor: null,
content: {
textData: null,
timesheetData: null,
contractData: {
contractDate: Date.now(),
id: "someid",
},
letterData: {} as plugins.tsclass.business.ILetter,
invoiceData: {
id: "LL-INV-48765",
reverseCharge: true,
dueInDays: 30,
billedBy: fromContact,
billedTo: toContact,
status: null,
deliveryDate: new Date().getTime(),
periodOfPerformance: {
from: +new Date().setDate(new Date().getDate() - 7),
to: +new Date(),
},
printResult: null,
currency: "EUR",
notes: [],
type: "debitnote",
items: [
{
name: "Item with 19% VAT",
unitQuantity: 2,
unitNetPrice: 100,
unitType: "hours",
vatPercentage: 19,
position: 0,
},
{
name: "Item with 7% VAT",
unitQuantity: 4,
unitNetPrice: 100,
unitType: "hours",
vatPercentage: 7,
position: 1,
},
{
name: "Item with 7% VAT",
unitQuantity: 3,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 7,
position: 2,
},
{
name: "Item with 21% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 21,
position: 3,
},
{
name: "Item with 0% VAT",
unitQuantity: 6,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 4,
},
{
name: "Item with 19% VAT",
unitQuantity: 8,
unitNetPrice: 100,
unitType: "hours",
vatPercentage: 19,
position: 5,
},
{
name: "Item with 7% VAT",
unitQuantity: 9,
unitNetPrice: 100,
unitType: "hours",
vatPercentage: 7,
position: 6,
},
{
name: "Item with 7% VAT",
unitQuantity: 4,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 7,
position: 8,
},
{
name: "Item with 21% VAT",
unitQuantity: 3,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 21,
position: 9,
},
{
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: 11,
},
{
name: "Item with 0% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 12,
},
{
name: "Item with 0% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 13,
},
{
name: "Item with 0% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 14,
},
{
name: "Item with 0% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 15,
},
{
name: "Item with 0% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 16,
},
{
name: "Item with 0% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 17,
},
{
name: "Item with 0% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 18,
},
{
name: "Item with 0% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 19,
},
{
name: "Item with 0% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 20,
},
],
},
},
date: Date.now(),
type: "invoice", type: "invoice",
needsCoverSheet: false, id: "LL-INV-48765",
objectActions: [], versionInfo: {
pdf: null, version: "1.0.0",
type: "draft",
},
language: "de",
date: Date.now(),
incidenceId: "LL-INV-48765",
invoiceId: "LL-INV-48765",
subject: "LL-INV-48765",
reverseCharge: true,
dueInDays: 30,
from: fromContact, from: fromContact,
to: toContact, to: toContact,
incidenceId: null, status: null,
language: null, deliveryDate: new Date().getTime(),
legalContact: null, periodOfPerformance: {
logoUrl: null, from: +new Date().setDate(new Date().getDate() - 7),
pdfAttachments: null, to: +new Date(),
subject: "Invoice: LL-INV-48765", },
printResult: null,
currency: "EUR",
notes: [],
invoiceType: "debitnote",
items: [
{
name: "Item with 19% VAT",
unitQuantity: 2,
unitNetPrice: 100,
unitType: "hours",
vatPercentage: 19,
position: 0,
},
{
name: "Item with 7% VAT",
unitQuantity: 4,
unitNetPrice: 100,
unitType: "hours",
vatPercentage: 7,
position: 1,
},
{
name: "Item with 7% VAT",
unitQuantity: 3,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 7,
position: 2,
},
{
name: "Item with 21% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 21,
position: 3,
},
{
name: "Item with 0% VAT",
unitQuantity: 6,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 4,
},
{
name: "Item with 19% VAT",
unitQuantity: 8,
unitNetPrice: 100,
unitType: "hours",
vatPercentage: 19,
position: 5,
},
{
name: "Item with 7% VAT",
unitQuantity: 9,
unitNetPrice: 100,
unitType: "hours",
vatPercentage: 7,
position: 6,
},
{
name: "Item with 7% VAT",
unitQuantity: 4,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 7,
position: 8,
},
{
name: "Item with 21% VAT",
unitQuantity: 3,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 21,
position: 9,
},
{
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: 11,
},
{
name: "Item with 0% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 12,
},
{
name: "Item with 0% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 13,
},
{
name: "Item with 0% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 14,
},
{
name: "Item with 0% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 15,
},
{
name: "Item with 0% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 16,
},
{
name: "Item with 0% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 17,
},
{
name: "Item with 0% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 18,
},
{
name: "Item with 0% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 19,
},
{
name: "Item with 0% VAT",
unitQuantity: 1,
unitNetPrice: 230,
unitType: "hours",
vatPercentage: 0,
position: 20,
},
],
}; };
export const demoDocumentSettings: interfaces.IDocumentSettings = { export const demoDocumentSettings: interfaces.IDocumentSettings = {

View File

@ -41,7 +41,7 @@ export class DeContentInvoice extends DeesElement {
type: Object, type: Object,
reflect: true, reflect: true,
}) })
public letterData: plugins.tsclass.business.ILetter; public letterData: plugins.tsclass.finance.TInvoice;
@property({ @property({
type: Object, type: Object,
@ -178,7 +178,7 @@ export class DeContentInvoice extends DeesElement {
return totalNet; return totalNet;
} }
for (const item of this.letterData.content.invoiceData.items) { for (const item of this.letterData.items) {
totalNet += item.unitNetPrice * item.unitQuantity; totalNet += item.unitNetPrice * item.unitQuantity;
} }
return totalNet; return totalNet;
@ -200,7 +200,7 @@ export class DeContentInvoice extends DeesElement {
public getVatGroups = () => { public getVatGroups = () => {
const vatGroups: { const vatGroups: {
vatPercentage: number; vatPercentage: number;
items: plugins.tsclass.finance.IInvoice["items"]; items: plugins.tsclass.finance.TInvoice["items"];
vatAmountSum: number; vatAmountSum: number;
}[] = []; }[] = [];
@ -209,14 +209,14 @@ export class DeContentInvoice extends DeesElement {
} }
const taxAmounts: number[] = []; const taxAmounts: number[] = [];
for (const item of this.letterData.content.invoiceData.items) { for (const item of this.letterData.items) {
taxAmounts.includes(item.vatPercentage) taxAmounts.includes(item.vatPercentage)
? null ? null
: taxAmounts.push(item.vatPercentage); : taxAmounts.push(item.vatPercentage);
} }
for (const taxAmount of taxAmounts) { for (const taxAmount of taxAmounts) {
const matchingItems = this.letterData.content.invoiceData.items.filter( const matchingItems = this.letterData.items.filter(
(itemArg) => itemArg.vatPercentage === taxAmount (itemArg) => itemArg.vatPercentage === taxAmount
); );
let sum = 0; let sum = 0;
@ -324,7 +324,7 @@ export class DeContentInvoice extends DeesElement {
}).format( }).format(
new Date(this.letterData.date).setDate( new Date(this.letterData.date).setDate(
new Date(this.letterData.date).getDate() + new Date(this.letterData.date).getDate() +
this.letterData?.content.invoiceData.dueInDays this.letterData?.dueInDays
) )
)} )}
</span> </span>
@ -334,14 +334,12 @@ export class DeContentInvoice extends DeesElement {
} }
private renderPaymentInfo(): TemplateResult { private renderPaymentInfo(): TemplateResult {
const bic = const bic = this.letterData?.from.sepaConnection.bic;
this.letterData?.content.invoiceData.billedBy.sepaConnection.bic; const name = this.letterData?.from.name;
const name = this.letterData?.content.invoiceData.billedBy.name; const iban = this.letterData?.from.sepaConnection.iban;
const iban = const currency = this.letterData?.currency;
this.letterData?.content.invoiceData.billedBy.sepaConnection.iban;
const currency = this.letterData?.content.invoiceData.currency;
const totalGross = this.getTotalGross(); const totalGross = this.getTotalGross();
const reference = this.letterData?.content.invoiceData.id; const reference = this.letterData?.id;
return html`<div class="infoBox"> return html`<div class="infoBox">
<div> <div>
@ -362,22 +360,23 @@ export class DeContentInvoice extends DeesElement {
} }
private renderReferencedContract(): TemplateResult { private renderReferencedContract(): TemplateResult {
return this.documentSettings.enableInvoiceContractRefSection && return null;
this.letterData?.content?.contractData?.contractDate // return this.documentSettings.enableInvoiceContractRefSection &&
? html` // this.invoiceData?.content?.contractData?.contractDate
<div class="infoBox"> // ? html`
<div class="label"> // <div class="infoBox">
${this.translateKey("invoice@@referencedContract")} // <div class="label">
</div> // ${this.translateKey("invoice@@referencedContract")}
${this.translateKey("invoice@@referencedContract.text")} // </div>
${new Intl.DateTimeFormat(this.documentSettings.languageCode, { // ${this.translateKey("invoice@@referencedContract.text")}
dateStyle: this.documentSettings.dateStyle, // ${new Intl.DateTimeFormat(this.documentSettings.languageCode, {
}).format( // dateStyle: this.documentSettings.dateStyle,
new Date(this.letterData?.content.contractData.contractDate) // }).format(
)}. // new Date(this.invoiceData?.content.contractData.contractDate)
</div> // )}.
` // </div>
: null; // `
// : null;
} }
public async attachInvoiceDom() { public async attachInvoiceDom() {
@ -406,7 +405,7 @@ export class DeContentInvoice extends DeesElement {
${this.translateKey("invoice@@price.total.net")} ${this.translateKey("invoice@@price.total.net")}
</div> </div>
</div> </div>
${this.letterData?.content.invoiceData?.items?.map( ${this.letterData?.items?.map(
(invoiceItem, index) => html` (invoiceItem, index) => html`
<div class="grid needsDataHeader"> <div class="grid needsDataHeader">
<div class="lineItem rightAlign">${index + 1}</div> <div class="lineItem rightAlign">${index + 1}</div>
@ -438,10 +437,7 @@ export class DeContentInvoice extends DeesElement {
</div> </div>
${this.getVatGroups().map((vatGroupArg) => { ${this.getVatGroups().map((vatGroupArg) => {
let itemNumbers = vatGroupArg.items let itemNumbers = vatGroupArg.items
.map( .map((item) => this.letterData.items.indexOf(item) + 1)
(item) =>
this.letterData.content.invoiceData.items.indexOf(item) + 1
)
.join(", "); .join(", ");
return html` return html`
<div class="sumline"> <div class="sumline">
@ -472,7 +468,7 @@ export class DeContentInvoice extends DeesElement {
</div> </div>
<div class="divider"></div> <div class="divider"></div>
${this.letterData?.content.invoiceData.reverseCharge ${this.letterData?.reverseCharge
? html`<div class="taxNote"> ? html`<div class="taxNote">
${this.translateKey("invoice@@vat.reverseCharge.note")} ${this.translateKey("invoice@@vat.reverseCharge.note")}
</div>` </div>`

View File

@ -26,6 +26,7 @@ import { DeContentInvoice } from "./contentinvoice.js";
import { demoFunc } from "./document.demo.js"; import { demoFunc } from "./document.demo.js";
import { dedocumentSharedStyle } from "../style.js"; import { dedocumentSharedStyle } from "../style.js";
import type { TInvoice } from "@tsclass/tsclass/dist_ts/finance/invoice.js";
declare global { declare global {
interface HTMLElementTagNameMap { interface HTMLElementTagNameMap {
@ -72,7 +73,7 @@ export class DeDocument extends DeesElement {
} }
}, },
}) })
public letterData: plugins.tsclass.business.ILetter; public letterData: plugins.tsclass.business.TLetter;
@property({ @property({
type: Object, type: Object,
@ -136,7 +137,7 @@ export class DeDocument extends DeesElement {
public latestDocumentSettings: plugins.shared.interfaces.IDocumentSettings = public latestDocumentSettings: plugins.shared.interfaces.IDocumentSettings =
null; null;
public latestRenderedLetterData: plugins.tsclass.business.ILetter = null; public latestRenderedLetterData: plugins.tsclass.business.TLetter = null;
public cleanupStore: any[] = []; public cleanupStore: any[] = [];
public async renderDocument() { public async renderDocument() {
@ -158,7 +159,7 @@ export class DeDocument extends DeesElement {
// lets append the content // lets append the content
const content: DeContentInvoice = new DeContentInvoice(); const content: DeContentInvoice = new DeContentInvoice();
cleanUpStoreCurrentRender.push(content); cleanUpStoreCurrentRender.push(content);
content.letterData = this.letterData; content.letterData = this.letterData as unknown as TInvoice;
content.documentSettings = this.documentSettings; content.documentSettings = this.documentSettings;
document.body.appendChild(content); document.body.appendChild(content);

View File

@ -31,7 +31,7 @@ export class DeLetterHeader extends DeesElement {
type: Object, type: Object,
reflect: true, reflect: true,
}) })
public letterData: plugins.tsclass.business.ILetter; public letterData: plugins.tsclass.finance.TInvoice;
@property({ @property({
type: Number, type: Number,
@ -171,7 +171,7 @@ export class DeLetterHeader extends DeesElement {
"letterhead@@vat.yourId" "letterhead@@vat.yourId"
)} )}
</div> </div>
${this.letterData.to.vatId || "not provided"} ${this.letterData.to.registrationDetails.vatId || "not provided"}
<!-- TODO: Make use of components --> <!-- TODO: Make use of components -->
${this.letterData.type === "invoice" ${this.letterData.type === "invoice"
@ -181,15 +181,11 @@ export class DeLetterHeader extends DeesElement {
"letterhead@@invoice.number" "letterhead@@invoice.number"
)} )}
</div> </div>
${this.letterData.content.invoiceData.id || "not registered"}` ${this.letterData.id || "not registered"}`
: null} : null}
${this.renderDeliveryDate( ${this.renderDeliveryDate(
new Date( new Date(this.letterData.periodOfPerformance?.from),
this.letterData.content?.invoiceData?.periodOfPerformance?.from new Date(this.letterData.periodOfPerformance?.to)
),
new Date(
this.letterData.content?.invoiceData?.periodOfPerformance?.to
)
)} )}
</div> </div>
`; `;

View File

@ -53,7 +53,7 @@ export class DePage extends DeesElement {
@property({ @property({
type: Object, type: Object,
}) })
public letterData: tsclass.business.ILetter = null; public letterData: tsclass.business.TLetter = null;
@property({ @property({
type: Boolean, type: Boolean,

View File

@ -28,7 +28,7 @@ export class DePageContent extends DeesElement {
@property({ @property({
type: Number, type: Number,
}) })
public letterData: plugins.tsclass.business.ILetter; public letterData: plugins.tsclass.business.TLetter;
@property({ @property({
type: Number, type: Number,

View File

@ -27,7 +27,7 @@ export class DePageFooter extends DeesElement {
@property({ @property({
type: Object, type: Object,
}) })
letterData: plugins.tsclass.business.ILetter; letterData: plugins.tsclass.business.TLetter;
@property({ @property({
type: Object, type: Object,
@ -119,17 +119,20 @@ export class DePageFooter extends DeesElement {
${this.letterData.from.address.city}<br /> ${this.letterData.from.address.city}<br />
${this.letterData.from.address.country} ${this.letterData.from.address.country}
</div> </div>
<div> ${this.letterData.from.registrationDetails
<strong ? html` <div>
>${plugins.shared.translation.translate( <strong
this.documentSettings.languageCode, >${plugins.shared.translation.translate(
"footer@@registration.label" this.documentSettings.languageCode,
)}:</strong "footer@@registration.label"
><br /> )}:</strong
Amtsgericht Bremen<br /> ><br />
<i>reg-#:</i> HRB 35230 HB<br /> ${this.letterData.from.registrationDetails.registrationName}<br />
<i>vat-id:</i> ${this.letterData.from.vatId} <i>reg-#:</i> ${this.letterData.from.registrationDetails
</div> .registrationId}<br />
<i>vat-id:</i> ${this.letterData.from.registrationDetails.vatId}
</div>`
: null}
<div> <div>
<strong <strong
>${plugins.shared.translation.translate( >${plugins.shared.translation.translate(

View File

@ -28,7 +28,7 @@ export class DePageHeader extends DeesElement {
@property({ @property({
type: Object, type: Object,
}) })
public letterData: plugins.tsclass.business.ILetter = null; public letterData: plugins.tsclass.business.TLetter = null;
@property({ @property({
type: Object, type: Object,

View File

@ -26,7 +26,7 @@ export class DeDocumentViewer extends DeesElement {
type: Object, type: Object,
reflect: true, reflect: true,
}) })
public letterData: plugins.tsclass.business.ILetter = null; public letterData: plugins.tsclass.business.TLetter = null;
@property({ @property({
type: Object, type: Object,

View File

@ -1,5 +1,5 @@
import * as plugins from '../plugins.js'; import * as plugins from "../plugins.js";
import { html } from '@design.estate/dees-element'; import { html } from "@design.estate/dees-element";
export const page1 = () => html` export const page1 = () => html`
<style> <style>
@ -7,11 +7,15 @@ export const page1 = () => html`
margin: 16px; margin: 16px;
} }
</style> </style>
<dedocument-dedocument .printMode=${false} letterData=${plugins.smartjson.stringifyBase64({ <dedocument-dedocument
.printMode=${false}
letterData=${plugins.smartjson.stringifyBase64({
...plugins.shared.demoLetter, ...plugins.shared.demoLetter,
from: { from: {
...plugins.shared.demoLetter.from, ...plugins.shared.demoLetter.from,
description: 'a string set via stringified JSON' description: "a string set via stringified JSON",
} },
} as plugins.tsclass.business.ILetter)}> </dedocument-dedocument> } as plugins.tsclass.finance.TInvoice)}
>
</dedocument-dedocument>
`; `;