Compare commits

...

54 Commits

Author SHA1 Message Date
JiaSheng c55a8e7af9 fix account statement mapping issue 2023-09-14 14:59:02 +08:00
Omair Saleh fbf097eb62 fix wallet transaction history and top up list bug 2023-09-13 14:22:36 +08:00
Omair Saleh 30c2673fdf fix wallet transaction history and top up list bug 2023-09-13 13:59:49 +08:00
Omair Saleh fd3709e103 fix wallet transaction history and top up list bug 2023-09-13 13:59:08 +08:00
Omair Saleh 08473d85ab fix wallet transaction history and top up list bug 2023-09-13 13:58:29 +08:00
Omair Saleh 489974ca5a fix wallet transaction history and top up list bug 2023-09-13 13:55:21 +08:00
Omair Saleh 6a6a0f0ee7 fix wallet transaction history and top up list bug 2023-09-13 13:46:20 +08:00
Omair Saleh 402f64364b export arrived parcel improvements 2023-09-01 05:27:13 +08:00
Omair Saleh a3bff9d079 export arrived parcel improvements 2023-09-01 05:26:32 +08:00
Omair Saleh 2a7a448059 export arrived parcel improvements 2023-09-01 05:25:41 +08:00
Omair Saleh 7d855064da export arrived parcel improvements 2023-09-01 05:24:47 +08:00
Omair Saleh efc0a3b94e export arrived parcel improvements 2023-09-01 05:24:05 +08:00
Omair Saleh 01654ee0d3 export arrived parcel improvements 2023-09-01 05:22:58 +08:00
Omair Saleh 23c2f92e6d export arrived parcel improvements 2023-09-01 05:21:32 +08:00
Omair Saleh 3945c47f52 export arrived parcel improvements 2023-09-01 05:20:36 +08:00
Omair Saleh 51ab6ce48b export arrived parcel improvements 2023-09-01 05:19:33 +08:00
Omair Saleh ca8140a1ba export arrived parcel improvements 2023-09-01 05:17:35 +08:00
Omair Saleh a84580c1dd export arrived parcel improvements 2023-09-01 05:14:07 +08:00
Omair Saleh 63b212a66c export arrived parcel improvements 2023-09-01 05:13:21 +08:00
Omair Saleh 7979d89997 export arrived parcel improvements 2023-09-01 05:00:36 +08:00
Omair Saleh bc603fc125 Merge remote-tracking branch 'origin/master' 2023-09-01 04:54:17 +08:00
Omair Saleh b55fd49830 export arrived parcel improvements 2023-09-01 04:54:00 +08:00
edmondlang 60ceac645f fix bug invoices/approve 2023-08-24 14:36:47 +08:00
Dillon Ngo 90c599049b Merge branch 'dillon/42-crm-code-sync-with-exchange-b' into 'master'
CRM invoice decimal problem fix + fetch invoice fail fix + debug log update

See merge request CIEFWorldwideSdnBhd/shipping-portal!170
2023-08-23 20:59:33 +00:00
Dillon f538fb7f2f Post Deployment monitoring: CRM invoice decimal problem fix + fetch invoice fail fix + debug log update 2023-08-24 04:52:34 +08:00
Omair Saleh a45105f5ae fix yd api 2023-08-23 14:08:47 +08:00
Omair Saleh 2f1a8ee648 fix yd api 2023-08-23 14:06:43 +08:00
Omair Saleh aacf4ea53d fix yd api 2023-08-23 14:05:15 +08:00
Omair Saleh 1fa2b60871 fix duplicate packages 2023-08-22 15:40:44 +08:00
Omair Saleh 203dc0c230 fix duplicate packages 2023-08-22 15:39:42 +08:00
Omair Saleh fcc4da1a56 fix duplicate packages 2023-08-22 15:24:38 +08:00
Omair Saleh c5a49bbc44 fix duplicate packages 2023-08-22 15:21:47 +08:00
Omair Saleh f8131b3a1e fix duplicate packages 2023-08-22 15:20:06 +08:00
Omair Saleh 336cc0b37f Merge remote-tracking branch 'origin/master' 2023-08-22 15:05:58 +08:00
Omair Saleh 42f096b09c fix duplicate packages 2023-08-22 15:01:44 +08:00
Dillon Ngo 614167cac5 Merge branch 'dillon/42-crm-code-sync-with-exchange-a' into 'master'
Update condition to update CRM task status

See merge request CIEFWorldwideSdnBhd/shipping-portal!169
2023-08-20 08:02:07 +00:00
Dillon e5421f8810 Update condition to update CRM task status 2023-08-20 15:57:51 +08:00
Dillon Ngo 8dc84baee0 Merge branch 'dillon/42-crm-code-sync-with-exchange-a' into 'master'
CRM Integration (Part 2 of code sync with Exchange-2.0)

See merge request CIEFWorldwideSdnBhd/shipping-portal!168
2023-08-19 21:43:07 +00:00
Dillon a413533975 CRM Integration (Part 2 of code sync with Exchange-2.0) 2023-08-20 05:30:54 +08:00
Dillon Ngo 0a98f8a8c6 Merge branch 'dillon/42-crm-code-sync-with-exchange-a' into 'master'
Quick fix

See merge request CIEFWorldwideSdnBhd/shipping-portal!167
2023-08-18 04:14:46 +00:00
Dillon aceed5f754 Quick fix 2023-08-18 12:13:47 +08:00
Dillon Ngo 761d191c1d Merge branch 'dillon/42-crm-code-sync-with-exchange' into 'master'
Exchange-2.0 code sync for crm changes

