gp connection error catch
parent
4f6fc87e05
commit
96eb7f36dc
|
|
@ -2,7 +2,7 @@ import { dateIntegerToString, timeIntegerToString } from '@cityssm/utils-datetim
|
||||||
import sqlite from 'better-sqlite3';
|
import sqlite from 'better-sqlite3';
|
||||||
import { getConfigProperty } from '../helpers/config.helpers.js';
|
import { getConfigProperty } from '../helpers/config.helpers.js';
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||||
import { getDynamicsGPDocument } from '../helpers/functions.dynamicsGP.js';
|
import { getDynamicsGPDocument } from '../helpers/dynamicsGp.helpers.js';
|
||||||
export default async function GetContractTransactions(contractId, options, connectedDatabase) {
|
export default async function GetContractTransactions(contractId, options, connectedDatabase) {
|
||||||
const database = connectedDatabase ?? sqlite(sunriseDB, { readonly: true });
|
const database = connectedDatabase ?? sqlite(sunriseDB, { readonly: true });
|
||||||
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
database.function('userFn_dateIntegerToString', dateIntegerToString);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import sqlite from 'better-sqlite3'
|
||||||
|
|
||||||
import { getConfigProperty } from '../helpers/config.helpers.js'
|
import { getConfigProperty } from '../helpers/config.helpers.js'
|
||||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||||
import { getDynamicsGPDocument } from '../helpers/functions.dynamicsGP.js'
|
import { getDynamicsGPDocument } from '../helpers/dynamicsGp.helpers.js'
|
||||||
import type { ContractTransaction } from '../types/record.types.js'
|
import type { ContractTransaction } from '../types/record.types.js'
|
||||||
|
|
||||||
export default async function GetContractTransactions(
|
export default async function GetContractTransactions(
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* eslint-disable @eslint-community/eslint-comments/disable-enable-pair, unicorn/filename-case */
|
/* eslint-disable @eslint-community/eslint-comments/disable-enable-pair, unicorn/filename-case */
|
||||||
import { getDynamicsGPDocument } from '../../helpers/functions.dynamicsGP.js';
|
import { getDynamicsGPDocument } from '../../helpers/dynamicsGp.helpers.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const externalReceiptNumber = request.body.externalReceiptNumber;
|
const externalReceiptNumber = request.body.externalReceiptNumber;
|
||||||
const dynamicsGPDocument = await getDynamicsGPDocument(externalReceiptNumber);
|
const dynamicsGPDocument = await getDynamicsGPDocument(externalReceiptNumber);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
import { getDynamicsGPDocument } from '../../helpers/functions.dynamicsGP.js'
|
import { getDynamicsGPDocument } from '../../helpers/dynamicsGp.helpers.js'
|
||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: Request<unknown, unknown, { externalReceiptNumber: string }>,
|
request: Request<unknown, unknown, { externalReceiptNumber: string }>,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
import { DynamicsGP } from '@cityssm/dynamics-gp';
|
import { DynamicsGP } from '@cityssm/dynamics-gp';
|
||||||
|
import Debug from 'debug';
|
||||||
|
import { DEBUG_NAMESPACE } from '../debug.config.js';
|
||||||
import { getConfigProperty } from './config.helpers.js';
|
import { getConfigProperty } from './config.helpers.js';
|
||||||
|
const debug = Debug(`${DEBUG_NAMESPACE}:dynamicsGP.helpers:${process.pid}`);
|
||||||
let gp;
|
let gp;
|
||||||
if (getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
if (getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
||||||
gp = new DynamicsGP(getConfigProperty('settings.dynamicsGP.mssqlConfig'));
|
gp = new DynamicsGP(getConfigProperty('settings.dynamicsGP.mssqlConfig'));
|
||||||
|
|
@ -10,7 +13,13 @@ export async function getDynamicsGPDocument(documentNumber) {
|
||||||
}
|
}
|
||||||
let document;
|
let document;
|
||||||
for (const lookupType of getConfigProperty('settings.dynamicsGP.lookupOrder')) {
|
for (const lookupType of getConfigProperty('settings.dynamicsGP.lookupOrder')) {
|
||||||
|
try {
|
||||||
document = await _getDynamicsGPDocument(documentNumber, lookupType);
|
document = await _getDynamicsGPDocument(documentNumber, lookupType);
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
debug(`Error fetching Dynamics GP document for ${lookupType}:`);
|
||||||
|
debug(error);
|
||||||
|
}
|
||||||
if (document !== undefined) {
|
if (document !== undefined) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -4,12 +4,16 @@ import {
|
||||||
type GPInvoice,
|
type GPInvoice,
|
||||||
DynamicsGP
|
DynamicsGP
|
||||||
} from '@cityssm/dynamics-gp'
|
} from '@cityssm/dynamics-gp'
|
||||||
|
import Debug from 'debug'
|
||||||
|
|
||||||
|
import { DEBUG_NAMESPACE } from '../debug.config.js'
|
||||||
import type { DynamicsGPLookup } from '../types/config.types.js'
|
import type { DynamicsGPLookup } from '../types/config.types.js'
|
||||||
import type { DynamicsGPDocument } from '../types/record.types.js'
|
import type { DynamicsGPDocument } from '../types/record.types.js'
|
||||||
|
|
||||||
import { getConfigProperty } from './config.helpers.js'
|
import { getConfigProperty } from './config.helpers.js'
|
||||||
|
|
||||||
|
const debug = Debug(`${DEBUG_NAMESPACE}:dynamicsGP.helpers:${process.pid}`)
|
||||||
|
|
||||||
let gp: DynamicsGP
|
let gp: DynamicsGP
|
||||||
|
|
||||||
if (getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
if (getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) {
|
||||||
|
|
@ -28,7 +32,12 @@ export async function getDynamicsGPDocument(
|
||||||
for (const lookupType of getConfigProperty(
|
for (const lookupType of getConfigProperty(
|
||||||
'settings.dynamicsGP.lookupOrder'
|
'settings.dynamicsGP.lookupOrder'
|
||||||
)) {
|
)) {
|
||||||
|
try {
|
||||||
document = await _getDynamicsGPDocument(documentNumber, lookupType)
|
document = await _getDynamicsGPDocument(documentNumber, lookupType)
|
||||||
|
} catch (error) {
|
||||||
|
debug(`Error fetching Dynamics GP document for ${lookupType}:`)
|
||||||
|
debug(error)
|
||||||
|
}
|
||||||
|
|
||||||
if (document !== undefined) {
|
if (document !== undefined) {
|
||||||
break
|
break
|
||||||
Loading…
Reference in New Issue