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

Updates for PHP version requirements

This commit is contained in:
David Bomba 2024-05-26 07:57:05 +10:00
parent 98e1f160bb
commit 1ef97ef2bb
9 changed files with 174 additions and 440 deletions

View File

@ -1,23 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\DataMapper\EDoc;
use Spatie\LaravelData\Data;
class Fact1 extends Data
{
public string $sectorCode = 'SECTOR1';
public string $BankId = '';
public string $BankName = '';
public string $PaymentMeans = 'TP02';
}

View File

@ -1,29 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\DataMapper;
use Spatie\LaravelData\Data;
use Spatie\LaravelData\Optional;
use Invoiceninja\Einvoice\Models\FatturaPA\FatturaElettronica;
class EDocSettings extends Data
{
public FatturaElettronica|Optional $FatturaElettronica;
public function __construct() {}
public function createFatturaPA(): FatturaElettronica
{
return $this->FatturaElettronica ??= new FatturaElettronica;
}
}

View File

@ -41,7 +41,6 @@ use Illuminate\Database\Eloquent\Builder;
use League\Fractal\Serializer\JsonApiSerializer;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use Illuminate\Contracts\Container\BindingResolutionException;
use Invoiceninja\Einvoice\Decoder\Schema;
/**
* Class BaseController.
@ -997,8 +996,8 @@ class BaseController extends Controller
if(request()->has('einvoice')){
$ro = new Schema();
$response_data['einvoice_schema'] = $ro('FACT1');
// $ro = new Schema();
// $response_data['einvoice_schema'] = $ro('FACT1');
}

View File

@ -13,7 +13,6 @@ namespace App\Http\Controllers;
use App\Utils\Statics;
use Illuminate\Http\Response;
use Invoiceninja\Einvoice\Decoder\Schema;
class StaticController extends BaseController
{
@ -61,8 +60,9 @@ class StaticController extends BaseController
if(request()->has('einvoice')){
$schema = new Schema();
$response_data['einvoice_schema'] = $schema('FACT1');
// $schema = new Schema();
// $response_data['einvoice_schema'] = $schema('FACT1');
}
return response()->json($response_data, 200, ['Content-type' => 'application/json; charset=utf-8'], JSON_PRETTY_PRINT);

View File

@ -17,7 +17,6 @@ use App\Http\ValidationRules\Company\ValidSubdomain;
use App\Http\ValidationRules\ValidSettingsRule;
use App\Utils\Ninja;
use App\Utils\Traits\MakesHash;
use Invoiceninja\Einvoice\Models\FatturaPA\FatturaElettronica;
class UpdateCompanyRequest extends Request
{

View File

@ -39,6 +39,9 @@ use CleverIt\UBL\Invoice\FatturaPA\common\CessionarioCommittente;
use CleverIt\UBL\Invoice\FatturaPA\common\FatturaElettronicaBody;
use CleverIt\UBL\Invoice\FatturaPA\common\FatturaElettronicaHeader;
/**
* @deprecated not needed anylonger as we have invoiceninja/einvoice
*/
class FatturaPA extends AbstractService
{
private $xml;

View File

@ -105,8 +105,7 @@
"webpatser/laravel-countries": "dev-master#75992ad",
"wepay/php-sdk": "^0.3",
"wildbit/postmark-php": "^4.0",
"hyvor/php-json-exporter": "^0.0.3",
"invoiceninja/einvoice": "dev-main"
"hyvor/php-json-exporter": "^0.0.3"
},
"require-dev": {
"php": "^8.1|^8.2",

391
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "1356155e46e797b140685c105df97b8e",
"content-hash": "6904626bbe465492796c27cd86ad4d2c",
"packages": [
{
"name": "adrienrn/php-mimetyper",
@ -1385,16 +1385,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.308.1",
"version": "3.308.3",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "bf5f1221d4c5c67d3213150fb91dfb5ce627227b"
"reference": "7fa0625056fa1fcf6732f89ba37b3f630d78de59"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/bf5f1221d4c5c67d3213150fb91dfb5ce627227b",
"reference": "bf5f1221d4c5c67d3213150fb91dfb5ce627227b",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/7fa0625056fa1fcf6732f89ba37b3f630d78de59",
"reference": "7fa0625056fa1fcf6732f89ba37b3f630d78de59",
"shasum": ""
},
"require": {
@ -1474,9 +1474,9 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.308.1"
"source": "https://github.com/aws/aws-sdk-php/tree/3.308.3"
},
"time": "2024-05-22T18:05:56+00:00"
"time": "2024-05-24T18:29:40+00:00"
},
{
"name": "bacon/bacon-qr-code",
@ -4869,16 +4869,16 @@
},
{
"name": "imdhemy/laravel-purchases",
"version": "1.11.0",
"version": "1.12.0",
"source": {
"type": "git",
"url": "https://github.com/imdhemy/laravel-in-app-purchases.git",
"reference": "3c0031880dc0bbd39ec89eac61fc3d0f32580dec"
"reference": "bd7303d23a950aa8f4573d98498ce1e4c8b6664a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/imdhemy/laravel-in-app-purchases/zipball/3c0031880dc0bbd39ec89eac61fc3d0f32580dec",
"reference": "3c0031880dc0bbd39ec89eac61fc3d0f32580dec",
"url": "https://api.github.com/repos/imdhemy/laravel-in-app-purchases/zipball/bd7303d23a950aa8f4573d98498ce1e4c8b6664a",
"reference": "bd7303d23a950aa8f4573d98498ce1e4c8b6664a",
"shasum": ""
},
"require": {
@ -4934,7 +4934,7 @@
],
"support": {
"issues": "https://github.com/imdhemy/laravel-in-app-purchases/issues",
"source": "https://github.com/imdhemy/laravel-in-app-purchases/tree/1.11.0"
"source": "https://github.com/imdhemy/laravel-in-app-purchases/tree/1.12.0"
},
"funding": [
{
@ -4942,7 +4942,7 @@
"type": "github"
}
],
"time": "2024-05-12T19:06:24+00:00"
"time": "2024-05-25T12:18:29+00:00"
},
{
"name": "intervention/image",
@ -5028,57 +5028,6 @@
],
"time": "2022-05-21T17:30:32+00:00"
},
{
"name": "invoiceninja/einvoice",
"version": "dev-main",
"source": {
"type": "git",
"url": "https://github.com/invoiceninja/einvoice.git",
"reference": "757800fa89f845443ad1880c1ea7aa905d1043ea"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/invoiceninja/einvoice/zipball/757800fa89f845443ad1880c1ea7aa905d1043ea",
"reference": "757800fa89f845443ad1880c1ea7aa905d1043ea",
"shasum": ""
},
"require": {
"illuminate/collections": "^10.48",
"sabre/xml": "^4.0",
"symfony/property-access": "^6.4",
"symfony/serializer": "^6.4",
"symfony/validator": "^6.4"
},
"require-dev": {
"nesbot/carbon": "^2",
"nette/php-generator": "^4.1",
"phpstan/phpstan": "^1.11",
"phpunit/phpunit": "^10.5",
"symfony/console": "^6.4"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
"Invoiceninja\\Einvoice\\": "src/"
}
},
"license": [
"Elastic-2.0"
],
"authors": [
{
"name": "David Bomba",
"email": "turbo124@gmail.com"
}
],
"description": "Schema for einvoicing standards",
"support": {
"source": "https://github.com/invoiceninja/einvoice/tree/main",
"issues": "https://github.com/invoiceninja/einvoice/issues"
},
"time": "2024-05-22T07:45:24+00:00"
},
{
"name": "invoiceninja/inspector",
"version": "v2.0",
@ -6553,40 +6502,39 @@
},
{
"name": "league/csv",
"version": "9.15.0",
"version": "9.16.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/csv.git",
"reference": "fa7e2441c0bc9b2360f4314fd6c954f7ff40d435"
"reference": "998280c6c34bd67d8125fdc8b45bae28d761b440"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/csv/zipball/fa7e2441c0bc9b2360f4314fd6c954f7ff40d435",
"reference": "fa7e2441c0bc9b2360f4314fd6c954f7ff40d435",
"url": "https://api.github.com/repos/thephpleague/csv/zipball/998280c6c34bd67d8125fdc8b45bae28d761b440",
"reference": "998280c6c34bd67d8125fdc8b45bae28d761b440",
"shasum": ""
},
"require": {
"ext-filter": "*",
"ext-json": "*",
"ext-mbstring": "*",
"php": "^8.1.2"
},
"require-dev": {
"doctrine/collections": "^2.1.4",
"doctrine/collections": "^2.2.2",
"ext-dom": "*",
"ext-xdebug": "*",
"friendsofphp/php-cs-fixer": "^v3.22.0",
"friendsofphp/php-cs-fixer": "^3.57.1",
"phpbench/phpbench": "^1.2.15",
"phpstan/phpstan": "^1.10.57",
"phpstan/phpstan-deprecation-rules": "^1.1.4",
"phpstan/phpstan-phpunit": "^1.3.15",
"phpstan/phpstan-strict-rules": "^1.5.2",
"phpunit/phpunit": "^10.5.9",
"symfony/var-dumper": "^6.4.2"
"phpstan/phpstan": "^1.11.1",
"phpstan/phpstan-deprecation-rules": "^1.2.0",
"phpstan/phpstan-phpunit": "^1.4.0",
"phpstan/phpstan-strict-rules": "^1.6.0",
"phpunit/phpunit": "^10.5.16 || ^11.1.3",
"symfony/var-dumper": "^6.4.6 || ^7.0.7"
},
"suggest": {
"ext-dom": "Required to use the XMLConverter and the HTMLConverter classes",
"ext-iconv": "Needed to ease transcoding CSV using iconv stream filters"
"ext-iconv": "Needed to ease transcoding CSV using iconv stream filters",
"ext-mbstring": "Needed to ease transcoding CSV using mb stream filters"
},
"type": "library",
"extra": {
@ -6638,7 +6586,7 @@
"type": "github"
}
],
"time": "2024-02-20T20:00:00+00:00"
"time": "2024-05-24T11:04:54+00:00"
},
{
"name": "league/flysystem",
@ -14634,166 +14582,6 @@
],
"time": "2024-04-18T09:22:46+00:00"
},
{
"name": "symfony/property-access",
"version": "v6.4.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/property-access.git",
"reference": "9174e2ec62563dfc15fbe84d1618613092e09d91"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/property-access/zipball/9174e2ec62563dfc15fbe84d1618613092e09d91",
"reference": "9174e2ec62563dfc15fbe84d1618613092e09d91",
"shasum": ""
},
"require": {
"php": ">=8.1",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/property-info": "^5.4|^6.0|^7.0"
},
"require-dev": {
"symfony/cache": "^5.4|^6.0|^7.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\PropertyAccess\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides functions to read and write from/to an object or array using a simple string notation",
"homepage": "https://symfony.com",
"keywords": [
"access",
"array",
"extraction",
"index",
"injection",
"object",
"property",
"property-path",
"reflection"
],
"support": {
"source": "https://github.com/symfony/property-access/tree/v6.4.7"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-04-18T09:22:46+00:00"
},
{
"name": "symfony/property-info",
"version": "v6.4.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/property-info.git",
"reference": "42778ca731b8796e02e237008f4ed871361ddfce"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/property-info/zipball/42778ca731b8796e02e237008f4ed871361ddfce",
"reference": "42778ca731b8796e02e237008f4ed871361ddfce",
"shasum": ""
},
"require": {
"php": ">=8.1",
"symfony/string": "^5.4|^6.0|^7.0"
},
"conflict": {
"phpdocumentor/reflection-docblock": "<5.2",
"phpdocumentor/type-resolver": "<1.5.1",
"symfony/dependency-injection": "<5.4",
"symfony/serializer": "<6.4"
},
"require-dev": {
"phpdocumentor/reflection-docblock": "^5.2",
"phpstan/phpdoc-parser": "^1.0",
"symfony/cache": "^5.4|^6.0|^7.0",
"symfony/dependency-injection": "^5.4|^6.0|^7.0",
"symfony/serializer": "^6.4|^7.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\PropertyInfo\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Kévin Dunglas",
"email": "dunglas@gmail.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Extracts information about PHP class' properties using metadata of popular sources",
"homepage": "https://symfony.com",
"keywords": [
"doctrine",
"phpdoc",
"property",
"symfony",
"type",
"validator"
],
"support": {
"source": "https://github.com/symfony/property-info/tree/v6.4.7"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-04-28T10:28:08+00:00"
},
{
"name": "symfony/psr-http-message-bridge",
"version": "v2.3.1",
@ -14966,104 +14754,6 @@
],
"time": "2024-04-18T09:22:46+00:00"
},
{
"name": "symfony/serializer",
"version": "v6.4.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/serializer.git",
"reference": "73820ab43d12c2f29445080004054b0066082bf1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/serializer/zipball/73820ab43d12c2f29445080004054b0066082bf1",
"reference": "73820ab43d12c2f29445080004054b0066082bf1",
"shasum": ""
},
"require": {
"php": ">=8.1",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/polyfill-ctype": "~1.8"
},
"conflict": {
"doctrine/annotations": "<1.12",
"phpdocumentor/reflection-docblock": "<3.2.2",
"phpdocumentor/type-resolver": "<1.4.0",
"symfony/dependency-injection": "<5.4",
"symfony/property-access": "<5.4",
"symfony/property-info": "<5.4.24|>=6,<6.2.11",
"symfony/uid": "<5.4",
"symfony/validator": "<6.4",
"symfony/yaml": "<5.4"
},
"require-dev": {
"doctrine/annotations": "^1.12|^2",
"phpdocumentor/reflection-docblock": "^3.2|^4.0|^5.0",
"seld/jsonlint": "^1.10",
"symfony/cache": "^5.4|^6.0|^7.0",
"symfony/config": "^5.4|^6.0|^7.0",
"symfony/console": "^5.4|^6.0|^7.0",
"symfony/dependency-injection": "^5.4|^6.0|^7.0",
"symfony/error-handler": "^5.4|^6.0|^7.0",
"symfony/filesystem": "^5.4|^6.0|^7.0",
"symfony/form": "^5.4|^6.0|^7.0",
"symfony/http-foundation": "^5.4|^6.0|^7.0",
"symfony/http-kernel": "^5.4|^6.0|^7.0",
"symfony/messenger": "^5.4|^6.0|^7.0",
"symfony/mime": "^5.4|^6.0|^7.0",
"symfony/property-access": "^5.4.26|^6.3|^7.0",
"symfony/property-info": "^5.4.24|^6.2.11|^7.0",
"symfony/translation-contracts": "^2.5|^3",
"symfony/uid": "^5.4|^6.0|^7.0",
"symfony/validator": "^6.4|^7.0",
"symfony/var-dumper": "^5.4|^6.0|^7.0",
"symfony/var-exporter": "^5.4|^6.0|^7.0",
"symfony/yaml": "^5.4|^6.0|^7.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Serializer\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON.",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/serializer/tree/v6.4.7"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-04-23T09:00:49+00:00"
},
{
"name": "symfony/service-contracts",
"version": "v3.5.0",
@ -18163,16 +17853,16 @@
},
{
"name": "phpstan/phpstan",
"version": "1.11.1",
"version": "1.11.2",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "e524358f930e41a2b4cca1320e3b04fc26b39e0b"
"reference": "0d5d4294a70deb7547db655c47685d680e39cfec"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/e524358f930e41a2b4cca1320e3b04fc26b39e0b",
"reference": "e524358f930e41a2b4cca1320e3b04fc26b39e0b",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/0d5d4294a70deb7547db655c47685d680e39cfec",
"reference": "0d5d4294a70deb7547db655c47685d680e39cfec",
"shasum": ""
},
"require": {
@ -18217,7 +17907,7 @@
"type": "github"
}
],
"time": "2024-05-15T08:00:59+00:00"
"time": "2024-05-24T13:23:04+00:00"
},
{
"name": "phpunit/php-code-coverage",
@ -18942,16 +18632,16 @@
},
{
"name": "react/promise",
"version": "v3.1.0",
"version": "v3.2.0",
"source": {
"type": "git",
"url": "https://github.com/reactphp/promise.git",
"reference": "e563d55d1641de1dea9f5e84f3cccc66d2bfe02c"
"reference": "8a164643313c71354582dc850b42b33fa12a4b63"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/promise/zipball/e563d55d1641de1dea9f5e84f3cccc66d2bfe02c",
"reference": "e563d55d1641de1dea9f5e84f3cccc66d2bfe02c",
"url": "https://api.github.com/repos/reactphp/promise/zipball/8a164643313c71354582dc850b42b33fa12a4b63",
"reference": "8a164643313c71354582dc850b42b33fa12a4b63",
"shasum": ""
},
"require": {
@ -19003,7 +18693,7 @@
],
"support": {
"issues": "https://github.com/reactphp/promise/issues",
"source": "https://github.com/reactphp/promise/tree/v3.1.0"
"source": "https://github.com/reactphp/promise/tree/v3.2.0"
},
"funding": [
{
@ -19011,7 +18701,7 @@
"type": "open_collective"
}
],
"time": "2023-11-16T16:21:57+00:00"
"time": "2024-05-24T10:39:05+00:00"
},
{
"name": "react/socket",
@ -20649,8 +20339,7 @@
"minimum-stability": "dev",
"stability-flags": {
"socialiteproviders/apple": 20,
"webpatser/laravel-countries": 20,
"invoiceninja/einvoice": 20
"webpatser/laravel-countries": 20
},
"prefer-stable": true,
"prefer-lowest": false,

View File

@ -11,23 +11,24 @@
namespace Tests\Feature;
use Tests\TestCase;
use App\Models\User;
use App\Utils\Ninja;
use App\Models\Client;
use App\Models\Account;
use App\Models\Company;
use App\Models\Invoice;
use Tests\MockAccountData;
use App\Models\CompanyToken;
use App\Models\ClientContact;
use App\Jobs\Util\ReminderJob;
use Illuminate\Support\Carbon;
use App\Utils\Traits\MakesHash;
use App\DataMapper\CompanySettings;
use App\Factory\CompanyUserFactory;
use App\Jobs\Util\ReminderJob;
use App\Models\Account;
use App\Models\Client;
use App\Models\ClientContact;
use App\Models\Company;
use App\Models\CompanyToken;
use App\Models\Invoice;
use App\Models\User;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Support\Carbon;
use Tests\MockAccountData;
use Tests\TestCase;
use Illuminate\Foundation\Testing\DatabaseTransactions;
/**
* @test
@ -138,7 +139,8 @@ class ReminderTest extends TestCase
'is_primary' => 1,
'first_name' => 'john',
'last_name' => 'doe',
'email' => 'john@doe.com'
'email' => 'john@doe.com',
'send_email' => true,
]);
$this->invoice = Invoice::factory()->create([
@ -180,32 +182,127 @@ class ReminderTest extends TestCase
$settings->enable_reminder3 = true;
$settings->enable_reminder_endless = true;
$settings->schedule_reminder1 = 'after_invoice_date';
$settings->schedule_reminder2 = 'after_invoice_date';
$settings->schedule_reminder3 = 'after_invoice_date';
$settings->num_days_reminder1 = 5;
$settings->num_days_reminder1 = 10;
$settings->num_days_reminder1 = 15;
$settings->num_days_reminder2 = 10;
$settings->num_days_reminder3 = 15;
$settings->endless_reminder_frequency_id = '3';
$this->buildData($settings);
$this->travelTo(Carbon::parse('2024-03-01')->startOfDay());
$this->invoice->status_id = 1;
$this->invoice->amount = 10;
$this->invoice->balance = 10;
$this->invoice->next_send_date = null;
$this->invoice->date = '2024-03-01';
$this->invoice->last_sent_date = now();
$this->invoice->reminder_last_sent = null;
$this->invoice->save();
$invoice = Invoice::factory()->create([
'company_id' => $this->company->id,
'user_id' => $this->user->id,
'client_id' => $this->client->id,
'amount' => 10,
'balance' => 10,
'date' => '2024-03-01',
'number' => 'X-11-2024',
'due_date' => null,
'status_id' => 1,
'last_sent_date' => '2024-03-01',
]);
$this->invoice->service()->markSent()->save();
//baseline checks pass
$invoice->service()->createInvitations()->markSent()->save();
$this->assertGreaterThan(0, $invoice->balance);
$this->assertEquals(5, $this->invoice->company->settings->num_days_reminder1);
$this->assertEquals('2024-03-01', now()->format('Y-m-d'));
$this->assertEquals('2024-03-15', $invoice->due_date);
$this->assertEquals('2024-03-06', $invoice->next_send_date->format('Y-m-d'));
$this->assertEquals('2024-03-15', $this->invoice->due_date);
$this->assertTrue(
$invoice->client->getSetting('send_reminders') &&
(Ninja::isSelfHost() || $invoice->company->account->isPaidHostedClient())
);
// //day five: schedule send time 7am UTC
$this->travelTo(now()->addDays(5)->startOfDay());
$this->assertEquals('2024-03-06', now()->format('Y-m-d'));
$x = false;
do {
$this->travelTo(now()->addHour());
(new ReminderJob())->handle();
$invoice = $invoice->fresh();
$x = (bool)$invoice->reminder1_sent;
}
while($x === false);
$this->assertNotNull($invoice->reminder_last_sent);
//check next send date is on day "10"
$this->assertEquals(now()->addDays(5), $invoice->next_send_date);
$this->travelTo(now()->copy()->addDays(5)->startOfDay()->addHours(5));
$this->assertEquals('2024-03-11', now()->format('Y-m-d'));
$this->travelTo(now()->copy()->addHour());
(new ReminderJob())->handle();
$invoice = $invoice->fresh();
$this->assertGreaterThan(0, $invoice->balance);
$this->assertNull($invoice->reminder2_sent);
$this->travelTo(now()->copy()->addHour());
(new ReminderJob())->handle();
$invoice = $invoice->fresh();
$this->assertNotNull($invoice->reminder2_sent);
$this->assertEquals($invoice->reminder2_sent, $invoice->reminder_last_sent);
$this->assertEquals(now()->addDays(5), $invoice->next_send_date);
//check next send date is on day "15"
$this->assertEquals(now()->addDays(5), $invoice->next_send_date);
$this->travelTo(now()->copy()->addDays(5)->startOfDay()->addHours(5));
$this->assertEquals('2024-03-16', now()->format('Y-m-d'));
$this->travelTo(now()->copy()->addHour());
(new ReminderJob())->handle();
$invoice = $invoice->fresh();
$this->assertGreaterThan(0, $invoice->balance);
$this->assertNull($invoice->reminder3_sent);
$this->travelTo(now()->copy()->addHour());
(new ReminderJob())->handle();
$invoice = $invoice->fresh();
$this->assertNotNull($invoice->reminder3_sent);
$this->assertEquals($invoice->reminder3_sent, $invoice->reminder_last_sent);
//endless reminders
$this->assertEquals(now()->addDays(14), $invoice->next_send_date);
$this->travelTo(now()->addDays(14)->startOfDay());
$this->assertEquals('2024-03-30', now()->format('Y-m-d'));
$x = false;
do {
$this->travelTo(now()->addHour());
(new ReminderJob())->handle();
$invoice = $invoice->fresh();
$x = (bool)Carbon::parse($invoice->next_send_date)->gt(now()->addDays(2));
} while($x === false);
nlog($invoice->toArray());
$this->assertEquals(now()->addDays(14), $invoice->next_send_date);
}