Description
OIAdjCommitSubCInvoiceCreateWHT: Submethod of OIAdjCommitSubCInvoice. This has to be in the same segment as the calling method, since we will use records that are already available there.
Parameters
biWHTNumber | input-output | integer | WHTNumber |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program8/bopenitemadjustment.p)
/* ====================================================================== */
/* Create two extra movements in case there is WHT on the OI Adjustment: */
/* - One line with tlMovementIsAboutWHT set to false (to automatically */
/* handle the posting on the control account in BCInvoice) */
/* - one line with tlMovementIsAboutWHT set to true (to automatically */
/* handle WHT posting line in BCInvoice) */
/* Do not pass in the LC or CC Rates so class BCInvoice will use the */
/* rates of the invoices to get the LC and CC amounts for the movement */
/* ====================================================================== */
if tOIAdj.tdAdjustmentWHTAmountTC <> 0 and
tOIAdj.tdAdjustmentWHTAmountTC <> ?
then do:
create tOICMovement.
assign tOICMovement.tiCInvoiceId = tOIAdj.tiInvoiceID
tOICMovement.tcGLAccountDivisionCode = "":U
tOICMovement.tdAmountDebitTC = if tOIAdj.tcAdjustmentCrDt = {&CREDITDEBITABBREVIATION-DEBIT}
then tOIAdj.tdAdjustmentWHTAmountTC
else 0
tOICMovement.tdAmountCreditTC = if tOIAdj.tcAdjustmentCrDt = {&CREDITDEBITABBREVIATION-CREDIT}
then tOIAdj.tdAdjustmentWHTAmountTC
else 0
tOICMovement.tcPostingRowId = vcMainPostingTcRowid
tOICMovement.tcPostingText = vcMainDescription
tOICMovement.tdCInvoiceHoldAmountTC = ? /* Set to unknown-value to make sure this field in the invoice is not updated */
tOICMovement.tlMovementisForDraft = false
tOICMovement.tlIsUndoPayment = (if tOIAdj.tdNewBalanceTC = tOIAdj.tdInvoiceOriginalBalanceTC
then true
else false)
tOICMovement.tlMovementIsAboutWHT = false
tOICMovement.tdMovementDiscountTC = 0
tOICMovement.tdRateTCLC = 0
tOICMovement.tdScaleTCLC = 0
tOICMovement.tdRateTCCC = 0
tOICMovement.tdScaleTCCC = 0
tOICMovement.tlIsDelTaxAtPartialPayment = false.
/* Get the exchange rates (TC>LC and TC>CC) for VAT at the date of the OI Adjustment */
assign vcExchangeRateType = {&EXCHANGERATETYPE-VAT}.
<M-59 run GetExchangeRateAndScale
(input ? (iiFromCurrencyId),
input tOIAdj.tcInvoiceCurrencyCode (icFromCurrencyCode),
input viCompanyLCId (iiToCurrencyId),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeId),
input vcExchangeRateType (icExchangeRateTypeCode),
input false (ilisCustomer),
input tOIAdj.ttInvoiceDate (itInvoiceDate),
input vtMainPostingDate (itPostingDate),
input tOIAdj.tcInvoiceType (icInvoiceType),
output vdWHTLCRate (odExchangeRate),
output vdWHTLCRateScale (odExchangeRateScale),
output viFcReturnSuper (oiReturnStatus)) in BOpenItemAdjustment>
if viFcReturnSuper < 0 or oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave.
assign vcExchangeRateType = {&EXCHANGERATETYPE-VAT}.
<M-86 run GetExchangeRateAndScale
(input ? (iiFromCurrencyId),
input tOIAdj.tcInvoiceCurrencyCode (icFromCurrencyCode),
input viCompanyCCId (iiToCurrencyId),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeId),
input vcExchangeRateType (icExchangeRateTypeCode),
input false (ilisCustomer),
input tOIAdj.ttInvoiceDate (itInvoiceDate),
input vtMainPostingDate (itPostingDate),
input tOIAdj.tcInvoiceType (icInvoiceType),
output vdWHTCCRate (odExchangeRate),
output vdWHTCCRateScale (odExchangeRateScale),
output viFcReturnSuper (oiReturnStatus)) in BOpenItemAdjustment>
if viFcReturnSuper < 0 or oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave.
/* Create the movement for WHT */
create tOICMovement.
assign tOICMovement.tiCInvoiceId = tOIAdj.tiInvoiceID
tOICMovement.tcGLAccountDivisionCode = "":U
tOICMovement.tdAmountDebitTC = if tOIAdj.tcAdjustmentCrDt = {&CREDITDEBITABBREVIATION-CREDIT}
then tOIAdj.tdAdjustmentWHTAmountTC
else 0
tOICMovement.tdAmountCreditTC = if tOIAdj.tcAdjustmentCrDt = {&CREDITDEBITABBREVIATION-DEBIT}
then tOIAdj.tdAdjustmentWHTAmountTC
else 0
tOICMovement.tcPostingRowId = vcMainPostingTcRowid
tOICMovement.tcPostingText = vcMainDescription
tOICMovement.tdCInvoiceHoldAmountTC = ? /* Set to unknown-value to make sure this field in the invoice is not updated */
tOICMovement.tlMovementisForDraft = false
tOICMovement.tlIsUndoPayment = (if tOIAdj.tdNewBalanceTC = tOIAdj.tdInvoiceOriginalBalanceTC
then true
else false)
tOICMovement.tlMovementIsAboutWHT = true
tOICMovement.tdMovementDiscountTC = 0
tOICMovement.tdRateTCLC = vdWHTLCRate
tOICMovement.tdScaleTCLC = vdWHTLCRateScale
tOICMovement.tdRateTCCC = vdWHTCCRate
tOICMovement.tdScaleTCCC = vdWHTCCRateScale.
/* ============================================================================================= */
/* Get the WHT-number if we had no WHT-number yet for this bank state line + company combination */
/* ============================================================================================= */
if biWHTNumber = 0
then do :
assign vhFcComponent = ?.
<M-2 run GetNumber
(input tOIAdj.tiCompanyId (iiCompanyId),
input 9999 (iiNumbrYear),
input 'WHT':U (icNumbrType),
output biWHTNumber (oiNumber),
input viFcCurrentInstanceId (iiInstanceId),
input vcFcComponentName (icClassName),
output viFcReturnSuper (oiReturnStatus)) in BNumber>
if viFcReturnSuper < 0 or oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave.
if vcReleaseWHTNumberList = "" or vcReleaseWHTNumberList = ?
then assign vcReleaseWHTNumberList = string(biWHTNumber).
else assign vcReleaseWHTNumberList = vcReleaseWHTNumberList + chr(4) + string(biWHTNumber).
end. /* if biWHTNumber = 0 */
/* ============================================================================================ */
/* create the WHT */
/* make sure the wht number is reset for each company. You only get a wht number if wht is used */
/* and we have no number yet and it concerns a new document. the number is retrieved from the */
/* entity/domain where the invoice is created. This is done in the calling method. */
/* ============================================================================================ */
create tInvoiceWHTPaymentForOIA.
assign tInvoiceWHTPaymentForOIA.tiCInvoiceID = tOIAdj.tiInvoiceID
tInvoiceWHTPaymentForOIA.tdAllocatedAmountTC = tOIAdj.tdAdjustmentAmountTC
tInvoiceWHTPaymentForOIA.tdDiscountAmountTC = tOIAdj.tdAdjustmentDiscountAmountTC
tInvoiceWHTPaymentForOIA.tdWHTTaxableFeeTC = tOIAdj.tdAdjustmentWHTTaxFeeTC
tInvoiceWHTPaymentForOIA.tdWHTAmountTC = tOIAdj.tdAdjustmentWHTAmountTC
tInvoiceWHTPaymentForOIA.tlCreateWHT = true
tInvoiceWHTPaymentForOIA.tiWHTNumber = biWHTNumber
tInvoiceWHTPaymentForOIA.tcPaymentReference = substring(
string(viMainPostingYear, "9999") + "/" +
trim(vcMainPostingJournalCode) + "/" +
string(viMainPostingVoucher, "999999999"), 1, 40, "CHARACTER")
tInvoiceWHTPaymentForOIA.tcCurrencyCode = tOIAdj.tcInvoiceCurrencyCode
tInvoiceWHTPaymentForOIA.tiCDocumentInvoiceXrefID = ?
tInvoiceWHTPaymentForOIA.tiBankStateAllocID = ?
tInvoiceWHTPaymentForOIA.tiOIAjustLnID = tOIAdj.tiOIAdjustLnId
tInvoiceWHTPaymentForOIA.ttPostingDate = vtMainPostingDate
tInvoiceWHTPaymentForOIA.tcWHTStatus = {&WHTSTATUS-DUE}
tInvoiceWHTPaymentForOIA.ttSettlementDate = ?
tInvoiceWHTPaymentForOIA.tlUpdateAllAmounts = false
tInvoiceWHTPaymentForOIA.tdPaymentWHTRateTCLC = tOIAdj.tdAdjustmentWHTLCRate
tInvoiceWHTPaymentForOIA.tdPaymentWHTScaleTCLC = tOIAdj.tdAdjustmentWHTLCScale
tInvoiceWHTPaymentForOIA.tdPaymentWHTRateTCCC = tOIAdj.tdAdjustmentWHTCCRate
tInvoiceWHTPaymentForOIA.tdPaymentWHTScaleTCCC = tOIAdj.tdAdjustmentWHTCCScale
tInvoiceWHTPaymentForOIA.tdPaymentAccRateTCLC = tOIAdj.tdAdjustmentExchangeRate
tInvoiceWHTPaymentForOIA.tdPaymentAccScaleTCLC = tOIAdj.tdAdjustmentExchangeRateScale
tInvoiceWHTPaymentForOIA.tdPaymentAccRateTCCC = tOIAdj.tdAdjustmentCCExchangeRate
tInvoiceWHTPaymentForOIA.tdPaymentAccScaleTCCC = tOIAdj.tdAdjustmentCCExchangeScale
tInvoiceWHTPaymentForOIA.tiPaymentAccountingYear = viMainPostingYear
tInvoiceWHTPaymentForOIA.tiPaymentAccountingPeriod = viMainPostingPeriod.
end. /* if tOIAdj.tdAdjustmentWHTAmountTC <> 0 and */