project QadFinancials > class BDInvoice > method CreateDInvoiceMovementsSuspTax
Description
Create movement from Suspended tax account to nornal tax account
Parameters
odSuspTaxAmountTC | output | decimal | |
tMoveSuspendedTax | input-output | temp-table | |
itPaymentTaxPointDate | input | date | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program3/bdinvoice.p)
/* Create Suspended tax postinglines if needed */
for each tDInvoiceVat where tDInvoiceVat.DInvoice_ID = tDIMovement.tiDInvoiceId :
assign odSuspTaxAmountTC = 0.
if tDInvoiceVat.DInvoiceVatIsSuspDel = true and
tDIMovement.tlMovementIsForDraft = false and
tDIMovement.tlIsUndoPayment = false
then do:
<Q-1 run CompanyPropertyBySuspDelTax (all) (Read) (NoCache)
(input tDInvoice.Company_ID, (CompanyId)
input ?, (DelTax)
input ?, (SuspTax)
output dataset tqCompanyPropertyBySuspDelTax) in BCompanyProperty >
find first tqCompanyPropertyBySuspDelTax where
tqCompanyPropertyBySuspDelTax.tiCompany_ID = tDInvoice.Company_ID no-error.
if available tqCompanyPropertyBySuspDelTax
then do:
if tDIMovement.tiDDocumentId <> 0
then do:
if tqCompanyPropertyBySuspDelTax.tcCompanyPropertySuspTax = {&SUSPDELAYTAX-FIRSTPAY}
then assign odSuspTaxAmountTC = tDInvoiceVat.DInvoiceVatSuspDelTaxAmtTC.
else if tqCompanyPropertyBySuspDelTax.tcCompanyPropertySuspTax = {&SUSPDELAYTAX-LASTPAY} and
(((tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICE} or
tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICECORRECTION}) and
abs(tDInvoice.DInvoiceBalanceDebitTC) = tDIMovement.tdAmountCreditTC) OR
((tDInvoice.DInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tDInvoice.DInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}) and
abs(tDInvoice.DInvoiceBalanceCreditTC) = tDIMovement.tdAmountDebitTC))
then assign odSuspTaxAmountTC = tDInvoiceVat.DInvoiceVatSuspDelTaxAmtTC.
else if tqCompanyPropertyBySuspDelTax.tcCompanyPropertySuspTax = {&SUSPDELAYTAX-PROPORPAY}
then assign odSuspTaxAmountTC = if (((tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICE} or
tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICECORRECTION}) and
abs(tDInvoice.DInvoiceBalanceDebitTC) = tDIMovement.tdAmountCreditTC) OR
((tDInvoice.DInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tDInvoice.DInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}) and
abs(tDInvoice.DInvoiceBalanceCreditTC)= tDIMovement.tdAmountDebitTC))
then tDInvoiceVat.DInvoiceVatSuspDelTaxAmtTC
else if(tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICE} or
tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICECORRECTION})
then (tDIMovement.tdAmountCreditTC / abs(tDInvoice.DInvoiceOriginalDebitTC)) * tDInvoiceVat.DInvoiceVatSuspDelTaxAmtTC
else (tDIMovement.tdAmountDebitTC / abs(tDInvoice.DInvoiceOriginalCreditTC)) * tDInvoiceVat.DInvoiceVatSuspDelTaxAmtTC
odSuspTaxAmountTC = <M-2 RoundAmount
(input odSuspTaxAmountTC (idUnroundedAmount),
input tDInvoice.DInvoiceCurrency_ID (iiCurrencyID),
input ? (icCurrencyCode)) in business>.
else assign odSuspTaxAmountTC = 0.
end. /* if tDIMovement.tiDDocumentId <> 0 */
else do:
if tDIMovement.tlIsSuspTaxAtPartialPayment = false
then assign odSuspTaxAmountTC = if ((tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICE} or
tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICECORRECTION})and
abs(tDInvoice.DInvoiceBalanceDebitTC) = abs(tDIMovement.tdAmountCreditTC) and
tDIMovement.tdAmountCreditTC <> 0)
then tDInvoiceVat.DInvoiceVatSuspDelTaxAmtTC
else if ((tDInvoice.DInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tDInvoice.DInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION})and
abs(tDInvoice.DInvoiceBalanceCreditTC)= abs(tDIMovement.tdAmountDebitTC) and
tDIMovement.tdAmountDebitTC <> 0)
then tDInvoiceVat.DInvoiceVatSuspDelTaxAmtTC
else 0.
else do:
if tqCompanyPropertyBySuspDelTax.tcCompanyPropertySuspTax = {&SUSPDELAYTAX-FIRSTPAY} or
tqCompanyPropertyBySuspDelTax.tcCompanyPropertySuspTax = {&SUSPDELAYTAX-LASTPAY}
then do :
assign odSuspTaxAmountTC = if ((tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICE} or
tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICECORRECTION}) and
(if tqCompanyPropertyBySuspDelTax.tlCompanyPropertyIsSuspPaid = True or
tqCompanyPropertyBySuspDelTax.tcCompanyPropertySuspTax = {&SUSPDELAYTAX-LASTPAY}
then abs(tDInvoice.DInvoiceBalanceDebitTC) = abs(tDIMovement.tdAmountCreditTC)
else true) and
tDIMovement.tdAmountCreditTC <> 0)
then tDInvoiceVat.DInvoiceVatSuspDelTaxAmtTC
else if ((tDInvoice.DInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tDInvoice.DInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}) and
(if tqCompanyPropertyBySuspDelTax.tlCompanyPropertyIsSuspPaid = True or
tqCompanyPropertyBySuspDelTax.tcCompanyPropertySuspTax = {&SUSPDELAYTAX-LASTPAY}
then abs(tDInvoice.DInvoiceBalanceCreditTC) = abs(tDIMovement.tdAmountDebitTC)
else true) and
tDIMovement.tdAmountDebitTC <> 0)
then tDInvoiceVat.DInvoiceVatSuspDelTaxAmtTC
else 0.
end. /* tqCompanyPropertyBySuspDelTax.tcCompanyPropertySuspTax = {&SUSPDELAYTAX-FIRSTPAY} or {&SUSPDELAYTAX-LASTPAY} */
else if tqCompanyPropertyBySuspDelTax.tcCompanyPropertySuspTax = {&SUSPDELAYTAX-PROPORPAY}
then assign odSuspTaxAmountTC = if (((tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICE} or
tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICECORRECTION}) and
abs(tDInvoice.DInvoiceBalanceDebitTC) = tDIMovement.tdAmountCreditTC) OR
((tDInvoice.DInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tDInvoice.DInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}) and
abs(tDInvoice.DInvoiceBalanceCreditTC)= tDIMovement.tdAmountDebitTC))
then tDInvoiceVat.DInvoiceVatSuspDelTaxAmtTC
else if(tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICE} or
tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICECORRECTION})
then (tDIMovement.tdAmountCreditTC / abs(tDInvoice.DInvoiceOriginalDebitTC)) * tDInvoiceVat.DInvoiceVatSuspDelTaxAmtTC
else (tDIMovement.tdAmountDebitTC / abs(tDInvoice.DInvoiceOriginalCreditTC)) * tDInvoiceVat.DInvoiceVatSuspDelTaxAmtTC
odSuspTaxAmountTC = <M-91 RoundAmount
(input odSuspTaxAmountTC (idUnroundedAmount),
input tDInvoice.DInvoiceCurrency_ID (iiCurrencyID),
input ? (icCurrencyCode)) in business>.
else assign odSuspTaxAmountTC = 0.
end. /*if tax to be booked at partial payment */
end. /*if document id = 0*/
end. /* if available tqCompanyPropertyBySuspDelTax */
end. /* if available tDInvoiceVat and */
/* undo the suspended tax when the payment is undo */
if available tDInvoiceVat and
tDInvoiceVat.DInvoiceVatIsSuspDel = true and
tDIMovement.tlMovementIsForDraft = false and
tDIMovement.tlIsUndoPayment = true
then do:
<Q-3 run CompanyPropertyBySuspDelTax (all) (Read) (NoCache)
(input tDInvoice.Company_ID, (CompanyId)
input ?, (DelTax)
input ?, (SuspTax)
output dataset tqCompanyPropertyBySuspDelTax) in BCompanyProperty >
find first tqCompanyPropertyBySuspDelTax where
tqCompanyPropertyBySuspDelTax.tiCompany_ID = tDInvoice.Company_ID
no-error.
if available tqCompanyPropertyBySuspDelTax
then do:
if tDIMovement.tiDDocumentId <> 0
then do:
assign vcStatusList = {&DOCUMENTSTATUS-ACCEPT} + ',':U + {&DOCUMENTSTATUS-DISCONT} + ',':U + {&DOCUMENTSTATUS-INCASSO} + ',':U + {&DOCUMENTSTATUS-PORTFOLIO}.
<Q-4 assign vlFcQueryRecordsAvailable = DDocumentInvoiceXrefPostByStatus (NoCache)
(input vcStatusList, (DocumentStatus)
input ?, (DocumentType)
input tDInvoice.DInvoice_ID, (DInvoiceId)
input ?, (CompanyId)
input tDIMovement.tiDDocumentId, (DDocumentId)
input {&GLTYPECODE-VAT}, (GLTypeCode)) in BDDocument >
if vlFcQueryRecordsAvailable <> false
then do:
if tqCompanyPropertyBySuspDelTax.tcCompanyPropertySuspTax = {&SUSPDELAYTAX-FIRSTPAY} or
tqCompanyPropertyBySuspDelTax.tcCompanyPropertySuspTax = {&SUSPDELAYTAX-LASTPAY}
then do:
assign odSuspTaxAmountTC = if (tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICE} or
tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICECORRECTION})
then tDInvoiceVat.DInvoiceVatVatCreditTC
else tDInvoiceVat.DInvoiceVatVatDebitTC.
end.
else if tqCompanyPropertyBySuspDelTax.tcCompanyPropertySuspTax = {&SUSPDELAYTAX-PROPORPAY}
then do:
assign odSuspTaxAmountTC = if ((tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICE} or
tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICECORRECTION}) and
abs(tDInvoice.DInvoiceOriginalDebitTC)= abs(tDInvoice.DInvoiceBalanceDebitTC) + tDIMovement.tdAmountDebitTC)
then (tDInvoice.DInvoiceVatCreditTC - tDInvoiceVat.DInvoiceVatSuspDelTaxAmtTC)
else if ((tDInvoice.DInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tDInvoice.DInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}) and
abs(tDInvoice.DInvoiceOriginalCreditTC)= abs(tDInvoice.DInvoiceBalanceCreditTC) + tDIMovement.tdAmountCreditTC)
then (tDInvoice.DInvoiceVatDebitTC - tDInvoiceVat.DInvoiceVatSuspDelTaxAmtTC)
else if (tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICE} or
tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICECORRECTION})
then (tDIMovement.tdAmountDebitTC / abs(tDInvoice.DInvoiceOriginalDebitTC)) * tDInvoice.DInvoiceVatCreditTC
else (tDIMovement.tdAmountCreditTC / abs(tDInvoice.DInvoiceOriginalCreditTC)) * tDInvoice.DInvoiceVatDebitTC
odSuspTaxAmountTC = <M-6 RoundAmount
(input odSuspTaxAmountTC (idUnroundedAmount),
input tDInvoice.DInvoiceCurrency_ID (iiCurrencyID),
input ? (icCurrencyCode)) in business>.
end.
else assign odSuspTaxAmountTC = 0.
end. /* if vlFcQueryRecordsAvailable <> false */
end. /* if tDIMovement.tiDDocumentId <> 0 */
else do:
assign odSuspTaxAmountTC = if (tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICE} or
tDInvoice.DInvoiceType = {&INVOICETYPE-INVOICECORRECTION}) and
abs(tDInvoice.DInvoiceOriginalDebitTC)= abs(tDInvoice.DInvoiceBalanceDebitTC) + abs(tDIMovement.tdAmountDebitTC)
then tDInvoiceVat.DInvoiceVatVatCreditTC
else if (tDInvoice.DInvoiceType = {&INVOICETYPE-CREDITNOTE} or
tDInvoice.DInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}) and
abs(tDInvoice.DInvoiceOriginalCreditTC) = abs(tDInvoice.DInvoiceBalanceCreditTC) + abs(tDIMovement.tdAmountCreditTC)
then tDInvoiceVat.DInvoiceVatVatDebitTC
else 0.
end.
assign odSuspTaxAmountTC = - odSuspTaxAmountTC.
end. /* if available tqCompanyPropertyBySuspDelTax */
end. /* if tDDocument.tc_Status = 'C':U and */
if odSuspTaxAmountTC <> 0
then do :
create tMoveSuspendedTax.
assign tMoveSuspendedTax.tcPostingRowId = tDIMovement.tcPostingRowId
tMoveSuspendedTax.tdSuspTaxAmountTC = odSuspTaxAmountTC
tMoveSuspendedTax.tiDInvoiceId = tDIMovement.tiDInvoiceId
tMoveSuspendedTax.ttPaymentTaxPointDate = itPaymentTaxPointDate
tMoveSuspendedTax.tiDInvoiceVatId = tDInvoiceVat.DInvoiceVat_ID.
end. /* odSuspTaxAmountTC <> 0 */
end. /* for each tinvoicevat */