project QadFinancials > class BCInvoice > method DefaultValuesReverse
Description
Default values for reverse of supplier invoice
Parameters
| icRowId | input | character | |
| ocReverseWithList | output | character | |
| ocReverseWith | output | character | |
| oiReverseYear | output | integer | |
| oiReversePeriod | output | integer | |
| otReverseDate | output | date | |
| ocReverseInvJournal | output | character | |
| oiReverseInvVoucher | output | integer | |
| ocReverseAdjJournal | output | character | |
| oiReverseAdjVoucher | output | integer | |
| ocReverseDaybookSet | output | character | |
| ocReverseSite | output | character | |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program3/bcinvoice.p)
/* =================================================================================================== */
/* Method : DefaultValuesReverse */
/* Desc : This method calculates default values for supplier invoice reversal functionality */
/* --------------------------------------------------------------------------------------------------- */
/* Params: (I) icRowId Row id of supplier invoice to be reversed */
/* (O) ocReverseWithList List of applicable invoice types which can be used for reverse */
/* (O) ocReverseWith Default invoice type which can be used for reverse operation */
/* (O) oiReverseYear Default posting year for reversal */
/* (O) oiReversePeriod Default posting period for reversal */
/* (O) otReverseDate Default posting date for reversal */
/* (O) ocReverseInvJournal Default invoice journal used for reversal invoice */
/* (O) oiReverseInvVoucher Default invoice voucher used for reversal invoice */
/* (O) ocReverseAdjJournal Default adjustment journal used for adjustment posting */
/* (O) oiReverseAdjVoucher Default asjustment voucher used for adjustment posting */
/* =================================================================================================== */
assign oiReturnStatus = -98.
/* =================================================================================================== */
/* Default output values */
/* =================================================================================================== */
assign ocReverseWithList = "":U
ocReverseWith = "":U
oiReverseYear = ?
oiReversePeriod = ?
otReverseDate = ?
ocReverseInvJournal = "":U
oiReverseInvVoucher = ?
ocReverseAdjJournal = "":U
oiReverseAdjVoucher = ?.
/* =================================================================================================== */
/* Normalize input parameters */
/* =================================================================================================== */
if icRowId = "":U then assign icRowId = ?.
/* =================================================================================================== */
/* Validate input parameters */
/* =================================================================================================== */
if icRowId = ?
then do:
assign vcMessage = #T-1'The system could not retrieve the default values to reverse the supplier invoice.':255(69094)t-1#
vcContext = "icRowId=?":U.
<M-2 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7868':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
assign oiReturnStatus = -1.
return.
end.
/* =================================================================================================== */
/* Get supplier invoice record which is reversed */
/* =================================================================================================== */
find tCInvoice where
tCInvoice.tc_Rowid = icRowId
no-error.
if not available tCInvoice
then do:
assign vcMessage = #T-12'The system could not retrieve the default values to reverse the supplier invoice.':255(69094)t-12#
vcContext = substitute("icRowId=&1":U, icRowId).
<M-11 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7882':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
assign oiReturnStatus = -1.
return.
end.
/* =================================================================================================== */
/* Validate whether supplier invoice can be reversed */
/* =================================================================================================== */
<M-3 run ReverseCInvoiceValidateStatus (output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
/* =================================================================================================== */
/* Get list of valid invoice types which can be used for reverse operation */
/* =================================================================================================== */
<M-13 run DefaultValuesReverseInvoiceTypes
(input tCInvoice.CInvoiceType (icOriginalInvoiceType),
output ocReverseWithList (ocReverseInvoiceTypes),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
/* Do defaulting of type when there is only one */
if num-entries(ocReverseWithList, chr(2)) >= 2
then assign ocReverseWith = entry(2, ocReverseWithList, chr(2)).
/* =================================================================================================== */
/* Daybook Set and Site */
/* =================================================================================================== */
assign ocReverseDaybookSet = tCInvoice.CInvoiceDayBookSetCode
ocReverseSite = tCInvoice.CInvoiceSiteCode.
/* =================================================================================================== */
/* Posting date, year and period */
/* =================================================================================================== */
/* First get it from original invoice, and check, whether period is open for AP */
assign otReverseDate = tCInvoice.CInvoicePostingDate
oiReverseYear = tCInvoice.CInvoicePostingYear
oiReversePeriod = tCInvoice.CInvoicePostingPeriod.
<M-9 run DefaultValuesReversePeriod
(input-output otReverseDate (btDate),
input-output oiReverseYear (biYear),
input-output oiReversePeriod (biPeriod),
input true (ilIfNeededDefaultToday),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
/* =================================================================================================== */
/* Journal and voucher */
/* =================================================================================================== */
<M-10 run DefaultValuesReverseDaybook
(input icRowId (icCInvoiceRowId),
input ocReverseWith (icReverseInvoiceType),
input oiReverseYear (iiReverseInvoiceYear),
output ocReverseInvJournal (ocReverseInvoiceJournal),
output oiReverseInvVoucher (oiReverseInvoiceVoucher),
output ocReverseAdjJournal (ocAdjustmentJournal),
output oiReverseAdjVoucher (oiAdjustmentVoucher),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
/* =================================================================================================== */
/* Return */
/* =================================================================================================== */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.