Catch errors in database table create statements.

This commit is contained in:
James Cole
2023-04-07 18:21:12 +02:00
parent 40e2bf7cac
commit dd11f98be7
34 changed files with 1386 additions and 1039 deletions

View File

@@ -78,7 +78,7 @@ class NetWorth implements NetWorthInterface
$netWorth = [];
$result = [];
// Log::debug(sprintf('Now in getNetWorthByCurrency(%s)', $date->format('Y-m-d')));
// Log::debug(sprintf('Now in getNetWorthByCurrency(%s)', $date->format('Y-m-d')));
// get default currency
$default = app('amount')->getDefaultCurrencyByUser($this->user);
@@ -89,11 +89,11 @@ class NetWorth implements NetWorthInterface
// get the preferred currency for this account
/** @var Account $account */
foreach ($accounts as $account) {
// Log::debug(sprintf('Now at account #%d: "%s"', $account->id, $account->name));
// Log::debug(sprintf('Now at account #%d: "%s"', $account->id, $account->name));
$currencyId = (int)$this->accountRepository->getMetaValue($account, 'currency_id');
$currencyId = 0 === $currencyId ? $default->id : $currencyId;
// Log::debug(sprintf('Currency ID is #%d', $currencyId));
// Log::debug(sprintf('Currency ID is #%d', $currencyId));
// balance in array:
$balance = $balances[$account->id] ?? '0';
@@ -106,13 +106,13 @@ class NetWorth implements NetWorthInterface
$balance = bcsub($balance, $virtualBalance);
}
// Log::debug(sprintf('Balance corrected to %s because of virtual balance (%s)', $balance, $virtualBalance));
// Log::debug(sprintf('Balance corrected to %s because of virtual balance (%s)', $balance, $virtualBalance));
if (!array_key_exists($currencyId, $netWorth)) {
$netWorth[$currencyId] = '0';
}
$netWorth[$currencyId] = bcadd($balance, $netWorth[$currencyId]);
// Log::debug(sprintf('Total net worth for currency #%d is %s', $currencyId, $netWorth[$currencyId]));
// Log::debug(sprintf('Total net worth for currency #%d is %s', $currencyId, $netWorth[$currencyId]));
}
ksort($netWorth);

View File

@@ -263,9 +263,9 @@ class OperatorQuerySearch implements SearchInterface
Log::info(sprintf('Ignore search operator "%s"', $operator));
return false;
//
//
// all account related searches:
//
//
case 'account_is':
$this->searchAccount($value, 3, 4);
break;
@@ -496,9 +496,9 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->findNothing();
}
break;
//
//
// cash account
//
//
case 'source_is_cash':
$account = $this->getCashAccount();
$this->collector->setSourceAccounts(new Collection([$account]));
@@ -523,9 +523,9 @@ class OperatorQuerySearch implements SearchInterface
$account = $this->getCashAccount();
$this->collector->excludeAccounts(new Collection([$account]));
break;
//
//
// description
//
//
case 'description_starts':
$this->collector->descriptionStarts([$value]);
break;
@@ -552,9 +552,9 @@ class OperatorQuerySearch implements SearchInterface
case '-description_is':
$this->collector->descriptionIsNot($value);
break;
//
//
// currency
//
//
case 'currency_is':
$currency = $this->findCurrency($value);
if (null !== $currency) {
@@ -591,9 +591,9 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->findNothing();
}
break;
//
//
// attachments
//
//
case 'has_attachments':
case '-has_no_attachments':
Log::debug('Set collector to filter on attachments.');
@@ -604,7 +604,7 @@ class OperatorQuerySearch implements SearchInterface
Log::debug('Set collector to filter on NO attachments.');
$this->collector->hasNoAttachments();
break;
//
//
// categories
case '-has_any_category':
case 'has_no_category':
@@ -683,9 +683,9 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->findNothing();
}
break;
//
//
// budgets
//
//
case '-has_any_budget':
case 'has_no_budget':
$this->collector->withoutBudget();
@@ -764,9 +764,9 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->findNothing();
}
break;
//
//
// bill
//
//
case '-has_any_bill':
case 'has_no_bill':
$this->collector->withoutBill();
@@ -843,9 +843,9 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->findNothing();
}
break;
//
//
// tags
//
//
case '-has_any_tag':
case 'has_no_tag':
$this->collector->withoutTags();
@@ -873,9 +873,9 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->setWithoutSpecificTags($result);
}
break;
//
//
// notes
//
//
case 'notes_contains':
$this->collector->notesContain($value);
break;
@@ -914,9 +914,9 @@ class OperatorQuerySearch implements SearchInterface
case '-reconciled':
$this->collector->isNotReconciled();
break;
//
//
// amount
//
//
case 'amount_is':
// strip comma's, make dots.
Log::debug(sprintf('Original value "%s"', $value));
@@ -987,9 +987,9 @@ class OperatorQuerySearch implements SearchInterface
Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $amount));
$this->collector->foreignAmountMore($amount);
break;
//
//
// transaction type
//
//
case 'transaction_type':
$this->collector->setTypes([ucfirst($value)]);
Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value));
@@ -998,9 +998,9 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->excludeTypes([ucfirst($value)]);
Log::debug(sprintf('Set "%s" using collector with value "%s"', $operator, $value));
break;
//
//
// dates
//
//
case '-date_on':
case 'date_on':
$range = $this->parseDateRange($value);
@@ -1150,9 +1150,9 @@ class OperatorQuerySearch implements SearchInterface
$range = $this->parseDateRange($value);
$this->setObjectDateAfterParams('updated_at', $range);
return false;
//
//
// external URL
//
//
case '-any_external_url':
case 'no_external_url':
$this->collector->withoutExternalUrl();
@@ -1195,9 +1195,9 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->externalUrlDoesNotEnd($value);
break;
//
//
// other fields
//
//
case 'external_id_is':
$this->collector->setExternalId($value);
break;

