mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-19 11:45:01 +00:00
- decimal price fixes
This commit is contained in:
@@ -168,7 +168,7 @@
|
||||
<div class="block-wrapper">
|
||||
<label>{{ $t('in_editor.amount') }}:</label>
|
||||
<ValidationProvider tag="div" mode="passive" class="input-wrapper" name="amount" rules="required" v-slot="{ errors }">
|
||||
<input v-model.number="item.amount" :placeholder="$t('in_editor.plac.item_amount')" type="number" :class="{'is-error': errors[0]}" class="focus-border-theme" />
|
||||
<input v-model="item.amount" :placeholder="$t('in_editor.plac.item_amount')" type="text" :class="{'is-error': errors[0]}" class="focus-border-theme" />
|
||||
<span class="error-message" v-if="errors[0]">{{ errors[0] }}</span>
|
||||
</ValidationProvider>
|
||||
</div>
|
||||
@@ -176,7 +176,7 @@
|
||||
<div class="block-wrapper">
|
||||
<label>{{ $t('in_editor.unit') }}:</label>
|
||||
<ValidationProvider tag="div" mode="passive" class="input-wrapper" name="unit" rules="required" v-slot="{ errors }">
|
||||
<input v-model.number="item.unit" :placeholder="$t('in_editor.plac.item_unit')" type="text" :class="{'is-error': errors[0]}" class="focus-border-theme" />
|
||||
<input v-model="item.unit" :placeholder="$t('in_editor.plac.item_unit')" type="text" :class="{'is-error': errors[0]}" class="focus-border-theme" />
|
||||
<span class="error-message" v-if="errors[0]">{{ errors[0] }}</span>
|
||||
</ValidationProvider>
|
||||
</div>
|
||||
@@ -184,7 +184,7 @@
|
||||
<div v-if="isVatPayer" class="block-wrapper">
|
||||
<label>{{ $t('in_editor.tax_rate') }}:</label>
|
||||
<ValidationProvider tag="div" mode="passive" class="input-wrapper" name="tax_rate" rules="required" v-slot="{ errors }">
|
||||
<input v-model.number="item.tax_rate" :placeholder="$t('in_editor.plac.item_tax_rate')" type="number" step="1" min="1" max="100" :class="{'is-error': errors[0]}" class="focus-border-theme" />
|
||||
<input v-model="item.tax_rate" :placeholder="$t('in_editor.plac.item_tax_rate')" type="text" :class="{'is-error': errors[0]}" class="focus-border-theme" />
|
||||
<span class="error-message" v-if="errors[0]">{{ errors[0] }}</span>
|
||||
</ValidationProvider>
|
||||
</div>
|
||||
@@ -192,7 +192,7 @@
|
||||
<div class="block-wrapper">
|
||||
<label>{{ $t('in_editor.price') }}:</label>
|
||||
<ValidationProvider tag="div" mode="passive" class="input-wrapper" name="price" rules="required" v-slot="{ errors }">
|
||||
<input v-model.number="item.price" :placeholder="$t('in_editor.plac.item_price')" type="text" pattern="[0-9]{1,4}(\.[0-9]{2})?" step="0.01" :class="{'is-error': errors[0]}" class="focus-border-theme" />
|
||||
<input v-model="item.price" :placeholder="$t('in_editor.plac.item_price')" type="text" :class="{'is-error': errors[0]}" class="focus-border-theme" />
|
||||
<span class="error-message" v-if="errors[0]">{{ errors[0] }}</span>
|
||||
</ValidationProvider>
|
||||
</div>
|
||||
@@ -397,14 +397,14 @@
|
||||
|
||||
bag.push({
|
||||
rate: item.tax_rate,
|
||||
total: (item.price * item.amount),
|
||||
total: (this.$parseFloat(item.price) * this.$parseFloat(item.amount)),
|
||||
})
|
||||
} else {
|
||||
bag.find(bagItem => {
|
||||
|
||||
// Count total tax rate for percentage
|
||||
if (bagItem.rate === item.tax_rate) {
|
||||
bagItem.total += (item.price * item.amount)
|
||||
bagItem.total += (this.$parseFloat(item.price) * this.$parseFloat(item.amount))
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -440,7 +440,7 @@
|
||||
|
||||
bag.push({
|
||||
rate: item.tax_rate,
|
||||
total: (item.price * item.amount) * (item.tax_rate / 100),
|
||||
total: (this.$parseFloat(item.price) * this.$parseFloat(item.amount)) * (item.tax_rate / 100),
|
||||
})
|
||||
|
||||
} else {
|
||||
@@ -449,7 +449,7 @@
|
||||
|
||||
// Count total tax rate for percentage
|
||||
if (bagItem.rate === item.tax_rate) {
|
||||
bagItem.total += (item.price * item.amount) * (item.tax_rate / 100)
|
||||
bagItem.total += (this.$parseFloat(item.price) * this.$parseFloat(item.amount)) * (item.tax_rate / 100)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -480,7 +480,7 @@
|
||||
this.invoice.items.forEach(item => {
|
||||
if (item.price && item.amount) {
|
||||
|
||||
let total_without_tax = (item.price * item.amount)
|
||||
let total_without_tax = (this.$parseFloat(item.price) * this.$parseFloat(item.amount))
|
||||
|
||||
// Count tax
|
||||
if (this.isVatPayer && item.tax_rate) {
|
||||
@@ -545,8 +545,8 @@
|
||||
price: undefined,
|
||||
}
|
||||
],
|
||||
discount_type: 'percent',
|
||||
discount_rate: 10,
|
||||
discount_type: undefined,
|
||||
discount_rate: undefined,
|
||||
client: '',
|
||||
client_avatar: '',
|
||||
client_name: '',
|
||||
@@ -693,7 +693,7 @@
|
||||
|
||||
let year = new Intl.DateTimeFormat('en', {year: 'numeric'}).format(delivery_time),
|
||||
month = new Intl.DateTimeFormat('en', {month: '2-digit'}).format(delivery_time),
|
||||
day = new Intl.DateTimeFormat('en', {day: 'numeric'}).format(delivery_time)
|
||||
day = new Intl.DateTimeFormat('en', {day: '2-digit'}).format(delivery_time)
|
||||
|
||||
this.invoice.delivery_at = `${year}-${month}-${day}`
|
||||
}
|
||||
@@ -701,6 +701,8 @@
|
||||
mounted() {
|
||||
this.invoice.invoice_type = this.$route.query.type
|
||||
|
||||
this.get_recommended_delivery_date()
|
||||
|
||||
if (this.user && ! this.user.data.attributes.has_billing_profile) {
|
||||
this.$router.push({name: 'BillingProfileSetUp'})
|
||||
}
|
||||
@@ -718,7 +720,6 @@
|
||||
this.invoice.invoice_number = response.data.recommendedInvoiceNumber
|
||||
this.latestInvoiceNumber = response.data.latestInvoiceNumber
|
||||
|
||||
this.get_recommended_delivery_date()
|
||||
})
|
||||
.finally(() => {
|
||||
this.isLoadingPage = false
|
||||
|
||||
@@ -75,7 +75,15 @@
|
||||
<div class="block-wrapper">
|
||||
<label>{{ $t('in_editor.amount') }}:</label>
|
||||
<ValidationProvider tag="div" mode="passive" class="input-wrapper" name="amount" rules="required" v-slot="{ errors }">
|
||||
<input v-model.number="item.amount" :placeholder="$t('in_editor.plac.item_amount')" type="number" :class="{'is-error': errors[0]}" class="focus-border-theme" />
|
||||
<input v-model="item.amount" :placeholder="$t('in_editor.plac.item_amount')" type="text" :class="{'is-error': errors[0]}" class="focus-border-theme" />
|
||||
<span class="error-message" v-if="errors[0]">{{ errors[0] }}</span>
|
||||
</ValidationProvider>
|
||||
</div>
|
||||
|
||||
<div class="block-wrapper">
|
||||
<label>{{ $t('in_editor.unit') }}:</label>
|
||||
<ValidationProvider tag="div" mode="passive" class="input-wrapper" name="unit" rules="required" v-slot="{ errors }">
|
||||
<input v-model="item.unit" :placeholder="$t('in_editor.plac.item_unit')" type="text" :class="{'is-error': errors[0]}" class="focus-border-theme" />
|
||||
<span class="error-message" v-if="errors[0]">{{ errors[0] }}</span>
|
||||
</ValidationProvider>
|
||||
</div>
|
||||
@@ -83,7 +91,7 @@
|
||||
<div v-if="isVatPayer" class="block-wrapper">
|
||||
<label>{{ $t('in_editor.tax_rate') }}:</label>
|
||||
<ValidationProvider tag="div" mode="passive" class="input-wrapper" name="tax_rate" rules="required" v-slot="{ errors }">
|
||||
<input v-model.number="item.tax_rate" :placeholder="$t('in_editor.plac.item_tax_rate')" type="number" step="1" min="1" max="100" :class="{'is-error': errors[0]}" class="focus-border-theme" />
|
||||
<input v-model="item.tax_rate" :placeholder="$t('in_editor.plac.item_tax_rate')" type="text" :class="{'is-error': errors[0]}" class="focus-border-theme" />
|
||||
<span class="error-message" v-if="errors[0]">{{ errors[0] }}</span>
|
||||
</ValidationProvider>
|
||||
</div>
|
||||
@@ -91,7 +99,7 @@
|
||||
<div class="block-wrapper">
|
||||
<label>{{ $t('in_editor.price') }}:</label>
|
||||
<ValidationProvider tag="div" mode="passive" class="input-wrapper" name="price" rules="required" v-slot="{ errors }">
|
||||
<input v-model.number="item.price" :placeholder="$t('in_editor.plac.item_price')" type="text" pattern="[0-9]{1,4}(\.[0-9]{2})?" step="0.01" :class="{'is-error': errors[0]}" class="focus-border-theme" />
|
||||
<input v-model="item.price" :placeholder="$t('in_editor.plac.item_price')" type="text" :class="{'is-error': errors[0]}" class="focus-border-theme" />
|
||||
<span class="error-message" v-if="errors[0]">{{ errors[0] }}</span>
|
||||
</ValidationProvider>
|
||||
</div>
|
||||
@@ -293,17 +301,16 @@
|
||||
if (item.price && item.amount && item.tax_rate) {
|
||||
|
||||
if (!bag.find(bagItem => bagItem.rate === item.tax_rate)) {
|
||||
|
||||
bag.push({
|
||||
rate: item.tax_rate,
|
||||
total: (item.price * item.amount),
|
||||
total: (this.$parseFloat(item.price) * this.$parseFloat(item.amount)),
|
||||
})
|
||||
} else {
|
||||
bag.find(bagItem => {
|
||||
|
||||
// Count total tax rate for percentage
|
||||
if (bagItem.rate === item.tax_rate) {
|
||||
bagItem.total += (item.price * item.amount)
|
||||
bagItem.total += (this.$parseFloat(item.price) * this.$parseFloat(item.amount))
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -339,7 +346,7 @@
|
||||
|
||||
bag.push({
|
||||
rate: item.tax_rate,
|
||||
total: (item.price * item.amount) * (item.tax_rate / 100),
|
||||
total: (this.$parseFloat(item.price) * this.$parseFloat(item.amount)) * (item.tax_rate / 100),
|
||||
})
|
||||
|
||||
} else {
|
||||
@@ -348,7 +355,7 @@
|
||||
|
||||
// Count total tax rate for percentage
|
||||
if (bagItem.rate === item.tax_rate) {
|
||||
bagItem.total += (item.price * item.amount) * (item.tax_rate / 100)
|
||||
bagItem.total += (this.$parseFloat(item.price) * this.$parseFloat(item.amount)) * (item.tax_rate / 100)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -379,7 +386,7 @@
|
||||
this.invoice.items.forEach(item => {
|
||||
if (item.price && item.amount) {
|
||||
|
||||
let total_without_tax = (item.price * item.amount)
|
||||
let total_without_tax = (this.$parseFloat(item.price) * this.$parseFloat(item.amount))
|
||||
|
||||
// Count tax
|
||||
if (this.isVatPayer && item.tax_rate) {
|
||||
@@ -490,14 +497,18 @@
|
||||
// Start loading
|
||||
this.isLoading = true
|
||||
|
||||
let payload = this.invoice
|
||||
|
||||
//payload.items = JSON.stringify(this.invoice.items)
|
||||
|
||||
// Send request to get user token
|
||||
axios
|
||||
.put(`/api/v1/invoicing/invoices/${this.$route.params.id}`, payload)
|
||||
.put(`/api/v1/invoicing/invoices/${this.$route.params.id}`, this.invoice)
|
||||
.then(() => {
|
||||
|
||||
this.$store.dispatch({
|
||||
'regular-invoice': 'getRegularInvoices',
|
||||
'advance-invoice': 'getAdvanceInvoices',
|
||||
}[this.invoice.invoice_type])
|
||||
|
||||
this.$router.push({name: 'InvoicesList'})
|
||||
|
||||
events.$emit('toaster', {
|
||||
type: 'success',
|
||||
message: this.$t('in_toaster.success_invoice_edition'),
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<ToolbarGroup>
|
||||
<PopoverWrapper>
|
||||
<ToolbarButton @click.stop.native="createMenu" source="plus" :action="$t('actions.create_folder')" />
|
||||
<PopoverItem name="desktop-create-invoices">
|
||||
<PopoverItem name="desktop-create-invoices" side="left">
|
||||
<OptionGroup>
|
||||
<Option @click.stop.native="createInvoice('regular-invoice')" :title="$t('in_editor.page.create_regular_invoice')" icon="file-plus" />
|
||||
<Option @click.stop.native="createInvoice('advance-invoice')" :title="$t('in_editor.page.create_advance_invoice')" icon="clock" />
|
||||
|
||||
Vendored
+6
@@ -7,6 +7,12 @@ import router from "./router";
|
||||
const OasisHelpers = {
|
||||
install(Vue) {
|
||||
|
||||
Vue.prototype.$parseFloat = function (val) {
|
||||
let number = val.toString().replace(',', '.')
|
||||
|
||||
return parseFloat(number)
|
||||
}
|
||||
|
||||
Vue.prototype.$goToInvoice = function () {
|
||||
router.push({name: 'InvoicesList'})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user