完善订单成本编辑与多商品置换,修正锁价跨天作废回池
This commit is contained in:
1 parent
a3262a455d
commit
2e4e7dad55
25 files changed
+430
-109
No files matched your search
+2
-1
@@ -53,8 +53,9 @@ function detail(ledger,id,env){
|
||||
const credit_card_fees=events.filter(event=>event.card_fee_amount!==null).map(event=>({key:'card_fee:'+event.id,system:'credit_card',source_kind:'price_lock',source_id:event.id,date:event.date,amount:event.card_fee_amount,payer:event.card_fee_payer,note:cardFeeNote(event),...(event.card_fee_rate?{rate_permille:event.card_fee_rate}:{}),...(event.card_fee_expense_id?{expense_id:event.card_fee_expense_id}:{})}));
|
||||
const reservations=LockPools.findAll(ledger,id),byIndex=new Map(reservations.map(r=>[r.line_index,r]));
|
||||
const lines=row.lines.map(item=>{const reservation=byIndex.get(item.line_index);return {...item,material_source:reservation?'pool':'manual',...(reservation?{material_amount:reservation.snapshot.amount??null,buy_rate:reservation.snapshot.averageRate??null,material_pool_id:reservation.pool_id,materialPool:LockPools.detail(ledger,id,env,item.line_index)}:{}),delivery:LockLines.deliveryAt(row,item.line_index)};});
|
||||
const cancellationReturns=ledger.rows("SELECT line_index,date,mg,amount,allocations,origin_pool_id FROM price_lock_pool_returns WHERE price_lock_id=? AND kind='cancel' ORDER BY line_index",id).map(value=>({...value,allocations:JSON.parse(value.allocations)}));
|
||||
const material_source=reservations.length===0?'manual':reservations.length===lines.length?'pool':'mixed',material_amount=lines.some(line=>line.material_amount===null)?null:lines.reduce((sum,line)=>sum+line.material_amount,0);
|
||||
return {...row,credit_card_rate_permille:CreditCardRates.read(ledger,'price_lock',id),lines,line:lines[0].line,locked_mg:lines.reduce((sum,line)=>sum+line.locked_mg,0),buy_rate:lines[0].buy_rate,buy_payer:lines[0].buy_payer,material_source,material_amount,...(lines.length===1&&lines[0].materialPool?{material_pool_id:lines[0].material_pool_id,materialPool:lines[0].materialPool}:{}),cash_events,material_events,voided_events:allEvents.filter(event=>event.voided),received,refunded,netReceived:received-refunded,credit_card_fees,credit_card_fee_total:credit_card_fees.reduce((total,fee)=>total+fee.amount,0)};
|
||||
return {...row,...(cancellationReturns.length?{cancellationReturns}:{}),credit_card_rate_permille:CreditCardRates.read(ledger,'price_lock',id),lines,line:lines[0].line,locked_mg:lines.reduce((sum,line)=>sum+line.locked_mg,0),buy_rate:lines[0].buy_rate,buy_payer:lines[0].buy_payer,material_source,material_amount,...(lines.length===1&&lines[0].materialPool?{material_pool_id:lines[0].material_pool_id,materialPool:lines[0].materialPool}:{}),cash_events,material_events,voided_events:allEvents.filter(event=>event.voided),received,refunded,netReceived:received-refunded,credit_card_fees,credit_card_fee_total:credit_card_fees.reduce((total,fee)=>total+fee.amount,0)};
|
||||
}
|
||||
function list(ledger,query,env){
|
||||
const date=env.day(query.date??query.to??env.today()),from=env.day(query.from??(query.date||query.to?date:'2000-01-01'));
|
||||
|
||||
Reference in new issue
Block a user