mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
Merge branch 'dillon/90-e-invoice-shipping-portal-e' into vapor/production
This commit is contained in:
+62
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyEInvoiceRequest;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EInvoiceRequestDTO;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyEInvoiceRequestChangeLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated EInvoice Request',
|
||||
'message' => 'You have successfully updated company E-Invoice request'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var UpdatesCompanyEInvoiceRequest */
|
||||
private $updatesCompanyEInvoiceRequest;
|
||||
|
||||
|
||||
/**
|
||||
* UpdateCompanyEInvoiceRequestChangeLogic constructor.
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param UpdatesCompanyEInvoiceRequest $updatesCompanyEInvoiceRequest
|
||||
*/
|
||||
public function __construct(FetchesCompanyModule $fetchesCompanyModule, UpdatesCompanyEInvoiceRequest $updatesCompanyEInvoiceRequest)
|
||||
{
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->updatesCompanyEInvoiceRequest = $updatesCompanyEInvoiceRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$dto = new EInvoiceRequestDTO($request->all());
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $dto->companyModuleId]);
|
||||
|
||||
if($companyModule->company->e_invoice === 1){
|
||||
$this->updatesCompanyEInvoiceRequest->execute($companyModule->company, $dto->eInvoiceRequest);
|
||||
}
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
@@ -17,12 +17,18 @@ class UpdatesCompanyEInvoiceRequest extends AbstractUpdateRecord
|
||||
*/
|
||||
public function execute(Company $model, bool $eInvoice)
|
||||
{
|
||||
if (is_null($model->e_invoice_requested_at)) {
|
||||
if($eInvoice){
|
||||
$model->e_invoice_requested_at = now();
|
||||
if($eInvoice){
|
||||
if (is_null($model->e_invoice_requested_at)) {
|
||||
if($eInvoice){
|
||||
$model->e_invoice_requested_at = now();
|
||||
}
|
||||
}
|
||||
$model->e_invoice = 1;
|
||||
}
|
||||
else{
|
||||
$model->e_invoice_requested_at = null;
|
||||
$model->e_invoice = 0;
|
||||
}
|
||||
$model->e_invoice = $eInvoice;
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Companies;
|
||||
|
||||
use App\Classes\Modules\Companies\ControllersLogic\UpdateCompanyEInvoiceInfoLogic;
|
||||
use App\Classes\Modules\Companies\ControllersLogic\UpdateCompanyEInvoiceRequestLogic;
|
||||
use App\Classes\Modules\Companies\ControllersLogic\UpdateCompanyEInvoiceRequestChangeLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -18,7 +19,7 @@ class UpdateCompanyEInvoiceInfoController
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateCompanyEInvoiceRequestLogic $logic
|
||||
* @return JsonResponse
|
||||
@@ -26,4 +27,13 @@ class UpdateCompanyEInvoiceInfoController
|
||||
public function updateRequest(Request $request, UpdateCompanyEInvoiceRequestLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateCompanyEInvoiceRequestChangeLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function updateChangeOfMindRequest(Request $request, UpdateCompanyEInvoiceRequestChangeLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,18 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col text-right">
|
||||
<a
|
||||
id="e-invoice-request-link"
|
||||
href="javascript:void(0);"
|
||||
class="fs-12 text-complete text-underline pointer"
|
||||
@click="updateChangeOfMind()"
|
||||
>
|
||||
I don't need now
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" v-if="step === 2">
|
||||
@@ -239,6 +251,10 @@
|
||||
successHandler(response){
|
||||
this.$emit('eInvoiceInfoUpdated', response.payload.data);
|
||||
this.closeModal();
|
||||
},
|
||||
updateChangeOfMind(){
|
||||
this.$emit('eInvoiceChangeOfMindRequest');
|
||||
this.closeModal();
|
||||
}
|
||||
},
|
||||
mixins: [ModalFormHandler],
|
||||
|
||||
+30
-19
@@ -101,7 +101,7 @@
|
||||
:company-module-id="company.company_module.id"
|
||||
:company-type="company.type"
|
||||
v-on:eInvoiceInfoUpdated="updatedEInvoiceInfo($event)"
|
||||
v-on:close="createAddress = !createAddress">
|
||||
v-on:eInvoiceChangeOfMindRequest="changeOfMindEInvoiceRequest()">
|
||||
</e-invoice-info-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
@@ -135,7 +135,8 @@
|
||||
return {
|
||||
section: 'orderListSection',
|
||||
isLoading: true,
|
||||
company: null
|
||||
company: null,
|
||||
parameters : {}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -163,25 +164,30 @@
|
||||
this.isLoading = false;
|
||||
this.company = response.payload.data;
|
||||
|
||||
if(!this.$store.getters.isAdmin){
|
||||
if(this.company.company_module.e_invoice === null){
|
||||
this.$nextTick(() => {
|
||||
$('#modal-einvoice-request').modal('show');
|
||||
});
|
||||
}
|
||||
else if( this.company.company_module.e_invoice && (this.company.company_module.tin === null || this.company.company_module.msic_code === null) )
|
||||
{
|
||||
this.$nextTick(() => {
|
||||
$('#modal-einvoice-info').modal('show');
|
||||
});
|
||||
}
|
||||
if(section == this.section + 'ChangeOfMind'){
|
||||
this.$store.dispatch('reloadList', {'name': this.section});
|
||||
}
|
||||
else{
|
||||
if( this.company.company_module.e_invoice && (this.company.company_module.tin === null || this.company.company_module.msic_code === null) )
|
||||
{
|
||||
this.$nextTick(() => {
|
||||
$('#modal-einvoice-info').modal('show');
|
||||
});
|
||||
if(!this.$store.getters.isAdmin){
|
||||
if(this.company.company_module.e_invoice === null){
|
||||
this.$nextTick(() => {
|
||||
$('#modal-einvoice-request').modal('show');
|
||||
});
|
||||
}
|
||||
else if( this.company.company_module.e_invoice && (this.company.company_module.tin === null || this.company.company_module.msic_code === null) )
|
||||
{
|
||||
this.$nextTick(() => {
|
||||
$('#modal-einvoice-info').modal('show');
|
||||
});
|
||||
}
|
||||
}
|
||||
else{
|
||||
if( this.company.company_module.e_invoice && (this.company.company_module.tin === null || this.company.company_module.msic_code === null) )
|
||||
{
|
||||
this.$nextTick(() => {
|
||||
$('#modal-einvoice-info').modal('show');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -193,6 +199,11 @@
|
||||
updatedEInvoiceInfo(info){
|
||||
this.$store.dispatch('reloadList', {'name': this.section});
|
||||
},
|
||||
changeOfMindEInvoiceRequest(){
|
||||
this.parameters.company_module_id = this.company.company_module.id;
|
||||
this.parameters.e_invoice_request = false;
|
||||
this.submit((this.route('api.company.einvoice.request.change')), 'post', this.section + 'ChangeOfMind', true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -47,4 +47,5 @@ Route::group(['prefix' => 'company', 'as' => 'company.', 'namespace' => 'Compani
|
||||
Route::get('/e-invoice/info/{id}', [FetchCompanyEInvoiceInfoController::class, 'fetch'])->name('einvoice.info');
|
||||
Route::post('/e-invoice/info/update', [UpdateCompanyEInvoiceInfoController::class, 'updateInfo'])->name('einvoice.info.update');
|
||||
Route::post('/e-invoice/request/update', [UpdateCompanyEInvoiceInfoController::class, 'updateRequest'])->name('einvoice.request.update');
|
||||
Route::post('/e-invoice/request/update/changeofmind', [UpdateCompanyEInvoiceInfoController::class, 'updateChangeOfMindRequest'])->name('einvoice.request.change');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user