commit melhorias compras1
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-21 21:04:40 +02:00
parent 976271f948
commit 12dd6df28a
108 changed files with 4391 additions and 408 deletions
+6 -4
View File
@@ -82,15 +82,17 @@ class ExternalPaymentWorkflow
$request = Requisition::query()->findOrFail($order->requisition_id);
app(ConflictGuard::class)->assertProcess($request, $order->supplier_id, $user);
$supplier = Supplier::query()->lockForUpdate()->findOrFail($order->supplier_id);
$bank = SupplierBankDetail::query()->where('supplier_id', $supplier->id)->latest('revision')->first();
$bank = SupplierBankDetail::query()->where('supplier_id', $supplier->id)->whereKey($bankId)->first();
$bankWorkflow = app(SupplierBankWorkflow::class);
if ($bank) {
User::query()->where('tenant_id', $user->tenant_id)->whereIn('id', SupplierBankReview::query()->where('supplier_bank_detail_id', $bank->id)->select('reviewed_by'))->orderBy('id')->lockForUpdate()->get();
}
if (! $bank || $bank->id !== $bankId || app(SupplierBankWorkflow::class)->state($supplier) !== 'approved') {
if (! $bank || $bankWorkflow->latest($supplier, $bank->account_key)?->id !== $bankId || $bankWorkflow->state($supplier, $bank->account_key) !== 'approved') {
$this->invalid('A versão bancária actual deve ter duas validações elegíveis. Actualize a ficha; não reutilize uma versão substituída.');
}
if ($bank->currency !== $order->currency || $order->currency !== 'MZN') {
$this->invalid('A moeda da conta deve coincidir com a factura. Câmbio não suportado.');
app(QuotationExchange::class)->orderAmounts($order, $order->subtotal_minor, $order->tax_minor);
if ($bank->currency !== $order->currency || ($invoice->snapshot['currency'] ?? 'MZN') !== $order->currency) {
$this->invalid('A moeda da conta deve coincidir com a factura e a ordem. Não é executada conversão bancária.');
}
return $bank;