diff --git a/app/Http/Requests/CustomerRequest.php b/app/Http/Requests/CustomerRequest.php index d93e5de1..be8e5c96 100644 --- a/app/Http/Requests/CustomerRequest.php +++ b/app/Http/Requests/CustomerRequest.php @@ -36,6 +36,7 @@ class CustomerRequest extends FormRequest 'name' => 'required', 'addresses.*.address_street_1' => 'max:255', 'addresses.*.address_street_2' => 'max:255', + 'email' => 'email|nullable|unique:users,email,'.$this->id ]; break; default: diff --git a/resources/assets/js/components/base/modal/CategoryModal.vue b/resources/assets/js/components/base/modal/CategoryModal.vue index 609e1d85..5226869e 100644 --- a/resources/assets/js/components/base/modal/CategoryModal.vue +++ b/resources/assets/js/components/base/modal/CategoryModal.vue @@ -148,7 +148,11 @@ export default { } if (response.data) { - window.toastr['success'](this.$t('settings.expense_category.created_message')) + if (!this.isEdit) { + window.toastr['success'](this.$t('settings.expense_category.created_message')) + } else { + window.toastr['success'](this.$t('settings.expense_category.updated_message')) + } window.hub.$emit('newCategory', response.data.category) this.closeCategoryModal() this.isLoading = false diff --git a/resources/assets/js/components/base/modal/CustomerModal.vue b/resources/assets/js/components/base/modal/CustomerModal.vue index 101564a1..33f7386c 100644 --- a/resources/assets/js/components/base/modal/CustomerModal.vue +++ b/resources/assets/js/components/base/modal/CustomerModal.vue @@ -67,15 +67,10 @@
-
- {{ $tc('validation.numbers_only') }} -
@@ -113,15 +108,10 @@
-
- {{ $tc('validation.numbers_only') }} -
@@ -249,15 +239,10 @@
-
- {{ $tc('validation.numbers_only') }} -
@@ -426,17 +411,11 @@ export default { email: { email }, - phone: { - numeric - }, website: { url } }, billing: { - phone: { - numeric - }, address_street_1: { maxLength: maxLength(255) }, @@ -445,9 +424,6 @@ export default { } }, shipping: { - phone: { - numeric - }, address_street_1: { maxLength: maxLength(255) }, @@ -629,21 +605,28 @@ export default { } else { this.formData.currency_id = this.defaultCurrency.id } - let response = await this.addCustomer(this.formData) - if (response.data) { - window.toastr['success'](this.$tc('customers.created_message')) - this.isLoading = false - if (this.$route.name === 'invoices.create') { - this.setInvoiceCustomer(response.data.customer.id) + try { + let response = await this.addCustomer(this.formData) + if (response.data) { + window.toastr['success'](this.$tc('customers.created_message')) + this.isLoading = false + if (this.$route.name === 'invoices.create') { + this.setInvoiceCustomer(response.data.customer.id) + } + if (this.$route.name === 'estimates.create') { + this.setEstimateCustomer(response.data.customer.id) + } + this.resetData() + this.closeModal() + return true } - if (this.$route.name === 'estimates.create') { - this.setEstimateCustomer(response.data.customer.id) + // window.toastr['error'](response.data.error) + } catch (err) { + if (err.response.data.errors.email) { + this.isLoading = false + window.toastr['error'](this.$t('validation.email_already_taken')) } - this.resetData() - this.closeModal() - return true } - window.toastr['error'](response.data.error) }, async fetchCountry () { let res = await window.axios.get('/api/countries') diff --git a/resources/assets/js/components/base/modal/TaxTypeModal.vue b/resources/assets/js/components/base/modal/TaxTypeModal.vue index 76b26240..587139f1 100644 --- a/resources/assets/js/components/base/modal/TaxTypeModal.vue +++ b/resources/assets/js/components/base/modal/TaxTypeModal.vue @@ -189,7 +189,11 @@ export default { response = await this.updateTaxType(this.formData) } if (response.data) { - window.toastr['success'](this.$t('settings.tax_types.created_message')) + if (!this.isEdit) { + window.toastr['success'](this.$t('settings.tax_types.created_message')) + } else { + window.toastr['success'](this.$t('settings.tax_types.updated_message')) + } window.hub.$emit('newTax', response.data.taxType) this.closeTaxModal() this.isLoading = false diff --git a/resources/assets/js/components/base/popup/CustomerSelectPopup.vue b/resources/assets/js/components/base/popup/CustomerSelectPopup.vue index d0f9994b..6d9ea0e4 100644 --- a/resources/assets/js/components/base/popup/CustomerSelectPopup.vue +++ b/resources/assets/js/components/base/popup/CustomerSelectPopup.vue @@ -34,7 +34,7 @@ - diff --git a/resources/assets/js/plugins/en.js b/resources/assets/js/plugins/en.js index d43b518b..73cf28af 100644 --- a/resources/assets/js/plugins/en.js +++ b/resources/assets/js/plugins/en.js @@ -642,9 +642,9 @@ export default { percent: 'Percent', action: 'Action', tax_setting_description: 'Enable this if you want to add taxes to individual invoice items. By default, taxes are added directly to the invoice.', - created_message: 'Sales tax created successfully', - updated_message: 'Sales tax updated successfully', - deleted_message: 'Sales tax deleted successfully', + created_message: 'Tax type created successfully', + updated_message: 'Tax type updated successfully', + deleted_message: 'Tax type deleted successfully', confirm_delete: 'You will not be able to recover this Tax Type', already_in_use: 'Tax is already in use' }, @@ -655,7 +655,7 @@ export default { add_new_category: 'Add New Category', category_name: 'Category Name', category_description: 'Description', - created_message: 'Category created successfully', + created_message: 'Expense Category created successfully', deleted_message: 'Expense category deleted successfully', updated_message: 'Expense category updated successfully', confirm_delete: 'You will not be able to recover this Expense Category', diff --git a/resources/assets/js/plugins/es.js b/resources/assets/js/plugins/es.js index 6c43c839..0535b5c9 100644 --- a/resources/assets/js/plugins/es.js +++ b/resources/assets/js/plugins/es.js @@ -638,9 +638,9 @@ export default { percent: 'Por ciento', action: 'Acción', tax_setting_description: 'Habilítelo si desea agregar impuestos a artículos de factura individuales. Por defecto, los impuestos se agregan directamente a la factura.', - created_message: 'Impuesto sobre las ventas creado con éxito', - updated_message: 'Impuesto sobre ventas actualizado con éxito', - deleted_message: 'Impuesto sobre las ventas eliminado con éxito', + created_message: 'Tipo de impuesto creado con éxito', + updated_message: 'Tipo de impuesto actualizado correctamente', + deleted_message: 'Tipo de impuesto eliminado correctamente', confirm_delete: 'No podrá recuperar este tipo de impuesto', already_in_use: 'El impuesto ya está en uso.' }, @@ -651,7 +651,7 @@ export default { add_new_category: 'Añadir nueva categoria', category_name: 'nombre de la categoría', category_description: 'Descripción', - created_message: 'Categoría creada con éxito', + created_message: 'Categoría de gastos creada con éxito', deleted_message: 'Categoría de gastos eliminada correctamente', updated_message: 'Categoría de gastos actualizada con éxito', confirm_delete: 'No podrá recuperar esta categoría de gastos', diff --git a/resources/assets/js/plugins/fr.js b/resources/assets/js/plugins/fr.js index 5b8e1882..1a8a11cf 100644 --- a/resources/assets/js/plugins/fr.js +++ b/resources/assets/js/plugins/fr.js @@ -640,9 +640,9 @@ export default { percent: 'Pour cent', action: 'action', tax_setting_description: 'Activez cette option si vous souhaitez ajouter des taxes à des postes de facture individuels. Par défaut, les taxes sont ajoutées directement à la facture.', - created_message: 'La taxe de vente créée avec succès', - updated_message: 'La taxe de vente a été mise à jour avec succès', - deleted_message: 'La taxe de vente a été supprimée avec succès', + created_message: 'Type de taxe créé avec succès', + updated_message: 'Type de taxe mis à jour avec succès', + deleted_message: 'Type de taxe supprimé avec succès', confirm_delete: 'Vous ne pourrez pas récupérer ce type de taxe', already_in_use: 'La taxe est déjà utilisée' }, @@ -653,7 +653,7 @@ export default { add_new_category: 'Ajouter une nouvelle catégorie', category_name: 'Nom de catégorie', category_description: 'La description', - created_message: 'Catégorie créée avec succès', + created_message: 'Catégorie de dépenses créée avec succès', deleted_message: 'La catégorie de dépenses a été supprimée avec succès', updated_message: 'Catégorie de dépenses mise à jour avec succès', confirm_delete: 'Vous ne pourrez pas récupérer cette catégorie de dépenses', diff --git a/resources/assets/js/views/customers/Create.vue b/resources/assets/js/views/customers/Create.vue index 8b831584..27125885 100644 --- a/resources/assets/js/views/customers/Create.vue +++ b/resources/assets/js/views/customers/Create.vue @@ -84,16 +84,11 @@
-
- {{ $tc('validation.numbers_only') }} -
@@ -196,16 +191,11 @@
-
- {{ $tc('validation.numbers_only') }} -
@@ -315,16 +305,11 @@
-
- {{ $tc('validation.numbers_only') }} -
@@ -432,17 +417,11 @@ export default { email: { email }, - phone: { - numeric - }, website: { url } }, billing: { - phone: { - numeric - }, address_street_1: { maxLength: maxLength(255) }, @@ -451,9 +430,6 @@ export default { } }, shipping: { - phone: { - numeric - }, address_street_1: { maxLength: maxLength(255) }, @@ -608,16 +584,20 @@ export default { this.formData.currency_id = this.currency.id } this.isLoading = true - let response = await this.updateCustomer(this.formData) - - if (response.data) { - window.toastr['success'](this.$t('customers.updated_message')) - this.$router.push('/admin/customers') - this.isLoading = false - return true + try { + let response = await this.updateCustomer(this.formData) + if (response.data) { + window.toastr['success'](this.$t('customers.updated_message')) + this.$router.push('/admin/customers') + this.isLoading = false + return true + } + } catch (err) { + if (err.response.data.errors.email) { + this.isLoading = false + window.toastr['error'](this.$t('validation.email_already_taken')) + } } - - window.toastr['error'](response.data.error) } else { this.isLoading = true if (this.currency) { diff --git a/resources/assets/js/views/payments/Create.vue b/resources/assets/js/views/payments/Create.vue index 1a0bea01..d31c5ab0 100644 --- a/resources/assets/js/views/payments/Create.vue +++ b/resources/assets/js/views/payments/Create.vue @@ -246,14 +246,19 @@ export default { watch: { customer (newValue) { this.formData.user_id = newValue.id + this.invoice = null + this.formData.amount = 0 + this.invoiceList = [] if (!this.isEdit) { this.fetchCustomerInvoices(newValue.id) } }, invoice (newValue) { - this.formData.invoice_id = newValue.id - if (!this.isEdit) { - this.setPaymentAmountByInvoiceData(newValue.id) + if (newValue) { + this.formData.invoice_id = newValue.id + if (!this.isEdit) { + this.setPaymentAmountByInvoiceData(newValue.id) + } } } },