Merge pull request #2408 from sevannerse/connect-split-transaction

Connect split transaction
This commit is contained in:
Denis Duliçi
2022-06-05 03:13:34 +03:00
committed by GitHub
6 changed files with 104 additions and 37 deletions

View File

@ -32,7 +32,7 @@
@click="onItemSelected(item)"
>
<div class="w-full flex items-center justify-between">
<span>{{ item.name }}</span>
<span class="w-9/12">{{ item.name }}</span>
<money
:name="'item-id-' + item.id"
@ -40,7 +40,25 @@
v-bind="money"
masked
disabled
class="text-right disabled-money text-gray"
class="w-1/12 text-right disabled-money text-gray"
></money>
-
<money
:name="'item-id-' + item.id"
:value="item.paid"
v-bind="money"
masked
disabled
class="w-1/12 text-right disabled-money text-gray"
></money>
=
<money
:name="'item-id-' + item.id"
:value="item.open"
v-bind="money"
masked
disabled
class="w-1/12 text-right disabled-money text-gray"
></money>
</div>
</div>
@ -180,6 +198,8 @@ export default {
id: item.id,
name: item.document_number + ' | ' + item.contact_name + (item.notes ? ' | ' + item.notes : ''),
amount: item.amount,
paid: item.paid,
open: item.amount - item.paid,
});
}, this);
}

View File

@ -38,20 +38,31 @@ const app = new Vue({
},
methods: {
onConnect(transaction, currency, documents) {
this.connect.show = true;
onConnect(route) {
let dial_promise = Promise.resolve(window.axios.get(route));
this.connect.transaction = transaction;
dial_promise.then(response => {
this.connect.show = true;
this.connect.currency = {
decimal_mark: currency.decimal_mark,
precision: currency.precision,
symbol: currency.symbol,
symbol_first: currency.symbol_first,
thousands_separator: currency.thousands_separator,
};
this.connect.transaction = JSON.parse(response.data.transaction);
this.connect.documents = documents;
let currency = JSON.parse(response.data.currency);
this.connect.currency = {
decimal_mark: currency.decimal_mark,
precision: currency.precision,
symbol: currency.symbol,
symbol_first: currency.symbol_first,
thousands_separator: currency.thousands_separator,
};
this.connect.documents = JSON.parse(response.data.documents);
})
.catch(error => {
})
.finally(function () {
// always executed
});
},
async onEmail(route) {

View File

@ -22,18 +22,16 @@
@stack('connect_button_start')
@if ($transaction->is_splittable && empty($transaction->document_id))
@if ($transaction->is_splittable && empty($transaction->document_id) && empty($transaction->recurring))
@if (! $hideButtonConnect)
@can($permissionCreate)
@if ($type == 'income' && $transaction->contact->exists)
<button type="button" class="w-full flex items-center text-purple px-2 h-9 leading-9 whitespace-nowrap" title="{{ trans('general.connect') }}" @click="onConnect({{ $transaction->load('account')->toJson() }}, {{ $transaction->currency->toJson() }}, {{ $transaction->contact->invoices()->notPaid()->where('currency_code', $transaction->currency_code)->with(['media', 'totals', 'transactions'])->get()->toJson() }})"><span class="w-full h-full flex items-center rounded-md px-2 text-sm hover:bg-lilac-100">{{ trans('general.connect') }}</span></button>
@elseif ($type == 'income' && ! $transaction->contact->exists)
<button type="button" class="w-full flex items-center text-purple px-2 h-9 leading-9 whitespace-nowrap" title="{{ trans('general.connect') }}" @click="onConnect({{ $transaction->load('account')->toJson() }}, {{ $transaction->currency->toJson() }}, {{ App\Models\Document\Document::invoice()->notPaid()->where('currency_code', $transaction->currency_code)->with(['media', 'totals', 'transactions'])->get()->toJson() }})"><span class="w-full h-full flex items-center rounded-md px-2 text-sm hover:bg-lilac-100">{{ trans('general.connect') }}</span></button>
@elseif ($type == 'expense' && $transaction->contact->exists)
<button type="button" class="w-full flex items-center text-purple px-2 h-9 leading-9 whitespace-nowrap" title="{{ trans('general.connect') }}" @click="onConnect({{ $transaction->load('account')->toJson() }}, {{ $transaction->currency->toJson() }}, {{ $transaction->contact->bills()->notPaid()->where('currency_code', $transaction->currency_code)->with(['media', 'totals', 'transactions'])->get()->toJson() }})"><span class="w-full h-full flex items-center rounded-md px-2 text-sm hover:bg-lilac-100">{{ trans('general.connect') }}</span></button>
@elseif ($type == 'expense' && ! $transaction->contact->exists)
<button type="button" class="w-full flex items-center text-purple px-2 h-9 leading-9 whitespace-nowrap" title="{{ trans('general.connect') }}" @click="onConnect({{ $transaction->load('account')->toJson() }}, {{ $transaction->currency->toJson() }}, {{ App\Models\Document\Document::bill()->notPaid()->where('currency_code', $transaction->currency_code)->with(['media', 'totals', 'transactions'])->get()->toJson() }})"><span class="w-full h-full flex items-center rounded-md px-2 text-sm hover:bg-lilac-100">{{ trans('general.connect') }}</span></button>
@endif
<button
type="button"
class="w-full flex items-center text-purple px-2 h-9 leading-9 whitespace-nowrap"
title="{{ trans('general.connect') }}"
@click="onConnect('{{ route('transactions.dial', $transaction->id) }}')">
<span class="w-full h-full flex items-center rounded-md px-2 text-sm hover:bg-lilac-100">{{ trans('general.connect') }}</span>
</button>
@endcan
@endif
@endif