fbr_invoice library

FBR Digital Invoicing: a builder that works out the sales tax and an offline validator for the invoice JSON posted to FBR's Digital Invoicing API. No HTTP client and no token handling.

Same as the pakdatakit/fbr-invoice entry point of the npm package.

Classes

FbrInvoiceBuild
Result of buildFbrInvoice.
FbrInvoiceError
One problem found by validateFbrInvoice.
FbrInvoiceTotals
Column totals of an invoice, in rupees. Not sent to FBR.
FbrInvoiceValidation
Result of validateFbrInvoice.

Enums

FbrInvoiceType
invoiceType values in the specification.
FbrRegistrationType
buyerRegistrationType values in the specification.

Constants

fbrDiSpecVersion → const String
Version of PRAL's technical specification this module follows (FBR_DI_SPEC_VERSION in the npm package).

Functions

buildFbrInvoice(Object? input) → FbrInvoiceBuild?
Builds an FBR digital invoice from your own fields, working out salesTaxApplicable on each line where you leave it out (see expectedSalesTax; uses calculateSalesTax). Lines with a rate that is neither N% nor Rs.N (Exempt, combined rates) get 0 unless you give the tax.
expectedSalesTax(Object? item) → double?
The sales tax FBR expects on a line, in rupees, or null when the rate is not a plain percentage or per-unit amount (spec §7, errors 0102, 0104, 0105):
validateFbrInvoice(Object? invoice, {String? today}) → FbrInvoiceValidation
Checks an FBR digital invoice against the rules of PRAL's specification (v1.12) and Error Message Guide that need no call to FBR, and returns every problem with FBR's error code.

Typedefs

FbrInvoice = Map<String, Object?>
The invoice body for postinvoicedata and validateinvoicedata (spec §4.1, §4.2), as JSON: invoiceType, invoiceDate (YYYY-MM-DD), sellerNTNCNIC, sellerBusinessName, sellerProvince, sellerAddress, buyerNTNCNIC, buyerBusinessName, buyerProvince, buyerAddress, buyerRegistrationType, invoiceRefNo, scenarioId (sandbox only) and items, a list of FbrInvoiceItems.
FbrInvoiceInput = Map<String, Object?>
Input for buildFbrInvoice: an FbrInvoice whose invoiceRefNo and buyerNTNCNIC may be left out.
FbrInvoiceItem = Map<String, Object?>
One line of an invoice (spec §4.1, items), as JSON. Amounts are in rupees: hsCode, productDescription, rate (18%, Rs.3, Exempt …), uoM, quantity (up to 4 decimals), totalValues, valueSalesExcludingST, fixedNotifiedValueOrRetailPrice, salesTaxApplicable, salesTaxWithheldAtSource, extraTax, furtherTax, sroScheduleNo, fedPayable, discount, saleType and sroItemSerialNo.
FbrInvoiceItemInput = Map<String, Object?>
An item for buildFbrInvoice: an FbrInvoiceItem whose salesTaxApplicable, salesTaxWithheldAtSource, totalValues and fixedNotifiedValueOrRetailPrice may be left out.