mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-20 04:44:05 +00:00
pending in title
This commit is contained in:
@@ -22,7 +22,7 @@ class InvoiceController extends Controller
|
||||
|
||||
$invoice = Invoice::where('booking_id', $id)->first();
|
||||
if (!$invoice) {
|
||||
return response().json(['message' => 'Invoice Not Found'], 404);
|
||||
return response()->json(['message' => 'Invoice Not Found'], 404);
|
||||
}
|
||||
$lines = InvoiceDetails::where('invoice_id', $invoice['id'])->orderBy('order', 'asc')->get();
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
/* eslint-disable camelcase */
|
||||
<template>
|
||||
<div class="invoice">
|
||||
<h3 class="title">Purchase Order</h3>
|
||||
<h3 v-if="created" class="title">
|
||||
Purchase Order (Pending Approval)
|
||||
</h3>
|
||||
<h3 v-else class="title">
|
||||
Purchase Order
|
||||
</h3>
|
||||
|
||||
<div class="invoice-container">
|
||||
<form @submit.prevent="submitForm">
|
||||
@@ -24,6 +29,7 @@
|
||||
'is-invalid': $v.form.formData.buyer_company.$invalid && $v.form.formData.buyer_company.$dirty,
|
||||
'is-valid': !$v.form.formData.buyer_company.$invalid && $v.form.formData.buyer_company.$dirty
|
||||
}"
|
||||
:disabled="!editable"
|
||||
type="text"
|
||||
class="form-control"
|
||||
@blur="$v.form.formData.buyer_company.$touch()">
|
||||
@@ -43,6 +49,7 @@
|
||||
'is-invalid': $v.form.formData.contact_no.$invalid && $v.form.formData.contact_no.$dirty,
|
||||
'is-valid': !$v.form.formData.contact_no.$invalid && $v.form.formData.contact_no.$dirty
|
||||
}"
|
||||
:disabled="!editable"
|
||||
type="tel"
|
||||
class="form-control"
|
||||
@blur="$v.form.formData.contact_no.$touch()">
|
||||
@@ -58,6 +65,7 @@
|
||||
'is-invalid': $v.form.formData.address.$invalid && $v.form.formData.address.$dirty,
|
||||
'is-valid': !$v.form.formData.address.$invalid && $v.form.formData.address.$dirty
|
||||
}"
|
||||
:disabled="!editable"
|
||||
class="form-control"
|
||||
cols="30"
|
||||
rows="4"
|
||||
@@ -100,6 +108,7 @@
|
||||
'is-invalid': $v.form.addLine.stock_code.$invalid && $v.form.addLine.stock_code.$dirty,
|
||||
'is-valid': !$v.form.addLine.stock_code.$invalid && $v.form.addLine.stock_code.$dirty
|
||||
}"
|
||||
:disabled="!editable"
|
||||
name="stockcode" type="text"
|
||||
class="form-control"
|
||||
@blur="$v.form.addLine.stock_code.$touch()">
|
||||
@@ -116,6 +125,7 @@
|
||||
'is-invalid': $v.form.addLine.description.$invalid && $v.form.addLine.description.$dirty,
|
||||
'is-valid': !$v.form.addLine.description.$invalid && $v.form.addLine.description.$dirty
|
||||
}"
|
||||
:disabled="!editable"
|
||||
name="description" cols="20" rows="2"
|
||||
@blur="$v.form.addLine.description.$touch()"/>
|
||||
<div class="invalid-feedback">
|
||||
@@ -131,6 +141,7 @@
|
||||
'is-invalid': $v.form.addLine.quantity.$invalid && $v.form.addLine.quantity.$dirty,
|
||||
'is-valid': !$v.form.addLine.quantity.$invalid && $v.form.addLine.quantity.$dirty
|
||||
}"
|
||||
:disabled="!editable"
|
||||
type="number"
|
||||
min="1"
|
||||
class="form-control"
|
||||
@@ -150,6 +161,7 @@
|
||||
'is-invalid': $v.form.addLine.unit_price_rmb.$invalid && $v.form.addLine.unit_price_rmb.$dirty,
|
||||
'is-valid': !$v.form.addLine.unit_price_rmb.$invalid && $v.form.addLine.unit_price_rmb.$dirty
|
||||
}"
|
||||
:disabled="!editable"
|
||||
type="number"
|
||||
min="0"
|
||||
name="rmb-unit-price"
|
||||
@@ -169,6 +181,7 @@
|
||||
'is-invalid': $v.form.addLine.unit_price_rm.$invalid && $v.form.addLine.unit_price_rm.$dirty,
|
||||
'is-valid': !$v.form.addLine.unit_price_rm.$invalid && $v.form.addLine.unit_price_rm.$dirty
|
||||
}"
|
||||
:disabled="!editable"
|
||||
type="number"
|
||||
min="0"
|
||||
name="rm-unit-price"
|
||||
@@ -192,7 +205,7 @@
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-success" type="button" @click="onAddLine()">
|
||||
<button :disabled="!editable" class="btn btn-success" type="button" @click="onAddLine()">
|
||||
Add
|
||||
</button>
|
||||
</td>
|
||||
@@ -220,7 +233,7 @@
|
||||
{{ line.total }}
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-danger" @click="onRemoveLine(index)">
|
||||
<button :disabled="!editable" class="btn btn-danger" @click="onRemoveLine(index)">
|
||||
Remove
|
||||
</button>
|
||||
</td>
|
||||
@@ -266,7 +279,7 @@
|
||||
<tr>
|
||||
<td colspan="5"> </td>
|
||||
<td colspan="2">
|
||||
<button class="btn btn-success btn-block" type="submit">
|
||||
<button :disabled="!editable" class="btn btn-success btn-block" type="submit">
|
||||
Create PO
|
||||
</button>
|
||||
</td>
|
||||
@@ -399,10 +412,16 @@ export default {
|
||||
invoice_total: 0,
|
||||
tax: 0,
|
||||
subtotal: 0,
|
||||
total: 0
|
||||
total: 0,
|
||||
role: null,
|
||||
created: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
editable: function () {
|
||||
// Not editable if created and not admin
|
||||
return this.role === 'admin' || !this.created
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
form: {
|
||||
@@ -452,10 +471,6 @@ export default {
|
||||
watch: {
|
||||
booking_details: function () {
|
||||
const {
|
||||
buyer_company,
|
||||
reg_no,
|
||||
address,
|
||||
contact_no,
|
||||
marking,
|
||||
tax,
|
||||
service_charge,
|
||||
@@ -463,10 +478,6 @@ export default {
|
||||
rate
|
||||
} = this.booking_details
|
||||
|
||||
this.form.formData.buyer_company = buyer_company
|
||||
this.form.formData.reg_no = reg_no
|
||||
this.form.formData.address = address
|
||||
this.form.formData.contact_no = contact_no
|
||||
this.form.formData.marking = marking
|
||||
this.tax = tax
|
||||
this.service_charge = service_charge
|
||||
@@ -474,8 +485,9 @@ export default {
|
||||
this.rate = rate
|
||||
}
|
||||
},
|
||||
created: {
|
||||
|
||||
mounted () {
|
||||
this.getInvoice()
|
||||
this.getUser()
|
||||
},
|
||||
methods: {
|
||||
onAddLine: function () {
|
||||
@@ -555,8 +567,40 @@ export default {
|
||||
|
||||
axios
|
||||
.post(url, this.form.formData)
|
||||
.then(resp => console.log(resp))
|
||||
.catch(err => console.error(err))
|
||||
.then(resp => {
|
||||
this.created = true
|
||||
alert('PO Created. Pending Approval.')
|
||||
this.$router.push({ name: 'home' })
|
||||
console.log(resp)
|
||||
})
|
||||
.catch(err => {
|
||||
alert(JSON.stringify(err.response.data.message))
|
||||
console.error(err.response.data.message)
|
||||
})
|
||||
},
|
||||
getInvoice () {
|
||||
const url = '/api/invoice/' + this.booking_id
|
||||
axios
|
||||
.get(url)
|
||||
.then(resp => {
|
||||
this.form.formData.buyer_company = resp.data.buyer_company
|
||||
this.form.formData.contact_no = resp.data.contact_no
|
||||
this.form.formData.address = resp.data.address
|
||||
|
||||
resp.data.lines.forEach((el, i) => {
|
||||
this.form.formData.lines.push(el)
|
||||
})
|
||||
|
||||
this.created = true
|
||||
})
|
||||
},
|
||||
getUser () {
|
||||
const url = '/api/user'
|
||||
axios
|
||||
.get(url)
|
||||
.then(resp => {
|
||||
this.role = resp.data.role
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user