-
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.
- Loading branch information
Showing
27 changed files
with
739 additions
and
68 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
type ScannerRecordUpdateField = 'repairId' | 'itemStoreroom' | 'unitPrice'; | ||
export declare function updateScannerRecord(recordId: number, fieldToUpdate: ScannerRecordUpdateField, fieldValue: string | number, updateUserName: string): boolean; | ||
export {}; | ||
export interface UpdateScannerRecordForm { | ||
recordId: string; | ||
workOrderNumber: string; | ||
repairId: string; | ||
itemNumber: string; | ||
quantity: string; | ||
unitPrice: string; | ||
} | ||
export declare function updateScannerRecord(recordForm: UpdateScannerRecordForm, updateUser: FasterWebHelperSessionUser): boolean; |
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,16 +1,20 @@ | ||
import sqlite from 'better-sqlite3'; | ||
import { databasePath } from './helpers.database.js'; | ||
export function updateScannerRecord(recordId, fieldToUpdate, fieldValue, updateUserName) { | ||
export function updateScannerRecord(recordForm, updateUser) { | ||
const database = sqlite(databasePath); | ||
const result = database | ||
.prepare(`update InventoryScannerRecords | ||
set ${fieldToUpdate} = ?, | ||
set workOrderNumber = ?, | ||
repairId = ?, | ||
itemNumber = ?, | ||
quantity = ?, | ||
unitPrice = ?, | ||
recordUpdate_userName = ?, | ||
recordUpdate_timeMillis = ? | ||
where recordId = ? | ||
and recordDelete_timeMillis is null | ||
and recordSync_timeMillis is null`) | ||
.run(fieldValue, updateUserName, Date.now(), recordId); | ||
.run(recordForm.workOrderNumber, recordForm.repairId === '' ? undefined : recordForm.repairId, recordForm.itemNumber, recordForm.quantity, recordForm.unitPrice === '' ? undefined : recordForm.unitPrice, updateUser.userName, Date.now(), recordForm.recordId); | ||
database.close(); | ||
return result.changes > 0; | ||
} |
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
3 changes: 3 additions & 0 deletions
3
modules/inventoryScanner/database/updateScannerRecordField.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,3 @@ | ||
type ScannerRecordUpdateField = 'repairId' | 'itemStoreroom' | 'unitPrice'; | ||
export declare function updateScannerRecordField(recordId: number, fieldToUpdate: ScannerRecordUpdateField, fieldValue: string | number, updateUserName: string): boolean; | ||
export {}; |
16 changes: 16 additions & 0 deletions
16
modules/inventoryScanner/database/updateScannerRecordField.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,16 @@ | ||
import sqlite from 'better-sqlite3'; | ||
import { databasePath } from './helpers.database.js'; | ||
export function updateScannerRecordField(recordId, fieldToUpdate, fieldValue, updateUserName) { | ||
const database = sqlite(databasePath); | ||
const result = database | ||
.prepare(`update InventoryScannerRecords | ||
set ${fieldToUpdate} = ?, | ||
recordUpdate_userName = ?, | ||
recordUpdate_timeMillis = ? | ||
where recordId = ? | ||
and recordDelete_timeMillis is null | ||
and recordSync_timeMillis is null`) | ||
.run(fieldValue, updateUserName, Date.now(), recordId); | ||
database.close(); | ||
return result.changes > 0; | ||
} |
30 changes: 30 additions & 0 deletions
30
modules/inventoryScanner/database/updateScannerRecordField.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,30 @@ | ||
import sqlite from 'better-sqlite3' | ||
|
||
import { databasePath } from './helpers.database.js' | ||
|
||
type ScannerRecordUpdateField = 'repairId' | 'itemStoreroom' | 'unitPrice' | ||
|
||
export function updateScannerRecordField( | ||
recordId: number, | ||
fieldToUpdate: ScannerRecordUpdateField, | ||
fieldValue: string | number, | ||
updateUserName: string | ||
): boolean { | ||
const database = sqlite(databasePath) | ||
|
||
const result = database | ||
.prepare( | ||
`update InventoryScannerRecords | ||
set ${fieldToUpdate} = ?, | ||
recordUpdate_userName = ?, | ||
recordUpdate_timeMillis = ? | ||
where recordId = ? | ||
and recordDelete_timeMillis is null | ||
and recordSync_timeMillis is null` | ||
) | ||
.run(fieldValue, updateUserName, Date.now(), recordId) | ||
|
||
database.close() | ||
|
||
return result.changes > 0 | ||
} |
6 changes: 6 additions & 0 deletions
6
modules/inventoryScanner/handlers/post-admin/doGetRepairRecords.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,6 @@ | ||
import type { Request, Response } from 'express'; | ||
interface DoGetRepairIdsForm { | ||
workOrderNumber: string; | ||
} | ||
export default function handler(request: Request<unknown, unknown, DoGetRepairIdsForm>, response: Response): void; | ||
export {}; |
7 changes: 7 additions & 0 deletions
7
modules/inventoryScanner/handlers/post-admin/doGetRepairRecords.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,7 @@ | ||
import getWorkOrderValidationRecords from '../../database/getWorkOrderValidationRecords.js'; | ||
import { getWorkOrderTypeFromWorkOrderNumber } from '../../helpers/workOrders.js'; | ||
export default function handler(request, response) { | ||
const workOrderType = getWorkOrderTypeFromWorkOrderNumber(request.body.workOrderNumber); | ||
const records = getWorkOrderValidationRecords(request.body.workOrderNumber, workOrderType); | ||
response.json({ records }); | ||
} |
24 changes: 24 additions & 0 deletions
24
modules/inventoryScanner/handlers/post-admin/doGetRepairRecords.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,24 @@ | ||
import type { Request, Response } from 'express' | ||
|
||
import getWorkOrderValidationRecords from '../../database/getWorkOrderValidationRecords.js' | ||
import { getWorkOrderTypeFromWorkOrderNumber } from '../../helpers/workOrders.js' | ||
|
||
interface DoGetRepairIdsForm { | ||
workOrderNumber: string | ||
} | ||
|
||
export default function handler( | ||
request: Request<unknown, unknown, DoGetRepairIdsForm>, | ||
response: Response | ||
): void { | ||
const workOrderType = getWorkOrderTypeFromWorkOrderNumber( | ||
request.body.workOrderNumber | ||
) | ||
|
||
const records = getWorkOrderValidationRecords( | ||
request.body.workOrderNumber, | ||
workOrderType | ||
) | ||
|
||
response.json({ records }) | ||
} |
3 changes: 3 additions & 0 deletions
3
modules/inventoryScanner/handlers/post-admin/doUpdatePendingRecord.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,3 @@ | ||
import type { Request, Response } from 'express'; | ||
import { type UpdateScannerRecordForm } from '../../database/updateScannerRecord.js'; | ||
export default function handler(request: Request<unknown, unknown, UpdateScannerRecordForm>, response: Response): void; |
7 changes: 7 additions & 0 deletions
7
modules/inventoryScanner/handlers/post-admin/doUpdatePendingRecord.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,7 @@ | ||
import getScannerRecords from '../../database/getScannerRecords.js'; | ||
import { updateScannerRecord } from '../../database/updateScannerRecord.js'; | ||
export default function handler(request, response) { | ||
const success = updateScannerRecord(request.body, request.session.user); | ||
const pendingRecords = getScannerRecords({ isSynced: false }, { limit: -1 }); | ||
response.json({ success, pendingRecords }); | ||
} |
21 changes: 21 additions & 0 deletions
21
modules/inventoryScanner/handlers/post-admin/doUpdatePendingRecord.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,21 @@ | ||
import type { Request, Response } from 'express' | ||
|
||
import getScannerRecords from '../../database/getScannerRecords.js' | ||
import { | ||
type UpdateScannerRecordForm, | ||
updateScannerRecord | ||
} from '../../database/updateScannerRecord.js' | ||
|
||
export default function handler( | ||
request: Request<unknown, unknown, UpdateScannerRecordForm>, | ||
response: Response | ||
): void { | ||
const success = updateScannerRecord( | ||
request.body, | ||
request.session.user as FasterWebHelperSessionUser | ||
) | ||
|
||
const pendingRecords = getScannerRecords({ isSynced: false }, { limit: -1 }) | ||
|
||
response.json({ success, pendingRecords }) | ||
} |
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 +1,2 @@ | ||
export {}; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
Oops, something went wrong.