mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-26 16:04:05 +00:00
E-Invoice - Fix minor problems discovered from Shipping Portal
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class AddressEInvoiceResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'street_one' => $this->street_one,
|
||||
'street_two' => $this->street_two,
|
||||
'district' => $this->district,
|
||||
'state' => $this->state,
|
||||
'post_code' => (int) $this->postcode,
|
||||
'country' => $this->country,
|
||||
'billing' => (int) $this->billing
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ class CompanyResource extends JsonResource
|
||||
'status' => (int) $this->status,
|
||||
'contact' => new ContactResource ($this->when($this->has('contacts'), $this->contacts->first())),
|
||||
'address' => new AddressResource($this->when($this->has('addresses'), $this->addresses->where('billing', true)->first())),
|
||||
'address_einvoice' => $this->e_invoice ? new AddressResource($this->when($this->has('addresses'), $this->addresses->where('billing', false)->where('e_invoice', true)->sortByDesc('created_at')->first())) : null,
|
||||
'address_einvoice' => $this->e_invoice ? new AddressEInvoiceResource($this->when($this->has('addresses'), $this->addresses->where('billing', false)->where('e_invoice', true)->sortByDesc('created_at')->first())) : null,
|
||||
'employee' => new UserResource(Auth::user()->type === RoleTypes::USER ? $this->employees()->where('email', '=', Auth::user()->email)->first() : $this->employees()->orderBy('id', 'DESC')->first()),
|
||||
'identification' => new DocumentResource($this->documents->whereIn('document_type', DocumentType::IDENTIFICATION_DOCUMENTS)->first()),
|
||||
'bookings' => $this->whenLoaded('bookings', $this->bookings()->orderBy('id', 'DESC')->get(), []),
|
||||
|
||||
@@ -20,7 +20,7 @@ class EInvoiceInfoResource extends JsonResource
|
||||
'street_two' => $this->street_two,
|
||||
'district' => $this->district,
|
||||
'state' => $this->state,
|
||||
'post_code' => $this->postcode,
|
||||
'post_code' => (int) $this->postcode,
|
||||
'country' => $this->country,
|
||||
'billing' => (int) $this->billing,
|
||||
'msic_code' => (int) $this->msic_code,
|
||||
|
||||
+41
-62
@@ -8,17 +8,17 @@
|
||||
</div>
|
||||
<div class="row m-b-15">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.parameters.name">
|
||||
<validation-wrapper-component :validator="$v.params.name">
|
||||
<label class="text-primary">Name</label>
|
||||
<input class="form-control" v-model="parameters.name">
|
||||
<input class="form-control" v-model="params.name">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.parameters.debtor">
|
||||
<validation-wrapper-component :validator="$v.params.debtor">
|
||||
<label class="text-primary">Debtor Code</label>
|
||||
<input class="form-control" v-model="parameters.debtor">
|
||||
<input class="form-control" v-model="params.debtor">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
@@ -27,58 +27,58 @@
|
||||
E-Invoice Info
|
||||
<div class="row m-b-15">
|
||||
<div class="col-6 p-r-5">
|
||||
<validation-wrapper-component :validator="$v.parameters.tin">
|
||||
<validation-wrapper-component :validator="$v.params.tin">
|
||||
<label class="text-primary">TIN</label>
|
||||
<input class="form-control" v-model="parameters.tin">
|
||||
<input class="form-control" v-model="params.tin">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col-6 p-l-5">
|
||||
<validation-wrapper-component :validator="$v.parameters.msic_code">
|
||||
<validation-wrapper-component :validator="$v.params.msic_code">
|
||||
<label class="text-primary">
|
||||
MSIC Code
|
||||
<a href="https://sdk.myinvois.hasil.gov.my/codes/msic-codes/" target="_blank" rel="noopener noreferrer">
|
||||
(View List)
|
||||
</a>
|
||||
</label>
|
||||
<input class="form-control" name="msic_code" v-model="parameters.msic_code">
|
||||
<input class="form-control" name="msic_code" v-model="params.msic_code">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.parameters.street_one">
|
||||
<validation-wrapper-component :validator="$v.params.street_one">
|
||||
<label class="text-primary">Billing Address Line 1</label>
|
||||
<input class="form-control" name="street_one" v-model="parameters.street_one">
|
||||
<input class="form-control" name="street_one" v-model="params.street_one">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.parameters.street_two">
|
||||
<validation-wrapper-component :validator="$v.params.street_two">
|
||||
<label class="text-primary">Billing Address Line 2</label>
|
||||
<input class="form-control" name="street_two" v-model="parameters.street_two">
|
||||
<input class="form-control" name="street_two" v-model="params.street_two">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15">
|
||||
<div class="col-7 p-r-5">
|
||||
<validation-wrapper-component selectable :validator="$v.parameters.district_id">
|
||||
<validation-wrapper-component selectable :validator="$v.params.district_id">
|
||||
<label class="text-primary">District</label>
|
||||
<selectable-component :endpoint="route('api.address.district.list')" section="districtListSection" valueColumn="id" :labelColumn="['city']" v-model="parameters.district_id"></selectable-component>
|
||||
<selectable-component :endpoint="route('api.address.district.list')" section="districtListSection" valueColumn="id" :labelColumn="['city']" v-model="params.district_id"></selectable-component>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col-5 p-l-5">
|
||||
<validation-wrapper-component :validator="$v.parameters.post_code">
|
||||
<validation-wrapper-component :validator="$v.params.post_code">
|
||||
<label class="text-primary">Post Code</label>
|
||||
<input class="form-control" v-model="parameters.post_code">
|
||||
<input class="form-control" v-model="params.post_code">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15">
|
||||
<div class="col-6 p-r-5">
|
||||
<validation-wrapper-component selectable :validator="$v.parameters.state_id">
|
||||
<validation-wrapper-component selectable :validator="$v.params.state_id">
|
||||
<label>State</label>
|
||||
<selectable-component :endpoint="route('api.address.state.list')" section="stateListSection" valueColumn="id" :labelColumn="['state']" v-model="parameters.state_id"></selectable-component>
|
||||
<selectable-component :endpoint="route('api.address.state.list')" section="stateListSection" valueColumn="id" :labelColumn="['state']" v-model="params.state_id"></selectable-component>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
@@ -116,28 +116,32 @@
|
||||
}
|
||||
|
||||
export default {
|
||||
// validations: {
|
||||
// parameters: {
|
||||
// name: {
|
||||
// required,
|
||||
// },
|
||||
// debtor: {},
|
||||
// tin: {},
|
||||
// msic_code: {},
|
||||
data() {
|
||||
return {
|
||||
params: {
|
||||
id: this.data.id,
|
||||
reference: this.data.reference,
|
||||
type: this.data.type,
|
||||
|
||||
// address_id: {},
|
||||
// street_one: {},
|
||||
// street_two: {},
|
||||
// district_id: {},
|
||||
// state_id: {},
|
||||
// post_code: {},
|
||||
// }
|
||||
// },
|
||||
name: this.data.name,
|
||||
debtor: this.data.debtor,
|
||||
tin: this.data.tin,
|
||||
msic_code: this.data.msic_code,
|
||||
|
||||
address_id: this.data.address_einvoice ? this.data.address_einvoice.id : null,
|
||||
street_one: this.data.address_einvoice ? this.data.address_einvoice.street_one : null,
|
||||
street_two: this.data.address_einvoice ? this.data.address_einvoice.street_two : null,
|
||||
district_id: this.data.address_einvoice ? this.data.address_einvoice.district.id : null,
|
||||
state_id: this.data.address_einvoice ? this.data.address_einvoice.state.id : null,
|
||||
post_code: this.data.address_einvoice ? this.data.address_einvoice.post_code : null,
|
||||
}
|
||||
}
|
||||
},
|
||||
validations() {
|
||||
const companyType = this.data.type
|
||||
const isEInvoiceEnabled = this.data.e_invoice !== 0 && this.data.e_invoice !== null;
|
||||
return {
|
||||
parameters: {
|
||||
params: {
|
||||
name: {
|
||||
required,
|
||||
},
|
||||
@@ -171,41 +175,16 @@
|
||||
street_two: {},
|
||||
district_id: isEInvoiceEnabled ? { required } : {},
|
||||
state_id: isEInvoiceEnabled ? { required } : {},
|
||||
post_code: isEInvoiceEnabled ? { required, notZero } : {},
|
||||
|
||||
post_code: isEInvoiceEnabled ? { notZero, fiveDigits } : {},
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (this.data) {
|
||||
if (this.data.address_einvoice) {
|
||||
this.parameters.address_id = this.data.address_einvoice.id;
|
||||
this.parameters.street_one = this.data.address_einvoice.street_one;
|
||||
this.parameters.street_two = this.data.address_einvoice.street_two;
|
||||
this.parameters.district_id = this.data.address_einvoice.district.id;
|
||||
this.parameters.state_id = this.data.address_einvoice.state.id;
|
||||
this.parameters.post_code = this.data.address_einvoice.post_code;
|
||||
}
|
||||
}
|
||||
},
|
||||
// watch: {
|
||||
// 'data': function(newData) { //cief todo: 90
|
||||
// if (newData && newData.address_einvoice) {
|
||||
// this.parameters.address_id = newData.address_einvoice.id;
|
||||
// this.parameters.street_one = newData.address_einvoice.street_one;
|
||||
// this.parameters.street_two = newData.address_einvoice.street_two;
|
||||
// this.parameters.district_id = newData.address_einvoice.district.id;
|
||||
// this.parameters.state_id = newData.address_einvoice.state.id;
|
||||
// this.parameters.post_code = newData.address_einvoice.post_code;
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
methods: {
|
||||
successHandler(response) {
|
||||
// window.location.replace(this.route('customers', response.payload.data.reference));
|
||||
this.closeModal();
|
||||
},
|
||||
submitForm() {
|
||||
this.parameters = this.params;
|
||||
this.submit(this.route('api.company.update.details', this.data.id), 'put', this.section, true, true)
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user