feat(core): Enhanced document generation features and added translation capabilities
This commit is contained in:
234
test/test.ts
234
test/test.ts
@@ -1,5 +1,6 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import * as paths from './paths.js';
|
||||
import * as interfaces from '../ts/interfaces/index.js';
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import * as deesDocumentServer from '../ts/index.js';
|
||||
|
||||
@@ -16,6 +17,9 @@ const testLetterData: plugins.tsclass.business.ILetter = {
|
||||
id: 'XX-CLIENT-48765',
|
||||
reverseCharge: true,
|
||||
dueInDays: 30,
|
||||
currency: 'EUR',
|
||||
notes: [],
|
||||
type: 'debitnote',
|
||||
billedBy: {
|
||||
address: null,
|
||||
description: null,
|
||||
@@ -102,116 +106,132 @@ tap.test('should create a document from an invoice', async () => {
|
||||
|
||||
tap.test('should create an invoice', async () => {
|
||||
let counter = 0;
|
||||
const saveResult = async (letterDataArg: plugins.tsclass.business.ILetter) => {
|
||||
const pdfResult = await testPdfServiceInstance.createPdfFromLetterObject(letterDataArg);
|
||||
await plugins.smartfile.memory.toFs(Buffer.from(pdfResult.buffer), plugins.path.join(paths.nogitDir, `test-${counter++}.pdf`));
|
||||
}
|
||||
await saveResult(testLetterData);
|
||||
const saveResult = async (optionsArg: {
|
||||
letterData: plugins.tsclass.business.ILetter;
|
||||
documentSettings: interfaces.IDocumentSettings;
|
||||
}) => {
|
||||
const pdfResult = await testPdfServiceInstance.createPdfFromLetterObject(optionsArg);
|
||||
await plugins.smartfile.memory.toFs(
|
||||
Buffer.from(pdfResult.buffer),
|
||||
plugins.path.join(paths.nogitDir, `test-${counter++}.pdf`)
|
||||
);
|
||||
};
|
||||
await saveResult({
|
||||
...testLetterData,
|
||||
versionInfo: {
|
||||
type: 'draft',
|
||||
version: '1.0.0',
|
||||
}
|
||||
letterData: testLetterData,
|
||||
documentSettings: {},
|
||||
});
|
||||
testLetterData.content.invoiceData.items = [
|
||||
{
|
||||
name: 'Website Creation',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 0,
|
||||
currency: 'EUR',
|
||||
},
|
||||
{
|
||||
name: 'Hosting',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 19,
|
||||
currency: 'EUR',
|
||||
},
|
||||
{
|
||||
name: 'Overnight Shipping',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 24,
|
||||
currency: 'EUR',
|
||||
},{
|
||||
name: 'Website Creation',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 0,
|
||||
currency: 'EUR',
|
||||
},
|
||||
{
|
||||
name: 'Hosting',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 19,
|
||||
currency: 'EUR',
|
||||
},
|
||||
{
|
||||
name: 'Overnight Shipping',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 24,
|
||||
currency: 'EUR',
|
||||
},{
|
||||
name: 'Website Creation',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 0,
|
||||
currency: 'EUR',
|
||||
},
|
||||
{
|
||||
name: 'Hosting',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 19,
|
||||
currency: 'EUR',
|
||||
},
|
||||
{
|
||||
name: 'Overnight Shipping',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 24,
|
||||
currency: 'EUR',
|
||||
},{
|
||||
name: 'Website Creation',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 0,
|
||||
currency: 'EUR',
|
||||
},
|
||||
{
|
||||
name: 'Hosting',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 19,
|
||||
currency: 'EUR',
|
||||
},
|
||||
{
|
||||
name: 'Overnight Shipping',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 24,
|
||||
currency: 'EUR',
|
||||
},
|
||||
],
|
||||
await saveResult({
|
||||
...testLetterData,
|
||||
})
|
||||
letterData: {
|
||||
...testLetterData,
|
||||
versionInfo: {
|
||||
type: 'draft',
|
||||
version: '1.0.0',
|
||||
},
|
||||
},
|
||||
documentSettings: {},
|
||||
});
|
||||
(testLetterData.content.invoiceData.items = [
|
||||
{
|
||||
name: 'Website Creation',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 0,
|
||||
position: 1,
|
||||
},
|
||||
{
|
||||
name: 'Hosting',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 19,
|
||||
position: 2,
|
||||
},
|
||||
{
|
||||
name: 'Overnight Shipping',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 24,
|
||||
position: 3,
|
||||
},
|
||||
{
|
||||
name: 'Website Creation',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 0,
|
||||
position: 4,
|
||||
},
|
||||
{
|
||||
name: 'Hosting',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 19,
|
||||
position: 5,
|
||||
},
|
||||
{
|
||||
name: 'Overnight Shipping',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 24,
|
||||
position: 6,
|
||||
},
|
||||
{
|
||||
name: 'Website Creation',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 0,
|
||||
position: 7,
|
||||
},
|
||||
{
|
||||
name: 'Hosting',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 19,
|
||||
position: 8,
|
||||
},
|
||||
{
|
||||
name: 'Overnight Shipping',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 24,
|
||||
position: 9,
|
||||
},
|
||||
{
|
||||
name: 'Website Creation',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 0,
|
||||
position: 10,
|
||||
},
|
||||
{
|
||||
name: 'Hosting',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 19,
|
||||
position: 11,
|
||||
},
|
||||
{
|
||||
name: 'Overnight Shipping',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 24,
|
||||
position: 12,
|
||||
},
|
||||
]),
|
||||
await saveResult({
|
||||
letterData: testLetterData,
|
||||
documentSettings: {},
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('should stop the service', async () => {
|
||||
|
Reference in New Issue
Block a user