1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Merge branch 'v5-develop' of https://github.com/turbo124/invoiceninja into v5-develop

This commit is contained in:
David Bomba 2024-02-29 12:32:05 +11:00
commit f325aecaed
7 changed files with 48 additions and 12 deletions

View File

@ -1 +1 @@
5.8.30
5.8.31

View File

@ -277,7 +277,7 @@ class InvoiceItemSum
$item_tax += $item_tax_rate1_total;
if (strlen($this->item->tax_name1) > 2) {
if (strlen($this->item->tax_name1) > 1) {
$this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total);
}
@ -285,7 +285,7 @@ class InvoiceItemSum
$item_tax += $item_tax_rate2_total;
if (strlen($this->item->tax_name2) > 2) {
if (strlen($this->item->tax_name2) > 1) {
$this->groupTax($this->item->tax_name2, $this->item->tax_rate2, $item_tax_rate2_total);
}
@ -293,7 +293,7 @@ class InvoiceItemSum
$item_tax += $item_tax_rate3_total;
if (strlen($this->item->tax_name3) > 2) {
if (strlen($this->item->tax_name3) > 1) {
$this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total);
}

View File

@ -231,7 +231,7 @@ class InvoiceItemSumInclusive
/** @var float $item_tax */
$item_tax += $this->formatValue($item_tax_rate1_total, $this->currency->precision);
if (strlen($this->item->tax_name1) > 2) {
if (strlen($this->item->tax_name1) > 1) {
$this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total);
}
@ -239,7 +239,7 @@ class InvoiceItemSumInclusive
$item_tax += $this->formatValue($item_tax_rate2_total, $this->currency->precision);
if (strlen($this->item->tax_name2) > 2) {
if (strlen($this->item->tax_name2) > 1) {
$this->groupTax($this->item->tax_name2, $this->item->tax_rate2, $item_tax_rate2_total);
}
@ -247,7 +247,7 @@ class InvoiceItemSumInclusive
$item_tax += $this->formatValue($item_tax_rate3_total, $this->currency->precision);
if (strlen($this->item->tax_name3) > 2) {
if (strlen($this->item->tax_name3) > 1) {
$this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total);
}

View File

@ -340,8 +340,7 @@ class InvoiceSumInclusive
$this->total_taxes += $total_line_tax;
}
nlog($this->tax_map);
nlog($this->total_taxes);
return $this;
}

View File

@ -397,6 +397,7 @@ class HtmlEngine
$data['$credit.date'] = ['value' => $this->translateDate($this->entity->date, $this->client->date_format(), $this->client->locale()), 'label' => ctrans('texts.credit_date')];
$data['$balance'] = ['value' => Number::formatMoney($this->getBalance(), $this->client) ?: ' ', 'label' => ctrans('texts.balance')];
$data['$credit.balance'] = ['value' => Number::formatMoney($this->entity_calc->getBalance(), $this->client) ?: ' ', 'label' => ctrans('texts.credit_balance')];
$data['$client.credit_balance'] = &$data['$credit.balance'];
$data['$invoice.balance'] = &$data['$balance'];
$data['$taxes'] = ['value' => Number::formatMoney($this->entity_calc->getItemTotalTaxes(), $this->client) ?: ' ', 'label' => ctrans('texts.taxes')];

View File

@ -17,8 +17,8 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
'app_version' => env('APP_VERSION', '5.8.30'),
'app_tag' => env('APP_TAG', '5.8.30'),
'app_version' => env('APP_VERSION', '5.8.31'),
'app_tag' => env('APP_TAG', '5.8.31'),
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', false),

View File

@ -36,6 +36,42 @@ class InvoiceItemTest extends TestCase
}
public function testEdgeCasewithDiscountsPercentageAndTaxCalculations()
{
$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 = 0;
$invoice->tax_rate1 = 0;
$invoice->tax_rate2 = 0;
$invoice->tax_rate3 = 0;
$invoice->tax_name1 = '';
$invoice->tax_name2 = '';
$invoice->tax_name3 = '';
$line_items = [];
$line_item = new InvoiceItem;
$line_item->quantity = 1;
$line_item->cost = 100;
$line_item->tax_rate1 = 22;
$line_item->tax_name1 = 'Km';
$line_item->product_key = 'Test';
$line_item->notes = 'Test';
$line_item->is_amount_discount = false;
$line_items[] = $line_item;
$invoice->line_items = $line_items;
$invoice->save();
$invoice = $invoice->calc()->getInvoice();
$this->assertEquals(122, $invoice->amount);
$this->assertEquals(22, $invoice->total_taxes);
}
public function testDiscountsWithInclusiveTaxes()
{
$invoice = InvoiceFactory::create($this->company->id, $this->user->id);