-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- get current inventory from dynamics gp for validation
- Loading branch information
Showing
45 changed files
with
771 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import type { ConfigFtpPath } from '../types/configTypes.js'; | ||
import type { ConfigFtpPath } from '../types/configHelperTypes.js'; | ||
export declare const tempFolderPath: string; | ||
export declare function ensureTempFolderExists(): Promise<void>; | ||
export declare function downloadFilesToTemp<S extends string>(ftpPath: ConfigFtpPath<S>): Promise<Array<`${string}${S}`>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type { GPItemWithQuantity } from '@cityssm/dynamics-gp'; | ||
import type { Spec } from 'node-schedule'; | ||
import type { ConfigFileSuffixXlsx, ConfigScheduledFtpReport } from '../../types/configHelperTypes.js'; | ||
export interface ConfigItemValidationDynamicsGP { | ||
source: 'dynamicsGP'; | ||
schedule?: Spec; | ||
gpLocationCodesToFasterStorerooms: Record<string, string>; | ||
gpItemFilter?: (item: GPItemWithQuantity) => boolean; | ||
} | ||
export interface ConfigItemValidationFaster { | ||
source: 'faster'; | ||
/** W200 - Inventory Report */ | ||
w200?: ConfigScheduledFtpReport<ConfigFileSuffixXlsx>; | ||
} | ||
export interface ConfigModuleInventoryScanner { | ||
scannerIpAddressRegex?: RegExp; | ||
workOrders?: { | ||
acceptNotValidated?: boolean; | ||
fasterRegex?: RegExp; | ||
acceptWorkTech?: boolean; | ||
workTechRegex?: RegExp; | ||
}; | ||
items?: { | ||
acceptNotValidated?: boolean; | ||
itemNumberRegex?: RegExp; | ||
validation?: ConfigItemValidationDynamicsGP | ConfigItemValidationFaster; | ||
}; | ||
quantities?: { | ||
acceptOverages?: boolean; | ||
acceptNegatives?: boolean; | ||
}; | ||
reports?: { | ||
/** | ||
* W311 - Active Work Orders by Shop | ||
*/ | ||
w311?: ConfigScheduledFtpReport<ConfigFileSuffixXlsx>; | ||
/** | ||
* W604 - Integration Log Viewer | ||
*/ | ||
w604?: ConfigScheduledFtpReport<ConfigFileSuffixXlsx>; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import type { GPItemWithQuantity } from '@cityssm/dynamics-gp' | ||
import type { Spec } from 'node-schedule' | ||
|
||
import type { | ||
ConfigFileSuffixXlsx, | ||
ConfigScheduledFtpReport | ||
} from '../../types/configHelperTypes.js' | ||
|
||
export interface ConfigItemValidationDynamicsGP { | ||
source: 'dynamicsGP' | ||
schedule?: Spec | ||
gpLocationCodesToFasterStorerooms: Record<string, string> | ||
gpItemFilter?: (item: GPItemWithQuantity) => boolean | ||
} | ||
|
||
export interface ConfigItemValidationFaster { | ||
source: 'faster' | ||
|
||
/** W200 - Inventory Report */ | ||
w200?: ConfigScheduledFtpReport<ConfigFileSuffixXlsx> | ||
} | ||
|
||
export interface ConfigModuleInventoryScanner { | ||
scannerIpAddressRegex?: RegExp | ||
|
||
workOrders?: { | ||
acceptNotValidated?: boolean | ||
fasterRegex?: RegExp | ||
acceptWorkTech?: boolean | ||
workTechRegex?: RegExp | ||
} | ||
|
||
items?: { | ||
acceptNotValidated?: boolean | ||
itemNumberRegex?: RegExp | ||
validation?: ConfigItemValidationDynamicsGP | ConfigItemValidationFaster | ||
} | ||
|
||
quantities?: { | ||
acceptOverages?: boolean | ||
acceptNegatives?: boolean | ||
} | ||
|
||
reports?: { | ||
/** | ||
* W311 - Active Work Orders by Shop | ||
*/ | ||
w311?: ConfigScheduledFtpReport<ConfigFileSuffixXlsx> | ||
|
||
/** | ||
* W604 - Integration Log Viewer | ||
*/ | ||
w604?: ConfigScheduledFtpReport<ConfigFileSuffixXlsx> | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
modules/inventoryScanner/database/createOrUpdateItemValidation.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import type { ItemValidationRecord } from '../types.js'; | ||
export default function createOrUpdateItemValidation(validationRecord: ItemValidationRecord, timeMillis: number): void; |
28 changes: 28 additions & 0 deletions
28
modules/inventoryScanner/database/createOrUpdateItemValidation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import sqlite from 'better-sqlite3'; | ||
import getItemValidation from './getItemValidation.js'; | ||
import { databasePath } from './helpers.database.js'; | ||
export default function createOrUpdateItemValidation(validationRecord, timeMillis) { | ||
const database = sqlite(databasePath); | ||
const databaseRecord = getItemValidation(validationRecord.itemStoreroom, validationRecord.itemNumber, true, database); | ||
if (databaseRecord === undefined) { | ||
database | ||
.prepare(`insert into ItemValidationRecords ( | ||
itemStoreroom, itemNumber, itemDescription, availableQuantity, unitPrice, | ||
recordCreate_timeMillis, recordUpdate_timeMillis) | ||
values (?, ?, ?, ?, ?, ?, ?)`) | ||
.run(validationRecord.itemStoreroom, validationRecord.itemNumber, validationRecord.itemDescription, validationRecord.availableQuantity, validationRecord.unitPrice, timeMillis, timeMillis); | ||
} | ||
else { | ||
database | ||
.prepare(`update ItemValidationRecords | ||
set itemDescription = ?, | ||
availableQuantity = ?, | ||
unitPrice = ?, | ||
recordUpdate_timeMillis = ?, | ||
recordDelete_timeMillis = null | ||
where itemStoreroom = ? | ||
and itemNumber = ?`) | ||
.run(validationRecord.itemDescription, validationRecord.availableQuantity, validationRecord.unitPrice, timeMillis, validationRecord.itemStoreroom, validationRecord.itemNumber); | ||
} | ||
database.close(); | ||
} |
61 changes: 61 additions & 0 deletions
61
modules/inventoryScanner/database/createOrUpdateItemValidation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import sqlite from 'better-sqlite3' | ||
|
||
import type { ItemValidationRecord } from '../types.js' | ||
|
||
import getItemValidation from './getItemValidation.js' | ||
import { databasePath } from './helpers.database.js' | ||
|
||
export default function createOrUpdateItemValidation( | ||
validationRecord: ItemValidationRecord, | ||
timeMillis: number | ||
): void { | ||
const database = sqlite(databasePath) | ||
|
||
const databaseRecord = getItemValidation( | ||
validationRecord.itemStoreroom, | ||
validationRecord.itemNumber, | ||
true, | ||
database | ||
) | ||
|
||
if (databaseRecord === undefined) { | ||
database | ||
.prepare( | ||
`insert into ItemValidationRecords ( | ||
itemStoreroom, itemNumber, itemDescription, availableQuantity, unitPrice, | ||
recordCreate_timeMillis, recordUpdate_timeMillis) | ||
values (?, ?, ?, ?, ?, ?, ?)` | ||
) | ||
.run( | ||
validationRecord.itemStoreroom, | ||
validationRecord.itemNumber, | ||
validationRecord.itemDescription, | ||
validationRecord.availableQuantity, | ||
validationRecord.unitPrice, | ||
timeMillis, | ||
timeMillis | ||
) | ||
} else { | ||
database | ||
.prepare( | ||
`update ItemValidationRecords | ||
set itemDescription = ?, | ||
availableQuantity = ?, | ||
unitPrice = ?, | ||
recordUpdate_timeMillis = ?, | ||
recordDelete_timeMillis = null | ||
where itemStoreroom = ? | ||
and itemNumber = ?` | ||
) | ||
.run( | ||
validationRecord.itemDescription, | ||
validationRecord.availableQuantity, | ||
validationRecord.unitPrice, | ||
timeMillis, | ||
validationRecord.itemStoreroom, | ||
validationRecord.itemNumber | ||
) | ||
} | ||
|
||
database.close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default function deleteItemValidation(minUpdateTimeMillis: number): void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import sqlite from 'better-sqlite3'; | ||
import { databasePath } from './helpers.database.js'; | ||
export default function deleteItemValidation(minUpdateTimeMillis) { | ||
const database = sqlite(databasePath); | ||
database | ||
.prepare(`update ItemValidationRecords | ||
set recordDelete_timeMillis = ? | ||
where recordUpdate_timeMillis < ?`) | ||
.run(Date.now(), minUpdateTimeMillis); | ||
database | ||
.prepare(`delete from ItemValidationRecords | ||
where recordDelete_timeMillis is not null | ||
and itemNumber not in (select itemNumber from InventoryScannerRecords)`) | ||
.run(); | ||
database.close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import sqlite from 'better-sqlite3' | ||
|
||
import { databasePath } from './helpers.database.js' | ||
|
||
export default function deleteItemValidation( | ||
minUpdateTimeMillis: number | ||
): void { | ||
const database = sqlite(databasePath) | ||
|
||
database | ||
.prepare( | ||
`update ItemValidationRecords | ||
set recordDelete_timeMillis = ? | ||
where recordUpdate_timeMillis < ?` | ||
) | ||
.run(Date.now(), minUpdateTimeMillis) | ||
|
||
database | ||
.prepare( | ||
`delete from ItemValidationRecords | ||
where recordDelete_timeMillis is not null | ||
and itemNumber not in (select itemNumber from InventoryScannerRecords)` | ||
) | ||
.run() | ||
|
||
database.close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import sqlite from 'better-sqlite3'; | ||
import type { ItemValidationRecord } from '../types.js'; | ||
export default function getItemValidation(itemStoreroom: string, itemNumber: string, includeDeleted: boolean, connectedDatabase?: sqlite.Database): ItemValidationRecord | undefined; |
Oops, something went wrong.