支持直接修改已生成订单并重算成本库存与利润
This commit is contained in:
1 parent
3bf9e8d82d
commit
34781b6cd1
14 files changed
+718
-31
No files matched your search
@@ -81,7 +81,7 @@ function syncMaterialPoolSelection(root,unit,quantity){
|
||||
const help=controls.querySelector('.material-source-help');help.textContent=allowed?'每日料价只自动核算料费,进货工费仍按实际填写。':'按件商品和银饰请手动填写料费成本。';
|
||||
const note=controls.querySelector('.material-pool-note');note.hidden=!active;
|
||||
if(!active)return false;
|
||||
const pool=materialPoolsCacheUser===state.user.id?materialPoolsCache?.rows.find(pool=>pool.id===selected):null,mg=materialPoolMg(quantity),wanted=materialPoolFormUsage(selected),covered=!!pool&&pool.totalMg>=pool.usedMg+wanted&&pool.totalMg>0;
|
||||
const pool=materialPoolsCacheUser===state.user.id?materialPoolsCache?.rows.find(pool=>pool.id===selected):null,mg=materialPoolMg(quantity),wanted=materialPoolFormUsage(selected),used=pool?(typeof orderEditPoolUsedMg==='function'?orderEditPoolUsedMg(pool):pool.usedMg):0,covered=!!pool&&pool.totalMg>=used+wanted&&pool.totalMg>0;
|
||||
let amount=null;if(covered&&mg)try{amount=LedgerCalc.poolMaterialAmount(pool.totalAmount,pool.totalMg,mg);}catch{}
|
||||
const payerText=materialPoolPayers(pool);
|
||||
get('materialMode').value='total';get('materialMode').disabled=true;get('materialMode').closest('label').hidden=true;
|
||||
@@ -92,7 +92,7 @@ function syncMaterialPoolSelection(root,unit,quantity){
|
||||
material.querySelector('.purchase-original').hidden=true;
|
||||
material.querySelector('.purchase-formula').textContent=amount==null?'料费尚未确定;登记足额购料后自动补齐,销售金额保持原单。':`${quantity}g × 当日实际加权料价 = ${yuan(amount)}元;按各付款人的购料金额自动分摊。`;
|
||||
const known=materialPoolsCacheUser===state.user.id&&!!materialPoolsCache;
|
||||
note.textContent=!known?'正在读取每日料价;可保留选择,读取完成后显示当前料费。':!pool||!pool.totalMg?`${selected} 尚未登记购料。可以先开单,稍后补足购料后自动核算成本与利润。`:!covered?`${selected} 已购 ${grams(pool.totalMg)}g,已用 ${grams(pool.usedMg)}g,本次共用 ${grams(wanted)}g;还需补采购 ${grams(Math.max(0,pool.usedMg+wanted-pool.totalMg))}g。可先开单,料费与利润暂待补。`:`${selected} 已购 ${grams(pool.totalMg)}g,已用 ${grams(pool.usedMg)}g,余 ${grams(pool.remainingMg)}g;本次共用 ${grams(wanted)}g。`;
|
||||
note.textContent=!known?'正在读取每日料价;可保留选择,读取完成后显示当前料费。':!pool||!pool.totalMg?`${selected} 尚未登记购料。可以先开单,稍后补足购料后自动核算成本与利润。`:!covered?`${selected} 已购 ${grams(pool.totalMg)}g,已用 ${grams(used)}g,本次共用 ${grams(wanted)}g;还需补采购 ${grams(Math.max(0,used+wanted-pool.totalMg))}g。可先开单,料费与利润暂待补。`:`${selected} 已购 ${grams(pool.totalMg)}g,已用 ${grams(used)}g,余 ${grams(Math.max(0,pool.totalMg-used))}g;本次共用 ${grams(wanted)}g。`;
|
||||
controls.dataset.preview=JSON.stringify({poolId:selected,date:selected,status:amount==null?'pending':'preview',amount,quantity:mg,averageRate:pool?.averageRate??null,revision:pool?.revision??0,allocations:[]});
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user