add testt files
This commit is contained in:
@ -1,35 +1,22 @@
|
||||
import * as plugins from './plugins.js';
|
||||
|
||||
// If you don't already have these imported, ensure they match your real file paths:
|
||||
// import type { IInvoice, IInvoiceItem } from './path/to/IInvoice';
|
||||
// import type { ILetter, IContact } from './path/to/ILetter';
|
||||
// import type { IAddress } from './path/to/IAddress';
|
||||
|
||||
/**
|
||||
* A class to convert a given ILetter with invoice data
|
||||
* into a minimal Factur-X / ZUGFeRD / EN16931-style XML.
|
||||
*/
|
||||
export class EInvoiceCreator {
|
||||
private letter: plugins.tsclass.business.ILetter;
|
||||
export class ZugferdXmlEncoder {
|
||||
|
||||
constructor(letter: plugins.tsclass.business.ILetter) {
|
||||
this.letter = letter;
|
||||
}
|
||||
constructor() {}
|
||||
|
||||
/**
|
||||
* Create an XML string representing the e-invoice (ZUGFeRD/Factur-X).
|
||||
* Note: This is a *high-level* example. Real compliance requires
|
||||
* correct namespacing, mandatory fields, etc.
|
||||
*/
|
||||
public createZugferdXml(): string {
|
||||
public createZugferdXml(letterArg: plugins.tsclass.business.ILetter): string {
|
||||
// 1) Get your "SmartXml" or "xmlbuilder2" instance
|
||||
const smartxmlInstance = new plugins.smartxml.SmartXml();
|
||||
|
||||
if (!this.letter.content.invoiceData) {
|
||||
if (!letterArg?.content?.invoiceData) {
|
||||
throw new Error('Letter does not contain invoice data.');
|
||||
}
|
||||
|
||||
const invoice: plugins.tsclass.finance.IInvoice = this.letter.content.invoiceData;
|
||||
const invoice: plugins.tsclass.finance.IInvoice = letterArg.content.invoiceData;
|
||||
const billedBy: plugins.tsclass.business.IContact = invoice.billedBy;
|
||||
const billedTo: plugins.tsclass.business.IContact = invoice.billedTo;
|
||||
|
||||
|
Reference in New Issue
Block a user