增加订单退货退款售后、原成本回料及跨日损益核算

This commit is contained in:
summer committed 2026-11-10 02:54:58 +08:00
1 parent b6a0213a0c
commit dab735423e
24 files changed
+1048 -82

No files matched your search

+2 -2
View File
@@ -14,7 +14,7 @@ const sum=(rows,key)=>rows.reduce((total,row)=>total+(typeof key==='function'?ke
const same=(a,b)=>JSON.stringify(a)===JSON.stringify(b);
const CreditCardFees=require('./public/credit-card-fees');
const isCardFee=item=>item?.system==='credit_card'||String(item?.key||'').startsWith('card_fee:');
const COST_FIELDS=['payer','costPayers','costFundings','cost','costParts','costMaterial','costLabor','materialAllocations','priceLockPool'];
const COST_FIELDS=['payer','costPayers','costFundings','cost','costParts','costMaterial','costLabor','materialAllocations','priceLockPool','returnedStockId','returnedStock'];
const SALE_FIELDS=['name','code','unit','quantity','pocket','stockCount','sale','baseSale','charges','pricingMode','goldPrice','laborRate','laborMode','pieces','priceNote'];
function activeActor(actor,env){if(!actor||!['owner','assistant'].includes(actor.role))env.fail('请使用麦麦或助理账号修改订单',403);}
function atomic(ledger,fn){
@@ -55,7 +55,7 @@ function inputFor(order){
return {id:order.id,date:order.date,customer:order.customer,salesperson:order.salesperson,note:order.note,internal_note:order.internal_note??'',
discount:converted.discount,rounding_mode:order.rounding_mode,fees_date:order.fees_date||order.date,
payment_account:accounts.size===1?[...accounts][0]:order.payment_account,
lines:converted.lines.map((line,index)=>({...Object.fromEntries(allowed.filter(key=>Object.hasOwn(line,key)).map(key=>[key,line[key]])),...(Number.isSafeInteger(order.lines[index]?.stockCount)?{stockCount:order.lines[index].stockCount}:{})})),fee_items:feeInputs(order)};
lines:converted.lines.map((line,index)=>({...Object.fromEntries(allowed.filter(key=>Object.hasOwn(line,key)).map(key=>[key,line[key]])),...(order.lines[index]?.returnedStockId?{returnedStockId:order.lines[index].returnedStockId}:{}),...(Number.isSafeInteger(order.lines[index]?.stockCount)?{stockCount:order.lines[index].stockCount}:{})})),fee_items:feeInputs(order)};
}
function priceLockCosts(ledger,order){
if(!order.price_lock_id)return null;