1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 00:41:34 +02:00

Merge pull request #8764 from turbo124/v5-develop

Adjustments for invoice calculations to support higher precision
This commit is contained in:
David Bomba 2023-08-31 15:17:35 +10:00 committed by GitHub
commit 56b7fb5978
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 10 deletions

View File

@ -109,7 +109,7 @@ class PurchaseOrderItemExport extends BaseExport
$transformed_purchase_order = $this->buildRow($purchase_order); $transformed_purchase_order = $this->buildRow($purchase_order);
$transformed_items = []; $transformed_items = [];
nlog($purchase_order->toArray());
foreach ($purchase_order->line_items as $item) { foreach ($purchase_order->line_items as $item) {
$item_array = []; $item_array = [];

View File

@ -198,7 +198,7 @@ class InvoiceItemSum
private function push(): self private function push(): self
{ {
$this->sub_total += $this->getLineTotal(); $this->sub_total += round($this->getLineTotal(), $this->currency->precision);
$this->gross_sub_total += $this->getGrossLineTotal(); $this->gross_sub_total += $this->getGrossLineTotal();

View File

@ -168,7 +168,6 @@ class Scheduler extends BaseModel
$next_run = null; $next_run = null;
} }
$this->next_run_client = $next_run ?: null; $this->next_run_client = $next_run ?: null;
$this->next_run = $next_run ? $next_run->copy()->addSeconds($offset) : null; $this->next_run = $next_run ? $next_run->copy()->addSeconds($offset) : null;
$this->save(); $this->save();

View File

@ -19,15 +19,15 @@ use Tests\MockAccountData;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use App\Models\RecurringInvoice; use App\Models\RecurringInvoice;
use App\Factory\SchedulerFactory; use App\Factory\SchedulerFactory;
use App\Services\Scheduler\EmailReport;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Session;
use App\DataMapper\Schedule\EmailStatement; use App\DataMapper\Schedule\EmailStatement;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
use Illuminate\Foundation\Testing\WithoutEvents; use Illuminate\Foundation\Testing\WithoutEvents;
use App\Services\Scheduler\EmailStatementService; use App\Services\Scheduler\EmailStatementService;
use App\Services\Scheduler\EmailReport;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Routing\Middleware\ThrottleRequests; use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Foundation\Testing\DatabaseTransactions;
/** /**
* @test * @test
@ -95,7 +95,7 @@ class SchedulerTest extends TestCase
$data = [ $data = [
'name' => 'A test product sales scheduler', 'name' => 'A test product sales scheduler',
'frequency_id' => RecurringInvoice::FREQUENCY_MONTHLY, 'frequency_id' => RecurringInvoice::FREQUENCY_MONTHLY,
'next_run' => now()->format('Y-m-d'), 'next_run' => now()->startOfDay()->format('Y-m-d'),
'template' => 'email_report', 'template' => 'email_report',
'parameters' => [ 'parameters' => [
'date_range' => EmailStatement::LAST_MONTH, 'date_range' => EmailStatement::LAST_MONTH,
@ -132,8 +132,10 @@ class SchedulerTest extends TestCase
$this->assertNotNull($scheduler); $this->assertNotNull($scheduler);
$export = (new EmailReport($scheduler))->run(); $export = (new EmailReport($scheduler))->run();
$this->assertEquals(now()->addMonth()->format('Y-m-d'), $scheduler->next_run->format('Y-m-d')); nlog($scheduler->fresh()->toArray());
$this->assertEquals(now()->startOfDay()->addMonthNoOverflow()->format('Y-m-d'), $scheduler->next_run->format('Y-m-d'));
} }
@ -179,7 +181,7 @@ class SchedulerTest extends TestCase
$export = (new EmailReport($scheduler))->run(); $export = (new EmailReport($scheduler))->run();
$this->assertEquals(now()->addMonth()->format('Y-m-d'), $scheduler->next_run->format('Y-m-d')); $this->assertEquals(now()->addMonthNoOverflow()->format('Y-m-d'), $scheduler->next_run->format('Y-m-d'));
} }
@ -222,7 +224,7 @@ class SchedulerTest extends TestCase
$export = (new EmailReport($scheduler))->run(); $export = (new EmailReport($scheduler))->run();
$this->assertEquals(now()->addMonth()->format('Y-m-d'), $scheduler->next_run->format('Y-m-d')); $this->assertEquals(now()->addMonthNoOverflow()->format('Y-m-d'), $scheduler->next_run->format('Y-m-d'));
} }

View File

@ -107,7 +107,7 @@ class InvoiceTest extends TestCase
$invoice = $invoice->calc()->getInvoice(); $invoice = $invoice->calc()->getInvoice();
$this->assertEquals(57.90, $invoice->amount); $this->assertEquals(57.92, $invoice->amount);
} }