diff --git a/app/Export/CSV/PurchaseOrderItemExport.php b/app/Export/CSV/PurchaseOrderItemExport.php index 9b55f78a4e..ec63f8388f 100644 --- a/app/Export/CSV/PurchaseOrderItemExport.php +++ b/app/Export/CSV/PurchaseOrderItemExport.php @@ -109,7 +109,7 @@ class PurchaseOrderItemExport extends BaseExport $transformed_purchase_order = $this->buildRow($purchase_order); $transformed_items = []; -nlog($purchase_order->toArray()); + foreach ($purchase_order->line_items as $item) { $item_array = []; diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index 3d419a66ae..57d26d43b9 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -198,7 +198,7 @@ class InvoiceItemSum private function push(): self { - $this->sub_total += $this->getLineTotal(); + $this->sub_total += round($this->getLineTotal(), $this->currency->precision); $this->gross_sub_total += $this->getGrossLineTotal(); diff --git a/app/Models/Scheduler.php b/app/Models/Scheduler.php index 76f17cf552..b3aa8bc9ab 100644 --- a/app/Models/Scheduler.php +++ b/app/Models/Scheduler.php @@ -168,7 +168,6 @@ class Scheduler extends BaseModel $next_run = null; } - $this->next_run_client = $next_run ?: null; $this->next_run = $next_run ? $next_run->copy()->addSeconds($offset) : null; $this->save(); diff --git a/tests/Feature/Scheduler/SchedulerTest.php b/tests/Feature/Scheduler/SchedulerTest.php index 6cafea26ef..80b3c77a17 100644 --- a/tests/Feature/Scheduler/SchedulerTest.php +++ b/tests/Feature/Scheduler/SchedulerTest.php @@ -19,15 +19,15 @@ use Tests\MockAccountData; use App\Utils\Traits\MakesHash; use App\Models\RecurringInvoice; use App\Factory\SchedulerFactory; +use App\Services\Scheduler\EmailReport; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Session; use App\DataMapper\Schedule\EmailStatement; use Illuminate\Validation\ValidationException; use Illuminate\Foundation\Testing\WithoutEvents; use App\Services\Scheduler\EmailStatementService; -use App\Services\Scheduler\EmailReport; -use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Routing\Middleware\ThrottleRequests; +use Illuminate\Foundation\Testing\DatabaseTransactions; /** * @test @@ -95,7 +95,7 @@ class SchedulerTest extends TestCase $data = [ 'name' => 'A test product sales scheduler', 'frequency_id' => RecurringInvoice::FREQUENCY_MONTHLY, - 'next_run' => now()->format('Y-m-d'), + 'next_run' => now()->startOfDay()->format('Y-m-d'), 'template' => 'email_report', 'parameters' => [ 'date_range' => EmailStatement::LAST_MONTH, @@ -132,8 +132,10 @@ class SchedulerTest extends TestCase $this->assertNotNull($scheduler); $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(); - $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(); - $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')); } diff --git a/tests/Unit/InvoiceTest.php b/tests/Unit/InvoiceTest.php index 6f189a4177..305e1e8670 100644 --- a/tests/Unit/InvoiceTest.php +++ b/tests/Unit/InvoiceTest.php @@ -107,7 +107,7 @@ class InvoiceTest extends TestCase $invoice = $invoice->calc()->getInvoice(); - $this->assertEquals(57.90, $invoice->amount); + $this->assertEquals(57.92, $invoice->amount); }