锁价交付补重支持当日料池,内部备注移至客户名旁
This commit is contained in:
1 parent
ac9073471d
commit
c5883351c1
20 files changed
+196
-66
No files matched your search
@@ -95,6 +95,7 @@ function syncPriceLockMaterial(form,row=form,lineIndex=0){
|
||||
}
|
||||
|
||||
async function loadPriceLockPoolChoices(force=false){
|
||||
if($('#price-lock-delivery-form')){materialQuoteEntry=null;++materialQuoteRequest;syncPriceLockDelivery();return;}
|
||||
const form=$('#price-lock-create-form');if(!form?.querySelector('[name="material_source"]')||typeof readMaterialPools!=='function')return;
|
||||
if(priceLockPoolRead?.form===form)return priceLockPoolRead.promise;
|
||||
const user=state.user.id;
|
||||
@@ -146,9 +147,25 @@ function priceLockItemsHTML(lock){
|
||||
return `<div class="table-wrap price-lock-items"><table aria-label="锁价商品明细"><thead><tr><th>商品</th><th class="number">原锁克重</th><th class="number">原锁销售金价</th><th>工费与附加项目</th><th>原锁料费/付款来源</th>${lock.status==='delivered'?'<th>实际交付</th>':''}</tr></thead><tbody>${rows.map((row,index)=>{const item=row.line||{},delivery=row.delivery;return `<tr><td><strong>${e(item.name||'黄金')}</strong><div class="small muted">商品 ${index+1}${item.code?' · '+e(item.code):''}</div></td><td class="number">${grams(row.locked_mg)}g</td><td class="number">¥${yuan(row.sell_rate)}/克</td><td>${item.laborMode==='piece'?`件工费 ¥${yuan(item.laborRate??0)} × ${e(item.pieces||1)}件`:`克工费 ¥${yuan(item.laborRate??0)}/克`}${(item.charges||[]).map(charge=>`<div class="small muted">${e(charge.name)} ¥${yuan(charge.amount)}</div>`).join('')}</td><td>${priceLockItemFactsHTML(row)}</td>${lock.status==='delivered'?`<td>${delivery?`${grams(delivery.finalMg??delivery.quantity??row.locked_mg)}g${(delivery.extraMg??delivery.extra_mg)?'<br>补重 '+grams((delivery.extraMg??delivery.extra_mg))+'g':''}${(delivery.leftoverMg??delivery.leftover_mg)?'<br>'+ (priceLockUsesPool(row)?'解除预留回池 ':'剩料留盘 ')+grams((delivery.leftoverMg??delivery.leftover_mg))+'g':''}${delivery.inventory?.pocket?'<br>货盘 '+e(pocketLabel(delivery.inventory.pocket)):delivery.pocket?'<br>货盘 '+e(pocketLabel(delivery.pocket)):''}`:'详见销售单'}</td>`:''}</tr>`;}).join('')}</tbody></table></div>`;
|
||||
}
|
||||
function priceLockDeliveryRows(form){return [...(form?.querySelectorAll('[data-price-lock-delivery-item]')||[])];}
|
||||
function materialLockExtraQuoteInput(form=$('#price-lock-delivery-form')){
|
||||
const date=lockFormValue(form,'date'),locks=priceLockLines(currentPriceLock),entries=[];
|
||||
priceLockDeliveryRows(form).forEach((root,lineIndex)=>{if(lockFormValue(root,'extra_source')!=='pool')return;const mg=materialPoolMg(root.querySelector('.line-item [name="quantity"]')?.value);const extra=mg?mg-locks[lineIndex].locked_mg:0;if(extra>0)entries.push({lineIndex,poolId:date,mg:extra});});
|
||||
return {date,member:currentPriceLock?.member||materialFormMember(form),entries};
|
||||
}
|
||||
function priceLockExtraPreview(form,index){
|
||||
const input=materialLockExtraQuoteInput(form);if(input.date!==state.today)throw new Error('补重使用当日料池,请选择今天的交付日期。');
|
||||
const quote=materialQuoteFor(form,input,'lockExtra');if(!quote.result)throw new Error(quote.error||'正在读取交付当日料池…');
|
||||
const entry=quote.result.entries.find(row=>row.lineIndex===index),pool=quote.result.pools.find(row=>row.poolId===input.date);
|
||||
if(!entry||!pool||entry.amount===null)throw new Error('当日料池不足或成本待补,请核实购料。');return {...entry,revision:pool.revision};
|
||||
}
|
||||
function priceLockDeliveryRowCost(item,quantity,extra,index,form){
|
||||
if(extra?.source!=='pool'||lockQuantityMg(quantity)<=item.locked_mg)return priceLockDeliveryCost(item,quantity,extra?.rate);
|
||||
const preview=priceLockExtraPreview(form,index),costs=priceLockDeliveryCost(item,quantity,'1');
|
||||
costs.extraCost=preview.amount;costs.materialCost=costs.originalUsedCost+preview.amount;costs.extraPool=preview;return costs;
|
||||
}
|
||||
function priceLockDeliveryInventoryHTML(lock,draft={},index=0){
|
||||
const part=name=>`data-lock-part="${name}"`,pool=priceLockUsesPool(lock);
|
||||
return `<div class="internal lock-line-inventory"><h3>本件金料与库存确认</h3><div data-lock-count-source hidden>${choice('成品来源','count_source',[['stocked','已在货盘'],['receive','本次新入库']],draft.inventory?.countSource||'stocked')}<p class="small muted">只确认本次交付成品的实际对数。选本次新入库时,对数先入库一次再销售出库;原锁及补重金料的克重另行核对。</p></div><div class="grid two">${choice('原锁金料是否已记入本件货盘','original_stock',[['','请选择'],['receive','尚未记入,交付时先入库'],['stocked',pool?'料池已预留,仅出库,不重复入库':'此前已记入,只出库']],pool?'stocked':draft.inventory?.original||'')}<div ${part('material-breakdown')} class="lock-material-breakdown" aria-live="polite"></div></div><div ${part('extra-material')} class="lock-extra-material" hidden><h3>本件超出原锁克重的补重金料</h3><div class="grid three">${moneyField('补重进货料价(元/克)','extra_rate',draft.extraMaterial?.rate??'')}${choice('补重料费付款人','extra_payer',[['','请选择'],...teamMemberOptions()],draft.extraMaterial?.payer||'')}${choice('补重金料是否已记入本件货盘','extra_stock',[['','请选择'],['receive','尚未记入,交付时先入库'],['stocked','此前已记入,只出库']],draft.inventory?.extra||'')}</div><label class="check"><input type="checkbox" name="extra_verified" ${draft.extraMaterial?.verified?'checked':''}>已核实本件补重料费实际付款。</label></div><p ${part('stock-note')} class="note" aria-live="polite"></p></div>`;
|
||||
return `<div class="internal lock-line-inventory"><h3>本件金料与库存确认</h3><div data-lock-count-source hidden>${choice('成品来源','count_source',[['stocked','已在货盘'],['receive','本次新入库']],draft.inventory?.countSource||'stocked')}<p class="small muted">只确认本次交付成品的实际对数。选本次新入库时,对数先入库一次再销售出库;原锁及补重金料的克重另行核对。</p></div><div class="grid two">${choice('原锁金料是否已记入本件货盘','original_stock',[['','请选择'],['receive','尚未记入,交付时先入库'],['stocked',pool?'料池已预留,仅出库,不重复入库':'此前已记入,只出库']],pool?'stocked':draft.inventory?.original||'')}<div ${part('material-breakdown')} class="lock-material-breakdown" aria-live="polite"></div></div><div ${part('extra-material')} class="lock-extra-material" hidden><h3>本件超出原锁克重的补重金料</h3>${choice('补重料费来源','extra_source',[['manual','手动填写料价'],['pool','交付当日加权料池']],draft.extraMaterial?.source||'manual')}<div data-lock-extra-pool class="note" hidden></div>${button('刷新补重料池','reload-price-lock-pool','quiet')}<div data-lock-extra-manual class="grid three">${moneyField('补重进货料价(元/克)','extra_rate',draft.extraMaterial?.rate??'')}${choice('补重料费付款人','extra_payer',[['','请选择'],...teamMemberOptions()],draft.extraMaterial?.payer||'')}${choice('补重金料是否已记入本件货盘','extra_stock',[['','请选择'],['receive','尚未记入,交付时先入库'],['stocked','此前已记入,只出库']],draft.inventory?.extra||'')}</div><label class="check"><input type="checkbox" name="extra_verified" ${draft.extraMaterial?.verified?'checked':''}>已核实本件补重料费实际付款。</label></div><p ${part('stock-note')} class="note" aria-live="polite"></p></div>`;
|
||||
}
|
||||
function priceLockFacts(lock){
|
||||
const voided=lock.status==='cancelled'?`<div class="note price-lock-voided-note"><strong>这张锁价单已作废</strong><p>客户收款、手填购料和信用卡手续费有效记账已撤销,料池预留已释放。下方原录入克重、售价和成本保留用于追溯,不计当前有效收付。</p>${(lock.cancellationReturns||[]).map(row=>`<p>商品 ${row.line_index+1} · ${e(row.date)} 按原成本回池:<strong>${grams(row.mg)}g / ¥${yuan(row.amount)}</strong>,参与回池当天加权;原料池日期 ${e(row.origin_pool_id)}。</p>`).join('')}</div>`:'';
|
||||
@@ -224,7 +241,7 @@ async function renderPriceLockDelivery(id){
|
||||
|
||||
function collectPriceLockDelivery(){
|
||||
const form=$('#price-lock-delivery-form'),get=name=>lockFormValue(form,name),roots=priceLockDeliveryRows(form),locks=priceLockLines(currentPriceLock);
|
||||
const items=(roots.length?roots:[form]).map((root,index)=>{const row=root.querySelector('.line-item')||root.querySelector('#lines .line-item'),item=locks[index];if(roots.length&&root.dataset.lineId!==item?.id)throw new Error('交付商品与原锁记录不一致,请重新读取。');const get=name=>lockFormValue(root,name);return {lineId:item?.id,line:collectLine(row),extraMaterial:{rate:get('extra_rate'),payer:get('extra_payer'),verified:root.querySelector('[name="extra_verified"]')?.checked===true},inventory:{pocket:row.querySelector('[name="pocket"]').value,original:priceLockUsesPool(item)?'stocked':get('original_stock'),extra:get('extra_stock'),...(pocketCountsEnabled(row.querySelector('[name="pocket"]').value)?{countSource:get('count_source')}: {})}};});
|
||||
const items=(roots.length?roots:[form]).map((root,index)=>{const row=root.querySelector('.line-item')||root.querySelector('#lines .line-item'),item=locks[index];if(roots.length&&root.dataset.lineId!==item?.id)throw new Error('交付商品与原锁记录不一致,请重新读取。');const get=name=>lockFormValue(root,name);return {lineId:item?.id,line:collectLine(row),extraMaterial:{source:get('extra_source')||'manual',...(get('extra_source')==='pool'?{poolId:lockFormValue(form,'date'),revision:materialQuoteEntry?.result?.pools?.find(p=>p.poolId===lockFormValue(form,'date'))?.revision}:{}),rate:get('extra_rate'),payer:get('extra_payer'),verified:root.querySelector('[name="extra_verified"]')?.checked===true},inventory:{pocket:row.querySelector('[name="pocket"]').value,original:priceLockUsesPool(item)?'stocked':get('original_stock'),extra:get('extra_source')==='pool'?'stocked':get('extra_stock'),...(pocketCountsEnabled(row.querySelector('[name="pocket"]').value)?{countSource:get('count_source')}: {})}};});
|
||||
const data={revision:Number(form.dataset.revision),date:get('date'),note:get('delivery_note'),discount:get('discount'),settlement:{amount:get('settlement_amount'),account:readPaymentAccount(form),credit_card_fee_payer:readCreditCardPayer(form),verified:form.querySelector('[name="settlement_verified"]').checked},fee_items:readFeeRows(),fee_auto_initialized:true,verified:form.querySelector('[name="delivery_verified"]').checked};
|
||||
if(!roots.length)return {...data,line:items[0].line,inventory:items[0].inventory,extraMaterial:items[0].extraMaterial};
|
||||
return {...data,lines:items.map(({line,...item})=>({...line,...item}))};
|
||||
@@ -238,21 +255,26 @@ function syncPriceLockDelivery(){
|
||||
get('goldPrice').value=(item.sell_rate/100).toFixed(2);get('unit').value='g';get('pricingMode').value='auto';get('cost-materialMode').value='total';get('cost-materialPayer').value=priceLockMaterialAllocations(item)[0]?.payer||item.buy_payer||'owner';
|
||||
let costs=null,extra=false;try{extra=lockQuantityMg(get('quantity').value)>item.locked_mg;}catch{}
|
||||
const extraRoot=priceLockPart(root,'extra-material');extraRoot.hidden=!extra;for(const input of extraRoot.querySelectorAll('input,select')){input.disabled=!extra;input.required=extra;}
|
||||
try{costs=priceLockDeliveryCost(item,get('quantity').value,value('extra_rate'));get('cost-material').value=(costs.materialCost/100).toFixed(2);}catch{get('cost-material').value='';}allCosts.push(costs);
|
||||
const extraPooled=extra&&value('extra_source')==='pool',extraNote=root.querySelector('[data-lock-extra-pool]');
|
||||
const manual=root.querySelector('[data-lock-extra-manual]');if(manual)manual.hidden=extraPooled;
|
||||
for(const name of ['extra_rate','extra_payer','extra_stock','extra_verified']){const input=root.querySelector('[name="'+name+'"]');if(input){input.disabled=!extra||extraPooled;input.required=extra&&!extraPooled;if(name==='extra_verified')input.closest('label').hidden=extraPooled;}}
|
||||
if(extraNote){extraNote.hidden=!extraPooled;if(extraPooled){try{const preview=priceLockExtraPreview(form,index);extraNote.innerHTML='<strong>'+e(materialSourceSegmentsText(preview.materialSources))+'</strong><br>'+priceLockAllocationHTML(preview.allocations)+'<br>只耗用补重金料,不再登记购料付款;当天补料跟随加权,跨天固定。';}catch(error){extraNote.textContent=error.message;}}}
|
||||
try{costs=priceLockDeliveryRowCost(item,get('quantity').value,{source:extraPooled?'pool':'manual',rate:value('extra_rate')},index,form);get('cost-material').value=(costs.materialCost/100).toFixed(2);}catch{get('cost-material').value='';}allCosts.push(costs);
|
||||
syncLine(row);
|
||||
for(const name of ['nameType','customName','unit','pricingMode','goldPrice','cost-materialMode','cost-materialPayer'])get(name).disabled=true;
|
||||
get('cost-material').readOnly=true;row.querySelector('.line-top button')?.remove();row.querySelector('.purchase-material .purchase-original').hidden=true;
|
||||
const poolMode=priceLockUsesPool(item),formula=row.querySelector('.purchase-material .purchase-formula');
|
||||
formula.textContent=costs?poolMode?`${costs.materialSources?.length?materialSourceSegmentsText(costs.materialSources):'原锁按 '+(item.material_pool_id||item.date)+' 料池耗用 '+grams(costs.originalUsedMg)+'g,料费 ¥'+yuan(costs.originalUsedCost)}${costs.extraMg?';补重 '+grams(costs.extraMg)+'g × '+value('extra_rate')+'元/克,料费 ¥'+yuan(costs.extraCost):''};合计 ¥${yuan(costs.materialCost)}`:`原锁使用 ${grams(costs.originalUsedMg)}g × ${yuan(item.buy_rate)}元/克${costs.extraMg?';补重 '+grams(costs.extraMg)+'g × '+value('extra_rate')+'元/克':''} = ${yuan(costs.materialCost)}元`:poolMode?'原锁料费沿用料池实际分币金额;有补重时,请填写补重进货料价。':'料费按原锁进货价计算;有补重时,请先填写补重进货料价。';
|
||||
if(costs?.extraPool)formula.textContent='原锁耗用 '+grams(costs.originalUsedMg)+'g,料费 ¥'+yuan(costs.originalUsedCost)+';补重 '+materialSourceSegmentsText(costs.extraPool.materialSources)+';合计 ¥'+yuan(costs.materialCost);
|
||||
if(poolMode){let payers=row.querySelector('.lock-pool-delivery-payers');if(!payers){formula.insertAdjacentHTML('afterend','<div class="lock-pool-delivery-payers price-lock-material-payers small"></div>');payers=row.querySelector('.lock-pool-delivery-payers');}payers.innerHTML='<strong>原锁耗用来源:</strong>'+priceLockAllocationHTML(costs?.allocations||priceLockMaterialAllocations(item));}
|
||||
get('goldPrice').closest('label').firstChild.textContent='原锁销售金价(元/克,固定)';get('cost-material').closest('label').firstChild.textContent='实际耗用料费合计(元,自动)';get('cost-materialPayer').closest('label').firstChild.textContent='原锁料费付款人';get('cost-materialMode').querySelector('option[value="total"]').textContent='原锁+补重自动核算';get('pocket').required=true;get('pocket').querySelector('option[value=""]').textContent='请选择本件实际黄金货盘';get('cost-materialPayer').closest('label').hidden=poolMode;
|
||||
const originalStock=root.querySelector('[name="original_stock"]');originalStock.required=!poolMode;originalStock.disabled=poolMode;if(poolMode)originalStock.value='stocked';
|
||||
priceLockPart(root,'material-breakdown').textContent=costs?`原锁${poolMode?'预留':'料费已付'} ¥${yuan(item.material_amount)};本件耗用料费 ¥${yuan(costs.materialCost)}${costs.leftoverMg?';'+(poolMode?'解除预留回池 ':'余料 ')+grams(costs.leftoverMg)+'g,成本 ¥'+yuan(costs.leftoverCost)+(costs.leftoverMaterialSources?.length?'('+materialSourceSegmentsText(costs.leftoverMaterialSources)+')':''):''}${poolMode?';已有购料付款不重复登记。':''}`:extra?'请填写本件补重料价,计算实际耗用成本。':'填写本件最终交付克重,自动计算实际耗料。';
|
||||
const original=originalStock.value,pocket=get('pocket').value,countSource=root.querySelector('[data-lock-count-source]'),countControl=root.querySelector('[name="count_source"]');if(countSource){countSource.hidden=!pocketCountsEnabled(pocket);if(countControl){countControl.disabled=!pocketCountsEnabled(pocket);countControl.required=pocketCountsEnabled(pocket);}}
|
||||
priceLockPart(root,'stock-note').textContent=costs&&original&&pocket?`${poolMode?'原锁金料已在料池预留,不重复入库;':original==='receive'?'原锁 '+grams(item.locked_mg)+'g 先入库;':'原锁金料此前已入库;'}${costs.extraMg?(value('extra_stock')==='receive'?'补重 '+grams(costs.extraMg)+'g 先入库;':value('extra_stock')==='stocked'?'补重金料此前已入库;':'请选择补重金料是否已入库;'):''}从「${pocketLabel(pocket)}」出库 ${grams(costs.finalMg)}g${pocketCountsEnabled(pocket)?' / '+stockCountText(Number(get('stockCount')?.value)||null):''}。${costs.leftoverMg?poolMode?'少重 '+grams(costs.leftoverMg)+'g 解除预留回到料池,实物留在货盘,不重复入库或扣料。':'余料 '+grams(costs.leftoverMg)+'g 留在该货盘,按原进货价计成本,不重复入库。':''}`:'选择本件实际货盘和金料入库情况后,显示库存动作。';
|
||||
priceLockPart(root,'stock-note').textContent=costs&&original&&pocket?`${poolMode?'原锁金料已在料池预留,不重复入库;':original==='receive'?'原锁 '+grams(item.locked_mg)+'g 先入库;':'原锁金料此前已入库;'}${costs.extraMg?(extraPooled?'补重从交付当日料池耗用,不重复入库;':value('extra_stock')==='receive'?'补重 '+grams(costs.extraMg)+'g 先入库;':value('extra_stock')==='stocked'?'补重金料此前已入库;':'请选择补重金料是否已入库;'):''}从「${pocketLabel(pocket)}」出库 ${grams(costs.finalMg)}g${pocketCountsEnabled(pocket)?' / '+stockCountText(Number(get('stockCount')?.value)||null):''}。${costs.leftoverMg?poolMode?'少重 '+grams(costs.leftoverMg)+'g 解除预留回到料池,实物留在货盘,不重复入库或扣料。':'余料 '+grams(costs.leftoverMg)+'g 留在该货盘,按原进货价计成本,不重复入库。':''}`:'选择本件实际货盘和金料入库情况后,显示库存动作。';
|
||||
});
|
||||
const feeDate=form.querySelector('[name="fees_date"]');feeDate.value=lockFormValue(form,'date');feeDate.readOnly=true;syncFeeRows();const d=collectPriceLockDelivery(),lines=d.lines||[d.line];
|
||||
const summary=$('#lock-delivery-summary');if(summary){if(allCosts.every(Boolean)){const sum=key=>allCosts.reduce((total,cost)=>total+cost[key],0);summary.textContent=`共 ${lines.length}件,实际交付 ${grams(sum('finalMg'))}g;耗用料费 ¥${yuan(sum('materialCost'))};补重 ${grams(sum('extraMg'))}g,新增料费 ¥${yuan(sum('extraCost'))};剩料/回池 ${grams(sum('leftoverMg'))}g,成本 ¥${yuan(sum('leftoverCost'))}。库存动作按各件所选货盘登记。`;}else summary.textContent='请逐件补齐最终克重和补重料价,再核对整单交付汇总。';}
|
||||
const summary=$('#lock-delivery-summary');if(summary){if(allCosts.every(Boolean)){const sum=key=>allCosts.reduce((total,cost)=>total+cost[key],0);summary.textContent=`共 ${lines.length}件,实际交付 ${grams(sum('finalMg'))}g;耗用料费 ¥${yuan(sum('materialCost'))};补重 ${grams(sum('extraMg'))}g,补重成本 ¥${yuan(sum('extraCost'))};剩料/回池 ${grams(sum('leftoverMg'))}g,成本 ¥${yuan(sum('leftoverCost'))}。库存动作按各件所选货盘登记。`;}else summary.textContent='请逐件补齐最终克重和补重料价,再核对整单交付汇总。';}
|
||||
let difference=null;
|
||||
try{
|
||||
const total=LedgerCalc.orderTotal(lines.map(line=>LedgerCalc.sale(line).sale),LedgerCalc.cents(d.discount),'yuan');difference=total.total-lock.netReceived;
|
||||
@@ -299,9 +321,9 @@ async function submitPriceLockForm(form){
|
||||
}else{
|
||||
const lock=currentPriceLock;if(!lock||form.dataset.id!==lock.id)throw new Error('请重新读取锁价单后办理交付。');data=collectPriceLockDelivery();url='/api/price-locks/'+encodeURIComponent(lock.id)+'/deliver';
|
||||
const locks=priceLockLines(lock),items=data.lines||[{...data.line,inventory:data.inventory,extraMaterial:data.extraMaterial}];if(items.length!==locks.length)throw new Error('请逐件填写全部锁价商品后整单交付。');
|
||||
const costs=items.map((line,index)=>{const item=locks[index];if(data.lines&&line.lineId!==item.id)throw new Error('交付商品与原锁记录不一致,请重新读取。');return priceLockDeliveryCost(item,line.quantity,line.extraMaterial?.rate);});
|
||||
const costs=items.map((line,index)=>{const item=locks[index];if(data.lines&&line.lineId!==item.id)throw new Error('交付商品与原锁记录不一致,请重新读取。');return priceLockDeliveryRowCost(item,line.quantity,line.extraMaterial,index,form);});
|
||||
validateIssueDraft({lines:items,fee_items:data.fee_items,discount:data.discount,rounding_mode:'yuan'},{requireIdentity:false});
|
||||
items.forEach((line,index)=>{if(pocketCountsEnabled(line.inventory.pocket)&&!['stocked','receive'].includes(line.inventory.countSource))throw new Error('请选择商品 '+(index+1)+' 的成品来源。');if(!state.pockets.includes(line.inventory.pocket)||!['receive','stocked'].includes(line.inventory.original))throw new Error(`请选择商品 ${index+1} 的实际出库货盘,并确认原锁金料是否已入库。`);if(costs[index].extraMg&&(!['receive','stocked'].includes(line.inventory.extra)||!['owner','assistant','assistant2'].includes(line.extraMaterial?.payer)||!line.extraMaterial?.verified))throw new Error(`请填写商品 ${index+1} 的补重料价、付款人、是否已入库,并确认实际付款。`);});
|
||||
items.forEach((line,index)=>{if(pocketCountsEnabled(line.inventory.pocket)&&!['stocked','receive'].includes(line.inventory.countSource))throw new Error('请选择商品 '+(index+1)+' 的成品来源。');if(!state.pockets.includes(line.inventory.pocket)||!['receive','stocked'].includes(line.inventory.original))throw new Error(`请选择商品 ${index+1} 的实际出库货盘,并确认原锁金料是否已入库。`);if(costs[index].extraMg&&line.extraMaterial?.source!=='pool'&&(!['receive','stocked'].includes(line.inventory.extra)||!['owner','assistant','assistant2'].includes(line.extraMaterial?.payer)||!line.extraMaterial?.verified))throw new Error(`请填写商品 ${index+1} 的补重料价、付款人、是否已入库,并确认实际付款。`);});
|
||||
const total=LedgerCalc.orderTotal(items.map(line=>LedgerCalc.sale(line).sale),LedgerCalc.cents(data.discount),'yuan'),difference=total.total-lock.netReceived;if(difference>0&&isCreditCardAccount(data.settlement.account)&&!creditCardAvailable())throw new Error('信用卡收款暂未准备好,请刷新后重新核对。');if(difference&&!data.settlement.verified)throw new Error('请先核实客户补款或退款已实际完成。');if(!data.verified)throw new Error('请核对各件实物、实际成本、库存来源与整单客户收付款后确认交付。');
|
||||
const actual=line=>({quantity:line.quantity,...(pocketCountsEnabled(line.inventory?.pocket||line.pocket)?{stockCount:stockCountValue(line.stockCount)}:{}),laborRate:line.laborRate,laborMode:line.laborMode,pieces:line.pieces,charges:line.charges,payer:line.payer,costParts:{labor:line.costParts.labor,accessories:line.costParts.accessories,other:line.costParts.other},costLabor:line.costLabor,costPayers:line.costPayers});
|
||||
if(data.lines)data.lines=items.map((line,index)=>({...actual(line),lineId:line.lineId,inventory:{pocket:line.inventory.pocket,original:line.inventory.original,...(pocketCountsEnabled(line.inventory.pocket)?{countSource:line.inventory.countSource}:{}),...(costs[index].extraMg?{extra:line.inventory.extra}:{})},...(costs[index].extraMg?{extraMaterial:line.extraMaterial}:{})}));
|
||||
|
||||
Reference in new issue
Block a user