Commit ba6abe16 authored by Chanon.u's avatar Chanon.u
Browse files

Fix issue manual response function

+ Save password since create new config
+ Validate response before submit, reference number format
+ Gen declaration number when use lock data checkbox
+ No gen declaration number for Document Number tag
+ Logic for non-update xml tag when lock data as MessageType and
AuditDateTime
parent 220539c0
......@@ -55,9 +55,9 @@ class GenXmlController extends Controller
}
if (empty($value)) {
if(!$lockData && in_array($key, ['DeclarationNumber', 'DocumentNumber']) && $documentType !== null){
if($key == 'DeclarationNumber' && ($documentType !== null && $documentType != '')){
$value = $this->generateDeclarationNo($documentType);
}else if(!$lockData && $key == 'GoodsTransitionNumber'){
}else if($key == 'GoodsTransitionNumber'){
$value = $this->generateGCLNo();
}
......@@ -69,19 +69,13 @@ class GenXmlController extends Controller
} else {
$xml->addChild($key, htmlspecialchars($value));
}
$xmlData[$key] = $value; // Collect all tags as editable
$xmlData[$key] = $value; // Collect all tags as editable input html
}
}
$xmlNoData = [];
foreach($xmlData as $key => $val){
$xmlNoData[$key] = '';
}
//$this->updateXmlValues($this->formatXml($xml->asXML()), $xmlNoData)
return ['xmlContent' => $this->formatXml($xml->asXML()),
'xmlWithData' => $xmlData,
'xmlNoData' => $xmlNoData
'xmlWithData' => $xmlData
];
}
......
......@@ -53,6 +53,11 @@ class ManualResponse extends Component
'templateId.required' => '*Template cannot be empty.'
];
protected $listNonLockData = [
"MessageType",
"AuditDateTime"
];
public function mount()
{
$this->messageTypes = MasterMessages::pluck('value', 'id')->toArray();
......@@ -89,6 +94,7 @@ class ManualResponse extends Component
}else{
$this->disableDocType = false;
}
$this->lockData = false;
}
public function updatedXmlTagInputList()
......@@ -126,7 +132,7 @@ class ManualResponse extends Component
if($this->lockData){
foreach($this->xmlData as $key => $val){
if(isset($tmp_xmlData[$key]) && $key != 'Message'){
if(isset($tmp_xmlData[$key]) && !in_array($key, $this->listNonLockData)){
$this->xmlData[$key] = $tmp_xmlData[$key];
}
}
......@@ -153,10 +159,12 @@ class ManualResponse extends Component
public function generateAndUploadXml()
{
$this->reGenerateXML();
if(!$this->validateBeforeSend($this->xmlContent)){
$validateResult = $this->validateBeforeSend();
if(!$validateResult['success']){
$this->dispatchBrowserEvent('open-modal', [
'name' => 'alert-modal',
'message' => 'Profile production is not allowed.',
'message' => $validateResult['message'],
'status' => 'failed'
]);
return;
......@@ -249,10 +257,24 @@ class ManualResponse extends Component
private function validateBeforeSend(){
$referenceNo = $this->xmlData['ReferenceNumber'];
$profileProds = ConfListProfile::where('type', 'PROD')->pluck('name')->toArray();
//Validate reference number format
if (isset($referenceNo) && !preg_match('/^[A-Z]{4}[0-9]{9}$/', $referenceNo)) {
return [
"success" => false,
'message' => 'Reference Number is incorrect format.'
];
}
//Validate profile production
if(isset($referenceNo) && in_array(substr($referenceNo, 0, 1), $profileProds)){
return false;
return [
"success" => false,
'message' => 'Profile production is not allowed.'
];
}
return true;
return ['success' => true, 'message' => ''];
}
private function validateAfterSend($result){
......
......@@ -53,8 +53,8 @@ class ConfigManualResponse extends Component
UsersConnectSpn::create([
'uid' => $this->editUserId,
'username' => $this->usernameSPN,
'password' => '',
"link" => $this->linkSPN
'password' => password_hash($this->passwordSPN, PASSWORD_BCRYPT),
'link' => $this->linkSPN
]);
}
......
......@@ -45,7 +45,7 @@ return new class extends Migration
'type' => 'GCLD',
'name' => 'พบหน่วยงานผู้ออกใบอนุญาตหรือใบรับรองอิเล็กทรอนิกส์เพื่อตรวจสอบของ',
'description' => '',
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLD","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"GoodsAudit":{"DeclarationNumber":"","ContainerNumber":"CONT-SIT-01","LoadPort":"0010","Message":"พบหน่วยงานผู้ออกใบอนุญาตหรือใบรับรองอิเล็กทรอนิกส์เพื่อตรวจสอบของ","AuditDateTime":""}}}}'
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLD","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"GoodsAudit":{"DeclarationNumber":"","ContainerNumber":"CONT1234567","LoadPort":"0010","Message":"พบหน่วยงานผู้ออกใบอนุญาตหรือใบรับรองอิเล็กทรอนิกส์เพื่อตรวจสอบของ","AuditDateTime":""}}}}'
],
[
'mid' => 1,
......@@ -53,7 +53,7 @@ return new class extends Migration
'type' => 'GCLD',
'name' => 'Goods Transition Control Already Checked ให้มาตรวจของที่ท่าที่ส่งออก',
'description' => '',
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLD","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"GoodsAudit":{"DeclarationNumber":"","ContainerNumber":"CONT-SIT-01","LoadPort":"0010","Message":"Goods Transition Control Already Checked ให้มาตรวจของที่ท่าที่ส่งออก","AuditDateTime":""}}}}'
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLD","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"GoodsAudit":{"DeclarationNumber":"","ContainerNumber":"CONT1234567","LoadPort":"0010","Message":"Goods Transition Control Already Checked ให้มาตรวจของที่ท่าที่ส่งออก","AuditDateTime":""}}}}'
],
[
'mid' => 1,
......@@ -61,7 +61,7 @@ return new class extends Migration
'type' => 'GCLD',
'name' => 'Goods Transition Control Already Checked',
'description' => '',
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLD","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"GoodsAudit":{"DeclarationNumber":"","ContainerNumber":"CONT-SIT-01","LoadPort":"0010","Message":"Goods Transition Control Already Checked","AuditDateTime":""}}}}'
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLD","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"GoodsAudit":{"DeclarationNumber":"","ContainerNumber":"CONT1234567","LoadPort":"0010","Message":"Goods Transition Control Already Checked","AuditDateTime":""}}}}'
],
[
'mid' => 1,
......@@ -69,7 +69,7 @@ return new class extends Migration
'type' => 'GCLD',
'name' => 'GOODS LOADED',
'description' => '',
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLD","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"GoodsAudit":{"DeclarationNumber":"","ContainerNumber":"CONT-SIT-01","LoadPort":"0010","Message":"GOODS LOADED","AuditDateTime":""}}}}'
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLD","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"GoodsAudit":{"DeclarationNumber":"","ContainerNumber":"CONCONT1234567","LoadPort":"0010","Message":"GOODS LOADED","AuditDateTime":""}}}}'
],
[
'mid' => 1,
......@@ -101,7 +101,7 @@ return new class extends Migration
'type' => 'GCLD',
'name' => 'Goods Transition Control Already Cancel Matching',
'description' => '',
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLD","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"GoodsAudit":{"DeclarationNumber":"","ContainerNumber":"CONT-SIT-01","LoadPort":"0010","Message":"Goods Transition Control Already Cancel Matching","AuditDateTime":""}}}}'
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLD","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"GoodsAudit":{"DeclarationNumber":"","ContainerNumber":"CONT1234567","LoadPort":"0010","Message":"Goods Transition Control Already Cancel Matching","AuditDateTime":""}}}}'
],
//Import
......@@ -201,7 +201,7 @@ return new class extends Migration
'type' => 'GCLA',
'name' => 'GOODS CONTROL ACCEPT',
'description' => '',
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLA","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"GoodsTransitionAccept":{"GoodsTransitionNumber":"","ContainerNumber":"CONT-A0102723-1","LoadPort":"2801","Message":"GOODS CONTROL ACCEPT"}}}}'
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLA","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"GoodsTransitionAccept":{"GoodsTransitionNumber":"","ContainerNumber":"CONT1234567","LoadPort":"2801","Message":"GOODS CONTROL ACCEPT"}}}}'
],
[
'mid' => 3,
......@@ -209,7 +209,7 @@ return new class extends Migration
'type' => 'GCLA_BKK',
'name' => 'GOODS CONTROL ACCEPT (Port)',
'description' => 'PORT',
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLA_BKK","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"GoodsTransitionAccept":{"GoodsTransitionNumber":"","ContainerNumber":"CONT-A0102723-1","LoadPort":"2801","Message":"GOODS CONTROL ACCEPT"}}}}'
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLA_BKK","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"GoodsTransitionAccept":{"GoodsTransitionNumber":"","ContainerNumber":"CONT1234567","LoadPort":"2801","Message":"GOODS CONTROL ACCEPT"}}}}'
],
[
'mid' => 3,
......@@ -217,7 +217,7 @@ return new class extends Migration
'type' => 'GCLD',
'name' => 'Goods Transition Control Already Checked ให้มาตรวจของที่ท่าที่ส่งออก',
'description' => '',
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLD","ReferenceNumber":"","RegistrationID":"TH0041010353980000000010001T5","DocumentDetail":{"GoodsAudit":{"DeclarationNumber":"","ContainerNumber":"CONT-SIT-02","LoadPort":"0010","Message":"Goods Transition Control Already Checked","AuditDateTime":""}}}}'
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLD","ReferenceNumber":"","RegistrationID":"TH0041010353980000000010001T5","DocumentDetail":{"GoodsAudit":{"DeclarationNumber":"","ContainerNumber":"CONT1234567","LoadPort":"0010","Message":"Goods Transition Control Already Checked","AuditDateTime":""}}}}'
],
[
'mid' => 3,
......@@ -225,7 +225,7 @@ return new class extends Migration
'type' => 'GCLD',
'name' => 'Goods Transition Control Already Checked',
'description' => '',
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLD","ReferenceNumber":"","RegistrationID":"TH0041010353980000000010001T5","DocumentDetail":{"GoodsAudit":{"GoodsTransitionNumber":"","ContainerNumber":"CONT-SIT-02","LoadPort":"0010","Message":"Goods Transition Control Already Checked","AuditDateTime":""}}}}'
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLD","ReferenceNumber":"","RegistrationID":"TH0041010353980000000010001T5","DocumentDetail":{"GoodsAudit":{"DeclarationNumber":"","ContainerNumber":"CONT1234567","LoadPort":"0010","Message":"Goods Transition Control Already Checked","AuditDateTime":""}}}}'
],
[
'mid' => 3,
......@@ -233,7 +233,7 @@ return new class extends Migration
'type' => 'GCLR',
'name' => 'REJECT',
'description' => 'INVALID CONTAINER SIZE AND TYPE CODE',
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLR","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"GoodsTransitionReject":{"DeclarationNumber":"","ContainerNumber":"CONT-A0102723-1","ErrorCode":"GCEX-00052 ","Message":"INVALID CONTAINER SIZE AND TYPE CODE"}}}}'
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLR","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"GoodsTransitionReject":{"DeclarationNumber":"","ContainerNumber":"CONT1234567","ErrorCode":"GCEX-00052 ","Message":"INVALID CONTAINER SIZE AND TYPE CODE"}}}}'
],
[
'mid' => 3,
......@@ -241,7 +241,15 @@ return new class extends Migration
'type' => 'XCDA',
'name' => 'CANCEL',
'description' => '',
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"XCDA","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"CancelDocumentAccept":{"DocumentNumber":"","Message":"CONT-A0102723-1"}}}}'
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"XCDA","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"CancelDocumentAccept":{"DocumentNumber":"","Message":"GOODS CONTROL CANCELED"}}}}'
],
[
'mid' => 3,
'code' => 'CANCEL ACCEPT - PORT',
'type' => 'XCDA_LCB',
'name' => 'CANCEL',
'description' => '',
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"XCDA_LCB","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"CancelDocumentAccept":{"DocumentNumber":"","Message":"GOODS CONTROL CANCELED"}}}}'
],
[
'mid' => 3,
......@@ -249,7 +257,7 @@ return new class extends Migration
'type' => 'GCLD',
'name' => 'CANCEL MATCHING',
'description' => '',
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLD","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"GoodsAudit":{"DeclarationNumber":"","ContainerNumber":"CONT-A0102723-1","LoadPort":"2801","Message":"Goods Transition Control Already Cancel Matching","AuditDateTime":""}}}}'
'template' => '{"root":"CustomsResponse","namespace":"http://ebxml.customs.go.th/XMLSchema/CustomsResponse_8_00","DocumentControl":{"MessageType":"GCLD","ReferenceNumber":"","RegistrationID":"TH0101075570001010000000001T0","DocumentDetail":{"GoodsAudit":{"DeclarationNumber":"","ContainerNumber":"CONT1234567","LoadPort":"2801","Message":"Goods Transition Control Already Cancel Matching","AuditDateTime":""}}}}'
],
//SHORT
......
......@@ -26,21 +26,17 @@ return new class extends Migration
DB::table('mr_master_doc_types')->insert([
['mid' => '2', 'code' => '0', 'name' => '0-ใบขนสินค้าขาเข้า', 'mode' => 'IMDECL'],
['mid' => '2', 'code' => '2', 'name' => '2-ใบขนสินค้าผ่านแดน (Transit)', 'mode' => 'IMDECL'],
['mid' => '2', 'code' => '3', 'name' => '3-คำร้องขอรับของไปก่อน', 'mode' => 'IMDECL'],
['mid' => '2', 'code' => '5', 'name' => '5-ใบขนสินค้าขาเข้าปากระวาง', 'mode' => 'IMDECL'],
['mid' => '2', 'code' => '8', 'name' => '8-ใบขนสินค้าถ่ายลำ (Transhipment)', 'mode' => 'IMDECL'],
['mid' => '2', 'code' => 'A', 'name' => 'A-ใบขนสินค้าขาเข้าโอนย้ายในประเทศ', 'mode' => 'IMDECL'],
['mid' => '2', 'code' => 'C', 'name' => 'C-ใบขนสินค้าขาเข้าโอนย้ายจากเขตปลอดอากร', 'mode' => 'IMDECL'],
['mid' => '2', 'code' => 'X', 'name' => 'X-ใบขนสินค้าขาเข้าเร่งด่วน', 'mode' => 'IMDECL'],
['mid' => '2', 'code' => 'P', 'name' => 'P-ใบขนสินค้าขาเข้าโอนย้ายชำระค่าภาษีอากร', 'mode' => 'IMDECL'],
['mid' => '1', 'code' => '1', 'name' => '1-ใบขนสินค้าขาออก', 'mode' => 'EXDECL'],
['mid' => '1', 'code' => '4', 'name' => '4-คำร้องขอออกของไปก่อน', 'mode' => 'EXDECL'],
['mid' => '1', 'code' => 'B', 'name' => 'B-ใบขนสินค้าขาออกโอนย้ายภายในประเทศ', 'mode' => 'EXDECL'],
['mid' => '1', 'code' => 'D', 'name' => 'D-ใบขนสินค้าขาออกโอนย้ายเข้าเขตปลอดอากร', 'mode' => 'EXDECL'],
['mid' => '1', 'code' => '6', 'name' => '6-ใบขนสินค้าพิเศษผ่านแดนขาออก', 'mode' => 'EXDECL'],
['mid' => '1', 'code' => 'H', 'name' => 'H-คำร้องขอนำออกนอกเขตอารักขาศุลกากร', 'mode' => 'EXDECL'],
['mid' => '1', 'code' => 'Y', 'name' => 'Y-ใบขนสินค้าขาออกเร่งด่วน', 'mode' => 'EXDECL'],
['mid' => '2', 'code' => 'X', 'name' => 'X-ใบขนสินค้าขาเข้าเร่งด่วน', 'mode' => 'IMDECL'],
['mid' => '2', 'code' => 'P', 'name' => 'P-ใบขนสินค้าขาเข้าโอนย้ายชำระค่าภาษีอากร', 'mode' => 'IMDECL'],
]);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment