mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
E-Invoice - Fix a timeout problem when processing import for E-Invoice
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesKeyValuePair;
|
||||
use App\Classes\Modules\Accounts\Services\UpdatesKeyValuePair;
|
||||
use App\Classes\Modules\Bookings\Processors\RegenerateInvoiceBookingProcessor;
|
||||
use App\Classes\ValueObjects\Constants\KVPKey;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Models\Booking;
|
||||
use App\Models\KeyValuePair;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
class ProcessPaymentReportV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var object */
|
||||
private $details;
|
||||
|
||||
/**
|
||||
* ProcessPaymentReportV2CommandJob constructor.
|
||||
* @param object $details
|
||||
*/
|
||||
public function __construct(object $details)
|
||||
{
|
||||
$this->details = $details;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Processing single record from 01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT] Import.');
|
||||
$start = new Carbon();
|
||||
|
||||
$docNo = $this->details[0] ?? null;
|
||||
$docDate = $this->details[1] ?? null;
|
||||
$debtorCode = $this->details[2] ?? null;
|
||||
$description = $this->details[3] ?? null;
|
||||
$paymentMethod = $this->details[4] ?? null;
|
||||
$paymentAmt = $this->details[5] ?? null;
|
||||
$knockOffDocNo = $this->details[6] ?? null;
|
||||
|
||||
Log::info("Row Payment Details:", [
|
||||
'DocNo' => $docNo,
|
||||
'DocDate' => $docDate,
|
||||
'DebtorCode' => $debtorCode,
|
||||
'Description' => $description,
|
||||
'PaymentMethod' => $paymentMethod,
|
||||
'PaymentAmt' => $paymentAmt,
|
||||
'KnockOffDocNo' => $knockOffDocNo,
|
||||
]);
|
||||
|
||||
if($knockOffDocNo){
|
||||
$kvp = KeyValuePair::where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->where('value', $knockOffDocNo)->first();
|
||||
if($kvp){
|
||||
$booking = $kvp->owner;
|
||||
if($booking){
|
||||
if($docNo != "" && $docNo != "<<New>>"){
|
||||
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCNO_OFFICIAL_RECEIPT, $docNo);
|
||||
}
|
||||
// if($eInvoiceValidationLink){
|
||||
// $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Processing single record from 01R - RECEIVE PAYMENT (FULL PAYMENT) [AR RECEIVE PAYMENT] Import. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
|
||||
|
||||
private function updateOrCreateKeyValuePair($booking, $key, $value)
|
||||
{
|
||||
$keyValuePairObject = new KeyValuePairObject($key, $value);
|
||||
$metadata = $booking->attributesKVP()->where('key', $key)->first();
|
||||
|
||||
if ($metadata) {
|
||||
(App()->make(UpdatesKeyValuePair::class))->execute($metadata, $keyValuePairObject);
|
||||
} else {
|
||||
(App()->make(CreatesKeyValuePair::class))->execute($booking, $keyValuePairObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\Imports\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Jobs\Commands\V2\ProcessPaymentReportV2CommandJob;
|
||||
use App\Classes\Jobs\Commands\V2\ProcessSalesInvoiceReportV2CommandJob;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesKeyValuePair;
|
||||
use App\Classes\Modules\Accounts\Services\UpdatesKeyValuePair;
|
||||
@@ -221,24 +222,25 @@ class ImportExcelLogic extends AbstractControllerLogic
|
||||
|
||||
if($knockOffDocNo)
|
||||
{
|
||||
$kvp = KeyValuePair::where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->where('value', $knockOffDocNo)->first();
|
||||
if($kvp){
|
||||
$booking = $kvp->owner;
|
||||
if($booking){
|
||||
if($docNo != "" && $docNo != "<<New>>"){
|
||||
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCNO_OFFICIAL_RECEIPT, $docNo);
|
||||
}
|
||||
// if($eInvoiceValidationLink){
|
||||
// $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink);
|
||||
// }
|
||||
}
|
||||
else{
|
||||
$unprocessedKnockOffs[] = $knockOffDocNo;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$unprocessedKnockOffs[] = $knockOffDocNo;
|
||||
}
|
||||
ProcessPaymentReportV2CommandJob::dispatch($details);
|
||||
// $kvp = KeyValuePair::where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->where('value', $knockOffDocNo)->first();
|
||||
// if($kvp){
|
||||
// $booking = $kvp->owner;
|
||||
// if($booking){
|
||||
// if($docNo != "" && $docNo != "<<New>>"){
|
||||
// $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCNO_OFFICIAL_RECEIPT, $docNo);
|
||||
// }
|
||||
// // if($eInvoiceValidationLink){
|
||||
// // $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink);
|
||||
// // }
|
||||
// }
|
||||
// else{
|
||||
// $unprocessedKnockOffs[] = $knockOffDocNo;
|
||||
// }
|
||||
// }
|
||||
// else{
|
||||
// $unprocessedKnockOffs[] = $knockOffDocNo;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user