mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 02:36:28 +00:00 
			
		
		
		
	Make sure integers are converted to strings because sqlite sucks.
This commit is contained in:
		| @@ -74,7 +74,7 @@ class CorrectsDatabase extends Command | ||||
|             'correction:recalculates-liabilities', | ||||
|             'correction:preferences', | ||||
|             // 'correction:transaction-types', // resource heavy, disabled.
 | ||||
|             // 'correction:recalculate-native-amounts', // not necessary, disabled.
 | ||||
|             'correction:recalculate-native-amounts', // not necessary, disabled.
 | ||||
|             'firefly-iii:report-integrity', | ||||
|         ]; | ||||
|         foreach ($commands as $command) { | ||||
|   | ||||
| @@ -160,8 +160,8 @@ class DebugController extends Controller | ||||
|         Artisan::call('view:clear'); | ||||
| 
 | ||||
|         // also do some recalculations.
 | ||||
|         Artisan::call('firefly-iii:trigger-credit-recalculation'); | ||||
|         AccountBalanceCalculator::recalculateAll(true); | ||||
|         Artisan::call('correction:recalculates-liabilities'); | ||||
|         AccountBalanceCalculator::recalculateAll(false); | ||||
| 
 | ||||
|         try { | ||||
|             Artisan::call('twig:clean'); | ||||
|   | ||||
| @@ -57,6 +57,7 @@ class Account extends Model | ||||
|             'active'          => 'boolean', | ||||
|             'encrypted'       => 'boolean', | ||||
|             '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']; | ||||
|   | ||||
| @@ -38,19 +38,20 @@ class AutoBudget extends Model | ||||
|     use ReturnsIntegerIdTrait; | ||||
|     use SoftDeletes; | ||||
| 
 | ||||
|     #[\Deprecated]
 | ||||
|     #[\Deprecated] /** @deprecated  */
 | ||||
|     public const int AUTO_BUDGET_ADJUSTED = 3; | ||||
| 
 | ||||
|     #[\Deprecated]
 | ||||
|     #[\Deprecated] /** @deprecated  */
 | ||||
|     public const int AUTO_BUDGET_RESET    = 1; | ||||
| 
 | ||||
|     #[\Deprecated]
 | ||||
|     #[\Deprecated] /** @deprecated  */
 | ||||
|     public const int AUTO_BUDGET_ROLLOVER = 2; | ||||
|     protected $casts | ||||
|                                           = [ | ||||
|             'amount' => 'string', | ||||
|             'native_amount' => 'string', | ||||
|         ]; | ||||
|     protected $fillable                   = ['budget_id', 'amount', 'period']; | ||||
|     protected $fillable                   = ['budget_id', 'amount', 'period','native_amount']; | ||||
| 
 | ||||
|     public function budget(): BelongsTo | ||||
|     { | ||||
|   | ||||
| @@ -50,9 +50,10 @@ class AvailableBudget extends Model | ||||
|             'end_date'                => 'date', | ||||
|             'transaction_currency_id' => 'int', | ||||
|             '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). | ||||
|   | ||||
| @@ -49,6 +49,7 @@ class BudgetLimit extends Model | ||||
|             'end_date'    => SeparateTimezoneCaster::class, | ||||
|             'auto_budget' => 'boolean', | ||||
|             'amount'      => 'string', | ||||
|             'native_amount'      => 'string', | ||||
|         ]; | ||||
|     protected $dispatchesEvents | ||||
|                         = [ | ||||
|   | ||||
| @@ -53,9 +53,10 @@ class PiggyBank extends Model | ||||
|             'active'        => 'boolean', | ||||
|             'encrypted'     => 'boolean', | ||||
|             '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). | ||||
|   | ||||
| @@ -42,9 +42,10 @@ class PiggyBankEvent extends Model | ||||
|             'updated_at' => 'datetime', | ||||
|             'date'       => SeparateTimezoneCaster::class, | ||||
|             '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']; | ||||
| 
 | ||||
|   | ||||
| @@ -586,7 +586,7 @@ class BillRepository implements BillRepositoryInterface | ||||
| 
 | ||||
|             $minField = $convertToNative && $bill->transactionCurrency->id !== $default->id ? 'native_amount_min' : 'amount_min'; | ||||
|             $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) { | ||||
|                 $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));
 | ||||
|         } | ||||
| 
 | ||||
|         return $amount; | ||||
|         return (string) $amount; | ||||
|     } | ||||
| 
 | ||||
|     public function convertToNative(?User $user = null): bool | ||||
|   | ||||
| @@ -198,8 +198,10 @@ class FrontpageChartGenerator | ||||
|         } | ||||
|         $useNative                  = $this->convertToNative && $this->default->id !== $limit->transaction_currency_id; | ||||
|         $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; | ||||
|             Log::debug(sprintf('Amount is now "%s".', $amount)); | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
| @@ -208,7 +210,6 @@ class FrontpageChartGenerator | ||||
|         $data[1]['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[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
 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user