mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
E-Invoice - New state field when filling E-invoice info, validation of tin field and msic code field, etc...[AdminUI]
This commit is contained in:
@@ -118,7 +118,7 @@ class UpdateCompanyDetailsLogic extends AbstractControllerLogic
|
||||
//Update EInvoice Related Info
|
||||
if($company->e_invoice){
|
||||
$district = $this->fetchesDistrict->execute(['id' => $dto->districtId]);
|
||||
$addObj = new AddressObject($dto->streetOne, $dto->streetTwo, $district->country_id, $district->state_id, $district->id, $dto->postCode);
|
||||
$addObj = new AddressObject($dto->streetOne, $dto->streetTwo, $district->country_id, $dto->stateId, $district->id, $dto->postCode);
|
||||
$this->canCreateAddress->passes($addObj);
|
||||
|
||||
$address = $this->upsertsAddress->execute($company, $addObj, $dto->addressId);
|
||||
|
||||
@@ -12,10 +12,11 @@ class UpdateCompanyDetailsDTO implements DataTransferObject
|
||||
public string $reference;
|
||||
public int $type;
|
||||
|
||||
public int $tin;
|
||||
public string $tin;
|
||||
public int $msicCode;
|
||||
public int $addressId;
|
||||
public int $districtId;
|
||||
public int $stateId;
|
||||
public int $companyId;
|
||||
public string $streetOne;
|
||||
public string $streetTwo;
|
||||
@@ -29,10 +30,11 @@ class UpdateCompanyDetailsDTO implements DataTransferObject
|
||||
$this->reference = (string) ($data['reference'] ?? '');
|
||||
$this->type = (int) ($data['type'] ?? 0);
|
||||
|
||||
$this->tin = (int) ($data['tin'] ?? 0);
|
||||
$this->tin = (string) ($data['tin'] ?? 0);
|
||||
$this->msicCode = (int) ($data['msic_code'] ?? 0);
|
||||
$this->addressId = (int) ($data['address_id'] ?? 0);
|
||||
$this->districtId = (int) ($data['district_id'] ?? 0);
|
||||
$this->stateId = (int) ($data['state_id'] ?? 0);
|
||||
$this->companyId = (int) ($data['company_id'] ?? 0);
|
||||
$this->streetOne = (string) ($data['street_one'] ?? '');
|
||||
$this->streetTwo = (string) ($data['street_two'] ?? '');
|
||||
@@ -52,6 +54,7 @@ class UpdateCompanyDetailsDTO implements DataTransferObject
|
||||
'msic_code' => $this->msicCode,
|
||||
'address_id' => $this->addressId,
|
||||
'district_id' => $this->districtId,
|
||||
'state_id' => $this->stateId,
|
||||
'company_id' => $this->companyId,
|
||||
'street_one' => $this->streetOne,
|
||||
'street_two' => $this->streetTwo,
|
||||
|
||||
@@ -24,7 +24,7 @@ class EInvoiceInfoResource extends JsonResource
|
||||
'country' => $this->country,
|
||||
'billing' => (int) $this->billing,
|
||||
'msic_code' => (int) $this->msic_code,
|
||||
'tin' => (int) $this->tin,
|
||||
'tin' => (string) $this->tin,
|
||||
'e_invoice' => (int) $this->e_invoice,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15">
|
||||
<div class="row m-b-15">
|
||||
<div class="col-6 p-r-5">
|
||||
<validation-wrapper-component selectable :validator="$v.parameters.state_id">
|
||||
<label>State</label>
|
||||
@@ -168,7 +168,7 @@
|
||||
'id': function() {
|
||||
this.parameters.company_id = this.companyId;
|
||||
},
|
||||
// 'eInvoiceData': function() {
|
||||
// 'eInvoiceData': function() { //cief todo: 90
|
||||
// this.resetForm();
|
||||
// this.parameters = {
|
||||
// company_id: this.companyId,
|
||||
|
||||
+84
-18
@@ -22,7 +22,7 @@
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-5" v-if="data.e_invoice && data.tin">
|
||||
<div class="row m-b-5" v-if="data.e_invoice !== null">
|
||||
<div class="col">
|
||||
E-Invoice Info
|
||||
<div class="row m-b-15">
|
||||
@@ -47,7 +47,7 @@
|
||||
<div class="row m-b-15">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.parameters.street_one">
|
||||
<label class="text-primary">Address Line 1</label>
|
||||
<label class="text-primary">Billing Address Line 1</label>
|
||||
<input class="form-control" name="street_one" v-model="parameters.street_one">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
@@ -55,7 +55,7 @@
|
||||
<div class="row m-b-15">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.parameters.street_two">
|
||||
<label class="text-primary">Address Line 2</label>
|
||||
<label class="text-primary">Billing Address Line 2</label>
|
||||
<input class="form-control" name="street_two" v-model="parameters.street_two">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
@@ -74,6 +74,14 @@
|
||||
</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">
|
||||
<label>State</label>
|
||||
<selectable-component :endpoint="route('api.address.state.list')" section="stateListSection" valueColumn="id" :labelColumn="['state']" v-model="parameters.state_id"></selectable-component>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -90,23 +98,79 @@
|
||||
</template>
|
||||
<script>
|
||||
import modalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
import { required, minLength } from "vuelidate/lib/validators";
|
||||
import { required, minLength, maxLength, alphaNum, helpers } from 'vuelidate/lib/validators'
|
||||
|
||||
function mustContainLetterAndNumber(value) {
|
||||
if (!value) return true;
|
||||
const hasLetter = /[a-zA-Z]/.test(value);
|
||||
const hasNumber = /\d/.test(value);
|
||||
return hasLetter && hasNumber;
|
||||
}
|
||||
|
||||
function notZero(value) {
|
||||
return value !== 0 && value !== '0' && value !== null && value !== undefined
|
||||
}
|
||||
|
||||
function fiveDigits(value) {
|
||||
return /^\d{5}$/.test(value)
|
||||
}
|
||||
|
||||
export default {
|
||||
validations: {
|
||||
parameters: {
|
||||
name: {
|
||||
required,
|
||||
},
|
||||
debtor: {},
|
||||
tin: {},
|
||||
msic_code: {},
|
||||
// validations: {
|
||||
// parameters: {
|
||||
// name: {
|
||||
// required,
|
||||
// },
|
||||
// debtor: {},
|
||||
// tin: {},
|
||||
// msic_code: {},
|
||||
|
||||
address_id: {},
|
||||
street_one: {},
|
||||
street_two: {},
|
||||
district_id: {},
|
||||
post_code: {},
|
||||
// address_id: {},
|
||||
// street_one: {},
|
||||
// street_two: {},
|
||||
// district_id: {},
|
||||
// state_id: {},
|
||||
// post_code: {},
|
||||
// }
|
||||
// },
|
||||
validations() {
|
||||
const companyType = this.data.type
|
||||
return {
|
||||
parameters: {
|
||||
name: {
|
||||
required,
|
||||
},
|
||||
debtor: {},
|
||||
tin: {
|
||||
...(companyType === 0
|
||||
? {
|
||||
required,
|
||||
alphaNum,
|
||||
minLength: minLength(11),
|
||||
maxLength: maxLength(13)
|
||||
}
|
||||
: {}),
|
||||
...(companyType === 1
|
||||
? {
|
||||
required,
|
||||
alphaNum,
|
||||
minLength: minLength(10),
|
||||
maxLength: maxLength(12)
|
||||
}
|
||||
: {})
|
||||
},
|
||||
msic_code: {
|
||||
notZero, fiveDigits
|
||||
},
|
||||
|
||||
address_id: {},
|
||||
street_one: { required },
|
||||
street_two: {},
|
||||
district_id: { required },
|
||||
state_id: { required },
|
||||
post_code: { required, notZero},
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@@ -116,17 +180,19 @@
|
||||
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) {
|
||||
'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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user