Change currency from settings #671 (#672)

This commit is contained in:
Nabeel S
2020-04-26 11:55:20 -04:00
committed by GitHub
parent 03cfc648b0
commit 99f4f3b3d8
15 changed files with 63 additions and 29 deletions

View File

@@ -63,11 +63,11 @@ class PirepFinanceService extends Service
public function processFinancesForPirep(Pirep $pirep)
{
if (!$pirep->airline->journal) {
$pirep->airline->journal = $pirep->airline->initJournal(config('phpvms.currency'));
$pirep->airline->journal = $pirep->airline->initJournal(setting('units.currency', 'USD'));
}
if (!$pirep->user->journal) {
$pirep->user->journal = $pirep->user->initJournal(config('phpvms.currency'));
$pirep->user->journal = $pirep->user->initJournal(setting('units.currency', 'USD'));
}
// Clean out the expenses first

View File

@@ -168,4 +168,16 @@ class FinanceService extends Service
'transactions' => $transactions,
];
}
/**
* Change the currencies on the journals and transactions to the current currency value
*/
public function changeJournalCurrencies(): void
{
$currency = setting('units.currency', 'USD');
$update = ['currency' => $currency];
Journal::query()->update($update);
JournalTransaction::query()->update($update);
}
}

View File

@@ -248,7 +248,7 @@ class SeederService extends Service
// See if any of the options have changed
if ($row->type === 'select') {
if ($row->options !== $setting['options']) {
if (!empty($row->options) && $row->options !== $setting['options']) {
Log::info('Options for '.$id.' changed, update available');
return true;
}