Merge branch 'dillon/122-1688-po-automation-project-p' into vapor/development

This commit is contained in:
Dillon Ngo
2026-01-14 22:47:43 +08:00
8 changed files with 94 additions and 7 deletions
@@ -73,7 +73,7 @@ class ETLPurchaseOrderTransactionV2CommandJob implements ShouldQueue
'file_count' => count($this->files),
]);
(App()->make(ETLPDFPurchaseOrderClaudeProcessor::class))->execute($this->files, $this->bookingId, $this->batchIndex !== 1);
(App()->make(ETLPDFPurchaseOrderClaudeProcessor::class))->execute($this->files, $this->bookingId, $this->batchIndex !== 1, $this->isLast);
$end = new Carbon();
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
@@ -166,7 +166,7 @@ class ImportPurchaseOrderTransactionLogic extends AbstractControllerLogic
if ($totalSize > $maxSize) {
// ETLPurchaseOrderTransactionV2CommandJob::dispatch($base64FilesEN, $request->route('id'));
$this->runAsJob($base64FilesEN, $request->route('id'));
$this->notificationMessage = "Please refresh page in a few minutes";
$this->notificationMessage = "Please dont refresh the page. The page will automatically update when the process is done.";
return $this->response([]);
}
else{
@@ -14,6 +14,7 @@ use App\Classes\ValueObjects\Constants\KVPKey;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\PaymentMethodType;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Events\ETLPurchaseOrderTransactionCompleteEvent;
use App\Models\KeyValuePair;
use App\Models\Booking;
use Illuminate\Support\Facades\Log;
@@ -47,7 +48,7 @@ class ETLPDFPurchaseOrderClaudeProcessor
* @param bool $append
* @return array|null
*/
public function execute(array $files, ?int $bookingId = null, bool $append = false): ?array
public function execute(array $files, ?int $bookingId = null, bool $append = false, bool $broadcast = false): ?array
{
$tempPaths = [];
@@ -146,6 +147,10 @@ class ETLPDFPurchaseOrderClaudeProcessor
);
$this->createPurchaseOrderTransactionProcessor->execute($booking, $object, $append);
if($broadcast){
event(new ETLPurchaseOrderTransactionCompleteEvent(true, $bookingId));
}
}
return $data;
@@ -0,0 +1,44 @@
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class ETLPurchaseOrderTransactionCompleteEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* True/false to indicate update status
*/
public $update;
/**
* The booking ID this event is for
*/
public $bookingId;
/**
* @param bool $update
* @param int $bookingId
*/
public function __construct($update, $bookingId)
{
$this->update = $update; // true or false
$this->bookingId = $bookingId; // unique booking identifier
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new Channel('admin.pdf.1688.processing.' . $this->bookingId);
}
}
+1
View File
@@ -29,6 +29,7 @@
"maatwebsite/excel": "^3.1",
"maxbanton/cwh": "^2.0",
"mpdf/mpdf": "^8.1",
"pusher/pusher-php-server": "^7.2",
"rinvex/countries": "^6.1",
"rspective/voucherify": " v2.0.*",
"smalot/pdfparser": "^2.2",
+2
View File
@@ -22,10 +22,12 @@
"jquery": "^3.7.0",
"jquery.scrollbar": "^0.2.11",
"jwt-decode": "^3.1.2",
"laravel-echo": "^1.19.0",
"laravel-vapor": "^0.6.0",
"noty": "^3.2.0-beta",
"perfect-scrollbar": "^1.5.0",
"popper.js": "^1.12",
"pusher-js": "^8.4.0",
"sass-loader": "10.1.0",
"select2": "^4.0.6-rc.1",
"v-money": "^0.8.1",
+13
View File
@@ -32,6 +32,19 @@ import Vapor from 'laravel-vapor';
// Vapor.withBaseAssetUrl(import.meta.env.VITE_VAPOR_ASSET_URL);
window.Vapor = Vapor;
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';
window.Pusher = Pusher;
window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
cluster: process.env.MIX_PUSHER_APP_CLUSTER,
forceTLS: true
});
/** Application Injections */
Vue.use(vuelidate);
Vue.use(VueTheMask);
@@ -102,11 +102,33 @@
}
return str;
},
resetFileInput() {
this.parameters.files = [];
this.$v.parameters.files.$reset();
this.fileInputKey++;
},
onComplete(data) {
this.$store.dispatch('reloadList', {'name': 'bookingDetailSection'});
this.fileInputKey += 1;
const bookingChannel = `admin.pdf.1688.processing.${data.bookingId}`;
window.Echo.leave(bookingChannel);
},
successHandler(response, section){
if(this.section + 'PDFImport' === section){
this.$store.dispatch('reloadList', {'name': 'bookingDetailSection'});
this.isImporting = false;
this.fileInputKey += 1;
if (Array.isArray(response.payload) && response.payload.length === 0) {
const bookingChannel = `admin.pdf.1688.processing.${this.bookingId}`;
window.Echo.channel(bookingChannel)
.listen('ETLPurchaseOrderTransactionCompleteEvent', this.onComplete);
this.isImporting = false;
this.resetFileInput();
}
else{
this.$store.dispatch('reloadList', {'name': 'bookingDetailSection'});
this.isImporting = false;
this.fileInputKey += 1;
}
}
else if(this.section + 'PDFExport' === section){
try {
@@ -143,7 +165,7 @@
errorHandler(response, statusCode, section){
this.isExporting = false;
this.isImporting = false;
}
},
},
mixins: [formHandler]
}