View File

@@ -67,11 +67,11 @@ class BudgetLimitTransformer extends AbstractTransformer
*/
public function transform(BudgetLimit $budgetLimit): array
{
// $repository = app(OperationsRepository::class);
// $repository->setUser($budgetLimit->budget->user);
// $expenses = $repository->sumExpenses(
// $budgetLimit->start_date, $budgetLimit->end_date, null, new Collection([$budgetLimit->budget]), $budgetLimit->transactionCurrency
// );
// $repository = app(OperationsRepository::class);
// $repository->setUser($budgetLimit->budget->user);
// $expenses = $repository->sumExpenses(
// $budgetLimit->start_date, $budgetLimit->end_date, null, new Collection([$budgetLimit->budget]), $budgetLimit->transactionCurrency
// );
$currency = $budgetLimit->transactionCurrency;
$amount = $budgetLimit->amount;
$currencyDecimalPlaces = 2;

View File

@@ -68,30 +68,30 @@ class BudgetTransformer extends AbstractTransformer
$start = $this->parameters->get('start');
$end = $this->parameters->get('end');
//$autoBudget = $this->repository->getAutoBudget($budget);
// $spent = [];
// if (null !== $start && null !== $end) {
// $spent = $this->beautify($this->opsRepository->sumExpenses($start, $end, null, new Collection([$budget])));
// }
// $spent = [];
// if (null !== $start && null !== $end) {
// $spent = $this->beautify($this->opsRepository->sumExpenses($start, $end, null, new Collection([$budget])));
// }
// $abCurrencyId = null;
// $abCurrencyCode = null;
// $abType = null;
// $abAmount = null;
// $abPeriod = null;
// $notes = $this->repository->getNoteText($budget);
//
// $types = [
// AutoBudget::AUTO_BUDGET_RESET => 'reset',
// AutoBudget::AUTO_BUDGET_ROLLOVER => 'rollover',
// ];
//
// if (null !== $autoBudget) {
// $abCurrencyId = (string) $autoBudget->transactionCurrency->id;
// $abCurrencyCode = $autoBudget->transactionCurrency->code;
// $abType = $types[$autoBudget->auto_budget_type];
// $abAmount = number_format((float) $autoBudget->amount, $autoBudget->transactionCurrency->decimal_places, '.', '');
// $abPeriod = $autoBudget->period;
// }
// $abCurrencyId = null;
// $abCurrencyCode = null;
// $abType = null;
// $abAmount = null;
// $abPeriod = null;
// $notes = $this->repository->getNoteText($budget);
//
// $types = [
// AutoBudget::AUTO_BUDGET_RESET => 'reset',
// AutoBudget::AUTO_BUDGET_ROLLOVER => 'rollover',
// ];
//
// if (null !== $autoBudget) {
// $abCurrencyId = (string) $autoBudget->transactionCurrency->id;
// $abCurrencyCode = $autoBudget->transactionCurrency->code;
// $abType = $types[$autoBudget->auto_budget_type];
// $abAmount = number_format((float) $autoBudget->amount, $autoBudget->transactionCurrency->decimal_places, '.', '');
// $abPeriod = $autoBudget->period;
// }
return [
'id' => (string)$budget->id,