Succesful header creation.
This commit is contained in:
50
fortellis.js
50
fortellis.js
@@ -64,6 +64,7 @@ async function FetchSubscriptions() {
|
||||
}
|
||||
|
||||
async function GetDepartmentId({ apiName, debug = false }) {
|
||||
if (!apiName) throw new Error('apiName not provided. Unable to get department without apiName.');
|
||||
if (debug) {
|
||||
console.log('API Names & Departments ');
|
||||
console.log('===========');
|
||||
@@ -140,7 +141,7 @@ async function MakeFortellisCall({
|
||||
return result.data;
|
||||
} catch (error) {
|
||||
console.log(`ReqID: ${ReqId} Error`, error.response?.data);
|
||||
console.log(`ReqID: ${ReqId} Full Error`, JSON.stringify(error, null, 4));
|
||||
//console.log(`ReqID: ${ReqId} Full Error`, JSON.stringify(error, null, 4));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,21 +150,23 @@ async function GetCOA() {
|
||||
await MakeFortellisCall({
|
||||
debug: true,
|
||||
type: 'get',
|
||||
apiName: 'CDK Drive Post Accounts GL WIP',
|
||||
url: `https://api.fortellis.io/cdk-test/drive/chartofaccounts/v2/bulk`,
|
||||
});
|
||||
}
|
||||
|
||||
async function StartWIP() {
|
||||
const TransactionWip = MakeFortellisCall({
|
||||
url: 'https://api.fortellis.io/cdk-test/drive/glpost/startWIP',
|
||||
url: 'https://api.fortellis.io/cdk-test/drive/glwippost/startWIP',
|
||||
apiName: 'CDK Drive Post Accounts GL WIP',
|
||||
body: {
|
||||
acctgDate: '2023-09-26', //job.invoice
|
||||
desc: 'TEST TRANSACTION',
|
||||
docType: '3', //pulled from Doc Type workbook
|
||||
m13Flag: '0', // Is this a M13 entry. Presumanbly always 0
|
||||
refer: 'RO12345', //Supposed to be a doc reference number. Presumably the RO?
|
||||
srcCo: '1',
|
||||
srcJrnl: '75',
|
||||
srcCo: '77',
|
||||
srcJrnl: '80',
|
||||
userID: 'csr', //bodyshop user
|
||||
userName: 'PROGRAM, PARTNER*ADP', //Can leave blank to have this return to default.
|
||||
},
|
||||
@@ -173,18 +176,39 @@ async function StartWIP() {
|
||||
return TransactionWip;
|
||||
}
|
||||
|
||||
async function InsertBatch({ transID }) {
|
||||
const TransactionWip = MakeFortellisCall({
|
||||
url: 'https://api.fortellis.io/cdk-test/drive/glwippost/transWIP',
|
||||
apiName: 'CDK Drive Post Accounts GL WIP',
|
||||
body: [
|
||||
{
|
||||
acct: '',
|
||||
cntl: '',
|
||||
cntl2: null,
|
||||
credtMemoNo: null,
|
||||
postAmt: Math.round(payer.amount * 100),
|
||||
postDesc: '', //Required if required by the DMS setup
|
||||
prod: null, //Productivity Number
|
||||
statCnt: 1, //Auto count, leave as 1.
|
||||
transID: transID,
|
||||
trgtCoID: '77', //Add this to read from the header
|
||||
},
|
||||
],
|
||||
debug: true,
|
||||
});
|
||||
}
|
||||
|
||||
async function DoTheThings() {
|
||||
await FetchSubscriptions();
|
||||
//What do we have access to?
|
||||
// console.log('Sub Access : ', SubscriptionMeta.apiDmsInfo.map((i) => i.name).join(', '));
|
||||
//await GetCOA();
|
||||
await MakeFortellisCall({
|
||||
type: 'get',
|
||||
debug: true,
|
||||
apiName: 'CDK Drive Post Accounts GL WIP',
|
||||
url: 'https://api.fortellis.io/cdk-test/drive/glwippost/orgHelper',
|
||||
});
|
||||
//await StartWIP();
|
||||
console.log('Sub Access : ', SubscriptionMeta.apiDmsInfo.map((i) => i.name).join(', '));
|
||||
await GetCOA();
|
||||
|
||||
return;
|
||||
|
||||
//Insert Transactions
|
||||
const TransactionHeader = await StartWIP();
|
||||
const BatchResult = await InsertBatch({ transID: TransactionHeader.transID });
|
||||
}
|
||||
|
||||
DoTheThings();
|
||||
|
||||
Reference in New Issue
Block a user