采购单优化
This commit is contained in:
@@ -17,8 +17,8 @@ use Illuminate\Support\Facades\DB;
|
||||
* 流程(事务内,可重复 build:先清后建):
|
||||
* 1. 按周期 + 品类(含子孙分类)+ 供应商拉取「已完成」门店订单的订货明细
|
||||
* 2. 每条订货明细 → 一条对账明细:
|
||||
* publish_amount = 订货金额(order_item.amount)
|
||||
* actual_amount = 采购成本(称重>0 ? 称重×单价 : 数量×单价,单价 = 成本/包规)
|
||||
* publish_amount = 订货金额(order_item.amount = 每包等级价×数量)
|
||||
* actual_amount = 采购成本(数量 × 每包成本价;单价/包规不参与金额计算)
|
||||
* diff = publish − actual,冗余 product_name / store_id
|
||||
* 3. 汇总写回头的 publish/actual/diff_amount,status → 对账中
|
||||
*/
|
||||
@@ -64,15 +64,7 @@ class ReconciliationBuildService
|
||||
$now = now();
|
||||
foreach ($orderItems as $orderItem) {
|
||||
$publish = (string) $orderItem->amount;
|
||||
$unitCost = PurchaseEditService::unitCost(
|
||||
(string) ($orderItem->cost_price ?? '0'),
|
||||
(string) $orderItem->product_spec
|
||||
);
|
||||
$actual = PurchaseEditService::costAmount(
|
||||
(string) $orderItem->quantity,
|
||||
(string) $orderItem->weight,
|
||||
$unitCost
|
||||
);
|
||||
$actual = bcmul((string) $orderItem->quantity, (string) ($orderItem->cost_price ?? '0'), 2);
|
||||
$publishTotal = bcadd($publishTotal, $publish, 2);
|
||||
$actualTotal = bcadd($actualTotal, $actual, 2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user