mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 04:01:10 -04:00
Merge branch 'expense-refactor' into 'master'
add customer in expense See merge request mohit.panjvani/crater-web!172
This commit is contained in:
@ -412,6 +412,8 @@
|
||||
"title": "النفقات",
|
||||
"expenses_list": "قائمة النفقات",
|
||||
"expense_title": "Title",
|
||||
"select_a_customer": "حدد عميلاً",
|
||||
"customer": "العميل",
|
||||
"contact": "تواصل",
|
||||
"category": "الفئة",
|
||||
"from_date": "من تاريخ",
|
||||
|
||||
@ -201,6 +201,7 @@
|
||||
"action": "Aktion",
|
||||
"add_expense": "Aufwendung hinzufügen",
|
||||
"add_new_expense": "Neue Aufwendung hinzufügen",
|
||||
"select_a_customer": "Wählen Sie einen Kunden aus",
|
||||
"amount": "Summe",
|
||||
"categories": {
|
||||
"actions": "Aktionen",
|
||||
@ -215,6 +216,7 @@
|
||||
"title": "Titel"
|
||||
},
|
||||
"category": "Kategorie",
|
||||
"customer": "Kunden",
|
||||
"category_id": "Kategorie-Id",
|
||||
"confirm_delete": "Sie können diese Ausgabe nicht wiederherstellen. | Sie können diese Ausgaben nicht wiederherstellen.",
|
||||
"contact": "Kontakt",
|
||||
|
||||
@ -426,7 +426,9 @@
|
||||
"expenses": {
|
||||
"title": "Expenses",
|
||||
"expenses_list": "Expenses List",
|
||||
"select_a_customer": "Select a customer",
|
||||
"expense_title": "Title",
|
||||
"customer": "Customer",
|
||||
"contact": "Contact",
|
||||
"category": "Category",
|
||||
"from_date": "From Date",
|
||||
|
||||
@ -412,6 +412,8 @@
|
||||
"expenses_list": "Lista de gastos",
|
||||
"expense_title": "Título",
|
||||
"contact": "Contacto",
|
||||
"customer": "Cliente",
|
||||
"select_a_customer": "Selecciona un cliente",
|
||||
"category": "Categoría",
|
||||
"from_date": "Desde la fecha",
|
||||
"to_date": "Hasta la fecha",
|
||||
|
||||
@ -410,6 +410,8 @@
|
||||
"expenses_list": "Liste des dépenses",
|
||||
"expense_title": "Titre",
|
||||
"contact": "Contact",
|
||||
"customer": "Client Client",
|
||||
"select_a_customer": "Sélectionnez un client",
|
||||
"category": "Catégorie",
|
||||
"from_date": "A partir de la date",
|
||||
"to_date": "À ce jour",
|
||||
|
||||
@ -414,6 +414,7 @@
|
||||
"expense_title": "Título",
|
||||
"contact": "Contato",
|
||||
"category": "Categoria",
|
||||
"customer": "Cliente",
|
||||
"from_date": "A partir da Data",
|
||||
"to_date": "Até a Data",
|
||||
"expense_date": "Data",
|
||||
|
||||
@ -102,6 +102,19 @@
|
||||
<span v-if="!$v.formData.amount.minValue" class="text-danger">{{ $t('validation.price_minvalue') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label class="form-label">{{ $t('expenses.customer') }}</label>
|
||||
<base-select
|
||||
ref="baseSelect"
|
||||
v-model="customer"
|
||||
:options="customerList"
|
||||
:searchable="true"
|
||||
:show-labels="false"
|
||||
:placeholder="$t('customers.select_a_customer')"
|
||||
label="name"
|
||||
track-by="id"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group col-sm-6">
|
||||
<label for="description">{{ $t('expenses.note') }}</label>
|
||||
<base-text-area
|
||||
@ -169,7 +182,8 @@ export default {
|
||||
expense_category_id: null,
|
||||
expense_date: new Date(),
|
||||
amount: null,
|
||||
notes: ''
|
||||
notes: '',
|
||||
user_id: null
|
||||
},
|
||||
money: {
|
||||
decimal: '.',
|
||||
@ -185,7 +199,9 @@ export default {
|
||||
passData: [],
|
||||
contacts: [],
|
||||
previewReceipt: null,
|
||||
fileSendUrl: '/api/expenses'
|
||||
fileSendUrl: '/api/expenses',
|
||||
customer: null,
|
||||
customerList: []
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
@ -297,6 +313,8 @@ export default {
|
||||
},
|
||||
async fetchInitialData () {
|
||||
this.fetchCategories()
|
||||
let fetchData = await this.fetchCreateExpense()
|
||||
this.customerList = fetchData.data.customers
|
||||
if (this.isEdit) {
|
||||
let response = await this.fetchExpense(this.$route.params.id)
|
||||
this.category = response.data.expense.category
|
||||
@ -304,6 +322,9 @@ export default {
|
||||
this.formData.expense_date = moment(this.formData.expense_date).toString()
|
||||
this.formData.amount = (response.data.expense.amount)
|
||||
this.fileSendUrl = `/api/expenses/${this.$route.params.id}`
|
||||
if (response.data.expense.user_id) {
|
||||
this.customer = this.customerList.find(customer => customer.id === response.data.expense.user_id)
|
||||
}
|
||||
}
|
||||
},
|
||||
async sendData () {
|
||||
@ -319,9 +340,10 @@ export default {
|
||||
data.append('attachment_receipt', this.file)
|
||||
}
|
||||
data.append('expense_category_id', this.formData.expense_category_id)
|
||||
data.append('expense_date', moment(this.formData.expense_date).format('DD/MM/YYYY'))
|
||||
data.append('expense_date', moment(this.formData.expense_date).format('DD/MM/YYYY'))
|
||||
data.append('amount', (this.formData.amount))
|
||||
data.append('notes', this.formData.notes ? this.formData.notes : '')
|
||||
data.append('user_id', this.customer ? this.customer.id : '')
|
||||
|
||||
if (this.isEdit) {
|
||||
this.isLoading = true
|
||||
|
||||
@ -43,7 +43,19 @@
|
||||
<transition name="fade">
|
||||
<div v-show="showFilters" class="filter-section">
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-3">
|
||||
<label>{{ $t('expenses.customer') }}</label>
|
||||
<base-select
|
||||
v-model="filters.user"
|
||||
:options="customers"
|
||||
:searchable="true"
|
||||
:show-labels="false"
|
||||
:placeholder="$t('expenses.select_a_customer')"
|
||||
label="name"
|
||||
@click="filter = ! filter"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label>{{ $t('expenses.category') }}</label>
|
||||
<base-select
|
||||
v-model="filters.category"
|
||||
@ -55,7 +67,7 @@
|
||||
@click="filter = ! filter"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-3">
|
||||
<label>{{ $t('expenses.from_date') }}</label>
|
||||
<base-date-picker
|
||||
v-model="filters.from_date"
|
||||
@ -63,7 +75,7 @@
|
||||
calendar-button-icon="calendar"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-3">
|
||||
<label>{{ $t('expenses.to_date') }}</label>
|
||||
<base-date-picker
|
||||
v-model="filters.to_date"
|
||||
@ -161,6 +173,11 @@
|
||||
sort-as="name"
|
||||
show="category.name"
|
||||
/>
|
||||
<table-column
|
||||
:label="$t('expenses.customer')"
|
||||
sort-as="user_name"
|
||||
show="user_name"
|
||||
/>
|
||||
<table-column
|
||||
:label="$t('expenses.date')"
|
||||
sort-as="expense_date"
|
||||
@ -237,10 +254,12 @@ export default {
|
||||
showFilters: false,
|
||||
filtersApplied: false,
|
||||
isRequestOngoing: true,
|
||||
customers: [],
|
||||
filters: {
|
||||
category: null,
|
||||
from_date: '',
|
||||
to_date: ''
|
||||
to_date: '',
|
||||
user: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -308,6 +327,7 @@ export default {
|
||||
]),
|
||||
async fetchData ({ page, filter, sort }) {
|
||||
let data = {
|
||||
user_id: this.filters.user ? this.filters.user.id : null,
|
||||
expense_category_id: this.filters.category !== null ? this.filters.category.id : '',
|
||||
from_date: this.filters.from_date === '' ? this.filters.from_date : moment(this.filters.from_date).format('DD/MM/YYYY'),
|
||||
to_date: this.filters.to_date === '' ? this.filters.to_date : moment(this.filters.to_date).format('DD/MM/YYYY'),
|
||||
@ -318,6 +338,7 @@ export default {
|
||||
|
||||
this.isRequestOngoing = true
|
||||
let response = await this.fetchExpenses(data)
|
||||
this.customers = response.data.customers
|
||||
this.isRequestOngoing = false
|
||||
|
||||
return {
|
||||
@ -340,7 +361,8 @@ export default {
|
||||
this.filters = {
|
||||
category: null,
|
||||
from_date: '',
|
||||
to_date: ''
|
||||
to_date: '',
|
||||
user: null
|
||||
}
|
||||
|
||||
this.$nextTick(() => {
|
||||
|
||||
Reference in New Issue
Block a user