Merge branch 'akaunting:master' into invoice-form-enhancements

This commit is contained in:
bengü thon mai mochi
2021-08-25 11:15:51 +03:00
committed by GitHub
148 changed files with 2103 additions and 1033 deletions

View File

@ -11,6 +11,7 @@
<el-select v-model="selected" :placeholder="placeholder" filterable
@change="change" @visible-change="visibleChange" @remove-tag="removeTag" @clear="clear" @blur="blur" @focus="focus"
:clearable="clearable"
:disabled="disabled"
:multiple="multiple"
:readonly="readonly"
@ -247,6 +248,12 @@ export default {
description: "Selectbox disabled status"
},
clearable: {
type: Boolean,
default: true,
description: "Selectbox clearable status"
},
disabled: {
type: Boolean,
default: false,
@ -384,13 +391,13 @@ export default {
for (const [key, value] of Object.entries(options)) {
values.push({
key: key,
key: key.toString(),
value: value
});
}
this.sorted_options.push({
key: index,
key: index.toString(),
value: values
});
}
@ -405,7 +412,7 @@ export default {
} else {
this.sorted_options.push({
index: index,
key: option.id,
key: option.id.toString(),
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
});
}
@ -416,7 +423,7 @@ export default {
if (!Array.isArray(created_options)) {
for (const [key, value] of Object.entries(created_options)) {
this.sorted_options.push({
key: key,
key: key.toString(),
value: value
});
}
@ -431,7 +438,7 @@ export default {
} else {
this.sorted_options.push({
index: index,
key: option.id,
key: option.id.toString(),
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
});
}
@ -654,6 +661,7 @@ export default {
}
})
.then(response => {
this.loading = false;
this.form.loading = false;
if (response.data.success) {
@ -675,10 +683,14 @@ export default {
this.add_new.html = '';
this.add_new_html = null;
response.data.data.mark_new = true;
this.$emit('new', response.data.data);
this.change();
this.$emit('visible-change', event);
let documentClasses = document.body.classList;
documentClasses.remove("modal-open");

View File

@ -11,6 +11,7 @@
<el-select v-model="selected" :placeholder="placeholder" filterable remote reserve-keyword
@change="change" @visible-change="visibleChange" @remove-tag="removeTag" @clear="clear" @blur="blur" @focus="focus"
:clearable="clearable"
:disabled="disabled"
:multiple="multiple"
:readonly="readonly"
@ -110,6 +111,7 @@
<span v-else>
<el-select v-model="selected" :placeholder="placeholder" filterable remote reserve-keyword
@change="change" @visible-change="visibleChange" @remove-tag="removeTag" @clear="clear" @blur="blur" @focus="focus"
:clearable="clearable"
:disabled="disabled"
:multiple="multiple"
:readonly="readonly"
@ -338,6 +340,12 @@ export default {
description: "Selectbox disabled status"
},
clearable: {
type: Boolean,
default: true,
description: "Selectbox clearable status"
},
disabled: {
type: Boolean,
default: false,

View File

@ -152,8 +152,10 @@ export default class BulkAction {
}));
type_promise.then(response => {
if (response.data.redirect) {
if (response.data.redirect === true) {
window.location.reload(false);
} else if (typeof response.data.redirect === 'string') {
window.location.href = response.data.redirect;
}
})
.catch(error => {

View File

@ -19,7 +19,7 @@ import BulkAction from './../../plugins/bulk-action';
Vue.use(DashboardPlugin);
const app = new Vue({
el: '#app',
el: '#main-body',
mixins: [
Global
@ -28,8 +28,7 @@ const app = new Vue({
data: function () {
return {
form: new Form('account'),
bulk_action: new BulkAction('accounts')
bulk_action: new BulkAction('accounts'),
}
},
});

View File

@ -19,7 +19,7 @@ import BulkAction from './../../plugins/bulk-action';
Vue.use(DashboardPlugin);
const app = new Vue({
el: '#app',
el: '#main-body',
mixins: [
Global

View File

@ -27,70 +27,74 @@ const app = new Vue({
],
data: function () {
return {
form: new Form('document'),
bulk_action: new BulkAction('documents'),
totals: {
sub: 0,
item_discount: '',
discount: '',
discount_text: false,
taxes: [],
total: 0
},
transaction: [],
edit: {
status: false,
currency: false,
items: 0,
},
colspan: 6,
discount: false,
tax: false,
discounts: [],
tax_id: [],
items: [],
taxes: [],
page_loaded: false,
currencies: [],
min_due_date: false,
currency_symbol: {
"name":"US Dollar",
"code":"USD",
"rate":1,
"precision":2,
"symbol":"$",
"symbol_first":1,
"decimal_mark":".",
"thousands_separator":","
},
dropdown_visible: true
}
return {
form: new Form('document'),
bulk_action: new BulkAction('documents'),
totals: {
sub: 0,
item_discount: '',
discount: '',
discount_text: false,
taxes: [],
total: 0
},
transaction: [],
edit: {
status: false,
currency: false,
items: 0,
},
colspan: 6,
discount: false,
tax: false,
discounts: [],
tax_id: [],
items: [],
taxes: [],
page_loaded: false,
currencies: [],
min_due_date: false,
currency_symbol: {
"name":"US Dollar",
"code":"USD",
"rate":1,
"precision":2,
"symbol":"$",
"symbol_first":1,
"decimal_mark":".",
"thousands_separator":","
},
dropdown_visible: true,
dynamic_taxes: [],
}
},
mounted() {
if ((document.getElementById('items') != null) && (document.getElementById('items').rows)) {
this.colspan = document.getElementById("items").rows[0].cells.length - 1;
}
if (!this.edit.status) {
this.dropdown_visible = false;
}
this.currency_symbol.rate = this.form.currency_rate;
this.form.discount_type = 'percentage';
if (company_currency_code) {
let default_currency_symbol = null;
if ((document.getElementById('items') != null) && (document.getElementById('items').rows)) {
this.colspan = document.getElementById("items").rows[0].cells.length - 1;
}
if (!this.edit.status) {
this.dropdown_visible = false;
}
this.currency_symbol.rate = this.form.currency_rate;
if (company_currency_code) {
let default_currency_symbol = null;
for (let symbol of this.currencies) {
if(symbol.code == company_currency_code) {
default_currency_symbol = symbol.symbol;
}
}
this.currency_symbol.symbol = default_currency_symbol;
}
for (let symbol of this.currencies) {
if(symbol.code == company_currency_code) {
default_currency_symbol = symbol.symbol;
}
}
this.currency_symbol.symbol = default_currency_symbol;
}
},
methods: {
@ -98,7 +102,7 @@ const app = new Vue({
let global_discount = parseFloat(this.form.discount);
let discount_total = 0;
let line_item_discount_total = 0;
let taxes = document_taxes;
let taxes = this.dynamic_taxes;
let sub_total = 0;
let totals_taxes = [];
let grand_total = 0;
@ -115,7 +119,19 @@ const app = new Vue({
let line_discount_amount = 0;
if (item.discount) {
line_discount_amount = item.total * (item.discount / 100);
if (item.discount_type === 'percentage') {
if (item.discount > 100) {
item.discount = 100;
}
line_discount_amount = item.total * (item.discount / 100);
} else {
if (parseInt(item.discount) > item.price) {
item.discount = item.price;
}
line_discount_amount = parseFloat(item.discount);
}
item.discount_amount = line_discount_amount
item_discounted_total = item.total -= line_discount_amount;
@ -124,12 +140,6 @@ const app = new Vue({
let item_discounted_total = item.total;
if (global_discount) {
item_discounted_total = item.total - (item.total * (global_discount / 100));
item_discount = global_discount;
}
// item tax calculate.
if (item.tax_ids) {
let inclusives = [];
@ -240,7 +250,11 @@ const app = new Vue({
// Apply discount to total
if (global_discount) {
discount_total = parseFloat(sub_total + inclusive_tax_total) * (global_discount / 100);
if (this.form.discount_type === 'percentage') {
discount_total = parseFloat(sub_total + inclusive_tax_total) * (global_discount / 100);
} else {
discount_total = global_discount;
}
this.totals.discount = discount_total;
@ -254,7 +268,7 @@ const app = new Vue({
this.form.items.forEach(function(form_item, form_index) {
let item = this.items[form_index];
for (const [key, value] of Object.entries(item)) {
if (key == 'add_tax' || key == 'tax_ids' || key == 'add_discount') {
continue
@ -352,7 +366,7 @@ const app = new Vue({
let selected_tax;
document_taxes.forEach(function(tax) {
this.dynamic_taxes.forEach(function(tax) {
if (tax.id == this.tax_id) {
selected_tax = tax;
}
@ -387,16 +401,35 @@ const app = new Vue({
},
onAddLineDiscount(item_index) {
this.items[item_index].discount_type = 'percentage';
this.items[item_index].add_discount = true;
},
onChangeDiscountType(type) {
this.form.discount_type = type;
this.onCalculateTotal();
},
onChangeLineDiscountType(item_index, type) {
this.items[item_index].discount_type = type;
this.onCalculateTotal();
},
onAddTotalDiscount() {
let discount = document.getElementById('pre-discount').value;
if (discount < 0) {
discount = 0;
} else if (discount > 100) {
discount = 100;
if (this.form.discount_type === 'percentage') {
if (discount < 0) {
discount = 0;
} else if (discount > 100) {
discount = 100;
}
} else {
if (discount < 0) {
discount = 0;
} else if (discount > this.totals.sub) {
discount = this.totals.sub;
}
}
document.getElementById('pre-discount').value = discount;
@ -620,6 +653,7 @@ const app = new Vue({
price: (item.price).toFixed(2),
tax_ids: item.tax_ids,
discount: item.discount_rate,
discount_type: item.discount_type,
total: (item.total).toFixed(2)
});
@ -657,6 +691,7 @@ const app = new Vue({
tax_ids: item_taxes,
add_discount: (item.discount_rate) ? true : false,
discount: item.discount_rate,
discount_type: item.discount_type,
total: (item.total).toFixed(2),
// @todo
// invoice_item_checkbox_sample: [],
@ -686,7 +721,7 @@ const app = new Vue({
this.page_loaded = true;
if (document_currencies) {
if (typeof document_currencies !== 'undefined' && document_currencies) {
this.currencies = document_currencies;
this.currencies.forEach(function (currency, index) {
@ -697,5 +732,9 @@ const app = new Vue({
}
}, this);
}
if (typeof document_taxes !== 'undefined' && document_taxes) {
this.dynamic_taxes = document_taxes;
}
}
});

View File

@ -1,34 +0,0 @@
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
require('./../../bootstrap');
import Vue from 'vue';
import DashboardPlugin from './../../plugins/dashboard-plugin';
import Global from './../../mixins/global';
import Form from './../../plugins/form';
import BulkAction from './../../plugins/bulk-action';
// plugin setup
Vue.use(DashboardPlugin);
const app = new Vue({
el: '#app',
mixins: [
Global
],
data: function () {
return {
form: new Form('payment'),
bulk_action: new BulkAction('payments'),
}
},
});

View File

@ -1,34 +0,0 @@
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
require('./../../bootstrap');
import Vue from 'vue';
import DashboardPlugin from './../../plugins/dashboard-plugin';
import Global from './../../mixins/global';
import Form from './../../plugins/form';
import BulkAction from './../../plugins/bulk-action';
// plugin setup
Vue.use(DashboardPlugin);
const app = new Vue({
el: '#app',
mixins: [
Global
],
data: function () {
return {
form: new Form('revenue'),
bulk_action: new BulkAction('revenues')
}
}
});