Implementa registo e conferencia de pagamentos externos
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Supplier;
|
||||
use App\Services\InvoiceWorkflow;
|
||||
use App\Services\SupplierBankWorkflow;
|
||||
|
||||
require_once __DIR__.'/InvoiceFixture.php';
|
||||
|
||||
/** invoiceFixture enforces a synthetic, isolated test database. */
|
||||
function paymentFixture(): array
|
||||
{
|
||||
$f = invoiceFixture();
|
||||
auth()->guard()->setUser($f['validator']);
|
||||
app(InvoiceWorkflow::class)->validate($f['validator'], $f['invoice']);
|
||||
$supplier = Supplier::query()->findOrFail($f['order']->supplier_id);
|
||||
auth()->guard()->setUser($f['issuer']);
|
||||
$bankData = ['previous_id' => 0, 'bank_name' => 'Banco fictício', 'country' => 'MZ', 'currency' => 'MZN', 'beneficiary' => 'Titular de teste', 'account_identifier' => 'TEST-PAY-ACCOUNT', 'evidence_reference' => 'Evidência de teste', 'reason' => 'Somente teste isolado'];
|
||||
$bank = app(SupplierBankWorkflow::class)->propose($f['issuer'], $supplier, $bankData);
|
||||
foreach ([$f['author'], $f['validator']] as $reviewer) {
|
||||
auth()->guard()->setUser($reviewer);
|
||||
app(SupplierBankWorkflow::class)->review($reviewer, $bank, 'approved', 'Conferência de teste');
|
||||
}
|
||||
auth()->guard()->setUser($f['author']);
|
||||
$paymentData = ['supplier_bank_detail_id' => $bank->id, 'amount' => '40.00', 'paid_on' => today()->format('Y-m-d'), 'external_reference' => 'TEST-EXT-01', 'evidence_reference' => 'Evidência externa fictícia'];
|
||||
|
||||
return [...$f, 'supplier' => $supplier, 'bank' => $bank, 'bank_data' => $bankData, 'payment_data' => $paymentData];
|
||||
}
|
||||
Reference in New Issue
Block a user