Skip to content

Commit

Permalink
close #665 Fixed: Reconciliation missing currency then it wrong calcu…
Browse files Browse the repository at this point in the history
…late
  • Loading branch information
cuneytsenturk committed Dec 4, 2018
1 parent bc8a130 commit f8ba272
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/Http/Controllers/Banking/Reconciliations.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Http\Controllers\Controller;
use App\Http\Requests\Banking\Reconciliation as Request;
use App\Http\Requests\Banking\ReconciliationCalculate as CalculateRequest;
use App\Models\Banking\Account;
use App\Models\Banking\Reconciliation;
use App\Models\Setting\Currency;
Expand Down Expand Up @@ -278,17 +279,17 @@ public function getOpeningBalance($account, $started_at)
return $total;
}

public function calculate()
public function calculate(CalculateRequest $request)
{
$currency_code = request('currency_code');
$closing_balance = request('closing_balance');
$currency_code = $request['currency_code'];
$closing_balance = $request['closing_balance'];

$json = new \stdClass();

$cleared_amount = $difference = $income_total = $expense_total = 0;

if ($transactions = request('transactions')) {
$opening_balance = request('opening_balance');
if ($transactions = $request['transactions']) {
$opening_balance = $request['opening_balance'];

foreach ($transactions as $key => $value) {
$model = explode('_', $key);
Expand Down
32 changes: 32 additions & 0 deletions app/Http/Requests/Banking/ReconciliationCalculate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Http\Requests\Banking;

use App\Http\Requests\Request;

class ReconciliationCalculate extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'currency_code' => 'required|string|currency',
'closing_balance' => 'required',
'transactions' => 'required',
];
}
}

0 comments on commit f8ba272

Please sign in to comment.