project QadFinancials > class BDInvoice > method CreateDIPostingTax
Description
Create the tax posting for the di
Parameters
| icRowId | input | character | Row ID |
| iiPostingId | input | integer | Posting ID |
| itTaxPointDate | input | date | TaxPointDate |
| icDIText | input | character | CI Text |
| icCurrencyCode | input | character | Currency Code |
| iiCurrencyId | input | integer | CurrencyID |
| icExchangeRateType | input | character | exchange rate type |
| idExchangeRate | input | decimal | exchange rate |
| idExchangeRateScale | input | decimal | |
| idVatFullDebitTC | input | decimal | Vat Full Debit TC |
| idVatFullCreditTC | input | decimal | Vat Full Credit TC |
| icDInvoiceType | input | character | CInvoiceType |
| icDivisionCode | input | character | |
| icVatCurrencyCode | input | character | |
| iiVatCurrencyId | input | integer | |
| idVatExchangeRate | input | decimal | |
| idVatExchangeRateScale | input | decimal | |
| icShipFromCountryCode | input | character | country code of the ship from address |
| icShipToCountryCode | input | character | Country code of the ship to address |
| ilShipFromCountryIsEUCountry | input | logical | Is the country code of the ship from address an EU country ? |
| ilShipToCountryIsEUCountry | input | logical | Is the country code of the ship to address an EU country ? |
| icTxclTaxCls | input | character | Tax Class of the debtor, or if the tax class on the tax tab is filled, then this one |
| icTxuTaxUsage | input | character | Tax usage of the debtor, or if the tax usage on the tax tab is filled, then this one |
| icShipFromTaxZone | input | character | Tax zone of Ship From |
| icShipToTxzTaxZone | input | character | Tax Zone of the Ship To Address |
| icTxenvTaxEnv | input | character | Tax Environment of the tax tab, if not filled yet, give the default value then |
| iiVoucher | input | integer | voucher of the invoice |
| icPaymentCondition | input | character | Payment condition of the invoice |
| ilIsTaxInCityFromShipTo | input | logical | tax in city flag from the ship to address |
| icControlGLCode | input | character | Control GL Account |
| iiMasterId | input | integer | Master Id : id of customer, supplier, ... |
| iiTransactionId | input | integer | Transaction id : id of customer invoice, supplier invoice, .... |
| ilIsTaxable | input | logical | Is Taxable flag |
| icCostCentreCode | input | character | |
| icProjectCode | input | character | |
| iiShipFromAddressId | input | integer | Ship From Address ID : necessary for addtaxposting to fill the postingvat fields federal tax id, state tax id, misc .... at manual journal entry fields can be blank |
| iiShipToAddressId | input | integer | ShipTo Address ID : necessary for addtaxposting to fill the postingvat fields federal tax id, state tax id, misc .... at manual journal entry fields can be blank |
| icSoldToDebtorCode | input | character | Sold To Debtor Code : only passed when it is the same as the ship to code |
| idInvoiceAmountTC | input | decimal | invoice amount tc |
| icShipFromTaxIDFeder | input | character | Tax ID Feder of the ship from address |
| icShipFromTaxIDState | input | character | Tax ID State of the ship from address |
| icShipFromTaxIDMisc1 | input | character | Tax ID Misc1 of the ship from address |
| icShipFromTaxIDMisc2 | input | character | Tax ID Misc2 of the ship from address |
| icShipFromTaxIDMisc3 | input | character | Tax ID Misc3 of the ship from address |
| iiShipFromTaxDeclaration | input | integer | Tax declaration of the ship from address |
| icShipToTaxIDFeder | input | character | Tax ID Feder of the ship to address |
| icShipToTaxIDState | input | character | Tax ID State of the ship to address |
| icShipToTaxIDMisc1 | input | character | Tax ID Misc1 of the ship to address |
| icShipToTaxIDMisc2 | input | character | Tax ID Misc2 of the ship to address |
| icShipToTaxIDMisc3 | input | character | Tax ID Misc3 of the ship to address |
| iiShipToTaxDeclaration | input | integer | Tax Declaration of the ship to address |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bdinvoice.p)
/* necessary when yuo modify the scond line of a vat code that is split up in mulitple lines */
if idInvoiceAmountTC <> 0 and
not can-find ( first tApiDInvoiceVat where
tApiDInvoiceVat.DInvoiceVatVatDebitTC <> 0 or
tApiDInvoiceVat.DInvoiceVatVatCreditTC <> 0) and
not can-find ( first tApiDInvoiceVat where
tApiDInvoiceVat.DInvoiceVatVatDebitTC = 0 and
tApiDInvoiceVat.DInvoiceVatVatCreditTC = 0 and
tApiDInvoiceVat.TxtyTaxType <> {&VATTAXTYPE-NONTAX})
then return.
if vlCompanyPropertyIsARUseTaxDate = true
then
assign vtExchangeRateDate = itTaxPointDate.
else
assign vtExchangeRateDate = ?.
for each tApiDInvoiceVat
break by tApiDInvoiceVat.TxclTaxCls
by tApiDInvoiceVat.TxuTaxUsage
by tApiDInvoiceVat.TxenvTaxEnv
by tApiDInvoiceVat.TxtyTaxType
by tApiDInvoiceVat.tcVatCode:
if first-of (tApiDInvoiceVat.tcVatCode)
then do:
assign vdDebitAmountTC = 0
vdCreditAmountTC = 0.
empty temp-table tTaxDetailDInvoice.
end.
if last-of (tApiDInvoiceVat.tcVatCode)
then do:
if icShipFromCountryCode = icShipToCountryCode and
ilShipFromCountryIsEUCountry = ilShipToCountryIsEUCountry
then assign vcTransactionType = {&VATTRANSACTIONTYPE-SALES}.
else if icShipFromCountryCode <> icShipToCountryCode
then assign vcTransactionType = if ilShipFromCountryIsEUCountry = yes and
ilShipFromCountryIsEUCountry = ilShipToCountryIsEUCountry
then {&VATTRANSACTIONTYPE-SUPPLY}
else {&VATTRANSACTIONTYPE-EXPORT}.
else assign vcTransactionType = "":U.
assign vdVatDebitTC = if tApiDInvoiceVat.DInvoiceVatIsAbsRet
then if icDInvoiceType = {&INVOICETYPE-INVOICE} or icDInvoiceType = {&INVOICETYPE-INVOICECORRECTION} or icDInvoiceType = {&INVOICETYPE-FINANCECHARGE}
then 0
else tApiDInvoiceVat.DInvoiceVatVatDebitTC
else tApiDInvoiceVat.DInvoiceVatVatDebitTC
vdVatCreditTC = if tApiDInvoiceVat.DInvoiceVatIsAbsRet
then if icDInvoiceType = {&INVOICETYPE-INVOICE} or icDInvoiceType = {&INVOICETYPE-INVOICECORRECTION} or icDInvoiceType = {&INVOICETYPE-FINANCECHARGE}
then tApiDInvoiceVat.DInvoiceVatVatCreditTC
else 0
else tApiDInvoiceVat.DInvoiceVatVatCreditTC
vdVatDebitLC = <M-5 RoundAmount
(input vdVatDebitTC * idExchangeRate * idExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BDInvoice>
vdVatCreditLC = <M-6 RoundAmount
(input vdVatCreditTC * idExchangeRate * idExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BDInvoice>.
<M-7 run AddPostingLineTax
(input icRowId (icPostingTcRowid),
input itTaxPointDate (itTaxPointDate),
input icDIText (icPostingLineText),
input icCurrencyCode (icCurrencyCode),
input tApiDInvoiceVat.tcVatInOut (icPostingVatInOut),
input tApiDInvoiceVat.tcVatCode (icPostingVatCode),
input tApiDInvoiceVat.tcDomainCode (icPostingVatDomain),
input idExchangeRate (idExchangeRate),
input idExchangeRateScale (idExchangeRateScale),
input icExchangeRateType (icExchangeRateType),
input ? (idCCExchangeRate),
input ? (idCCExchangeRateScale),
input vcTransactionType (icTransactionType),
input tApiDInvoiceVat.DInvoiceVatTaxTrType (icTaxTransactionType),
input tApiDInvoiceVat.DInvoiceVatVatBaseDebitTC (idBaseDebitTC),
input tApiDInvoiceVat.DInvoiceVatVatBaseCreditTC (idBaseCreditTC),
input tApiDInvoiceVat.DInvoiceVatVatBaseDebitLC (idBaseDebitLC),
input tApiDInvoiceVat.DInvoiceVatVatBaseCreditLC (idBaseCreditLC),
input tApiDInvoiceVat.DInvoiceVatVatBaseDebitCC (idBaseDebitCC),
input tApiDInvoiceVat.DInvoiceVatVatBaseCreditCC (idBaseCreditCC),
input vdVatDebitTC (idVatDebitTC),
input vdVatCreditTC (idVatCreditTC),
input vdVatDebitLC (idVatDebitLC),
input vdVatCreditLC (idVatCreditLC),
input ? (idVatDebitCC),
input ? (idVatCreditCC),
input if tApiDInvoiceVat.DInvoiceVatIsSuspDel = true then tApiDInvoiceVat.tcSuspDelTaxGLCode else tApiDInvoiceVat.tcNormalTaxGLCode (icNormalTaxGLCode),
input if tApiDInvoiceVat.DInvoiceVatIsSuspDel = true then tApiDInvoiceVat.tcSuspDelTaxDivisionCode else tApiDInvoiceVat.tcNormalTaxDivisionCode (icNormalTaxDivisionCode),
input false (ilNormalTaxIsAlreadyAbsRet),
input ? (icAbsRetTaxGLCode),
input ? (icAbsRetTaxDivisionCode),
input icShipFromTaxZone (icFromTaxZone),
input icshipToTxzTaxZone (icToTaxZone),
input tApiDInvoiceVat.TxenvTaxEnv (icTaxEnvrionment),
input tApiDInvoiceVat.DInvoiceVatIsTaxable (ilIsTaxable),
input tApiDInvoiceVat.TxclTaxCls (icTaxClass),
input tApiDInvoiceVat.TxuTaxUsage (icTaxUsage),
input tApiDInvoiceVat.TxtyTaxType (icTaxType),
input tApiDInvoiceVat.DInvoiceVatIsRevCharge (ilTaxIsReverseChargeDomestic),
input ? (iiTaxAddressID),
input icShipToTaxIDFeder (icTaxIDFeder),
input icShipToTaxIDState (icTaxIDState),
input icShipToTaxIDMisc1 (icTaxIDMisc1),
input icShipToTaxIDMisc2 (icTaxIDMisc2),
input icShipToTaxIDMisc3 (icTaxIDMisc3),
input ? (iiOwnAddressID),
input icShipFromTaxIDFeder (icOwnTaxIDFeder),
input icShipFromTaxIDState (icOwnTaxIDState),
input icShipFromTaxIDMisc1 (icOwnTaxIDMisc1),
input icShipFromTaxIDMisc2 (icOwnTaxIDMisc2),
input icShipFromTaxIDMisc3 (icOwnTaxIDMisc3),
input iiShipFromTaxDeclaration (iiOwnTaxIDDeclarat),
input tApiDInvoiceVat.DInvoiceVatIsSuspDel (ilIsSuspDel),
output viVatPostingLineId (oiNormalTaxPostingLineID),
output vcDummy (ocNormalTaxPostingLineTcRowid),
output viDummy (oiAbsRetTaxPostingLineID),
output vcDummy (ocAbsRetTaxPostingLineTcRowid),
output tApiDInvoiceVat.PostingVat_ID (oiNormalTaxPostingVatID),
input false (ilLinkedCrCyDaemonReqExists),
input no (ilCalledFromMoveSuspDelTax),
input vtExchangeRateDate (itInvoiceExchangeRateDate),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
/* if retained taxes */
if tApiDInvoiceVat.DInvoiceVatIsAbsRet
then do:
/* recalculate the lc values iso using the lc fields, because when you change manually the base amount, the tax lc are not calculated */
assign vdVatDebitTC = if icDInvoiceType = {&INVOICETYPE-INVOICE} or icDInvoiceType = {&INVOICETYPE-INVOICECORRECTION} or icDInvoiceType = {&INVOICETYPE-FINANCECHARGE}
then tApiDInvoiceVat.DInvoiceVatVatDebitTC
else 0
vdVatDebitLC = if icDInvoiceType = {&INVOICETYPE-INVOICE} or icDInvoiceType = {&INVOICETYPE-INVOICECORRECTION} or icDInvoiceType = {&INVOICETYPE-FINANCECHARGE}
then <M-8 RoundAmount
(input vdVatDebitTC * idExchangeRate * idExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BDInvoice>
else 0
vdVatCreditTC = if icDInvoiceType = {&INVOICETYPE-INVOICE} or icDInvoiceType = {&INVOICETYPE-INVOICECORRECTION} or icDInvoiceType = {&INVOICETYPE-FINANCECHARGE}
then 0
else tApiDInvoiceVat.DInvoiceVatVatCreditTC
vdVatCreditLC = if icDInvoiceType = {&INVOICETYPE-INVOICE} or icDInvoiceType = {&INVOICETYPE-INVOICECORRECTION} or icDInvoiceType = {&INVOICETYPE-FINANCECHARGE}
then 0
else <M-9 RoundAmount
(input vdVatCreditTC * idExchangeRate * idExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BDInvoice>.
<M-10 run AddPostingLineTax
(input icRowId (icPostingTcRowid),
input itTaxPointDate (itTaxPointDate),
input icDIText (icPostingLineText),
input icCurrencyCode (icCurrencyCode),
input tApiDInvoiceVat.tcVatInOut (icPostingVatInOut),
input tApiDInvoiceVat.tcVatCode (icPostingVatCode),
input tApiDInvoiceVat.tcDomainCode (icPostingVatDomain),
input idExchangeRate (idExchangeRate),
input idExchangeRateScale (idExchangeRateScale),
input icExchangeRateType (icExchangeRateType),
input ? (idCCExchangeRate),
input ? (idCCExchangeRateScale),
input vcTransactionType (icTransactionType),
input tApiDInvoiceVat.DInvoiceVatTaxTrType (icTaxTransactionType),
input tApiDInvoiceVat.DInvoiceVatVatBaseCreditTC (idBaseDebitTC),
input tApiDInvoiceVat.DInvoiceVatVatBaseDebitTC (idBaseCreditTC),
input tApiDInvoiceVat.DInvoiceVatVatBaseCreditLC (idBaseDebitLC),
input tApiDInvoiceVat.DInvoiceVatVatBaseDebitLC (idBaseCreditLC),
input tApiDInvoiceVat.DInvoiceVatVatBaseCreditCC (idBaseDebitCC),
input tApiDInvoiceVat.DInvoiceVatVatBaseDebitCC (idBaseCreditCC),
input vdVatDebitTC (idVatDebitTC),
input vdVatCreditTC (idVatCreditTC),
input vdVatDebitLC (idVatDebitLC),
input vdVatCreditLC (idVatCreditLC),
input ? (idVatDebitCC),
input ? (idVatCreditCC),
input tApiDInvoiceVat.tcAbsRetTaxGLCode (icNormalTaxGLCode),
input tApiDInvoiceVat.tcAbsRetTaxDivisionCode (icNormalTaxDivisionCode),
input true (ilNormalTaxIsAlreadyAbsRet),
input ? (icAbsRetTaxGLCode),
input ? (icAbsRetTaxDivisionCode),
input icShipFromTaxZone (icFromTaxZone),
input icshipToTxzTaxZone (icToTaxZone),
input tApiDInvoiceVat.TxenvTaxEnv (icTaxEnvrionment),
input tApiDInvoiceVat.DInvoiceVatIsTaxable (ilIsTaxable),
input tApiDInvoiceVat.TxclTaxCls (icTaxClass),
input tApiDInvoiceVat.TxuTaxUsage (icTaxUsage),
input tApiDInvoiceVat.TxtyTaxType (icTaxType),
input tApiDInvoiceVat.DInvoiceVatIsRevCharge (ilTaxIsReverseChargeDomestic),
input ? (iiTaxAddressID),
input icShipToTaxIDFeder (icTaxIDFeder),
input icShipToTaxIDState (icTaxIDState),
input icShipToTaxIDMisc1 (icTaxIDMisc1),
input icShipToTaxIDMisc2 (icTaxIDMisc2),
input icShipToTaxIDMisc3 (icTaxIDMisc3),
input ? (iiOwnAddressID),
input icShipFromTaxIDFeder (icOwnTaxIDFeder),
input icShipFromTaxIDState (icOwnTaxIDState),
input icShipFromTaxIDMisc1 (icOwnTaxIDMisc1),
input icShipFromTaxIDMisc2 (icOwnTaxIDMisc2),
input icShipFromTaxIDMisc3 (icOwnTaxIDMisc3),
input iiShipFromTaxDeclaration (iiOwnTaxIDDeclarat),
input ? (ilIsSuspDel),
output viVatPostingLineId (oiNormalTaxPostingLineID),
output vcDummy (ocNormalTaxPostingLineTcRowid),
output viDummy (oiAbsRetTaxPostingLineID),
output vcDummy (ocAbsRetTaxPostingLineTcRowid),
output viDummy (oiNormalTaxPostingVatID),
input false (ilLinkedCrCyDaemonReqExists),
input no (ilCalledFromMoveSuspDelTax),
input vtExchangeRateDate (itInvoiceExchangeRateDate),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
end.
end.
end.