fixx 01
This commit is contained in:
@@ -4254,7 +4254,8 @@ app.post('/api/assets/:id/export', requireAssetOrAdmin, async (req, res) => {
|
||||
NewQuantity,
|
||||
UsedQuantity,
|
||||
Custodian,
|
||||
Borrower
|
||||
Borrower,
|
||||
Notes
|
||||
FROM AssetInventory WITH (UPDLOCK, ROWLOCK)
|
||||
WHERE AssetId = @assetId
|
||||
`);
|
||||
@@ -4311,6 +4312,11 @@ app.post('/api/assets/:id/export', requireAssetOrAdmin, async (req, res) => {
|
||||
const nextNewQuantity = Math.max(stockBuckets.newQuantity - borrowFromNew, 0);
|
||||
const nextUsedQuantity = Math.max(stockBuckets.usedQuantity - borrowFromUsed, 0);
|
||||
const nextStatus = resolveAssetStatusFromStock(nextEndingBalance, nextExportInPeriod);
|
||||
const existingAssetNotes = String(asset.Notes || '').trim();
|
||||
const cleanExportNote = String(exportNote || '').trim();
|
||||
const nextAssetNotes = cleanExportNote
|
||||
? (existingAssetNotes ? `${existingAssetNotes}\n${cleanExportNote}` : cleanExportNote)
|
||||
: (existingAssetNotes || null);
|
||||
|
||||
await new sql.Request(transaction)
|
||||
.input('assetId', sql.Int, assetId)
|
||||
@@ -4322,6 +4328,7 @@ app.post('/api/assets/:id/export', requireAssetOrAdmin, async (req, res) => {
|
||||
.input('usedQuantity', sql.Int, nextUsedQuantity)
|
||||
.input('status', sql.NVarChar, nextStatus)
|
||||
.input('exportedBy', sql.NVarChar, exportedByName)
|
||||
.input('notes', sql.NVarChar, nextAssetNotes)
|
||||
.query(`
|
||||
UPDATE AssetInventory
|
||||
SET Project = @project,
|
||||
@@ -4332,6 +4339,7 @@ app.post('/api/assets/:id/export', requireAssetOrAdmin, async (req, res) => {
|
||||
UsedQuantity = @usedQuantity,
|
||||
Status = @status,
|
||||
ExportedBy = @exportedBy,
|
||||
Notes = @notes,
|
||||
UpdatedDate = GETDATE()
|
||||
WHERE AssetId = @assetId
|
||||
`);
|
||||
|
||||
Reference in New Issue
Block a user