| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * PiggyBankTransformer.php | 
					
						
							|  |  |  |  * Copyright (c) 2019 james@firefly-iii.org | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This file is part of Firefly III (https://github.com/firefly-iii). | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU Affero General Public License as | 
					
						
							|  |  |  |  * published by the Free Software Foundation, either version 3 of the | 
					
						
							|  |  |  |  * License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU Affero General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU Affero General Public License | 
					
						
							|  |  |  |  * along with this program.  If not, see <https://www.gnu.org/licenses/>. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | declare(strict_types=1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace FireflyIII\Transformers\V2; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use Carbon\Carbon; | 
					
						
							|  |  |  | use FireflyIII\Exceptions\FireflyException; | 
					
						
							|  |  |  | use FireflyIII\Models\Account; | 
					
						
							|  |  |  | use FireflyIII\Models\AccountMeta; | 
					
						
							|  |  |  | use FireflyIII\Models\Note; | 
					
						
							|  |  |  | use FireflyIII\Models\ObjectGroup; | 
					
						
							|  |  |  | use FireflyIII\Models\PiggyBank; | 
					
						
							|  |  |  | use FireflyIII\Models\PiggyBankRepetition; | 
					
						
							|  |  |  | use FireflyIII\Models\TransactionCurrency; | 
					
						
							|  |  |  | use FireflyIII\Models\TransactionJournal; | 
					
						
							|  |  |  | use FireflyIII\Support\Http\Api\ExchangeRateConverter; | 
					
						
							|  |  |  | use Illuminate\Support\Collection; | 
					
						
							|  |  |  | use Illuminate\Support\Facades\DB; | 
					
						
							| 
									
										
										
										
											2023-12-29 08:21:14 +01:00
										 |  |  | use Illuminate\Support\Facades\Log; | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Class PiggyBankTransformer | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class PiggyBankTransformer extends AbstractTransformer | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2023-08-11 06:05:02 +02:00
										 |  |  |     //    private AccountRepositoryInterface   $accountRepos;
 | 
					
						
							|  |  |  |     //    private CurrencyRepositoryInterface  $currencyRepos;
 | 
					
						
							|  |  |  |     //    private PiggyBankRepositoryInterface $piggyRepos;
 | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |     private array                 $accounts; | 
					
						
							|  |  |  |     private ExchangeRateConverter $converter; | 
					
						
							|  |  |  |     private array                 $currencies; | 
					
						
							|  |  |  |     private TransactionCurrency   $default; | 
					
						
							|  |  |  |     private array                 $groups; | 
					
						
							|  |  |  |     private array                 $notes; | 
					
						
							|  |  |  |     private array                 $repetitions; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * PiggyBankTransformer constructor. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function __construct() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $this->notes       = []; | 
					
						
							|  |  |  |         $this->accounts    = []; | 
					
						
							|  |  |  |         $this->groups      = []; | 
					
						
							|  |  |  |         $this->currencies  = []; | 
					
						
							|  |  |  |         $this->repetitions = []; | 
					
						
							| 
									
										
										
										
											2023-08-11 06:05:02 +02:00
										 |  |  |         //        $this->
 | 
					
						
							|  |  |  |         //        $this->currencyRepos = app(CurrencyRepositoryInterface::class);
 | 
					
						
							|  |  |  |         //        $this->piggyRepos    = app(PiggyBankRepositoryInterface::class);
 | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function collectMetaData(Collection $objects): void | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // TODO move to repository (does not exist yet)
 | 
					
						
							|  |  |  |         $piggyBanks          = $objects->pluck('id')->toArray(); | 
					
						
							|  |  |  |         $accountInfo         = Account::whereIn('id', $objects->pluck('account_id')->toArray())->get(); | 
					
						
							|  |  |  |         $currencyPreferences = AccountMeta::where('name', '"currency_id"')->whereIn('account_id', $objects->pluck('account_id')->toArray())->get(); | 
					
						
							| 
									
										
										
										
											2023-12-10 06:51:59 +01:00
										 |  |  |         $currencies          = []; | 
					
						
							| 
									
										
										
										
											2023-12-20 19:35:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |         /** @var Account $account */ | 
					
						
							|  |  |  |         foreach ($accountInfo as $account) { | 
					
						
							| 
									
										
										
										
											2023-11-05 19:41:37 +01:00
										 |  |  |             $id                  = $account->id; | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |             $this->accounts[$id] = [ | 
					
						
							|  |  |  |                 'name' => $account->name, | 
					
						
							|  |  |  |             ]; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-12-20 19:35:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |         /** @var AccountMeta $preference */ | 
					
						
							|  |  |  |         foreach ($currencyPreferences as $preference) { | 
					
						
							|  |  |  |             $currencyId                   = (int)$preference->data; | 
					
						
							| 
									
										
										
										
											2023-11-05 19:55:39 +01:00
										 |  |  |             $accountId                    = $preference->account_id; | 
					
						
							| 
									
										
										
										
											2024-01-01 14:43:56 +01:00
										 |  |  |             $currencies[$currencyId] ??= TransactionJournal::find($currencyId); | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |             $this->currencies[$accountId] = $currencies[$currencyId]; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // grab object groups:
 | 
					
						
							| 
									
										
										
										
											2024-01-01 14:43:56 +01:00
										 |  |  |         $set                 = DB::table('object_groupables') | 
					
						
							| 
									
										
										
										
											2023-12-20 19:35:52 +01:00
										 |  |  |             ->leftJoin('object_groups', 'object_groups.id', '=', 'object_groupables.object_group_id') | 
					
						
							|  |  |  |             ->where('object_groupables.object_groupable_type', PiggyBank::class) | 
					
						
							|  |  |  |             ->get(['object_groupables.*', 'object_groups.title', 'object_groups.order']) | 
					
						
							|  |  |  |         ; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |         /** @var ObjectGroup $entry */ | 
					
						
							|  |  |  |         foreach ($set as $entry) { | 
					
						
							|  |  |  |             $piggyBankId                = (int)$entry->object_groupable_id; | 
					
						
							|  |  |  |             $id                         = (int)$entry->object_group_id; | 
					
						
							| 
									
										
										
										
											2023-11-05 19:55:39 +01:00
										 |  |  |             $order                      = $entry->order; | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |             $this->groups[$piggyBankId] = [ | 
					
						
							| 
									
										
										
										
											2024-02-22 20:11:09 +01:00
										 |  |  |                 'object_group_id'    => (string)$id, | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |                 'object_group_title' => $entry->title, | 
					
						
							| 
									
										
										
										
											2024-01-02 20:19:09 +01:00
										 |  |  |                 'object_group_order' => $order, | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |             ]; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // grab repetitions (for current amount):
 | 
					
						
							| 
									
										
										
										
											2024-01-01 14:43:56 +01:00
										 |  |  |         $repetitions         = PiggyBankRepetition::whereIn('piggy_bank_id', $piggyBanks)->get(); | 
					
						
							| 
									
										
										
										
											2023-12-20 19:35:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |         /** @var PiggyBankRepetition $repetition */ | 
					
						
							|  |  |  |         foreach ($repetitions as $repetition) { | 
					
						
							| 
									
										
										
										
											2023-11-05 19:55:39 +01:00
										 |  |  |             $this->repetitions[$repetition->piggy_bank_id] = [ | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |                 'amount' => $repetition->currentamount, | 
					
						
							|  |  |  |             ]; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // grab notes
 | 
					
						
							|  |  |  |         // continue with notes
 | 
					
						
							| 
									
										
										
										
											2024-01-01 14:43:56 +01:00
										 |  |  |         $notes               = Note::whereNoteableType(PiggyBank::class)->whereIn('noteable_id', array_keys($piggyBanks))->get(); | 
					
						
							| 
									
										
										
										
											2023-12-20 19:35:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |         /** @var Note $note */ | 
					
						
							|  |  |  |         foreach ($notes as $note) { | 
					
						
							| 
									
										
										
										
											2023-11-05 19:55:39 +01:00
										 |  |  |             $id               = $note->noteable_id; | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |             $this->notes[$id] = $note; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-29 12:00:15 +01:00
										 |  |  |         Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__)); | 
					
						
							| 
									
										
										
										
											2024-01-01 14:43:56 +01:00
										 |  |  |         $this->default       = app('amount')->getDefaultCurrencyByUserGroup(auth()->user()->userGroup); | 
					
						
							|  |  |  |         $this->converter     = new ExchangeRateConverter(); | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Transform the piggy bank. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @throws FireflyException | 
					
						
							| 
									
										
										
										
											2023-12-22 20:12:38 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |     public function transform(PiggyBank $piggyBank): array | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2023-08-11 06:05:02 +02:00
										 |  |  |         //        $account = $piggyBank->account;
 | 
					
						
							|  |  |  |         //        $this->accountRepos->setUser($account->user);
 | 
					
						
							|  |  |  |         //        $this->currencyRepos->setUser($account->user);
 | 
					
						
							|  |  |  |         //        $this->piggyRepos->setUser($account->user);
 | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // get currency from account, or use default.
 | 
					
						
							| 
									
										
										
										
											2023-08-11 06:05:02 +02:00
										 |  |  |         //        $currency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUser($account->user);
 | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // note
 | 
					
						
							| 
									
										
										
										
											2023-08-11 06:05:02 +02:00
										 |  |  |         //        $notes = $this->piggyRepos->getNoteText($piggyBank);
 | 
					
						
							|  |  |  |         //        $notes = '' === $notes ? null : $notes;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //        $objectGroupId    = null;
 | 
					
						
							|  |  |  |         //        $objectGroupOrder = null;
 | 
					
						
							|  |  |  |         //        $objectGroupTitle = null;
 | 
					
						
							|  |  |  |         //        /** @var ObjectGroup $objectGroup */
 | 
					
						
							|  |  |  |         //        $objectGroup = $piggyBank->objectGroups->first();
 | 
					
						
							|  |  |  |         //        if (null !== $objectGroup) {
 | 
					
						
							|  |  |  |         //            $objectGroupId    = (int)$objectGroup->id;
 | 
					
						
							|  |  |  |         //            $objectGroupOrder = (int)$objectGroup->order;
 | 
					
						
							|  |  |  |         //            $objectGroupTitle = $objectGroup->title;
 | 
					
						
							|  |  |  |         //        }
 | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // get currently saved amount:
 | 
					
						
							| 
									
										
										
										
											2023-08-11 06:05:02 +02:00
										 |  |  |         //        $currentAmount = app('steam')->bcround($this->piggyRepos->getCurrentAmount($piggyBank), $currency->decimal_places);
 | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $percentage          = null; | 
					
						
							|  |  |  |         $leftToSave          = null; | 
					
						
							|  |  |  |         $nativeLeftToSave    = null; | 
					
						
							|  |  |  |         $savePerMonth        = null; | 
					
						
							|  |  |  |         $nativeSavePerMonth  = null; | 
					
						
							|  |  |  |         $startDate           = $piggyBank->startdate?->format('Y-m-d'); | 
					
						
							|  |  |  |         $targetDate          = $piggyBank->targetdate?->format('Y-m-d'); | 
					
						
							| 
									
										
										
										
											2023-11-05 19:55:39 +01:00
										 |  |  |         $accountId           = $piggyBank->account_id; | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |         $accountName         = $this->accounts[$accountId]['name'] ?? null; | 
					
						
							|  |  |  |         $currency            = $this->currencies[$accountId] ?? $this->default; | 
					
						
							| 
									
										
										
										
											2023-11-05 19:55:39 +01:00
										 |  |  |         $currentAmount       = app('steam')->bcround($this->repetitions[$piggyBank->id]['amount'] ?? '0', $currency->decimal_places); | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |         $nativeCurrentAmount = $this->converter->convert($this->default, $currency, today(), $currentAmount); | 
					
						
							|  |  |  |         $targetAmount        = $piggyBank->targetamount; | 
					
						
							|  |  |  |         $nativeTargetAmount  = $this->converter->convert($this->default, $currency, today(), $targetAmount); | 
					
						
							| 
									
										
										
										
											2023-11-05 19:55:39 +01:00
										 |  |  |         $note                = $this->notes[$piggyBank->id] ?? null; | 
					
						
							|  |  |  |         $group               = $this->groups[$piggyBank->id] ?? null; | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (0 !== bccomp($targetAmount, '0')) { // target amount is not 0.00
 | 
					
						
							|  |  |  |             $leftToSave         = bcsub($targetAmount, $currentAmount); | 
					
						
							|  |  |  |             $nativeLeftToSave   = $this->converter->convert($this->default, $currency, today(), $leftToSave); | 
					
						
							|  |  |  |             $percentage         = (int)bcmul(bcdiv($currentAmount, $targetAmount), '100'); | 
					
						
							|  |  |  |             $savePerMonth       = $this->getSuggestedMonthlyAmount($currentAmount, $targetAmount, $piggyBank->startdate, $piggyBank->targetdate); | 
					
						
							|  |  |  |             $nativeSavePerMonth = $this->converter->convert($this->default, $currency, today(), $savePerMonth); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-12-22 06:14:14 +01:00
										 |  |  |         $this->converter->summarize(); | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return [ | 
					
						
							| 
									
										
										
										
											2023-09-17 09:45:34 +02:00
										 |  |  |             '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, | 
					
						
							| 
									
										
										
										
											2023-11-26 12:10:42 +01:00
										 |  |  |             'currency_decimal_places'        => $currency->decimal_places, | 
					
						
							| 
									
										
										
										
											2023-09-17 09:45:34 +02:00
										 |  |  |             'native_currency_id'             => (string)$this->default->id, | 
					
						
							|  |  |  |             'native_currency_code'           => $this->default->code, | 
					
						
							|  |  |  |             'native_currency_symbol'         => $this->default->symbol, | 
					
						
							| 
									
										
										
										
											2023-11-26 12:24:37 +01:00
										 |  |  |             'native_currency_decimal_places' => $this->default->decimal_places, | 
					
						
							| 
									
										
										
										
											2023-09-17 09:45:34 +02:00
										 |  |  |             '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, | 
					
						
							| 
									
										
										
										
											2023-11-05 19:55:39 +01:00
										 |  |  |             'order'                          => $piggyBank->order, | 
					
						
							| 
									
										
										
										
											2023-09-17 09:45:34 +02:00
										 |  |  |             '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'                          => [ | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |                 [ | 
					
						
							|  |  |  |                     'rel' => 'self', | 
					
						
							| 
									
										
										
										
											2023-12-20 19:35:52 +01:00
										 |  |  |                     'uri' => '/piggy_banks/'.$piggyBank->id, | 
					
						
							| 
									
										
										
										
											2023-08-11 06:04:03 +02:00
										 |  |  |                 ], | 
					
						
							|  |  |  |             ], | 
					
						
							|  |  |  |         ]; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private function getSuggestedMonthlyAmount(string $currentAmount, string $targetAmount, ?Carbon $startDate, ?Carbon $targetDate): string | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $savePerMonth = '0'; | 
					
						
							|  |  |  |         if (null === $targetDate) { | 
					
						
							|  |  |  |             return '0'; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (bccomp($currentAmount, $targetAmount) < 1) { | 
					
						
							|  |  |  |             $now             = today(config('app.timezone')); | 
					
						
							|  |  |  |             $startDate       = null !== $startDate && $startDate->gte($now) ? $startDate : $now; | 
					
						
							|  |  |  |             $diffInMonths    = $startDate->diffInMonths($targetDate, false); | 
					
						
							|  |  |  |             $remainingAmount = bcsub($targetAmount, $currentAmount); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             // more than 1 month to go and still need money to save:
 | 
					
						
							|  |  |  |             if ($diffInMonths > 0 && 1 === bccomp($remainingAmount, '0')) { | 
					
						
							|  |  |  |                 $savePerMonth = bcdiv($remainingAmount, (string)$diffInMonths); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             // less than 1 month to go but still need money to save:
 | 
					
						
							|  |  |  |             if (0 === $diffInMonths && 1 === bccomp($remainingAmount, '0')) { | 
					
						
							|  |  |  |                 $savePerMonth = $remainingAmount; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $savePerMonth; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |