0% found this document useful (0 votes)
113 views

Fin-Integration Using APIs

QAD EE Financial Integration APIs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views

Fin-Integration Using APIs

QAD EE Financial Integration APIs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Fin-Integration using APIs: OIA-JE - BOIAJE - R&D Financials Group - Confluence - QAD Inc 03/12/2019 17)32

Páginas / … / Open Item Adjustment API - Technical

Fin-Integration using APIs: OIA-JE - BOIAJE


Criado por Miroslav Zukal, última alteração em dez 06, 2018

Integrating with Enterprise Financials using APIs: Open Item Adjustments


This document contains proprietary information that is protected by copyright and other intellectual property laws. No part of this document may be reproduced, translated, or
modified without the prior written consent of QAD Inc. The information contained in this document is subject to change without notice. QAD Inc. provides this material as is and
makes no warranty of any kind, expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. QAD Inc. shall
not be liable for errors contained herein or for incidental or consequential damages (including lost profits) in connection with the furnishing, performance, or use of this material
whether based on warranty, contract, or other legal theory. QAD and MFG/PRO are registered trademarks of QAD Inc. The QAD logo is a trademark of QAD Inc. Designations
used by other companies to distinguish their products are often claimed as trademarks. In this document, the product names appear in initial capital or all capital letters.
Contact the appropriate companies for more information regarding trademarks and registration.
© Copyright 2018 by QAD Inc. All rights reserved.
QAD Inc.
100 Innovation Place
Santa Barbara, California 93108
Phone (805) 684-6614
Fax (805) 684-1890
http://www.qad.com

Table of contents:

Integrating with Enterprise Financials using APIs: Open Item Adjustments


Prerequisites
Main properties of Open Item Adjustment
Adjustment Header
Adjustment Lines
Signs for Amounts
General description
Limitations
Parameters
Dataset information
Reference
Processing Notes
Validations
Defaulting
Code samples

Prerequisites
Before going through this document that covers the integration with Open Item Adjustments, it is mandatory to first go over the general document on integrating with the
Financials titled: "Enterprise Financials Integration: General Information"

Main properties of Open Item Adjustment


An open item adjustment consists of some main properties that drive the functional flows and as such, we will first mention the most important ones.

Adjustment Header

When creating the header for an open item adjustment, the system needs data for:
Entity (tcCompanyCode) - the entity in which the adjustment is being created. Defaults to the current entity (as defined by vcProxyCompanyCode, or from env.p) when
not provided
Year/Period (OIAdjustPostingYear/OIAdjustPostingPeriod)- automatically determined from the posting date when not provided
Posting Date (OIAdjustPostingDate)- defaults to current date when not provided
Daybook (OIAdjustPostingJournalCode) - must be of type "Customer Adjustment" or "Supplier Adjustment"
Description (OIAdjustDescription)- this value is optional and is only used in Open Item Adjustment View. The description has a maximum length of 255 chars. Note: this
is not used for the posting description, which is automatically set to the string Year + "/" + Period + "/" + Daybook = "/" + "Open Item Adjustment"

Adjustment Lines

https://team.qad.com/pages/viewpage.action?spaceKey=FIN&title=Fin-Integration+using+APIs%3A+OIA-JE+-+BOIAJE Página 1 de 18
Fin-Integration using APIs: OIA-JE - BOIAJE - R&D Financials Group - Confluence - QAD Inc 03/12/2019 17)32

The following key parameters are used in the creation of open item adjustment detail records:
1: Entity (OIAdjustLnInvCompanyCode):
This is the entity of the customer or supplier invoice record that is being adjusted. If not provided, the system will use the current entity (as defined
by vcProxyCompanyCode, or from env.p). Note: manual journal entry lines can only be processed in the current entity, and the ability to adjust invoice documents
from other entities is dependent on security permissions and the setting of the Open Item Cross Entity Allowed field of the current entity
2: Type (OIAdjustLnType):
The following types of adjustment line are supported by the API:
Supplier Invoice Movement (Field value - CIMOVEMENT, preprocessor value - OIADJUSTLNTYPE-CIMOV)
Customer Invoice Movement (Field value - DIMOVEMENT, preprocessor value - OIADJUSTLNTYPE-DIMOV)

3: Year, Daybook and Voucher (OIAdjustLnInvYear, OIAdjustLnInvJournalCode, OIAdjustLnInvVoucher) :


Customer and supplier invoice records to be adjusted must be identified by their year, daybook and voucher number. A single open item adjustment may include
detail lines for both customer and supplier invoice records, subject to the Customer/Supplier Compensation Allowed settings for the current entity and business
relation records, and the Open Item Netting Restriction setting for the current entity.
4: Amount(s):
Invoice records can be adjusted using either:
the TC Paid Amount and the TC Discount Amount (OIAdjustLnPaidAmtTC and OIAdjustLnPaymentDiscTC) ; OR
the TC New Balance Amount (OIAdjustLnNewBalanceAmtTC); OR
the TC Movement amount (OIAdjustLnMovementAmtTC)
It is not possible to use a combination of these 3 sets of parameters for any one document. Note: discount amounts are calculated automatically when using the new
balance amount or movement amount parameters, but if using the paid amount, then discount is not calculated - if no discount value is provided, then the discount is
set to zero. Note that all the values passed to the API are in transaction currency only (TC). Values for base and statutory currencies are calculated automatically.

Signs for Amounts


When passing values for new balances, movements, and paid and discount amounts, you need to be aware of the type of document that you are adjusting, as the
sign used will be different depending on the document type and the ledger concerned:
New Balance amount
When not set to zero, this must be positive for Customer Invoices, Customer Credit Note Corrections, Deductions, Finance Charges, Supplier Invoice Corrections,
Supplier Credit Notes and Supplier prepayments.
When not set to zero, this must be negative for Supplier Invoices, Supplier Credit Note Corrections, Customer Invoice Corrections, Customer Credit Notes and
Customer prepayments.
Paid, Discount and Movement amounts
When reducing the balance of a document, this must be positive for Supplier Invoices, Supplier Credit Note Corrections, Customer Invoice Corrections, Customer
Credit Notes and Customer prepayments.
When reducing the balance of a document, this must be negative for Customer Invoices, Customer Credit Note Corrections, Deductions, Finance Charges, Supplier
Invoice Corrections, Supplier Credit Notes and Supplier prepayments.
When increasing the balance of a document, this must be positive for Customer Invoices, Customer Credit Note Corrections, Deductions, Finance Charges,
Supplier Invoice Corrections, Supplier Credit Notes and Supplier prepayments.
When increasing the balance of a document, this must be negative for Supplier Invoices, Supplier Credit Note Corrections, Customer Invoice Corrections, Customer
Credit Notes and Customer prepayments.
Adjustment Invoices
Using the User Interface in Open Item Adjustments, it is possible to create new open items of type "Adjustment". These can be created with either Debit or Credit
balances. When using the API to adjust these "adjustment" records, then those with debit balances should be handled like customer invoices and those with credit
balances should be treated like supplier invoices.

5. Currencies and Realized Exchange Gains and Losses


Providing that all of the adjustment line records, for a single adjustment header record, have the same transaction currency (including any manual journal entry type
lines), then if all of the movements on the records net to zero in transaction currency, then the system will automatically calculate any rounding differences or
realized exchange gains and losses in base and statutory currencies. However, as soon as there is another transaction currency in the same open item adjustment,
this will not happen and you will have to provide additional manual journal entry lines (equivalent to the GL Allocation option via the user interface) to the API to
account for any remaining differences in those currencies. This business logic is exactly the same as with the .Net user interface.
6. Manual Journal Entry Lines
Manual journal entry lines are created by specifying tApiPostingLineOIAJE records in the API call. These lines are created in a similar fashion to journal entry lines
using the main Journal Entries API, but also result in the creation of open item adjustment lines. See the later code examples for more details. Note that the entity
cannot be specified for manual journal entry lines. The entity value is inherited from the open item adjustment header record.

https://team.qad.com/pages/viewpage.action?spaceKey=FIN&title=Fin-Integration+using+APIs%3A+OIA-JE+-+BOIAJE Página 2 de 18
Fin-Integration using APIs: OIA-JE - BOIAJE - R&D Financials Group - Confluence - QAD Inc 03/12/2019 17)32

