From 0d756853d2ce8a8fd8f59745a35ff2deae6456cd Mon Sep 17 00:00:00 2001 From: jabahum Date: Wed, 10 Jan 2024 10:47:15 +0300 Subject: [PATCH] refactor --- .../StockOperationReport.tsx | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/stock-operations/stock-print-reports/StockOperationReport.tsx b/src/stock-operations/stock-print-reports/StockOperationReport.tsx index 71b7c13a..300e7cfb 100644 --- a/src/stock-operations/stock-print-reports/StockOperationReport.tsx +++ b/src/stock-operations/stock-print-reports/StockOperationReport.tsx @@ -62,8 +62,8 @@ export const BuildStockOperationData = async ( }` : ""; } - data.remarks = currentOperation.remarks!; - data.operationNumber = currentOperation.operationNumber!; + data.remarks = currentOperation.remarks; + data.operationNumber = currentOperation.operationNumber; data.operationDate = parentOperation?.operationDate ?? currentOperation?.operationDate; data.location = @@ -73,7 +73,7 @@ export const BuildStockOperationData = async ( data.responsiblePerson = data.orderedBy = parentOperation?.responsiblePersonFamilyName ? `${parentOperation.responsiblePersonFamilyName ?? ""} ${ - parentOperation!.responsiblePersonGivenName ?? "" + parentOperation?.responsiblePersonGivenName ?? "" }` : `${currentOperation.responsiblePersonFamilyName ?? ""} ${ currentOperation.responsiblePersonGivenName ?? "" @@ -88,25 +88,25 @@ export const BuildStockOperationData = async ( }`; data.items = stockOperationItems.map((p) => { const item: StockOperationItemData = {}; - item.itemCode = p.acronym!; - item.itemDescription = p.stockItemName!; - item.purchasePrice = p.purchasePrice!; - item.batchNumber = p.batchNo!; - item.expiryDate = p.expiration!; + item.itemCode = p?.acronym; + item.itemDescription = p?.stockItemName; + item.purchasePrice = p?.purchasePrice; + item.batchNumber = p?.batchNo; + item.expiryDate = p?.expiration; if (parentOperation) { - item.quantityRequired = p.quantityRequested!; - item.quantityRequiredUoM = p.quantityRequestedPackagingUOMName!; - item.quantityIssued = p.quantity!; - item.quantityIssuedUoM = p.stockItemPackagingUOMName!; + item.quantityRequired = p?.quantityRequested; + item.quantityRequiredUoM = p?.quantityRequestedPackagingUOMName; + item.quantityIssued = p?.quantity; + item.quantityIssuedUoM = p?.stockItemPackagingUOMName; } else if ( OperationType.STOCK_ISSUE_OPERATION_TYPE === currentOperation.operationType ) { - item.quantityIssued = p.quantity!; - item.quantityIssuedUoM = p.stockItemPackagingUOMName!; + item.quantityIssued = p?.quantity; + item.quantityIssuedUoM = p?.stockItemPackagingUOMName; } else { - item.quantityRequired = p.quantity!; - item.quantityRequiredUoM = p.stockItemPackagingUOMName!; + item.quantityRequired = p?.quantity; + item.quantityRequiredUoM = p?.stockItemPackagingUOMName; } if (operationItemsCost) { const operationItemCost = operationItemsCost.find(