;; PRODUCT: <Discount>
;; PRODUCT-ID: a49cb3f4-ccc1-4a84-a13f-6ba6ec60166d
;; AUTHOR: Nilesh Gandhi


;;Objective:-
;;TDL program to Accept Discount in Amount instead of percentage
;;==============================================================

;;Remarks:-
;;1) In this TDL program, we are not adding any new field for "Discount Amount"
;;2) We are only changing the Title/captions and also the INPUT FORMAT for the "VCH Discount" field.
;;3) You also need to activate Discount facility in Tally. Use option GatewayOfTally -> F11 ->
;;   "Separate Discount coulmn on Invoices" option to be enabled
;;4) These changes affect the "Sales" Voucher entry only

;;Step 1: 
;;Change the Title to "Disc Amt" as it appears in the Invoice
[#Line: EI ColumnOne]
    Add: Option: Disc EI ColumnOne: @@IsSales

;;Optional definition for the line "Disc EI ColumnOne"
[!Line: Disc EI ColumnOne]
    Local: Field: VCH DiscTitle: Set as: "Disc Amt"

;;Step 2:
;;Change the title to "Disc Amt" as it appears in the Batch subform
[#Line: VCHBATCH ColumnOne]
    Add: Option: Disc EI ColumnName: @@IsSales

;;Optional definition
[!Line: Disc EI ColumnName]
    Local: Field: VCH DiscTitle: Info: "Disc Amt"

;;Step 3:
;;Change the Title to "Discount Amt" as it appears in the Multiple Price list report
[#Field: MPSDiscountTitle]
    Set as: "Discount Amt"

;;Step 4:
;;Reclaculate formula's
[System: Formula]
    CalcedAmt: ($Rate * $BilledQty) - $BatchDiscount
    NrmlAmount: ($BilledQty * $Rate) - $BatchDiscount

;;Step 5:
;;Update the format attribute for Discount field as it appears in the Invoice
[#Field: VCH Discount]
    Delete: Format
    Add: Format: "Nopercent,NoZero"

;;Update the format attribute for Discount field as it appears in Batch sub-form
[#Field: VCHBATCH Discount]
    Delete: Format
    Add: Format: "Nopercent,NoZero"

;;Required if there are no batch Allocations
[#Field: VCH Value]
    Resetval: if (@@NoBaseUnits OR $$IsEmpty:BilledQty) then $$Value else (($Rate * $BilledQty) - $Discount)



