Merge pull request #2118 from brkcvn/min-date-control
Flatpickr minimum date controlled Invoice and Reconciliations page.
This commit is contained in:
commit
856e10a2dd
@ -5,6 +5,7 @@
|
|||||||
{'readonly': readonly},
|
{'readonly': readonly},
|
||||||
{'disabled': disabled},
|
{'disabled': disabled},
|
||||||
{'hidden-year': hiddenYear},
|
{'hidden-year': hiddenYear},
|
||||||
|
{'data-value-min': dataValueMin},
|
||||||
formClasses
|
formClasses
|
||||||
]"
|
]"
|
||||||
:footer-error="formError"
|
:footer-error="formError"
|
||||||
@ -98,6 +99,9 @@ export default {
|
|||||||
},
|
},
|
||||||
hiddenYear: {
|
hiddenYear: {
|
||||||
type: [Boolean, String]
|
type: [Boolean, String]
|
||||||
|
},
|
||||||
|
dataValueMin: {
|
||||||
|
type: [Boolean, String, Date]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -149,7 +153,11 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
value: function(val) {
|
value: function(val) {
|
||||||
this.real_model = val;
|
this.real_model = val;
|
||||||
}
|
},
|
||||||
|
|
||||||
|
dataValueMin: function(val) {
|
||||||
|
this.dateConfig.minDate = val;
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
234
resources/assets/js/views/banking/reconciliations.js
vendored
234
resources/assets/js/views/banking/reconciliations.js
vendored
@ -4,118 +4,124 @@
|
|||||||
* building robust, powerful web applications using Vue and Laravel.
|
* building robust, powerful web applications using Vue and Laravel.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require('./../../bootstrap');
|
require('./../../bootstrap');
|
||||||
|
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
|
|
||||||
import DashboardPlugin from './../../plugins/dashboard-plugin';
|
import DashboardPlugin from './../../plugins/dashboard-plugin';
|
||||||
|
|
||||||
import Global from './../../mixins/global';
|
import Global from './../../mixins/global';
|
||||||
|
|
||||||
import Form from './../../plugins/form';
|
import Form from './../../plugins/form';
|
||||||
import BulkAction from './../../plugins/bulk-action';
|
import BulkAction from './../../plugins/bulk-action';
|
||||||
|
|
||||||
// plugin setup
|
// plugin setup
|
||||||
Vue.use(DashboardPlugin);
|
Vue.use(DashboardPlugin);
|
||||||
|
|
||||||
const app = new Vue({
|
const app = new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
|
|
||||||
mixins: [
|
mixins: [
|
||||||
Global
|
Global
|
||||||
],
|
],
|
||||||
|
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
form: new Form('reconciliation'),
|
form: new Form('reconciliation'),
|
||||||
bulk_action: new BulkAction('reconciliations'),
|
bulk_action: new BulkAction('reconciliations'),
|
||||||
reconcile: true,
|
reconcile: true,
|
||||||
difference: null,
|
difference: null,
|
||||||
totals: {
|
totals: {
|
||||||
closing_balance: 0,
|
closing_balance: 0,
|
||||||
cleared_amount: 0,
|
cleared_amount: 0,
|
||||||
difference: 0,
|
difference: 0,
|
||||||
},
|
},
|
||||||
}
|
min_due_date: false
|
||||||
},
|
}
|
||||||
|
},
|
||||||
mounted() {
|
|
||||||
if (document.getElementById('closing_balance') != null) {
|
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);
|
||||||
|
}
|
||||||
if (this.form._method == 'PATCH') {
|
|
||||||
this.onCalculate();
|
if (this.form._method == 'PATCH') {
|
||||||
}
|
this.onCalculate();
|
||||||
},
|
}
|
||||||
|
},
|
||||||
methods:{
|
|
||||||
onReconcilition() {
|
methods:{
|
||||||
let form = document.getElementById('form-create-reconciliation');
|
setDueMinDate(date) {
|
||||||
|
this.min_due_date = date;
|
||||||
let path = form.action +'?started_at=' + this.form.started_at + '&ended_at=' + this.form.ended_at + '&closing_balance=' + this.form.closing_balance + '&account_id=' + this.form.account_id;
|
},
|
||||||
|
|
||||||
window.location.href = path;
|
onReconcilition() {
|
||||||
},
|
let form = document.getElementById('form-create-reconciliation');
|
||||||
|
|
||||||
onCalculate() {
|
let path = form.action +'?started_at=' + this.form.started_at + '&ended_at=' + this.form.ended_at + '&closing_balance=' + this.form.closing_balance + '&account_id=' + this.form.account_id;
|
||||||
this.reconcile = true;
|
|
||||||
this.difference = null;
|
window.location.href = path;
|
||||||
|
},
|
||||||
let transactions = this.form.transactions;
|
|
||||||
|
onCalculate() {
|
||||||
let cleared_amount = 0;
|
this.reconcile = true;
|
||||||
let closing_balance = parseFloat(this.form.closing_balance);
|
this.difference = null;
|
||||||
let difference = 0;
|
|
||||||
let income_total = 0;
|
let transactions = this.form.transactions;
|
||||||
let expense_total = 0;
|
|
||||||
|
let cleared_amount = 0;
|
||||||
this.totals.closing_balance = closing_balance;
|
let closing_balance = parseFloat(this.form.closing_balance);
|
||||||
|
let difference = 0;
|
||||||
if (transactions) {
|
let income_total = 0;
|
||||||
// get all transactions.
|
let expense_total = 0;
|
||||||
Object.keys(transactions).forEach(function(transaction) {
|
|
||||||
if (!transactions[transaction]) {
|
this.totals.closing_balance = closing_balance;
|
||||||
return;
|
|
||||||
}
|
if (transactions) {
|
||||||
|
// get all transactions.
|
||||||
let type = transaction.split('_');
|
Object.keys(transactions).forEach(function(transaction) {
|
||||||
|
if (!transactions[transaction]) {
|
||||||
if (type[0] == 'income') {
|
return;
|
||||||
income_total += parseFloat(document.getElementById('transaction-' + type[1] + '-' + type[0]).value);
|
}
|
||||||
} else {
|
|
||||||
expense_total += parseFloat(document.getElementById('transaction-' + type[1] + '-' + type[0]).value);
|
let type = transaction.split('_');
|
||||||
}
|
|
||||||
});
|
if (type[0] == 'income') {
|
||||||
|
income_total += parseFloat(document.getElementById('transaction-' + type[1] + '-' + type[0]).value);
|
||||||
|
} else {
|
||||||
let transaction_total = income_total - expense_total;
|
expense_total += parseFloat(document.getElementById('transaction-' + type[1] + '-' + type[0]).value);
|
||||||
|
}
|
||||||
cleared_amount = parseFloat(this.form.opening_balance) + transaction_total;
|
});
|
||||||
}
|
|
||||||
|
|
||||||
if (cleared_amount > 0) {
|
let transaction_total = income_total - expense_total;
|
||||||
difference = (parseFloat(this.form.closing_balance) - parseFloat(cleared_amount)).toFixed(this.currency.precision);
|
|
||||||
} else {
|
cleared_amount = parseFloat(this.form.opening_balance) + transaction_total;
|
||||||
difference = (parseFloat(this.form.closing_balance) + parseFloat(cleared_amount)).toFixed(this.currency.precision);
|
}
|
||||||
}
|
|
||||||
|
if (cleared_amount > 0) {
|
||||||
if (difference != 0) {
|
difference = (parseFloat(this.form.closing_balance) - parseFloat(cleared_amount)).toFixed(this.currency.precision);
|
||||||
this.difference = 'table-danger';
|
} else {
|
||||||
this.reconcile = true;
|
difference = (parseFloat(this.form.closing_balance) + parseFloat(cleared_amount)).toFixed(this.currency.precision);
|
||||||
} else {
|
}
|
||||||
this.difference = 'table-success';
|
|
||||||
this.reconcile = false;
|
if (difference != 0) {
|
||||||
}
|
this.difference = 'table-danger';
|
||||||
|
this.reconcile = true;
|
||||||
this.totals.cleared_amount = parseFloat(cleared_amount);
|
} else {
|
||||||
this.totals.difference = difference;
|
this.difference = 'table-success';
|
||||||
},
|
this.reconcile = false;
|
||||||
|
}
|
||||||
onReconcileSubmit() {
|
|
||||||
this.form.reconcile = 1;
|
this.totals.cleared_amount = parseFloat(cleared_amount);
|
||||||
|
this.totals.difference = difference;
|
||||||
this.form.submit();
|
},
|
||||||
}
|
|
||||||
},
|
onReconcileSubmit() {
|
||||||
});
|
this.form.reconcile = 1;
|
||||||
|
|
||||||
|
this.form.submit();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
1282
resources/assets/js/views/common/documents.js
vendored
1282
resources/assets/js/views/common/documents.js
vendored
File diff suppressed because it is too large
Load Diff
@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row align-items-center">
|
<div class="row align-items-center">
|
||||||
{{ Form::dateGroup('started_at', trans('reconciliations.start_date'), 'calendar', ['id' => 'started_at', 'class' => 'form-control datepicker', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], request('started_at', Date::now()->firstOfMonth()->toDateString()), 'col-xl-3') }}
|
{{ Form::dateGroup('started_at', trans('reconciliations.start_date'), 'calendar', ['id' => 'started_at', 'class' => 'form-control datepicker', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off', 'change' => 'setDueMinDate'], 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', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], request('ended_at', Date::now()->endOfMonth()->toDateString()), 'col-xl-3') }}
|
{{ Form::dateGroup('ended_at', trans('reconciliations.end_date'), 'calendar', ['id' => 'ended_at', 'class' => 'form-control datepicker', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off', 'min-date' => 'form.started_at', 'min-date-dynamic' => 'min_due_date', 'data-value-min' => true], 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, 'dynamic-currency' => 'currency', 'input' => 'onCalculate'], 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') }}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<div class="col-sm-6 col-md-6 col-lg-6 col-xl-6">
|
<div class="col-sm-6 col-md-6 col-lg-6 col-xl-6">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@if (!$hideIssuedAt)
|
@if (!$hideIssuedAt)
|
||||||
{{ Form::dateGroup('issued_at', trans($textIssuedAt), 'calendar', ['id' => 'issued_at', 'class' => 'form-control datepicker', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], $issuedAt) }}
|
{{ Form::dateGroup('issued_at', trans($textIssuedAt), 'calendar', ['id' => 'issued_at', 'class' => 'form-control datepicker', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off', 'change' => 'setDueMinDate'], $issuedAt) }}
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if (!$hideDocumentNumber)
|
@if (!$hideDocumentNumber)
|
||||||
@ -30,7 +30,7 @@
|
|||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if (!$hideDueAt)
|
@if (!$hideDueAt)
|
||||||
{{ Form::dateGroup('due_at', trans($textDueAt), 'calendar', ['id' => 'due_at', 'class' => 'form-control datepicker', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], $dueAt) }}
|
{{ Form::dateGroup('due_at', trans($textDueAt), 'calendar', ['id' => 'due_at', 'class' => 'form-control datepicker', 'required' => 'required', 'show-date-format' => company_date_format(), 'date-format' => 'Y-m-d', 'autocomplete' => 'off', 'min-date' => 'form.issued_at', 'min-date-dynamic' => 'min_due_date', 'data-value-min' => true], $dueAt) }}
|
||||||
@else
|
@else
|
||||||
{{ Form::hidden('due_at', old('issued_at', $issuedAt), ['id' => 'due_at', 'v-model' => 'form.issued_at']) }}
|
{{ Form::hidden('due_at', old('issued_at', $issuedAt), ['id' => 'due_at', 'v-model' => 'form.issued_at']) }}
|
||||||
@endif
|
@endif
|
||||||
|
@ -55,6 +55,10 @@
|
|||||||
hidden-year
|
hidden-year
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if (!empty($attributes['min-date-dynamic']))
|
||||||
|
:data-value-min="{{ $attributes['min-date-dynamic'] }}"
|
||||||
|
@endif
|
||||||
|
|
||||||
@if (!empty($attributes['change']))
|
@if (!empty($attributes['change']))
|
||||||
@change="{{ $attributes['change'] }}"
|
@change="{{ $attributes['change'] }}"
|
||||||
@endif
|
@endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user