fix floating errors

This commit is contained in:
Mohit Panjwani
2020-12-31 12:16:04 +05:30
parent 0f1d7627ea
commit b55f8e5391
11 changed files with 498 additions and 466 deletions

View File

@ -43,7 +43,7 @@
:options="itemUnits" :options="itemUnits"
:searchable="true" :searchable="true"
:show-labels="false" :show-labels="false"
:maxHeight="200" :max-height="200"
label="name" label="name"
> >
</sw-select> </sw-select>
@ -160,7 +160,7 @@ export default {
return this.formData.price / 100 return this.formData.price / 100
}, },
set: function (newValue) { set: function (newValue) {
this.formData.price = newValue * 100 this.formData.price = Math.round(newValue * 100)
}, },
}, },

View File

@ -73,7 +73,7 @@ export default {
callbacks: { callbacks: {
label: function (tooltipItem, data) { label: function (tooltipItem, data) {
return self.FormatGraphMoney( return self.FormatGraphMoney(
tooltipItem.value * 100, Math.round(tooltipItem.value * 100),
self.defaultCurrency self.defaultCurrency
) )
}, },

View File

@ -7,23 +7,23 @@
<sw-page-header :title="pageTitle"> <sw-page-header :title="pageTitle">
<sw-breadcrumb slot="breadcrumbs"> <sw-breadcrumb slot="breadcrumbs">
<sw-breadcrumb-item <sw-breadcrumb-item
to="/admin/dashboard"
:title="$t('general.home')" :title="$t('general.home')"
to="/admin/dashboard"
/> />
<sw-breadcrumb-item <sw-breadcrumb-item
to="/admin/estimates"
:title="$tc('estimates.estimate', 2)" :title="$tc('estimates.estimate', 2)"
to="/admin/estimates"
/> />
<sw-breadcrumb-item <sw-breadcrumb-item
v-if="$route.name === 'estimates.edit'" v-if="$route.name === 'estimates.edit'"
to="#"
:title="$t('estimates.edit_estimate')" :title="$t('estimates.edit_estimate')"
to="#"
active active
/> />
<sw-breadcrumb-item <sw-breadcrumb-item
v-else v-else
to="#"
:title="$t('estimates.new_estimate')" :title="$t('estimates.new_estimate')"
to="#"
active active
/> />
</sw-breadcrumb> </sw-breadcrumb>
@ -31,8 +31,8 @@
<template slot="actions"> <template slot="actions">
<sw-button <sw-button
v-if="$route.name === 'estimates.edit'" v-if="$route.name === 'estimates.edit'"
tag-name="a"
:href="`/estimates/pdf/${newEstimate.unique_hash}`" :href="`/estimates/pdf/${newEstimate.unique_hash}`"
tag-name="a"
target="_blank" target="_blank"
class="mr-3" class="mr-3"
variant="primary-outline" variant="primary-outline"
@ -59,9 +59,9 @@
<!-- Select Customer & Basic Fields --> <!-- Select Customer & Basic Fields -->
<div class="grid-cols-12 gap-8 mt-6 mb-8 lg:grid"> <div class="grid-cols-12 gap-8 mt-6 mb-8 lg:grid">
<customer-select <customer-select
class="col-span-5 pr-0"
:valid="$v.selectedCustomer" :valid="$v.selectedCustomer"
:customer-id="customerId" :customer-id="customerId"
class="col-span-5 pr-0"
/> />
<div <div
@ -235,8 +235,8 @@
</div> </div>
<div <div
class="grid gap-x-4 gap-y-2 md:gap-x-8 md:gap-y-4 grid-col-1 md:grid-cols-2"
v-if="customFields.length > 0" v-if="customFields.length > 0"
class="grid gap-x-4 gap-y-2 md:gap-x-8 md:gap-y-4 grid-col-1 md:grid-cols-2"
> >
<sw-input-group <sw-input-group
v-for="(field, index) in customFields" v-for="(field, index) in customFields"
@ -247,7 +247,7 @@
<component <component
:type="field.type.label" :type="field.type.label"
:field="field" :field="field"
:isEdit="isEdit" :is-edit="isEdit"
:is="field.type + 'Field'" :is="field.type + 'Field'"
:invalid-fields="invalidFields" :invalid-fields="invalidFields"
@update="setCustomFieldValue" @update="setCustomFieldValue"
@ -366,8 +366,8 @@
</div> </div>
<sw-popup <sw-popup
ref="taxModal"
v-if="taxPerItem === 'NO' || taxPerItem === null" v-if="taxPerItem === 'NO' || taxPerItem === null"
ref="taxModal"
class="my-3 text-sm font-semibold leading-5 text-primary-400" class="my-3 text-sm font-semibold leading-5 text-primary-400"
> >
<div slot="activator" class="float-right pt-2 pb-4"> <div slot="activator" class="float-right pt-2 pb-4">
@ -425,8 +425,6 @@ const {
} = require('vuelidate/lib/validators') } = require('vuelidate/lib/validators')
export default { export default {
mixins: [CustomFieldsMixin],
components: { components: {
EstimateItem, EstimateItem,
CustomerSelect, CustomerSelect,
@ -438,6 +436,7 @@ export default {
PlusSmIcon, PlusSmIcon,
HashtagIcon, HashtagIcon,
}, },
mixins: [CustomFieldsMixin],
data() { data() {
return { return {
@ -563,7 +562,7 @@ export default {
if (this.newEstimate.discount_type === 'percentage') { if (this.newEstimate.discount_type === 'percentage') {
this.newEstimate.discount_val = (this.subtotal * newValue) / 100 this.newEstimate.discount_val = (this.subtotal * newValue) / 100
} else { } else {
this.newEstimate.discount_val = newValue * 100 this.newEstimate.discount_val = Math.round(newValue * 100)
} }
this.newEstimate.discount = newValue this.newEstimate.discount = newValue
@ -727,7 +726,9 @@ export default {
return return
} }
this.newEstimate.discount_val = this.newEstimate.discount * 100 this.newEstimate.discount_val = Math.round(
this.newEstimate.discount * 100
)
this.newEstimate.discount_type = 'fixed' this.newEstimate.discount_type = 'fixed'
}, },

View File

@ -256,7 +256,7 @@ export default {
if (this.item.discount_type === 'percentage') { if (this.item.discount_type === 'percentage') {
this.item.discount_val = (this.subtotal * newValue) / 100 this.item.discount_val = (this.subtotal * newValue) / 100
} else { } else {
this.item.discount_val = newValue * 100 this.item.discount_val = Math.round(newValue * 100)
} }
this.item.discount = newValue this.item.discount = newValue
@ -296,7 +296,7 @@ export default {
}, },
set: function (newValue) { set: function (newValue) {
if (parseFloat(newValue) > 0) { if (parseFloat(newValue) > 0) {
this.item.price = (newValue * 100).toFixed(2) this.item.price = Math.round(newValue * 100)
this.maxDiscount = this.item.price this.maxDiscount = this.item.price
} else { } else {
this.item.price = newValue this.item.price = newValue
@ -411,7 +411,7 @@ export default {
return return
} }
this.item.discount_val = this.item.discount * 100 this.item.discount_val = Math.round(this.item.discount * 100)
this.item.discount_type = 'fixed' this.item.discount_type = 'fixed'
}, },
selectPercentage() { selectPercentage() {

View File

@ -2,29 +2,29 @@
<base-page class="relative"> <base-page class="relative">
<form action="" @submit.prevent="sendData"> <form action="" @submit.prevent="sendData">
<!-- Page Header --> <!-- Page Header -->
<sw-page-header class="mb-5" :title="pageTitle"> <sw-page-header :title="pageTitle" class="mb-5">
<sw-breadcrumb slot="breadcrumbs"> <sw-breadcrumb slot="breadcrumbs">
<sw-breadcrumb-item <sw-breadcrumb-item
to="/admin/dashboard"
:title="$t('general.home')" :title="$t('general.home')"
to="/admin/dashboard"
/> />
<sw-breadcrumb-item <sw-breadcrumb-item
to="/admin/expenses"
:title="$tc('expenses.expense', 2)" :title="$tc('expenses.expense', 2)"
to="/admin/expenses"
/> />
<sw-breadcrumb-item <sw-breadcrumb-item
v-if="$route.name === 'expenses.edit'" v-if="$route.name === 'expenses.edit'"
to="#"
:title="$t('expenses.edit_expense')" :title="$t('expenses.edit_expense')"
to="#"
active active
/> />
<sw-breadcrumb-item <sw-breadcrumb-item
v-else v-else
to="#"
:title="$t('expenses.new_expense')" :title="$t('expenses.new_expense')"
to="#"
active active
/> />
</sw-breadcrumb> </sw-breadcrumb>
@ -32,8 +32,8 @@
<template slot="actions"> <template slot="actions">
<sw-button <sw-button
v-if="isReceiptAvailable" v-if="isReceiptAvailable"
tag-name="a"
:href="getReceiptUrl" :href="getReceiptUrl"
tag-name="a"
variant="primary" variant="primary"
outline outline
size="lg" size="lg"
@ -122,8 +122,8 @@
<sw-money <sw-money
v-model="amount" v-model="amount"
:currency="defaultCurrencyForInput" :currency="defaultCurrencyForInput"
class="focus:border focus:border-solid focus:border-primary-500"
:invalid="$v.formData.amount.$error" :invalid="$v.formData.amount.$error"
class="focus:border focus:border-solid focus:border-primary-500"
@input="$v.formData.amount.$touch()" @input="$v.formData.amount.$touch()"
/> />
</sw-input-group> </sw-input-group>
@ -176,9 +176,9 @@
</div> </div>
<sw-avatar <sw-avatar
trigger="#receipt-box"
:preview-avatar="previewReceipt" :preview-avatar="previewReceipt"
:enable-cropper="false" :enable-cropper="false"
trigger="#receipt-box"
@changed="onChange" @changed="onChange"
> >
<template v-slot:icon> <template v-slot:icon>
@ -201,7 +201,7 @@
<component <component
:type="field.type.label" :type="field.type.label"
:field="field" :field="field"
:isEdit="isEdit" :is-edit="isEdit"
:is="field.type + 'Field'" :is="field.type + 'Field'"
:invalid-fields="invalidFields" :invalid-fields="invalidFields"
@update="setCustomFieldValue" @update="setCustomFieldValue"
@ -242,13 +242,12 @@ import { CloudUploadIcon, ShoppingCartIcon } from '@vue-hero-icons/solid'
import CustomFieldsMixin from '../../mixins/customFields' import CustomFieldsMixin from '../../mixins/customFields'
export default { export default {
mixins: [CustomFieldsMixin],
components: { components: {
CloudUploadIcon, CloudUploadIcon,
ShoppingCartIcon, ShoppingCartIcon,
DownloadIcon, DownloadIcon,
}, },
mixins: [CustomFieldsMixin],
props: { props: {
addname: { addname: {
@ -315,7 +314,7 @@ export default {
return this.formData.amount / 100 return this.formData.amount / 100
}, },
set: function (newValue) { set: function (newValue) {
this.formData.amount = newValue * 100 this.formData.amount = Math.round(newValue * 100)
}, },
}, },

View File

@ -7,23 +7,23 @@
<sw-page-header :title="pageTitle"> <sw-page-header :title="pageTitle">
<sw-breadcrumb slot="breadcrumbs"> <sw-breadcrumb slot="breadcrumbs">
<sw-breadcrumb-item <sw-breadcrumb-item
to="/admin/dashboard"
:title="$t('general.home')" :title="$t('general.home')"
to="/admin/dashboard"
/> />
<sw-breadcrumb-item <sw-breadcrumb-item
to="/admin/invoices"
:title="$tc('invoices.invoice', 2)" :title="$tc('invoices.invoice', 2)"
to="/admin/invoices"
/> />
<sw-breadcrumb-item <sw-breadcrumb-item
v-if="$route.name === 'invoice.edit'" v-if="$route.name === 'invoice.edit'"
to="#"
:title="$t('invoices.edit_invoice')" :title="$t('invoices.edit_invoice')"
to="#"
active active
/> />
<sw-breadcrumb-item <sw-breadcrumb-item
v-else v-else
to="#"
:title="$t('invoices.new_invoice')" :title="$t('invoices.new_invoice')"
to="#"
active active
/> />
</sw-breadcrumb> </sw-breadcrumb>
@ -32,8 +32,8 @@
<sw-button <sw-button
v-if="$route.name === 'invoices.edit'" v-if="$route.name === 'invoices.edit'"
:disabled="isLoading" :disabled="isLoading"
tag-name="a"
:href="`/invoices/pdf/${newInvoice.unique_hash}`" :href="`/invoices/pdf/${newInvoice.unique_hash}`"
tag-name="a"
variant="primary-outline" variant="primary-outline"
class="mr-3" class="mr-3"
target="_blank" target="_blank"
@ -58,9 +58,9 @@
<!-- Select Customer & Basic Fields --> <!-- Select Customer & Basic Fields -->
<div class="grid-cols-12 gap-8 mt-6 mb-8 lg:grid"> <div class="grid-cols-12 gap-8 mt-6 mb-8 lg:grid">
<customer-select <customer-select
class="col-span-5 pr-0"
:valid="$v.selectedCustomer" :valid="$v.selectedCustomer"
:customer-id="customerId" :customer-id="customerId"
class="col-span-5 pr-0"
/> />
<div <div
@ -227,8 +227,8 @@
</div> </div>
<div <div
class="grid gap-x-4 gap-y-2 md:gap-x-8 md:gap-y-4 grid-col-1 md:grid-cols-2"
v-if="customFields.length > 0" v-if="customFields.length > 0"
class="grid gap-x-4 gap-y-2 md:gap-x-8 md:gap-y-4 grid-col-1 md:grid-cols-2"
> >
<sw-input-group <sw-input-group
v-for="(field, index) in customFields" v-for="(field, index) in customFields"
@ -239,7 +239,7 @@
<component <component
:type="field.type.label" :type="field.type.label"
:field="field" :field="field"
:isEdit="isEdit" :is-edit="isEdit"
:is="field.type + 'Field'" :is="field.type + 'Field'"
:invalid-fields="invalidFields" :invalid-fields="invalidFields"
@update="setCustomFieldValue" @update="setCustomFieldValue"
@ -418,8 +418,6 @@ const {
} = require('vuelidate/lib/validators') } = require('vuelidate/lib/validators')
export default { export default {
mixins: [CustomFieldsMixin],
components: { components: {
InvoiceItem, InvoiceItem,
CustomerSelect, CustomerSelect,
@ -431,6 +429,7 @@ export default {
ShoppingCartIcon, ShoppingCartIcon,
HashtagIcon, HashtagIcon,
}, },
mixins: [CustomFieldsMixin],
data() { data() {
return { return {
@ -558,7 +557,7 @@ export default {
if (this.newInvoice.discount_type === 'percentage') { if (this.newInvoice.discount_type === 'percentage') {
this.newInvoice.discount_val = (this.subtotal * newValue) / 100 this.newInvoice.discount_val = (this.subtotal * newValue) / 100
} else { } else {
this.newInvoice.discount_val = newValue * 100 this.newInvoice.discount_val = Math.round(newValue * 100)
} }
this.newInvoice.discount = newValue this.newInvoice.discount = newValue
@ -722,7 +721,7 @@ export default {
return return
} }
this.newInvoice.discount_val = this.newInvoice.discount * 100 this.newInvoice.discount_val = Math.round(this.newInvoice.discount * 100)
this.newInvoice.discount_type = 'fixed' this.newInvoice.discount_type = 'fixed'
}, },

View File

@ -256,7 +256,7 @@ export default {
if (this.item.discount_type === 'percentage') { if (this.item.discount_type === 'percentage') {
this.item.discount_val = (this.subtotal * newValue) / 100 this.item.discount_val = (this.subtotal * newValue) / 100
} else { } else {
this.item.discount_val = newValue * 100 this.item.discount_val = Math.round(newValue * 100)
} }
this.item.discount = newValue this.item.discount = newValue
@ -296,7 +296,7 @@ export default {
}, },
set: function (newValue) { set: function (newValue) {
if (parseFloat(newValue) > 0) { if (parseFloat(newValue) > 0) {
this.item.price = (newValue * 100).toFixed(2) this.item.price = Math.round(newValue * 100)
this.maxDiscount = this.item.price this.maxDiscount = this.item.price
} else { } else {
this.item.price = newValue this.item.price = newValue
@ -412,7 +412,7 @@ export default {
return return
} }
this.item.discount_val = this.item.discount * 100 this.item.discount_val = Math.round(this.item.discount * 100)
this.item.discount_type = 'fixed' this.item.discount_type = 'fixed'
}, },
selectPercentage() { selectPercentage() {

View File

@ -1,20 +1,20 @@
<template> <template>
<base-page> <base-page>
<!-- Page Header --> <!-- Page Header -->
<sw-page-header class="mb-3" :title="pageTitle"> <sw-page-header :title="pageTitle" class="mb-3">
<sw-breadcrumb slot="breadcrumbs"> <sw-breadcrumb slot="breadcrumbs">
<sw-breadcrumb-item to="/admin/dashboard" :title="$t('general.home')" /> <sw-breadcrumb-item :title="$t('general.home')" to="/admin/dashboard" />
<sw-breadcrumb-item to="/admin/items" :title="$tc('items.item', 2)" /> <sw-breadcrumb-item :title="$tc('items.item', 2)" to="/admin/items" />
<sw-breadcrumb-item <sw-breadcrumb-item
v-if="$route.name === 'items.edit'" v-if="$route.name === 'items.edit'"
to="#"
:title="$t('items.edit_item')" :title="$t('items.edit_item')"
to="#"
active active
/> />
<sw-breadcrumb-item <sw-breadcrumb-item
v-else v-else
to="#"
:title="$t('items.new_item')" :title="$t('items.new_item')"
to="#"
active active
/> />
</sw-breadcrumb> </sw-breadcrumb>
@ -59,11 +59,11 @@
<sw-input-group :label="$t('items.unit')" class="mb-4"> <sw-input-group :label="$t('items.unit')" class="mb-4">
<sw-select <sw-select
v-model="formData.unit" v-model="formData.unit"
class="mt-2"
:options="itemUnits" :options="itemUnits"
:searchable="true" :searchable="true"
:show-labels="false" :show-labels="false"
:placeholder="$t('items.select_a_unit')" :placeholder="$t('items.select_a_unit')"
class="mt-2"
label="name" label="name"
> >
<div <div
@ -89,12 +89,12 @@
> >
<sw-select <sw-select
v-model="formData.taxes" v-model="formData.taxes"
class="mt-2"
:options="getTaxTypes" :options="getTaxTypes"
:searchable="true" :searchable="true"
:show-labels="false" :show-labels="false"
:allow-empty="true" :allow-empty="true"
:multiple="true" :multiple="true"
class="mt-2"
track-by="tax_type_id" track-by="tax_type_id"
label="tax_name" label="tax_name"
/> />
@ -187,7 +187,7 @@ export default {
return this.formData.price / 100 return this.formData.price / 100
}, },
set: function (newValue) { set: function (newValue) {
this.formData.price = newValue * 100 this.formData.price = Math.round(newValue * 100)
}, },
}, },

View File

@ -2,8 +2,8 @@
<base-page> <base-page>
<sw-page-header :title="$t('items.title')"> <sw-page-header :title="$t('items.title')">
<sw-breadcrumb slot="breadcrumbs"> <sw-breadcrumb slot="breadcrumbs">
<sw-breadcrumb-item to="dashboard" :title="$t('general.home')" /> <sw-breadcrumb-item :title="$t('general.home')" to="dashboard" />
<sw-breadcrumb-item to="#" :title="$tc('items.item', 2)" active /> <sw-breadcrumb-item :title="$tc('items.item', 2)" to="#" active />
</sw-breadcrumb> </sw-breadcrumb>
<template slot="actions"> <template slot="actions">
@ -50,9 +50,9 @@
v-model="filters.unit" v-model="filters.unit"
:options="itemUnits" :options="itemUnits"
:searchable="true" :searchable="true"
class="mt-2"
:show-labels="false" :show-labels="false"
:placeholder="$t('items.select_a_unit')" :placeholder="$t('items.select_a_unit')"
class="mt-2"
label="name" label="name"
autocomplete="off" autocomplete="off"
/> />
@ -225,8 +225,8 @@
<dot-icon slot="activator" /> <dot-icon slot="activator" />
<sw-dropdown-item <sw-dropdown-item
tag-name="router-link"
:to="`items/${row.id}/edit`" :to="`items/${row.id}/edit`"
tag-name="router-link"
> >
<pencil-icon class="h-5 mr-3 text-gray-600" /> <pencil-icon class="h-5 mr-3 text-gray-600" />
{{ $t('general.edit') }} {{ $t('general.edit') }}
@ -356,7 +356,7 @@ export default {
let data = { let data = {
search: this.filters.name !== null ? this.filters.name : '', search: this.filters.name !== null ? this.filters.name : '',
unit_id: this.filters.unit !== null ? this.filters.unit.id : '', unit_id: this.filters.unit !== null ? this.filters.unit.id : '',
price: this.filters.price * 100, price: Math.round(this.filters.price * 100),
orderByField: sort.fieldName || 'created_at', orderByField: sort.fieldName || 'created_at',
orderBy: sort.order || 'desc', orderBy: sort.order || 'desc',
page, page,

View File

@ -1,26 +1,26 @@
<template> <template>
<base-page class="relative payment-create"> <base-page class="relative payment-create">
<form action="" @submit.prevent="submitPaymentData"> <form action="" @submit.prevent="submitPaymentData">
<sw-page-header class="mb-5" :title="pageTitle"> <sw-page-header :title="pageTitle" class="mb-5">
<sw-breadcrumb slot="breadcrumbs"> <sw-breadcrumb slot="breadcrumbs">
<sw-breadcrumb-item <sw-breadcrumb-item
to="/admin/dashboard"
:title="$t('general.home')" :title="$t('general.home')"
to="/admin/dashboard"
/> />
<sw-breadcrumb-item <sw-breadcrumb-item
to="/admin/payments"
:title="$tc('payments.payment', 2)" :title="$tc('payments.payment', 2)"
to="/admin/payments"
/> />
<sw-breadcrumb-item <sw-breadcrumb-item
v-if="$route.name === 'payments.edit'" v-if="$route.name === 'payments.edit'"
to="#"
:title="$t('payments.edit_payment')" :title="$t('payments.edit_payment')"
to="#"
active active
/> />
<sw-breadcrumb-item <sw-breadcrumb-item
v-else v-else
to="#"
:title="$t('payments.new_payment')" :title="$t('payments.new_payment')"
to="#"
active active
/> />
</sw-breadcrumb> </sw-breadcrumb>
@ -134,8 +134,8 @@
:searchable="true" :searchable="true"
:show-labels="false" :show-labels="false"
:placeholder="$t('payments.select_payment_mode')" :placeholder="$t('payments.select_payment_mode')"
:max-height="150"
label="name" label="name"
:maxHeight="150"
class="mt-1" class="mt-1"
> >
<div slot="afterList"> <div slot="afterList">
@ -165,7 +165,7 @@
<component <component
:type="field.type.label" :type="field.type.label"
:field="field" :field="field"
:isEdit="isEdit" :is-edit="isEdit"
:is="field.type + 'Field'" :is="field.type + 'Field'"
:invalid-fields="invalidFields" :invalid-fields="invalidFields"
@update="setCustomFieldValue" @update="setCustomFieldValue"
@ -218,9 +218,8 @@ import CustomFieldsMixin from '../../mixins/customFields'
const { required, between, numeric } = require('vuelidate/lib/validators') const { required, between, numeric } = require('vuelidate/lib/validators')
export default { export default {
mixins: [CustomFieldsMixin],
components: { ShoppingCartIcon }, components: { ShoppingCartIcon },
mixins: [CustomFieldsMixin],
data() { data() {
return { return {
@ -288,7 +287,7 @@ export default {
return this.formData.amount / 100 return this.formData.amount / 100
}, },
set: function (newValue) { set: function (newValue) {
this.formData.amount = (newValue * 100).toFixed(2) this.formData.amount = Math.round(newValue * 100)
}, },
}, },
pageTitle() { pageTitle() {
@ -552,9 +551,11 @@ export default {
}, },
id: this.$route.params.id, id: this.$route.params.id,
} }
try { try {
this.isLoading = true this.isLoading = true
let response = await this.updatePayment(data) let response = await this.updatePayment(data)
if (response.data.success) { if (response.data.success) {
this.isLoading = false this.isLoading = false
this.$router.push( this.$router.push(
@ -563,17 +564,21 @@ export default {
window.toastr['success'](this.$t('payments.updated_message')) window.toastr['success'](this.$t('payments.updated_message'))
return true return true
} }
if (response.data.error === 'invalid_amount') { if (response.data.error === 'invalid_amount') {
window.toastr['error'](this.$t('invalid_amount_message')) window.toastr['error'](this.$t('invalid_amount_message'))
return false return false
} }
window.toastr['error'](response.data.error) window.toastr['error'](response.data.error)
} catch (err) { } catch (err) {
this.isLoading = false this.isLoading = false
if (err.response.data.errors.payment_number) { if (err.response.data.errors.payment_number) {
window.toastr['error'](err.response.data.errors.payment_number) window.toastr['error'](err.response.data.errors.payment_number)
return true return true
} }
window.toastr['error'](err.response.data.message) window.toastr['error'](err.response.data.message)
} }
} else { } else {
@ -584,9 +589,12 @@ export default {
: null, : null,
payment_date: moment(this.formData.payment_date).format('YYYY-MM-DD'), payment_date: moment(this.formData.payment_date).format('YYYY-MM-DD'),
} }
this.isLoading = true this.isLoading = true
try { try {
let response = await this.addPayment(data) let response = await this.addPayment(data)
if (response.data.success) { if (response.data.success) {
this.$router.push( this.$router.push(
`/admin/payments/${response.data.payment.id}/view` `/admin/payments/${response.data.payment.id}/view`
@ -595,17 +603,21 @@ export default {
this.isLoading = true this.isLoading = true
return true return true
} }
if (response.data.error === 'invalid_amount') { if (response.data.error === 'invalid_amount') {
window.toastr['error'](this.$t('invalid_amount_message')) window.toastr['error'](this.$t('invalid_amount_message'))
return false return false
} }
window.toastr['error'](response.data.error) window.toastr['error'](response.data.error)
} catch (err) { } catch (err) {
this.isLoading = false this.isLoading = false
if (err.response.data.errors.payment_number) { if (err.response.data.errors.payment_number) {
window.toastr['error'](err.response.data.errors.payment_number) window.toastr['error'](err.response.data.errors.payment_number)
return true return true
} }
window.toastr['error'](err.response.data.message) window.toastr['error'](err.response.data.message)
} }
} }

815
yarn.lock

File diff suppressed because it is too large Load Diff