feat(payments): add customer ledgers and allocations (#744)

This commit is contained in:
Darko Gjorgjijoski
2026-08-05 03:28:35 +02:00
committed by GitHub
parent 8ae82ae91e
commit f322c2b74d
74 changed files with 5693 additions and 693 deletions
+15 -2
View File
@@ -3,6 +3,7 @@
use App\Http\Requests\InvoicesRequest;
use App\Models\Invoice;
use App\Models\InvoiceItem;
use App\Models\Payment;
use App\Models\Tax;
use App\Services\Document\DocumentItemService;
use App\Services\Document\InvoiceService;
@@ -30,9 +31,21 @@ test('invoice has many taxes', function () {
});
test('invoice has many payments', function () {
$invoice = Invoice::factory()->hasPayments(5)->create();
$invoice = Invoice::factory()->create();
$payments = Payment::factory()->count(5)->create([
'company_id' => $invoice->company_id,
'customer_id' => $invoice->customer_id,
'currency_id' => $invoice->currency_id,
]);
$this->assertCount(5, $invoice->payments);
foreach ($payments as $payment) {
$invoice->payments()->attach($payment->id, [
'amount' => $payment->amount,
'base_amount' => $payment->base_amount,
]);
}
$this->assertCount(5, $invoice->fresh()->payments);
$this->assertTrue($invoice->payments()->exists());
});