Description
if you create a new DInvoiceVat line,
you have to execute this mehod to calculate the right vat amount
It can result in one or multiple lines
Parameters
icDebtorCode | input | character | Debtor Code |
icCurrencyCode | input | character | Currency code of the invoice |
icDocumentReference | input | character | Year+Daybook+Voucher for example 2006DI000000001 |
itTaxPointDate | input | date | Tax Point Date of the invoice |
itPostingDate | input | date | posting Date of the Invoice |
ilTaxIncluded | input | logical | for the first time, so for defaulting it will be yes, so the invoice amount that will be passes is with taxes, but when you change for example the base amounts, it will be set to false |
idAmountTC | input | decimal | Amount TC : first time for defaulting it is the invoice amount, afterwards it is one of the base amounts |
idExchangeRate | input | decimal | Exchange Rate of the invoice |
idExchangeRateScale | input | decimal | Scale factor of the Exchange Rate of the invoice |
icPaymentCondition | input | character | Payment conditon of the invoice |
icShipFromTaxZone | input | character | Tax Zone of the Ship From Address of the Debtor |
icShipToTaxZone | input | character | Tax Zone of the Ship to Address of the debtor |
icTxclTaxCls | input | character | Tax Class (of DInvoiceVat) |
icTxuTaxUsage | input | character | Tax Usage (of DInvoiceVat) |
ilShipToAddressIsTaxInCity | input | logical | tax in city flag of the ship to address |
ilIsTaxable | input | logical | Taxable flag |
icCurrentRowId | input | character | current row id |
idAdjustmentFactor | input | decimal | adjustment factor |
iiShipToAddressID | input | integer | Ship To Address ID |
iiShipFromAddressID | input | integer | Ship From Address ID |
bcTxenvTaxEnv | input-output | character | Tax Environment (of DInvoiceVat) |
icInvoiceType | input | character | |
tTaxDetailDInvoice | input-output | temp-table | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program3/bdinvoice.p)
/* replace unknown values */
if icCurrencyCode = ? then assign icCurrencyCode = "":U.
if icDocumentReference = ? then assign icDocumentReference = "":U.
if ilTaxIncluded = ? then assign ilTaxIncluded = yes.
if icShipFromTaxZone = ? then assign icShipFromTaxZone = "":U.
if icShipToTaxZone = ? then assign icShipToTaxZone = "":U.
if bcTxenvTaxEnv = ? then assign bcTxenvTaxEnv = "":U.
if icDebtorCode = ? then assign icDebtorCode = "":U.
if icTxclTaxCls = ? then assign icTxclTaxCls = "":U.
if icTxuTaxUsage = ? then assign icTxuTaxUsage = "":U.
if idAmountTC = ? then assign idAmountTC = 0.
if idExchangeRateScale = ? then assign idExchangeRateScale = 0.
if idExchangeRate = ? then assign idExchangeRate = 0.
if icPaymentCondition = ? then assign icPaymentCondition = "":U.
if icCurrentRowId = ? then assign icCurrentRowId = "":U.
if idAdjustmentFactor = ? then assign idAdjustmentFactor = 0.
if iiShipFromAddressID = ? then assign iiShipFromAddressID= 0.
if iiShipToAddressID= ? then assign iiShipToAddressID= 0.
if icShipFromTaxZone = "":U or icShipToTaxZone = "":U
then do:
assign vcMessage = trim(#T-3'The tax zones of the ship-from and ship-to are mandatory.':150(55956)t-3#)
oiReturnStatus = -1.
<M-4 run SetMessage
(input vcMessage (icMessage),
input '':u (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-5601':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
return.
end.
empty temp-table tTaxDetailDInvoice.
if bcTxenvTaxEnv = "":U and icShipFromTaxZone <> "":U and icShipToTaxZone <> "":U
then do:
/* call the PTax to get the tax environment and tax */
assign vhFcComponent = ?.
<M-5 run GetTaxEnvironmentAndCalculateTax
(input icShipFromTaxZone (icShipFromTaxZone),
input icShipToTaxZone (icShipToTaxZone),
input icTxclTaxCls (icTxclTaxCls),
input icCurrencyCode (icCurrencyCode),
input {&VATTAXTRANSACTIONTYPE-ARDTCRMEMO} (icTransactionType),
input icDocumentReference (icDocumentReference),
input ? (icDocumentNumber),
input ilTaxIncluded (ilTaxIsIncluded),
input itTaxPointDate (itTaxPointDate),
input itPostingDate (itPostingDate),
input icTxuTaxUsage (icTaxUsageCode),
input idAmountTC (idAmountTC),
input idExchangeRateScale (idExchangeRateScale),
input idExchangeRate (idExchangeRate),
input vcCompanyCode (icCompanyCode),
input icPaymentCondition (icPaymentCondition),
input vlIsCompanyTaxInCity (ilIsTaxInCityFromCompany),
input ilShipToAddressIsTaxInCity (ilIsTaxInCityFromShipTo),
input ilIsTaxable (ilIsTaxable),
input idAdjustmentFactor (idAdjustmentFactor),
input iiShipFromAddressID (iiShipFromAddressID),
input iiShipToAddressID (iiShipToAddressID),
input ? (icCustomerCode),
input icInvoiceType (icInvoiceType),
input-output tTaxDetailDInvoice (tTaxDetail),
output tTaxParamExtDInv (tTaxParametersExtVAT),
output bcTxenvTaxEnv (ocTxenvTaxEnv),
output viFcReturnSuper (oiReturnStatus)) in BVAT>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
end.
else do:
/* calculate the taxes */
assign vhFcComponent = ?.
<M-1 run CalculateTax
(input true (ilStartAndOpenPGTM),
input icCurrencyCode (icCurrencyCode),
input {&VATTAXTRANSACTIONTYPE-ARDTCRMEMO} (icTransactionType),
input icDocumentReference (icDocumentReference),
input ? (icDocumentNumber),
input ilTaxIncluded (ilTaxIsIncluded),
input itTaxPointDate (itTaxPointDate),
input itPostingDate (itPostingDate),
input bcTxenvTaxEnv (icTaxEnvCode),
input icShipFromTaxZone (icFromTaxZoneCode),
input icShipToTaxZone (icToTaxZoneCode),
input icTxclTaxCls (icTaxClassCode),
input icTxuTaxUsage (icTaxUsageCode),
input idAmountTC (idAmountTC),
input idExchangeRateScale (idExchangeRateScale),
input idExchangeRate (idExchangeRate),
input vcCompanyCode (icCompanyCode),
input icPaymentCondition (icPaymentCondition),
input vlIsCompanyTaxInCity (ilIsTaxInCityFromCompany),
input ilShipToAddressIsTaxInCity (ilIsTaxInCityFromShipTo),
input ilIsTaxable (ilIsTaxable),
input idAdjustmentFactor (idAdjustmentFactor),
input iiShipToAddressID (iiShipToAddressID),
input iiShipFromAddressID (iiShipFromAddressID),
input icDebtorCode (icCustomerCode),
input icInvoiceType (icInvoiceType),
input-output tTaxDetailDInvoice (tTaxDetail),
output tTaxParamExtDInv (tTaxParametersExtVAT),
output viFcReturnSuper (oiReturnStatus)) in BVAT>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
end.
assign viSeq = 1.
/* just round the amounts for TC and LC */
for each tTaxDetailDInvoice :
if viSeq > 1
then do:
/* call query to get tax base code */
<Q-30 run MfgTaxCodeForTaxBase (all) (Read) (NoCache)
(input tTaxDetailDInvoice.tx2d_tax_code, (TaxCode)
input tTaxDetailDInvoice.tx2d_domain, (DomainCode)
output dataset tqMfgTaxCodeForTaxBase) in BMfgTaxCode >
find first tqMfgTaxCodeForTaxBase where tqMfgTaxCodeForTaxBase.tctx2_tax_code = tTaxDetailDInvoice.tx2d_tax_code and
tqMfgTaxCodeForTaxBase.tctx2_domain = tTaxDetailDInvoice.tx2d_domain no-error.
if available tqMfgTaxCodeForTaxBase
then assign tTaxDetailDInvoice.tlTx2UpdateTax = false.
end.
else
assign tTaxDetailDInvoice.tlTx2UpdateTax = true.
assign
tTaxDetailDInvoice.tx2d_tottax = <M-6 RoundAmount
(input tTaxDetailDInvoice.tx2d_tottax (idUnroundedAmount),
input ? (iiCurrencyID),
input icCurrencyCode (icCurrencyCode)) in BDInvoice>
tTaxDetailDInvoice.tx2d_cur_tax_amt = <M-7 RoundAmount
(input tTaxDetailDInvoice.tx2d_cur_tax_amt (idUnroundedAmount),
input ? (iiCurrencyID),
input icCurrencyCode (icCurrencyCode)) in BDInvoice>
tTaxDetailDInvoice.tx2d_cur_abs_ret_amt = <M-8 RoundAmount
(input tTaxDetailDInvoice.tx2d_cur_abs_ret_amt (idUnroundedAmount),
input ? (iiCurrencyID),
input icCurrencyCode (icCurrencyCode)) in BDInvoice>
/* LC */
tTaxDetailDInvoice.tx2d_taxable_amt = <M-9 RoundAmount
(input tTaxDetailDInvoice.tx2d_taxable_amt (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BDInvoice>
tTaxDetailDInvoice.tx2d_tax_amt = <M-10 RoundAmount
(input tTaxDetailDInvoice.tx2d_tax_amt (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BDInvoice>
tTaxDetailDInvoice.tx2d_abs_ret_amt = <M-11 RoundAmount
(input tTaxDetailDInvoice.tx2d_abs_ret_amt (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BDInvoice>.
end.