filter diamond invoices by trial balance code
parent
18207de4cb
commit
d74598c877
|
|
@ -60,6 +60,6 @@ config.settings.workOrders.workOrderMilestoneDateRecentBeforeDays = 7;
|
||||||
config.settings.workOrders.workOrderMilestoneDateRecentAfterDays = 30;
|
config.settings.workOrders.workOrderMilestoneDateRecentAfterDays = 30;
|
||||||
config.settings.dynamicsGP = {
|
config.settings.dynamicsGP = {
|
||||||
integrationIsEnabled: true,
|
integrationIsEnabled: true,
|
||||||
lookupOrder: ['diamond/cashReceipt', 'invoice']
|
lookupOrder: ['diamond/cashReceipt', 'diamond/extendedInvoice']
|
||||||
};
|
};
|
||||||
export default config;
|
export default config;
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ config.settings.workOrders.workOrderMilestoneDateRecentAfterDays = 30
|
||||||
|
|
||||||
config.settings.dynamicsGP = {
|
config.settings.dynamicsGP = {
|
||||||
integrationIsEnabled: true,
|
integrationIsEnabled: true,
|
||||||
lookupOrder: ['diamond/cashReceipt', 'invoice']
|
lookupOrder: ['diamond/cashReceipt', 'diamond/extendedInvoice']
|
||||||
}
|
}
|
||||||
|
|
||||||
export default config
|
export default config
|
||||||
|
|
|
||||||
|
|
@ -54,4 +54,5 @@ export declare function getProperty(propertyName: 'settings.dynamicsGP.mssqlConf
|
||||||
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.accountCodes'): string[];
|
||||||
export declare function getProperty(propertyName: 'settings.dynamicsGP.itemNumbers'): string[];
|
export declare function getProperty(propertyName: 'settings.dynamicsGP.itemNumbers'): string[];
|
||||||
|
export declare function getProperty(propertyName: 'settings.dynamicsGP.trialBalanceCodes'): string[];
|
||||||
export declare const keepAliveMillis: number;
|
export declare const keepAliveMillis: number;
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ 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.accountCodes', []);
|
||||||
configFallbackValues.set('settings.dynamicsGP.itemNumbers', []);
|
configFallbackValues.set('settings.dynamicsGP.itemNumbers', []);
|
||||||
|
configFallbackValues.set('settings.dynamicsGP.trialBalanceCodes', []);
|
||||||
export function getProperty(propertyName) {
|
export function getProperty(propertyName) {
|
||||||
const propertyNameSplit = propertyName.split('.');
|
const propertyNameSplit = propertyName.split('.');
|
||||||
let currentObject = config;
|
let currentObject = config;
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,7 @@ 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.accountCodes', [])
|
||||||
configFallbackValues.set('settings.dynamicsGP.itemNumbers', [])
|
configFallbackValues.set('settings.dynamicsGP.itemNumbers', [])
|
||||||
|
configFallbackValues.set('settings.dynamicsGP.trialBalanceCodes', [])
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up function overloads
|
* Set up function overloads
|
||||||
|
|
@ -239,6 +240,10 @@ export function getProperty(
|
||||||
propertyName: 'settings.dynamicsGP.itemNumbers'
|
propertyName: 'settings.dynamicsGP.itemNumbers'
|
||||||
): string[]
|
): string[]
|
||||||
|
|
||||||
|
export function getProperty(
|
||||||
|
propertyName: 'settings.dynamicsGP.trialBalanceCodes'
|
||||||
|
): string[]
|
||||||
|
|
||||||
export function getProperty(propertyName: string): unknown {
|
export function getProperty(propertyName: string): unknown {
|
||||||
const propertyNameSplit = propertyName.split('.')
|
const propertyNameSplit = propertyName.split('.')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,17 @@ function filterInvoice(invoice) {
|
||||||
}
|
}
|
||||||
return invoice;
|
return invoice;
|
||||||
}
|
}
|
||||||
|
function filterExtendedInvoice(invoice) {
|
||||||
|
if (filterInvoice(invoice) === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const trialBalanceCodes = configFunctions.getProperty('settings.dynamicsGP.trialBalanceCodes');
|
||||||
|
if (trialBalanceCodes.length > 0 &&
|
||||||
|
trialBalanceCodes.includes(invoice.trialBalanceCode ?? '')) {
|
||||||
|
return invoice;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
async function _getDynamicsGPDocument(documentNumber, lookupType) {
|
async function _getDynamicsGPDocument(documentNumber, lookupType) {
|
||||||
let document;
|
let document;
|
||||||
switch (lookupType) {
|
switch (lookupType) {
|
||||||
|
|
@ -78,6 +89,28 @@ async function _getDynamicsGPDocument(documentNumber, lookupType) {
|
||||||
documentTotal: receipt.total
|
documentTotal: receipt.total
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'diamond/extendedInvoice': {
|
||||||
|
let invoice = await diamond.getDiamondExtendedGPInvoice(documentNumber);
|
||||||
|
if (invoice !== undefined) {
|
||||||
|
invoice = filterExtendedInvoice(invoice);
|
||||||
|
}
|
||||||
|
if (invoice !== undefined) {
|
||||||
|
document = {
|
||||||
|
documentType: 'Invoice',
|
||||||
|
documentNumber: invoice.invoiceNumber,
|
||||||
|
documentDate: invoice.documentDate,
|
||||||
|
documentDescription: [
|
||||||
|
invoice.comment1,
|
||||||
|
invoice.comment2,
|
||||||
|
invoice.comment3,
|
||||||
|
invoice.comment4
|
||||||
|
],
|
||||||
|
documentTotal: invoice.documentAmount
|
||||||
|
};
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return document;
|
return document;
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,12 @@ 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 {
|
||||||
import { type GPInvoice } from '@cityssm/dynamics-gp/gp/types.js'
|
DiamondExtendedGPInvoice,
|
||||||
|
DiamondCashReceipt
|
||||||
|
} from '@cityssm/dynamics-gp/diamond/types'
|
||||||
|
|
||||||
|
import type { GPInvoice } from '@cityssm/dynamics-gp/gp/types'
|
||||||
|
|
||||||
if (configFunctions.getProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
if (configFunctions.getProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
||||||
gp.setMSSQLConfig(
|
gp.setMSSQLConfig(
|
||||||
|
|
@ -64,6 +68,27 @@ function filterInvoice(invoice: GPInvoice): GPInvoice | undefined {
|
||||||
return invoice
|
return invoice
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function filterExtendedInvoice(
|
||||||
|
invoice: DiamondExtendedGPInvoice
|
||||||
|
): DiamondExtendedGPInvoice | undefined {
|
||||||
|
if (filterInvoice(invoice) === undefined) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
const trialBalanceCodes = configFunctions.getProperty(
|
||||||
|
'settings.dynamicsGP.trialBalanceCodes'
|
||||||
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
trialBalanceCodes.length > 0 &&
|
||||||
|
trialBalanceCodes.includes(invoice.trialBalanceCode ?? '')
|
||||||
|
) {
|
||||||
|
return invoice
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
async function _getDynamicsGPDocument(
|
async function _getDynamicsGPDocument(
|
||||||
documentNumber: string,
|
documentNumber: string,
|
||||||
lookupType: DynamicsGPLookup
|
lookupType: DynamicsGPLookup
|
||||||
|
|
@ -118,6 +143,32 @@ async function _getDynamicsGPDocument(
|
||||||
documentTotal: receipt.total
|
documentTotal: receipt.total
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case 'diamond/extendedInvoice': {
|
||||||
|
let invoice = await diamond.getDiamondExtendedGPInvoice(documentNumber)
|
||||||
|
|
||||||
|
if (invoice !== undefined) {
|
||||||
|
invoice = filterExtendedInvoice(invoice)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (invoice !== undefined) {
|
||||||
|
document = {
|
||||||
|
documentType: 'Invoice',
|
||||||
|
documentNumber: invoice.invoiceNumber,
|
||||||
|
documentDate: invoice.documentDate,
|
||||||
|
documentDescription: [
|
||||||
|
invoice.comment1,
|
||||||
|
invoice.comment2,
|
||||||
|
invoice.comment3,
|
||||||
|
invoice.comment4
|
||||||
|
],
|
||||||
|
documentTotal: invoice.documentAmount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,10 +67,11 @@ export interface Config {
|
||||||
lookupOrder?: DynamicsGPLookup[];
|
lookupOrder?: DynamicsGPLookup[];
|
||||||
accountCodes?: string[];
|
accountCodes?: string[];
|
||||||
itemNumbers?: string[];
|
itemNumbers?: string[];
|
||||||
|
trialBalanceCodes?: string[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
export type DynamicsGPLookup = 'diamond/cashReceipt' | 'invoice';
|
export type DynamicsGPLookup = 'diamond/cashReceipt' | 'diamond/extendedInvoice' | 'invoice';
|
||||||
interface ConfigApplication {
|
interface ConfigApplication {
|
||||||
applicationName?: string;
|
applicationName?: string;
|
||||||
backgroundURL?: string;
|
backgroundURL?: string;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
// eslint-disable-next-line node/no-extraneous-import
|
||||||
import type { config as MSSQLConfig } from 'mssql'
|
import type { config as MSSQLConfig } from 'mssql'
|
||||||
|
|
||||||
export interface Config {
|
export interface Config {
|
||||||
|
|
@ -68,11 +69,12 @@ export interface Config {
|
||||||
lookupOrder?: DynamicsGPLookup[]
|
lookupOrder?: DynamicsGPLookup[]
|
||||||
accountCodes?: string[]
|
accountCodes?: string[]
|
||||||
itemNumbers?: string[]
|
itemNumbers?: string[]
|
||||||
|
trialBalanceCodes?: string[]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DynamicsGPLookup = 'diamond/cashReceipt' | 'invoice'
|
export type DynamicsGPLookup = 'diamond/cashReceipt' | 'diamond/extendedInvoice' | 'invoice'
|
||||||
|
|
||||||
interface ConfigApplication {
|
interface ConfigApplication {
|
||||||
applicationName?: string
|
applicationName?: string
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue