create_purchase_invoice
Record supplier purchase invoices as item-voucher entries in TallyPrime, with stock item lines, quantities, rates, and optional VAT/tax postings.
Instructions
Create an item-invoice Purchase voucher in TallyPrime — mirror of create_sales_invoice for the buying side. A real invoice with stock item lines (quantity, rate), each posted to its own Purchase ledger, plus one optional VAT/tax line on the total. WARNING (confirmed live, same as create_sales_invoice): if the same party ledger or stock item is used in BOTH a Sales and a Purchase item-invoice, it can become undeletable via the API afterward — using it in only one of the two is fine and stays deletable. If it does happen, running Company Data → Rewrite in Tally itself clears it (confirmed live) — this is not a permanent lock.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes | Invoice date in DD-MM-YYYY format | |
| items | Yes | One entry per invoice line. | |
| billName | No | Bill reference name for bill-wise tracking (requires the party ledger's maintainBillWise to be on). Omit if not using bill-wise tracking. | |
| billType | No | Defaults to 'New Ref'. | |
| buyerTrn | No | YOUR OWN company's TRN, as it should appear on this purchase invoice (Tally's BASICBUYERSSALESTAXNO field) — you are the buyer on a purchase. Check get_company_info or an existing purchase invoice for the correct value; this is normally constant across all purchase invoices for one company. | |
| narration | No | Narration / description for the invoice | |
| reference | No | Free-text reference for this invoice (Tally's voucher-level REFERENCE field) — typically the supplier's own bill/invoice number. | |
| vatLedger | No | Default Input VAT ledger applied to any item that doesn't set its own vatLedger (optional — omit for a fully non-taxable invoice). | |
| buyerState | No | YOUR OWN company's Emirate/state on this invoice's Party Details (voucher-level STATENAME) — you are the buyer on a purchase. Normally constant; check get_company_info. | |
| partyLedger | Yes | Supplier ledger name (the party being paid) | |
| supplierTrn | No | The supplier's (party's) TRN as it should appear on THIS invoice — Tally's TRADERCONSVATTINNO field. NOTE the asymmetry vs create_sales_invoice: on a purchase, the party is the supplier, not the buyer, so this is a distinct field from buyerTrn below (they held different real values in a reverse-engineered example — do not set them to the same value). | |
| buyerCountry | No | YOUR OWN company's country on this invoice's Party Details (voucher-level COUNTRYOFRESIDENCE). Normally constant; check get_company_info. | |
| referenceDate | No | Date for the reference above, in DD-MM-YYYY format. Independent of the invoice's own date. | |
| voucherNumber | No | Explicit voucher number. Normally omit this and let Tally auto-number — but some Tally configurations (confirmed live: after a Company Data → Rewrite in at least one case) stop auto-numbering item-invoice vouchers via the XML gateway and fail with a blank EXCEPTIONS:1/no error text unless a number is given explicitly. If a create call fails with no error text, check get_vouchers for the highest existing number of this voucher type and retry with voucherNumber set to the next one. | |
| vatRatePercent | No | Default VAT rate as a percentage, e.g. 5. Required if vatLedger is set. Items with mixed rates can override this per-line. | |
| placeOfSupplyCountry | No | UAE VAT Place of Supply Country (Tally's PLACEOFSUPPLYCOUNTRY field), e.g. 'UAE'. | |
| placeOfSupplyEmirate | No | UAE VAT Place of Supply Emirate for this invoice (Tally's EMIRATEPOS field). |