General description
The integration point for the Open Item Adjustment component - BOIAJE - is the method APIMaintainByDatasetWithOutput.
This open item adjustment API integration allows for the creation of new open item adjustments that can include the following features:
1. Netting supplier invoices with supplier credit notes and other supplier invoice document types
2. Netting customer invoices with customer credit notes and other customer invoice document types
3. Netting customer invoice documents with supplier invoice documents
4. Writing off customer and supplier invoices
5. Reopening already closed customer and supplier invoices
6. Allocating differences to selected GL accounts
7. Adjustments to invoice documents from the same entity or across multiple entities

Limitations
1. The API cannot be used to create new open items of type "prepayment" or "adjustment". These can be created using other existing customer and supplier invoice APIs.
2. The API cannot be used to update supplier invoice hold amounts.
3. The API cannot be used to update withholding tax amounts.
4. Through the API, you cannot identify invoices using either invoice reference or shipper details.

Parameters
See the general section on the usage of the parameters of the API method. All classes have the method APIMaintainByDatasetWithOutput and all have the same input
parameters.
The only difference is the dataset to be passed to the method. In the case of BOIAJE , it is the BOIAJE dataset that should be passed in order to the the method
APIMaintainByDatasetWithOutput.

Dataset information
The API method uses a dataset to pass the actual open item adjustment information to the API. This dataset is called BOIAJE and it consists of the following tables:

Table Field Description Parent Table

tApiOIAdjustOIAJE This is the main table which contains data needed for Open item -
adjustment creation

OIAdjustPostingYear Accounting year, in which the posting is created. Optional and if not passed,
value is retrieved by the posting date.

OIAdjustPostingPeriod Accounting period, in which the posting is created. Optional and if not passed,
value is retrieved by the posting date.

OIAdjustPostingJournalCode Daybook used for the creation of the open item adjustment. Value is
mandatory and needs to be one of the Supplier or Customer open item types
daybook.

OIAdjustPostingDate Posting date of the created Open item adjustment. Value is optional, and, if
not passed, is set to current date.

OIAdjustDescription Description of the created Open item adjustment. Value is optional.

tcCompanyCode Entity of the open item adjustment. Value is optional. If entered, current value
is expected only.

tc_Rowid Unique record identification.

other fields in this table are not


used for the integration

tApiOIAdjustLnOIAJE This table contains all lines of the open item adjustment tApiOIAdjustOIAJE

OIAdjustLnType Type of the open item adjustment. Supported values are


{&OIADJUSTLNTYPE-CIMOV} and {&OIADJUSTLNTYPE-DIMOV} (supplier
invoice movement and customer invoice movement). Value is mandatory.

OIAdjustLnInvCompanyCode Invoice identification. Value is mandatory. Only entity code is optional and if
OIAdjustLnInvYear not passed, current entity is assumed.
OIAdjustLnInvJournalCode
OIAdjustLnInvVoucher

OIAdjustLnPaidAmtTC Payment amount in the currency of the invoice of the movement. Value is
optional.

OIAdjustLnPaymentDiscTC Discount amount in the currency of the invoice of the movement. Value is
optional.

OIAdjustLnMovementAmtTC Movement amount in the currency of the invoice. Value is optional.

OIAdjustLnNewBalanceAmtTC New balance of the invoice in the currency of the invoice. Value is optional.

https://team.qad.com/pages/viewpage.action?spaceKey=FIN&title=Fin-Integration+using+APIs%3A+OIA-JE+-+BOIAJE Página 3 de 18
Fin-Integration using APIs: OIA-JE - BOIAJE - R&D Financials Group - Confluence - QAD Inc 03/12/2019 17)32

tc_Rowid Unique record identification.

tc_ParentRowid Relation field between open item adjustment line and header
(tAPIOIAdjustLnOIAJE.tc_ParentRowid → tAPIOIAdjustOIAJE.tc_Rowid)

other field in this table are not


used for the integration

tApiPostingLineOIAJE This table contains journal entry line(s) of open item adjustment tApiOIAdjustOIAJE
Description of the field content, allowed values and defaulting is described for
Journal entry integration point (BPosting.ApiStdMaintainTT) as it is re-using
the same integration functionality at the end.
Value of tApiPostingLineOIAJE.tc_ParentRowId has to be the same as
tc_RowId record value of parent Open item adjustment
(tApiPostingLineOIAJE.tc_ParentRowId = tApiOIAdjustOIAJE.tc_Rowid)

tcGLCode GL account code. Value is mandatory.

tcCurrencyCode Currency of the transaction. Value is optional. If not supplied, base currency is
used.

tcDivisionCode Sub-account code. Value is optional. If not passed but required by GL account
analysis, default value from the GL account definition is taken.

tcProjectCode Project code. Value is optional. If not passed but required by GL account
analysis, default value from the GL account definition is taken.

tcCostCentreCode Cost center code. Value is optional. If not passed but required by GL account
analysis, default value from the GL account definition is taken.

PostingLineCreditTC Credit amounts of the transaction. Value is optional. Base and statutory
PostingLineCreditCC amounts are calculated from the transaction currency if blank value is passed
PostingLineCreditLC (=?).

PostingLineDebitTC Debit amounts of the transaction. Value is optional. Base and statutory
PostingLineDebitCC amounts are calculated from the transaction currency if blank value is passed
PostingLineDebitLC (=?).

PostingLineExchangeRate Exchange rate between transaction and base currency. Value is optional
PostingLineRateScale

PostingLineCCRate Exchange rate between transaction and statutory currency.. Value is optional.
PostingLineCCScale

tcAllocationType Allocation type of the transaction. Mandatory for GL accounts of type Open
item.
Allowed values
{&ALLOCATIONTYPE-NEW} = "N" - New open
{&ALLOCATIONTYPE-LATER} = "A" - Allocate later
{&ALLOCATIONTYPE-LINK} = "L" - Link to Open Item

tcAllocationKey Allocation key of open item. Mandatory for creation of new open item or for
linking to existing open item.

tcAllocationPostingLine Reference to posting line with Open item adjustment (eq


"2018/CUSTADJ/74")

tc_Rowid Unique record identification.

tc_ParentRowid Relation field between journal entry line and open item header
(tApiPostingLineOIAJE.tc_ParentRowid → tAPIOIAdjustOIAJE.tc_Rowid)

tApiPostingSafOIAJE This table contains SAF details of the journal entry line. Records in this tApiPostingLineOIAJE
table are optional, even the created journal entry line is created with
SAFs. In this case, system defaults theirs values from GL account
definition.

tcSafConceptCode SAF concept code. Value is mandatory.

tcSafCode SAF code. Must be defined for SAF concept tcSafConcept. Value is
mandatory.

tc_Rowid Unique record identification.

tc_ParentRowid Relation field between SAF value and journal entry line
(tApiPostingSafOIAJE.tc_ParentRowid → tApiPostingLineOIAJE.tc_Rowid)

tApiPostingVatOIAJE This table contains tax details of the journal entry line tApiPostingLineOIAJE

PostingVatOwnTaxIDFeder Company tax id(s). These can optionally be provided, depending on the tax
PostingVatOwnTaxIDState jurisdiction concerned, if you need the transactions to be included in tax
reporting.

https://team.qad.com/pages/viewpage.action?spaceKey=FIN&title=Fin-Integration+using+APIs%3A+OIA-JE+-+BOIAJE Página 4 de 18
Fin-Integration using APIs: OIA-JE - BOIAJE - R&D Financials Group - Confluence - QAD Inc 03/12/2019 17)32

PostingVatOwnTaxIDMisc1
PostingVatOwnTaxIDMisc2
PostingVatOwnTaxIDMisc3

PostingVatTaxIDFeder Customer/Supplier tax id(s). These can optionally be provided, depending on


PostingVatTaxIDState the tax jurisdiction concerned, if you need the transactions to be included in
tax reporting.
PostingVatTaxIDMisc1
PostingVatTaxIDMisc2
PostingVatTaxIDMisc3

PostingVatBaseDebitTC Base tax amount.


PostingVatBaseDebitCC
PostingVatBaseDebitLC
PostingVatBaseCreditTC
PostingVatBaseCreditCC
PostingVatBaseCreditLC

