mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
add customer in expense
This commit is contained in:
@ -53,9 +53,13 @@ class ExpensesController extends Controller
|
||||
public function create(Request $request)
|
||||
{
|
||||
$categories = ExpenseCategory::whereCompany($request->header('company'))->get();
|
||||
$customers = User::customer()
|
||||
->whereCompany($request->header('company'))
|
||||
->get();
|
||||
|
||||
return response()->json([
|
||||
'categories' => $categories
|
||||
'categories' => $categories,
|
||||
'customers' => $customers
|
||||
]);
|
||||
}
|
||||
|
||||
@ -107,7 +111,9 @@ class ExpensesController extends Controller
|
||||
public function edit(Request $request,$id)
|
||||
{
|
||||
$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();
|
||||
|
||||
return response()->json([
|
||||
@ -205,7 +211,7 @@ class ExpensesController extends Controller
|
||||
* Retrive details of an expense receipt from storage.
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
*/
|
||||
public function showReceipt($id)
|
||||
{
|
||||
$expense = Expense::find($id);
|
||||
@ -239,7 +245,7 @@ class ExpensesController extends Controller
|
||||
* @param int $id
|
||||
* @param strig $hash
|
||||
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse | \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
*/
|
||||
public function downloadReceipt($id, $hash)
|
||||
{
|
||||
$company = Company::where('unique_hash', $hash)->first();
|
||||
|
||||
@ -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('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">
|
||||
<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
|
||||
@ -319,9 +337,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
|
||||
|
||||
Reference in New Issue
Block a user