mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for calculations
This commit is contained in:
parent
232ec6364a
commit
635a7484aa
@ -178,6 +178,66 @@ class InvoiceItemTest extends TestCase
|
|||||||
$this->assertEquals(9, $invoice->total_taxes);
|
$this->assertEquals(9, $invoice->total_taxes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDicountsWithTaxesPercentageOnLine()
|
||||||
|
{
|
||||||
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id);
|
||||||
|
$invoice->client_id = $this->client->id;
|
||||||
|
$invoice->uses_inclusive_taxes = true;
|
||||||
|
$invoice->is_amount_discount =false;
|
||||||
|
$invoice->discount = 10;
|
||||||
|
|
||||||
|
$line_items = [];
|
||||||
|
|
||||||
|
$line_item = new InvoiceItem;
|
||||||
|
$line_item->quantity = 1;
|
||||||
|
$line_item->cost = 100;
|
||||||
|
$line_item->is_amount_discount = false;
|
||||||
|
$line_item->discount = 10;
|
||||||
|
$line_item->tax_rate1 = 10;
|
||||||
|
$line_item->tax_name1 = 'GST';
|
||||||
|
$line_item->product_key = 'Test';
|
||||||
|
$line_item->notes = 'Test';
|
||||||
|
$line_items[] = $line_item;
|
||||||
|
|
||||||
|
$invoice->line_items = $line_items;
|
||||||
|
$invoice->save();
|
||||||
|
|
||||||
|
$invoice = $invoice->calc()->getInvoice();
|
||||||
|
|
||||||
|
$this->assertEquals(81, $invoice->amount);
|
||||||
|
$this->assertEquals(7.36, $invoice->total_taxes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDicountsWithExclusiveTaxesPercentageOnLine()
|
||||||
|
{
|
||||||
|
$invoice = InvoiceFactory::create($this->company->id, $this->user->id);
|
||||||
|
$invoice->client_id = $this->client->id;
|
||||||
|
$invoice->uses_inclusive_taxes = false;
|
||||||
|
$invoice->is_amount_discount =false;
|
||||||
|
$invoice->discount = -10;
|
||||||
|
|
||||||
|
$line_items = [];
|
||||||
|
|
||||||
|
$line_item = new InvoiceItem;
|
||||||
|
$line_item->quantity = -1;
|
||||||
|
$line_item->cost = 100;
|
||||||
|
$line_item->is_amount_discount = false;
|
||||||
|
$line_item->discount = -10;
|
||||||
|
$line_item->tax_rate1 = 10;
|
||||||
|
$line_item->tax_name1 = 'GST';
|
||||||
|
$line_item->product_key = 'Test';
|
||||||
|
$line_item->notes = 'Test';
|
||||||
|
$line_items[] = $line_item;
|
||||||
|
|
||||||
|
$invoice->line_items = $line_items;
|
||||||
|
$invoice->save();
|
||||||
|
|
||||||
|
$invoice = $invoice->calc()->getInvoice();
|
||||||
|
|
||||||
|
$this->assertEquals(-133.1, $invoice->amount);
|
||||||
|
$this->assertEquals(-12.1, $invoice->total_taxes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testDicountsWithTaxesNegativeInvoicePercentage()
|
public function testDicountsWithTaxesNegativeInvoicePercentage()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user