支持订单归属修改与麦麦复核

This commit is contained in:
summer committed 2026-10-26 20:25:31 +08:00
1 parent ab9d3009ea
commit b3b67c8003
17 files changed
+829 -32

No files matched your search

+4 -2
View File
@@ -100,7 +100,7 @@ function recipientSummaries(ledger,book,payments){
return recipients;
}
function reportRevision(book,dailyFundsState=null){
function reportRevision(book,dailyFundsState=null,ownership=[]){
// 复核、打印、库存和其他日期的账务不会改变本日的财务核对状态。
// 新增展示用计数不改变旧快照版本;售后本身已包含在财务行和金额中。
const {afterSaleCount,recordCount,...summary}=book.summary;
@@ -118,6 +118,8 @@ function reportRevision(book,dailyFundsState=null){
totalCost:row.totalCost,profit:row.profit,ownerCost:row.ownerCost,assistantCost:row.assistantCost,
known:row.known,costItems:row.costItems,pendingCostItems:row.pendingCostItems,balance:row.balance}));
const financial={basis:'orderDate',date:book.date,from:book.from,summary,rows,receipts:book.receiptsByOrderDate};
// 未转移过的旧日保留原指纹。实际归属调整使订单日及关联锁价收付日重新核对。
if(ownership.length)financial.orderOwnership=ownership;
if(dailyFundsState)financial.dailyFunds=dailyFundsState;
if(book.priceLockActivity.summary.eventCount){
// 只把原日不可变的收付款项目纳入版本。之后交付关联出的状态、单号和待交信息,
@@ -162,7 +164,7 @@ 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));
const revision=reportRevision(book,DailyFunds.financialState(ledger,book.from,book.date),ledger.orderOwnershipReportState(book.from,book.date));
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);