create_debit_note
Create debit notes (purchase returns) in TallyPrime, reversing stock and expenses. Handles godown and auto-numbering fallback.
Instructions
Create an item-invoice Debit Note in TallyPrime — a Purchase return, reversing stock and expense for returned items. Same shape as create_purchase_invoice but with the debit/credit convention flipped, matching Sales's sign pattern (a Debit Note is structurally a reverse Purchase entry). Confirmed live on a real company: returning 3 units correctly decreased the item's book quantity by exactly 3. Same godown and dual-role deletion caveats as create_purchase_invoice apply.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes | Debit note date in DD-MM-YYYY format | |
| items | Yes | One entry per returned line. | |
| billName | No | Bill reference to settle against, e.g. the original bill's name. Defaults to 'Agst Ref' billType. | |
| billType | No | Defaults to 'Agst Ref' — settling against the original purchase's bill, unlike create_purchase_invoice's 'New Ref' default. | |
| buyerTrn | No | YOUR OWN company's TRN on this debit note (Tally's BASICBUYERSSALESTAXNO field) — you are the buyer on a purchase-side document. Normally constant; check get_company_info. | |
| narration | No | Narration / description | |
| reference | No | Free-text reference for this debit note (Tally's voucher-level REFERENCE field). | |
| vatLedger | No | Default VAT ledger for items without their own override. | |
| buyerState | No | YOUR OWN company's Emirate/state on this debit note's Party Details. | |
| partyLedger | Yes | Supplier ledger name (the party being debited) | |
| supplierTrn | No | The supplier's (party's) TRN on this debit note (Tally's TRADERCONSVATTINNO field). Distinct from buyerTrn below — NOTE the asymmetry: on a purchase-side document the party is the supplier, not the buyer. | |
| buyerCountry | No | YOUR OWN company's country on this debit note's Party Details. | |
| referenceDate | No | Date for the reference above, in DD-MM-YYYY format. | |
| voucherNumber | No | Explicit voucher number. Normally omit and let Tally auto-number — but some Tally configurations stop auto-numbering item-invoice vouchers via the XML gateway (confirmed live). If creation fails with a blank EXCEPTIONS:1, 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. Required if vatLedger is set. | |
| placeOfSupplyCountry | No | UAE VAT Place of Supply Country for this debit note. | |
| placeOfSupplyEmirate | No | UAE VAT Place of Supply Emirate for this debit note. |