From fa9b68063d9339208d4a74a4b9b51d5789ee309d Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 30 Apr 2017 16:16:48 +0300 Subject: [PATCH] Add default tax rates to check data --- app/Console/Commands/CheckData.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index f57c17cae355..d24ce1432e71 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -248,6 +248,7 @@ class CheckData extends Command ], 'products' => [ ENTITY_USER, + ENTITY_TAX_RATE, ], 'vendors' => [ ENTITY_USER, @@ -262,14 +263,28 @@ class CheckData extends Command ENTITY_USER, ENTITY_CLIENT, ], + 'accounts' => [ + ENTITY_TAX_RATE, + ] ]; foreach ($tables as $table => $entityTypes) { foreach ($entityTypes as $entityType) { $tableName = Utils::pluralizeEntityType($entityType); + if ($entityType == ENTITY_TAX_RATE) { + $field = 'default_' . $entityType; + } else { + $field = $entityType; + } + if ($table == 'accounts') { + $accountId = 'id'; + } else { + $accountId = 'account_id'; + } + $records = DB::table($table) - ->join($tableName, "{$tableName}.id", '=', "{$table}.{$entityType}_id") - ->where("{$table}.account_id", '!=', DB::raw("{$tableName}.account_id")) + ->join($tableName, "{$tableName}.id", '=', "{$table}.{$field}_id") + ->where("{$table}.{$accountId}", '!=', DB::raw("{$tableName}.account_id")) ->get(["{$table}.id"]); if (count($records)) {