import { AutoEncoder } from '@simonbackx/simple-encoding'; import { VATExcemptReason } from '../BalanceItem.js'; import { Company } from '../Company.js'; import { PaymentCustomer } from '../PaymentCustomer.js'; import { PriceBreakdown, PriceBreakdownAction } from '../PriceBreakdown.js'; import { File } from '../files/File.js'; import { PaymentGeneral } from '../members/PaymentGeneral.js'; import { InvoicedBalanceItem } from './InvoicedBalanceItem.js'; export declare class VATSubtotal extends AutoEncoder { /** * For tax ecempt items, this should be zero but it is ignored anyway */ VATPercentage: number; VATExcempt: VATExcemptReason | null; /** * Value on which the VAT is calculated (taxable amount) */ taxablePrice: number; VAT: number; } export declare enum InvoiceType { Invoice = "Invoice", CreditNote = "CreditNote" } export declare class InvoiceTypeHelper { static getName(type: InvoiceType): string; } export declare class Invoice extends AutoEncoder { id: string; /** * Set if the invoice number is official. This number is unique per seller */ number: string | null; /** * Seller */ organizationId: string; /** * Can be null if it is not linked to an organization. * This is only used to allow the payer to list their (incoming) invoices. * * In the future we could expand this with members, users, and/or orders */ payingOrganizationId: string | null; /** * A point-in-time snapshot of the seller. * In case the address changes over time, or when an organization has multiple companies and some invoices */ seller: Company; /** * Payer */ customer: PaymentCustomer; /** * The balance items that are invoiced, with their original price. This does not always correspond to the total price of the invoice, or the item prices on the invoice because prices are converted to prices excluding VAT and with PEPPOL rounding rules. */ items: InvoicedBalanceItem[]; /** * The total sum of an invoice should always match the total sum of the payments connected to it. * On top of that, the amounts related to each balance item in the payments, should match the invoiced balance amount in each item in the invoice. * * Note, that this is a limitation. A payment can only be related to a single invoice. But an invoice can be for multiple payments. * More flexibility is often unneeded and makes reconciliation unnecessary complex. */ payments: PaymentGeneral[]; get totalWithoutVAT(): number; get totalBalanceInvoicedAmount(): number; get totalPaymentsAmount(): number; /** * This is the rounding amount in cents that is applied to the normal calculation of the invoiced balance items (prices exluding VAT) to come to the actual total price of the invoice. * * This is visible on the invoice. It is use to correct for differences between the paid price and the calculated invoice price because of rounding issues or things that can't be represented properly in PEPPOL due to rounding * * - Say we invoice 31 items of 5 euro including VAT, so 4,13 euro excluding VAT. This means InvoicedBalanceItem has * - balanceInvoicedAmount = 5 euro * - amount = 31_00_00 (31 pieces) * - unitPrice = 4_13_00 (4,13 euro excluding VAT, rounded to 1 cent because of PEPPOL) * The normal invoiced sum would be 155 euro if we sum balanceInvoicedAmount * But the invoice total price will be 128,03 excluding VAT, and 154,92 euro including VAT because of rounding rules (round on total level, not individual item level). * In this case payableRoundingAmount would be 0,08 euro, because that is the price that needs to be added to the normal calculation to come to the actual invoice total price that needs to be paid (155 euro). * A different solution might be to increase the price excluding VAT of some items by 0,07 euro (or add an extra item on the invoice with the same VAT rate), so the total excluding VAT becomes 128,10 euro, and including VAT 155 euro. This is not always possible though, in some cases we maintain a difference of 1 cent. * balanceRoundingAmount would be 0 because there is no difference lower than 1 cent. */ payableRoundingAmount: number; /** * The difference between the totalWithVAT of the invoice and the sum of all balanceInvoicedAmount of the invoiced balance items. * totalBalanceInvoicedAmount + balanceRoundingAmount = totalWithVAT * * Best viewed as a virtual extra balance item linked to the invoice to compensate. * * This is used to explain and report why there is a difference between the sum of the balance item's prices and the actually invoiced price, comparable with roundingAmount on payments. * - Say we invoice 3 items of 0,242 euro. The sum would be 0,726. The invoice total price might be 0,73 because of rounding rules. Then the balanceRoundingAmount would be 0,004. */ get balanceRoundingAmount(): number; /** * List of VAT per VAT rate or category. This is stored in case the calculation changes over time. */ VATTotal: VATSubtotal[]; get VATTotalAmount(): number; /** * Total invoiced price, including VAT * This should equal the sum of: * - all InvoicedBalanceItem.totalWithoutVAT * - plus payableRoundingAmount * - plus VATTotalAmount */ get totalWithVAT(): number; ipAddress: string | null; userAgent: string | null; /** * When it is an invoice for transaction fees related to a given stripe account. The stripe account id is stored here. */ stripeAccountId: string | null; reference: string | null; pdf: File | null; xml: File | null; negativeInvoiceId: string | null; didSendPeppol: boolean; invoicedAt: Date | null; dueAt: Date | null; createdAt: Date; updatedAt: Date; validateVATRates(): void; calculateVAT(): void; addItem(item: InvoicedBalanceItem): void; get type(): InvoiceType; get theme(): "theme-error" | undefined; get priceBreakdown(): PriceBreakdown; getPriceBreakdown(options?: { vatAction?: PriceBreakdownAction; }): PriceBreakdown; updatePayableRoundingAmount(): void; get didChangeUnitPricesToCorrectRounding(): boolean; correctRoundingByUpdatingPrices(): void; updatePrices(): void; /** * Call this method after changing the payments related to an invoice. */ buildFromPayments(): void; } //# sourceMappingURL=Invoice.d.ts.map