mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Make sure integers are converted to strings because sqlite sucks.
This commit is contained in:
parent
9a9dd9e075
commit
3c20e5f3af
@ -74,7 +74,7 @@ class CorrectsDatabase extends Command
|
|||||||
'correction:recalculates-liabilities',
|
'correction:recalculates-liabilities',
|
||||||
'correction:preferences',
|
'correction:preferences',
|
||||||
// 'correction:transaction-types', // resource heavy, disabled.
|
// 'correction:transaction-types', // resource heavy, disabled.
|
||||||
// 'correction:recalculate-native-amounts', // not necessary, disabled.
|
'correction:recalculate-native-amounts', // not necessary, disabled.
|
||||||
'firefly-iii:report-integrity',
|
'firefly-iii:report-integrity',
|
||||||
];
|
];
|
||||||
foreach ($commands as $command) {
|
foreach ($commands as $command) {
|
||||||
|
@ -160,8 +160,8 @@ class DebugController extends Controller
|
|||||||
Artisan::call('view:clear');
|
Artisan::call('view:clear');
|
||||||
|
|
||||||
// also do some recalculations.
|
// also do some recalculations.
|
||||||
Artisan::call('firefly-iii:trigger-credit-recalculation');
|
Artisan::call('correction:recalculates-liabilities');
|
||||||
AccountBalanceCalculator::recalculateAll(true);
|
AccountBalanceCalculator::recalculateAll(false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Artisan::call('twig:clean');
|
Artisan::call('twig:clean');
|
||||||
|
@ -57,6 +57,7 @@ class Account extends Model
|
|||||||
'active' => 'boolean',
|
'active' => 'boolean',
|
||||||
'encrypted' => 'boolean',
|
'encrypted' => 'boolean',
|
||||||
'virtual_balance' => 'string',
|
'virtual_balance' => 'string',
|
||||||
|
'native_virtual_balance' => 'string',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $fillable = ['user_id', 'user_group_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban', 'native_virtual_balance'];
|
protected $fillable = ['user_id', 'user_group_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban', 'native_virtual_balance'];
|
||||||
|
@ -38,19 +38,20 @@ class AutoBudget extends Model
|
|||||||
use ReturnsIntegerIdTrait;
|
use ReturnsIntegerIdTrait;
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
#[\Deprecated]
|
#[\Deprecated] /** @deprecated */
|
||||||
public const int AUTO_BUDGET_ADJUSTED = 3;
|
public const int AUTO_BUDGET_ADJUSTED = 3;
|
||||||
|
|
||||||
#[\Deprecated]
|
#[\Deprecated] /** @deprecated */
|
||||||
public const int AUTO_BUDGET_RESET = 1;
|
public const int AUTO_BUDGET_RESET = 1;
|
||||||
|
|
||||||
#[\Deprecated]
|
#[\Deprecated] /** @deprecated */
|
||||||
public const int AUTO_BUDGET_ROLLOVER = 2;
|
public const int AUTO_BUDGET_ROLLOVER = 2;
|
||||||
protected $casts
|
protected $casts
|
||||||
= [
|
= [
|
||||||
'amount' => 'string',
|
'amount' => 'string',
|
||||||
|
'native_amount' => 'string',
|
||||||
];
|
];
|
||||||
protected $fillable = ['budget_id', 'amount', 'period'];
|
protected $fillable = ['budget_id', 'amount', 'period','native_amount'];
|
||||||
|
|
||||||
public function budget(): BelongsTo
|
public function budget(): BelongsTo
|
||||||
{
|
{
|
||||||
|
@ -50,9 +50,10 @@ class AvailableBudget extends Model
|
|||||||
'end_date' => 'date',
|
'end_date' => 'date',
|
||||||
'transaction_currency_id' => 'int',
|
'transaction_currency_id' => 'int',
|
||||||
'amount' => 'string',
|
'amount' => 'string',
|
||||||
|
'native_amount' => 'string',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $fillable = ['user_id', 'user_group_id', 'transaction_currency_id', 'amount', 'start_date', 'end_date', 'start_date_tz', 'end_date_tz'];
|
protected $fillable = ['user_id', 'user_group_id', 'transaction_currency_id', 'amount', 'start_date', 'end_date', 'start_date_tz', 'end_date_tz','native_amount'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||||
|
@ -49,6 +49,7 @@ class BudgetLimit extends Model
|
|||||||
'end_date' => SeparateTimezoneCaster::class,
|
'end_date' => SeparateTimezoneCaster::class,
|
||||||
'auto_budget' => 'boolean',
|
'auto_budget' => 'boolean',
|
||||||
'amount' => 'string',
|
'amount' => 'string',
|
||||||
|
'native_amount' => 'string',
|
||||||
];
|
];
|
||||||
protected $dispatchesEvents
|
protected $dispatchesEvents
|
||||||
= [
|
= [
|
||||||
|
@ -53,9 +53,10 @@ class PiggyBank extends Model
|
|||||||
'active' => 'boolean',
|
'active' => 'boolean',
|
||||||
'encrypted' => 'boolean',
|
'encrypted' => 'boolean',
|
||||||
'target_amount' => 'string',
|
'target_amount' => 'string',
|
||||||
|
'native_target_amount' => 'string',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $fillable = ['name', 'order', 'target_amount', 'start_date', 'start_date_tz', 'target_date', 'target_date_tz', 'active', 'transaction_currency_id'];
|
protected $fillable = ['name', 'order', 'target_amount', 'start_date', 'start_date_tz', 'target_date', 'target_date_tz', 'active', 'transaction_currency_id','native_target_amount'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||||
|
@ -42,9 +42,10 @@ class PiggyBankEvent extends Model
|
|||||||
'updated_at' => 'datetime',
|
'updated_at' => 'datetime',
|
||||||
'date' => SeparateTimezoneCaster::class,
|
'date' => SeparateTimezoneCaster::class,
|
||||||
'amount' => 'string',
|
'amount' => 'string',
|
||||||
|
'amount' => 'native_string',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'date_tz', 'amount'];
|
protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'date_tz', 'amount','native_amount'];
|
||||||
|
|
||||||
protected $hidden = ['amount_encrypted'];
|
protected $hidden = ['amount_encrypted'];
|
||||||
|
|
||||||
|
@ -586,7 +586,7 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
|
|
||||||
$minField = $convertToNative && $bill->transactionCurrency->id !== $default->id ? 'native_amount_min' : 'amount_min';
|
$minField = $convertToNative && $bill->transactionCurrency->id !== $default->id ? 'native_amount_min' : 'amount_min';
|
||||||
$maxField = $convertToNative && $bill->transactionCurrency->id !== $default->id ? 'native_amount_max' : 'amount_max';
|
$maxField = $convertToNative && $bill->transactionCurrency->id !== $default->id ? 'native_amount_max' : 'amount_max';
|
||||||
// Log::debug(sprintf('min field is %s, max field is %s', $minField, $maxField));
|
Log::debug(sprintf('min field is %s, max field is %s', $minField, $maxField));
|
||||||
|
|
||||||
if ($total > 0) {
|
if ($total > 0) {
|
||||||
$currency = $convertToNative && $bill->transactionCurrency->id !== $default->id ? $default : $bill->transactionCurrency;
|
$currency = $convertToNative && $bill->transactionCurrency->id !== $default->id ? $default : $bill->transactionCurrency;
|
||||||
|
@ -65,7 +65,7 @@ class Amount
|
|||||||
// Log::debug(sprintf('Overruled, amount is now %s', $amount));
|
// Log::debug(sprintf('Overruled, amount is now %s', $amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $amount;
|
return (string) $amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function convertToNative(?User $user = null): bool
|
public function convertToNative(?User $user = null): bool
|
||||||
|
@ -198,8 +198,10 @@ class FrontpageChartGenerator
|
|||||||
}
|
}
|
||||||
$useNative = $this->convertToNative && $this->default->id !== $limit->transaction_currency_id;
|
$useNative = $this->convertToNative && $this->default->id !== $limit->transaction_currency_id;
|
||||||
$amount = $limit->amount;
|
$amount = $limit->amount;
|
||||||
if ($useNative) {
|
Log::debug(sprintf('Amount is "%s".', $amount));
|
||||||
|
if ($useNative && $limit->transaction_currency_id !== $this->default->id) {
|
||||||
$amount = $limit->native_amount;
|
$amount = $limit->native_amount;
|
||||||
|
Log::debug(sprintf('Amount is now "%s".', $amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -208,7 +210,6 @@ class FrontpageChartGenerator
|
|||||||
$data[1]['entries'][$title] ??= '0';
|
$data[1]['entries'][$title] ??= '0';
|
||||||
$data[2]['entries'][$title] ??= '0';
|
$data[2]['entries'][$title] ??= '0';
|
||||||
|
|
||||||
|
|
||||||
$data[0]['entries'][$title] = bcadd($data[0]['entries'][$title], 1 === bccomp($sumSpent, $amount) ? $amount : $sumSpent); // spent
|
$data[0]['entries'][$title] = bcadd($data[0]['entries'][$title], 1 === bccomp($sumSpent, $amount) ? $amount : $sumSpent); // spent
|
||||||
$data[1]['entries'][$title] = bcadd($data[1]['entries'][$title], 1 === bccomp($amount, $sumSpent) ? bcadd($entry['sum'], $amount) : '0'); // left to spent
|
$data[1]['entries'][$title] = bcadd($data[1]['entries'][$title], 1 === bccomp($amount, $sumSpent) ? bcadd($entry['sum'], $amount) : '0'); // left to spent
|
||||||
$data[2]['entries'][$title] = bcadd($data[2]['entries'][$title], 1 === bccomp($amount, $sumSpent) ? '0' : bcmul(bcadd($entry['sum'], $amount), '-1')); // overspent
|
$data[2]['entries'][$title] = bcadd($data[2]['entries'][$title], 1 === bccomp($amount, $sumSpent) ? '0' : bcmul(bcadd($entry['sum'], $amount), '-1')); // overspent
|
||||||
|
Loading…
Reference in New Issue
Block a user