PostingVatTaxDebitTC Tax amount. If not supplied, value is overtaken from the parent journal entry
PostingVatTaxDebitCC line.
PostingVatTaxDebitLC
PostingVatTaxCreditTC
PostingVatTaxCreditCC
PostingVatTaxCreditLC

PostingVatInOut Tax direction. Value is mandatory. Allowed values.


{&VATINOUT_INPUT} = "INPUT"
{&VATINOUT_OUTPUT} = "OUTPUT"

PostingVatTaxTransType Tax transaction type

PostingVatTransType Transaction type

PostingVatIsReverseCharge Reverse charge

PostingVatIsAbsRet Absorbed/Retained

PostingVatIsSuspDel Suspended/Delayed tax

TxtyTaxType Tax type

TxenvTaxEnv Tax environment

FromTxzTaxZone From tax zone

ToTxzTaxZone To tax zone

tcVatCode Tax code

tc_Rowid Unique record identification.

tc_ParentRowid Relation field between tax record and journal entry line
(tApiPostingVatOIAJE.tc_ParentRowid → tApiPostingLineOIAJE.tc_Rowid)

tApiPositngVatDelayOIAJE This table contains delayed tax details of the journal entry line. tApiPostingLineOIAJE

PostingVatDelayBaseDebTC Base delayed tax amount.


PostingVatDelayBaseDebCC
PostingVatDelayBaseDebLC
PostingVatDelayBaseCredTC
PostingVatDelayBaseCredCC
PostingVatDelayBaseCredLC

tcVatCode Tax code

tcVatInOut Tax direction

For a full description of the tables in the dataset, refer to the html documentation supplied with the software:

Reference
Project: QADFinancials
Class: BOIAJE
Method: ApiMaintainByDatasetWithOutput
Dataset: BOIAJE
The HTML documentation is installed with the QAD EE software. Instructions for finding and using the HTML documentation are also available in the non-intrusive
customization training.
The HTML documentation will also provide information on values to be used for certain fields. For example, the open item adjustment line type field - OIAdjustLnType - can be
set to {&OIADJUSTLNTYPE-CIMOV} which is for supplier invoice movements. However, there are other values for customer invoice movements and manual journal entry line
and these are documented in the HTML documentation.

https://team.qad.com/pages/viewpage.action?spaceKey=FIN&title=Fin-Integration+using+APIs%3A+OIA-JE+-+BOIAJE Página 5 de 18
Fin-Integration using APIs: OIA-JE - BOIAJE - R&D Financials Group - Confluence - QAD Inc 03/12/2019 17)32

Processing Notes
Validations
Parameters validation
Open item adjustment can be created only in entity, user is logged in.
Open item adjustment daybook is mandatory, it must exist in the system, be of type customer or supplier adjustment and must be active.
If Year and Period are supplied in the header as well as the posting date, then the system checks that the posting date correctly belongs to the supplied period.
Supplier/Customer invoice have to determined by accounting year, day book and voucher. These parameters are mandatory.
Open item adjustment line type is mandatory and can be set to {&OIADJUSTLNTYPE-CIMOV}, {&OIADJUSTLNTYPE-DIMOV} and {&OIADJUSTLNTYPE-JE}.
On the open item adjustment lines you must supply the payment and discount amount, the movement amount, or the new balance amount. Combinations of these
options are not supported.
The supplier invoice must exist in the entity specified.
Open item adjustments can only be created for supplier invoices with an allocation status different to no allocation.
During execution of the API, multiple open item adjustments can be passed. These adjustments are processed one by one. Therefore, it can happen that some of them are
successfully saved where others not. Processing of any one open item adjustment is stopped immediately when the first error is detected.

Defaulting
The open item adjustment API integration has built in field defaulting functionality, that checks the temp-table records that are passed to the API and makes sure that all
important fields in the records have correct values and consistent values.
Open item adjustment entity is defaulted to current entity (where the API is logged in).
Open item adjustment date is defaulted to today when not passed.
Accounting period is defaulted to the accounting period to which posting date belongs.
When entity is not passed for the invoice lookup, then current entity is assumed.
When the paid amount is entered but the discount amount is not, the discount amount is set to 0.
If the paid amount, discount amount, movement amount and new balance amount are not passed in the API, the new balance amount is set to 0.
If the new balance or the movement amount is set, the payment and discount amounts will be calculated.

Code samples

/* ============================================================================= *
* As a Financial Controller, I want to be able to create open item adjustments *
* that net AP documents in the same entity automatically via an API, to improve *
* processing time and accuracy. *
* ----------------------------------------------------------------------------- *
* Scenario : Matching a supplier prepayment to supplier invoice(s). *
* *
* Input data: Entity: 22UKCO *
* : Supplier Invoice with a balance of 50 *
* : Supplier Invoice with a balance of 20 *
* : Prepayment with open balance of 200 *
* ============================================================================= */
routine-level on error undo, throw.

/* Required definitions */
{ proxy/QadFinancialsConstants.i }
{ proxy/datasets/boiaje.i }
{ proxy/boiaje/apimaintainbydatasetwithoutputdef.i }

/* Variables used in exception handling */


define variable viErrCount as integer no-undo.
define variable vcReturnedInfo as char no-undo.
define variable vhOIAdjustQry as handle no-undo.
define variable vhOIAdjustBfr as handle no-undo.

/* Specify input for the API method */


vcProxyCompanyCode = "22UKCO".
izObjectToUpdate = dataset boiaje:handle.
ilReturnDataset = true.

/* ensure a clean set of data is used */


empty temp-table tApiOIAdjustOIAJE.
empty temp-table tApiOIAdjustLnOIAJE.

/* Specify the details for the OIA header */


create tApiOIAdjustOIAJE.

https://team.qad.com/pages/viewpage.action?spaceKey=FIN&title=Fin-Integration+using+APIs%3A+OIA-JE+-+BOIAJE Página 6 de 18
Fin-Integration using APIs: OIA-JE - BOIAJE - R&D Financials Group - Confluence - QAD Inc 03/12/2019 17)32

assign tApiOIAdjustOIAJE.OIAdjustPostingJournalCode = "SUPADJ" /* Daybook Code */


tApiOIAdjustOIAJE.OIAdjustPostingDate = today
tApiOIAdjustOIAJE.OIAdjustDescription = "API Test 1"
tApiOIAdjustOIAJE.tc_Rowid = "oia-1".

/* Specify invoice details */


create tApiOIAdjustLnOIAJE.
assign tApiOIAdjustLnOIAJE.OIAdjustLnType = {&OIADJUSTLNTYPE-CIMOV} /* Supplier Invoice Movement */
tApiOIAdjustLnOIAJE.OIAdjustLnInvYear = 2018
tApiOIAdjustLnOIAJE.OIAdjustLnInvJournalCode = "SINV" /* Daybook Code */
tApiOIAdjustLnOIAJE.OIAdjustLnInvVoucher = 000000120
tApiOIAdjustLnOIAJE.OIAdjustLnNewBalanceAmtTC = 0 /* New Balance Amount */
tApiOIAdjustLnOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiOIAdjustLnOIAJE.tc_Rowid = "oia-2".

/* Specify invoice details */


create tApiOIAdjustLnOIAJE.
assign tApiOIAdjustLnOIAJE.OIAdjustLnType = {&OIADJUSTLNTYPE-CIMOV} /* Supplier Invoice Movement */
tApiOIAdjustLnOIAJE.OIAdjustLnInvYear = 2018
tApiOIAdjustLnOIAJE.OIAdjustLnInvJournalCode = "SINV" /* Daybook Code */
tApiOIAdjustLnOIAJE.OIAdjustLnInvVoucher = 000000121
tApiOIAdjustLnOIAJE.OIAdjustLnNewBalanceAmtTC = 0 /* New Balance Amount */
tApiOIAdjustLnOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiOIAdjustLnOIAJE.tc_Rowid = "oia-3".

/* Specify the prepayment details */


