mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 02:36:28 +00:00 
			
		
		
		
	Rebuild frontpage with better bills overview.
This commit is contained in:
		| @@ -144,15 +144,15 @@ class AccountTransformer extends AbstractTransformer | ||||
|             'currency_symbol'         => $currency->symbol, | ||||
|             'currency_decimal_places' => (int)$currency->decimal_places, | ||||
| 
 | ||||
|             'native_id'              => (string)$this->default->id, | ||||
|             'native_code'            => $this->default->code, | ||||
|             'native_symbol'          => $this->default->symbol, | ||||
|             'native_decimal_places'  => (int)$this->default->decimal_places, | ||||
|             'native_currency_id'             => (string)$this->default->id, | ||||
|             'native_currency_code'           => $this->default->code, | ||||
|             'native_currency_symbol'         => $this->default->symbol, | ||||
|             'native_currency_decimal_places' => (int)$this->default->decimal_places, | ||||
| 
 | ||||
|             // balance:
 | ||||
|             'current_balance'        => $balance, | ||||
|             'native_current_balance' => $nativeBalance, | ||||
|             'current_balance_date'   => $this->getDate(), | ||||
|             'current_balance'                => $balance, | ||||
|             'native_current_balance'         => $nativeBalance, | ||||
|             'current_balance_date'           => $this->getDate(), | ||||
| 
 | ||||
|             // more meta
 | ||||
| 
 | ||||
| @@ -173,7 +173,7 @@ class AccountTransformer extends AbstractTransformer | ||||
|             //            'longitude'               => $longitude,
 | ||||
|             //            'latitude'                => $latitude,
 | ||||
|             //            'zoom_level'              => $zoomLevel,
 | ||||
