Skip to content

Commit

Permalink
close #3120 Fixed: Invoice items price gets multiplied when currency …
Browse files Browse the repository at this point in the history
…accuracy is changed
  • Loading branch information
cuneytsenturk committed Feb 12, 2024
1 parent 0599090 commit a217e44
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 6 deletions.
6 changes: 6 additions & 0 deletions resources/assets/js/mixins/global.js
Expand Up @@ -1600,5 +1600,11 @@ export default {
setMinDate(date) {
this.min_date = date;
},
},

created() {
if (aka_currency) {
this.currency = aka_currency;
}
}
}
2 changes: 1 addition & 1 deletion resources/assets/js/views/banking/transactions.js
Expand Up @@ -159,7 +159,7 @@ const app = new Vue({
}

this.tax_summary = true;
this.tax_summary_total = tax_total.toFixed(2);
this.tax_summary_total = tax_total.toFixed(this.currency.precision ?? 2);
},
},
});
10 changes: 5 additions & 5 deletions resources/assets/js/views/common/documents.js
Expand Up @@ -901,11 +901,11 @@ const app = new Vue({
name: item.name,
description: item.description === null ? "" : item.description,
quantity: item.quantity,
price: (item.price).toFixed(2),
price: (item.price).toFixed(this.currency.precision ?? 2),
tax_ids: item.tax_ids,
discount: item.discount_rate,
discount_type: item.discount_type,
total: (item.total).toFixed(2)
total: (item.total).toFixed(this.currency.precision ?? 2)
});

if (item.tax_ids) {
Expand All @@ -928,7 +928,7 @@ const app = new Vue({
item_taxes.push({
id: item_tax.tax_id,
name: item_tax.name,
price: (item_tax.amount).toFixed(2),
price: (item_tax.amount).toFixed(this.currency.precision ?? 2),
});
});

Expand All @@ -937,13 +937,13 @@ const app = new Vue({
name: item.name,
description: item.description === null ? "" : item.description,
quantity: item.quantity,
price: (item.price).toFixed(2),
price: (item.price).toFixed(this.currency.precision ?? 2),
add_tax: false,
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),
total: (item.total).toFixed(this.currency.precision ?? 2),
// @todo
// invoice_item_checkbox_sample: [],
});
Expand Down
10 changes: 10 additions & 0 deletions resources/views/banking/accounts/create.blade.php
Expand Up @@ -63,5 +63,15 @@
</x-form.container>
</x-slot>

@push('scripts_start')
<script type="text/javascript">
if (typeof aka_currency !== 'undefined') {
aka_currency = {!! json_encode(! empty($currency) ? $currency : company()->currency) !!};
} else {
var aka_currency = {!! json_encode(! empty($currency) ? $currency : company()->currency) !!};
}
</script>
@endpush

<x-script folder="banking" file="accounts" />
</x-layouts.admin>
10 changes: 10 additions & 0 deletions resources/views/banking/accounts/edit.blade.php
Expand Up @@ -61,5 +61,15 @@
</x-form.container>
</x-slot>

@push('scripts_start')
<script type="text/javascript">
if (typeof aka_currency !== 'undefined') {
aka_currency = {!! json_encode(! empty($account) ? $account->currency : company()->currency) !!};
} else {
var aka_currency = {!! json_encode(! empty($account) ? $account->currency : company()->currency) !!};
}
</script>
@endpush

<x-script folder="banking" file="accounts" />
</x-layouts.admin>
10 changes: 10 additions & 0 deletions resources/views/banking/recurring_transactions/create.blade.php
Expand Up @@ -106,5 +106,15 @@
</x-form.container>
</x-slot>

@push('scripts_start')
<script type="text/javascript">
if (typeof aka_currency !== 'undefined') {
aka_currency = {!! json_encode(! empty($currency) ? $currency : company()->currency) !!};
} else {
var aka_currency = {!! json_encode(! empty($currency) ? $currency : company()->currency) !!};
}
</script>
@endpush

<x-script folder="banking" file="transactions" />
</x-layouts.admin>
10 changes: 10 additions & 0 deletions resources/views/banking/recurring_transactions/edit.blade.php
Expand Up @@ -111,5 +111,15 @@
</x-form.container>
</x-slot>

@push('scripts_start')
<script type="text/javascript">
if (typeof aka_currency !== 'undefined') {
aka_currency = {!! json_encode(! empty($recurring_transaction) ? $recurring_transaction->currency : company()->currency) !!};
} else {
var aka_currency = {!! json_encode(! empty($recurring_transaction) ? $recurring_transaction->currency : company()->currency) !!};
}
</script>
@endpush

<x-script folder="banking" file="transactions" />
</x-layouts.admin>
7 changes: 7 additions & 0 deletions resources/views/banking/transactions/create.blade.php
Expand Up @@ -76,7 +76,14 @@
@push('scripts_start')
<script type="text/javascript">
var transaction_taxes = {!! $taxes !!};
if (typeof aka_currency !== 'undefined') {
aka_currency = {!! json_encode(! empty($currency) ? $currency : company()->currency) !!};
} else {
var aka_currency = {!! json_encode(! empty($currency) ? $currency : company()->currency) !!};
}
</script>
@endpush

<x-script folder="banking" file="transactions" />
</x-layouts.admin>
6 changes: 6 additions & 0 deletions resources/views/banking/transactions/edit.blade.php
Expand Up @@ -100,6 +100,12 @@
@push('scripts_start')
<script type="text/javascript">
var transaction_taxes = {!! $taxes !!};
if (typeof aka_currency !== 'undefined') {
aka_currency = {!! json_encode(! empty($transaction) ? $transaction->currency : company()->currency) !!};
} else {
var aka_currency = {!! json_encode(! empty($transaction) ? $transaction->currency : company()->currency) !!};
}
</script>
@endpush
<x-script folder="banking" file="transactions" />
Expand Down
10 changes: 10 additions & 0 deletions resources/views/banking/transfers/create.blade.php
Expand Up @@ -68,5 +68,15 @@
</x-form.container>
</x-slot>

@push('scripts_start')
<script type="text/javascript">
if (typeof aka_currency !== 'undefined') {
aka_currency = {!! json_encode(! empty($currency) ? $currency : company()->currency) !!};
} else {
var aka_currency = {!! json_encode(! empty($currency) ? $currency : company()->currency) !!};
}
</script>
@endpush

<x-script folder="banking" file="transfers" />
</x-layouts.admin>
6 changes: 6 additions & 0 deletions resources/views/banking/transfers/edit.blade.php
Expand Up @@ -81,6 +81,12 @@
@push('scripts_start')
<script type="text/javascript">
var transfer_edit = {{ $transfer->id }};
if (typeof aka_currency !== 'undefined') {
aka_currency = {!! json_encode(! empty($currency) ? $currency : company()->currency) !!};
} else {
var aka_currency = {!! json_encode(! empty($currency) ? $currency : company()->currency) !!};
}
</script>
@endpush

Expand Down
6 changes: 6 additions & 0 deletions resources/views/components/documents/script.blade.php
Expand Up @@ -16,6 +16,12 @@
var document_currencies = {!! $currencies !!};
var document_taxes = {!! $taxes !!};
var document_app_env = '{{ $document_app_env }}';
if (typeof aka_currency !== 'undefined') {
aka_currency = {!! json_encode(! empty($document) ? $document->currency : company()->currency) !!};
} else {
var aka_currency = {!! json_encode(! empty($document) ? $document->currency : company()->currency) !!};
}
</script>
@endpush

Expand Down

0 comments on commit a217e44

Please sign in to comment.