mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 10:47:00 +00:00 
			
		
		
		
	Fix #2956
This commit is contained in:
		| @@ -90,6 +90,7 @@ class ReconcileController extends Controller | |||||||
|             return $this->redirectAccountToAccount($account); // @codeCoverageIgnore |             return $this->redirectAccountToAccount($account); // @codeCoverageIgnore | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|         if (AccountType::ASSET !== $account->accountType->type) { |         if (AccountType::ASSET !== $account->accountType->type) { | ||||||
|             // @codeCoverageIgnoreStart |             // @codeCoverageIgnoreStart | ||||||
|             session()->flash('error', (string)trans('firefly.must_be_asset_account')); |             session()->flash('error', (string)trans('firefly.must_be_asset_account')); | ||||||
| @@ -117,6 +118,9 @@ class ReconcileController extends Controller | |||||||
|             $end = app('navigation')->endOfPeriod($start, $range); |             $end = app('navigation')->endOfPeriod($start, $range); | ||||||
|         } |         } | ||||||
|         // @codeCoverageIgnoreEnd |         // @codeCoverageIgnoreEnd | ||||||
|  |         if ($end->lt($start)) { | ||||||
|  |             [$start, $end] = [$end, $start]; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         $startDate = clone $start; |         $startDate = clone $start; | ||||||
|         $startDate->subDay(); |         $startDate->subDay(); | ||||||
| @@ -163,6 +167,11 @@ class ReconcileController extends Controller | |||||||
|         } |         } | ||||||
|         Log::debug('Reconciled all transactions.'); |         Log::debug('Reconciled all transactions.'); | ||||||
|  |  | ||||||
|  |         // switch dates if necessary | ||||||
|  |         if ($end->lt($start)) { | ||||||
|  |             [$start, $end] = [$end, $start]; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         // create reconciliation transaction (if necessary): |         // create reconciliation transaction (if necessary): | ||||||
|         $result = ''; |         $result = ''; | ||||||
|         if ('create' === $data['reconcile']) { |         if ('create' === $data['reconcile']) { | ||||||
| @@ -182,9 +191,16 @@ class ReconcileController extends Controller | |||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Creates a reconciliation group. |      * Creates a reconciliation group. | ||||||
|  |      * | ||||||
|  |      * @param Account $account | ||||||
|  |      * @param Carbon  $start | ||||||
|  |      * @param Carbon  $end | ||||||
|  |      * @param string  $difference | ||||||
|  |      * | ||||||
|      * @return string |      * @return string | ||||||
|  |      * @throws \FireflyIII\Exceptions\DuplicateTransactionException | ||||||
|      */ |      */ | ||||||
|     private function createReconciliation(Account $account, Carbon $start, Carbon $end, string $difference): string |     private function createReconciliation(Account $account, Carbon $start, Carbon $end, string $difference) | ||||||
|     { |     { | ||||||
|         if (!$this->isEditableAccount($account)) { |         if (!$this->isEditableAccount($account)) { | ||||||
|             return $this->redirectAccountToAccount($account); // @codeCoverageIgnore |             return $this->redirectAccountToAccount($account); // @codeCoverageIgnore | ||||||
| @@ -199,6 +215,10 @@ class ReconcileController extends Controller | |||||||
|             $destination = $reconciliation; |             $destination = $reconciliation; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         if ($end->lt($start)) { | ||||||
|  |             [$start, $end] = [$end, $start]; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         // title: |         // title: | ||||||
|         $description = trans('firefly.reconciliation_transaction_title', |         $description = trans('firefly.reconciliation_transaction_title', | ||||||
|                              ['from' => $start->formatLocalized($this->monthAndDayFormat), 'to'   => $end->formatLocalized($this->monthAndDayFormat)]); |                              ['from' => $start->formatLocalized($this->monthAndDayFormat), 'to'   => $end->formatLocalized($this->monthAndDayFormat)]); | ||||||
|   | |||||||
| @@ -93,6 +93,11 @@ class ReconcileController extends Controller | |||||||
|         $accountCurrency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency(); |         $accountCurrency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency(); | ||||||
|         $amount          = '0'; |         $amount          = '0'; | ||||||
|         $clearedAmount   = '0'; |         $clearedAmount   = '0'; | ||||||
|  |  | ||||||
|  |         if ($end->lt($start)) { | ||||||
|  |             [$start, $end] = [$end, $start]; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         $route           = route('accounts.reconcile.submit', [$account->id, $start->format('Ymd'), $end->format('Ymd')]); |         $route           = route('accounts.reconcile.submit', [$account->id, $start->format('Ymd'), $end->format('Ymd')]); | ||||||
|         $selectedIds     = $request->get('journals') ?? []; |         $selectedIds     = $request->get('journals') ?? []; | ||||||
|         $clearedJournals = []; |         $clearedJournals = []; | ||||||
| @@ -171,6 +176,9 @@ class ReconcileController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function transactions(Account $account, Carbon $start, Carbon $end) |     public function transactions(Account $account, Carbon $start, Carbon $end) | ||||||
|     { |     { | ||||||
|  |         if ($end->lt($start)) { | ||||||
|  |             [$end, $start] = [$start, $end]; | ||||||
|  |         } | ||||||
|         $startDate = clone $start; |         $startDate = clone $start; | ||||||
|         $startDate->subDay(); |         $startDate->subDay(); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user