project QadFinancials > class BCInvoiceAPMatching > method ApiEDICInvoiceAPMatchingImportInitialDefaulting
Description
ApiEDICInvoiceAPMatchingImportInitialDefaulting: submethod of ApiEDICInvoiceAPMatchingImport.
This method is called when creating an invoice with its receiver-matching through an API right before the processing of the input.
This method can be used to default field values to the incoming dataset prior to the acctual processing.
Standard-defaulting in this method:
• Default CompanyCode with the current-logged-onto company
• Default DomainCode with the domain of the company
• Default DInvoiceNumber with CInvoiceReference when not specified
• Fill CInvoicePostingDate with CInvoiceDate (and vice versa) and use Today when both empty
• Fill in IsCreateCInvoice with true when not specified
• Fill in CInvoiceIsStatusFinal with true when not specified
• On all Logistic and all Non-logistic matching details of the interface: set the Pvod-Finshed flag to false when unknown so the matched pending-vouchers remain open.
Parameters
bzCInvoiceAPMatching | input-output | dataset-handle | CInvoiceAPMatching: Handle to dataset where EDI stores all data. The data identified by this handle gets extended with some default values and values that can be derived from the filled fields. |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program3/bcinvoiceapmatching.p)
/* ============================================================================== */
/* Notes: */
/* 1. No records are available at the moment this method is entered */
/* 2. The records that need to be extended are following tables: tEDICInvoice, */
/* tEDIAPMatching and tEDIAPMatchingLcCharge and should be taken from the */
/* input-output dataset-handle and copied into it at the end of this method */
/* 3. Exception handling is done via progress itself (on error undo throw) */
/* 4. Database is accessed directly and variables are defined manually to: */
/* A. Come to a proper performance */
/* B. Ease downgradability */
/* C. Ease installations on released products: This complete peice of code */
/* can be copied into the 'before' hook of the parent-method of this */
/* method by using the customization-technology that we have in the Fin */
/* Addition: Note that only Financial-tables can be accessed directly - for */
/* Operational tables we will have to use dynamic queries! */
/* Note: For pre-SP12 versions; Change bzCInvoiceAPMatching into */
/* izCInvoiceAPMatching when copying this code into the customisations */
/* ============================================================================== */
/* ====================================================== */
/* Return in case the handle is not correct */
/* Copy data to static temporary tables */
/* ====================================================== */
if bzCInvoiceAPMatching = ? or
not valid-handle(bzCInvoiceAPMatching)
then Return.
if dataset dCInvoiceAPMatching:handle <> bzCInvoiceAPMatching
then dataset dCInvoiceAPMatching:handle:copy-dataset(bzCInvoiceAPMatching).
/* ====================================================== */
/* Go through all invoices that need to be created */
/* ====================================================== */
for each tEDICInvoice on error undo, throw :
/* ========================================================================================= */
/* Default CompanyCode with the current-logged-onto company when not specified */
/* Default DomainCode with the domain of the companywhen not specified */
/* Default DInvoiceNumber with CInvoiceReference when not specified */
/* Fill CInvoicePostingDate with CInvoiceDate (and vice versa) and use Today when both empty */
/* Fill in IsCreateCInvoice with true when not specified */
/* Fill in CInvoiceIsStatusFinal with true when not specified */
/* ========================================================================================= */
if tEDICInvoice.tcCompanyCode = "":U or
tEDICInvoice.tcCompanyCode = ?
then assign tEDICInvoice.tcCompanyCode = vcCompanyCode.
if tEDICInvoice.tcDomainCode = "":U or
tEDICInvoice.tcDomainCode = ?
then assign tEDICInvoice.tcDomainCode = vcDomainCode.
if tEDICInvoice.tcDInvoiceNumber = "":U or
tEDICInvoice.tcDInvoiceNumber = ?
then assign tEDICInvoice.tcDInvoiceNumber = tEDICInvoice.tcCInvoiceReference.
if tEDICInvoice.ttCInvoiceDate = ? and
tEDICInvoice.ttCInvoicePostingDate = ?
then assign tEDICInvoice.ttCInvoicePostingDate = today.
if tEDICInvoice.ttCInvoiceDate = ? and
tEDICInvoice.ttCInvoicePostingDate <> ?
then assign tEDICInvoice.ttCInvoiceDate = tEDICInvoice.ttCInvoicePostingDate.
if tEDICInvoice.ttCInvoicePostingDate = ? and
tEDICInvoice.ttCInvoiceDate <> ?
then assign tEDICInvoice.ttCInvoicePostingDate = tEDICInvoice.ttCInvoiceDate.
if tEDICInvoice.tlIsCreateCInvoice = ?
then assign tEDICInvoice.tlIsCreateCInvoice = true.
if tEDICInvoice.tlCInvoiceIsStatusFinal = ?
then assign tEDICInvoice.tlCInvoiceIsStatusFinal = true.
/* =============================================================================================================== */
/* Go through all Non-logistic matching details of the invoice and set the Pvod-Finshed flag to false when unknown */
/* =============================================================================================================== */
for each tEDIAPMatching where
tEDIAPMatching.tc_ParentRowid = tEDICInvoice.tc_Rowid
on error undo, throw :
if tEDIAPMatching.tlIsPvodFinished = ?
then assign tEDIAPMatching.tlIsPvodFinished = false.
end. /* for each tEDIAPMatching where */
/* =============================================================================================================== */
/* Go through all Logistic matching details of the invoice and set the Pvod-Finshed flag to false when unknown */
/* =============================================================================================================== */
for each tEDIAPMatchingLcCharge where
tEDIAPMatchingLcCharge.tc_ParentRowid = tEDICInvoice.tc_Rowid
on error undo, throw :
if tEDIAPMatchingLcCharge.tlIsPvodFinished = ?
then assign tEDIAPMatchingLcCharge.tlIsPvodFinished = false.
end. /* for each tEDIAPMatchingLcCharge where */
end. /* for each tEDICInvoice on error undo, throw : */
/* ============================================================================= */
/* Copy data from the static temporary tables to the input-output dataset-handle */
/* ============================================================================= */
bzCInvoiceAPMatching:copy-dataset(dataset dCInvoiceAPMatching:handle).