mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
✨ Add QuickBooks transactions report (#2040)
* add get QBO report: transaction list * merge upstream with n8n master * Update QuickBooks.node.ts * add back transaction list resource * ⚡ Refactor transactions list expansion * ⚡ Alphabetize options * ⚡ Fix param type of source account types * ⚡ Add missing description * ⚡ Improve memo display name * ⚡ Fix default values * ⚡ Fix casing * 🔥 Remove logging * ⚡ Remove time from dates * 🔨 Rename operation * ⚡ Add simplify response toggle * 🐛 Fix issue when transaction:getReport does not return data Co-authored-by: Calvin Tan <calvin14@gmail.com> Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
This commit is contained in:
@@ -28,11 +28,14 @@ import {
|
||||
paymentOperations,
|
||||
purchaseFields,
|
||||
purchaseOperations,
|
||||
transactionFields,
|
||||
transactionOperations,
|
||||
vendorFields,
|
||||
vendorOperations,
|
||||
} from './descriptions';
|
||||
|
||||
import {
|
||||
adjustTransactionDates,
|
||||
getRefAndSyncToken,
|
||||
getSyncToken,
|
||||
handleBinaryData,
|
||||
@@ -41,6 +44,7 @@ import {
|
||||
populateFields,
|
||||
processLines,
|
||||
quickBooksApiRequest,
|
||||
simplifyTransactionReport,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import {
|
||||
@@ -52,7 +56,9 @@ import {
|
||||
} from 'lodash';
|
||||
|
||||
import {
|
||||
DateFieldsUi,
|
||||
QuickBooksOAuth2Credentials,
|
||||
TransactionFields,
|
||||
} from './types';
|
||||
|
||||
export class QuickBooks implements INodeType {
|
||||
@@ -114,6 +120,10 @@ export class QuickBooks implements INodeType {
|
||||
name: 'Purchase',
|
||||
value: 'purchase',
|
||||
},
|
||||
{
|
||||
name: 'Transaction',
|
||||
value: 'transaction',
|
||||
},
|
||||
{
|
||||
name: 'Vendor',
|
||||
value: 'vendor',
|
||||
@@ -138,6 +148,8 @@ export class QuickBooks implements INodeType {
|
||||
...paymentFields,
|
||||
...purchaseOperations,
|
||||
...purchaseFields,
|
||||
...transactionOperations,
|
||||
...transactionFields,
|
||||
...vendorOperations,
|
||||
...vendorFields,
|
||||
],
|
||||
@@ -153,14 +165,26 @@ export class QuickBooks implements INodeType {
|
||||
return await loadResource.call(this, 'preferences');
|
||||
},
|
||||
|
||||
async getDepartments(this: ILoadOptionsFunctions) {
|
||||
return await loadResource.call(this, 'department');
|
||||
},
|
||||
|
||||
async getItems(this: ILoadOptionsFunctions) {
|
||||
return await loadResource.call(this, 'item');
|
||||
},
|
||||
|
||||
async getMemos(this: ILoadOptionsFunctions) {
|
||||
return await loadResource.call(this, 'CreditMemo');
|
||||
},
|
||||
|
||||
async getPurchases(this: ILoadOptionsFunctions) {
|
||||
return await loadResource.call(this, 'purchase');
|
||||
},
|
||||
|
||||
async getTerms(this: ILoadOptionsFunctions) {
|
||||
return await loadResource.call(this, 'Term');
|
||||
},
|
||||
|
||||
async getVendors(this: ILoadOptionsFunctions) {
|
||||
return await loadResource.call(this, 'vendor');
|
||||
},
|
||||
@@ -948,6 +972,67 @@ export class QuickBooks implements INodeType {
|
||||
|
||||
}
|
||||
|
||||
} else if (resource === 'transaction') {
|
||||
|
||||
// *********************************************************************
|
||||
// transaction
|
||||
// *********************************************************************
|
||||
|
||||
// https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/transactionlist
|
||||
|
||||
if (operation === 'getReport') {
|
||||
|
||||
// ----------------------------------
|
||||
// transaction: getReport
|
||||
// ----------------------------------
|
||||
|
||||
const {
|
||||
columns,
|
||||
memo,
|
||||
term,
|
||||
customer,
|
||||
vendor,
|
||||
...rest
|
||||
} = this.getNodeParameter('filters', i) as TransactionFields;
|
||||
|
||||
let qs = { ...rest };
|
||||
|
||||
if (columns?.length) {
|
||||
qs.columns = columns.join(',');
|
||||
}
|
||||
|
||||
if (memo?.length) {
|
||||
qs.memo = memo.join(',');
|
||||
}
|
||||
|
||||
if (term?.length) {
|
||||
qs.term = term.join(',');
|
||||
}
|
||||
|
||||
if (customer?.length) {
|
||||
qs.customer = customer.join(',');
|
||||
}
|
||||
|
||||
if (vendor?.length) {
|
||||
qs.vendor = vendor.join(',');
|
||||
}
|
||||
|
||||
qs = adjustTransactionDates(qs);
|
||||
|
||||
const endpoint = `/v3/company/${companyId}/reports/TransactionList`;
|
||||
responseData = await quickBooksApiRequest.call(this, 'GET', endpoint, qs, {});
|
||||
|
||||
const simplifyResponse = this.getNodeParameter('simple', i, true) as boolean;
|
||||
|
||||
if (!Object.keys(responseData?.Rows).length) {
|
||||
responseData = [];
|
||||
}
|
||||
|
||||
if (simplifyResponse && !Array.isArray(responseData)) {
|
||||
responseData = simplifyTransactionReport(responseData);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (resource === 'vendor') {
|
||||
|
||||
// *********************************************************************
|
||||
|
||||
Reference in New Issue
Block a user