1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00
invoiceninja/tests/Unit/GeneratesCounterTest.php

626 lines
23 KiB
PHP
Raw Normal View History

<?php
2020-09-14 13:11:46 +02:00
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
2020-09-14 13:11:46 +02:00
*
* @license https://www.elastic.co/licensing/elastic-license
2020-09-14 13:11:46 +02:00
*/
namespace Tests\Unit;
use Tests\TestCase;
use App\Models\Quote;
use App\Models\Client;
use App\Models\Credit;
use App\Models\Company;
use App\Models\Invoice;
2021-04-22 02:10:20 +02:00
use App\Models\Timezone;
use Tests\MockAccountData;
use App\Models\GroupSetting;
use App\Factory\ClientFactory;
use App\Factory\VendorFactory;
2019-05-27 13:54:27 +02:00
use App\Utils\Traits\MakesHash;
use App\Models\RecurringInvoice;
use App\DataMapper\ClientSettings;
use App\Utils\Traits\GeneratesCounter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Session;
use Illuminate\Foundation\Testing\DatabaseTransactions;
/**
2024-09-16 13:13:55 +02:00
*
* App\Utils\Traits\GeneratesCounter
*/
class GeneratesCounterTest extends TestCase
{
use GeneratesCounter;
use DatabaseTransactions;
2019-05-27 13:54:27 +02:00
use MakesHash;
use MockAccountData;
2023-09-26 00:22:21 +02:00
public $faker;
2024-08-22 08:57:52 +02:00
protected function setUp(): void
{
parent::setUp();
2019-05-27 13:54:27 +02:00
Session::start();
$this->faker = \Faker\Factory::create();
Model::reguard();
$this->makeTestData();
2019-05-27 13:54:27 +02:00
}
public function testResetCounterGroup()
{
$timezone = Timezone::find(1);
$date_formatted = now($timezone->name)->format('Ymd');
2024-08-22 08:57:52 +02:00
$gs = new GroupSetting();
$gs->name = 'Test';
$gs->company_id = $this->client->company_id;
$gs->settings = ClientSettings::buildClientSettings($this->company->settings, $this->client->settings);
$gs->save();
$this->client->group_settings_id = $gs->id;
$this->client->save();
$settings = $gs->settings;
// $settings = $this->client->settings;
$settings->invoice_number_pattern = '{$date:Ymd}-{$group_counter}';
2024-08-22 08:57:52 +02:00
$settings->timezone_id = 1;
$gs->settings = $settings;
$gs->save();
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0001', $invoice_number);
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0002', $invoice_number);
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0003', $invoice_number);
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0004', $invoice_number);
$settings->reset_counter_date = now($timezone->name)->format('Y-m-d');
$settings->reset_counter_frequency_id = RecurringInvoice::FREQUENCY_DAILY;
$gs->settings = $settings;
$gs->save();
$this->travel(5)->days();
$date_formatted = now($timezone->name)->format('Ymd');
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0001', $invoice_number);
$this->invoice->number = $invoice_number;
$this->invoice->save();
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0002', $invoice_number);
$settings->reset_counter_date = now($timezone->name)->format('Y-m-d');
$settings->reset_counter_frequency_id = RecurringInvoice::FREQUENCY_DAILY;
$gs->settings = $settings;
$gs->save();
$this->travel(5)->days();
$date_formatted = now($timezone->name)->format('Ymd');
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0001', $invoice_number);
$this->travelBack();
}
public function testResetCounterClient()
{
$timezone = Timezone::find(1);
$date_formatted = now($timezone->name)->format('Ymd');
$settings = $this->client->settings;
$settings->invoice_number_pattern = '{$date:Ymd}-{$client_counter}';
$settings->timezone_id = 1;
$this->client->settings = $settings;
$this->client->save();
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0001', $invoice_number);
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0002', $invoice_number);
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0003', $invoice_number);
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0004', $invoice_number);
$settings->reset_counter_date = now($timezone->name)->format('Y-m-d');
$settings->reset_counter_frequency_id = RecurringInvoice::FREQUENCY_DAILY;
$this->client->settings = $settings;
$this->client->save();
$this->travel(5)->days();
$date_formatted = now($timezone->name)->format('Ymd');
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0001', $invoice_number);
$this->invoice->number = $invoice_number;
$this->invoice->save();
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0002', $invoice_number);
$settings->reset_counter_date = now($timezone->name)->format('Y-m-d');
$settings->reset_counter_frequency_id = RecurringInvoice::FREQUENCY_DAILY;
$this->client->settings = $settings;
$this->client->save();
$this->travel(5)->days();
$date_formatted = now($timezone->name)->format('Ymd');
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0001', $invoice_number);
$this->travelBack();
}
2021-04-22 02:10:20 +02:00
public function testResetCounter()
{
$timezone = Timezone::find(1);
$date_formatted = now($timezone->name)->format('Ymd');
$settings = $this->company->settings;
$settings->invoice_number_pattern = '{$date:Ymd}-{$counter}';
$settings->timezone_id = 1;
$this->company->settings = $settings;
$this->company->save();
$this->client->settings = $settings;
$this->client->save();
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0001', $invoice_number);
2021-04-22 02:10:20 +02:00
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0002', $invoice_number);
2021-05-03 01:44:03 +02:00
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0003', $invoice_number);
2021-05-03 01:44:03 +02:00
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0004', $invoice_number);
2021-04-22 02:10:20 +02:00
$settings->reset_counter_date = now($timezone->name)->format('Y-m-d');
$settings->reset_counter_frequency_id = RecurringInvoice::FREQUENCY_DAILY;
$this->company->settings = $settings;
$this->company->save();
// $this->client->settings = $settings;
// $this->client->save();
2021-04-22 02:10:20 +02:00
$this->travel(5)->days();
$date_formatted = now($timezone->name)->format('Ymd');
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0001', $invoice_number);
2022-08-10 06:10:05 +02:00
$this->invoice->number = $invoice_number;
$this->invoice->save();
2021-05-03 01:44:03 +02:00
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0002', $invoice_number);
2021-05-03 01:44:03 +02:00
$settings->reset_counter_date = now($timezone->name)->format('Y-m-d');
$settings->reset_counter_frequency_id = RecurringInvoice::FREQUENCY_DAILY;
$this->company->settings = $settings;
$this->company->save();
$this->travel(5)->days();
$date_formatted = now($timezone->name)->format('Ymd');
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
$this->assertEquals($date_formatted.'-0001', $invoice_number);
2021-05-03 03:06:12 +02:00
$this->travelBack();
2021-04-22 02:10:20 +02:00
}
public function testHasSharedCounter()
2019-05-27 13:54:27 +02:00
{
$this->assertFalse($this->hasSharedCounter($this->client, ));
2019-05-27 13:54:27 +02:00
}
public function testHasTrueSharedCounter()
{
$settings = $this->client->getMergedSettings();
$settings->invoice_number_counter = 1;
$settings->invoice_number_pattern = '{$year}-{$counter}';
$settings->shared_invoice_quote_counter = 1;
$this->company->settings = $settings;
$this->company->save();
$this->client->settings = $settings;
$this->client->save();
$gs = $this->client->group_settings;
$gs->settings = $settings;
$gs->save();
$this->assertTrue($this->hasSharedCounter($this->client));
}
2021-04-10 04:01:36 +02:00
public function testNoCounterBeingSpecifiedInCounterStringStub()
{
$settings = $this->client->company->settings;
$settings->invoice_number_counter = 1;
$settings->invoice_number_pattern = 'test-{$counter}';
$settings->shared_invoice_quote_counter = 1;
$this->client->company->settings = $settings;
$this->client->company->save();
$this->client->settings = $settings;
$this->client->save();
$this->client->fresh();
$invoice_number = $this->getNextInvoiceNumber($this->client, $this->invoice);
$this->assertEquals('test-0001', $invoice_number);
}
public function testNoCounterBeingSpecifiedInCounterStringWithFix()
{
$settings = $this->client->company->settings;
$settings->invoice_number_counter = 100;
$settings->invoice_number_pattern = 'test-';
$settings->shared_invoice_quote_counter = 100;
$this->client->company->settings = $settings;
$this->client->company->save();
$this->client->settings = $settings;
$this->client->save();
$this->client->fresh();
$invoice_number = $this->getNextInvoiceNumber($this->client, $this->invoice);
$this->assertEquals('test-0100', $invoice_number);
}
2019-05-27 13:54:27 +02:00
public function testInvoiceNumberValue()
{
2021-07-03 06:37:06 +02:00
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
2019-05-27 13:54:27 +02:00
2021-07-14 02:31:07 +02:00
$this->assertEquals($invoice_number, '0002');
2021-07-03 06:37:06 +02:00
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
2019-05-27 13:54:27 +02:00
2022-10-02 03:24:49 +02:00
$this->assertEquals($invoice_number, '0003');
2019-05-27 13:54:27 +02:00
}
public function testQuoteNumberValue()
{
2021-10-17 05:21:13 +02:00
$quote = Quote::factory()->create([
'user_id' => $this->client->user_id,
'company_id' => $this->client->company_id,
'client_id' => $this->client->id,
2021-10-17 05:21:13 +02:00
]);
2021-07-03 05:47:15 +02:00
2021-10-17 05:21:13 +02:00
$quote_number = $this->getNextQuoteNumber($this->client->fresh(), $quote);
$this->assertEquals($quote_number, 0002);
}
2019-05-27 13:54:27 +02:00
public function testInvoiceNumberPattern()
{
$settings = $this->client->company->settings;
$settings->invoice_number_counter = 1;
2019-05-27 13:54:27 +02:00
$settings->invoice_number_pattern = '{$year}-{$counter}';
2024-01-01 08:04:23 +01:00
$settings->timezone_id = '31';
2019-05-27 13:54:27 +02:00
$this->client->company->settings = $settings;
$this->client->company->save();
$this->client->settings = $settings;
$this->client->save();
$this->client->fresh();
2020-10-07 01:16:57 +02:00
$invoice_number = $this->getNextInvoiceNumber($this->client, $this->invoice);
$invoice_number2 = $this->getNextInvoiceNumber($this->client, $this->invoice);
2019-05-27 13:54:27 +02:00
$this->assertEquals($invoice_number, date('Y').'-0001');
$this->assertEquals($invoice_number2, date('Y').'-0002');
$this->assertEquals($this->client->company->settings->invoice_number_counter, 3);
2019-05-27 13:54:27 +02:00
}
public function testQuoteNumberPattern()
{
$settings = $this->client->company->settings;
$settings->quote_number_counter = 1;
$settings->quote_number_pattern = '{$year}-{$counter}';
2024-01-01 08:04:23 +01:00
$settings->timezone_id = '31';
$this->client->company->settings = $settings;
$this->client->company->save();
$this->client->settings = $settings;
$this->client->save();
$this->client->fresh();
2021-10-17 05:21:13 +02:00
$quote = Quote::factory()->create([
'user_id' => $this->client->user_id,
'company_id' => $this->client->company_id,
'client_id' => $this->client->id,
2021-10-17 05:21:13 +02:00
]);
$quote_number = $this->getNextQuoteNumber($this->client, $quote);
$quote_number2 = $this->getNextQuoteNumber($this->client, $quote);
$this->assertEquals($quote_number, date('Y').'-0001');
$this->assertEquals($quote_number2, date('Y').'-0002');
$this->assertEquals($this->client->company->settings->quote_number_counter, 3);
}
public function testQuoteNumberPatternWithSharedCounter()
{
$settings = $this->client->company->settings;
$settings->quote_number_counter = 100;
$settings->invoice_number_counter = 1000;
$settings->quote_number_pattern = '{$year}-{$counter}';
$settings->shared_invoice_quote_counter = true;
2024-08-22 08:57:52 +02:00
$settings->timezone_id = '31';
2024-01-01 08:04:57 +01:00
$this->client->company->settings = $settings;
$this->client->company->save();
$gs = $this->client->group_settings;
$gs->settings = $settings;
$gs->save();
2021-10-17 05:21:13 +02:00
$quote = Quote::factory()->create([
'user_id' => $this->client->user_id,
'company_id' => $this->client->company_id,
'client_id' => $this->client->id,
2021-10-17 05:21:13 +02:00
]);
$quote_number = $this->getNextQuoteNumber($this->client, $quote);
$quote_number2 = $this->getNextQuoteNumber($this->client, $quote);
$this->assertEquals($quote_number, date('Y').'-1000');
$this->assertEquals($quote_number2, date('Y').'-1001');
$this->assertEquals($this->client->company->settings->quote_number_counter, 100);
}
2019-05-27 13:54:27 +02:00
public function testInvoiceClientNumberPattern()
{
$settings = $this->company->settings;
2020-11-23 22:53:51 +01:00
$settings->client_number_pattern = '{$year}-{$client_counter}';
$settings->client_number_counter = 10;
2019-05-27 13:54:27 +02:00
2024-08-22 08:57:52 +02:00
$settings->timezone_id = '31';
2024-01-01 08:04:57 +01:00
$this->company->settings = $settings;
$this->company->save();
2019-05-27 13:54:27 +02:00
$settings = $this->client->settings;
2020-11-23 22:53:51 +01:00
$settings->client_number_pattern = '{$year}-{$client_counter}';
$settings->client_number_counter = 10;
2019-05-27 13:54:27 +02:00
$this->client->settings = $settings;
$this->client->save();
$this->client->fresh();
2019-05-27 13:54:27 +02:00
$this->assertEquals($this->client->settings->client_number_counter, 10);
2020-11-23 22:53:51 +01:00
$this->assertEquals($this->client->getSetting('client_number_pattern'), '{$year}-{$client_counter}');
$invoice_number = $this->getNextClientNumber($this->client);
2019-05-27 13:54:27 +02:00
2022-08-10 06:10:05 +02:00
$this->assertEquals($invoice_number, date('Y').'-0010');
$this->client->number = $invoice_number;
$this->client->save();
$invoice_number = $this->getNextClientNumber($this->client);
2022-08-10 06:10:05 +02:00
$this->assertEquals($invoice_number, date('Y').'-0011');
}
2019-05-28 07:55:50 +02:00
public function testInvoicePadding()
{
$settings = $this->company->settings;
2019-05-28 07:55:50 +02:00
$settings->counter_padding = 5;
$settings->invoice_number_counter = 7;
//$this->client->settings = $settings;
2024-08-22 08:57:52 +02:00
$settings->timezone_id = '31';
2024-01-01 08:04:57 +01:00
$this->company->settings = $settings;
$this->company->save();
$cliz = ClientFactory::create($this->company->id, $this->user->id);
$cliz->settings = ClientSettings::defaults();
$cliz->save();
2020-10-07 01:16:57 +02:00
$invoice_number = $this->getNextInvoiceNumber($cliz, $this->invoice);
$this->assertEquals($cliz->getSetting('counter_padding'), 5);
$this->assertEquals($invoice_number, '00007');
2019-05-28 07:55:50 +02:00
$this->assertEquals(strlen($invoice_number), 5);
$settings = $this->company->settings;
2019-05-28 07:55:50 +02:00
$settings->counter_padding = 10;
$this->company->settings = $settings;
$this->company->save();
$cliz = ClientFactory::create($this->company->id, $this->user->id);
$cliz->settings = ClientSettings::defaults();
$cliz->save();
2019-05-28 07:55:50 +02:00
2020-10-07 01:16:57 +02:00
$invoice_number = $this->getNextInvoiceNumber($cliz, $this->invoice);
2019-05-28 07:55:50 +02:00
$this->assertEquals($cliz->getSetting('counter_padding'), 10);
2019-05-28 07:55:50 +02:00
$this->assertEquals(strlen($invoice_number), 10);
$this->assertEquals($invoice_number, '0000000007');
2019-05-28 07:55:50 +02:00
}
public function testInvoicePrefix()
{
$settings = $this->company->settings;
$this->company->settings = $settings;
$this->company->save();
2019-05-28 07:55:50 +02:00
$cliz = ClientFactory::create($this->company->id, $this->user->id);
$cliz->settings = ClientSettings::defaults();
$cliz->save();
2021-07-03 06:37:06 +02:00
$invoice_number = $this->getNextInvoiceNumber($cliz->fresh(), $this->invoice);
2021-07-14 02:31:07 +02:00
$this->assertEquals($invoice_number, '0002');
2019-05-28 07:55:50 +02:00
2021-07-03 06:37:06 +02:00
$invoice_number = $this->getNextInvoiceNumber($cliz->fresh(), $this->invoice);
2019-05-28 07:55:50 +02:00
2022-10-02 03:24:49 +02:00
$this->assertEquals($invoice_number, '0003');
2019-05-28 07:55:50 +02:00
}
public function testClientNumber()
{
$client_number = $this->getNextClientNumber($this->client);
$this->assertEquals($client_number, '0001');
2019-05-28 07:55:50 +02:00
$client_number = $this->getNextClientNumber($this->client);
$this->assertEquals($client_number, '0002');
2019-05-28 07:55:50 +02:00
}
public function testClientNumberPrefix()
{
$settings = $this->company->settings;
$this->company->settings = $settings;
$this->company->save();
2019-05-28 07:55:50 +02:00
$cliz = ClientFactory::create($this->company->id, $this->user->id);
$cliz->settings = ClientSettings::defaults();
$cliz->save();
$client_number = $this->getNextClientNumber($cliz);
$this->assertEquals($client_number, '0001');
2019-05-28 07:55:50 +02:00
$client_number = $this->getNextClientNumber($cliz);
2019-05-28 07:55:50 +02:00
$this->assertEquals($client_number, '0002');
2019-05-28 07:55:50 +02:00
}
public function testClientNumberPattern()
{
$settings = $this->company->settings;
2019-05-28 07:55:50 +02:00
$settings->client_number_pattern = '{$year}-{$user_id}-{$counter}';
2024-08-22 08:57:52 +02:00
$settings->timezone_id = '31';
2024-01-01 08:04:57 +01:00
$this->company->settings = $settings;
$this->company->save();
2019-05-28 07:55:50 +02:00
$cliz = ClientFactory::create($this->company->id, $this->user->id);
$cliz->settings = ClientSettings::defaults();
$cliz->save();
$client_number = $this->getNextClientNumber($cliz);
$this->assertEquals($client_number, date('Y').'-'.str_pad($this->client->user_id, 2, '0', STR_PAD_LEFT).'-0001');
2019-05-28 07:55:50 +02:00
$client_number = $this->getNextClientNumber($cliz);
$this->assertEquals($client_number, date('Y').'-'.str_pad($this->client->user_id, 2, '0', STR_PAD_LEFT).'-0002');
2019-05-27 13:54:27 +02:00
}
2020-09-23 02:16:19 +02:00
public function testVendorNumberPattern()
{
$settings = $this->company->settings;
$settings->vendor_number_pattern = '{$year}-{$user_id}-{$counter}';
2024-08-22 08:57:52 +02:00
$settings->timezone_id = '31';
2024-01-01 08:04:57 +01:00
2020-09-23 02:16:19 +02:00
$this->company->settings = $settings;
$this->company->save();
$vendor = VendorFactory::create($this->company->id, $this->user->id);
$vendor->save();
$vendor_number = $this->getNextVendorNumber($vendor);
$this->assertEquals($vendor_number, date('Y').'-'.str_pad($vendor->user_id, 2, '0', STR_PAD_LEFT).'-0001');
$vendor_number = $this->getNextVendorNumber($vendor);
$this->assertEquals($vendor_number, date('Y').'-'.str_pad($vendor->user_id, 2, '0', STR_PAD_LEFT).'-0002');
}
/*
public function testClientNextNumber()
{
$this->assertEquals($this->getNextNumber($this->client),1);
}
public function testRecurringInvoiceNumberPrefix()
{
//$this->assertEquals($this->getNextNumber(RecurringInvoice::class), 'R1');
$this->assertEquals($this->getCounter($this->client), 1);
}
public function testClientIncrementer()
{
$this->incrementCounter($this->client);
$this->assertEquals($this->getCounter($this->client), 2);
}
/*
public function testCounterValues()
{
$this->assertEquals($this->getCounter(Invoice::class), 1);
$this->assertEquals($this->getCounter(RecurringInvoice::class), 1);
$this->assertEquals($this->getCounter(Credit::class), 1);
}
public function testClassIncrementers()
{
$this->client->incrementCounter(Invoice::class);
$this->client->incrementCounter(RecurringInvoice::class);
$this->client->incrementCounter(Credit::class);
$this->assertEquals($this->getCounter(Invoice::class), 3);
$this->assertEquals($this->getCounter(RecurringInvoice::class), 3);
$this->assertEquals($this->getCounter(Credit::class), 2);
}
public function testClientNumberPattern()
{
$settings = $this->client->getSettingsByKey('client_number_pattern');
$settings->client_number_pattern = '{$year}-{$counter}';
$this->client->setSettingsByEntity(Client::class, $settings);
$company = Company::find($this->client->company_id);
$this->assertEquals($company->settings->client_number_counter,1);
$this->assertEquals($this->getNextNumber($this->client), date('y').'-1');
$this->assertEquals($this->getNextNumber($this->client), date('y').'-2');
$company = Company::find($this->client->company_id);
$this->assertEquals($company->settings->client_number_counter,2);
$this->assertEquals($this->client->settings->client_number_counter,1);
}
public function testClientNumberPatternWithDate()
{
date_default_timezone_set('US/Eastern');
$settings = $this->client->getSettingsByKey('client_number_pattern');
$settings->client_number_pattern = '{$date:j}-{$counter}';
$this->client->setSettingsByEntity(Client::class, $settings);
$this->assertEquals($this->getNextNumber($this->client), date('j') . '-1');
}
public function testClientNumberPatternWithDate2()
{
date_default_timezone_set('US/Eastern');
$settings = $this->client->getSettingsByKey('client_number_pattern');
$settings->client_number_pattern = '{$date:d M Y}-{$counter}';
$this->client->setSettingsByEntity(Client::class, $settings);
$this->assertEquals($this->getNextNumber($this->client), date('d M Y') . '-1');
}
*/
}