-
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.
update faster inventory from dynamics gp
- Loading branch information
Showing
16 changed files
with
482 additions
and
44 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
14 changes: 14 additions & 0 deletions
14
modules/integrityChecker/database/getDynamicsGpInventoryItemsToUpdateInFaster.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,14 @@ | ||
interface DynamicsGpInventoryItemToUpdate { | ||
itemNumber: string; | ||
storeroom: string; | ||
fasterItemName: string | null; | ||
fasterBinLocation: string | null; | ||
fasterQuantityInStock: number | null; | ||
gpItemName: string | null; | ||
gpBinLocation: string | null; | ||
gpAlternateLocation: string | null; | ||
gpCurrentCost: number | null; | ||
gpQuantityInStock: number | null; | ||
} | ||
export default function getDynamicsGpInventoryItemsToUpdateInFaster(): DynamicsGpInventoryItemToUpdate[]; | ||
export {}; |
36 changes: 36 additions & 0 deletions
36
modules/integrityChecker/database/getDynamicsGpInventoryItemsToUpdateInFaster.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,36 @@ | ||
import fasterInventoryItemConstants from '@cityssm/faster-constants/inventory/items'; | ||
import sqlite from 'better-sqlite3'; | ||
import { databasePath } from './helpers.database.js'; | ||
export default function getDynamicsGpInventoryItemsToUpdateInFaster() { | ||
const database = sqlite(databasePath, { | ||
readonly: true | ||
}); | ||
const result = database | ||
.prepare(`select | ||
ifnull(f.itemNumber, gp.itemNumber) as itemNumber, | ||
ifnull(f.storeroom, gp.fasterStoreroom) as storeroom, | ||
f.itemName as fasterItemName, | ||
case when f.binLocation = 'Undefined' then '' else f.binLocation end as fasterBinLocation, | ||
f.quantityInStock as fasterQuantityInStock, | ||
gp.itemDescription as gpItemName, | ||
gp.binNumber as gpBinLocation, | ||
gp.itemShortName as gpAlternateLocation, | ||
gp.currentCost as gpCurrentCost, | ||
gp.quantityOnHand as gpQuantityInStock | ||
from FasterInventoryItems f | ||
full join DynamicsGpInventoryItems gp | ||
on f.itemNumber = gp.itemNumber and f.storeroom = gp.fasterStoreroom | ||
where (f.itemNumber is null and gp.quantityOnHand > 0) | ||
or gp.itemNumber is null | ||
or f.itemName <> substring(gp.itemDescription, 1, ${fasterInventoryItemConstants.itemName.maxLength}) | ||
or case when f.binLocation = 'Undefined' then '' else f.binLocation end <> substr(gp.binNumber, 1, ${fasterInventoryItemConstants.binLocation.maxLength}) | ||
order by gpItemName desc`) | ||
.all(); | ||
database.close(); | ||
return result; | ||
} |
58 changes: 58 additions & 0 deletions
58
modules/integrityChecker/database/getDynamicsGpInventoryItemsToUpdateInFaster.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,58 @@ | ||
import fasterInventoryItemConstants from '@cityssm/faster-constants/inventory/items' | ||
import sqlite from 'better-sqlite3' | ||
|
||
import { databasePath } from './helpers.database.js' | ||
|
||
interface DynamicsGpInventoryItemToUpdate { | ||
itemNumber: string | ||
storeroom: string | ||
|
||
fasterItemName: string | null | ||
fasterBinLocation: string | null | ||
fasterQuantityInStock: number | null | ||
|
||
gpItemName: string | null | ||
gpBinLocation: string | null | ||
gpAlternateLocation: string | null | ||
gpCurrentCost: number | null | ||
gpQuantityInStock: number | null | ||
} | ||
|
||
export default function getDynamicsGpInventoryItemsToUpdateInFaster(): DynamicsGpInventoryItemToUpdate[] { | ||
const database = sqlite(databasePath, { | ||
readonly: true | ||
}) | ||
|
||
const result = database | ||
.prepare( | ||
`select | ||
ifnull(f.itemNumber, gp.itemNumber) as itemNumber, | ||
ifnull(f.storeroom, gp.fasterStoreroom) as storeroom, | ||
f.itemName as fasterItemName, | ||
case when f.binLocation = 'Undefined' then '' else f.binLocation end as fasterBinLocation, | ||
f.quantityInStock as fasterQuantityInStock, | ||
gp.itemDescription as gpItemName, | ||
gp.binNumber as gpBinLocation, | ||
gp.itemShortName as gpAlternateLocation, | ||
gp.currentCost as gpCurrentCost, | ||
gp.quantityOnHand as gpQuantityInStock | ||
from FasterInventoryItems f | ||
full join DynamicsGpInventoryItems gp | ||
on f.itemNumber = gp.itemNumber and f.storeroom = gp.fasterStoreroom | ||
where (f.itemNumber is null and gp.quantityOnHand > 0) | ||
or gp.itemNumber is null | ||
or f.itemName <> substring(gp.itemDescription, 1, ${fasterInventoryItemConstants.itemName.maxLength}) | ||
or case when f.binLocation = 'Undefined' then '' else f.binLocation end <> substr(gp.binNumber, 1, ${fasterInventoryItemConstants.binLocation.maxLength}) | ||
order by gpItemName desc` | ||
) | ||
.all() as DynamicsGpInventoryItemToUpdate[] | ||
|
||
database.close() | ||
|
||
return result | ||
} |
4 changes: 2 additions & 2 deletions
4
modules/integrityChecker/helpers/inventoryValidation/dynamicsGp.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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
import type sqlite from 'better-sqlite3'; | ||
export declare function refreshDynamicsGpInventory(database: sqlite.Database): Promise<void>; | ||
export declare function refreshDynamicsGpInventory(): Promise<boolean>; | ||
export declare function updateInventoryInFaster(): Promise<void>; |
Oops, something went wrong.