project QadFinancials > class BPosting > method ValidateComponentPreAssignPostingVat
Description
ValidateComponent before Ancestor tag: Assign postingvat.VatPeriod_ID + PeriodMark_ID.
Parameters
bcCurrencyCode | input-output | character | |
blCurrencyFetched | input-output | logical | |
bdCCExchangeRate | input-output | decimal | |
bdCCExchangeScale | input-output | decimal | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bposting.p)
/* ===================== */
/* Exception handling */
/* ===================== */
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
POSTINGVATBLOCK:
DO:
/* ================================ */
/* Assign tPostingVat.VatPeriod_ID */
/* Assign tPostingVat.PeriodMark_ID */
/* ================================ */
if vcActivityCode = "JournalEntryTransExcelIntegration":U or
vcActivityCode = "JournalEntryExcelIntegrationRepair":U or
vcActivityCode = "ExcelIntegration"
then if t_sPostingVat.PostingVatTaxPointDate = ?
then assign t_sPostingVat.PostingVatTaxPointDate = t_sPosting.PostingDate.
<Q-2 run VatPeriodByStartEndDate (all) (Read) (Cache)
(input t_sPosting.Company_ID, (CompanyId)
input t_sPostingVat.PostingVatTaxPointDate, (Date)
input '':U, (Status)
output dataset tqVatPeriodByStartEndDate) in BVATPeriod >
find first tqVatPeriodByStartEndDate where
tqVatPeriodByStartEndDate.tiCompany_ID = t_sPosting.Company_ID and
tqVatPeriodByStartEndDate.ttVatPeriodStartDate <= t_sPostingVat.PostingVatTaxPointDate and
tqVatPeriodByStartEndDate.ttVatPeriodEndDate >= t_sPostingVat.PostingVatTaxPointDate
no-error.
if not available tqVatPeriodByStartEndDate
then do:
assign vcMsgExplanation = <M-76 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
vcDatetemp = <M-97 DisplayDate (input t_sPostingVat.PostingVatTaxPointDate (itDate)) in BPosting>.
assign vcMessage = trim(substitute(#T-35'Error retrieving Tax period for Tax point date &1':255(59643588)T-35#,vcDatetemp)).
<M-62 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPostingVat.PostingVatTaxPointDate':U (icFieldName),
input vcDatetemp (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingVat.tc_Rowid (icRowid),
input 'qadfin-762654':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign viLocalReturnStatus = -1.
leave POSTINGVATBLOCK.
end. /* if not available tqVatPeriodByStartEndDate */
if available tqVatPeriodByStartEndDate and
tqVatPeriodByStartEndDate.tcVatPeriodStatus <> {&VATPERIODSTATUS-OPEN}
then do:
assign vcMsgExplanation = <M-26 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(substitute(#T-83'Tax period is not open for Tax point date.':255(16828565)T-83#)).
vcDatetemp = <M-60 DisplayDate (input t_sPostingVat.PostingVatTaxPointDate (itDate)) in BPosting>.
<M-3 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPostingVat.PostingVatTaxPointDate':U (icFieldName),
input vcDatetemp (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingVat.tc_Rowid (icRowid),
input 'QadFin-7271':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign viLocalReturnStatus = -1.
leave POSTINGVATBLOCK.
end. /* if not available tqVatPeriodByStartEndDate */
assign t_sPostingVat.VatPeriod_ID = tqVatPeriodByStartEndDate.tiVatPeriod_ID
t_sPostingVat.PeriodMark_ID = tqVatPeriodByStartEndDate.tiPeriodMark_ID.
/* ============================== */
/* Assign LC Amounts & CC Amounts */
/* ============================== */
if t_sPosting.tc_Status <> "D":U and
t_sPostingLine.tcCurrencyCode <> '':U and
t_sPostingLine.tcCurrencyCode <> ? and
(t_sPostingLine.tc_Status = "N":U or
t_sPostingLine.tc_Status = "C":U) and
t_sPostingVat.tc_Status = "N":U
then do:
/* ====================================== */
/* Assign the LC-amounts & Rates */
/* This is not done for external postings */
/* ====================================== */
if t_sPosting.PostingIsSkipAutoAssignLC = false and
t_sPostingVat.PostingVatBaseDebitTC <> 0 and
t_sPostingVat.PostingVatBaseDebitTC <> ? and
t_sPostingVat.PostingVatBaseCreditTC <> 0 and
t_sPostingVat.PostingVatBaseCreditTC <> ?
then do:
if t_sPostingLine.tcCurrencyCode = vcCompanyLC
then assign t_sPostingVat.PostingVatBaseCreditLC = t_sPostingVat.PostingVatBaseCreditTC
t_sPostingVat.PostingVatBaseDebitLC = t_sPostingVat.PostingVatBaseDebitTC
t_sPostingVat.PostingVatExchangeRate = 1
t_sPostingVat.PostingVatRateScale = 1.
else do:
<M-73 run GetExchangeRate
(input t_sPosting.Company_ID (iiCompanyID),
input ? (iiFromCurrencyID),
input t_sPostingLine.tcCurrencyCode (icFromCurrencyCode),
input viCompanyLCID (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode),
input t_sPosting.PostingDate (itValidityDate),
output vdRate (odExchangeRate),
output vdRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave POSTINGVATBLOCK.
assign bcCurrencyCode = t_sPostingLine.tcCurrencyCode.
if t_sPostingVat.PostingVatBaseDebitTC <> 0 and
t_sPostingVat.PostingVatBaseDebitTC <> ?
then assign t_sPostingVat.PostingVatBaseDebitLC = <M-6 RoundAmount
(input t_sPostingVat.PostingVatBaseDebitTC * vdRate * vdRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>.
if t_sPostingLine.PostingLineCreditTC <> 0 and
t_sPostingLine.PostingLineCreditTC <> ?
then assign t_sPostingVat.PostingVatBaseCreditLC = <M-7 RoundAmount
(input t_sPostingVat.PostingVatBaseCreditTC * vdRate * vdRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>.
assign t_sPostingVat.PostingVatExchangeRate = 1
t_sPostingVat.PostingVatRateScale = 1.
end. /* Not if t_sPostingLine.tcCurrencyCode = vcCompanyLC */
end. /* if t_sPostingVat.PostingVatBaseDebitTC <> 0 and */
/* ====================================== */
/* Assign the LC-amounts & Rates */
/* This is not done for external postings */
/* ====================================== */
if t_sPosting.PostingIsSkipAutoAssignLC = false and
t_sPostingVat.PostingVatTaxDebitTC <> 0 and
t_sPostingVat.PostingVatTaxDebitTC <> ? and
(t_sPostingVat.PostingVatTaxDebitLC = 0 or
t_sPostingVat.PostingVatTaxDebitLC = ?) or
t_sPostingVat.PostingVatTaxCreditTC <> 0 and
t_sPostingVat.PostingVatTaxCreditTC <> ? and
(t_sPostingVat.PostingVatTaxCreditLC = 0 or
t_sPostingVat.PostingVatTaxCreditLC = ?)
then do:
if t_sPostingLine.tcCurrencyCode = vcCompanyLC
then assign t_sPostingVat.PostingVatTaxCreditLC = t_sPostingVat.PostingVatTaxCreditTC
t_sPostingVat.PostingVatTaxDebitLC = t_sPostingVat.PostingVatTaxDebitTC
t_sPostingVat.PostingVatExchangeRate = 1
t_sPostingVat.PostingVatRateScale = 1.
else do:
<M-69 run GetExchangeRate
(input t_sPosting.Company_ID (iiCompanyID),
input ? (iiFromCurrencyID),
input t_sPostingLine.tcCurrencyCode (icFromCurrencyCode),
input viCompanyLCID (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode),
input t_sPosting.PostingDate (itValidityDate),
output vdRate (odExchangeRate),
output vdRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave POSTINGVATBLOCK.
assign bcCurrencyCode = t_sPostingLine.tcCurrencyCode.
if t_sPostingVat.PostingVatTaxDebitTC <> 0 and
t_sPostingVat.PostingVatTaxDebitTC <> ?
then assign t_sPostingVat.PostingVatTaxDebitLC = <M-9 RoundAmount
(input t_sPostingVat.PostingVatTaxDebitTC * vdRate * vdRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in business>.
if t_sPostingVat.PostingVatTaxCreditTC <> 0 and
t_sPostingVat.PostingVatTaxCreditTC <> ?
then assign t_sPostingVat.PostingVatTaxCreditLC = <M-10 RoundAmount
(input t_sPostingVat.PostingVatTaxCreditTC * vdRate * vdRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in business>.
assign t_sPostingVat.PostingVatExchangeRate = 1
t_sPostingVat.PostingVatRateScale = 1.
end. /* Not if t_sPostingLine.tcCurrencyCode = vcCompanyLC */
end. /* if t_sPostingVat.PostingVatTaxDebitTC <> 0 and */
/* ================= */
/* Assign CC Amounts */
/* ================= */
if t_sPostingVat.PostingVatBaseDebitCC = ? and
t_sPostingVat.PostingVatBaseDebitTC = 0 and
t_sPostingVat.PostingVatBaseDebitTC = 0
then assign t_sPostingVat.PostingVatBaseDebitCC = 0.
if t_sPostingVat.PostingVatBaseCreditCC = ? and
t_sPostingVat.PostingVatBaseCreditLC = 0 and
t_sPostingVat.PostingVatBaseCreditTC = 0
then assign t_sPostingVat.PostingVatBaseCreditCC = 0.
if t_sPostingVat.PostingVatTaxDebitCC = ? and
t_sPostingVat.PostingVatTaxDebitTC = 0 and
t_sPostingVat.PostingVatTaxDebitTC = 0
then assign t_sPostingVat.PostingVatTaxDebitCC = 0.
if t_sPostingVat.PostingVatTaxCreditCC = ? and
t_sPostingVat.PostingVatTaxCreditLC = 0 and
t_sPostingVat.PostingVatTaxCreditTC = 0
then assign t_sPostingVat.PostingVatTaxCreditCC = 0.
if (((t_sPostingVat.PostingVatBaseDebitTC <> 0 and
t_sPostingVat.PostingVatBaseDebitTC <> ?) or
(t_sPostingVat.PostingVatBaseDebitLC <> 0 and
t_sPostingVat.PostingVatBaseDebitLC <> ?)) and
(t_sPostingVat.PostingVatBaseDebitCC = 0 or
t_sPostingVat.PostingVatBaseDebitCC = ?)) OR
(((t_sPostingVat.PostingVatBaseCreditTC <> 0 and
t_sPostingVat.PostingVatBaseCreditTC <> ?) or
(t_sPostingVat.PostingVatBaseCreditLC <> 0 and
t_sPostingVat.PostingVatBaseCreditLC <> ?)) and
(t_sPostingVat.PostingVatBaseCreditCC = 0 or
t_sPostingVat.PostingVatBaseCreditCC = ?)) OR
(((t_sPostingVat.PostingVatTaxDebitTC <> 0 and
t_sPostingVat.PostingVatTaxDebitTC <> ?) or
(t_sPostingVat.PostingVatTaxDebitLC <> 0 and
t_sPostingVat.PostingVatTaxDebitLC <> ?))) OR
(((t_sPostingVat.PostingVatTaxCreditTC <> 0 and
t_sPostingVat.PostingVatTaxCreditTC <> ?) or
(t_sPostingVat.PostingVatTaxCreditLC <> 0 and
t_sPostingVat.PostingVatTaxCreditLC <> ?)))
then do:
if t_sPostingLine.tcCurrencyCode = vcCompanyCC
then assign t_sPostingVat.PostingVatBaseCreditCC = t_sPostingVat.PostingVatBaseCreditTC
t_sPostingVat.PostingVatBaseDebitCC = t_sPostingVat.PostingVatBaseDebitTC
t_sPostingVat.PostingVatTaxCreditCC = t_sPostingVat.PostingVatTaxCreditTC
t_sPostingVat.PostingVatTaxDebitCC = t_sPostingVat.PostingVatTaxDebitTC.
else
if vlDomainIsStatutory = false
then assign t_sPostingVat.PostingVatBaseCreditCC = t_sPostingVat.PostingVatBaseCreditLC
t_sPostingVat.PostingVatBaseDebitCC = t_sPostingVat.PostingVatBaseDebitLC
t_sPostingVat.PostingVatTaxCreditCC = t_sPostingVat.PostingVatTaxCreditLC
t_sPostingVat.PostingVatTaxDebitCC = t_sPostingVat.PostingVatTaxDebitLC.
else do:
if not blCurrencyFetched
then do:
<M-31 run GetExchangeRate
(input t_sPosting.Company_ID (iiCompanyID),
input ? (iiFromCurrencyID),
input t_sPostingLine.tcCurrencyCode (icFromCurrencyCode),
input viCompanyCCID (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-STATUTORY} (icExchangeRateTypeCode),
input t_sPosting.PostingDate (itValidityDate),
output bdCCExchangeRate (odExchangeRate),
output bdCCExchangeScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0 and viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave POSTINGVATBLOCK.
assign blCurrencyFetched = true.
end. /* if not blCurrencyFetched */
if t_sPostingVat.PostingVatBaseDebitTC <> 0 and
t_sPostingVat.PostingVatBaseDebitTC <> ?
then assign t_sPostingVat.PostingVatBaseDebitCC = <M-12 RoundAmount
(input t_sPostingVat.PostingVatBaseDebitTC * bdCCExchangeRate * bdCCExchangeScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in business>.
if t_sPostingVat.PostingVatBaseCreditTC <> 0 and
t_sPostingVat.PostingVatBaseCreditTC <> ?
then assign t_sPostingVat.PostingVatBaseCreditCC = <M-13 RoundAmount
(input t_sPostingVat.PostingVatBaseCreditTC * bdCCExchangeRate * bdCCExchangeScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in business>.
if t_sPostingVat.PostingVatTaxDebitTC <> 0 and
t_sPostingVat.PostingVatTaxDebitTC <> ?
then assign t_sPostingVat.PostingVatTaxDebitCC = <M-14 RoundAmount
(input t_sPostingVat.PostingVatTaxDebitTC * bdCCExchangeRate * bdCCExchangeScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in business>.
if t_sPostingVat.PostingVatTaxCreditTC <> 0 and
t_sPostingVat.PostingVatTaxCreditTC <> ?
then assign t_sPostingVat.PostingVatTaxCreditCC = <M-15 RoundAmount
(input t_sPostingVat.PostingVatTaxCreditTC * bdCCExchangeRate * bdCCExchangeScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in business>.
end. /* Not if vlDomainIsStatutory = false */
end. /* if (((t_sPostingVat.PostingVatBaseDebitTC <> 0 and */
end. /* if t_sPostingVat.tc_Status = "N":U */
end. /* POSTINGVATBLOCK */
/* ===================== */
/* Exception handling */
/* ===================== */
assign oiReturnStatus = viLocalReturnStatus.