mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 04:01:10 -04:00
add customer in expense
This commit is contained in:
@ -53,9 +53,13 @@ class ExpensesController extends Controller
|
|||||||
public function create(Request $request)
|
public function create(Request $request)
|
||||||
{
|
{
|
||||||
$categories = ExpenseCategory::whereCompany($request->header('company'))->get();
|
$categories = ExpenseCategory::whereCompany($request->header('company'))->get();
|
||||||
|
$customers = User::customer()
|
||||||
|
->whereCompany($request->header('company'))
|
||||||
|
->get();
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'categories' => $categories
|
'categories' => $categories,
|
||||||
|
'customers' => $customers
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +111,9 @@ class ExpensesController extends Controller
|
|||||||
public function edit(Request $request,$id)
|
public function edit(Request $request,$id)
|
||||||
{
|
{
|
||||||
$categories = ExpenseCategory::whereCompany($request->header('company'))->get();
|
$categories = ExpenseCategory::whereCompany($request->header('company'))->get();
|
||||||
$customers = User::where('role', 'customer')->whereCompany($request->header('company'))->get();
|
$customers = User::customer()
|
||||||
|
->whereCompany($request->header('company'))
|
||||||
|
->get();
|
||||||
$expense = Expense::with('category')->where('id', $id)->first();
|
$expense = Expense::with('category')->where('id', $id)->first();
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
|||||||
@ -102,6 +102,19 @@
|
|||||||
<span v-if="!$v.formData.amount.minValue" class="text-danger">{{ $t('validation.price_minvalue') }}</span>
|
<span v-if="!$v.formData.amount.minValue" class="text-danger">{{ $t('validation.price_minvalue') }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group col-sm-6">
|
||||||
|
<label class="form-label">{{ $t('payments.customer') }}</label><span class="text-danger"> *</span>
|
||||||
|
<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">
|
<div class="form-group col-sm-6">
|
||||||
<label for="description">{{ $t('expenses.note') }}</label>
|
<label for="description">{{ $t('expenses.note') }}</label>
|
||||||
<base-text-area
|
<base-text-area
|
||||||
@ -169,7 +182,8 @@ export default {
|
|||||||
expense_category_id: null,
|
expense_category_id: null,
|
||||||
expense_date: new Date(),
|
expense_date: new Date(),
|
||||||
amount: null,
|
amount: null,
|
||||||
notes: ''
|
notes: '',
|
||||||
|
user_id: null
|
||||||
},
|
},
|
||||||
money: {
|
money: {
|
||||||
decimal: '.',
|
decimal: '.',
|
||||||
@ -185,7 +199,9 @@ export default {
|
|||||||
passData: [],
|
passData: [],
|
||||||
contacts: [],
|
contacts: [],
|
||||||
previewReceipt: null,
|
previewReceipt: null,
|
||||||
fileSendUrl: '/api/expenses'
|
fileSendUrl: '/api/expenses',
|
||||||
|
customer: null,
|
||||||
|
customerList: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
validations: {
|
validations: {
|
||||||
@ -297,6 +313,8 @@ export default {
|
|||||||
},
|
},
|
||||||
async fetchInitialData () {
|
async fetchInitialData () {
|
||||||
this.fetchCategories()
|
this.fetchCategories()
|
||||||
|
let fetchData = await this.fetchCreateExpense()
|
||||||
|
this.customerList = fetchData.data.customers
|
||||||
if (this.isEdit) {
|
if (this.isEdit) {
|
||||||
let response = await this.fetchExpense(this.$route.params.id)
|
let response = await this.fetchExpense(this.$route.params.id)
|
||||||
this.category = response.data.expense.category
|
this.category = response.data.expense.category
|
||||||
@ -322,6 +340,7 @@ export default {
|
|||||||
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('amount', (this.formData.amount))
|
||||||
data.append('notes', this.formData.notes ? this.formData.notes : '')
|
data.append('notes', this.formData.notes ? this.formData.notes : '')
|
||||||
|
data.append('user_id', this.customer ? this.customer.id : '')
|
||||||
|
|
||||||
if (this.isEdit) {
|
if (this.isEdit) {
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
|
|||||||
Reference in New Issue
Block a user