Fixes for partial validation

This commit is contained in:
David Bomba 2023-09-25 07:34:10 +10:00
parent 96785e27bf
commit 2a40658222
3 changed files with 18 additions and 16 deletions

View File

@ -74,7 +74,7 @@ class StoreInvoiceRequest extends Request
$rules['tax_name3'] = 'bail|sometimes|string|nullable'; $rules['tax_name3'] = 'bail|sometimes|string|nullable';
$rules['exchange_rate'] = 'bail|sometimes|numeric'; $rules['exchange_rate'] = 'bail|sometimes|numeric';
$rules['partial'] = 'bail|sometimes|nullable|numeric'; $rules['partial'] = 'bail|sometimes|nullable|numeric';
$rules['partial_due_date'] = 'bail|sometimes|required_if:partial,>0|date'; $rules['partial_due_date'] = ['bail', 'sometimes', 'exclude_if:partial,0', Rule::requiredIf(fn () => $this->partial > 0), 'date'];
return $rules; return $rules;
} }

View File

@ -65,6 +65,8 @@ class UpdateInvoiceRequest extends Request
$rules['is_amount_discount'] = ['boolean']; $rules['is_amount_discount'] = ['boolean'];
nlog($this->partial);
$rules['line_items'] = 'array'; $rules['line_items'] = 'array';
$rules['discount'] = 'sometimes|numeric'; $rules['discount'] = 'sometimes|numeric';
$rules['project_id'] = ['bail', 'sometimes', new ValidProjectForClient($this->all())]; $rules['project_id'] = ['bail', 'sometimes', new ValidProjectForClient($this->all())];
@ -77,7 +79,7 @@ class UpdateInvoiceRequest extends Request
$rules['status_id'] = 'bail|sometimes|not_in:5'; //do not allow cancelled invoices to be modfified. $rules['status_id'] = 'bail|sometimes|not_in:5'; //do not allow cancelled invoices to be modfified.
$rules['exchange_rate'] = 'bail|sometimes|numeric'; $rules['exchange_rate'] = 'bail|sometimes|numeric';
$rules['partial'] = 'bail|sometimes|nullable|numeric'; $rules['partial'] = 'bail|sometimes|nullable|numeric';
$rules['partial_due_date'] = 'bail|sometimes|required_if:partial,>0|date'; $rules['partial_due_date'] = ['bail', 'sometimes', 'exclude_if:partial,0', Rule::requiredIf(fn () => $this->partial > 0), 'date'];
return $rules; return $rules;
} }

26
composer.lock generated
View File

@ -13804,16 +13804,16 @@
}, },
{ {
"name": "turbo124/beacon", "name": "turbo124/beacon",
"version": "v1.5.0", "version": "v1.5.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/turbo124/beacon.git", "url": "https://github.com/turbo124/beacon.git",
"reference": "ffc0a7b229129f6503fa699adaabc1d9f300e41c" "reference": "a737499198a3aff2d194d4f2a4c834257187d9b8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/turbo124/beacon/zipball/ffc0a7b229129f6503fa699adaabc1d9f300e41c", "url": "https://api.github.com/repos/turbo124/beacon/zipball/a737499198a3aff2d194d4f2a4c834257187d9b8",
"reference": "ffc0a7b229129f6503fa699adaabc1d9f300e41c", "reference": "a737499198a3aff2d194d4f2a4c834257187d9b8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -13860,9 +13860,9 @@
"turbo124" "turbo124"
], ],
"support": { "support": {
"source": "https://github.com/turbo124/beacon/tree/v1.5.0" "source": "https://github.com/turbo124/beacon/tree/v1.5.1"
}, },
"time": "2023-08-20T23:18:11+00:00" "time": "2023-09-24T07:20:04+00:00"
}, },
{ {
"name": "twig/twig", "name": "twig/twig",
@ -16827,16 +16827,16 @@
}, },
{ {
"name": "sebastian/exporter", "name": "sebastian/exporter",
"version": "5.1.0", "version": "5.1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git", "url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "c3fa8483f9539b190f7cd4bfc4a07631dd1df344" "reference": "64f51654862e0f5e318db7e9dcc2292c63cdbddc"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c3fa8483f9539b190f7cd4bfc4a07631dd1df344", "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/64f51654862e0f5e318db7e9dcc2292c63cdbddc",
"reference": "c3fa8483f9539b190f7cd4bfc4a07631dd1df344", "reference": "64f51654862e0f5e318db7e9dcc2292c63cdbddc",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -16850,7 +16850,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "5.0-dev" "dev-main": "5.1-dev"
} }
}, },
"autoload": { "autoload": {
@ -16893,7 +16893,7 @@
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/exporter/issues", "issues": "https://github.com/sebastianbergmann/exporter/issues",
"security": "https://github.com/sebastianbergmann/exporter/security/policy", "security": "https://github.com/sebastianbergmann/exporter/security/policy",
"source": "https://github.com/sebastianbergmann/exporter/tree/5.1.0" "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.1"
}, },
"funding": [ "funding": [
{ {
@ -16901,7 +16901,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2023-09-18T07:15:37+00:00" "time": "2023-09-24T13:22:09+00:00"
}, },
{ {
"name": "sebastian/global-state", "name": "sebastian/global-state",