From ea7fc208ea021e23a0aa5ea520a24556d6f79e99 Mon Sep 17 00:00:00 2001 From: Burak Civan Date: Mon, 28 Jun 2021 21:45:55 +0300 Subject: [PATCH] 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 @@ - - - +