允许手动移除附加成本并保留草稿模板删除状态

This commit is contained in:
summer committed 2026-11-20 00:43:55 +08:00
1 parent 5777036743
commit a3262a455d
8 files changed
+109 -11

No files matched your search

+2 -1
View File
@@ -45,6 +45,7 @@
}
const completed=['delivered','returned','cancelled'].includes(order.status);
for(const [index,line] of lines.entries())for(const charge of line.charges){
if(charge.costRemoved===true)continue;
const shipping=Fees.normalize(charge.name)==='快递',key=shipping?'shipping':'charge:'+charge.id;
if(items.some(item=>item.key===key))continue;
const found=items.find(item=>item.key.startsWith('manual:')&&Fees.normalize(item.note)===Fees.normalize(charge.name));
@@ -61,7 +62,7 @@
const source=inputs(order),chargeIds=new Map(),locked=!!order.price_lock_id||order.lines.some(line=>line.materialAllocations?.length);
const lines=source.lines.map(line=>{
const result=Object.fromEntries(['name','nameType','customName','unit','quantity','pocket','stockCount','payer','pricingMode','goldPrice','laborMode','laborRate','pieces','priceNote','sale','baseSale'].filter(key=>Object.hasOwn(line,key)).map(key=>[key,line[key]]));
result.charges=line.charges.map(charge=>{const id=newId();if(charge.id)chargeIds.set(charge.id,id);return {id,name:charge.name,amount:charge.amount};});
result.charges=line.charges.map(charge=>{const id=newId();if(charge.id)chargeIds.set(charge.id,id);return {id,name:charge.name,amount:charge.amount,...(charge.costRemoved===true?{costRemoved:true}:{})};});
if(line.costParts){
result.costParts={...line.costParts};result.costMaterial={...line.costMaterial};result.costLabor={...line.costLabor};
result.costPayers={material:line.costPayers?.material??line.payer??'owner',labor:line.costPayers?.labor??line.payer??'owner'};