|
1 | | -<?php |
2 | | - |
3 | | -use Brick\Money\Money; |
4 | | -use Finller\Invoice\PdfInvoiceItem; |
5 | | - |
6 | | -it('computes the right subTotalAmount', function ($unit_price, $quantity, $unit_tax, $expected) { |
7 | | - $item = new PdfInvoiceItem( |
8 | | - label: "Item 1", |
9 | | - unit_price: Money::of($unit_price, 'USD'), |
10 | | - quantity: $quantity, |
11 | | - unit_tax: Money::of($unit_tax, 'USD') |
12 | | - ); |
13 | | - |
14 | | - expect($item->subTotalAmount())->toCost($expected, 'USD'); |
15 | | -})->with([ |
16 | | - [110, 3, 10, 330], |
17 | | - [1567, 3, 209, 4701], |
18 | | - [578, 0, 468, 0], |
19 | | -]); |
20 | | - |
21 | | -it('computes the right totalTaxAmount with unit_tax', function ($unit_price, $quantity, $unit_tax, $expected) { |
22 | | - $item = new PdfInvoiceItem( |
23 | | - label: "Item 1", |
24 | | - unit_price: Money::of($unit_price, 'USD'), |
25 | | - quantity: $quantity, |
26 | | - unit_tax: Money::of($unit_tax, 'USD') |
27 | | - ); |
28 | | - |
29 | | - expect($item->totalTaxAmount())->toCost($expected, 'USD'); |
30 | | -})->with([ |
31 | | - [110, 3, 10, 30], |
32 | | - [1567, 3, 209, 627], |
33 | | - [578, 0, 468, 0], |
34 | | - [0, 10, 468, 4680], |
35 | | -]); |
36 | | - |
37 | | -it('computes the right totalTaxAmount with tax_percentage', function ($unit_price, $quantity, $tax_percentage, $expected) { |
38 | | - $item = new PdfInvoiceItem( |
39 | | - label: "Item 1", |
40 | | - unit_price: Money::of($unit_price, 'USD'), |
41 | | - quantity: $quantity, |
42 | | - tax_percentage: $tax_percentage |
43 | | - ); |
44 | | - |
45 | | - expect($item->totalTaxAmount())->toCost($expected, 'USD'); |
46 | | -})->with([ |
47 | | - [110, 3, 20, 66], |
48 | | - [1567, 3, 10, 470.1], |
49 | | - [578, 0, 30, 0], |
50 | | - [0, 10, 20, 0], |
51 | | - [6789, 10, 0, 0], |
52 | | -]); |
53 | | - |
54 | | -it('computes the right totalTaxAmount with unit_tax when both unit_tax and tax_percentage are defined', function ($unit_price, $quantity, $unit_tax, $tax_percentage, $expected) { |
55 | | - $item = new PdfInvoiceItem( |
56 | | - label: "Item 1", |
57 | | - unit_price: Money::of($unit_price, 'USD'), |
58 | | - quantity: $quantity, |
59 | | - tax_percentage: $tax_percentage, |
60 | | - unit_tax: Money::of($unit_tax, 'USD') |
61 | | - ); |
62 | | - |
63 | | - expect($item->totalTaxAmount())->toCost($expected, 'USD'); |
64 | | -})->with([ |
65 | | - [110, 3, 100, 20, 300], |
66 | | - [1567, 3, 30, 10, 90], |
67 | | - [578, 0, 10, 30, 0], |
68 | | - [0, 10, 50, 20, 500], |
69 | | - [6789, 10, 10, 0, 100], |
70 | | - [938, 10, 0, 20, 0], |
71 | | -]); |
| 1 | +<?php |
| 2 | + |
| 3 | +use Brick\Money\Money; |
| 4 | +use Finller\Invoice\PdfInvoiceItem; |
| 5 | + |
| 6 | +it('computes the right subTotalAmount', function ($unit_price, $quantity, $unit_tax, $expected) { |
| 7 | + $item = new PdfInvoiceItem( |
| 8 | + label: 'Item 1', |
| 9 | + unit_price: Money::of($unit_price, 'USD'), |
| 10 | + quantity: $quantity, |
| 11 | + unit_tax: Money::of($unit_tax, 'USD') |
| 12 | + ); |
| 13 | + |
| 14 | + expect($item->subTotalAmount())->toCost($expected, 'USD'); |
| 15 | +})->with([ |
| 16 | + [110, 3, 10, 330], |
| 17 | + [1567, 3, 209, 4701], |
| 18 | + [578, 0, 468, 0], |
| 19 | +]); |
| 20 | + |
| 21 | +it('computes the right totalTaxAmount with unit_tax', function ($unit_price, $quantity, $unit_tax, $expected) { |
| 22 | + $item = new PdfInvoiceItem( |
| 23 | + label: 'Item 1', |
| 24 | + unit_price: Money::of($unit_price, 'USD'), |
| 25 | + quantity: $quantity, |
| 26 | + unit_tax: Money::of($unit_tax, 'USD') |
| 27 | + ); |
| 28 | + |
| 29 | + expect($item->totalTaxAmount())->toCost($expected, 'USD'); |
| 30 | +})->with([ |
| 31 | + [110, 3, 10, 30], |
| 32 | + [1567, 3, 209, 627], |
| 33 | + [578, 0, 468, 0], |
| 34 | + [0, 10, 468, 4680], |
| 35 | +]); |
| 36 | + |
| 37 | +it('computes the right totalTaxAmount with tax_percentage', function ($unit_price, $quantity, $tax_percentage, $expected) { |
| 38 | + $item = new PdfInvoiceItem( |
| 39 | + label: 'Item 1', |
| 40 | + unit_price: Money::of($unit_price, 'USD'), |
| 41 | + quantity: $quantity, |
| 42 | + tax_percentage: $tax_percentage |
| 43 | + ); |
| 44 | + |
| 45 | + expect($item->totalTaxAmount())->toCost($expected, 'USD'); |
| 46 | +})->with([ |
| 47 | + [110, 3, 20, 66], |
| 48 | + [1567, 3, 10, 470.1], |
| 49 | + [578, 0, 30, 0], |
| 50 | + [0, 10, 20, 0], |
| 51 | + [6789, 10, 0, 0], |
| 52 | +]); |
| 53 | + |
| 54 | +it('computes the right totalTaxAmount with unit_tax when both unit_tax and tax_percentage are defined', function ($unit_price, $quantity, $unit_tax, $tax_percentage, $expected) { |
| 55 | + $item = new PdfInvoiceItem( |
| 56 | + label: 'Item 1', |
| 57 | + unit_price: Money::of($unit_price, 'USD'), |
| 58 | + quantity: $quantity, |
| 59 | + tax_percentage: $tax_percentage, |
| 60 | + unit_tax: Money::of($unit_tax, 'USD') |
| 61 | + ); |
| 62 | + |
| 63 | + expect($item->totalTaxAmount())->toCost($expected, 'USD'); |
| 64 | +})->with([ |
| 65 | + [110, 3, 100, 20, 300], |
| 66 | + [1567, 3, 30, 10, 90], |
| 67 | + [578, 0, 10, 30, 0], |
| 68 | + [0, 10, 50, 20, 500], |
| 69 | + [6789, 10, 10, 0, 100], |
| 70 | + [938, 10, 0, 20, 0], |
| 71 | +]); |
0 commit comments