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 || '', label: item.warehouse?.name || '',
}, },
qty: item.sub_qty || item.qty || 0, qty: item.sub_qty || item.qty || 0,
price: type === 'add' price:
? ('ProductPrice' in item.product ? (item.product.ProductPrice || item.price || '') : item.price) type === 'add'
: item.price, ? 'ProductPrice' in item.product
total_price: type === 'add' ? item.product.ProductPrice || item.price || ''
? (('ProductPrice' in item.product ? (item.product.ProductPrice || item.price || 0) : item.price) * (item.sub_qty || item.qty || 0)) : item.price
: item.total_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,
})) }))
: [ : [
{ {