refactor(FE): Support add/edit type and use ProductPrice for add

This commit is contained in:
rstubryan
2026-01-06 20:25:09 +07:00
parent 46c06ea548
commit fa199e4879
@@ -332,12 +332,18 @@ export const PurchaseRequestStaffApprovalFormDefaultValues = (
label: item.warehouse?.name || '',
},
qty: item.sub_qty || item.qty || 0,
price: type === 'add'
? ('ProductPrice' in item.product ? (item.product.ProductPrice || item.price || '') : item.price)
: item.price,
total_price: type === 'add'
? (('ProductPrice' in item.product ? (item.product.ProductPrice || item.price || 0) : item.price) * (item.sub_qty || item.qty || 0))
: item.total_price,
price:
type === 'add'
? 'ProductPrice' in item.product
? item.product.ProductPrice || item.price || ''
: item.price
: item.price,
total_price:
type === 'add'
? ('ProductPrice' in item.product
? item.product.ProductPrice || item.price || 0
: item.price) * (item.sub_qty || item.qty || 0)
: item.total_price,
}))
: [
{