🚀 مُصادَق: تحديث وتطوير النظام 2026-05-03 13:49
This commit is contained in:
@@ -18,34 +18,35 @@ final class TaxValidationTest extends TestCase
|
||||
|
||||
public function test_it_validates_standard_invoice(): void
|
||||
{
|
||||
$data = [
|
||||
'invoice_type' => '001', // Standard
|
||||
'total_tax_exclusive_amount' => 100,
|
||||
'total_tax_amount' => 16,
|
||||
'grand_total' => 116,
|
||||
'tax_items' => [
|
||||
['tax_percent' => 16, 'tax_amount' => 16, 'taxable_amount' => 100]
|
||||
]
|
||||
$invoice = [
|
||||
'invoice_number' => 'INV-001',
|
||||
'invoice_date' => date('Y-m-d'),
|
||||
'subtotal' => 100,
|
||||
'discount_total' => 0,
|
||||
'grand_total' => 116
|
||||
];
|
||||
$lines = [
|
||||
['line_number' => 1, 'quantity' => 1, 'unit_price' => 100, 'tax_rate' => 0.16, 'tax_amount' => 16, 'line_total' => 116]
|
||||
];
|
||||
|
||||
$result = $this->service->validate($data);
|
||||
$result = $this->service->validate($invoice, $lines);
|
||||
$this->assertTrue($result['is_valid']);
|
||||
}
|
||||
|
||||
public function test_it_detects_mismatching_totals(): void
|
||||
{
|
||||
$data = [
|
||||
'invoice_type' => '001',
|
||||
'total_tax_exclusive_amount' => 100,
|
||||
'total_tax_amount' => 16,
|
||||
'grand_total' => 110, // Error: should be 116
|
||||
'tax_items' => [
|
||||
['tax_percent' => 16, 'tax_amount' => 16, 'taxable_amount' => 100]
|
||||
]
|
||||
$invoice = [
|
||||
'invoice_number' => 'INV-002',
|
||||
'invoice_date' => date('Y-m-d'),
|
||||
'subtotal' => 100,
|
||||
'discount_total' => 0,
|
||||
'grand_total' => 110 // Mismatch
|
||||
];
|
||||
$lines = [
|
||||
['line_number' => 1, 'quantity' => 1, 'unit_price' => 100, 'tax_rate' => 0.16, 'tax_amount' => 16, 'line_total' => 116]
|
||||
];
|
||||
|
||||
$result = $this->service->validate($data);
|
||||
$result = $this->service->validate($invoice, $lines);
|
||||
$this->assertFalse($result['is_valid']);
|
||||
$this->assertContains('Grand total mismatch', $result['errors']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user