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