diff --git a/Fortellis Notes.md b/Fortellis Notes.md index 0cb7e1941..066dc8713 100644 --- a/Fortellis Notes.md +++ b/Fortellis Notes.md @@ -1,18 +1,341 @@ Fortellis Notes Subscription ID -* Appears to give us a list of all dealerships we have access to, and `apiDmsInfo` contains the integrations that are enabled for that dealership. -* Will likely need to filter based on the DMS ID or something? -* Should store the whole subscription object. Contains department information needed in subsequent calls. +- Appears to give us a list of all dealerships we have access to, and `apiDmsInfo` contains the integrations that are enabled for that dealership. +- Will likely need to filter based on the DMS ID or something? +- Should store the whole subscription object. Contains department information needed in subsequent calls. Department ID -* May have multiple departments. Appears that financial stuff goes to Accounting, History will go to Service. -* TODO: How do we handle the multiple departments that may come up. +- May have multiple departments. Appears that financial stuff goes to Accounting, History will go to Service. +- TODO: How do we handle the multiple departments that may come up. + +# GL Wip Posting + +## Org Helper Return Data + +```json +[ + { + "acctgLgnID": "DEVWB-A", + "applCode": "V", + "coID": "77", + "companyName": "TEST SYS C187092 DEVWB", + "lgnDesc": "DEV WRITE BACK VMS", + "logon": "DEVWB-V" + }, + { + "acctgLgnID": "DEVWB-A", + "applCode": "F", + "coID": "77", + "companyName": "TEST SYS C187092 DEVWB", + "lgnDesc": "DEV WRITE BACK F&I SALES", + "logon": "DEVWB-FI" + }, + { + "acctgLgnID": "DEVWB-A", + "applCode": "CS", + "coID": "77", + "companyName": "TEST SYS C187092 DEVWB", + "lgnDesc": "DEV WRITE BACK SERVICE", + "logon": "DEVWB-S" + }, + { + "acctgLgnID": "DEVWB-A", + "applCode": "A", + "coID": "77", + "companyName": "TEST SYS C187092 DEVWB", + "lgnDesc": "DEV WRITE BACK ACCTG", + "logon": "DEVWB-A" + }, + { + "acctgLgnID": "DEVWB-A", + "applCode": "SL", + "coID": "77", + "companyName": "TEST SYS C187092 DEVWB", + "lgnDesc": "DEV WRTIE BACK SLS MGMT", + "logon": "DEVWB-SL" + }, + { + "acctgLgnID": "DEVWB-A", + "applCode": "O", + "coID": "77", + "companyName": "TEST SYS C187092 DEVWB", + "lgnDesc": "DEV WRITE BACK PARTS", + "logon": "DEVWB-I" + } +] +``` + +## Journal Helper Return Data + +```json +[ + { + "companyNo": "77", + "jrnlID": "32", + "jrnlName": "PARTS SALES", + "jrnlType": "S", + "intercoFlag": "0", + "defaultDocType": "4", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "92", + "jrnlName": "YTD ADJUSTMENTS", + "jrnlType": "Y", + "intercoFlag": "0", + "defaultDocType": "3", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "12", + "jrnlName": "FLEET SALES", + "jrnlType": "S", + "intercoFlag": "0", + "defaultDocType": "9", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "57", + "jrnlName": "CASH RECEIPTS (OPEN-ITEM)", + "jrnlType": "R", + "intercoFlag": "0", + "defaultDocType": "1", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "93", + "jrnlName": "SET UP HISTORY", + "jrnlType": "H", + "intercoFlag": "0", + "defaultDocType": "10", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "88", + "jrnlName": "F/S STATISCAL DATA", + "jrnlType": "F", + "intercoFlag": "0", + "defaultDocType": "10", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "58", + "jrnlName": "WARRANTY CREDITS", + "jrnlType": "G", + "intercoFlag": "0", + "defaultDocType": "3", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "FC", + "jrnlName": "FINANCE CHARGE", + "jrnlType": "A", + "intercoFlag": "0", + "defaultDocType": "12", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "94", + "jrnlName": "SET UP SCHEDULES", + "jrnlType": "C", + "intercoFlag": "0", + "defaultDocType": "3", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "95", + "jrnlName": "SET UP GENERAL LEDGER", + "jrnlType": "B", + "intercoFlag": "0", + "defaultDocType": "3", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "20", + "jrnlName": "USED VEHICLE SALES", + "jrnlType": "S", + "intercoFlag": "0", + "defaultDocType": "9", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "60", + "jrnlName": "CASH DISBURSEMENTS", + "jrnlType": "G", + "intercoFlag": "0", + "defaultDocType": "2", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "30", + "jrnlName": "SERVICE SALES", + "jrnlType": "S", + "intercoFlag": "0", + "defaultDocType": "7", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "40", + "jrnlName": "PAYROLL", + "jrnlType": "G", + "intercoFlag": "0", + "defaultDocType": "11", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "15", + "jrnlName": "DEALER TRADES", + "jrnlType": "S", + "intercoFlag": "0", + "defaultDocType": "9", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "70", + "jrnlName": "NEW VEHICLE PURCHASES", + "jrnlType": "G", + "intercoFlag": "0", + "defaultDocType": "8", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "25", + "jrnlName": "USED WHOLESALE", + "jrnlType": "S", + "intercoFlag": "0", + "defaultDocType": "9", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "75", + "jrnlName": "GENERAL PURCHASES", + "jrnlType": "G", + "intercoFlag": "0", + "defaultDocType": "5", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "10", + "jrnlName": "NEW VEHICLE SALES", + "jrnlType": "S", + "intercoFlag": "0", + "defaultDocType": "9", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "80", + "jrnlName": "GENERAL JOURNAL", + "jrnlType": "G", + "intercoFlag": "0", + "defaultDocType": "3", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "11", + "jrnlName": "WORK IN PROGRESS", + "jrnlType": "G", + "intercoFlag": "0", + "defaultDocType": "10", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "56", + "jrnlName": "CASH RECEIPTS (BALANCE FWD)", + "jrnlType": "G", + "intercoFlag": "0", + "defaultDocType": "1", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "81", + "jrnlName": "STANDARD ENTRIES", + "jrnlType": "G", + "intercoFlag": "0", + "defaultDocType": "6", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "51", + "jrnlName": "CASH RECEIPTS JOURNAL - EFT", + "jrnlType": "G", + "intercoFlag": "0", + "defaultDocType": "10", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "61", + "jrnlName": "CASH DISBURSMENTS -EFT", + "jrnlType": "G", + "intercoFlag": "0", + "defaultDocType": "10", + "errCode": "", + "errMsg": "" + }, + { + "companyNo": "77", + "jrnlID": "71", + "jrnlName": "USED VEHICLE PURCHASES", + "jrnlType": "G", + "intercoFlag": "0", + "defaultDocType": "8", + "errCode": "", + "errMsg": "" + } +] +``` # Feedback -* Receiving bad request errors, with no details. API errors page doesn't indicate what's wrong. -# API Error -* Not in real time - appaers to be every 3 minutes? +- Receiving bad request errors, with no details. API errors page doesn't indicate what's wrong for certain types of error codes. +- API Error page works on a several minute delay. diff --git a/fortellis.js b/fortellis.js index d5bcad4ba..925c95fb9 100644 --- a/fortellis.js +++ b/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();