create tApiOIAdjustLnOIAJE.
assign tApiOIAdjustLnOIAJE.OIAdjustLnType = {&OIADJUSTLNTYPE-CIMOV} /* Supplier Invoice Movement */
tApiOIAdjustLnOIAJE.OIAdjustLnInvYear = 2018
tApiOIAdjustLnOIAJE.OIAdjustLnInvJournalCode = "APPAY" /* Daybook Code */
tApiOIAdjustLnOIAJE.OIAdjustLnInvVoucher = 000000086
tApiOIAdjustLnOIAJE.OIAdjustLnNewBalanceAmtTC = 130 /* New Balance Amount */
tApiOIAdjustLnOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiOIAdjustLnOIAJE.tc_Rowid = "oia-4".

/* Call the API method */


{ proxy/boiaje/apimaintainbydatasetwithoutputrun.i }

/* Exception handling the return-values of the call */


catch eAnyError as Progress.Lang.SysError:
assign vcReturnedInfo = subst("Exception during execution of API raised (&1)", eAnyError:GetMessage(1)).

message "Exception error!!! "


+ chr(10)
+ vcReturnedInfo
view-as alert-box.

output to "API_Result_Exception.txt".
put unformatted vcReturnedInfo.
output close.
end catch.

finally:
assign vcReturnedInfo = "Return status: " + string(oiReturnStatus) + chr(10).
for each tFcMessages:
assign viErrCount = viErrCount + 1
vcReturnedInfo = vcReturnedInfo + chr(10)
+ string(viErrCount) + ": ":U + tFcMessages.tcFcMessage + chr(10)
+ " tcFcFieldName = " + (IF tFcMessages.tcFcFieldName = ? THEN "?" ELSE tFcMessages.tcFcFiel
+ " tcFcRowid = " + (IF tFcMessages.tcFcRowid = ? THEN "?":U ELSE tFcMessages.tcFcRowid) + c
+ " tcFcType = " + (IF tFcMessages.tcFcType = ? THEN "?":U ELSE tFcMessages.tcFcType) + chr(
+ " tcFcFieldValue = " + (IF tFcMessages.tcFcFieldValue = ? THEN "?":U ELSE tFcMessages.tcFc
+ " tcFcBusMethod = " + (IF tFcMessages.tcFcBusMethod = ? Then "?":U else tFcMessages.tcFcBu
+ " tcFcMsgNumber = " + (IF tFcMessages.tcFcMsgNumber = ? THEN "?":U ELSE tFcMessages.tcFcMs
+ " tcFcContext = " + (IF tFcMessages.tcFcContext = ? THEN "?":U ELSE tFcMessages.tcFcContex

https://team.qad.com/pages/viewpage.action?spaceKey=FIN&title=Fin-Integration+using+APIs%3A+OIA-JE+-+BOIAJE Página 7 de 18
Fin-Integration using APIs: OIA-JE - BOIAJE - R&D Financials Group - Confluence - QAD Inc 03/12/2019 17)32

if viErrCount > 8 then leave.


end. /* for each tFcMessages: */

message vcReturnedInfo
view-as alert-box.

output to "API_Result.txt".
put unformatted vcReturnedInfo.
output close.

/* Retrieve created open item adjustment(s) */


if oiReturnStatus >= 0
then do:
assign vcReturnedInfo = "":U
vhOIAdjustBfr = ozObjectRepresentation:get-buffer-handle("tApiOIAdjustOIAJE") no-error.

create query vhOIAdjustQry no-error.


vhOIAdjustQry:add-buffer(vhOIAdjustBfr) no-error.
vhOIAdjustQry:query-prepare("for each " + vhOIAdjustBfr:name ) no-error.
vhOIAdjustQry:query-open() no-error.
vhOIAdjustQry:get-first() no-error.

repeat while not vhOIAdjustQry:query-off-end:


assign vcReturnedInfo = vcReturnedInfo + chr(10)
+ "OIA Year/Daybook/Voucher: "
+ string(vhOIAdjustBfr::OIAdjustPostingYear) + "/"
+ string(vhOIAdjustBfr::OIAdjustPostingJournalCode) + "/"
+ string(vhOIAdjustBfr::OIAdjustPostingVoucher).
vhOIAdjustQry:get-next() no-error.
end. /* repeat until vhQuery:query-off-end: */

vhOIAdjustQry:query-close().
delete object vhOIAdjustQry.

message vcReturnedInfo
view-as alert-box.

output to "API_Result.txt".
put unformatted vcReturnedInfo.
output close.

end. /* if oiReturnStatus >= 0 */


end finally.

/* =============================================================================== *
* As a Financial Controller, I want to be able to create open item adjustments *
* that net AP documents in the same entity automatically via an API, to improve *
* processing time and accuracy. *
* ------------------------------------------------------------------------------- *
* Scenario : Matching supplier prepayment to supplier invoice(s) with discounts. *
* *
* Input data: Entity: 22UKCO *
* : Supplier Invoice with a balance of 40, Credit Terms with a Discount *
* : Supplier Invoice with a balance of 60, Credit Terms with a Discount *
* : Prepayment with open balance of 98 *
* =============================================================================== */
routine-level on error undo, throw.

/* Required definitions */
{ proxy/QadFinancialsConstants.i }
{ proxy/datasets/boiaje.i }
{ proxy/boiaje/apimaintainbydatasetwithoutputdef.i }

https://team.qad.com/pages/viewpage.action?spaceKey=FIN&title=Fin-Integration+using+APIs%3A+OIA-JE+-+BOIAJE Página 8 de 18
Fin-Integration using APIs: OIA-JE - BOIAJE - R&D Financials Group - Confluence - QAD Inc 03/12/2019 17)32

/* Variables used in exception handling */


define variable viErrCount as integer no-undo.
define variable vcReturnedInfo as char no-undo.
define variable vhOIAdjustQry as handle no-undo.
define variable vhOIAdjustBfr as handle no-undo.

/* Specify input for the API method */


vcProxyCompanyCode = "22UKCO".
izObjectToUpdate = dataset boiaje:handle.
ilReturnDataset = true.

empty temp-table tApiOIAdjustOIAJE.


empty temp-table tApiOIAdjustLnOIAJE.

/* Specify the details for the OIA header */


create tApiOIAdjustOIAJE.
assign tApiOIAdjustOIAJE.OIAdjustPostingJournalCode = "SUPADJ" /* Daybook Code */
tApiOIAdjustOIAJE.OIAdjustPostingDate = today
tApiOIAdjustOIAJE.OIAdjustDescription = "API Test 3"
tApiOIAdjustOIAJE.tc_Rowid = "oia-1".

/* Specify the invoice details */


create tApiOIAdjustLnOIAJE.
assign tApiOIAdjustLnOIAJE.OIAdjustLnType = {&OIADJUSTLNTYPE-CIMOV} /* Supplier Invoice Movement */
tApiOIAdjustLnOIAJE.OIAdjustLnInvYear = 2018
tApiOIAdjustLnOIAJE.OIAdjustLnInvJournalCode = "SINV" /* Daybook Code */
tApiOIAdjustLnOIAJE.OIAdjustLnInvVoucher = 000000124
tApiOIAdjustLnOIAJE.OIAdjustLnPaidAmtTC = 58.80 /* Paid Amount */
tApiOIAdjustLnOIAJE.OIAdjustLnPaymentDiscTC = 1.20 /* Discount Amount */
tApiOIAdjustLnOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiOIAdjustLnOIAJE.tc_Rowid = "oia-2".

/* Specify the invoice details */


create tApiOIAdjustLnOIAJE.
assign tApiOIAdjustLnOIAJE.OIAdjustLnType = {&OIADJUSTLNTYPE-CIMOV} /* Supplier Invoice Movement */
tApiOIAdjustLnOIAJE.OIAdjustLnInvYear = 2018
tApiOIAdjustLnOIAJE.OIAdjustLnInvJournalCode = "SINV" /* Daybook Code */
tApiOIAdjustLnOIAJE.OIAdjustLnInvVoucher = 000000125
tApiOIAdjustLnOIAJE.OIAdjustLnPaidAmtTC = 39.20 /* Paid Amount */
tApiOIAdjustLnOIAJE.OIAdjustLnPaymentDiscTC = 0.80 /* Discount Amount */
tApiOIAdjustLnOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiOIAdjustLnOIAJE.tc_Rowid = "oia-3".

/* Specify the prepayment details */


create tApiOIAdjustLnOIAJE.
assign tApiOIAdjustLnOIAJE.OIAdjustLnType = {&OIADJUSTLNTYPE-CIMOV} /* Supplier Invoice Movement */
tApiOIAdjustLnOIAJE.OIAdjustLnInvYear = 2018
tApiOIAdjustLnOIAJE.OIAdjustLnInvJournalCode = "APPAY" /* Daybook Code */
tApiOIAdjustLnOIAJE.OIAdjustLnInvVoucher = 000000088
tApiOIAdjustLnOIAJE.OIAdjustLnMovementAmtTC = -98 /* Adjustment Amount */
tApiOIAdjustLnOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiOIAdjustLnOIAJE.tc_Rowid = "oia-4".

/* Call the API method */


{ proxy/boiaje/apimaintainbydatasetwithoutputrun.i }

/* Exception handling - see exception handling from the first example */

/* ============================================================================= *
* As a Financial Controller, I want to be able to create open item adjustments *
* that net AP documents in the same entity automatically via an API, to improve *

https://team.qad.com/pages/viewpage.action?spaceKey=FIN&title=Fin-Integration+using+APIs%3A+OIA-JE+-+BOIAJE Página 9 de 18
Fin-Integration using APIs: OIA-JE - BOIAJE - R&D Financials Group - Confluence - QAD Inc 03/12/2019 17)32

* processing time and accuracy. *


* ----------------------------------------------------------------------------- *
* Scenario : Re-opening previously netted invoices. *
* *
* Input data: Entity: 22UKCO *
* : Supplier Invoice with a balance of 0 *
* : Supplier Credit Note with a balance of 0 *
* ============================================================================= */
routine-level on error undo, throw.

/* Required definitions */
{ proxy/QadFinancialsConstants.i }
{ proxy/datasets/boiaje.i }
{ proxy/boiaje/apimaintainbydatasetwithoutputdef.i }

/* Variables used in exception handling */


define variable viErrCount as integer no-undo.
define variable vcReturnedInfo as char no-undo.
define variable vhOIAdjustQry as handle no-undo.
define variable vhOIAdjustBfr as handle no-undo.

/* Specify input for the API method */


vcProxyCompanyCode = "22UKCO".
izObjectToUpdate = dataset boiaje:handle.
ilReturnDataset = true.

empty temp-table tApiOIAdjustOIAJE.


empty temp-table tApiOIAdjustLnOIAJE.

/* Specify the details for the OIA header */


create tApiOIAdjustOIAJE.
assign tApiOIAdjustOIAJE.OIAdjustPostingJournalCode = "SUPADJ" /* Daybook Code */
tApiOIAdjustOIAJE.OIAdjustPostingDate = today
tApiOIAdjustOIAJE.OIAdjustDescription = "API Test 4"
tApiOIAdjustOIAJE.tc_Rowid = "oia-1".

/* Specify the invoice details */


create tApiOIAdjustLnOIAJE.
assign tApiOIAdjustLnOIAJE.OIAdjustLnType = {&OIADJUSTLNTYPE-CIMOV} /* Supplier Invoice Movement */
tApiOIAdjustLnOIAJE.OIAdjustLnInvYear = 2018
tApiOIAdjustLnOIAJE.OIAdjustLnInvJournalCode = "SINV" /* Daybook Code */
tApiOIAdjustLnOIAJE.OIAdjustLnInvVoucher = 000000126
tApiOIAdjustLnOIAJE.OIAdjustLnNewBalanceAmtTC = -100 /* New Balance Amount */
tApiOIAdjustLnOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiOIAdjustLnOIAJE.tc_Rowid = "oia-2".

/* Specify the credit note details */


create tApiOIAdjustLnOIAJE.
assign tApiOIAdjustLnOIAJE.OIAdjustLnType = {&OIADJUSTLNTYPE-CIMOV} /* Supplier Invoice Movement */
tApiOIAdjustLnOIAJE.OIAdjustLnInvYear = 2018
tApiOIAdjustLnOIAJE.OIAdjustLnInvJournalCode = "SCN" /* Daybook Code */
tApiOIAdjustLnOIAJE.OIAdjustLnInvVoucher = 000000001
tApiOIAdjustLnOIAJE.OIAdjustLnNewBalanceAmtTC = 100 /* New Balance Amount */
tApiOIAdjustLnOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiOIAdjustLnOIAJE.tc_Rowid = "oia-3".

/* Call the API method */


{ proxy/boiaje/apimaintainbydatasetwithoutputrun.i }

/* Exception handling - see exception handling from the first example */

/* ============================================================================= *

https://team.qad.com/pages/viewpage.action?spaceKey=FIN&title=Fin-Integration+using+APIs%3A+OIA-JE+-+BOIAJE Página 10 de 18
Fin-Integration using APIs: OIA-JE - BOIAJE - R&D Financials Group - Confluence - QAD Inc 03/12/2019 17)32

* As a Financial Controller, I want to be able to create open item adjustments *


* that net multiple customer invoices in different currencies. Any exchange *
* rate difference is then posted to an open item account. *
* ----------------------------------------------------------------------------- *
* Scenario : Netting customer invoices and credit notes + manual posting lines *
* *
* Input data: Entity: 10USACO *
* : Customer Invoices and credit notes in EUR and CAD with different *
* exchange rates *
* : Journal entry lines (GL allocation) *
* ============================================================================= */
routine-level on error undo, throw.

/* Required definitions */
{ proxy/QadFinancialsConstants.i }
{ proxy/datasets/boiaje.i }
{ proxy/boiaje/apimaintainbydatasetwithoutputdef.i }

/* Variables used in exception handling */


define variable viErrCount as integer no-undo.
define variable vcReturnedInfo as char no-undo.
define variable vhOIAdjustQry as handle no-undo.
define variable vhOIAdjustBfr as handle no-undo.

/* Specify input for the API method */


vcProxyCompanyCode = "10USACO".
izObjectToUpdate = dataset boiaje:handle.
ilReturnDataset = true.

/* ensure a clean set of data is used */


empty temp-table tApiOIAdjustOIAJE.
empty temp-table tApiOIAdjustLnOIAJE.
empty temp-table tApiPostingLineOIAJE.
empty temp-table tApiPostingSafOIAJE.
empty temp-table tApiPostingVatOIAJE.
empty temp-table tApiPostingVatDelayOIAJE.

/* Specify the details for the OIA header */


create tApiOIAdjustOIAJE.
assign tApiOIAdjustOIAJE.OIAdjustPostingJournalCode = "CUSTADJ" /* Daybook Code */
tApiOIAdjustOIAJE.OIAdjustPostingDate = today
tApiOIAdjustOIAJE.OIAdjustDescription = "Customer invoice netting + GL allocation"
tApiOIAdjustOIAJE.tc_Rowid = "oia-1".

/* Specify customer invoice */


/* 100 EUR, 130 USD in base currency - invoice is being partially allocated */
create tApiOIAdjustLnOIAJE.
assign tApiOIAdjustLnOIAJE.OIAdjustLnType = {&OIADJUSTLNTYPE-DIMOV} /* Customer invoice movement */
tApiOIAdjustLnOIAJE.OIAdjustLnInvYear = 2018
tApiOIAdjustLnOIAJE.OIAdjustLnInvJournalCode = "CIM" /* Daybook Code */
tApiOIAdjustLnOIAJE.OIAdjustLnInvVoucher = 35
tApiOIAdjustLnOIAJE.OIAdjustLnNewBalanceAmtTC = 80 /* Decrease invoice balance */
tApiOIAdjustLnOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiOIAdjustLnOIAJE.tc_Rowid = "oia-2".

/* Specify customer credit note - credit note is being closed */


/* 20 EUR, 30 USD in base currency */
create tApiOIAdjustLnOIAJE.
assign tApiOIAdjustLnOIAJE.OIAdjustLnType = {&OIADJUSTLNTYPE-DIMOV} /* Customer invoice movement */
tApiOIAdjustLnOIAJE.OIAdjustLnInvYear = 2018
tApiOIAdjustLnOIAJE.OIAdjustLnInvJournalCode = "CCNM" /* Daybook Code */
tApiOIAdjustLnOIAJE.OIAdjustLnInvVoucher = 5
tApiOIAdjustLnOIAJE.OIAdjustLnMovementAmtTC = 20 /* Decrease Credit note balance */
tApiOIAdjustLnOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid

https://team.qad.com/pages/viewpage.action?spaceKey=FIN&title=Fin-Integration+using+APIs%3A+OIA-JE+-+BOIAJE Página 11 de 18
Fin-Integration using APIs: OIA-JE - BOIAJE - R&D Financials Group - Confluence - QAD Inc 03/12/2019 17)32

tApiOIAdjustLnOIAJE.tc_Rowid = "oia-3".

/* Specify customer invoice */


/* 100 CAD, 95 USD in base currency - invoice is being partially allocated */
create tApiOIAdjustLnOIAJE.
assign tApiOIAdjustLnOIAJE.OIAdjustLnType = {&OIADJUSTLNTYPE-DIMOV} /* Customer invoice movement */
tApiOIAdjustLnOIAJE.OIAdjustLnInvYear = 2018
tApiOIAdjustLnOIAJE.OIAdjustLnInvJournalCode = "CIM" /* Daybook Code */
tApiOIAdjustLnOIAJE.OIAdjustLnInvVoucher = 37
tApiOIAdjustLnOIAJE.OIAdjustLnNewBalanceAmtTC = 80 /* Decrease invoice balance */
tApiOIAdjustLnOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiOIAdjustLnOIAJE.tc_Rowid = "oia-4".

/* Specify customer credit note - credit note is being closed */


/* 40 CAD, 36 USD in base currency */
create tApiOIAdjustLnOIAJE.
assign tApiOIAdjustLnOIAJE.OIAdjustLnType = {&OIADJUSTLNTYPE-DIMOV} /* Customer invoice movement */
tApiOIAdjustLnOIAJE.OIAdjustLnInvYear = 2018
tApiOIAdjustLnOIAJE.OIAdjustLnInvJournalCode = "CCNM" /* Daybook Code */
tApiOIAdjustLnOIAJE.OIAdjustLnInvVoucher = 7
tApiOIAdjustLnOIAJE.OIAdjustLnMovementAmtTC = 20 /* Decrease Credit note balance */
tApiOIAdjustLnOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiOIAdjustLnOIAJE.tc_Rowid = "oia-5".

/* Allocated exchange rate difference to GL account of type "Open item" */


create tApiPostingLineOIAJE.
assign tApiPostingLineOIAJE.tcGLCode = "1390"
tApiPostingLineOIAJE.tcCurrencyCode = "USD"
tApiPostingLineOIAJE.PostingLineCreditTC = 2.77
tApiPostingLineOIAJE.PostingLineCreditLC = 2.77
tApiPostingLineOIAJE.PostingLineCreditCC = 2.77
tApiPostingLineOIAJE.PostingLineDebitTC = 0
tApiPostingLineOIAJE.tcAllocationType = {&ALLOCATIONTYPE-NEW} /* Allocation type */
/* {&ALLOCATIONTYPE-NEW} = "N" - New open */
/* {&ALLOCATIONTYPE-LATER} = "A" - Allocate later */
/* {&ALLOCATIONTYPE-LINK} = "L" - Link to Open Item */
tApiPostingLineOIAJE.tcAllocationKey = "OIA netting difference"
tApiPostingLineOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiPostingLineOIAJE.tc_Rowid = "oia-6".

/* Call the API method */


{ proxy/boiaje/apimaintainbydatasetwithoutputrun.i }

/* Exception handling the return-values of the call */


catch eAnyError as Progress.Lang.SysError:
assign vcReturnedInfo = subst("Exception during execution of API raised (&1)", eAnyError:GetMessage(1)).

message "Exception error!!! "


+ chr(10)
+ vcReturnedInfo
view-as alert-box.

output to "API_Result_Exception.txt".
put unformatted vcReturnedInfo.
output close.
end catch.

finally:
assign vcReturnedInfo = "Return status: " + string(oiReturnStatus) + chr(10).
for each tFcMessages:

https://team.qad.com/pages/viewpage.action?spaceKey=FIN&title=Fin-Integration+using+APIs%3A+OIA-JE+-+BOIAJE Página 12 de 18
Fin-Integration using APIs: OIA-JE - BOIAJE - R&D Financials Group - Confluence - QAD Inc 03/12/2019 17)32

assign viErrCount = viErrCount + 1


vcReturnedInfo = vcReturnedInfo + chr(10)
+ string(viErrCount) + ": ":U + tFcMessages.tcFcMessage + chr(10)
+ " tcFcFieldName = " + (IF tFcMessages.tcFcFieldName = ? THEN "?" ELSE tFcMessages.tcFcFiel
+ " tcFcRowid = " + (IF tFcMessages.tcFcRowid = ? THEN "?":U ELSE tFcMessages.tcFcRowid) + c
+ " tcFcType = " + (IF tFcMessages.tcFcType = ? THEN "?":U ELSE tFcMessages.tcFcType) + chr(
+ " tcFcFieldValue = " + (IF tFcMessages.tcFcFieldValue = ? THEN "?":U ELSE tFcMessages.tcFc
+ " tcFcBusMethod = " + (IF tFcMessages.tcFcBusMethod = ? Then "?":U else tFcMessages.tcFcBu
+ " tcFcMsgNumber = " + (IF tFcMessages.tcFcMsgNumber = ? THEN "?":U ELSE tFcMessages.tcFcMs
+ " tcFcContext = " + (IF tFcMessages.tcFcContext = ? THEN "?":U ELSE tFcMessages.tcFcContex
if viErrCount > 8 then leave.
end. /* for each tFcMessages: */

message vcReturnedInfo
view-as alert-box.

output to "API_Result.txt".
put unformatted vcReturnedInfo.
output close.

/* Retrieve created open item adjustment(s) */


if oiReturnStatus >= 0
then do:
assign vcReturnedInfo = "":U
vhOIAdjustBfr = ozObjectRepresentation:get-buffer-handle("tApiOIAdjustOIAJE") no-error.

create query vhOIAdjustQry no-error.


vhOIAdjustQry:add-buffer(vhOIAdjustBfr) no-error.
vhOIAdjustQry:query-prepare("for each " + vhOIAdjustBfr:name ) no-error.
vhOIAdjustQry:query-open() no-error.
vhOIAdjustQry:get-first() no-error.

repeat while not vhOIAdjustQry:query-off-end:


assign vcReturnedInfo = vcReturnedInfo + chr(10)
+ "OIA Year/Daybook/Voucher: "
+ string(vhOIAdjustBfr::OIAdjustPostingYear) + "/"
+ string(vhOIAdjustBfr::OIAdjustPostingJournalCode) + "/"
+ string(vhOIAdjustBfr::OIAdjustPostingVoucher).
vhOIAdjustQry:get-next() no-error.
end. /* repeat until vhQuery:query-off-end: */

vhOIAdjustQry:query-close().
delete object vhOIAdjustQry.

message vcReturnedInfo
view-as alert-box.

output to "API_Result.txt".
put unformatted vcReturnedInfo.
output close.

end. /* if oiReturnStatus >= 0 */


end finally.

/* ============================================================================= *
* As a Financial Controller, I want to be able to create open item adjustments *
* to reopen closed AR documents and posting the adjusted amount to multiple *
* GL Accounts. *
* ----------------------------------------------------------------------------- *
* Scenario : Reopening of closed customer invoice against journal entry lines *
* *
* Input data: Entity: 10USACO *

https://team.qad.com/pages/viewpage.action?spaceKey=FIN&title=Fin-Integration+using+APIs%3A+OIA-JE+-+BOIAJE Página 13 de 18
Fin-Integration using APIs: OIA-JE - BOIAJE - R&D Financials Group - Confluence - QAD Inc 03/12/2019 17)32

* : Customer Invoice with a balance of 0 *


* : Journal entry lines (GL allocation) *
* ============================================================================= */
routine-level on error undo, throw.

/* Required definitions */
{ proxy/QadFinancialsConstants.i }
{ proxy/datasets/boiaje.i }
{ proxy/boiaje/apimaintainbydatasetwithoutputdef.i }

/* Variables used in exception handling */


define variable viErrCount as integer no-undo.
define variable vcReturnedInfo as char no-undo.
define variable vhOIAdjustQry as handle no-undo.
define variable vhOIAdjustBfr as handle no-undo.

/* Specify input for the API method */


vcProxyCompanyCode = "10USACO".
izObjectToUpdate = dataset boiaje:handle.
ilReturnDataset = true.

/* ensure a clean set of data is used */


empty temp-table tApiOIAdjustOIAJE.
empty temp-table tApiOIAdjustLnOIAJE.
empty temp-table tApiPostingLineOIAJE.
empty temp-table tApiPostingSafOIAJE.
empty temp-table tApiPostingVatOIAJE.
empty temp-table tApiPostingVatDelayOIAJE.

/* Specify the details for the OIA header */


create tApiOIAdjustOIAJE.
assign tApiOIAdjustOIAJE.OIAdjustPostingJournalCode = "CUSTADJ" /* Daybook Code */
tApiOIAdjustOIAJE.OIAdjustPostingDate = today
tApiOIAdjustOIAJE.OIAdjustDescription = "Customer invoice re-open + GL alloc"
tApiOIAdjustOIAJE.tc_Rowid = "oia-1".

/* Specify closed customer invoice */


create tApiOIAdjustLnOIAJE.
assign tApiOIAdjustLnOIAJE.OIAdjustLnType = {&OIADJUSTLNTYPE-DIMOV} /* Customer Invoice Movement */
tApiOIAdjustLnOIAJE.OIAdjustLnInvYear = 2018
tApiOIAdjustLnOIAJE.OIAdjustLnInvJournalCode = "CIM" /* Daybook Code */
tApiOIAdjustLnOIAJE.OIAdjustLnInvVoucher = 34
tApiOIAdjustLnOIAJE.OIAdjustLnNewBalanceAmtTC = 50 /* New Balance Amount */
tApiOIAdjustLnOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiOIAdjustLnOIAJE.tc_Rowid = "oia-2".

/* Allocate part of the reopening invoice amount against GL account with SAFs */
create tApiPostingLineOIAJE.
assign tApiPostingLineOIAJE.tcGLCode = "6830" /* GL account */
tApiPostingLineOIAJE.PostingLineCreditTC = 52.77
tApiPostingLineOIAJE.PostingLineDebitTC = 0
tApiPostingLineOIAJE.tcDivisionCode = "Elec" /* Sub-account */
tApiPostingLineOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiPostingLineOIAJE.tc_Rowid = "oia-3".

create tApiPostingSafOIAJE.
assign tApiPostingSafOIAJE.tcSafConceptCode = "Site" /* SAF concept */
tApiPostingSafOIAJE.tcSafCode = "UK-01" /* SAF code */
tApiPostingSafOIAJE.tc_ParentRowid = tApiPostingLineOIAJE.tc_Rowid
tApiPostingSafOIAJE.tc_Rowid = "oia-4".

create tApiPostingSafOIAJE.
assign tApiPostingSafOIAJE.tcSafConceptCode = "Product Line" /* SAF concept */

https://team.qad.com/pages/viewpage.action?spaceKey=FIN&title=Fin-Integration+using+APIs%3A+OIA-JE+-+BOIAJE Página 14 de 18
Fin-Integration using APIs: OIA-JE - BOIAJE - R&D Financials Group - Confluence - QAD Inc 03/12/2019 17)32

tApiPostingSafOIAJE.tcSafCode = "ACE" /* SAF code */


tApiPostingSafOIAJE.tc_ParentRowid = tApiPostingLineOIAJE.tc_Rowid
tApiPostingSafOIAJE.tc_Rowid = "oia-5".

/* Allocate part of the reopening invoice amount against GL account of Open account type */
create tApiPostingLineOIAJE.
assign tApiPostingLineOIAJE.tcGLCode = "1390" /* Tax GL account */
tApiPostingLineOIAJE.PostingLineDebitTC = 2.77
tApiPostingLineOIAJE.PostingLineCreditTC = 0
tApiPostingLineOIAJE.tcAllocationType = {&ALLOCATIONTYPE-LINK} /* Allocation type */
/* {&ALLOCATIONTYPE-NEW} = "N" - New open */
/* {&ALLOCATIONTYPE-LATER} = "A" - Allocate later */
/* {&ALLOCATIONTYPE-LINK} = "L" - Link to Open Item */
tApiPostingLineOIAJE.tcAllocationKey = "OIA netting difference"
tApiPostingLineOIAJE.tcAllocationPostingLine = "2018/CUSTADJ/74"
tApiPostingLineOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiPostingLineOIAJE.tc_Rowid = "oia-6".

/* Call the API method */


{ proxy/boiaje/apimaintainbydatasetwithoutputrun.i }

/* Exception handling - see exception handling from the first example */

/* ============================================================================= *
* As a Financial Controller, I want to be able to create open item adjustments *
* that re-open closed AP documents and post entries to bank, bank charge and tax*
* accounts *
* ----------------------------------------------------------------------------- *
* Scenario : Reopening of closed supplier invoices against journal entry lines *
* *
* Input data: Supplier Invoice with a balance of 0 *
* : Journal entry lines (GL allocation) *
* ============================================================================= */
routine-level on error undo, throw.

/* Required definitions */
{ proxy/QadFinancialsConstants.i }
{ proxy/datasets/boiaje.i }
{ proxy/boiaje/apimaintainbydatasetwithoutputdef.i }

/* Variables used in exception handling */


define variable viErrCount as integer no-undo.
define variable vcReturnedInfo as char no-undo.
define variable vhOIAdjustQry as handle no-undo.
define variable vhOIAdjustBfr as handle no-undo.

/* Specify input for the API method */


vcProxyCompanyCode = "10USACO".
izObjectToUpdate = dataset boiaje:handle.
ilReturnDataset = true.

/* ensure a clean set of data is used */


empty temp-table tApiOIAdjustOIAJE.
empty temp-table tApiOIAdjustLnOIAJE.
empty temp-table tApiPostingLineOIAJE.
empty temp-table tApiPostingSafOIAJE.
empty temp-table tApiPostingVatOIAJE.
empty temp-table tApiPostingVatDelayOIAJE.

https://team.qad.com/pages/viewpage.action?spaceKey=FIN&title=Fin-Integration+using+APIs%3A+OIA-JE+-+BOIAJE Página 15 de 18
Fin-Integration using APIs: OIA-JE - BOIAJE - R&D Financials Group - Confluence - QAD Inc 03/12/2019 17)32

/* Specify the details for the OIA header */


create tApiOIAdjustOIAJE.
assign tApiOIAdjustOIAJE.OIAdjustPostingJournalCode = "SUPADJ" /* Daybook Code */
tApiOIAdjustOIAJE.OIAdjustPostingDate = today
tApiOIAdjustOIAJE.OIAdjustDescription = "Supplier invoice re-open"
tApiOIAdjustOIAJE.tc_Rowid = "oia-1".

/* ================================================================================ */
/* Specify closed supplier invoice to be re-opened */
/* ================================================================================ */
create tApiOIAdjustLnOIAJE.
assign tApiOIAdjustLnOIAJE.OIAdjustLnType = {&OIADJUSTLNTYPE-CIMOV} /* Supplier Invoice Movement */
tApiOIAdjustLnOIAJE.OIAdjustLnInvYear = 2018 /* Year */
tApiOIAdjustLnOIAJE.OIAdjustLnInvJournalCode = "SINV" /* Daybook Code */
tApiOIAdjustLnOIAJE.OIAdjustLnInvVoucher = 38 /* Voucher */
tApiOIAdjustLnOIAJE.OIAdjustLnNewBalanceAmtTC = -100 /* New Balance Amount */
tApiOIAdjustLnOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiOIAdjustLnOIAJE.tc_Rowid = "oia-2".

/* ================================================================================ */
/* Use GL allocation to balance the transaction */
/* ================================================================================ */
/* Bank GL account */
create tApiPostingLineOIAJE.
assign tApiPostingLineOIAJE.tcGLCode = "1100" /* GL account */
tApiPostingLineOIAJE.PostingLineCreditTC = 0
tApiPostingLineOIAJE.PostingLineDebitTC = 80
tApiPostingLineOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiPostingLineOIAJE.tc_Rowid = "oia-3".

/* Bank charge (GL account that contains both sub-account and SAF analysis */
create tApiPostingLineOIAJE.
assign tApiPostingLineOIAJE.tcGLCode = "6830" /* GL account */
tApiPostingLineOIAJE.tcDivisionCode = "Elec" /* Sub-account */
tApiPostingLineOIAJE.PostingLineCreditTC = 0
tApiPostingLineOIAJE.PostingLineDebitTC = 13.02
tApiPostingLineOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiPostingLineOIAJE.tc_Rowid = "oia-4".

create tApiPostingSafOIAJE.
assign tApiPostingSafOIAJE.tcSafConceptCode = "Supplier Type" /* SAF concept */
tApiPostingSafOIAJE.tcSafCode = "PROD" /* SAF code */
tApiPostingSafOIAJE.tc_ParentRowid = tApiPostingLineOIAJE.tc_Rowid
tApiPostingSafOIAJE.tc_Rowid = "oia-5".

create tApiPostingSafOIAJE.
assign tApiPostingSafOIAJE.tcSafConceptCode = "Product Line" /* SAF concept */
tApiPostingSafOIAJE.tcSafCode = "ACE" /* SAF code */
tApiPostingSafOIAJE.tc_ParentRowid = tApiPostingLineOIAJE.tc_Rowid
tApiPostingSafOIAJE.tc_Rowid = "oia-6".

/* Tax account */
create tApiPostingLineOIAJE.
assign tApiPostingLineOIAJE.tcGLCode = "1400"
tApiPostingLineOIAJE.PostingLineCreditTC = 0
tApiPostingLineOIAJE.PostingLineDebitTC = 6.98
tApiPostingLineOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiPostingLineOIAJE.tc_Rowid = "oia-7".

create tApiPostingVatOIAJE.
assign tApiPostingVatOIAJE.PostingVatBaseDebitTC = 23.81

https://team.qad.com/pages/viewpage.action?spaceKey=FIN&title=Fin-Integration+using+APIs%3A+OIA-JE+-+BOIAJE Página 16 de 18
Fin-Integration using APIs: OIA-JE - BOIAJE - R&D Financials Group - Confluence - QAD Inc 03/12/2019 17)32

tApiPostingVatOIAJE.PostingVatInOut = {&VATINOUT-INPUT}
tApiPostingVatOIAJE.PostingVatTaxTransType = "55"
tApiPostingVatOIAJE.PostingVatTransType = "PURCHASE"
tApiPostingVatOIAJE.PostingVatOwnTaxIDFeder = "1111111111"
tApiPostingVatOIAJE.PostingVatIsReverseCharge = no
tApiPostingVatOIAJE.PostingVatIsAbsRet = no
tApiPostingVatOIAJE.PostingVatIsSuspDel = no
tApiPostingVatOIAJE.TxtyTaxType = "US-ST"
tApiPostingVatOIAJE.TxenvTaxEnv = "USA"
tApiPostingVatOIAJE.FromTxzTaxZone = ""
tApiPostingVatOIAJE.ToTxzTaxZone = ""
tApiPostingVatOIAJE.tcVatCode = "15"
tApiPostingVatOIAJE.tc_ParentRowid = tApiPostingLineOIAJE.tc_Rowid
tApiPostingVatOIAJE.tc_Rowid = "oia-8".

/* Call the API method */


{ proxy/boiaje/apimaintainbydatasetwithoutputrun.i }

/* Exception handling - see exception handling from the first example */

/* ============================================================================= *
* As a Financial Controller, I want to be able to write off *
* supplier/customer invoices from different entities and post the balance *
* against a GL expense account *
* ----------------------------------------------------------------------------- *
* Scenario : Close supplier invoice *
* Close customer invoice *
* Post the difference against GL account *
* ============================================================================= */
routine-level on error undo, throw.

/* Required definitions */
{ proxy/QadFinancialsConstants.i }
{ proxy/datasets/boiaje.i }
{ proxy/boiaje/apimaintainbydatasetwithoutputdef.i }

/* Variables used in exception handling */


define variable viErrCount as integer no-undo.
define variable vcReturnedInfo as char no-undo.
define variable vhOIAdjustQry as handle no-undo.
define variable vhOIAdjustBfr as handle no-undo.

/* Specify input for the API method */


vcProxyCompanyCode = "10USACO".
izObjectToUpdate = dataset boiaje:handle.
ilReturnDataset = true.

/* ensure a clean set of data is used */


empty temp-table tApiOIAdjustOIAJE.
empty temp-table tApiOIAdjustLnOIAJE.
empty temp-table tApiPostingLineOIAJE.
empty temp-table tApiPostingSafOIAJE.
empty temp-table tApiPostingVatOIAJE.
empty temp-table tApiPostingVatDelayOIAJE.

/* Specify the details for the OIA header */


create tApiOIAdjustOIAJE.
assign tApiOIAdjustOIAJE.OIAdjustPostingJournalCode = "CUSTADJ" /* Daybook Code */

https://team.qad.com/pages/viewpage.action?spaceKey=FIN&title=Fin-Integration+using+APIs%3A+OIA-JE+-+BOIAJE Página 17 de 18
Fin-Integration using APIs: OIA-JE - BOIAJE - R&D Financials Group - Confluence - QAD Inc 03/12/2019 17)32

tApiOIAdjustOIAJE.OIAdjustPostingDate = today
tApiOIAdjustOIAJE.OIAdjustDescription = "CI SI Write Off + GL Alloc"
tApiOIAdjustOIAJE.tc_Rowid = "oia-1".

/* ================================================================================ */
/* Specify customer invoice to be closed */
/* ================================================================================ */
create tApiOIAdjustLnOIAJE.
assign tApiOIAdjustLnOIAJE.OIAdjustLnType = {&OIADJUSTLNTYPE-DIMOV} /* Customer Invoice Movement */
tApiOIAdjustLnOIAJE.OIAdjustLnInvYear = 2018 /* Year */
tApiOIAdjustLnOIAJE.OIAdjustLnInvJournalCode = "CIM" /* Daybook Code */
tApiOIAdjustLnOIAJE.OIAdjustLnInvVoucher = 40 /* Voucher */
tApiOIAdjustLnOIAJE.OIAdjustLnNewBalanceAmtTC = 0 /* New Balance Amount */
tApiOIAdjustLnOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiOIAdjustLnOIAJE.tc_Rowid = "oia-2".

/* ================================================================================ */
/* Specify supplier invoice to be closed */
/* ================================================================================ */
create tApiOIAdjustLnOIAJE.
assign tApiOIAdjustLnOIAJE.OIAdjustLnType = {&OIADJUSTLNTYPE-CIMOV} /* Supplier Invoice Movement */
tApiOIAdjustLnOIAJE.OIAdjustLnInvCompanyCode = "22UKCO"
tApiOIAdjustLnOIAJE.OIAdjustLnInvYear = 2018 /* Year */
tApiOIAdjustLnOIAJE.OIAdjustLnInvJournalCode = "SINV" /* Daybook Code */
tApiOIAdjustLnOIAJE.OIAdjustLnInvVoucher = 34 /* Voucher */
tApiOIAdjustLnOIAJE.OIAdjustLnNewBalanceAmtTC = 0 /* New Balance Amount */
tApiOIAdjustLnOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiOIAdjustLnOIAJE.tc_Rowid = "oia-3".

/* =================================================================================== */
/* Use GL allocation to balance the transaction and post it against expense GL account */
/* =================================================================================== */
create tApiPostingLineOIAJE.
assign tApiPostingLineOIAJE.tcGLCode = "7825" /* GL account */
tApiPostingLineOIAJE.tcCurrencyCode = "USD" /* Currency */
tApiPostingLineOIAJE.PostingLineDebitTC = 9
tApiPostingLineOIAJE.PostingLineDebitLC = 9
tApiPostingLineOIAJE.PostingLineDebitCC = 9
tApiPostingLineOIAJE.tc_ParentRowid = tApiOIAdjustOIAJE.tc_Rowid
tApiPostingLineOIAJE.tc_Rowid = "oia-4".

/* Call the API method */


{ proxy/boiaje/apimaintainbydatasetwithoutputrun.i }

/* Exception handling - see exception handling from the first example */

Sem rótulos

https://team.qad.com/pages/viewpage.action?spaceKey=FIN&title=Fin-Integration+using+APIs%3A+OIA-JE+-+BOIAJE Página 18 de 18

You might also like