See merge request CIEFWorldwideSdnBhd/shipping-portal!166
2023-08-17 13:58:09 +00:00
Omair Saleh f279d39ddb fix yd bug 2023-08-15 13:50:22 +08:00
Omair Saleh 2e1e8875b4 fix yd bug 2023-08-15 13:47:53 +08:00
Omair Saleh c30c5a36f2 fix yd bug 2023-08-15 13:46:24 +08:00
Omair Saleh 7d3901ee48 fix yd bug 2023-08-15 13:41:00 +08:00
Omair Saleh 463398945f fix yd bug 2023-08-15 13:40:18 +08:00
Omair Saleh d619862e63 fix yd bug 2023-08-15 13:38:18 +08:00
Omair Saleh 9665a0e242 fix yd bug 2023-08-14 15:43:02 +08:00
Omair Saleh 7ed6c11f37 fix yd bug 2023-08-14 15:40:40 +08:00
Omair Saleh 3eaee0d122 fix yd bug 2023-08-14 15:35:47 +08:00
Omair Saleh b7816873fe fix yd bug 2023-08-14 15:30:05 +08:00
Omair Saleh 8809caa046 Merge remote-tracking branch 'origin/master' 2023-08-14 14:55:35 +08:00
Omair Saleh b8b6910a45 fix yd quantity is not a number bug 2023-08-14 14:55:21 +08:00
41 changed files with 525 additions and 160 deletions
@@ -0,0 +1,20 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class PaymentMethodNotIn implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return Builder|mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->whereNotIn('payment_method', $value);
}
}
@@ -15,9 +15,17 @@ use App\Classes\ValueObjects\Constants\OrderRoleTypes;
class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, FromQuery
{
use Exportable;
private $start_date;
private $end_date;
public function __construct($start_date = null, $end_date = null)
{
$this->start_date = $start_date;
$this->end_date = $end_date;
}
public function headings(): array
{
return [
@@ -26,38 +34,49 @@ class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping,
'Warehouse',
'Cbm',
'Description',
'quantity',
'Quantity',
'Received Date',
'Recorded On',
'Days to Record',
'Remarks'
];
}
/**
* @return \Illuminate\Support\Collection|mixed
*/
public function query()
{
return PackingList::where('type', '=', 1)->where('status', '=', 2)->where('owner_type', Order::class);
$query = PackingList::with([
'owner.companyModule.inviters',
'owner.orderRoles',
'packages',
'transports'
])
->where('type', '=', 1)
->where('status', '=', 2)
->where('owner_type', Order::class);
if (!is_null($this->start_date) && !is_null($this->end_date)) {
$query->whereHas('transports', function ($q) {
$q->whereBetween('drop_date', [
Carbon::parse($this->start_date)->startOfDay(),
Carbon::parse($this->end_date)->endOfDay()
]);
});
}
return $query;
}
/**
* @param $packingList
* @return array
*/
public function map($packingList): array
{
$order = $packingList->owner;
$connection = $order->companyModule()->first()->inviters()->withPivot('invitee_reference')->first();
$marking = $connection ? $connection->pivot->invitee_reference:'';
$warehouse = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee;
$cbm = $packingList->packages->sum(function($package){
return (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
$marking = $order->companyModule->getMarking();
$warehouse = $order->orderRoles->firstWhere('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->appointee;
$cbm = $packingList->packages->sum(function ($package) {
return (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
});
$arrival_date = $packingList->transports()->first()->drop_date->format('d-m-Y');
$arrival_date = $packingList->transports->first()->drop_date->format('d-m-Y');
$recorded_on = $packingList->created_at->format('d-m-Y');
$days_to_record = Carbon::parse($arrival_date)->diffInDays(Carbon::parse($recorded_on));
return [
$packingList->owner->reference,
@@ -67,7 +86,9 @@ class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping,
$packingList->packages->implode('description', ', '),
$packingList->packages->sum('quantity'),
$arrival_date,
$recorded_on,
$days_to_record,
''
];
}
}
}
@@ -32,6 +32,7 @@ class FetchesDataFromYDPortal
$content = str_replace("\r",'', $content);
$content = str_replace("\n",'', $content);
$content = str_replace("\t",'', $content);
$content = str_replace('"data":}', '"data":""}', $content);
return json_decode($content);
}
}
@@ -11,6 +11,7 @@ use App\Classes\Modules\PackingLists\Standards\Rules\CanCreatePackingList;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
use App\Classes\ValueObjects\Constants\PackingListType;
use App\Classes\ValueObjects\Constants\PerfexCRMTasksYDStages;
use App\Classes\ValueObjects\Constants\WarehouseReferences;
use App\Models\Order;
use App\Models\PackingList;
@@ -65,7 +66,7 @@ class CreatePackingListProcessor
$this->createsPackingList->execute($object, $packingList);
if(config('perfexcrm.is_enabled') == 'true'){
$this->packingListToPerfexCRMProcessor->execute($packingList);
$this->packingListToPerfexCRMProcessor->execute($packingList, PerfexCRMTasksYDStages::DEFAULT);
}
return $packingList;
@@ -26,6 +26,7 @@ use App\Classes\Modules\Unity\Processors\AssignContractEntityProcessor;
use App\Classes\Modules\Unity\Processors\CreateContractEntityProcessor;
use App\Classes\Modules\Unity\Services\CreatesContract;
use App\Classes\Modules\Unity\Services\UpdatesContractObligation;
use App\Classes\Modules\PerfexCRM\Processors\PackingListToPerfexCRMProcessor;
use App\Classes\Notifications\ShipmentDepartureEmail;
use App\Classes\Notifications\ShipmentRescheduleEmail;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
@@ -35,6 +36,7 @@ use App\Classes\ValueObjects\Constants\PackageType;
use App\Classes\ValueObjects\Constants\PackingListType;
use App\Classes\ValueObjects\Constants\TransportType;
use App\Classes\ValueObjects\Constants\WarehouseReferences;
use App\Classes\ValueObjects\Constants\PerfexCRMTasksYDStages;
use App\Models\Container;
use App\Models\Order;
use App\Models\PackingList;
@@ -62,20 +64,25 @@ class FetchContainersFromYdPortalProcessor
/** @var CreateContainerProcessor */
private $createContainerProcessor;
/** @var PackingListToPerfexCRMProcessor */
private $packingListToPerfexCRMProcessor;
/**
* @param FetchesDataFromYDPortal $fetchesDataFRomYDPortal
* @param CreatesTransport $createsTransport
* @param CreatesSchedule $createsSchedule
* @param FetchesContainer $fetchesContainer
* @param CreateContainerProcessor $createContainerProcessor
* @param PackingListToPerfexCRMProcessor $packingListToPerfexCRMProcessor
*/
public function __construct(FetchesDataFromYDPortal $fetchesDataFRomYDPortal, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule, FetchesContainer $fetchesContainer, CreateContainerProcessor $createContainerProcessor)
public function __construct(FetchesDataFromYDPortal $fetchesDataFRomYDPortal, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule, FetchesContainer $fetchesContainer, CreateContainerProcessor $createContainerProcessor, PackingListToPerfexCRMProcessor $packingListToPerfexCRMProcessor)
{
$this->fetchesDataFRomYDPortal = $fetchesDataFRomYDPortal;
$this->createsTransport = $createsTransport;
$this->createsSchedule = $createsSchedule;
$this->fetchesContainer = $fetchesContainer;
$this->createContainerProcessor = $createContainerProcessor;
$this->packingListToPerfexCRMProcessor = $packingListToPerfexCRMProcessor;
}
@@ -87,7 +94,8 @@ class FetchContainersFromYdPortalProcessor
*/
public function execute()
{
$packingLists = PackingList::where('type', PackingListType::SHIPPING_PACKING_LIST)->doesntHave('containers')->get();
$maxFetchTime = Carbon::now()->subMonths(4);
$packingLists = PackingList::where('type', PackingListType::SHIPPING_PACKING_LIST)->whereDate('created_at', '>=', $maxFetchTime)->doesntHave('containers')->get();
foreach ($packingLists as $packingList) {
$time_start = microtime(true);
@@ -137,6 +145,10 @@ class FetchContainersFromYdPortalProcessor
$container->packingLists()->detach($packingList);
$container->packingLists()->attach($packingList);
if(config('perfexcrm.is_enabled') == 'true'){
$this->packingListToPerfexCRMProcessor->execute($packingList, PerfexCRMTasksYDStages::LOAD_CONTAINER);
}
$transport = $container->transports()->first();
if(!$transport){
@@ -8,9 +8,11 @@ use App\Classes\Modules\Orders\Services\FetchesDataFromYDPortal;
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
use App\Classes\Modules\Unity\Services\UpdatesContractObligation;
use App\Classes\Modules\PerfexCRM\Processors\PackingListToPerfexCRMProcessor;
use App\Classes\Notifications\ShipmentRescheduleEmail;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
use App\Classes\ValueObjects\Constants\PerfexCRMTasksYDStages;
use App\Models\Container;
use App\Models\Order;
use App\Models\PackingList;
@@ -27,16 +29,21 @@ class FetchContainersUpdatesFromYdPortalProcessor
/** @var CreatesSchedule */
private $createsSchedule;
/** @var PackingListToPerfexCRMProcessor */
private $packingListToPerfexCRMProcessor;
/**
* @param FetchesDataFromYDPortal $fetchesDataFRomYDPortal
* @param UpdatesContractObligation $updatesContractObligations
* @param CreatesSchedule $createsSchedule
* @param PackingListToPerfexCRMProcessor $packingListToPerfexCRMProcessor
*/
public function __construct(FetchesDataFromYDPortal $fetchesDataFRomYDPortal, UpdatesContractObligation $updatesContractObligations, CreatesSchedule $createsSchedule)
public function __construct(FetchesDataFromYDPortal $fetchesDataFRomYDPortal, UpdatesContractObligation $updatesContractObligations, CreatesSchedule $createsSchedule, PackingListToPerfexCRMProcessor $packingListToPerfexCRMProcessor)
{
$this->fetchesDataFRomYDPortal = $fetchesDataFRomYDPortal;
$this->updatesContractObligations = $updatesContractObligations;
$this->createsSchedule = $createsSchedule;
$this->packingListToPerfexCRMProcessor = $packingListToPerfexCRMProcessor;
}
@@ -65,10 +72,14 @@ class FetchContainersUpdatesFromYdPortalProcessor
$unstuffingDate = null;
$delayDate = null;
$checkShipSailDate = null;
$checkShipArrivalDate = null;
foreach (array_reverse($rows->data) as $trackingRow) {
$rescheduleETD = strpos($trackingRow->remark, '开') || strpos($trackingRow->remark, '到港');
$rescheduleETA = strpos($trackingRow->remark, '到港');
if (($rescheduleETD !== false || $rescheduleETA !== false) && strpos($trackingRow->tracking, '货物装柜完成。') === false) {
preg_match_all('/([0-9]+.{3})/', $trackingRow->remark, $matches);
$dates = collect();
@@ -97,10 +108,12 @@ class FetchContainersUpdatesFromYdPortalProcessor
if ($trackingRow->tracking === '到港') {
$delayDate = Carbon::parse($trackingRow->trackingtime);
$checkShipArrivalDate = Carbon::parse($trackingRow->trackingtime);
}
if ($trackingRow->tracking === '已开船') {
$delayDate = Carbon::parse($trackingRow->trackingtime)->addDays('5');
$checkShipSailDate = Carbon::parse($trackingRow->trackingtime);
}
if ($trackingRow->tracking === '货物已进目的港仓库') {
@@ -110,7 +123,30 @@ class FetchContainersUpdatesFromYdPortalProcessor
dump($delayDate, $unstuffingDate);
if($checkShipSailDate){
//check if ship has sailed
if($checkShipSailDate->isPast()){
foreach ($container->packingLists as $packingList){
if(config('perfexcrm.is_enabled') == 'true'){
$this->packingListToPerfexCRMProcessor->execute($packingList, PerfexCRMTasksYDStages::SHIP_SAILED);
}
}
}
}
if($checkShipArrivalDate){
//check if ship has arrived at destination
if($checkShipArrivalDate->isPast()){
foreach ($container->packingLists as $packingList){
if(config('perfexcrm.is_enabled') == 'true'){
$this->packingListToPerfexCRMProcessor->execute($packingList, PerfexCRMTasksYDStages::SHIP_ARRIVED);
}
}
}
}
if($delayDate){
$delayDate = $delayDate->addDays(2);
$transport = $container->transports()->first();
@@ -126,7 +162,6 @@ class FetchContainersUpdatesFromYdPortalProcessor
}
}
}
}
if($unstuffingDate){
@@ -148,7 +183,9 @@ class FetchContainersUpdatesFromYdPortalProcessor
$this->updatesContractObligations->execute($signature, $step->obligation_hash_id);
$step->update(['status' => ApprovalStatus::COMPLETED]);
}
if(config('perfexcrm.is_enabled') == 'true'){
$this->packingListToPerfexCRMProcessor->execute($packingList, PerfexCRMTasksYDStages::UNSTUFFING);
}
}
}
@@ -8,6 +8,8 @@ use App\Classes\Modules\Schedules\Services\CreatesSchedule;
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
use App\Classes\Modules\Transports\Services\CreatesTransport;
use App\Classes\Modules\Unity\Services\UpdatesContractObligation;
use App\Classes\Modules\PerfexCRM\Processors\PackingListToPerfexCRMProcessor;
use App\Classes\ValueObjects\Constants\PerfexCRMTasksYDStages;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
use App\Classes\ValueObjects\Constants\PackingListType;
@@ -34,16 +36,21 @@ class FetchDeliveryUpdatesFromYdPortalProcessor
/** @var CreatesSchedule */
private $createsSchedule;
/** @var PackingListToPerfexCRMProcessor */
private $packingListToPerfexCRMProcessor;
/**
* @param UpdatesContractObligation $updatesContractObligations
* @param CreatesTransport $createsTransport
* @param CreatesSchedule $createsSchedule
* @param PackingListToPerfexCRMProcessor $packingListToPerfexCRMProcessor
*/
public function __construct(UpdatesContractObligation $updatesContractObligations, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule)
public function __construct(UpdatesContractObligation $updatesContractObligations, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule, PackingListToPerfexCRMProcessor $packingListToPerfexCRMProcessor)
{
$this->updatesContractObligations = $updatesContractObligations;
$this->createsTransport = $createsTransport;
$this->createsSchedule = $createsSchedule;
$this->packingListToPerfexCRMProcessor = $packingListToPerfexCRMProcessor;
}
@@ -99,6 +106,9 @@ class FetchDeliveryUpdatesFromYdPortalProcessor
$this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id);
$deliveryStep->update(['status' => ApprovalStatus::COMPLETED]);
if(config('perfexcrm.is_enabled') == 'true'){
$this->packingListToPerfexCRMProcessor->execute($packingList, PerfexCRMTasksYDStages::DELIVERY);
}
}
$time_end = microtime(true);
@@ -121,6 +121,7 @@ class FetchPackingListsFromYdPortalProcessor
}
$endDate = Carbon::today()->subDays($x - 1);
$orderRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/GetOrderList.ashx', 'GET', [
'begintime' => $startDate->timestamp,
'endtime' => $endDate->timestamp,
@@ -131,6 +132,7 @@ class FetchPackingListsFromYdPortalProcessor
if(!$rows->data) continue;
foreach($rows->data as $row){
if(!is_numeric($row->goodcount)) continue;
$time_start = microtime(true);
@@ -151,7 +151,8 @@ class CreatePerfexCRMInvoiceProcessor
array_push($invoiceItems, $invoiceSingleItem);
}
$total = $transaction->amount;
// $total = $transaction->amount;
$total = number_format($transaction->amount, 2,'.','') * 1;
//This setting is similar to Setup > Leads > Sources, Setup > Leads > Statuses
//Can be found at Finance > Payment Modes
@@ -46,7 +46,7 @@ class FetchPerfexCRMInvoiceProcessor
$customer = $this->fetchesPerfexCRMCustomer->execute($fetchPerfexCRMInvoiceObject->getEmail());
$transaction = $fetchPerfexCRMInvoiceObject->getTransaction();
$number = $transaction->bill_no;
$number = $transaction->owner->bill_no;
$prefix = "INV-";
//This will remove the prefix if prefix already exist in the string
@@ -7,6 +7,8 @@ use App\Classes\Jobs\CreatePerfexCRMSingleTask;
use App\Classes\ValueObjects\Constants\PerfexCRMTaskPriority;
use App\Classes\ValueObjects\Constants\PerfexCRMTasks;
use App\Models\Company;
use Illuminate\Support\Facades\Log;
class NewLeadTaskToPerfexCRMProcessor
{
@@ -17,26 +19,32 @@ class NewLeadTaskToPerfexCRMProcessor
*/
public function execute(Company $company)
{
$companyModule = $company->companyModules()->first();
$employee = $companyModule->employees()->first();
$contactEmail = $employee->email;
try {
$companyModule = $company->companyModules()->first();
$employee = $companyModule->employees()->first();
$contactEmail = $employee->email;
$createTaskPerfexCRMObject = new CreateTaskPerfexCRMObject(
$contactEmail,
PerfexCRMTasks::TASK_IDENTIFICATION_1['name'],
PerfexCRMTasks::TASK_IDENTIFICATION_1['description'],
"",
"",
"",
"",
"",
PerfexCRMTasks::TASK_IDENTIFICATION_1['status'],
PerfexCRMTasks::TASK_IDENTIFICATION_1['department'],
PerfexCRMTaskPriority::DEFAULT,
"0"
);
$createTaskPerfexCRMObject = new CreateTaskPerfexCRMObject(
$contactEmail,
PerfexCRMTasks::TASK_IDENTIFICATION_1['name'],
PerfexCRMTasks::TASK_IDENTIFICATION_1['description'],
"",
"",
"",
"",
"",
PerfexCRMTasks::TASK_IDENTIFICATION_1['status'],
PerfexCRMTasks::TASK_IDENTIFICATION_1['department'],
PerfexCRMTaskPriority::DEFAULT,
"0",
0
);
CreatePerfexCRMSingleTask::dispatch($createTaskPerfexCRMObject);
CreatePerfexCRMSingleTask::dispatch($createTaskPerfexCRMObject);
} catch (\Exception $exception){
Log::error($exception);
}
return true;
}
@@ -4,10 +4,11 @@ namespace App\Classes\Modules\PerfexCRM\Processors;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
use App\Classes\ValueObjects\Constants\PerfexCRMTasks;
use App\Classes\Jobs\UpdatePerfexCRM;
use App\Classes\Jobs\UpdatePerfexCRMPrelude;
use App\Models\PackingList;
use App\Classes\ValueObjects\Constants\PerfexCRMProjectStatus;
use App\Classes\ValueObjects\Constants\PerfexCRMTasksYDStages;
use App\Classes\ValueObjects\Constants\PerfexCRMTaskStatus;
use Illuminate\Support\Facades\Log;
class PackingListToPerfexCRMProcessor
@@ -17,45 +18,146 @@ class PackingListToPerfexCRMProcessor
* @return bool
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(PackingList $packingList): bool
public function execute(PackingList $packingList, int $stage = PerfexCRMTasksYDStages::DEFAULT): bool
{
try {
if($packingList->owner instanceof \App\Models\Order) {
$order = $packingList->owner;
$companyModule = $order->companyModule()->first();
$connection = $companyModule->inviters()->withPivot('invitee_reference')->first();
$companyName = $companyModule->name;
$companyReference = $connection ? $connection->pivot->invitee_reference:'';
$employee = $companyModule->employees()->first();
$contactEmail = $employee->email;
$contactName = $employee->name;
$orderReference = $packingList->owner->reference;
$packingListReference = $packingList->reference;
$projectName = 'IZYIM | X1 Shipping | '.$orderReference.' | '.$packingListReference;
$info = $this->extractInfo($packingList);
$tasks = $this->defineTasks($stage);
$updatePerfexCRMObject = new UpdatePerfexCRMObject(
$companyName,
$companyReference,
$contactName,
$contactEmail,
"",
$projectName,
$info['companyName'],
$info['companyReference'],
$info['contactName'],
$info['contactEmail'],
$info['bookingMarking'], //For Exchange-2.0
$info['projectName'],
PerfexCRMProjectStatus::NOT_STARTED,
0,
[],
[
PerfexCRMTasks::TASK_LOADED_CONTAINER_1,
PerfexCRMTasks::TASK_LOADED_CONTAINER_2,
]
$tasks
);
UpdatePerfexCRMPrelude::dispatch($packingList, null, $updatePerfexCRMObject, false);
$this->dispatchUpdateJob($packingList, $updatePerfexCRMObject);
}
} catch (\Exception $exception){
Log::error(json_encode('PackingListToPerfexCRMProcessor debug:'));
Log::error(json_encode($packingList));
Log::error('PackingListToPerfexCRMProcessor: ' . json_encode($packingList));
Log::error($exception);
}
return true;
}
//Level 1
private function extractInfo(PackingList $packingList): array
{
$order = $packingList->owner;
$companyModule = $order->companyModule()->first();
$employee = $companyModule->employees()->first();
$info = [];
$info['companyName'] = $companyModule->name;
$info['companyReference'] = $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
$info['contactName'] = $employee->name;
$info['contactEmail'] = $employee->email;
$info['bookingMarking'] = ''; //For Exchange-2.0
$info['projectName'] = 'IZYIM | X1 Shipping | '.$packingList->owner->reference.' | '.$packingList->reference;
return $info;
}
private function defineTasks(int $stage): array
{
$tasks = [];
if ($stage === PerfexCRMTasksYDStages::DEFAULT) {
$tasks = $this->defineAllYDStagesTasks();
}
else if ($stage === PerfexCRMTasksYDStages::LOAD_CONTAINER) {
$tasks = $this->updateLoadContainerTasks();
}
else if ($stage === PerfexCRMTasksYDStages::SHIP_SAILED) {
$tasks = $this->updateShipSailedTasks();
}
else if ($stage === PerfexCRMTasksYDStages::SHIP_ARRIVED) {
$tasks = $this->updateShipArrivedTasks();
}
else if ($stage === PerfexCRMTasksYDStages::UNSTUFFING) {
$tasks = $this->updateUnstuffingTasks();
}
else if ($stage === PerfexCRMTasksYDStages::DELIVERY) {
$tasks = $this->updateDeliveryTasks();
}
return $tasks;
}
private function dispatchUpdateJob(PackingList $packingList, UpdatePerfexCRMObject $updatePerfexCRMObject)
{
UpdatePerfexCRMPrelude::dispatch($packingList, null, $updatePerfexCRMObject, false);
}
//Level Others: Nested
private function defineAllYDStagesTasks(): array
{
$tasks = [
PerfexCRMTasks::TASK_YD_LOADED_CONTAINER_1,
PerfexCRMTasks::TASK_YD_LOADED_CONTAINER_2,
PerfexCRMTasks::TASK_YD_LOADED_CONTAINER_3,
PerfexCRMTasks::TASK_YD_SHIPPING_1,
PerfexCRMTasks::TASK_YD_UNSTUFFING_1,
PerfexCRMTasks::TASK_YD_DELIVERY_1,
];
return $tasks;
}
private function updateLoadContainerTasks(): array
{
$tasks = [];
$tasks = $this->completeTask(null, PerfexCRMTasks::TASK_YD_LOADED_CONTAINER_3);
return $tasks;
}
private function updateShipSailedTasks(): array
{
$tasks = [];
$tasks = $this->completeTask(PerfexCRMTasks::TASK_YD_LOADED_CONTAINER_3, PerfexCRMTasks::TASK_YD_SHIPPING_1);
return $tasks;
}
private function updateShipArrivedTasks(): array
{
$tasks = [];
$tasks = $this->completeTask(PerfexCRMTasks::TASK_YD_SHIPPING_1, PerfexCRMTasks::TASK_YD_UNSTUFFING_1);
return $tasks;
}
private function updateUnstuffingTasks(): array
{
$tasks = [];
$tasks = $this->completeTask(PerfexCRMTasks::TASK_YD_UNSTUFFING_1, PerfexCRMTasks::TASK_YD_DELIVERY_1);
return $tasks;
}
private function updateDeliveryTasks(): array
{
$tasks = [];
$tasks = $this->completeTask(PerfexCRMTasks::TASK_YD_DELIVERY_1, null);
return $tasks;
}
private function completeTask($startTask, $endTask) {
$resultArray = [];
if($startTask){
$startTask['status'] = PerfexCRMTaskStatus::COMPLETED;
array_push($resultArray, $startTask);
}
if($endTask){
$endTask['status'] = PerfexCRMTaskStatus::IN_PROGRESS;
array_push($resultArray, $endTask);
}
return $resultArray;
}
}
@@ -224,8 +224,8 @@ class UpdatePerfexCRMProcessor
$result = $this->fetchesPerfexCRMTask->execute($taskName, $milestoneId, 'project', $projectId, $updatePerfexCRMObject->getInvoiceId());
if(isset($result->payload)){
// && $result->payload[0]['status'] == PerfexCRMTaskStatus::NOT_STARTED //purpose of this checking is just to make sure that only update task at crm when the status is NOT_STARTED, a double check to prevent unintentional update
if($taskStatus != PerfexCRMTaskStatus::NOT_STARTED)
//Check to make sure that task that is already completed do not get updated again
if($taskStatus != PerfexCRMTaskStatus::NOT_STARTED && $result->payload[0]['status'] != PerfexCRMTaskStatus::COMPLETED && $result->payload[0]['status'] != $taskStatus)
{
$task = $result->payload[0];
$result = $this->updatesPerfexCRMTask->execute($task['id'], $task['name'], $task['milestone'], $task['rel_id'], $taskStatus, $task['startdate'], is_null($task['duedate']) ? '': $task['duedate']);
@@ -24,7 +24,7 @@ class ConvertsPerfexCRMLeadToCustomer
return (object) $data;
}else{
Log::error($response);
Log::error('ConvertsPerfexCRMLeadToCustomer: '.$response);
return null;
}
}catch(\Exception $exception){
@@ -27,7 +27,7 @@ class CreatesPerfexCRMCustomer
$data = $response->json();
return (object) $data;
}else{
Log::error($response);
Log::error('CreatesPerfexCRMCustomer: '.$response);
return null;
}
}catch(\Exception $exception){
@@ -34,7 +34,7 @@ class CreatesPerfexCRMCustomerContact
$data = $response->json();
return (object) $data;
}else{
Log::error($response);
Log::error('CreatesPerfexCRMCustomerContact: '.$response);
return null;
}
}catch(\Exception $exception){
@@ -33,7 +33,7 @@ class CreatesPerfexCRMCustomerProject
$data = $response->json();
return (object) $data;
}else{
Log::error($response);
Log::error('CreatesPerfexCRMCustomerProject: '.$response);
return null;
}
}catch(\Exception $exception){
@@ -53,7 +53,7 @@ class CreatesPerfexCRMInvoice
$data = $response->json();
return (object) $data;
}else{
Log::error($response);
Log::error('CreatesPerfexCRMInvoice: '.$response);
return null;
}
}catch(\Exception $exception){
@@ -33,7 +33,7 @@ class CreatesPerfexCRMInvoicePayment
$data = $response->json();
return (object) $data;
}else{
Log::error($response);
Log::error('CreatesPerfexCRMInvoicePayment: '.$response);
return null;
}
}catch(\Exception $exception){
@@ -40,7 +40,7 @@ class CreatesPerfexCRMLead
$data = $response->json();
return (object) $data;
}else{
Log::error($response);
Log::error('CreatesPerfexCRMLead: '.$response);
return null;
}
}catch(\Exception $exception){
@@ -36,7 +36,7 @@ class CreatesPerfexCRMMilestone
$data = $response->json();
return (object) $data;
}else{
Log::error($response);
Log::error('CreatesPerfexCRMMilestone: '.$response);
return null;
}
}catch(\Exception $exception){
@@ -57,7 +57,7 @@ class CreatesPerfexCRMTask
$data = $response->json();
return (object) $data;
}else{
Log::error($response);
Log::error('CreatesPerfexCRMTask: '.$response);
return null;
}
}catch(\Exception $exception){
@@ -24,7 +24,7 @@ class FetchesPerfexCRMCustomer
return (object) $data;
}else{
Log::error($response);
Log::error('FetchesPerfexCRMCustomer: '.$response);
return null;
}
}catch(\Exception $exception){
@@ -26,7 +26,7 @@ class FetchesPerfexCRMInvoice
return (object) $data;
}else{
Log::error($response);
Log::error('FetchesPerfexCRMInvoice: '.$response);
return null;
}
}catch(\Exception $exception){
@@ -24,7 +24,7 @@ class FetchesPerfexCRMLead
return (object) $data;
}else{
Log::error($response);
Log::error('FetchesPerfexCRMLead: '.$response);
return null;
}
}catch(\Exception $exception){
@@ -30,7 +30,7 @@ class FetchesPerfexCRMMilestone
return (object) $data;
}else{
Log::error($response);
Log::error('FetchesPerfexCRMMilestone: '.$response);
return null;
}
}catch(\Exception $exception){
@@ -30,7 +30,7 @@ class FetchesPerfexCRMProject
return (object) $data;
}else{
Log::error($response);
Log::error('FetchesPerfexCRMProject: '.$response);
return null;
}
}catch(\Exception $exception){
@@ -38,7 +38,7 @@ class UpdatesPerfexCRMCustomer
$data = $response->json();
return (object) $data;
}else{
Helper::debugLogger($response);
// Helper::debugLogger($response);
return null;
}
}catch(\Exception $exception){
@@ -60,7 +60,7 @@ class UpdatesPerfexCRMInvoice
$data = $response->json();
return (object) $data;
}else{
Log::error($response);
Log::error('UpdatesPerfexCRMInvoice: '.$response);
return null;
}
}catch(\Exception $exception){
@@ -41,7 +41,7 @@ class UpdatesPerfexCRMLead
$data = $response->json();
return (object) $data;
}else{
Log::error($response);
Log::error('UpdatesPerfexCRMLead: '.$response);
return null;
}
}catch(\Exception $exception){
@@ -33,7 +33,7 @@ class UpdatesPerfexCRMProject
$data = $response->json();
return (object) $data;
}else{
Log::error($response);
Log::error('UpdatesPerfexCRMProject: '.$response);
return null;
}
}catch(\Exception $exception){
@@ -38,7 +38,7 @@ class UpdatesPerfexCRMTask
$data = $response->json();
return (object) $data;
}else{
Log::error($response);
Log::error('UpdatesPerfexCRMTask: '.$response);
return null;
}
}catch(\Exception $exception){
@@ -111,35 +111,6 @@ class PerfexCRMTasks
'is_on_task_completion_update' => false
];
public const TASK_LOADED_CONTAINER_1 = [
'name' => 'Generate Shipping Invoices',
'description' => '○ Purpose: -<br>
○ Link to order page: {link_order}<br>',
'milestone' => '',
'reference' => 'TASK_LOADED_CONTAINER_1',
'on_task_completion' => 'TASK_LOADED_CONTAINER_2',
'department' => 'Operations',
'status' => PerfexCRMTaskStatus::IN_PROGRESS,
'priority' => PerfexCRMTaskPriority::HIGH,
'duedate' => 1,
'is_allow_multiple' => false,
'is_on_task_completion_update' => false
];
public const TASK_LOADED_CONTAINER_2 = [
'name' => 'Approve Shipping Invoices',
'description' => '○ Purpose: -<br>
○ Link to refer Pay On Behalf or Any extra charge: : {link_perfex}<br>',
'milestone' => '',
'reference' => 'TASK_LOADED_CONTAINER_2',
'on_task_completion' => '',
'department' => 'Customer Services',
'status' => '',
'priority' => PerfexCRMTaskPriority::HIGH,
'duedate' => 1,
'is_allow_multiple' => false,
'is_on_task_completion_update' => false
];
public const TASK_IDENTIFICATION_1 = [
@@ -162,4 +133,93 @@ class PerfexCRMTasks
'is_allow_multiple' => false,
'is_on_task_completion_update' => false
];
public const TASK_YD_LOADED_CONTAINER_1 = [
'name' => 'Generate Shipping Invoices',
'description' => '○ Purpose: -<br>
○ Link to order page: {link_order}<br>',
'milestone' => '',
'reference' => 'TASK_LOADED_CONTAINER_1',
'on_task_completion' => 'TASK_LOADED_CONTAINER_2',
'department' => 'Operations',
'status' => PerfexCRMTaskStatus::IN_PROGRESS,
'priority' => PerfexCRMTaskPriority::HIGH,
'duedate' => 1,
'is_allow_multiple' => false,
'is_on_task_completion_update' => false
];
public const TASK_YD_LOADED_CONTAINER_2 = [
'name' => 'Approve Shipping Invoices',
'description' => '○ Purpose: -<br>
○ Link to refer Pay On Behalf or Any extra charge: : {link_perfex}<br>',
'milestone' => '',
'reference' => 'TASK_LOADED_CONTAINER_2',
'on_task_completion' => '',
'department' => 'Customer Services',
'status' => '',
'priority' => PerfexCRMTaskPriority::HIGH,
'duedate' => 1,
'is_allow_multiple' => false,
'is_on_task_completion_update' => false
];
public const TASK_YD_LOADED_CONTAINER_3 = [
'name' => 'Track 1 - Loaded Container',
'description' => '',
'milestone' => '',
'reference' => 'TASK_YD_SHIPPING_3',
'on_task_completion' => '',
'department' => '',
'status' => PerfexCRMTaskStatus::NOT_STARTED,
'priority' => PerfexCRMTaskPriority::DEFAULT,
'duedate' => 1,
'is_allow_multiple' => false,
'is_on_task_completion_update' => false
];
public const TASK_YD_SHIPPING_1 = [
'name' => 'Track 2 - Shipping',
'description' => '',
'milestone' => '',
'reference' => 'TASK_YD_SHIPPING_1',
'on_task_completion' => '',
'department' => '',
'status' => PerfexCRMTaskStatus::NOT_STARTED,
'priority' => PerfexCRMTaskPriority::DEFAULT,
'duedate' => 1,
'is_allow_multiple' => false,
'is_on_task_completion_update' => false
];
public const TASK_YD_UNSTUFFING_1 = [
'name' => 'Track 3 - Unstuffing',
'description' => '',
'milestone' => '',
'reference' => 'TASK_YD_UNSTUFFING_1',
'on_task_completion' => '',
'department' => '',
'status' => PerfexCRMTaskStatus::NOT_STARTED,
'priority' => PerfexCRMTaskPriority::DEFAULT,
'duedate' => 1,
'is_allow_multiple' => false,
'is_on_task_completion_update' => false
];
public const TASK_YD_DELIVERY_1 = [
'name' => 'Track 4 - Delivery',
'description' => '',
'milestone' => '',
'reference' => 'TASK_YD_DELIVERY_1',
'on_task_completion' => '',
'department' => '',
'status' => PerfexCRMTaskStatus::NOT_STARTED,
'priority' => PerfexCRMTaskPriority::DEFAULT,
'duedate' => 1,
'is_allow_multiple' => false,
'is_on_task_completion_update' => false
];
}
@@ -0,0 +1,17 @@
<?php
namespace App\Classes\ValueObjects\Constants;
final class PerfexCRMTasksYDStages {
public const DEFAULT = 0;
public const LOAD_CONTAINER = 10;
public const SHIP_SAILED = 20;
public const SHIP_ARRIVED = 21;
public const UNSTUFFING = 30;
public const DELIVERY = 40;
}
@@ -75,14 +75,14 @@ class FixBillplzFailedCallbackPayment extends Command
*/
public function handle()
{
ini_set('memory_limit', '-1');
ini_set('memory_limit', '-1');
$this->outputArray = [];
$this->outputArray = [];
$start = new Carbon();
$approvalStatusArray = ApprovalStatus::APPROVAL_STATUS_ID;
$transactions = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
$transactions = Transaction::whereIn('type', [TransactionType::PAYMENT, TransactionType::TOP_UP])->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
$totalTransactions = count($transactions);
if ($totalTransactions) {
@@ -93,7 +93,7 @@ class FixBillplzFailedCallbackPayment extends Command
$totalAmount = 0;
foreach ($transactions as $transaction){
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference);
if($response->successful()){
$data = $response->json();
if($data['paid']){
@@ -122,36 +122,36 @@ class FixBillplzFailedCallbackPayment extends Command
// $billPlz = $this->getBillplzBill->execute($billplzXSignatureObject->getBillPlzId());
// if(!$billPlz) throw new ResourceNotFoundException('Billplz bill not found.');
// $transaction = $this->fetchesTransaction->execute(['payment_reference' => $billplzXSignatureObject->getBillPlzId()]);
$invoice = $transaction->owner;
$packingList = $invoice->owner;
$order = $packingList->owner;
$status = ApprovalStatus::PENDING_VERIFICATION;
if($data['state'] === 'paid') {
$status = ApprovalStatus::APPROVED;
}
// if($data->state === 'due') {
// $status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION;
// }
// $token = Auth::fromUser(User::find(1));
// $request->headers->set('Authorization', 'Bearer '.$token);
$this->updatesTransactionStatus->execute($transaction, $status);
$totalPaidAmount = $invoice->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
if(($invoice->amount - $totalPaidAmount) < 0.01) {
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
$packingList->status = ApprovalStatus::APPROVED;
$packingList->save();
if(app()->environment('production')){
$this->updateDoFromVTPortalProcessor->execute($packingList);
$this->updateDoFromYDPortalProcessor->execute($packingList);
@@ -170,7 +170,7 @@ class FixBillplzFailedCallbackPayment extends Command
$this->info($counter . ' of ' . $totalTransactions . '. Order: '. $order->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount . '. Status: ' . $approvalStatusArray[$transaction->status] . '. Invoice Status: ' . $invoiceStatus);
}
}
} else {
// $totalAmount += $transaction->amount;
// $this->appendToOutput($counter . ' of ' . $totalTransactions . '. Order: '. $transaction->owner->owner->owner->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount);
@@ -180,7 +180,7 @@ class FixBillplzFailedCallbackPayment extends Command
}
$counter++;
}
$end = new Carbon();
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
@@ -23,7 +23,11 @@ class ExportArrivedParcelController
}
public function export(Request $request) {
$exportsPendingArrangementDeliveryList = new ExportsArrivedParcel($request);
$startDate = $request->query('start_date');
$endDate = $request->query('end_date');
$exportsPendingArrangementDeliveryList = new ExportsArrivedParcel($startDate, $endDate);
$response = $exportsPendingArrangementDeliveryList->download('arrived-parcel.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
ob_end_clean();
return $response;
@@ -26,7 +26,7 @@ class MappableTransactionResource extends JsonResource
$reference = $this->owner->owner->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
}
if($this->type === TransactionType::PAYMENT && $this->owner !== Wallet::class){
if($this->type === TransactionType::PAYMENT && $this->owner_type !== Wallet::class){
$reference = $this->owner->owner->owner->reference;
}
@@ -34,7 +34,7 @@ class MappableTransactionResource extends JsonResource
'status' => 'success',
'system' => 'SHIPPING_PORTAL',
'type' => $this->type,
'owner_type' => $this->owner_type,
'owner_type' => Transaction::class,
'owner_id'=> $this->id,
'owner_reference'=> $reference,
];
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Http\Resources;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
use Illuminate\Http\Resources\Json\JsonResource;
@@ -21,8 +22,8 @@ class WalletResource extends JsonResource
'currency_id' => $this->currency_id,
'amount' => (double) $this->amount,
'company_id' => (int) $this->owner->id,
'transactions' => $this->whenLoaded('transactions', WalletTransactionResource::collection($this->transactions()->whereIn('status', [2, 3])->orderBy('id', 'DESC')->get()), []),
'top_up_records' => $this->whenLoaded('transactions', WalletTransactionResource::collection($this->transactions()->whereNotIn('status', [0])->where('type', TransactionType::TOP_UP)->orderBy('id', 'DESC')->get()), []),
'transactions' => $this->whenLoaded('transactions', WalletTransactionResource::collection($this->transactions()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->orderBy('id', 'DESC')->get()), []),
'top_up_records' => $this->whenLoaded('transactions', WalletTransactionResource::collection($this->transactions()->whereIn('type', [TransactionType::TOP_UP])->orderBy('id', 'DESC')->get()), []),
'company_module_marking' => $this->owner->connections->first()->invitee_reference,
];
}
+8 -2
View File
@@ -29,7 +29,7 @@ use App\Classes\General\Interfaces\Remarkable;
* Class CompanyModule
* @package App\Models
*
* @property \App\Models\Company company_id
* @property \App\Models\Company company_id
* @property integer type
* @property integer status
*/
@@ -111,6 +111,12 @@ class CompanyModule extends AbstractModel implements Addressable, Documentable,
return $this->hasMany(CompanyConnection::class, 'invitee_id');
}
public function getMarking()
{
$connection = $this->connections()->first();
return $connection ? $connection->invitee_reference : '';
}
/**
* @return HasMany
*/
@@ -193,7 +199,7 @@ class CompanyModule extends AbstractModel implements Addressable, Documentable,
{
return $this->hasManyDeep(Transaction::class, [Order::class], ['company_module_id', 'owner_id'], ['id', 'id']);
}
/**
* @return MorphMany
*/
+23 -11
View File
@@ -1,22 +1,34 @@
@extends('layouts.base_portal')
@section('inner_content')
<div class="row">
<div class="col-5">
<div class="col-8">
<div class="row p-b-5 b-b b-grey m-b-10 m-l-0 m-r-0">
<div class="col no-padding">
<h6>Arrived Parcel</h6>
</div>
</div>
<a href="{{route('packing_list.arrived_parcel.export')}}" target="_blank">
<button type="button" class="btn btn-sm p-t-10 p-b-10 p-r-35 p-l-35 btn-primary b-rad-none">
<div class="row align-items-center">
<div class="col-auto p-r-0 p-l-0">
<i class="fa fa-file-excel-o fs-16"></i>
</div>
<div class="col p-r-5">Export To Excel</div>
<form action="{{route('packing_list.arrived_parcel.export')}}" method="GET" target="_blank">
<div class="form-group row">
<label for="start_date" class="col-sm-2 col-form-label">Start Date</label>
<div class="col-sm-10">
<input type="date" class="form-control" id="start_date" name="start_date">
</div>
</button>
</a>
</div>
<div class="form-group row">
<label for="end_date" class="col-sm-2 col-form-label">End Date</label>
<div class="col-sm-10">
<input type="date" class="form-control" id="end_date" name="end_date">
</div>
</div>
<div class="form-group row">
<div class="col-sm-10 offset-sm-2">
<button type="submit" class="btn btn-primary">Export</button>
</div>
</div>
</form>
<list-component section="warehouseListSection" :endpoint="route('api.packing_list.list')" :options="{packing_list_type: 1, per_page: 20, order_by: {column: 'arrival_date', DESC: true}, with_arrival_date: true}" >
<template slot="list" slot-scope="{data}">
<parcel-component v-for="packages in data.packages" :data="packages" :key="packages.id"></parcel-component>
@@ -48,4 +60,4 @@
</list-component>
</div>
</div>
@endsection
@endsection
+51 -1
View File
@@ -35,6 +35,7 @@ use App\Models\CompanyConnection;
use App\Models\CompanyModule;
use App\Models\Document;
use App\Models\Order;
use App\Models\Package;
use App\Models\PackingList;
use Carbon\Carbon;
use Illuminate\Http\Request;
@@ -864,11 +865,14 @@ Route::get('/invoices/combine/{ids}', function($ids){
// })->name('generate.invoices');
Route::get('/invoices/approve', function(Request $request){
// whereDoesntHave
$invoices = Transaction::where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::PENDING_SUBMISSION)->get();
foreach ($invoices as $invoice) {
$packingList = $invoice->owner;
if (!$packingList) {
dump ('Error packingList not found. Invoice ID - ' . $invoice->id);
continue;
}
$order = $packingList->owner;
if ($request->input('exclude')){
@@ -1140,3 +1144,49 @@ Route::get('/final-duplicated-invoice-debug', function(){
echo '</table>';
});
Route::get('/duplicate-package-clean-up', function(){
// Fetching duplicate rows based on given columns
$duplicates = Package::select('packing_list_id', 'description', 'width', 'height', 'weight', 'quantity', DB::raw('COUNT(*) as count'))
->groupBy('packing_list_id', 'description', 'width', 'height', 'weight', 'quantity')
->havingRaw('COUNT(*) > 1')
->get();
$totalGroups = 0;
// Loop through each group of duplicates
foreach ($duplicates as $duplicate) {
$totalGroups++;
// Fetch all rows of the current group and order by created_at
$rows = Package::where('packing_list_id', $duplicate->packing_list_id)
->where('description', $duplicate->description)
->where('width', $duplicate->width)
->where('height', $duplicate->height)
->where('weight', $duplicate->weight)
->where('quantity', $duplicate->quantity)
->orderBy('created_at')
->get();
// Echo the group details
echo "Group {$totalGroups} Details:<br>";
foreach ($rows as $row) {
echo "ID: {$row->id}, Packing List ID: {$row->packing_list_id}, Description: {$row->description}, Width: {$row->width}, Height: {$row->height}, Weight: {$row->weight}, Quantity: {$row->quantity}, Created At: {$row->created_at}<br>";
}
// Delete all rows in the group except the first one (oldest based on created_at)
$firstRow = $rows->shift();
foreach ($rows as $row) {
Package::where('id', $row->id)->delete();
}
// Calculate the case age for the group (assuming case age means difference between current date and created_at of the oldest row)
$caseAge = Carbon::now()->diffInDays(Carbon::parse($firstRow->created_at));
echo "Case Age for Group {$totalGroups}: {$caseAge} days<br><br>";
}
// Echo the total number of duplicate groups
echo "Total Number of Duplicate Groups: {$totalGroups}";
});