project QadFinancials > class BDInvoice > method CalculateDInvoiceVat
Description
Method calculates amount of calculated fields contaning Vat in Vat currency
Parameters
icRowid | input | character | Row Id of tDInvoiceVat record which should be calculated. If ? all records are recalculated. |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bdinvoice.p)
if icRowId = ? then assign icRowId = "*":U.
for each tDInvoiceVat where
tDInvoiceVat.tc_Rowid matches icRowId and
(tDInvoiceVat.tdDInvoiceVatVatBaseDebitVC = 0 or
tDInvoiceVat.tdDInvoiceVatVatBaseDebitVC = ?) and
(tDInvoiceVat.tdDInvoiceVatVatBaseCreditVC = 0 or
tDInvoiceVat.tdDInvoiceVatVatBaseCreditVC = ?)
break by tDInvoiceVat.tc_ParentRowid:
/* CEE VAT Currency ================================================================= */
/* Calculate values of VAT in VAT currency */
/* ================================================================================== */
/* find parent debtor invoice */
if first-of(tDInvoiceVat.tc_ParentRowid)
then do:
find first tDInvoice where
tDInvoice.tc_Rowid = tDInvoiceVat.tc_ParentRowid
no-error.
if not available tDInvoice
then do:
assign vcMessage = trim(#T-2'The specified customer invoice is invalid.':255(17001)T-2#)
oiReturnStatus = -1.
<M-1 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tDInvoice.tc_Rowid':U (icFieldName),
input tDInvoiceVat.tc_ParentRowid (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tDInvoiceVat.tc_Rowid (icRowid),
input 'QADFIN-4182':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
next.
end.
assign viVatCurrencyId = tDInvoice.VatCurrency_ID
vdVatExchangeRate = tDInvoice.DInvoiceVatExchangeRate
vdVatRateScale = tDInvoice.DInvoiceVatRateScale.
/* if VAT curency are not defined for invoice, they are the same as transactional */
if viVatCurrencyId = ? or viVatCurrencyId = 0
then assign viVatCurrencyId = tDInvoice.DInvoiceCurrency_ID
vdVatExchangeRate = 1
vdVatRateScale = 1.
end. /* if first-of(tDInvoiceVat.tc_ParentRowid) */
<Q-10 run MfgTaxCodeByTaxCode (all) (Read) (Cache)
(input tDInvoiceVat.tcVatCode, (TaxCode)
input tDInvoiceVat.tcDomainCode, (DomainCode)
input ?, (DiscountAtPayment)
input ?, (IsTaxByLine)
output dataset tqMfgTaxCodeByTaxCode) in BMfgTaxCode>
find first tqMfgTaxCodeByTaxCode where
tqMfgTaxCodeByTaxCode.tctx2_tax_code = tDInvoiceVat.tcVatCode and
tqMfgTaxCodeByTaxCode.tctx2_domain = tDInvoiceVat.tcDomainCode
no-error.
if not available tqMfgTaxCodeByTaxCode
then next.
/* calculate values of vat amounts in vat currency */
assign tDInvoiceVat.tdDInvoiceVatVatBaseDebitVC = if tDInvoiceVat.DInvoiceVatVatBaseDebitTC = 0
then 0
else <M-59 RoundAmount
(input tDInvoiceVat.DInvoiceVatVatBaseDebitTC * vdVatExchangeRate * vdVatRateScale (idUnroundedAmount),
input ? (iiCurrencyID),
input tDInvoice.tcVatCurrencyCode (icCurrencyCode)) in BDInvoice>
tDInvoiceVat.tdDInvoiceVatVatBaseCreditVC = if tDInvoiceVat.DInvoiceVatVatBaseCreditTC = 0
then 0
else <M-19 RoundAmount
(input tDInvoiceVat.DInvoiceVatVatBaseCreditTC * vdVatExchangeRate * vdVatRateScale (idUnroundedAmount),
input ? (iiCurrencyID),
input tDInvoice.tcVatCurrencyCode (icCurrencyCode)) in BDInvoice>
tDInvoiceVat.tdDInvoiceVatVatDebitVC = if tDInvoiceVat.DInvoiceVatVatDebitTC = 0
then 0
else <M-92 RoundAmount
(input tDInvoiceVat.DInvoiceVatVatDebitTC * vdVatExchangeRate * vdVatRateScale (idUnroundedAmount),
input ? (iiCurrencyID),
input tDInvoice.tcVatCurrencyCode (icCurrencyCode)) in BDInvoice>
tDInvoiceVat.tdDInvoiceVatVatCreditVC = if tDInvoiceVat.DInvoiceVatVatCreditTC = 0
then 0
else <M-25 RoundAmount
(input tDInvoiceVat.DInvoiceVatVatCreditTC * vdVatExchangeRate * vdVatRateScale (idUnroundedAmount),
input ? (iiCurrencyID),
input tDInvoice.tcVatCurrencyCode (icCurrencyCode)) in BDInvoice>.
end. /* for each tDInvoiceVat */