@stafyniaksacha/facturx
Version:
Factur-X and Order-X generation library for European e-invoicing standard
226 lines (216 loc) • 13.5 kB
text/typescript
import { XMLDocument } from 'libxmljs';
import { Buffer } from 'node:buffer';
import { CrossIndustryInvoiceType, AccountingAccountTypeCodeType, AdvancePaymentType, AllowanceChargeReasonCodeType, AmountType, BinaryObjectType, CodeType, ContactTypeCodeType, CountryIDType, CreditorFinancialAccountType, CreditorFinancialInstitutionType, CurrencyCodeType, DateTimeType, DateType, DebtorFinancialAccountType, DeliveryTermsCodeType, DocumentCodeType, DocumentContextParameterType, DocumentLineDocumentType, ExchangedDocumentContextType, ExchangedDocumentType, FormattedDateTimeType, HeaderTradeAgreementType, HeaderTradeDeliveryType, HeaderTradeSettlementType, IDType, IndicatorType, LegalOrganizationType, LineStatusCodeType, LineTradeAgreementType, LineTradeDeliveryType, LineTradeSettlementType, LogisticsServiceChargeType, LogisticsTransportMovementType, MeasureType, NoteType, NumericType, PartyRoleCodeType, PaymentMeansCodeType, PercentType, ProcuringProjectType, ProductCharacteristicType, ProductClassificationType, QuantityType, RateType, ReferenceCodeType, ReferencedDocumentType, ReferencedProductType, SpecifiedPeriodType, SupplyChainConsignmentType, SupplyChainEventType, SupplyChainTradeLineItemType, SupplyChainTradeTransactionType, TaxCategoryCodeType, TaxRegistrationType, TaxTypeCodeType, TextType, TimeReferenceCodeType, TradeAccountingAccountType, TradeAddressType, TradeAllowanceChargeType, TradeContactType, TradeCountryType, TradeCurrencyExchangeType, TradeDeliveryTermsType, TradePartyType, TradePaymentDiscountTermsType, TradePaymentPenaltyTermsType, TradePaymentTermsType, TradePriceType, TradeProductInstanceType, TradeProductType, TradeSettlementFinancialCardType, TradeSettlementHeaderMonetarySummationType, TradeSettlementLineMonetarySummationType, TradeSettlementPaymentMeansType, TradeTaxType, TransportModeCodeType, UniversalCommunicationType } from './models.mjs';
import { PDFDocument } from 'pdf-lib';
declare function check(options: {
xml: string | Buffer | XMLDocument;
flavor?: string;
level?: string;
}): Promise<{
valid: boolean;
errors: any[];
flavor: string;
level: string;
}>;
/**
* Converter for FacturX CrossIndustryInvoice model to XML
*/
declare function invoiceToXml(invoice: CrossIndustryInvoiceType): Promise<XMLDocument>;
interface ExtractResult {
filename: string;
xml: string;
flavor?: string;
level?: string;
}
declare function extract(options: {
pdf: string | Buffer | PDFDocument;
check?: boolean;
level?: string;
flavor?: string;
}): Promise<ExtractResult>;
interface PdfMetadata {
author: string;
title: string;
subject: string;
keywords: string[];
date: Date;
}
declare function generate(options: {
pdf: string | Buffer | PDFDocument;
xml: string | Buffer | XMLDocument;
check?: boolean;
flavor?: string;
level?: string;
language?: string;
meta?: PdfMetadata;
}): Promise<Uint8Array>;
/**
* Factur-X model index file
*/
declare const index_AccountingAccountTypeCodeType: typeof AccountingAccountTypeCodeType;
declare const index_AdvancePaymentType: typeof AdvancePaymentType;
declare const index_AllowanceChargeReasonCodeType: typeof AllowanceChargeReasonCodeType;
declare const index_AmountType: typeof AmountType;
declare const index_BinaryObjectType: typeof BinaryObjectType;
declare const index_CodeType: typeof CodeType;
declare const index_ContactTypeCodeType: typeof ContactTypeCodeType;
declare const index_CountryIDType: typeof CountryIDType;
declare const index_CreditorFinancialAccountType: typeof CreditorFinancialAccountType;
declare const index_CreditorFinancialInstitutionType: typeof CreditorFinancialInstitutionType;
declare const index_CrossIndustryInvoiceType: typeof CrossIndustryInvoiceType;
declare const index_CurrencyCodeType: typeof CurrencyCodeType;
declare const index_DateTimeType: typeof DateTimeType;
declare const index_DateType: typeof DateType;
declare const index_DebtorFinancialAccountType: typeof DebtorFinancialAccountType;
declare const index_DeliveryTermsCodeType: typeof DeliveryTermsCodeType;
declare const index_DocumentCodeType: typeof DocumentCodeType;
declare const index_DocumentContextParameterType: typeof DocumentContextParameterType;
declare const index_DocumentLineDocumentType: typeof DocumentLineDocumentType;
declare const index_ExchangedDocumentContextType: typeof ExchangedDocumentContextType;
declare const index_ExchangedDocumentType: typeof ExchangedDocumentType;
declare const index_FormattedDateTimeType: typeof FormattedDateTimeType;
declare const index_HeaderTradeAgreementType: typeof HeaderTradeAgreementType;
declare const index_HeaderTradeDeliveryType: typeof HeaderTradeDeliveryType;
declare const index_HeaderTradeSettlementType: typeof HeaderTradeSettlementType;
declare const index_IDType: typeof IDType;
declare const index_IndicatorType: typeof IndicatorType;
declare const index_LegalOrganizationType: typeof LegalOrganizationType;
declare const index_LineStatusCodeType: typeof LineStatusCodeType;
declare const index_LineTradeAgreementType: typeof LineTradeAgreementType;
declare const index_LineTradeDeliveryType: typeof LineTradeDeliveryType;
declare const index_LineTradeSettlementType: typeof LineTradeSettlementType;
declare const index_LogisticsServiceChargeType: typeof LogisticsServiceChargeType;
declare const index_LogisticsTransportMovementType: typeof LogisticsTransportMovementType;
declare const index_MeasureType: typeof MeasureType;
declare const index_NoteType: typeof NoteType;
declare const index_NumericType: typeof NumericType;
declare const index_PartyRoleCodeType: typeof PartyRoleCodeType;
declare const index_PaymentMeansCodeType: typeof PaymentMeansCodeType;
declare const index_PercentType: typeof PercentType;
declare const index_ProcuringProjectType: typeof ProcuringProjectType;
declare const index_ProductCharacteristicType: typeof ProductCharacteristicType;
declare const index_ProductClassificationType: typeof ProductClassificationType;
declare const index_QuantityType: typeof QuantityType;
declare const index_RateType: typeof RateType;
declare const index_ReferenceCodeType: typeof ReferenceCodeType;
declare const index_ReferencedDocumentType: typeof ReferencedDocumentType;
declare const index_ReferencedProductType: typeof ReferencedProductType;
declare const index_SpecifiedPeriodType: typeof SpecifiedPeriodType;
declare const index_SupplyChainConsignmentType: typeof SupplyChainConsignmentType;
declare const index_SupplyChainEventType: typeof SupplyChainEventType;
declare const index_SupplyChainTradeLineItemType: typeof SupplyChainTradeLineItemType;
declare const index_SupplyChainTradeTransactionType: typeof SupplyChainTradeTransactionType;
declare const index_TaxCategoryCodeType: typeof TaxCategoryCodeType;
declare const index_TaxRegistrationType: typeof TaxRegistrationType;
declare const index_TaxTypeCodeType: typeof TaxTypeCodeType;
declare const index_TextType: typeof TextType;
declare const index_TimeReferenceCodeType: typeof TimeReferenceCodeType;
declare const index_TradeAccountingAccountType: typeof TradeAccountingAccountType;
declare const index_TradeAddressType: typeof TradeAddressType;
declare const index_TradeAllowanceChargeType: typeof TradeAllowanceChargeType;
declare const index_TradeContactType: typeof TradeContactType;
declare const index_TradeCountryType: typeof TradeCountryType;
declare const index_TradeCurrencyExchangeType: typeof TradeCurrencyExchangeType;
declare const index_TradeDeliveryTermsType: typeof TradeDeliveryTermsType;
declare const index_TradePartyType: typeof TradePartyType;
declare const index_TradePaymentDiscountTermsType: typeof TradePaymentDiscountTermsType;
declare const index_TradePaymentPenaltyTermsType: typeof TradePaymentPenaltyTermsType;
declare const index_TradePaymentTermsType: typeof TradePaymentTermsType;
declare const index_TradePriceType: typeof TradePriceType;
declare const index_TradeProductInstanceType: typeof TradeProductInstanceType;
declare const index_TradeProductType: typeof TradeProductType;
declare const index_TradeSettlementFinancialCardType: typeof TradeSettlementFinancialCardType;
declare const index_TradeSettlementHeaderMonetarySummationType: typeof TradeSettlementHeaderMonetarySummationType;
declare const index_TradeSettlementLineMonetarySummationType: typeof TradeSettlementLineMonetarySummationType;
declare const index_TradeSettlementPaymentMeansType: typeof TradeSettlementPaymentMeansType;
declare const index_TradeTaxType: typeof TradeTaxType;
declare const index_TransportModeCodeType: typeof TransportModeCodeType;
declare const index_UniversalCommunicationType: typeof UniversalCommunicationType;
declare namespace index {
export {
index_AccountingAccountTypeCodeType as AccountingAccountTypeCodeType,
index_AdvancePaymentType as AdvancePaymentType,
index_AllowanceChargeReasonCodeType as AllowanceChargeReasonCodeType,
index_AmountType as AmountType,
index_BinaryObjectType as BinaryObjectType,
index_CodeType as CodeType,
index_ContactTypeCodeType as ContactTypeCodeType,
index_CountryIDType as CountryIDType,
index_CreditorFinancialAccountType as CreditorFinancialAccountType,
index_CreditorFinancialInstitutionType as CreditorFinancialInstitutionType,
index_CrossIndustryInvoiceType as CrossIndustryInvoiceType,
index_CurrencyCodeType as CurrencyCodeType,
index_DateTimeType as DateTimeType,
index_DateType as DateType,
index_DebtorFinancialAccountType as DebtorFinancialAccountType,
index_DeliveryTermsCodeType as DeliveryTermsCodeType,
index_DocumentCodeType as DocumentCodeType,
index_DocumentContextParameterType as DocumentContextParameterType,
index_DocumentLineDocumentType as DocumentLineDocumentType,
index_ExchangedDocumentContextType as ExchangedDocumentContextType,
index_ExchangedDocumentType as ExchangedDocumentType,
index_FormattedDateTimeType as FormattedDateTimeType,
index_HeaderTradeAgreementType as HeaderTradeAgreementType,
index_HeaderTradeDeliveryType as HeaderTradeDeliveryType,
index_HeaderTradeSettlementType as HeaderTradeSettlementType,
index_IDType as IDType,
index_IndicatorType as IndicatorType,
index_LegalOrganizationType as LegalOrganizationType,
index_LineStatusCodeType as LineStatusCodeType,
index_LineTradeAgreementType as LineTradeAgreementType,
index_LineTradeDeliveryType as LineTradeDeliveryType,
index_LineTradeSettlementType as LineTradeSettlementType,
index_LogisticsServiceChargeType as LogisticsServiceChargeType,
index_LogisticsTransportMovementType as LogisticsTransportMovementType,
index_MeasureType as MeasureType,
index_NoteType as NoteType,
index_NumericType as NumericType,
index_PartyRoleCodeType as PartyRoleCodeType,
index_PaymentMeansCodeType as PaymentMeansCodeType,
index_PercentType as PercentType,
index_ProcuringProjectType as ProcuringProjectType,
index_ProductCharacteristicType as ProductCharacteristicType,
index_ProductClassificationType as ProductClassificationType,
index_QuantityType as QuantityType,
index_RateType as RateType,
index_ReferenceCodeType as ReferenceCodeType,
index_ReferencedDocumentType as ReferencedDocumentType,
index_ReferencedProductType as ReferencedProductType,
index_SpecifiedPeriodType as SpecifiedPeriodType,
index_SupplyChainConsignmentType as SupplyChainConsignmentType,
index_SupplyChainEventType as SupplyChainEventType,
index_SupplyChainTradeLineItemType as SupplyChainTradeLineItemType,
index_SupplyChainTradeTransactionType as SupplyChainTradeTransactionType,
index_TaxCategoryCodeType as TaxCategoryCodeType,
index_TaxRegistrationType as TaxRegistrationType,
index_TaxTypeCodeType as TaxTypeCodeType,
index_TextType as TextType,
index_TimeReferenceCodeType as TimeReferenceCodeType,
index_TradeAccountingAccountType as TradeAccountingAccountType,
index_TradeAddressType as TradeAddressType,
index_TradeAllowanceChargeType as TradeAllowanceChargeType,
index_TradeContactType as TradeContactType,
index_TradeCountryType as TradeCountryType,
index_TradeCurrencyExchangeType as TradeCurrencyExchangeType,
index_TradeDeliveryTermsType as TradeDeliveryTermsType,
index_TradePartyType as TradePartyType,
index_TradePaymentDiscountTermsType as TradePaymentDiscountTermsType,
index_TradePaymentPenaltyTermsType as TradePaymentPenaltyTermsType,
index_TradePaymentTermsType as TradePaymentTermsType,
index_TradePriceType as TradePriceType,
index_TradeProductInstanceType as TradeProductInstanceType,
index_TradeProductType as TradeProductType,
index_TradeSettlementFinancialCardType as TradeSettlementFinancialCardType,
index_TradeSettlementHeaderMonetarySummationType as TradeSettlementHeaderMonetarySummationType,
index_TradeSettlementLineMonetarySummationType as TradeSettlementLineMonetarySummationType,
index_TradeSettlementPaymentMeansType as TradeSettlementPaymentMeansType,
index_TradeTaxType as TradeTaxType,
index_TransportModeCodeType as TransportModeCodeType,
index_UniversalCommunicationType as UniversalCommunicationType,
};
}
/**
* Parse a Factur-X XML string into a CrossIndustryInvoiceType object
*/
declare function xmlToInvoice(xml: string | Buffer): Promise<CrossIndustryInvoiceType>;
export { index as Models, check, extract, generate, invoiceToXml, xmlToInvoice };