|             'links'                  => [ | ||||
|             'links'                          => [ | ||||
|                 [ | ||||
|                     'rel' => 'self', | ||||
|                     'uri' => '/accounts/' . $account->id, | ||||
|   | ||||
| @@ -107,6 +107,7 @@ class BillTransformer extends AbstractTransformer | ||||
|         } | ||||
|         $this->default   = app('amount')->getDefaultCurrency(); | ||||
|         $this->converter = new ExchangeRateConverter(); | ||||
| 
 | ||||
|         // grab all paid dates:
 | ||||
|         if (null !== $this->parameters->get('start') && null !== $this->parameters->get('end')) { | ||||
|             $journals   = TransactionJournal::whereIn('bill_id', $bills) | ||||
| @@ -128,6 +129,7 @@ class BillTransformer extends AbstractTransformer | ||||
|             } | ||||
|             /** @var TransactionJournal $journal */ | ||||
|             foreach ($journals as $journal) { | ||||
|                 app('log')->debug(sprintf('Processing journal #%d', $journal->id)); | ||||
|                 $transaction             = $transactions[(int)$journal->id] ?? []; | ||||
|                 $billId                  = (int)$journal->bill_id; | ||||
|                 $currencyId              = (int)$transaction['transaction_currency_id'] ?? 0; | ||||
| @@ -139,7 +141,9 @@ class BillTransformer extends AbstractTransformer | ||||
|                 $foreignCurrencyName   = null; | ||||
|                 $foreignCurrencySymbol = null; | ||||
|                 $foreignCurrencyDp     = null; | ||||
|                 app('log')->debug('Foreign currency is NULL'); | ||||
|                 if (null !== $transaction['foreign_currency_id']) { | ||||
|                     app('log')->debug(sprintf('Foreign currency is #%d', $transaction['foreign_currency_id'])); | ||||
|                     $foreignCurrencyId              = (int)$transaction['foreign_currency_id']; | ||||
|                     $currencies[$foreignCurrencyId] = $currencies[$foreignCurrencyId] ?? TransactionCurrency::find($foreignCurrencyId); | ||||
|                     $foreignCurrencyCode            = $currencies[$foreignCurrencyId]->code; | ||||
| @@ -157,10 +161,10 @@ class BillTransformer extends AbstractTransformer | ||||
|                     'currency_name'                   => $currencies[$currencyId]->name, | ||||
|                     'currency_symbol'                 => $currencies[$currencyId]->symbol, | ||||
|                     'currency_decimal_places'         => (int)$currencies[$currencyId]->decimal_places, | ||||
|                     'native_id'                       => (int)$currencies[$currencyId]->id, | ||||
|                     'native_code'                     => $currencies[$currencyId]->code, | ||||
|                     'native_symbol'                   => $currencies[$currencyId]->symbol, | ||||
|                     'native_decimal_places'           => (int)$currencies[$currencyId]->decimal_places, | ||||
|                     'native_currency_id'              => (int)$currencies[$currencyId]->id, | ||||
|                     'native_currency_code'            => $currencies[$currencyId]->code, | ||||
|                     'native_currency_symbol'          => $currencies[$currencyId]->symbol, | ||||
|                     'native_currency_decimal_places'  => (int)$currencies[$currencyId]->decimal_places, | ||||
|                     'foreign_currency_id'             => $foreignCurrencyId, | ||||
|                     'foreign_currency_code'           => $foreignCurrencyCode, | ||||
|                     'foreign_currency_name'           => $foreignCurrencyName, | ||||
| @@ -169,7 +173,9 @@ class BillTransformer extends AbstractTransformer | ||||
|                     'amount'                          => $transaction['amount'], | ||||
|                     'foreign_amount'                  => $transaction['foreign_amount'], | ||||
|                     'native_amount'                   => $this->converter->convert($currencies[$currencyId], $this->default, $journal->date, $transaction['amount']), | ||||
|                     'foreign_native_amount'           => null === $transaction['foreign_amount'] ? null : $this->converter->convert($currencies[$foreignCurrencyId], $this->default, $journal->date, $transaction['foreign_amount']), | ||||
|                     'foreign_native_amount'           => '' === (string)$transaction['foreign_amount'] ? null : $this->converter->convert( | ||||
|                         $currencies[$foreignCurrencyId], | ||||
|                         $this->default, $journal->date, $transaction['foreign_amount']), | ||||
|                 ]; | ||||
|             } | ||||
|         } | ||||
| @@ -199,40 +205,40 @@ class BillTransformer extends AbstractTransformer | ||||
| 
 | ||||
|         $nextExpectedMatchDiff = $this->getNextExpectedMatchDiff($nextExpectedMatch, $payDates); | ||||
|         return [ | ||||
|             'id'                       => (int)$bill->id, | ||||
|             'created_at'               => $bill->created_at->toAtomString(), | ||||
|             'updated_at'               => $bill->updated_at->toAtomString(), | ||||
|             'name'                     => $bill->name, | ||||
|             'amount_min'               => app('steam')->bcround($bill->amount_min, $currency->decimal_places), | ||||
|             'amount_max'               => app('steam')->bcround($bill->amount_max, $currency->decimal_places), | ||||
|             'native_amount_min'        => $this->converter->convert($currency, $this->default, $date, $bill->amount_min), | ||||
|             'native_amount_max'        => $this->converter->convert($currency, $this->default, $date, $bill->amount_max), | ||||
|             'currency_id'              => (string)$bill->transaction_currency_id, | ||||
|             'currency_code'            => $currency->code, | ||||
|             'currency_name'            => $currency->name, | ||||
|             'currency_symbol'          => $currency->symbol, | ||||
|             'currency_decimal_places'  => (int)$currency->decimal_places, | ||||
|             'native_id'                => $this->default->id, | ||||
|             'native_code'              => $this->default->code, | ||||
|             'native_name'              => $this->default->name, | ||||
|             'native_symbol'            => $this->default->symbol, | ||||
|             'native_decimal_places'    => (int)$this->default->decimal_places, | ||||
|             'date'                     => $bill->date->toAtomString(), | ||||
|             'end_date'                 => $bill->end_date?->toAtomString(), | ||||
|             'extension_date'           => $bill->extension_date?->toAtomString(), | ||||
|             'repeat_freq'              => $bill->repeat_freq, | ||||
|             'skip'                     => (int)$bill->skip, | ||||
|             'active'                   => $bill->active, | ||||
|             'order'                    => (int)$bill->order, | ||||
|             'notes'                    => $this->notes[(int)$bill->id] ?? null, | ||||
|             'object_group_id'          => $group ? $group['object_group_id'] : null, | ||||
|             'object_group_order'       => $group ? $group['object_group_order'] : null, | ||||
|             'object_group_title'       => $group ? $group['object_group_title'] : null, | ||||
|             'next_expected_match'      => $nextExpectedMatch->toAtomString(), | ||||
|             'next_expected_match_diff' => $nextExpectedMatchDiff, | ||||
|             'pay_dates'                => $payDates, | ||||
|             'paid_dates'               => $paidData, | ||||
|             'links'                    => [ | ||||
|             'id'                             => (int)$bill->id, | ||||
|             'created_at'                     => $bill->created_at->toAtomString(), | ||||
|             'updated_at'                     => $bill->updated_at->toAtomString(), | ||||
|             'name'                           => $bill->name, | ||||
|             'amount_min'                     => app('steam')->bcround($bill->amount_min, $currency->decimal_places), | ||||
|             'amount_max'                     => app('steam')->bcround($bill->amount_max, $currency->decimal_places), | ||||
|             'native_amount_min'              => $this->converter->convert($currency, $this->default, $date, $bill->amount_min), | ||||
|             'native_amount_max'              => $this->converter->convert($currency, $this->default, $date, $bill->amount_max), | ||||
|             'currency_id'                    => (string)$bill->transaction_currency_id, | ||||
|             'currency_code'                  => $currency->code, | ||||
|             'currency_name'                  => $currency->name, | ||||
|             'currency_symbol'                => $currency->symbol, | ||||
|             'currency_decimal_places'        => (int)$currency->decimal_places, | ||||
|             'native_currency_id'             => $this->default->id, | ||||
|             'native_currency_code'           => $this->default->code, | ||||
|             'native_currency_name'           => $this->default->name, | ||||
|             'native_currency_symbol'         => $this->default->symbol, | ||||
|             'native_currency_decimal_places' => (int)$this->default->decimal_places, | ||||
|             'date'                           => $bill->date->toAtomString(), | ||||
|             'end_date'                       => $bill->end_date?->toAtomString(), | ||||
|             'extension_date'                 => $bill->extension_date?->toAtomString(), | ||||
|             'repeat_freq'                    => $bill->repeat_freq, | ||||
|             'skip'                           => (int)$bill->skip, | ||||
|             'active'                         => $bill->active, | ||||
|             'order'                          => (int)$bill->order, | ||||
|             'notes'                          => $this->notes[(int)$bill->id] ?? null, | ||||
|             'object_group_id'                => $group ? $group['object_group_id'] : null, | ||||
|             'object_group_order'             => $group ? $group['object_group_order'] : null, | ||||
|             'object_group_title'             => $group ? $group['object_group_title'] : null, | ||||
|             'next_expected_match'            => $nextExpectedMatch->toAtomString(), | ||||
|             'next_expected_match_diff'       => $nextExpectedMatchDiff, | ||||
|             'pay_dates'                      => $payDates, | ||||
|             'paid_dates'                     => $paidData, | ||||
|             'links'                          => [ | ||||
|                 [ | ||||
|                     'rel' => 'self', | ||||
|                     'uri' => sprintf('/bills/%d', $bill->id), | ||||
|   | ||||
| @@ -198,38 +198,38 @@ class PiggyBankTransformer extends AbstractTransformer | ||||
|         } | ||||
| 
 | ||||
|         return [ | ||||
|             'id'                      => (string)$piggyBank->id, | ||||
|             'created_at'              => $piggyBank->created_at->toAtomString(), | ||||
|             'updated_at'              => $piggyBank->updated_at->toAtomString(), | ||||
|             'account_id'              => (string)$piggyBank->account_id, | ||||
|             'account_name'            => $accountName, | ||||
|             'name'                    => $piggyBank->name, | ||||
|             'currency_id'             => (string)$currency->id, | ||||
|             'currency_code'           => $currency->code, | ||||
|             'currency_symbol'         => $currency->symbol, | ||||
|             'currency_decimal_places' => (int)$currency->decimal_places, | ||||
|             'native_id'               => (string)$this->default->id, | ||||
|             'native_code'             => $this->default->code, | ||||
|             'native_symbol'           => $this->default->symbol, | ||||
|             'native_decimal_places'   => (int)$this->default->decimal_places, | ||||
|             'current_amount'          => $currentAmount, | ||||
|             'native_current_amount'   => $nativeCurrentAmount, | ||||
|             'target_amount'           => $targetAmount, | ||||
|             'native_target_amount'    => $nativeTargetAmount, | ||||
|             'percentage'              => $percentage, | ||||
|             'left_to_save'            => $leftToSave, | ||||
|             'native_left_to_save'     => $nativeLeftToSave, | ||||
|             'save_per_month'          => $savePerMonth, | ||||
|             'native_save_per_month'   => $nativeSavePerMonth, | ||||
|             'start_date'              => $startDate, | ||||
|             'target_date'             => $targetDate, | ||||
|             'order'                   => (int)$piggyBank->order, | ||||
|             'active'                  => $piggyBank->active, | ||||
|             'notes'                   => $note, | ||||
|             'object_group_id'         => $group ? $group['object_group_id'] : null, | ||||
|             'object_group_order'      => $group ? $group['object_group_order'] : null, | ||||
|             'object_group_title'      => $group ? $group['object_group_title'] : null, | ||||
|             'links'                   => [ | ||||
|             'id'                             => (string)$piggyBank->id, | ||||
|             'created_at'                     => $piggyBank->created_at->toAtomString(), | ||||
|             'updated_at'                     => $piggyBank->updated_at->toAtomString(), | ||||
|             'account_id'                     => (string)$piggyBank->account_id, | ||||
|             'account_name'                   => $accountName, | ||||
|             'name'                           => $piggyBank->name, | ||||
|             'currency_id'                    => (string)$currency->id, | ||||
|             'currency_code'                  => $currency->code, | ||||
|             'currency_symbol'                => $currency->symbol, | ||||
|             'currency_decimal_places'        => (int)$currency->decimal_places, | ||||
|             'native_currency_id'             => (string)$this->default->id, | ||||
|             'native_currency_code'           => $this->default->code, | ||||
|             'native_currency_symbol'         => $this->default->symbol, | ||||
|             'native_currency_decimal_places' => (int)$this->default->decimal_places, | ||||
|             'current_amount'                 => $currentAmount, | ||||
|             'native_current_amount'          => $nativeCurrentAmount, | ||||
|             'target_amount'                  => $targetAmount, | ||||
|             'native_target_amount'           => $nativeTargetAmount, | ||||
|             'percentage'                     => $percentage, | ||||
|             'left_to_save'                   => $leftToSave, | ||||
|             'native_left_to_save'            => $nativeLeftToSave, | ||||
|             'save_per_month'                 => $savePerMonth, | ||||
|             'native_save_per_month'          => $nativeSavePerMonth, | ||||
|             'start_date'                     => $startDate, | ||||
|             'target_date'                    => $targetDate, | ||||
|             'order'                          => (int)$piggyBank->order, | ||||
|             'active'                         => $piggyBank->active, | ||||
|             'notes'                          => $note, | ||||
|             'object_group_id'                => $group ? $group['object_group_id'] : null, | ||||
|             'object_group_order'             => $group ? $group['object_group_order'] : null, | ||||
|             'object_group_title'             => $group ? $group['object_group_title'] : null, | ||||
|             'links'                          => [ | ||||
|                 [ | ||||
|                     'rel' => 'self', | ||||
|                     'uri' => '/piggy_banks/' . $piggyBank->id, | ||||
|   | ||||
| @@ -36,7 +36,6 @@ use FireflyIII\Support\Http\Api\ExchangeRateConverter; | ||||
| use FireflyIII\Support\NullArrayObject; | ||||
| use Illuminate\Support\Collection; | ||||
| use Illuminate\Support\Facades\DB; | ||||
| use Illuminate\Support\Facades\Log; | ||||
| use stdClass; | ||||
| 
 | ||||
| /** | ||||
| @@ -192,11 +191,11 @@ class TransactionGroupTransformer extends AbstractTransformer | ||||
|             'currency_decimal_places'         => (int)$transaction['currency_decimal_places'], | ||||
| 
 | ||||
|             // converted to native currency
 | ||||
|             'native_id'                       => (string)$this->default->id, | ||||
|             'native_code'                     => $this->default->code, | ||||
|             'native_name'                     => $this->default->name, | ||||
|             'native_symbol'                   => $this->default->symbol, | ||||
|             'native_decimal_places'           => (int)$this->default->decimal_places, | ||||
|             'native_currency_id'              => (string)$this->default->id, | ||||
|             'native_currency_code'            => $this->default->code, | ||||
|             'native_currency_name'            => $this->default->name, | ||||
|             'native_currency_symbol'          => $this->default->symbol, | ||||
|             'native_currency_decimal_places'  => (int)$this->default->decimal_places, | ||||
| 
 | ||||
|             // foreign currency amount:
 | ||||
|             'foreign_currency_id'             => $this->stringFromArray($transaction, 'foreign_currency_id', null), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user