mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Rappen Rounding
This commit is contained in:
parent
65a356c99f
commit
c0ffaca0eb
@ -246,8 +246,6 @@ class InvoiceSum
|
|||||||
|
|
||||||
if ($this->invoice->status_id != Invoice::STATUS_DRAFT) {
|
if ($this->invoice->status_id != Invoice::STATUS_DRAFT) {
|
||||||
if ($this->invoice->amount != $this->invoice->balance) {
|
if ($this->invoice->amount != $this->invoice->balance) {
|
||||||
// $paid_to_date = $this->invoice->amount - $this->invoice->balance;
|
|
||||||
|
|
||||||
$this->invoice->balance = Number::roundValue($this->getTotal(), $this->precision) - $this->invoice->paid_to_date; //21-02-2024 cannot use the calculated $paid_to_date here as it could send the balance backward.
|
$this->invoice->balance = Number::roundValue($this->getTotal(), $this->precision) - $this->invoice->paid_to_date; //21-02-2024 cannot use the calculated $paid_to_date here as it could send the balance backward.
|
||||||
} else {
|
} else {
|
||||||
$this->invoice->balance = Number::roundValue($this->getTotal(), $this->precision);
|
$this->invoice->balance = Number::roundValue($this->getTotal(), $this->precision);
|
||||||
@ -256,8 +254,10 @@ class InvoiceSum
|
|||||||
/* Set new calculated total */
|
/* Set new calculated total */
|
||||||
$this->invoice->amount = $this->formatValue($this->getTotal(), $this->precision);
|
$this->invoice->amount = $this->formatValue($this->getTotal(), $this->precision);
|
||||||
|
|
||||||
if($this->rappen_rounding)
|
if($this->rappen_rounding){
|
||||||
$this->invoice->amount = $this->roundRappen($this->invoice->amount);
|
$this->invoice->amount = $this->roundRappen($this->invoice->amount);
|
||||||
|
$this->invoice->balance = $this->roundRappen($this->invoice->balance);
|
||||||
|
}
|
||||||
|
|
||||||
$this->invoice->total_taxes = $this->getTotalTaxes();
|
$this->invoice->total_taxes = $this->getTotalTaxes();
|
||||||
|
|
||||||
|
@ -272,11 +272,11 @@ class InvoiceSumInclusive
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set new calculated total */
|
/* Set new calculated total */
|
||||||
/** @todo - rappen rounding here */
|
|
||||||
$this->invoice->amount = $this->formatValue($this->getTotal(), $this->precision);
|
$this->invoice->amount = $this->formatValue($this->getTotal(), $this->precision);
|
||||||
|
|
||||||
if($this->rappen_rounding) {
|
if($this->rappen_rounding) {
|
||||||
$this->invoice->amount = $this->roundRappen($this->invoice->amount);
|
$this->invoice->amount = $this->roundRappen($this->invoice->amount);
|
||||||
|
$this->invoice->balance = $this->roundRappen($this->invoice->balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->invoice->total_taxes = $this->getTotalTaxes();
|
$this->invoice->total_taxes = $this->getTotalTaxes();
|
||||||
|
@ -461,8 +461,8 @@ $lang = array(
|
|||||||
'delete_token' => 'Delete Token',
|
'delete_token' => 'Delete Token',
|
||||||
'token' => 'Token',
|
'token' => 'Token',
|
||||||
'add_gateway' => 'Add Payment Gateway',
|
'add_gateway' => 'Add Payment Gateway',
|
||||||
'delete_gateway' => 'Delete Gateway',
|
'delete_gateway' => 'Delete Payment Gateway',
|
||||||
'edit_gateway' => 'Edit Gateway',
|
'edit_gateway' => 'Edit Payment Gateway',
|
||||||
'updated_gateway' => 'Successfully updated gateway',
|
'updated_gateway' => 'Successfully updated gateway',
|
||||||
'created_gateway' => 'Successfully created gateway',
|
'created_gateway' => 'Successfully created gateway',
|
||||||
'deleted_gateway' => 'Successfully deleted gateway',
|
'deleted_gateway' => 'Successfully deleted gateway',
|
||||||
@ -5267,6 +5267,7 @@ $lang = array(
|
|||||||
'enable_rappen_roudning' => 'Enable Rappen Rounding',
|
'enable_rappen_roudning' => 'Enable Rappen Rounding',
|
||||||
'enable_rappen_rounding_help' => 'Rounds totals to nearest 5',
|
'enable_rappen_rounding_help' => 'Rounds totals to nearest 5',
|
||||||
'duration_words' => 'Duration in words',
|
'duration_words' => 'Duration in words',
|
||||||
|
'upcoming_recurring_invoices' => 'Upcoming Recurring Invoices',
|
||||||
);
|
);
|
||||||
|
|
||||||
return $lang;
|
return $lang;
|
||||||
|
@ -61,6 +61,8 @@ class InvoiceTest extends TestCase
|
|||||||
'settings' => $c_settings,
|
'settings' => $c_settings,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$this->assertEquals(0, $c->balance);
|
||||||
|
|
||||||
$item = InvoiceItemFactory::create();
|
$item = InvoiceItemFactory::create();
|
||||||
$item->quantity = 1;
|
$item->quantity = 1;
|
||||||
$item->cost = 10.01;
|
$item->cost = 10.01;
|
||||||
@ -88,6 +90,10 @@ class InvoiceTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(10, $ii->amount);
|
$this->assertEquals(10, $ii->amount);
|
||||||
|
|
||||||
|
$ii->service()->markSent()->save();
|
||||||
|
|
||||||
|
$this->assertEquals(10, $c->fresh()->balance);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRappenRoundingUp()
|
public function testRappenRoundingUp()
|
||||||
@ -129,6 +135,26 @@ class InvoiceTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(10.10, round($ii->amount,2));
|
$this->assertEquals(10.10, round($ii->amount,2));
|
||||||
|
|
||||||
|
$ii->service()->markSent()->save();
|
||||||
|
|
||||||
|
$this->assertEquals(10.10, $c->fresh()->balance);
|
||||||
|
|
||||||
|
$item = InvoiceItemFactory::create();
|
||||||
|
$item->quantity = 2;
|
||||||
|
$item->cost = 10.09;
|
||||||
|
$item->type_id = '1';
|
||||||
|
$item->tax_id = '1';
|
||||||
|
|
||||||
|
$i->line_items = [$item];
|
||||||
|
|
||||||
|
$invoice_calc = new InvoiceSum($i);
|
||||||
|
$ii = $invoice_calc->build()->getInvoice();
|
||||||
|
|
||||||
|
$ii->client->service()->calculateBalance($ii);
|
||||||
|
|
||||||
|
$this->assertEquals(20.20, round($ii->amount,2));
|
||||||
|
$this->assertEquals(20.20, round($ii->balance,2));
|
||||||
|
$this->assertEquals(20.20, round($c->fresh()->balance,2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPartialDueDateCast()
|
public function testPartialDueDateCast()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user