1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #4612 from turbo124/v5-develop

Fixes for recurring invoice ->copy() on null
This commit is contained in:
David Bomba 2021-01-03 18:08:42 +11:00 committed by GitHub
commit 7ee0e22978
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 42 deletions

View File

@ -29,7 +29,10 @@ class UpdateUserRequest extends Request
public function rules()
{
$input = $this->all();
$rules = [];
$rules = [
'password' => 'nullable|string|min:6',
];
if (isset($input['email'])) {
$rules['email'] = ['email:rfc,dns', 'sometimes', new UniqueUserRule($this->user, $input['email'])];

View File

@ -193,6 +193,8 @@ class RecurringInvoice extends BaseModel
}
switch ($this->frequency_id) {
case self::FREQUENCY_DAILY:
return Carbon::parse($this->next_send_date)->addDay();
case self::FREQUENCY_WEEKLY:
return Carbon::parse($this->next_send_date)->addWeek();
case self::FREQUENCY_TWO_WEEKS:
@ -223,6 +225,8 @@ class RecurringInvoice extends BaseModel
public function nextDateByFrequency($date)
{
switch ($this->frequency_id) {
case self::FREQUENCY_DAILY:
return Carbon::parse($date)->addDay();
case self::FREQUENCY_WEEKLY:
return Carbon::parse($date)->addWeek();
case self::FREQUENCY_TWO_WEEKS:
@ -369,12 +373,11 @@ class RecurringInvoice extends BaseModel
$data = [];
if(!$this->next_send_date)
if(!Carbon::parse($this->next_send_date))
return $data;
$next_send_date = Carbon::parse($this->next_send_date)->copy();
for ($x=0; $x<$iterations; $x++) {
// we don't add the days... we calc the day of the month!!
$next_due_date = $this->calculateDueDate($next_send_date->copy()->format('Y-m-d'));

View File

@ -18,6 +18,7 @@ use App\Models\User;
use App\Utils\Ninja;
use App\Utils\Traits\MakesHash;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
/**
* UserRepository.
@ -61,6 +62,12 @@ class UserRepository extends BaseRepository
$user->fill($details);
//allow users to change only their passwords - not others!
if(auth()->user()->id == $user->id && array_key_exists('password', $data) && isset($data['password']))
{
$user->password = Hash::make($data['password']);
}
if (!$user->confirmation_code) {
$user->confirmation_code = $this->createDbHash(config('database.default'));
}

View File

@ -628,21 +628,24 @@ trait GeneratesCounter
$replace[] = $entity->id_number;
}
if ($entity->client) {
if ($entity->client || ($entity instanceof Client)) {
$client = $entity->client ?: $entity;
$search[] = '{$client_custom1}';
$replace[] = $entity->client->custom_value1;
$replace[] = $client->custom_value1;
$search[] = '{$client_custom2}';
$replace[] = $entity->client->custom_value2;
$replace[] = $client->custom_value2;
$search[] = '{$client_custom3}';
$replace[] = $entity->client->custom_value3;
$replace[] = $client->custom_value3;
$search[] = '{$client_custom4}';
$replace[] = $entity->client->custom_value4;
$replace[] = $client->custom_value4;
$search[] = '{$client_id_number}';
$replace[] = $entity->client->id_number;
$replace[] = $client->id_number;
}
return str_replace($search, $replace, $pattern);

66
composer.lock generated
View File

@ -116,16 +116,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.171.6",
"version": "3.171.10",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "5587d22e63ef82ef74dffca5d47f307b84137b51"
"reference": "ba12cbba6b7ae8f2aab741e5ac47e8bb30d3eac7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/5587d22e63ef82ef74dffca5d47f307b84137b51",
"reference": "5587d22e63ef82ef74dffca5d47f307b84137b51",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/ba12cbba6b7ae8f2aab741e5ac47e8bb30d3eac7",
"reference": "ba12cbba6b7ae8f2aab741e5ac47e8bb30d3eac7",
"shasum": ""
},
"require": {
@ -200,22 +200,22 @@
"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.171.6"
"source": "https://github.com/aws/aws-sdk-php/tree/3.171.10"
},
"time": "2020-12-23T19:12:28+00:00"
"time": "2020-12-31T19:13:37+00:00"
},
{
"name": "beganovich/snappdf",
"version": "v1.2.0",
"version": "v1.3.0",
"source": {
"type": "git",
"url": "https://github.com/beganovich/snappdf.git",
"reference": "5f5e9bb17ddc9d9f16df7c20b7af35f04ffcddbd"
"reference": "1afb8d951461375eb334bb54e211b7e5724c9d10"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/beganovich/snappdf/zipball/5f5e9bb17ddc9d9f16df7c20b7af35f04ffcddbd",
"reference": "5f5e9bb17ddc9d9f16df7c20b7af35f04ffcddbd",
"url": "https://api.github.com/repos/beganovich/snappdf/zipball/1afb8d951461375eb334bb54e211b7e5724c9d10",
"reference": "1afb8d951461375eb334bb54e211b7e5724c9d10",
"shasum": ""
},
"require": {
@ -227,6 +227,7 @@
"symfony/process": "^5.2"
},
"require-dev": {
"ext-fileinfo": "*",
"friendsofphp/php-cs-fixer": "^2.17",
"phpunit/phpunit": "^9.5"
},
@ -252,9 +253,9 @@
"description": "Convert webpages or HTML into the PDF file using Chromium or Google Chrome.",
"support": {
"issues": "https://github.com/beganovich/snappdf/issues",
"source": "https://github.com/beganovich/snappdf/tree/v1.2.0"
"source": "https://github.com/beganovich/snappdf/tree/v1.3.0"
},
"time": "2020-12-28T11:57:06+00:00"
"time": "2021-01-02T17:56:16+00:00"
},
{
"name": "brick/math",
@ -1590,16 +1591,16 @@
},
{
"name": "egulias/email-validator",
"version": "2.1.24",
"version": "2.1.25",
"source": {
"type": "git",
"url": "https://github.com/egulias/EmailValidator.git",
"reference": "ca90a3291eee1538cd48ff25163240695bd95448"
"reference": "0dbf5d78455d4d6a41d186da50adc1122ec066f4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/egulias/EmailValidator/zipball/ca90a3291eee1538cd48ff25163240695bd95448",
"reference": "ca90a3291eee1538cd48ff25163240695bd95448",
"url": "https://api.github.com/repos/egulias/EmailValidator/zipball/0dbf5d78455d4d6a41d186da50adc1122ec066f4",
"reference": "0dbf5d78455d4d6a41d186da50adc1122ec066f4",
"shasum": ""
},
"require": {
@ -1646,7 +1647,7 @@
],
"support": {
"issues": "https://github.com/egulias/EmailValidator/issues",
"source": "https://github.com/egulias/EmailValidator/tree/2.1.24"
"source": "https://github.com/egulias/EmailValidator/tree/2.1.25"
},
"funding": [
{
@ -1654,7 +1655,7 @@
"type": "github"
}
],
"time": "2020-11-14T15:56:27+00:00"
"time": "2020-12-29T14:50:06+00:00"
},
{
"name": "fedeisas/laravel-mail-css-inliner",
@ -10323,16 +10324,16 @@
},
{
"name": "facade/ignition",
"version": "2.5.3",
"version": "2.5.8",
"source": {
"type": "git",
"url": "https://github.com/facade/ignition.git",
"reference": "d8dc4f90ed469f9f9313b976fb078c20585d5c99"
"reference": "8e907d81244649c5ea746e2ec30c32c5f59df472"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/facade/ignition/zipball/d8dc4f90ed469f9f9313b976fb078c20585d5c99",
"reference": "d8dc4f90ed469f9f9313b976fb078c20585d5c99",
"url": "https://api.github.com/repos/facade/ignition/zipball/8e907d81244649c5ea746e2ec30c32c5f59df472",
"reference": "8e907d81244649c5ea746e2ec30c32c5f59df472",
"shasum": ""
},
"require": {
@ -10396,7 +10397,7 @@
"issues": "https://github.com/facade/ignition/issues",
"source": "https://github.com/facade/ignition"
},
"time": "2020-12-09T20:25:45+00:00"
"time": "2020-12-29T09:12:55+00:00"
},
{
"name": "facade/ignition-contracts",
@ -13322,16 +13323,16 @@
},
{
"name": "vimeo/psalm",
"version": "4.3.1",
"version": "4.3.2",
"source": {
"type": "git",
"url": "https://github.com/vimeo/psalm.git",
"reference": "2feba22a005a18bf31d4c7b9bdb9252c73897476"
"reference": "57b53ff26237074fdf5cbcb034f7da5172be4524"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/vimeo/psalm/zipball/2feba22a005a18bf31d4c7b9bdb9252c73897476",
"reference": "2feba22a005a18bf31d4c7b9bdb9252c73897476",
"url": "https://api.github.com/repos/vimeo/psalm/zipball/57b53ff26237074fdf5cbcb034f7da5172be4524",
"reference": "57b53ff26237074fdf5cbcb034f7da5172be4524",
"shasum": ""
},
"require": {
@ -13363,15 +13364,14 @@
"require-dev": {
"amphp/amp": "^2.4.2",
"bamarni/composer-bin-plugin": "^1.2",
"brianium/paratest": "^4.0.0",
"brianium/paratest": "^4.0||^6.0",
"ext-curl": "*",
"php": "^7.3|^8",
"phpdocumentor/reflection-docblock": "^5",
"phpmyadmin/sql-parser": "5.1.0",
"phpmyadmin/sql-parser": "5.1.0||dev-master",
"phpspec/prophecy": ">=1.9.0",
"phpunit/phpunit": "^9.0",
"psalm/plugin-phpunit": "^0.13",
"slevomat/coding-standard": "^5.0",
"slevomat/coding-standard": "^6.3.11",
"squizlabs/php_codesniffer": "^3.5",
"symfony/process": "^4.3",
"weirdan/prophecy-shim": "^1.0 || ^2.0"
@ -13421,9 +13421,9 @@
],
"support": {
"issues": "https://github.com/vimeo/psalm/issues",
"source": "https://github.com/vimeo/psalm/tree/4.3.1"
"source": "https://github.com/vimeo/psalm/tree/4.3.2"
},
"time": "2020-12-03T16:44:10+00:00"
"time": "2020-12-29T17:37:09+00:00"
},
{
"name": "webmozart/path-util",