@@ -225,6 +225,14 @@ class OrderCancellationWorkflow
|
||||
abort_unless($distribution !== null, 503, 'Preserve a origem do compromisso.');
|
||||
$source['version'] = DB::table('budget_order_bindings')->where('tenant_id', $actor->tenant_id)->where('distribution_id', $distribution->id)->count();
|
||||
$source['plan_hash'] = json_decode($distribution->snapshot, true, 64, JSON_THROW_ON_ERROR)['plan_hash'];
|
||||
foreach ($source['allocations'] as &$row) {
|
||||
$current = DB::table('budget_order_allocations')->where('tenant_id', $actor->tenant_id)->where('distribution_id', $distribution->id)
|
||||
->where('order_key', $order->getAttribute('order_key'))->where('allocation_key', $row['allocation_key'])->whereIn('kind', ['commit', 'amend']);
|
||||
foreach (['subtotal_minor', 'total_minor'] as $field) {
|
||||
$row[$field] = (int) (clone $current)->sum($field);
|
||||
}
|
||||
}
|
||||
unset($row);
|
||||
}
|
||||
unset($source);
|
||||
$adapter = app(CommonBudget::class);
|
||||
|
||||
Reference in New Issue
Block a user