Reconciliations multi currency and calculate fixed.
This commit is contained in:
		@@ -10,7 +10,7 @@
 | 
			
		||||
                </span>
 | 
			
		||||
            </div>
 | 
			
		||||
 | 
			
		||||
            <money :name="name" @input="input" :placeholder="placeholder" v-bind="money" :value="value" :disabled="disabled" :masked="masked" class="form-control"></money>
 | 
			
		||||
            <money :name="name" @input="input" :placeholder="placeholder" v-bind="money" :value="model" :disabled="disabled" :masked="masked" class="form-control"></money>
 | 
			
		||||
        </div>
 | 
			
		||||
 | 
			
		||||
        <div class="invalid-feedback d-block" v-if="error" v-html="error"></div>
 | 
			
		||||
@@ -133,10 +133,14 @@ export default {
 | 
			
		||||
        change() {
 | 
			
		||||
            //this.$emit('change', this.model);
 | 
			
		||||
            //this.$emit('interface', this.model);
 | 
			
		||||
 | 
			
		||||
            this.$emit('input', this.model);
 | 
			
		||||
        },
 | 
			
		||||
        input(event) {
 | 
			
		||||
            this.model = event;
 | 
			
		||||
 | 
			
		||||
            this.$emit('input', event);
 | 
			
		||||
 | 
			
		||||
            //this.$emit('change', this.model);
 | 
			
		||||
            //this.$emit('interface', this.model);
 | 
			
		||||
        }
 | 
			
		||||
@@ -144,6 +148,10 @@ export default {
 | 
			
		||||
 | 
			
		||||
    watch: {
 | 
			
		||||
        dynamicCurrency: function (currency) {
 | 
			
		||||
            if (!currency) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            this.money = {
 | 
			
		||||
                decimal: currency.decimal_mark,
 | 
			
		||||
                thousands: currency.thousands_separator,
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,9 @@ const app = new Vue({
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    mounted() {
 | 
			
		||||
        this.totals.closing_balance = parseFloat(document.getElementById('closing_balance').value);
 | 
			
		||||
        if (document.getElementById('closing_balance') != null) {
 | 
			
		||||
            this.totals.closing_balance = parseFloat(document.getElementById('closing_balance').value);
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    methods:{
 | 
			
		||||
@@ -59,10 +61,13 @@ const app = new Vue({
 | 
			
		||||
            let transactions = this.form.transactions;
 | 
			
		||||
 | 
			
		||||
            let cleared_amount = 0;
 | 
			
		||||
            let closing_balance = parseFloat(this.form.closing_balance);
 | 
			
		||||
            let difference = 0;
 | 
			
		||||
            let income_total = 0;
 | 
			
		||||
            let expense_total = 0;
 | 
			
		||||
 | 
			
		||||
            this.totals.closing_balance = closing_balance;
 | 
			
		||||
 | 
			
		||||
            if (transactions) {
 | 
			
		||||
                // get all transactions.
 | 
			
		||||
                Object.keys(transactions).forEach(function(transaction) {
 | 
			
		||||
@@ -79,10 +84,17 @@ const app = new Vue({
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
                cleared_amount = parseFloat(this.form.opening_balance) + parseFloat(income_total - expense_total);
 | 
			
		||||
 | 
			
		||||
                let transaction_total = income_total - expense_total;
 | 
			
		||||
 | 
			
		||||
                cleared_amount = parseFloat(this.form.opening_balance) + transaction_total;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            difference = parseFloat(this.form.closing_balance) - cleared_amount;
 | 
			
		||||
            if (cleared_amount > 0) {
 | 
			
		||||
                difference = parseFloat(this.form.closing_balance) - parseFloat(cleared_amount);
 | 
			
		||||
            } else {
 | 
			
		||||
                difference = parseFloat(this.form.closing_balance) + parseFloat(cleared_amount);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (difference != 0) {
 | 
			
		||||
                this.difference = 'table-danger';
 | 
			
		||||
@@ -92,7 +104,7 @@ const app = new Vue({
 | 
			
		||||
                this.reconcile = false;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            this.totals.cleared_amount = cleared_amount;
 | 
			
		||||
            this.totals.cleared_amount = parseFloat(cleared_amount);
 | 
			
		||||
            this.totals.difference = difference;
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ return [
 | 
			
		||||
 | 
			
		||||
    'reconcile'             => 'Reconcile',
 | 
			
		||||
    'reconciled'            => 'Reconciled',
 | 
			
		||||
    'opening_balance'       => 'Opening Balance',
 | 
			
		||||
    'closing_balance'       => 'Closing Balance',
 | 
			
		||||
    'unreconciled'          => 'Unreconciled',
 | 
			
		||||
    'transactions'          => 'Transactions',
 | 
			
		||||
 
 | 
			
		||||
@@ -16,11 +16,11 @@
 | 
			
		||||
 | 
			
		||||
            <div class="card-body">
 | 
			
		||||
                <div class="row align-items-center">
 | 
			
		||||
                    {{ Form::dateGroup('started_at', trans('reconciliations.start_date'), 'calendar', ['id' => 'started_at', 'class' => 'form-control datepicker', 'required' => 'required', 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], request('started_at'), 'col-xl-3') }}
 | 
			
		||||
                    {{ Form::dateGroup('started_at', trans('reconciliations.start_date'), 'calendar', ['id' => 'started_at', 'class' => 'form-control datepicker', 'required' => 'required', 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], request('started_at', Date::now()->firstOfMonth()->toDateString()), 'col-xl-3') }}
 | 
			
		||||
 | 
			
		||||
                    {{ Form::dateGroup('ended_at', trans('reconciliations.end_date'), 'calendar', ['id' => 'ended_at', 'class' => 'form-control datepicker', 'required' => 'required', 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], request('ended_at'), 'col-xl-3') }}
 | 
			
		||||
                    {{ Form::dateGroup('ended_at', trans('reconciliations.end_date'), 'calendar', ['id' => 'ended_at', 'class' => 'form-control datepicker', 'required' => 'required', 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], request('ended_at', Date::now()->endOfMonth()->toDateString()), 'col-xl-3') }}
 | 
			
		||||
 | 
			
		||||
                    {{ Form::moneyGroup('closing_balance', trans('reconciliations.closing_balance'), 'balance-scale', ['required' => 'required', 'autofocus' => 'autofocus', 'currency' => $currency], request('closing_balance', 0.00), 'col-xl-2') }}
 | 
			
		||||
                    {{ Form::moneyGroup('closing_balance', trans('reconciliations.closing_balance'), 'balance-scale', ['required' => 'required', 'autofocus' => 'autofocus', 'currency' => $currency, 'dynamic-currency' => 'currency', 'input' => 'onCalculate'], request('closing_balance', 0.00), 'col-xl-2') }}
 | 
			
		||||
 | 
			
		||||
                    {{ Form::selectAddNewGroup('account_id', trans_choice('general.accounts', 1), 'university', $accounts, request('account_id', setting('default.account')), ['required' => 'required', 'path' => route('modals.accounts.create'), 'change' => 'onChangeAccount'], 'col-xl-2') }}
 | 
			
		||||
 | 
			
		||||
@@ -83,7 +83,7 @@
 | 
			
		||||
                                @endif
 | 
			
		||||
                                <td class="col-md-1 text-right d-none d-md-block">
 | 
			
		||||
                                    <div class="custom-control custom-checkbox">
 | 
			
		||||
                                        {{ Form::checkbox($item->type . '_' . $item->id, $item->amount, $item->reconciled, [
 | 
			
		||||
                                        {{ Form::checkbox($item->type . '_' . $item->id, $item->price, $item->reconciled, [
 | 
			
		||||
                                            'data-field' => 'transactions',
 | 
			
		||||
                                            'v-model' => 'form.transactions.' . $item->type . '_' . $item->id,
 | 
			
		||||
                                            'id' => 'transaction-' . $item->id . '-'. $item->type,
 | 
			
		||||
@@ -100,6 +100,12 @@
 | 
			
		||||
                @if ($transactions->count())
 | 
			
		||||
                    <table class="table">
 | 
			
		||||
                        <tbody>
 | 
			
		||||
                            <tr class="row">
 | 
			
		||||
                                <th class="col-md-9 col-lg-11 text-right d-none d-md-block">{{ trans('reconciliations.opening_balance') }}:</th>
 | 
			
		||||
                                <td id="closing-balance" class="col-md-3 col-lg-1 text-right d-none d-md-block">
 | 
			
		||||
                                    <span>@money($opening_balance, $account->currency_code, true)</span>
 | 
			
		||||
                                </td>
 | 
			
		||||
                            </tr>
 | 
			
		||||
                            <tr class="row">
 | 
			
		||||
                                <th class="col-md-9 col-lg-11 text-right d-none d-md-block">{{ trans('reconciliations.closing_balance') }}:</th>
 | 
			
		||||
                                <td id="closing-balance" class="col-md-3 col-lg-1 text-right d-none d-md-block">
 | 
			
		||||
 
 | 
			
		||||
@@ -70,34 +70,40 @@
 | 
			
		||||
                    </tbody>
 | 
			
		||||
                </table>
 | 
			
		||||
                @if ($transactions->count())
 | 
			
		||||
                <table class="table">
 | 
			
		||||
                    <tbody>
 | 
			
		||||
                        <tr class="row">
 | 
			
		||||
                            <th class="col-md-9 col-lg-11 text-right d-none d-md-block">{{ trans('reconciliations.closing_balance') }}:</th>
 | 
			
		||||
                            <td id="closing-balance" class="col-md-3 col-lg-1 text-right d-none d-md-block">
 | 
			
		||||
                                {{ Form::moneyGroup('closing_balance_total', '', '', ['disabled' => true, 'required' => 'required', 'v-model' => 'totals.closing_balance', 'currency' => $currency, 'masked' => 'true'], $reconciliation->closing_balance, 'text-right d-none') }}
 | 
			
		||||
                                <span id="closing-balance-total" v-if="totals.closing_balance" v-html="totals.closing_balance"></span>
 | 
			
		||||
                                <span v-else>@money($reconciliation->closing_balance, $account->currency_code, true)</span>
 | 
			
		||||
                            </td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
                        <tr class="row">
 | 
			
		||||
                            <th class="col-md-9 col-lg-11 text-right d-none d-md-block">{{ trans('reconciliations.cleared_amount') }}:</th>
 | 
			
		||||
                            <td id="cleared-amount" class="col-md-3 col-lg-1 text-right d-none d-md-block">
 | 
			
		||||
                                {{ Form::moneyGroup('cleared_amount_total', '', '', ['disabled' => true, 'required' => 'required', 'v-model' => 'totals.cleared_amount', 'currency' => $currency, 'masked' => 'true'], 0.00, 'text-right d-none') }}
 | 
			
		||||
                                <span id="cleared-amount-total" v-if="totals.cleared_amount" v-html="totals.cleared_amount"></span>
 | 
			
		||||
                                <span v-else>@money(0, $account->currency_code, true)</span>
 | 
			
		||||
                            </td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
                        <tr :class="difference" class="row">
 | 
			
		||||
                            <th class="col-md-9 col-lg-11 text-right d-none d-md-block">{{ trans('general.difference') }}:</th>
 | 
			
		||||
                            <td id="difference" class="col-md-3 col-lg-1 text-right d-none d-md-block">
 | 
			
		||||
                                {{ Form::moneyGroup('difference_total', '', '', ['disabled' => true, 'required' => 'required', 'v-model' => 'totals.difference', 'currency' => $currency, 'masked' => 'true'], 0.00, 'text-right d-none') }}
 | 
			
		||||
                                <span id="difference-total" v-if="totals.difference" v-html="totals.difference"></span>
 | 
			
		||||
                                <span v-else>@money(0, $account->currency_code, true)</span>
 | 
			
		||||
                            </td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
                    </tbody>
 | 
			
		||||
                </table>
 | 
			
		||||
                    <table class="table">
 | 
			
		||||
                        <tbody>
 | 
			
		||||
                            <tr class="row">
 | 
			
		||||
                                <th class="col-md-9 col-lg-11 text-right d-none d-md-block">{{ trans('reconciliations.opening_balance') }}:</th>
 | 
			
		||||
                                <td id="closing-balance" class="col-md-3 col-lg-1 text-right d-none d-md-block">
 | 
			
		||||
                                    <span>@money($opening_balance, $account->currency_code, true)</span>
 | 
			
		||||
                                </td>
 | 
			
		||||
                            </tr>
 | 
			
		||||
                            <tr class="row">
 | 
			
		||||
                                <th class="col-md-9 col-lg-11 text-right d-none d-md-block">{{ trans('reconciliations.closing_balance') }}:</th>
 | 
			
		||||
                                <td id="closing-balance" class="col-md-3 col-lg-1 text-right d-none d-md-block">
 | 
			
		||||
                                    {{ Form::moneyGroup('closing_balance_total', '', '', ['disabled' => true, 'required' => 'required', 'v-model' => 'totals.closing_balance', 'currency' => $currency, 'masked' => 'true'], $reconciliation->closing_balance, 'text-right d-none') }}
 | 
			
		||||
                                    <span id="closing-balance-total" v-if="totals.closing_balance" v-html="totals.closing_balance"></span>
 | 
			
		||||
                                    <span v-else>@money($reconciliation->closing_balance, $account->currency_code, true)</span>
 | 
			
		||||
                                </td>
 | 
			
		||||
                            </tr>
 | 
			
		||||
                            <tr class="row">
 | 
			
		||||
                                <th class="col-md-9 col-lg-11 text-right d-none d-md-block">{{ trans('reconciliations.cleared_amount') }}:</th>
 | 
			
		||||
                                <td id="cleared-amount" class="col-md-3 col-lg-1 text-right d-none d-md-block">
 | 
			
		||||
                                    {{ Form::moneyGroup('cleared_amount_total', '', '', ['disabled' => true, 'required' => 'required', 'v-model' => 'totals.cleared_amount', 'currency' => $currency, 'masked' => 'true'], 0.00, 'text-right d-none') }}
 | 
			
		||||
                                    <span id="cleared-amount-total" v-if="totals.cleared_amount" v-html="totals.cleared_amount"></span>
 | 
			
		||||
                                    <span v-else>@money(0, $account->currency_code, true)</span>
 | 
			
		||||
                                </td>
 | 
			
		||||
                            </tr>
 | 
			
		||||
                            <tr :class="difference" class="row">
 | 
			
		||||
                                <th class="col-md-9 col-lg-11 text-right d-none d-md-block">{{ trans('general.difference') }}:</th>
 | 
			
		||||
                                <td id="difference" class="col-md-3 col-lg-1 text-right d-none d-md-block">
 | 
			
		||||
                                    {{ Form::moneyGroup('difference_total', '', '', ['disabled' => true, 'required' => 'required', 'v-model' => 'totals.difference', 'currency' => $currency, 'masked' => 'true'], 0.00, 'text-right d-none') }}
 | 
			
		||||
                                    <span id="difference-total" v-if="totals.difference" v-html="totals.difference"></span>
 | 
			
		||||
                                    <span v-else>@money(0, $account->currency_code, true)</span>
 | 
			
		||||
                                </td>
 | 
			
		||||
                            </tr>
 | 
			
		||||
                        </tbody>
 | 
			
		||||
                    </table>
 | 
			
		||||
                @endif
 | 
			
		||||
            </div>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -49,6 +49,10 @@
 | 
			
		||||
        @change="{{ $attributes['change'] }}($event)"
 | 
			
		||||
        @endif
 | 
			
		||||
 | 
			
		||||
        @if (!empty($attributes['input']))
 | 
			
		||||
        @input="{{ $attributes['input'] }}"
 | 
			
		||||
        @endif
 | 
			
		||||
 | 
			
		||||
        @if (!empty($attributes['v-model']))
 | 
			
		||||
        @interface="{{ $attributes['v-model'] . ' = $event' }}"
 | 
			
		||||
        @elseif (!empty($attributes['data-field']))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user