支持回收单修改取消、按归属人优先用料及锁价交付改单

This commit is contained in:
summer committed 2026-11-04 22:18:56 +08:00
1 parent 0e146739bc
commit 19b1b0263c
41 files changed
+1814 -203

No files matched your search

+5 -2
View File
@@ -128,7 +128,7 @@ function ownershipSummaries(ledger,recipients,actor){
return groups;
}
function reportRevision(book,dailyFundsState=null,ownership=[]){
function reportRevision(book,dailyFundsState=null,ownership=[],recoveryRevisions=[]){
// 复核、打印、库存和其他日期的账务不会改变本日的财务核对状态。
// 新增展示用计数不改变旧快照版本;售后本身已包含在财务行和金额中。
const {afterSaleCount,recordCount,...summary}=book.summary;
@@ -149,6 +149,8 @@ function reportRevision(book,dailyFundsState=null,ownership=[]){
// 仅真正改过的售后加入版本,客户名等展示更正也须重核;旧记录升级不改原指纹。
const afterSaleRevisions=legacyRows.filter(row=>row.kind==='afterSale'&&row.revision>1).map(row=>({id:row.id,revision:row.revision}));
if(afterSaleRevisions.length)financial.afterSaleRevisions=afterSaleRevisions;
// 仅实际更正/取消过的回收参与新版本;升级不改变未改旧单已保存的核对指纹。
if(recoveryRevisions.length)financial.recoveryRevisions=recoveryRevisions;
// 未转移过的旧日保留原指纹。实际归属调整使订单日及关联锁价收付日重新核对。
if(ownership.length)financial.orderOwnership=ownership;
if(dailyFundsState)financial.dailyFunds=dailyFundsState;
@@ -195,7 +197,8 @@ function dailyFundsReceipts(ledger,date){
function reportByOrderDate(ledger,date,from=date,actor=null,env){
const book=ledger.orderBook({date,from,status:'all'});
const previous=ledger.report(book.date,book.from),orderPayerCosts=costSummaries(ledger,book.rows),payerCosts=actualCostSummaries(ledger,book);
const revision=reportRevision(book,DailyFunds.financialState(ledger,book.from,book.date),ledger.orderOwnershipReportState(book.from,book.date));
const recoveryRevisions=ledger.visibleRows('recovery',ledger.rows('SELECT id,revision,status FROM recoveries WHERE date>=? AND date<=? AND revision>1 ORDER BY id',book.from,book.date));
const revision=reportRevision(book,DailyFunds.financialState(ledger,book.from,book.date),ledger.orderOwnershipReportState(book.from,book.date),recoveryRevisions);
const entries=table=>ledger.visibleRows('order',ledger.rows(`SELECT e.*,o.number,o.paper_number,o.date AS order_date FROM ${table} e JOIN orders o ON o.id=e.order_id WHERE o.date>=? AND o.date<=? ORDER BY o.date,e.date,e.created,e.id`,book.from,book.date),'order_id');
const pendingMaterialOrders=new Set(book.rows.filter(row=>row.materialCostPending).map(row=>row.id));
const outlayGoods=Object.values(payerCosts).reduce((total,payer)=>total+payer.goods,0),outlayExpense=Object.values(payerCosts).reduce((total,payer)=>total+payer.paidFees,0);