From 0786753d480595265bc4b89192269d261292eb9f Mon Sep 17 00:00:00 2001 From: Burak Civan Date: Mon, 28 Jun 2021 13:00:24 +0300 Subject: [PATCH 1/4] Currency conversion component edited --- .../AkauntingCurrencyConversion.vue | 63 ++++- resources/assets/js/views/common/documents.js | 26 +- .../documents/form/totals.blade.php | 238 +++++++----------- 3 files changed, 168 insertions(+), 159 deletions(-) diff --git a/resources/assets/js/components/AkauntingCurrencyConversion.vue b/resources/assets/js/components/AkauntingCurrencyConversion.vue index 49e40ccff..a97e2f9b1 100644 --- a/resources/assets/js/components/AkauntingCurrencyConversion.vue +++ b/resources/assets/js/components/AkauntingCurrencyConversion.vue @@ -1,14 +1,27 @@ From f1f5fadc1c64d5880a87c873f563554c54b876bc Mon Sep 17 00:00:00 2001 From: Burak Civan Date: Mon, 28 Jun 2021 18:23:40 +0300 Subject: [PATCH 2/4] Edit method edited --- .../AkauntingCurrencyConversion.vue | 45 ++++++++++--------- resources/assets/js/views/common/documents.js | 2 +- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/resources/assets/js/components/AkauntingCurrencyConversion.vue b/resources/assets/js/components/AkauntingCurrencyConversion.vue index a97e2f9b1..c31af8e6c 100644 --- a/resources/assets/js/components/AkauntingCurrencyConversion.vue +++ b/resources/assets/js/components/AkauntingCurrencyConversion.vue @@ -8,9 +8,9 @@ suffix: (!this.currencySymbol.symbol_first) ? this.currencySymbol.symbol : '', precision: parseInt(this.currencySymbol.precision), masked: true - }" :value="price" name="rate" disabled size="5" masked class="disabled-money text-right mr-2 js-conversion-input"> + }" :value="price" disabled size="5" masked class="disabled-money text-right mr-2 js-conversion-input"> {{ currecyCode }} - + @@ -41,31 +41,14 @@ export default { }, currencySymbol: { default: {} - }, - currency: { - type: Object, - default: function () { - return { - - }; - }, - description: "Default currency" - }, + } }, data() { return { conversion: '', rate: this.currencyRate, - texts: [], - money: { - decimal: this.currencySymbol.decimal_mark, - thousands: this.currencySymbol.thousands_separator, - prefix: (this.currencySymbol.symbol_first) ? this.currencySymbol.symbol : '', - suffix: (!this.currencySymbol.symbol_first) ? this.currencySymbol.symbol : '', - precision: parseInt(this.currencySymbol.precision), - masked: true - } + texts: [] }; }, @@ -78,7 +61,27 @@ export default { methods: { onChange() { + let self = this; this.$emit('change', this.rate); + + if(self.currencyRate.length !== 0) { + window.axios({ + method: 'PATCH', + url: url + "/settings/currencies", + data: { + name: self.currencySymbol.name, + code: self.currecyCode, + rate: self.currencyRate + } + }).then(response => { + this.$notify({ + message: 'SUCCESS', + timeout: 200, + icon: 'fas fa-bell', + type + }); + }) + } } }, diff --git a/resources/assets/js/views/common/documents.js b/resources/assets/js/views/common/documents.js index 03449c7af..9eb3b0503 100644 --- a/resources/assets/js/views/common/documents.js +++ b/resources/assets/js/views/common/documents.js @@ -553,7 +553,7 @@ this.form.currency_code = currency.code; this.form.currency_rate = currency.rate; this.currency_symbol = currency; - + this.currencyConversion(); } }, this); From ea7fc208ea021e23a0aa5ea520a24556d6f79e99 Mon Sep 17 00:00:00 2001 From: Burak Civan Date: Mon, 28 Jun 2021 21:45:55 +0300 Subject: [PATCH 3/4] Currency rate made development --- .../AkauntingCurrencyConversion.vue | 775 +++++++++++++++--- .../documents/form/totals.blade.php | 240 ++++-- 2 files changed, 822 insertions(+), 193 deletions(-) diff --git a/resources/assets/js/components/AkauntingCurrencyConversion.vue b/resources/assets/js/components/AkauntingCurrencyConversion.vue index c31af8e6c..9eb3b0503 100644 --- a/resources/assets/js/components/AkauntingCurrencyConversion.vue +++ b/resources/assets/js/components/AkauntingCurrencyConversion.vue @@ -1,109 +1,674 @@ - +/** + * 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. + */ - + }, 250) + } + }, + + created() { + this.form.items = []; + + if (typeof document_items !== 'undefined' && document_items) { + this.edit.status = true; + this.edit.currency = 1; + + document_items.forEach(function(item) { + // form set item + this.form.items.push({ + item_id: item.item_id, + name: item.name, + description: item.description === null ? "" : item.description, + quantity: item.quantity, + price: (item.price).toFixed(2), + tax_ids: item.tax_ids, + discount: item.discount_rate, + total: (item.total).toFixed(2) + }); + + if (item.tax_ids) { + item.tax_ids.forEach(function (tax_id, index) { + if (this.taxes.includes(tax_id)) { + this.taxes[tax_id].push(item.id); + } else { + this.taxes.push(tax_id); + + this.taxes[tax_id] = []; + + this.taxes[tax_id].push(item.id); + } + }, this); + } + + let item_taxes = []; + + item.taxes.forEach(function(item_tax) { + item_taxes.push({ + id: item_tax.tax_id, + name: item_tax.name, + price: (item_tax.amount).toFixed(2), + }); + }); + + this.items.push({ + item_id: item.item_id, + name: item.name, + description: item.description === null ? "" : item.description, + quantity: item.quantity, + price: (item.price).toFixed(2), + add_tax: (!item_taxes.length && document.getElementById('invoice-item-discount-rows') != null) ? false : true, + tax_ids: item_taxes, + add_discount: (item.discount_rate) ? true : false, + discount: item.discount_rate, + total: (item.total).toFixed(2), + // @todo + // invoice_item_checkbox_sample: [], + }); + }, this); + + this.items.forEach(function(item) { + item.tax_ids.forEach(function(tax) { + let total_tax_index = this.totals.taxes.findIndex(total_tax => { + if (total_tax.id === tax.id) { + return true; + } + }, this); + + if (total_tax_index === -1) { + this.totals.taxes.push({ + id: tax.id, + name: tax.name, + total: tax.price, + }); + } else { + this.totals.taxes[total_tax_index].total = parseFloat(this.totals.taxes[total_tax_index].total) + parseFloat(tax.price); + } + }, this); + }, this); + } + + this.page_loaded = true; + + if (document_currencies) { + this.currencies = document_currencies; + + this.currencies.forEach(function (currency, index) { + if (document_default_currency == currency.code) { + this.currency = currency; + + this.form.currency_code = currency.code; + } + }, this); + } + } + }); + \ No newline at end of file diff --git a/resources/views/components/documents/form/totals.blade.php b/resources/views/components/documents/form/totals.blade.php index 925931617..2508a11ad 100644 --- a/resources/views/components/documents/form/totals.blade.php +++ b/resources/views/components/documents/form/totals.blade.php @@ -1,89 +1,153 @@ - - - + From 96e448d3ba5f09f262df866a9a18f36e618e840d Mon Sep 17 00:00:00 2001 From: Burak Civan Date: Tue, 29 Jun 2021 09:33:07 +0300 Subject: [PATCH 4/4] Javascirpt function edited --- .../AkauntingCurrencyConversion.vue | 759 ++---------------- resources/assets/js/views/common/documents.js | 1 + 2 files changed, 89 insertions(+), 671 deletions(-) diff --git a/resources/assets/js/components/AkauntingCurrencyConversion.vue b/resources/assets/js/components/AkauntingCurrencyConversion.vue index 9eb3b0503..3ee000822 100644 --- a/resources/assets/js/components/AkauntingCurrencyConversion.vue +++ b/resources/assets/js/components/AkauntingCurrencyConversion.vue @@ -1,674 +1,91 @@ -/** - * 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'); + diff --git a/resources/assets/js/views/common/documents.js b/resources/assets/js/views/common/documents.js index 9eb3b0503..0cebfa3ff 100644 --- a/resources/assets/js/views/common/documents.js +++ b/resources/assets/js/views/common/documents.js @@ -246,6 +246,7 @@ } } }, this); + this.currencyConversion(); }, calculateTotalsTax(totals_taxes, id, name, price) {