project QadFinancials > class BMFGLegalDocument > method GetLegalDocumentDetForAPMatchingLCDist
Description
This procedure retrieves details for legal document line for Material
Parameters
icLgdDomain | input | character | |
icLgdNbr | input | character | |
icLgdShipFrom | input | character | |
itLgdEffDate | input | date | |
icLgddLcCharge | input | character | |
iiLgddLine | input | integer | |
iiLgddOrderLine | input | integer | |
idTotalAmountLC | input | decimal | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bmfglegaldocument.p)
/* ====================================================================================== *
* Method : GetLgddDetMatForAPMatchingLCDist *
* Description : This method retrieves distribution of the logistical charges across *
* multiple orders *
* ====================================================================================== */
define variable doLacdDistribOfLcChargeForLegalDoc as com.qad.eefin.bmfglogisticsaccounting.LacdDistribOfLcChargeForLegalDoc.
define variable doPvoMstr as com.qad.eefin.bmfgpendingvoucher.PvoMstrByRef.
MAIN_BLOCK:
do on error undo, throw:
/* =================================================================================================================================== *
* Get all distributions of the logistical chargers for the legal document line *
* =================================================================================================================================== */
/* Calculate all compoused keys for data retrieval */
assign vcInternalRef = substitute("&1::&2::&3&4&5::&6::&7::&8":U,
icLgdNbr, /* LC Legal document number */
icLgdShipFrom, /* LC Legal document ship from */
string(year(itLgdEffDate), "9999"), /* LC Legal document effective date */
string(month(itLgdEffDate), "9999"), /* LC Legal document effective date */
string(day(itLgdEffDate), "99"), /* LC Legal document effective date */
icLgddLcCharge, /* Logistic charge */
string(iiLgddLine, ">>9"), /* LC Legal document line number */
string(iiLgddOrderLine, ">>9")). /* LC Legal document order line */
/* Read data from database */
publish "Logging.BusinessCode":U ("START-SUB,LacdDistribOfLcChargeForLegalDoc":U,
replace(substitute("In:icLgdDomain=&1|In:vcInternalRef=&2|In:icLgddLcCharge=&3|In:icLgdShipFrom=&4":U,
icLgdDomain,vcInternalRef,icLgddLcCharge,icLgdShipFrom),
"|":U, chr(10))).
doLacdDistribOfLcChargeForLegalDoc = new com.qad.eefin.bmfglogisticsaccounting.LacdDistribOfLcChargeForLegalDoc(
icLgdDomain, /* Lacd domain */
"13", /* Lacd internal ref type */
vcInternalRef, /* Lacd internrl reference */
icLgddLcCharge, /* Lacd logistic charge */
icLgdShipFrom). /* Lacd ship from */
publish "Logging.DatabaseAccess":U ("query doLacdDistribOfLcChargeForLegalDoc":U + chr(10) + doLacdDistribOfLcChargeForLegalDoc:QueryInfo(), ?).
publish "Logging.BusinessCode":U ("END-SUB,LacdDistribOfLcChargeForLegalDoc":U, "":U).
/* Go through all disributions of logistic charge */
do while doLacdDistribOfLcChargeForLegalDoc:available:
/* Create output record */
create tLgddDetLCDistForAPM.
assign tLgddDetLCDistForAPM.tc_ParentRowid = tLgddDetLCForAPM.tc_Rowid
tLgddDetLCDistForAPM.tc_Rowid = tLgddDetLCForAPM.tc_Rowid + string(doLacdDistribOfLcChargeForLegalDoc:oid_lacod_det)
tLgddDetLCDistForAPM.tcmat_lgd_domain = doLacdDistribOfLcChargeForLegalDoc:mat_lgd_domain
tLgddDetLCDistForAPM.tcmat_lgd_nbr = doLacdDistribOfLcChargeForLegalDoc:mat_lgd_nbr
tLgddDetLCDistForAPM.ttmat_lgd_effdate = doLacdDistribOfLcChargeForLegalDoc:mat_lgd_effdate
tLgddDetLCDistForAPM.tcmat_lgd_ship = doLacdDistribOfLcChargeForLegalDoc:mat_lgd_ship
tLgddDetLCDistForAPM.timat_lgdd_line = doLacdDistribOfLcChargeForLegalDoc:mat_lgdd_line
tLgddDetLCDistForAPM.tdmat_oid_lgd_mstr = doLacdDistribOfLcChargeForLegalDoc:mat_oid_lgd_mstr
tLgddDetLCDistForAPM.tdmat_oid_lgdd_det = doLacdDistribOfLcChargeForLegalDoc:mat_oid_lgdd_det
tLgddDetLCDistForAPM.tdAmountLC = <M-8 RoundAmount
(input doLacdDistribOfLcChargeForLegalDoc:lacod_lc_amt (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BMFGLegalDocument>
idTotalAmountLC = idTotalAmountLC - tLgddDetLCDistForAPM.tdAmountLC.
/* Get pending voucher that was created for this distribution of the logistic charge */
PVO_MSTR_BLOCK:
do on error undo, throw:
assign vcPvoExternalRef = substitute("&1::&2::&3::&4::&5",
doLacdDistribOfLcChargeForLegalDoc:mat_lgd_nbr,
string(doLacdDistribOfLcChargeForLegalDoc:mat_lgdd_line, "999"),
doLacdDistribOfLcChargeForLegalDoc:mat_lgd_shipfrom,
doLacdDistribOfLcChargeForLegalDoc:mat_lgd_ship,
doLacdDistribOfLcChargeForLegalDoc:lacd_log_supplier).
publish "Logging.BusinessCode":U ("START-SUB,PvoMstrByRef":U,
replace(substitute("In:icLgdDomain=&1|In:doLacdDistribOfLcChargeForLegalDoc:lacd_log_supplier=&2|In:vcPvoExternalRef=&3|In:vcInternalRef=&4|icLgddLcCharge=&5|iiLgddLine=&6":U,
icLgdDomain,doLacdDistribOfLcChargeForLegalDoc:lacd_log_supplier,vcPvoExternalRef,vcInternalRef,icLgddLcCharge,iiLgddLine),
"|":U, chr(10))).
doPvoMstr = new com.qad.eefin.bmfgpendingvoucher.PvoMstrByRef(
icLgdDomain, /* Domain */
doLacdDistribOfLcChargeForLegalDoc:lacd_log_supplier, /* Supplier */
vcPvoExternalRef, /* External reference */
vcInternalRef, /* Internal reference */
icLgddLcCharge, /* Logistic charge */
iiLgddLine ). /* Legal document line */
publish "Logging.DatabaseAccess":U ("query doPvoMstr":U + chr(10) + doPvoMstr:QueryInfo(), ?).
publish "Logging.BusinessCode":U ("END-SUB,PvoMstrByRef":U, "":U).
if doPvoMstr:available
then assign tLgddDetLCDistForAPM.tcPvoDomain = doPvoMstr:pvo_domain
tLgddDetLCDistForAPM.tiPvoId = doPvoMstr:pvo_id
tLgddDetLCDistForAPM.tiPvodIdLine = doPvoMstr:pvod_id_line
tLgddDetLCDistForAPM.tipvo_line = doPvoMstr:pvo_line
tLgddDetLCDistForAPM.tipvo_ers_status = doPvoMstr:pvo_ers_status
tLgddDetLCDistForAPM.tipvo_ers_opt = doPvoMstr:pvo_ers_opt
tLgddDetLCDistForAPM.tcpvo_project = doPvoMstr:pvo_project
tLgddDetLCDistForAPM.tcSupplier = doPvoMstr:pvo_supplier
tLgddDetLCDistForAPM.tcpvo_order_type = doPvoMstr:pvo_order_type
tLgddDetLCDistForAPM.tcpvo_shipfrom = doPvoMstr:pvo_shipfrom
tLgddDetLCDistForAPM.tcpvo_shipto = doPvoMstr:pvo_shipto
tLgddDetLCDistForAPM.tcpvo_curr = doPvoMstr:pvo_curr
tLgddDetLCDistForAPM.tcpvo_internal_ref = doPvoMstr:pvo_internal_ref
tLgddDetLCDistForAPM.tcpvo_part = doPvoMstr:pvo_part.
finally:
if valid-object(doPvoMstr) then delete object doPvoMstr no-error.
end.
end. /* PVO_MSTR_BLOCK: */
/* ========================================================================================================= *
* Retrieve taxes for the logistic charge distribution *
* ========================================================================================================= */
assign vcTaxReference = substitute("&1,&2,&3/&4/&5":U,
icLgdShipFrom,
icLgdNbr,
string(year(itLgdEffDate) modulo 100, "99":U),
string(month(itLgdEffDate), "99":U),
string(day(itLgdEffDate), "99":U))
vcTaxTrailer = substitute("&1,&2,&3/&4/&5,&6,&7":U,
doLacdDistribOfLcChargeForLegalDoc:mat_lgd_shipfrom, /* Material legal document supplier */
doLacdDistribOfLcChargeForLegalDoc:mat_lgd_nbr, /* Material legal document number */
string(year(doLacdDistribOfLcChargeForLegalDoc:mat_lgd_effdate) modulo 100, "99":U), /* Material legal document year */
string(month(doLacdDistribOfLcChargeForLegalDoc:mat_lgd_effdate) modulo 100, "99":U), /* Material legal document month */
string(day(doLacdDistribOfLcChargeForLegalDoc:mat_lgd_effdate) modulo 100, "99":U), /* Material legal document day */
string(doLacdDistribOfLcChargeForLegalDoc:mat_lgdd_line, "999"), /* Material legal document line number format 999 */
doLacdDistribOfLcChargeForLegalDoc:mat_lgdd_part). /* Item code for the logistic charge */
<M-81 run GetLegalDocumentDetForAPMatchingTax
(input icLgdDomain (icTaxDomain),
input vcTaxReference (icTaxReference),
input ? (icOrderNumber),
input icLgddLcCharge (icLcCharge),
input iiLgddLine (iiTaxLine),
input vcTaxTrailer (icTaxTrailer),
input tLgddDetLCDistForAPM.tc_Rowid (icParentRowId),
output viFcReturnSuper (oiReturnStatus)) in BMFGLegalDocument>
/* Go to the next distribution record */
doLacdDistribOfLcChargeForLegalDoc:next.
end. /* do while doLacdDistribOfLcChargeForLegalDoc:available: */
/* If the system did not use whole amount lf logistic charges as stated on the legal document line, then allocate it to the last *
* allocation. This can be caused normally by rounding issues */
if idTotalAmountLC <> 0 and
available tLgddDetLCDistForAPM
then assign tLgddDetLCDistForAPM.tdAmountLC = tLgddDetLCDistForAPM.tdAmountLC + idTotalAmountLC.
/* Finally block */
finally:
if valid-object(doLacdDistribOfLcChargeForLegalDoc) then delete object doLacdDistribOfLcChargeForLegalDoc no-error.
end.
end. /* MAIN_BLOCK */