filter gp documents
parent
721f6059d0
commit
bbcfed5f45
|
|
@ -52,4 +52,6 @@ export declare function getProperty(propertyName: 'settings.printPdf.contentDisp
|
||||||
export declare function getProperty(propertyName: 'settings.dynamicsGP.integrationIsEnabled'): boolean;
|
export declare function getProperty(propertyName: 'settings.dynamicsGP.integrationIsEnabled'): boolean;
|
||||||
export declare function getProperty(propertyName: 'settings.dynamicsGP.mssqlConfig'): MSSQLConfig;
|
export declare function getProperty(propertyName: 'settings.dynamicsGP.mssqlConfig'): MSSQLConfig;
|
||||||
export declare function getProperty(propertyName: 'settings.dynamicsGP.lookupOrder'): configTypes.DynamicsGPLookup[];
|
export declare function getProperty(propertyName: 'settings.dynamicsGP.lookupOrder'): configTypes.DynamicsGPLookup[];
|
||||||
|
export declare function getProperty(propertyName: 'settings.dynamicsGP.accountCodes'): string[];
|
||||||
|
export declare function getProperty(propertyName: 'settings.dynamicsGP.itemNumbers'): string[];
|
||||||
export declare const keepAliveMillis: number;
|
export declare const keepAliveMillis: number;
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,8 @@ configFallbackValues.set('settings.adminCleanup.recordDeleteAgeDays', 60);
|
||||||
configFallbackValues.set('settings.printPdf.contentDisposition', 'attachment');
|
configFallbackValues.set('settings.printPdf.contentDisposition', 'attachment');
|
||||||
configFallbackValues.set('settings.dynamicsGP.integrationIsEnabled', false);
|
configFallbackValues.set('settings.dynamicsGP.integrationIsEnabled', false);
|
||||||
configFallbackValues.set('settings.dynamicsGP.lookupOrder', ['invoice']);
|
configFallbackValues.set('settings.dynamicsGP.lookupOrder', ['invoice']);
|
||||||
|
configFallbackValues.set('settings.dynamicsGP.accountCodes', []);
|
||||||
|
configFallbackValues.set('settings.dynamicsGP.itemNumbers', []);
|
||||||
export function getProperty(propertyName) {
|
export function getProperty(propertyName) {
|
||||||
const propertyNameSplit = propertyName.split('.');
|
const propertyNameSplit = propertyName.split('.');
|
||||||
let currentObject = config;
|
let currentObject = config;
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,8 @@ configFallbackValues.set('settings.printPdf.contentDisposition', 'attachment')
|
||||||
|
|
||||||
configFallbackValues.set('settings.dynamicsGP.integrationIsEnabled', false)
|
configFallbackValues.set('settings.dynamicsGP.integrationIsEnabled', false)
|
||||||
configFallbackValues.set('settings.dynamicsGP.lookupOrder', ['invoice'])
|
configFallbackValues.set('settings.dynamicsGP.lookupOrder', ['invoice'])
|
||||||
|
configFallbackValues.set('settings.dynamicsGP.accountCodes', [])
|
||||||
|
configFallbackValues.set('settings.dynamicsGP.itemNumbers', [])
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up function overloads
|
* Set up function overloads
|
||||||
|
|
@ -229,6 +231,14 @@ export function getProperty(
|
||||||
propertyName: 'settings.dynamicsGP.lookupOrder'
|
propertyName: 'settings.dynamicsGP.lookupOrder'
|
||||||
): configTypes.DynamicsGPLookup[]
|
): configTypes.DynamicsGPLookup[]
|
||||||
|
|
||||||
|
export function getProperty(
|
||||||
|
propertyName: 'settings.dynamicsGP.accountCodes'
|
||||||
|
): string[]
|
||||||
|
|
||||||
|
export function getProperty(
|
||||||
|
propertyName: 'settings.dynamicsGP.itemNumbers'
|
||||||
|
): string[]
|
||||||
|
|
||||||
export function getProperty(propertyName: string): unknown {
|
export function getProperty(propertyName: string): unknown {
|
||||||
const propertyNameSplit = propertyName.split('.')
|
const propertyNameSplit = propertyName.split('.')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,43 @@ if (configFunctions.getProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
||||||
gp.setMSSQLConfig(configFunctions.getProperty('settings.dynamicsGP.mssqlConfig'));
|
gp.setMSSQLConfig(configFunctions.getProperty('settings.dynamicsGP.mssqlConfig'));
|
||||||
diamond.setMSSQLConfig(configFunctions.getProperty('settings.dynamicsGP.mssqlConfig'));
|
diamond.setMSSQLConfig(configFunctions.getProperty('settings.dynamicsGP.mssqlConfig'));
|
||||||
}
|
}
|
||||||
|
function filterCashReceipt(cashReceipt) {
|
||||||
|
const accountCodes = configFunctions.getProperty('settings.dynamicsGP.accountCodes');
|
||||||
|
for (const accountCode of accountCodes) {
|
||||||
|
let found = cashReceipt.details.some((detailRecord) => {
|
||||||
|
return detailRecord.accountCode === accountCode;
|
||||||
|
});
|
||||||
|
if (!found) {
|
||||||
|
found = cashReceipt.distributions.some((distributionRecord) => {
|
||||||
|
return distributionRecord.accountCode === accountCode;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cashReceipt;
|
||||||
|
}
|
||||||
|
function filterInvoice(invoice) {
|
||||||
|
const itemNumbers = configFunctions.getProperty('settings.dynamicsGP.itemNumbers');
|
||||||
|
for (const itemNumber of itemNumbers) {
|
||||||
|
const found = invoice.lineItems.some((itemRecord) => {
|
||||||
|
return itemRecord.itemNumber === itemNumber;
|
||||||
|
});
|
||||||
|
if (!found) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return invoice;
|
||||||
|
}
|
||||||
async function _getDynamicsGPDocument(documentNumber, lookupType) {
|
async function _getDynamicsGPDocument(documentNumber, lookupType) {
|
||||||
let document;
|
let document;
|
||||||
switch (lookupType) {
|
switch (lookupType) {
|
||||||
case 'invoice': {
|
case 'invoice': {
|
||||||
const invoice = await gp.getInvoiceByInvoiceNumber(documentNumber);
|
let invoice = await gp.getInvoiceByInvoiceNumber(documentNumber);
|
||||||
|
if (invoice !== undefined) {
|
||||||
|
invoice = filterInvoice(invoice);
|
||||||
|
}
|
||||||
if (invoice !== undefined) {
|
if (invoice !== undefined) {
|
||||||
document = {
|
document = {
|
||||||
documentType: 'Invoice',
|
documentType: 'Invoice',
|
||||||
|
|
@ -27,7 +59,10 @@ async function _getDynamicsGPDocument(documentNumber, lookupType) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'diamond/cashReceipt': {
|
case 'diamond/cashReceipt': {
|
||||||
const receipt = await diamond.getCashReceiptByDocumentNumber(documentNumber);
|
let receipt = await diamond.getCashReceiptByDocumentNumber(documentNumber);
|
||||||
|
if (receipt !== undefined) {
|
||||||
|
receipt = filterCashReceipt(receipt);
|
||||||
|
}
|
||||||
if (receipt !== undefined) {
|
if (receipt !== undefined) {
|
||||||
document = {
|
document = {
|
||||||
documentType: 'Cash Receipt',
|
documentType: 'Cash Receipt',
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@ import * as configFunctions from './functions.config.js'
|
||||||
import type { DynamicsGPLookup } from '../types/configTypes'
|
import type { DynamicsGPLookup } from '../types/configTypes'
|
||||||
import type { DynamicsGPDocument } from '../types/recordTypes.js'
|
import type { DynamicsGPDocument } from '../types/recordTypes.js'
|
||||||
|
|
||||||
|
import { type DiamondCashReceipt } from '@cityssm/dynamics-gp/diamond/types.js'
|
||||||
|
import { type GPInvoice } from '@cityssm/dynamics-gp/gp/types.js'
|
||||||
|
|
||||||
if (configFunctions.getProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
if (configFunctions.getProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
||||||
gp.setMSSQLConfig(
|
gp.setMSSQLConfig(
|
||||||
configFunctions.getProperty('settings.dynamicsGP.mssqlConfig')
|
configFunctions.getProperty('settings.dynamicsGP.mssqlConfig')
|
||||||
|
|
@ -17,6 +20,50 @@ if (configFunctions.getProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function filterCashReceipt(
|
||||||
|
cashReceipt: DiamondCashReceipt
|
||||||
|
): DiamondCashReceipt | undefined {
|
||||||
|
const accountCodes = configFunctions.getProperty(
|
||||||
|
'settings.dynamicsGP.accountCodes'
|
||||||
|
)
|
||||||
|
|
||||||
|
for (const accountCode of accountCodes) {
|
||||||
|
let found = cashReceipt.details.some((detailRecord) => {
|
||||||
|
return detailRecord.accountCode === accountCode
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
found = cashReceipt.distributions.some((distributionRecord) => {
|
||||||
|
return distributionRecord.accountCode === accountCode
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cashReceipt
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterInvoice(invoice: GPInvoice): GPInvoice | undefined {
|
||||||
|
const itemNumbers = configFunctions.getProperty(
|
||||||
|
'settings.dynamicsGP.itemNumbers'
|
||||||
|
)
|
||||||
|
|
||||||
|
for (const itemNumber of itemNumbers) {
|
||||||
|
const found = invoice.lineItems.some((itemRecord) => {
|
||||||
|
return itemRecord.itemNumber === itemNumber
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return invoice
|
||||||
|
}
|
||||||
|
|
||||||
async function _getDynamicsGPDocument(
|
async function _getDynamicsGPDocument(
|
||||||
documentNumber: string,
|
documentNumber: string,
|
||||||
lookupType: DynamicsGPLookup
|
lookupType: DynamicsGPLookup
|
||||||
|
|
@ -25,7 +72,11 @@ async function _getDynamicsGPDocument(
|
||||||
|
|
||||||
switch (lookupType) {
|
switch (lookupType) {
|
||||||
case 'invoice': {
|
case 'invoice': {
|
||||||
const invoice = await gp.getInvoiceByInvoiceNumber(documentNumber)
|
let invoice = await gp.getInvoiceByInvoiceNumber(documentNumber)
|
||||||
|
|
||||||
|
if (invoice !== undefined) {
|
||||||
|
invoice = filterInvoice(invoice)
|
||||||
|
}
|
||||||
|
|
||||||
if (invoice !== undefined) {
|
if (invoice !== undefined) {
|
||||||
document = {
|
document = {
|
||||||
|
|
@ -45,9 +96,12 @@ async function _getDynamicsGPDocument(
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'diamond/cashReceipt': {
|
case 'diamond/cashReceipt': {
|
||||||
const receipt = await diamond.getCashReceiptByDocumentNumber(
|
let receipt: DiamondCashReceipt | undefined =
|
||||||
documentNumber
|
await diamond.getCashReceiptByDocumentNumber(documentNumber)
|
||||||
)
|
|
||||||
|
if (receipt !== undefined) {
|
||||||
|
receipt = filterCashReceipt(receipt)
|
||||||
|
}
|
||||||
|
|
||||||
if (receipt !== undefined) {
|
if (receipt !== undefined) {
|
||||||
document = {
|
document = {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
"@cityssm/bulma-js": "^0.4.0",
|
"@cityssm/bulma-js": "^0.4.0",
|
||||||
"@cityssm/bulma-webapp-js": "^1.5.0",
|
"@cityssm/bulma-webapp-js": "^1.5.0",
|
||||||
"@cityssm/date-diff": "^2.2.3",
|
"@cityssm/date-diff": "^2.2.3",
|
||||||
"@cityssm/dynamics-gp": "^0.4.0",
|
"@cityssm/dynamics-gp": "^0.4.1",
|
||||||
"@cityssm/expressjs-server-js": "^2.3.3",
|
"@cityssm/expressjs-server-js": "^2.3.3",
|
||||||
"@cityssm/ntfy-publish": "^0.2.2",
|
"@cityssm/ntfy-publish": "^0.2.2",
|
||||||
"@cityssm/pdf-puppeteer": "^2.0.0-beta.1",
|
"@cityssm/pdf-puppeteer": "^2.0.0-beta.1",
|
||||||
|
|
@ -523,11 +523,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@cityssm/dynamics-gp": {
|
"node_modules/@cityssm/dynamics-gp": {
|
||||||
"version": "0.4.0",
|
"version": "0.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/@cityssm/dynamics-gp/-/dynamics-gp-0.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/@cityssm/dynamics-gp/-/dynamics-gp-0.4.1.tgz",
|
||||||
"integrity": "sha512-bbgZxUYAOfN3xFigX501UvEaCfVZ0ReyagcN+ZcKTWtOGrMnUOKK850l+xRnYymfaaUQ2amp4Uj9O6gP+Bj3gQ==",
|
"integrity": "sha512-gj3zC7SMEZCLX1OihpxMH4zc6VYP+vkwkX8g8Yf5csJwVFq3l8PkKrCCC2WSaya/Cd9JdMacMl2m9XnT4TYPiA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cityssm/mssql-multi-pool": "^2.2.0",
|
"@cityssm/mssql-multi-pool": "^2.2.1",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"mssql": "^9.1.1",
|
"mssql": "^9.1.1",
|
||||||
"node-cache": "^5.1.2"
|
"node-cache": "^5.1.2"
|
||||||
|
|
@ -12929,11 +12929,11 @@
|
||||||
"integrity": "sha512-GmRXmBQxBPnt/oJ4V7iM1UszRzv/NjvfZDqVB0NdVZ8Mw+udT7G8+VZuo8pLBmiSMcijNYvJ/hV0AW2Vi5nDJA=="
|
"integrity": "sha512-GmRXmBQxBPnt/oJ4V7iM1UszRzv/NjvfZDqVB0NdVZ8Mw+udT7G8+VZuo8pLBmiSMcijNYvJ/hV0AW2Vi5nDJA=="
|
||||||
},
|
},
|
||||||
"@cityssm/dynamics-gp": {
|
"@cityssm/dynamics-gp": {
|
||||||
"version": "0.4.0",
|
"version": "0.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/@cityssm/dynamics-gp/-/dynamics-gp-0.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/@cityssm/dynamics-gp/-/dynamics-gp-0.4.1.tgz",
|
||||||
"integrity": "sha512-bbgZxUYAOfN3xFigX501UvEaCfVZ0ReyagcN+ZcKTWtOGrMnUOKK850l+xRnYymfaaUQ2amp4Uj9O6gP+Bj3gQ==",
|
"integrity": "sha512-gj3zC7SMEZCLX1OihpxMH4zc6VYP+vkwkX8g8Yf5csJwVFq3l8PkKrCCC2WSaya/Cd9JdMacMl2m9XnT4TYPiA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@cityssm/mssql-multi-pool": "^2.2.0",
|
"@cityssm/mssql-multi-pool": "^2.2.1",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"mssql": "^9.1.1",
|
"mssql": "^9.1.1",
|
||||||
"node-cache": "^5.1.2"
|
"node-cache": "^5.1.2"
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
"@cityssm/bulma-js": "^0.4.0",
|
"@cityssm/bulma-js": "^0.4.0",
|
||||||
"@cityssm/bulma-webapp-js": "^1.5.0",
|
"@cityssm/bulma-webapp-js": "^1.5.0",
|
||||||
"@cityssm/date-diff": "^2.2.3",
|
"@cityssm/date-diff": "^2.2.3",
|
||||||
"@cityssm/dynamics-gp": "^0.4.0",
|
"@cityssm/dynamics-gp": "^0.4.1",
|
||||||
"@cityssm/expressjs-server-js": "^2.3.3",
|
"@cityssm/expressjs-server-js": "^2.3.3",
|
||||||
"@cityssm/ntfy-publish": "^0.2.2",
|
"@cityssm/ntfy-publish": "^0.2.2",
|
||||||
"@cityssm/pdf-puppeteer": "^2.0.0-beta.1",
|
"@cityssm/pdf-puppeteer": "^2.0.0-beta.1",
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,8 @@ export interface Config {
|
||||||
integrationIsEnabled: boolean;
|
integrationIsEnabled: boolean;
|
||||||
mssqlConfig?: MSSQLConfig;
|
mssqlConfig?: MSSQLConfig;
|
||||||
lookupOrder?: DynamicsGPLookup[];
|
lookupOrder?: DynamicsGPLookup[];
|
||||||
|
accountCodes?: string[];
|
||||||
|
itemNumbers?: string[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,8 @@ export interface Config {
|
||||||
integrationIsEnabled: boolean
|
integrationIsEnabled: boolean
|
||||||
mssqlConfig?: MSSQLConfig
|
mssqlConfig?: MSSQLConfig
|
||||||
lookupOrder?: DynamicsGPLookup[]
|
lookupOrder?: DynamicsGPLookup[]
|
||||||
|
accountCodes?: string[]
|
||||||
|
itemNumbers?: string[]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue