mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge branch 'v5-develop' into laravel10
This commit is contained in:
commit
7c159321f6
5
.github/ISSUE_TEMPLATE/bug_report.md
vendored
5
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -14,6 +14,11 @@ https://invoiceninja.github.io/docs/self-host-troubleshooting/ -->
|
|||||||
- Version: <!-- i.e. v4.5.25 / v5.0.30 -->
|
- Version: <!-- i.e. v4.5.25 / v5.0.30 -->
|
||||||
- Environment: <!-- Docker/Shared Hosting/ZIP/Other -->
|
- Environment: <!-- Docker/Shared Hosting/ZIP/Other -->
|
||||||
|
|
||||||
|
## Interface
|
||||||
|
- Flutter: []
|
||||||
|
- React: []
|
||||||
|
- Both: []
|
||||||
|
|
||||||
## Checklist
|
## Checklist
|
||||||
- Can you replicate the issue on our v5 demo site https://demo.invoiceninja.com or https://react.invoicing.co/demo?
|
- Can you replicate the issue on our v5 demo site https://demo.invoiceninja.com or https://react.invoicing.co/demo?
|
||||||
- Have you searched existing issues?
|
- Have you searched existing issues?
|
||||||
|
@ -1 +1 @@
|
|||||||
5.7.5
|
5.7.6
|
@ -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 = [];
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
|
||||||
|
@ -1097,6 +1097,9 @@ class Import implements ShouldQueue
|
|||||||
$modified['user_id'] = $this->processUserId($resource);
|
$modified['user_id'] = $this->processUserId($resource);
|
||||||
$modified['company_id'] = $this->company->id;
|
$modified['company_id'] = $this->company->id;
|
||||||
$modified['line_items'] = $this->cleanItems($modified['line_items']);
|
$modified['line_items'] = $this->cleanItems($modified['line_items']);
|
||||||
|
|
||||||
|
//31/08-2023 set correct paid to date here:
|
||||||
|
$modified['paid_to_date'] = $modified['amount'] - $modified['balance'] ?? 0;
|
||||||
|
|
||||||
unset($modified['id']);
|
unset($modified['id']);
|
||||||
|
|
||||||
|
@ -54,13 +54,13 @@ class Backup extends BaseModel
|
|||||||
return $this->belongsTo(Activity::class);
|
return $this->belongsTo(Activity::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function storeRemotely(?string $html, Client $client)
|
public function storeRemotely(?string $html, Client | Vendor $client_or_vendor)
|
||||||
{
|
{
|
||||||
if (! $html || strlen($html) == 0) {
|
if (! $html || strlen($html) == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = $client->backup_path().'/';
|
$path = $client_or_vendor->backup_path().'/';
|
||||||
$filename = now()->format('Y_m_d').'_'.md5(time()).'.html';
|
$filename = now()->format('Y_m_d').'_'.md5(time()).'.html';
|
||||||
$file_path = $path.$filename;
|
$file_path = $path.$filename;
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
@ -274,4 +274,9 @@ class Vendor extends BaseModel
|
|||||||
{
|
{
|
||||||
return $this->company->date_format();
|
return $this->company->date_format();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function backup_path() :string
|
||||||
|
{
|
||||||
|
return $this->company->company_key.'/'.$this->vendor_hash.'/backups';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,21 +11,23 @@
|
|||||||
|
|
||||||
namespace App\Repositories;
|
namespace App\Repositories;
|
||||||
|
|
||||||
use App\Models\Activity;
|
use App\Models\User;
|
||||||
|
use App\Models\Quote;
|
||||||
use App\Models\Backup;
|
use App\Models\Backup;
|
||||||
use App\Models\CompanyToken;
|
|
||||||
use App\Models\Credit;
|
use App\Models\Credit;
|
||||||
use App\Models\Design;
|
use App\Models\Design;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Quote;
|
use App\Models\Activity;
|
||||||
|
use App\Utils\HtmlEngine;
|
||||||
|
use App\Models\CompanyToken;
|
||||||
|
use App\Models\PurchaseOrder;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
|
use App\Utils\VendorHtmlEngine;
|
||||||
use App\Models\RecurringInvoice;
|
use App\Models\RecurringInvoice;
|
||||||
use App\Models\User;
|
use App\Utils\Traits\MakesInvoiceHtml;
|
||||||
use App\Services\PdfMaker\Design as PdfDesignModel;
|
use App\Services\PdfMaker\Design as PdfDesignModel;
|
||||||
use App\Services\PdfMaker\Design as PdfMakerDesign;
|
use App\Services\PdfMaker\Design as PdfMakerDesign;
|
||||||
use App\Services\PdfMaker\PdfMaker as PdfMakerService;
|
use App\Services\PdfMaker\PdfMaker as PdfMakerService;
|
||||||
use App\Utils\HtmlEngine;
|
|
||||||
use App\Utils\Traits\MakesHash;
|
|
||||||
use App\Utils\Traits\MakesInvoiceHtml;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for activity repository.
|
* Class for activity repository.
|
||||||
@ -85,13 +87,30 @@ class ActivityRepository extends BaseRepository
|
|||||||
) {
|
) {
|
||||||
$backup = new Backup();
|
$backup = new Backup();
|
||||||
$entity->load('client');
|
$entity->load('client');
|
||||||
$contact = $entity->client->primary_contact()->first();
|
|
||||||
$backup->amount = $entity->amount;
|
$backup->amount = $entity->amount;
|
||||||
$backup->activity_id = $activity->id;
|
$backup->activity_id = $activity->id;
|
||||||
$backup->json_backup = '';
|
$backup->json_backup = '';
|
||||||
$backup->save();
|
$backup->save();
|
||||||
|
|
||||||
$backup->storeRemotely($this->generateHtml($entity), $entity->client);
|
$backup->storeRemotely($this->generateHtml($entity), $entity->client);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(get_class($entity) == PurchaseOrder::class)
|
||||||
|
{
|
||||||
|
|
||||||
|
$backup = new Backup();
|
||||||
|
$entity->load('client');
|
||||||
|
$backup->amount = $entity->amount;
|
||||||
|
$backup->activity_id = $activity->id;
|
||||||
|
$backup->json_backup = '';
|
||||||
|
$backup->save();
|
||||||
|
|
||||||
|
$backup->storeRemotely($this->generateVendorHtml($entity), $entity->vendor);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,6 +128,58 @@ class ActivityRepository extends BaseRepository
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function generateVendorHtml($entity)
|
||||||
|
{
|
||||||
|
$entity_design_id = $entity->design_id ? $entity->design_id : $this->decodePrimaryKey($entity->vendor->getSetting('purchase_order_design_id'));
|
||||||
|
|
||||||
|
$design = Design::withTrashed()->find($entity_design_id);
|
||||||
|
|
||||||
|
if (! $entity->invitations()->exists() || ! $design) {
|
||||||
|
nlog("No invitations for entity {$entity->id} - {$entity->number}");
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$entity->load('vendor.company', 'invitations');
|
||||||
|
|
||||||
|
$html = new VendorHtmlEngine($entity->invitations->first()->load('purchase_order', 'contact'));
|
||||||
|
|
||||||
|
if ($design->is_custom) {
|
||||||
|
$options = [
|
||||||
|
'custom_partials' => json_decode(json_encode($design->design), true),
|
||||||
|
];
|
||||||
|
$template = new PdfMakerDesign(PdfDesignModel::CUSTOM, $options);
|
||||||
|
} else {
|
||||||
|
$template = new PdfMakerDesign(strtolower($design->name));
|
||||||
|
}
|
||||||
|
|
||||||
|
$state = [
|
||||||
|
'template' => $template->elements([
|
||||||
|
'vendor' => $entity->vendor,
|
||||||
|
'entity' => $entity,
|
||||||
|
'pdf_variables' => (array) $entity->company->settings->pdf_variables,
|
||||||
|
'$product' => $design->design->product,
|
||||||
|
]),
|
||||||
|
'variables' => $html->generateLabelsAndValues(),
|
||||||
|
'options' => [
|
||||||
|
'all_pages_header' => $entity->vendor->getSetting('all_pages_header'),
|
||||||
|
'all_pages_footer' => $entity->vendor->getSetting('all_pages_footer'),
|
||||||
|
],
|
||||||
|
'process_markdown' => $entity->vendor->company->markdown_enabled,
|
||||||
|
];
|
||||||
|
|
||||||
|
$maker = new PdfMakerService($state);
|
||||||
|
|
||||||
|
$html = $maker->design($template)
|
||||||
|
->build()
|
||||||
|
->getCompiledHTML(true);
|
||||||
|
|
||||||
|
$maker = null;
|
||||||
|
$state = null;
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private function generateHtml($entity)
|
private function generateHtml($entity)
|
||||||
{
|
{
|
||||||
$entity_design_id = '';
|
$entity_design_id = '';
|
||||||
@ -128,8 +199,6 @@ class ActivityRepository extends BaseRepository
|
|||||||
$entity_design_id = 'credit_design_id';
|
$entity_design_id = 'credit_design_id';
|
||||||
}
|
}
|
||||||
|
|
||||||
// $entity->load('client.company');
|
|
||||||
|
|
||||||
$entity_design_id = $entity->design_id ? $entity->design_id : $this->decodePrimaryKey($entity->client->getSetting($entity_design_id));
|
$entity_design_id = $entity->design_id ? $entity->design_id : $this->decodePrimaryKey($entity->client->getSetting($entity_design_id));
|
||||||
|
|
||||||
$design = Design::withTrashed()->find($entity_design_id);
|
$design = Design::withTrashed()->find($entity_design_id);
|
||||||
|
61
app/Transformers/PurchaseOrderHistoryTransformer.php
Normal file
61
app/Transformers/PurchaseOrderHistoryTransformer.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Transformers;
|
||||||
|
|
||||||
|
use App\Models\Activity;
|
||||||
|
use App\Models\Backup;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
|
class PurchaseOrderHistoryTransformer extends EntityTransformer
|
||||||
|
{
|
||||||
|
use MakesHash;
|
||||||
|
|
||||||
|
protected $defaultIncludes = [
|
||||||
|
// 'activity',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $availableIncludes = [
|
||||||
|
'activity',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function transform(?Backup $backup)
|
||||||
|
{
|
||||||
|
if (! $backup) {
|
||||||
|
return [
|
||||||
|
'id' => '',
|
||||||
|
'activity_id' => '',
|
||||||
|
'json_backup' => (string) '',
|
||||||
|
'html_backup' => (string) '', //deprecated
|
||||||
|
'amount' => (float) 0,
|
||||||
|
'created_at' => (int) 0,
|
||||||
|
'updated_at' => (int) 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'id' => $this->encodePrimaryKey($backup->id),
|
||||||
|
'activity_id' => $this->encodePrimaryKey($backup->activity_id),
|
||||||
|
'json_backup' => (string) '',
|
||||||
|
'html_backup' => (string) '', //deprecated
|
||||||
|
'amount' => (float) $backup->amount,
|
||||||
|
'created_at' => (int) $backup->created_at,
|
||||||
|
'updated_at' => (int) $backup->updated_at,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function includeActivity(Backup $backup)
|
||||||
|
{
|
||||||
|
$transformer = new ActivityTransformer($this->serializer);
|
||||||
|
|
||||||
|
return $this->includeItem($backup->activity, $transformer, Activity::class);
|
||||||
|
}
|
||||||
|
}
|
@ -11,8 +11,10 @@
|
|||||||
|
|
||||||
namespace App\Transformers;
|
namespace App\Transformers;
|
||||||
|
|
||||||
|
use App\Models\Backup;
|
||||||
use App\Models\Vendor;
|
use App\Models\Vendor;
|
||||||
use App\Models\Expense;
|
use App\Models\Expense;
|
||||||
|
use App\Models\Activity;
|
||||||
use App\Models\Document;
|
use App\Models\Document;
|
||||||
use App\Models\PurchaseOrder;
|
use App\Models\PurchaseOrder;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
@ -30,8 +32,16 @@ class PurchaseOrderTransformer extends EntityTransformer
|
|||||||
protected array $availableIncludes = [
|
protected array $availableIncludes = [
|
||||||
'expense',
|
'expense',
|
||||||
'vendor',
|
'vendor',
|
||||||
|
'activities',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function includeActivities(PurchaseOrder $purchase_order)
|
||||||
|
{
|
||||||
|
$transformer = new ActivityTransformer($this->serializer);
|
||||||
|
|
||||||
|
return $this->includeCollection($purchase_order->activities, $transformer, Activity::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function includeInvitations(PurchaseOrder $purchase_order)
|
public function includeInvitations(PurchaseOrder $purchase_order)
|
||||||
{
|
{
|
||||||
$transformer = new PurchaseOrderInvitationTransformer($this->serializer);
|
$transformer = new PurchaseOrderInvitationTransformer($this->serializer);
|
||||||
@ -39,6 +49,12 @@ class PurchaseOrderTransformer extends EntityTransformer
|
|||||||
return $this->includeCollection($purchase_order->invitations, $transformer, PurchaseOrderInvitation::class);
|
return $this->includeCollection($purchase_order->invitations, $transformer, PurchaseOrderInvitation::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function includeHistory(PurchaseOrder $purchase_order)
|
||||||
|
{
|
||||||
|
$transformer = new PurchaseOrderHistoryTransformer($this->serializer);
|
||||||
|
|
||||||
|
return $this->includeCollection($purchase_order->history, $transformer, Backup::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function includeDocuments(PurchaseOrder $purchase_order)
|
public function includeDocuments(PurchaseOrder $purchase_order)
|
||||||
{
|
{
|
||||||
|
@ -15,8 +15,8 @@ return [
|
|||||||
'require_https' => env('REQUIRE_HTTPS', true),
|
'require_https' => env('REQUIRE_HTTPS', true),
|
||||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||||
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
||||||
'app_version' => env('APP_VERSION','5.7.5'),
|
'app_version' => env('APP_VERSION','5.7.6'),
|
||||||
'app_tag' => env('APP_TAG','5.7.5'),
|
'app_tag' => env('APP_TAG','5.7.6'),
|
||||||
'minimum_client_version' => '5.0.16',
|
'minimum_client_version' => '5.0.16',
|
||||||
'terms_version' => '1.0.1',
|
'terms_version' => '1.0.1',
|
||||||
'api_secret' => env('API_SECRET', ''),
|
'api_secret' => env('API_SECRET', ''),
|
||||||
|
@ -660,7 +660,7 @@ $LANG = array(
|
|||||||
'customize_help' => '<p>We use :pdfmake_link to define the invoice designs declaratively. The pdfmake :playground_link provides a great way to see the library in action.</p>
|
'customize_help' => '<p>We use :pdfmake_link to define the invoice designs declaratively. The pdfmake :playground_link provides a great way to see the library in action.</p>
|
||||||
<p>If you need help figuring something out post a question to our :forum_link with the design you\'re using.</p>',
|
<p>If you need help figuring something out post a question to our :forum_link with the design you\'re using.</p>',
|
||||||
'playground' => 'playground',
|
'playground' => 'playground',
|
||||||
'support_forum' => 'support forum',
|
'support_forum' => 'Support Forums',
|
||||||
'invoice_due_date' => 'Due Date',
|
'invoice_due_date' => 'Due Date',
|
||||||
'quote_due_date' => 'Valid Until',
|
'quote_due_date' => 'Valid Until',
|
||||||
'valid_until' => 'Valid Until',
|
'valid_until' => 'Valid Until',
|
||||||
|
@ -11,14 +11,20 @@
|
|||||||
|
|
||||||
namespace Tests\Feature;
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Tests\TestCase;
|
||||||
|
use App\Utils\Ninja;
|
||||||
|
use App\Models\Activity;
|
||||||
|
use Tests\MockAccountData;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use App\Models\PurchaseOrder;
|
use App\Models\PurchaseOrder;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
use Illuminate\Support\Facades\Session;
|
||||||
use Illuminate\Support\Str;
|
use App\Repositories\ActivityRepository;
|
||||||
use Tests\MockAccountData;
|
use App\Events\PurchaseOrder\PurchaseOrderWasCreated;
|
||||||
use Tests\TestCase;
|
use App\Events\PurchaseOrder\PurchaseOrderWasUpdated;
|
||||||
|
use App\Events\PurchaseOrder\PurchaseOrderWasAccepted;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
|
||||||
class PurchaseOrderTest extends TestCase
|
class PurchaseOrderTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -26,6 +32,8 @@ class PurchaseOrderTest extends TestCase
|
|||||||
use DatabaseTransactions;
|
use DatabaseTransactions;
|
||||||
use MockAccountData;
|
use MockAccountData;
|
||||||
|
|
||||||
|
public $faker;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@ -39,6 +47,37 @@ class PurchaseOrderTest extends TestCase
|
|||||||
$this->makeTestData();
|
$this->makeTestData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPurchaseOrderHistory()
|
||||||
|
{
|
||||||
|
event(new PurchaseOrderWasUpdated($this->purchase_order, $this->company, Ninja::eventVars($this->company, $this->user)));
|
||||||
|
event(new PurchaseOrderWasCreated($this->purchase_order, $this->company, Ninja::eventVars($this->company, $this->user)));
|
||||||
|
|
||||||
|
$ar = new ActivityRepository();
|
||||||
|
$fields = new \stdClass;
|
||||||
|
$fields->user_id = $this->purchase_order->user_id;
|
||||||
|
$fields->vendor_id = $this->purchase_order->vendor_id;
|
||||||
|
$fields->company_id = $this->purchase_order->company_id;
|
||||||
|
$fields->activity_type_id = Activity::UPDATE_PURCHASE_ORDER;
|
||||||
|
$fields->purchase_order_id = $this->purchase_order->id;
|
||||||
|
|
||||||
|
$ar->save($fields, $this->purchase_order, Ninja::eventVars($this->company, $this->user));
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->get("/api/v1/purchase_orders/{$this->purchase_order->hashed_id}?include=activities.history")
|
||||||
|
->assertStatus(200);
|
||||||
|
|
||||||
|
$arr = $response->json();
|
||||||
|
|
||||||
|
$activities = $arr['data']['activities'];
|
||||||
|
|
||||||
|
foreach($activities as $activity) {
|
||||||
|
$this->assertTrue(count($activity['history']) >= 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function testPurchaseOrderBulkActions()
|
public function testPurchaseOrderBulkActions()
|
||||||
{
|
{
|
||||||
$i = $this->purchase_order->invitations->first();
|
$i = $this->purchase_order->invitations->first();
|
||||||
@ -194,7 +233,7 @@ class PurchaseOrderTest extends TestCase
|
|||||||
|
|
||||||
$x = $purchase_order->service()->markSent()->getPurchaseOrderPdf();
|
$x = $purchase_order->service()->markSent()->getPurchaseOrderPdf();
|
||||||
|
|
||||||
nlog($x);
|
// nlog($x);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPurchaseOrderRest()
|
public function testPurchaseOrderRest()
|
||||||
|
@ -19,14 +19,14 @@ 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 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
|
||||||
@ -93,7 +93,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,
|
||||||
@ -130,8 +130,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'));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +179,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'));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +222,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'));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,6 +182,11 @@ trait MockAccountData
|
|||||||
*/
|
*/
|
||||||
public $scheduler;
|
public $scheduler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var
|
||||||
|
*/
|
||||||
|
public $purchase_order;
|
||||||
|
|
||||||
public $contact;
|
public $contact;
|
||||||
|
|
||||||
public $product;
|
public $product;
|
||||||
|
@ -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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,4 +41,19 @@ class RecurringDateTest extends TestCase
|
|||||||
|
|
||||||
$this->assertequals($trial_ends->format('Y-m-d'), '2021-12-03');
|
$this->assertequals($trial_ends->format('Y-m-d'), '2021-12-03');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDateOverflowsForEndOfMonth()
|
||||||
|
{
|
||||||
|
$today = Carbon::parse('2022-01-31');
|
||||||
|
|
||||||
|
$next_month = $today->addMonthNoOverflow();
|
||||||
|
|
||||||
|
$this->assertEquals('2022-02-28', $next_month->format('Y-m-d'));
|
||||||
|
|
||||||
|
// $next_month = $today->addMonthNoOverflow();
|
||||||
|
|
||||||
|
// $this->assertEquals('2022-03-31', $next_month->format('Y-m-d'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user