Skip to content

Commit

Permalink
fix(modifier): validate account IDs regardless of the operation
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Jun 7, 2024
1 parent 9d47251 commit 3e398b8
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions app/Controllers/ModifierController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,6 @@ protected static function makeCreateValidation(User $owner): Validation {
$individual_name = static::getIndividualName();
$table_name = static::getCollectiveName();

$validation->setRule("$individual_name.debit_account_id", "debit account", [
"required",
"is_natural_no_zero",
"ensure_ownership[".implode(",", [
AccountModel::class,
SEARCH_NORMALLY
])."]"
]);
$validation->setRule("$individual_name.credit_account_id", "credit account", [
"required",
"is_natural_no_zero",
"ensure_ownership[".implode(",", [
AccountModel::class,
SEARCH_NORMALLY
])."]"
]);
$validation->setRule("$individual_name.name", "name", [
"required",
"min_length[3]",
Expand Down Expand Up @@ -169,11 +153,28 @@ private static function makeValidation(): Validation {
$validation->setRule($individual_name, "modifier info", [
"required"
]);
$validation->setRule("$individual_name.debit_account_id", "debit account", [
"required",
"is_natural_no_zero",
"ensure_ownership[".implode(",", [
AccountModel::class,
SEARCH_NORMALLY
])."]"
]);
$validation->setRule("$individual_name.credit_account_id", "credit account", [
"required",
"is_natural_no_zero",
"ensure_ownership[".implode(",", [
AccountModel::class,
SEARCH_NORMALLY
])."]"
]);
$validation->setRule(
"$individual_name.debit_cash_flow_activity_id",
"debit cash flow activity", [
"permit_empty_if_column_value_matches[".implode(",", [
AccountModel::class,
"$individual_name.debit_account_id",
"kind",
LIQUID_ASSET_ACCOUNT_KIND
])."]",
Expand All @@ -189,6 +190,7 @@ private static function makeValidation(): Validation {
"credit cash flow activity", [
"permit_empty_if_column_value_matches[".implode(",", [
AccountModel::class,
"$individual_name.credit_account_id",
"kind",
LIQUID_ASSET_ACCOUNT_KIND
])."]",
Expand Down

0 comments on commit 3e398b8

Please sign in to comment.