Compare commits

...

84 Commits

Author SHA1 Message Date
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
Dillon e5421f8810 Update condition to update CRM task status 2023-08-20 15:57:51 +08:00
Dillon a413533975 CRM Integration (Part 2 of code sync with Exchange-2.0) 2023-08-20 05:30:54 +08: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
Dillon d769be137e Exchange-2.0 code sync for crm changes 2023-08-17 21:49:48 +08:00
Dillon d6a5dd56c6 Exchange-2.0 code sync for crm changes 2023-08-17 21:34:18 +08: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
edmondlang 64bfbac4f7 update manual generate warehouse packinglist 2023-08-03 14:30:45 +08:00
edmondlang a5b7e79964 manual generate warehouse packinglist 2023-08-03 13:45:07 +08:00
edmondlang 03c9bec256 fix-duplicate-container-reference cron 2023-08-01 00:04:20 +08:00
edmondlang 06134e006c fix deleted packinglist 2023-07-23 15:42:35 +08:00
Omair Saleh 7563b455ba update yd updates link 2023-07-21 12:40:56 +08:00
Omair Saleh 26edb3bebd Merge remote-tracking branch 'origin/master' 2023-07-21 12:34:35 +08:00
Omair Saleh 55e1a6ad02 remove all customer from vt warehouse list 2023-07-21 12:34:19 +08:00
edmondlang 381425c6bc update export mappable transaction 2023-07-18 12:53:00 +08:00
edmondlang 09ab95faf8 update listing mapping transaction 2023-07-18 11:54:27 +08:00
edmondlang 8bb6f0317a update list mappable transactino details log 2023-07-11 17:59:43 +08:00
edmondlang fe95db2605 update list mappable transactino details log 2023-07-11 17:48:09 +08:00
edmondlang 02640e6ae8 update list mappable transactino details log 2023-07-11 17:39:09 +08:00
Omair Saleh 104dd19a6f Merge remote-tracking branch 'origin/master' 2023-07-10 12:52:35 +08:00
Omair Saleh 89117c0706 debug yd api 2023-07-10 12:51:59 +08:00
edmondlang bc650b0816 update public endpoint for exchange to get transaction data for accounting mapping 2023-07-09 22:01:35 +08:00
edmondlang a6a239c489 add public endpoint for exchange to get transaction data for accounting mapping 2023-07-09 21:54:56 +08:00
edmondlang 45b78465da add debtor code in company module resource for exchange accounting mapping purpose 2023-07-07 00:59:48 +08:00
Omair Saleh 71edeca994 Merge remote-tracking branch 'origin/master' 2023-07-05 14:18:02 +08:00
Omair Saleh cd229c6a8f fix the invoice export format 2023-07-05 14:17:43 +08:00
edmondlang ebc3e588ca update support 2023-06-29 14:35:12 +08:00
edmondlang 80471acc5b update support page 2023-06-28 01:08:31 +08:00
Omair Saleh ea08774111 Merge remote-tracking branch 'origin/master' 2023-06-23 14:43:04 +08:00
Omair Saleh 4a1f05e62a include ref column to payment export for autocount 2023-06-23 14:42:46 +08:00
edmondlang 840fb86192 show bill_no for all payments 2023-06-22 13:41:48 +08:00
Omair Saleh 7a171685f6 create a public api for mappable transactions 2023-06-21 16:34:50 +08:00
Omair Saleh 096e039ffb create a public api for mappable transactions 2023-06-21 16:31:52 +08:00
Omair Saleh 2319393758 create a public api for mappable transactions 2023-06-21 16:30:30 +08:00
Omair Saleh 85ba9d66d5 create a public api for mappable transactions 2023-06-21 16:21:08 +08:00
Omair Saleh 626dff6137 create a public api for mappable transactions 2023-06-21 15:19:45 +08:00
Omair Saleh 99efce22db add owner type column to transaction resource to help with bank mapping function in exchange 2023-06-21 13:25:56 +08:00
Omair Saleh 4a9e89c752 disable accounting task in crm 2023-06-15 06:30:48 +08:00
Omair Saleh 39e3398f8e debug yd api 2023-06-09 17:46:27 +08:00
Omair Saleh 7db77d619b debug yd api 2023-06-09 17:40:59 +08:00
Omair Saleh 8f390311af debug yd api 2023-06-09 15:32:39 +08:00
Omair Saleh 6502957021 debug yd api 2023-06-09 15:21:16 +08:00
Omair Saleh d6ddf6d607 fix invoice email 2023-06-07 10:04:54 +08:00
Omair Saleh b368b1c0d1 debug invoice email 2023-06-07 09:59:21 +08:00
Omair Saleh a2ef3ed1b1 debug invoice email 2023-06-07 09:57:47 +08:00
Omair Saleh e1b712ad10 debug invoice email 2023-06-07 09:54:52 +08:00
Omair Saleh ddbfc5fdfd debug invoice email 2023-06-07 09:51:06 +08:00
Omair Saleh 1cdd511f67 fix bug with invoice showing that doesn't belong to the order 2023-05-25 15:35:56 +08:00
Omair Saleh f7d0fe117e fix bug with invoice showing that doesn't belong to the order 2023-05-25 15:35:11 +08:00
Omair Saleh 4dede50156 fix bug with invoice showing that doesn't belong to the order 2023-05-25 15:34:19 +08:00
Omair Saleh 0d555eedc9 fix bug with invoice showing that doesn't belong to the order 2023-05-25 15:32:19 +08:00
Omair Saleh 7f73ec14a5 fix bug with fetching company module from invoice modal in create payment transaction processor 2023-05-25 15:08:24 +08:00
Omair Saleh 408397e20e Merge remote-tracking branch 'origin/master' 2023-05-25 15:06:36 +08:00
Omair Saleh ef37f1ebbe fix bug with fetching company module from invoice modal in create payment transaction processor 2023-05-25 15:06:17 +08:00
edmondlang 914e9a6f0f add BillNo Filter 2023-05-21 19:20:26 +08:00
edmondlang 525e7a5dd1 deletes group payment 2023-05-19 21:27:26 +08:00
edmondlang a3cad7816c deletes group payment 2023-05-19 21:22:16 +08:00
edmondlang 2100c4a14a update fix_failed_callback_from_billplz log 2023-05-19 20:45:03 +08:00
Omair Saleh 0d090b4eaf update public api for querying transactions and groups 2023-05-16 11:42:57 +08:00
edmondlang 73801a5acd enable generate combine invoice function for unpaid invoice 2023-05-15 20:47:22 +08:00
edmondlang 2c0eeab84e fix duplicated invoice 2023-05-10 23:01:07 +08:00
edmondlang 40c4a39927 revert order resource for debug 2023-05-10 13:47:29 +08:00
edmondlang 866df52e52 fix sending billplz email to customer on development environment 2023-05-10 13:37:50 +08:00
edmondlang b34d909a09 fix order resource returning incorrect invoice 2023-05-10 13:24:10 +08:00
edmondlang 26b3e968e9 fix order resource returning incorrect invoice 2023-05-10 13:22:44 +08:00
edmondlang 7b127b2cba fix order resource returning incorrect invoice 2023-05-10 13:15:57 +08:00
edmondlang 7488313a0e fix order resource returning incorrect invoice 2023-05-10 13:12:56 +08:00
edmondlang 7589b5c553 customer payment and billing menu 2023-05-08 13:14:25 +08:00
edmondlang d8391fe479 fix invoice appearing in PENDING PAYMENT and also GROUP PAYMENT IN PROGRESS 2023-05-08 12:53:52 +08:00
edmondlang c01e8d6eb2 fix retry payment button coverage 2023-05-08 00:28:13 +08:00
edmondlang 5aad5f1729 merge master 2023-05-06 18:51:58 +08:00
edmondlang 485a6e2e82 merge master 2023-05-06 18:45:00 +08:00
90 changed files with 1893 additions and 447 deletions
@@ -0,0 +1,20 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class BillNo implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return Builder|mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->where('bill_no', $value);
}
}
@@ -15,7 +15,7 @@ class DoesNotHaveTransactionType implements Filter
public static function apply(Builder $builder, $value)
{
return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
$query->where('type', $value)->whereIn('status', [0,1,2,3]);
$query->where('type', $value)->whereIn('status', [0,1,2,3,5]);
})->whereHas('containers', function ($query){
return $query->whereDate('loading_date', '>=', Carbon::parse('20-09-2022'));
});
+3 -4
View File
@@ -24,12 +24,11 @@ class Helper
return array_slice(get_class_methods($className), 1);
}
/**
/**
* @param $log
* @return none
*/
static function debugLoggerForPerfexCRM($log){
if($log){
static function debugLogger($log){
if($log && isset($log['message'])){
$message = $log['message'];
$substring = 'No data were found';
if (isset($message)) {
+28 -10
View File
@@ -3,6 +3,8 @@
namespace App\Classes\Jobs;
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
use App\Classes\Modules\PerfexCRM\Processors\FetchPerfexCRMInvoiceProcessor;
use App\Models\Transaction;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
@@ -10,6 +12,8 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\FetchPerfexCRMInvoiceObject;
class UpdatePerfexCRM implements ShouldQueue
{
@@ -18,37 +22,51 @@ class UpdatePerfexCRM implements ShouldQueue
/** @var UpdatePerfexCRMObject */
private $updatePerfexCRMObject;
/** @var UpdatePerfexCRMInvoice */
private $nextJob;
/** @var */
private $transaction;
/** @var bool|null */
private $shouldCreateInvoice;
/**
* UpdatePerfexCRM constructor.
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
* @param UpdatePerfexCRMInvoice $nextJob
* @param $transaction
* @param Transaction $transaction
* @param bool|null $shouldCreateInvoice
*/
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject, $transaction, $nextJob)
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject, $transaction, ?bool $shouldCreateInvoice = false)
{
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
$this->nextJob = $nextJob;
$this->transaction = $transaction;
$this->shouldCreateInvoice = $shouldCreateInvoice;
}
public function handle()
{
//To use invoice as a reference to decide whether more tasks should be created
$this->updatePerfexCRMObject->setInvoiceId($this->getInvoiceIdOrCreateInvoice());
$result = (App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
if($this->nextJob != null && $this->transaction != null){
if($this->transaction != null && $this->shouldCreateInvoice){
$updatePerfexCRMInvoiceOject = new UpdatePerfexCRMInvoiceObject(
$this->updatePerfexCRMObject->getContactEmail(),
$result->projectId,
$this->transaction,
true
);
/** @var UpdatePerfexCRMInvoice $nextJob */
$this->nextJob::dispatch($updatePerfexCRMInvoiceOject);
UpdatePerfexCRMInvoice::dispatch($updatePerfexCRMInvoiceOject);
}
}
private function getInvoiceIdOrCreateInvoice(){
if($this->transaction != null){
$fetchPerfexCRMInvoiceObject = new FetchPerfexCRMInvoiceObject(
$this->updatePerfexCRMObject->getContactEmail(),
$this->transaction
);
$invoiceId = (App()->make(FetchPerfexCRMInvoiceProcessor::class))->execute($fetchPerfexCRMInvoiceObject);
return $invoiceId;
}
return 0;
}
}
+3 -4
View File
@@ -30,7 +30,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
/**
* CreatePerfexCRMSingleTask constructor.
* @param UpdatePerfexCRMInvoiceObject $createTaskPerfexCRMObject
* @param UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject
*/
public function __construct(UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject)
{
@@ -47,7 +47,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
$invoiceId = 0;
$invoiceStatus = 0;
$invoice = (App()->make(FetchesPerfexCRMInvoice::class))->execute($customer->userid,"INV-", $transaction->owner->bill_no);
Log::error(json_encode('UpdatePerfexCRMInvoice debug $transaction->owner->bill_no: '.$transaction->owner->bill_no));
Log::error('UpdatePerfexCRMInvoice debug bill_no: ' . $transaction->owner->bill_no . ', Project Id: ' . $this->updatePerfexCRMInvoiceObject->getProjectId());
if(is_null($invoice)){
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction->owner, $this->updatePerfexCRMInvoiceObject->getIsPaid());
@@ -55,7 +55,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
$invoiceId = $result->payload['id'];
} else {
// Log::error(json_encode('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed'));
Helper::debugLoggerForPerfexCRM('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
Helper::debugLogger('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
}
}
else{
@@ -64,7 +64,6 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
//This only run when invoice already exist and the invoice does not have a PAID status
if($invoiceStatus != PerfexCRMInvoiceStatus::PAID){
Log::error(json_encode('UpdatePerfexCRMInvoice debug $this->updatePerfexCRMInvoiceObject->getProjectId(): '.$this->updatePerfexCRMInvoiceObject->getProjectId()));
//update invoice
(App()->make(UpdatesPerfexCRMInvoice::class))->execute($invoice, $this->updatePerfexCRMInvoiceObject->getProjectId());
}
+7 -14
View File
@@ -27,27 +27,22 @@ class UpdatePerfexCRMPrelude implements ShouldQueue
/** @var UpdatePerfexCRMObject */
private $updatePerfexCRMObject;
/** @var UpdatePerfexCRM */
private $nextJob1;
/** @var UpdatePerfexCRMInvoice */
private $nextJob2;
/** @var bool|null */
private $shouldCreateInvoice;
/**
* UpdatePerfexCRMPrelude constructor.
* @param $packingList
* @param $transaction
* @param Transaction $transaction
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
* @param UpdatePerfexCRM $nextJob1
* @param UpdatePerfexCRMInvoice $nextJob2
* @param bool|null $shouldCreateInvoice
*/
public function __construct($packingList, $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, $nextJob1, $nextJob2)
public function __construct($packingList, $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, ?bool $shouldCreateInvoice = false)
{
$this->packingList = $packingList;
$this->transaction = $transaction;
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
$this->nextJob1 = $nextJob1;
$this->nextJob2 = $nextJob2;
$this->shouldCreateInvoice = $shouldCreateInvoice;
}
public function handle()
@@ -69,9 +64,7 @@ class UpdatePerfexCRMPrelude implements ShouldQueue
$result = $this->replacePlaceholders($this->updatePerfexCRMObject->getTasks(), $data);
$this->updatePerfexCRMObject->setTasks($result);
/** @var UpdatePerfexCRM $nextJob1 */
/** @var UpdatePerfexCRMInvoice $nextJob2 */
$this->nextJob1::dispatch($this->updatePerfexCRMObject, $this->transaction, $this->nextJob2);
UpdatePerfexCRM::dispatch($this->updatePerfexCRMObject, $this->transaction, $this->shouldCreateInvoice);
}
function replacePlaceholders($template, $data, $prefix = '')
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Billplzs\Services;
use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException;
use Illuminate\Support\Facades\App;
class CreatesBillplzBill
{
@@ -25,7 +26,7 @@ class CreatesBillplzBill
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
'collection_id' => config('billplz.collection_id'),
'name' => $name,
'email' => $email,
'email' => App::environment('production') ? $email : 'development@cief-malaysia.com',
'description' => $description,
'amount' => $this->finalizeAmount($amount),
'redirect_url' => route('online_payment.redirect'),
@@ -32,6 +32,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
'DocNo',
'DocDate',
'DebtorCode',
'Ref',
'ShipInfo',
'AccNo',
'DetailDescription',
@@ -126,6 +127,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
$transaction->created_at->format('m/d/Y H:m'),
$company->debtor,
$order->reference,
$order->reference,
'500-0000',
'X1 Freight Service Charge',
$furtherDescription,
@@ -83,11 +83,10 @@ class CreateOrderLogic extends AbstractControllerLogic
} else {
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]);
if (!in_array($company->companyModules()->importers()->first()->id, WarehouseReferences::YD_EXEMPT_LIST)) {
$originWarehouse = $this->fetchesCompanyModule->execute(['reference' => $originWarehouse->reference === WarehouseReferences::VT_GUANG_ZHOU ? WarehouseReferences::YD_GUANG_ZHOU : WarehouseReferences::YD_YIWU]);
}
$originWarehouse = $this->fetchesCompanyModule->execute(['reference' => $originWarehouse->reference === WarehouseReferences::VT_GUANG_ZHOU ? WarehouseReferences::YD_GUANG_ZHOU : WarehouseReferences::YD_YIWU]);
// if (!in_array($company->companyModules()->importers()->first()->id, WarehouseReferences::YD_EXEMPT_LIST))
}
if($originWarehouse->reference === WarehouseReferences::YD_YIWU && in_array($address->state_id, [5, 13, 14])) {
throw new RequestValidationException('Our Yiwu warehouse is unable to ship goods to Sabah & Sarawak at the moment. you can select our Guangzhou warehouse as an alternative.');
}
@@ -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);
}
}
@@ -0,0 +1,131 @@
<?php
namespace App\Classes\Modules\PackingLists\ControllersLogic;
use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\PackingLists\Processors\CreatePackingListProcessor;
use App\Classes\Modules\PackingLists\Processors\CreatePackageProcessor;
use App\Classes\Modules\Transports\Services\CreatesTransport;
use App\Classes\Modules\PackingLists\Services\GeneratesPackingListReferenceNumber;
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
use App\Classes\ValueObjects\Constants\PackingListType;
use App\Classes\ValueObjects\Constants\TransportType;
use App\Http\Resources\PackingListResource;
use App\Models\PackingList;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Carbon\Carbon;
class CreateWarehouseTransportLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification(): array
{
return [
'title' => 'Created Warehouse PackingList',
'message' => 'You have successfully created a Warehouse PackingList'
];
}
/** @var FetchesPackingList */
private $fetchesPackingList;
/** @var CreatePackingListProcessor */
private $createPackingListProcessor;
/** @var GeneratesPackingListReferenceNumber */
private $generatesPackingListReferenceNumber;
/** @var CreatesTransport */
private $createsTransport;
/** @var CreatePackageProcessor */
private $createPackageProcessor;
/** @var CreatesSchedule */
private $createsSchedule;
public function __construct(
FetchesPackingList $fetchesPackingList,
CreatePackingListProcessor $createPackingListProcessor,
CreatesTransport $createsTransport,
CreatesSchedule $createsSchedule,
CreatePackageProcessor $createPackageProcessor,
GeneratesPackingListReferenceNumber $generatesPackingListReferenceNumber
) {
$this->fetchesPackingList = $fetchesPackingList;
$this->createPackingListProcessor = $createPackingListProcessor;
$this->createsTransport = $createsTransport;
$this->createsSchedule = $createsSchedule;
$this->createPackageProcessor = $createPackageProcessor;
$this->generatesPackingListReferenceNumber = $generatesPackingListReferenceNumber;
}
/**
* @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
{
$packing_list = $this->fetchesPackingList->execute([
'id' => $request->route('id'),
]);
$count_warehouse_packing_list = PackingList::where('reference', $packing_list->reference)->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->count();
if ($count_warehouse_packing_list) {
throw new MalformedRequestException('Warehouse Receive List Exists');
}
$order = $packing_list->owner;
$reference_number = $this->generatesPackingListReferenceNumber->execute();
$packingListObject = new PackingListObject(
$packing_list->reference,
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->id,
PackingListType::WAREHOUSE_RECEIVE_LIST,
ApprovalStatus::PENDING_SUBMISSION
);
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
$transportObject = new TransportObject(TransportType::LAND, null, $request->input('tracking'), Carbon::parse($request->input('receive_date')), Carbon::parse($request->input('receive_date')), ApprovalStatus::APPROVED);
$transport = $this->createsTransport->execute($transportObject, $packingList);
$scheduleObject = new ScheduleObject(Carbon::parse($request->input('receive_date')), Carbon::parse($request->input('receive_date')), ApprovalStatus::APPROVED);
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
$packages = $packing_list->packages;
foreach ($packages as $key => $row) {
$packageObject = new PackageObject(
$row['type'],
$row['description'],
$row['width'],
$row['height'],
$row['length'],
$row['weight'],
$row['quantity'],
ApprovalStatus::APPROVED,
$row['reference'],
);
$this->createPackageProcessor->execute($packageObject, $packingList);
}
return $this->resourceResponse(new PackingListResource($packingList));
}
}
@@ -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;
}
@@ -137,6 +144,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;
}
@@ -51,7 +58,7 @@ class FetchContainersUpdatesFromYdPortalProcessor
foreach ($containers as $container) {
$time_start = microtime(true);
$packingList = $container->packingLists()->random();
$packingList = $container->packingLists()->first();
$trackingRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/ApiTracking.ashx', 'GET', [
'trakingno' => $packingList->reference
@@ -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 === '货物已进目的港仓库') {
@@ -108,7 +121,32 @@ 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();
@@ -124,7 +162,6 @@ class FetchContainersUpdatesFromYdPortalProcessor
}
}
}
}
if($unstuffingDate){
@@ -146,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);
@@ -42,7 +42,10 @@ class CreateTaskPerfexCRMObject implements DataTransferObject
/** @var string */
private $duedate;
public function __construct(string $email, string $name, string $description, string $leadId, string $projectId, string $milestoneId, string $reference, string $onTaskCompletion, string $status, string $department, string $priority, string $duedate)
/** @var int */
private $invoiceId;
public function __construct(string $email, string $name, string $description, string $leadId, string $projectId, string $milestoneId, string $reference, string $onTaskCompletion, string $status, string $department, string $priority, string $duedate, int $invoiceId)
{
$this->email = $email;
$this->name = $name;
@@ -56,6 +59,7 @@ class CreateTaskPerfexCRMObject implements DataTransferObject
$this->department = $department;
$this->priority = $priority;
$this->duedate = $duedate;
$this->invoiceId = $invoiceId;
}
/**
@@ -158,4 +162,12 @@ class CreateTaskPerfexCRMObject implements DataTransferObject
{
return $this->duedate;
}
/**
* @return int
*/
public function getInvoiceId(): int
{
return $this->invoiceId;
}
}
@@ -0,0 +1,38 @@
<?php
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
use App\Classes\General\Interfaces\DataTransferObject;
use App\Models\Transaction;
class FetchPerfexCRMInvoiceObject implements DataTransferObject
{
/** @var string */
private $email;
/** @var Transaction */
private $transaction;
public function __construct(string $email, Transaction $transaction)
{
$this->email = $email;
$this->transaction = $transaction;
}
/**
* @return string
*/
public function getEmail(): string
{
return $this->email;
}
/**
* @return Transaction
*/
public function getTransaction(): Transaction
{
return $this->transaction;
}
}
@@ -28,6 +28,9 @@ class UpdatePerfexCRMObject implements DataTransferObject
/** @var int */
private $projectStatus;
/** @var int */
private $invoiceId = 0;
/** @var array */
private $milestoneNames;
@@ -35,7 +38,7 @@ class UpdatePerfexCRMObject implements DataTransferObject
private $tasks;
public function __construct(string $companyName, string $companyReference, string $contactName, string $contactEmail, string $bookingMarking, string $projectName, int $projectStatus, array $milestoneNames, array $tasks)
public function __construct(string $companyName, string $companyReference, string $contactName, string $contactEmail, string $bookingMarking, string $projectName, int $projectStatus, int $invoiceId, array $milestoneNames, array $tasks)
{
$this->companyName = $companyName;
@@ -45,6 +48,7 @@ class UpdatePerfexCRMObject implements DataTransferObject
$this->bookingMarking = $bookingMarking;
$this->projectName = $projectName;
$this->projectStatus = $projectStatus;
$this->$invoiceId = $invoiceId;
$this->milestoneNames = $milestoneNames;
$this->tasks = $tasks;
}
@@ -105,6 +109,14 @@ class UpdatePerfexCRMObject implements DataTransferObject
return $this->projectStatus;
}
/**
* @return int
*/
public function getInvoiceId(): int
{
return $this->invoiceId;
}
/**
* @return array
*/
@@ -125,4 +137,9 @@ class UpdatePerfexCRMObject implements DataTransferObject
{
$this->tasks = $tasks;
}
public function setInvoiceId($invoiceId)
{
$this->invoiceId = $invoiceId;
}
}
@@ -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
@@ -25,19 +25,7 @@ class CreatePerfexCRMTaskProcessor
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(CreateTaskPerfexCRMObject $createTaskPerfexCRMObject) {
$this->createsPerfexCRMTask->execute(
$createTaskPerfexCRMObject->getName(),
$createTaskPerfexCRMObject->getDescription(),
$createTaskPerfexCRMObject->getLeadId(),
$createTaskPerfexCRMObject->getMilestoneId(),
$createTaskPerfexCRMObject->getProjectId(),
$createTaskPerfexCRMObject->getReference(),
$createTaskPerfexCRMObject->getOnTaskCompletion(),
$createTaskPerfexCRMObject->getDepartment(),
$createTaskPerfexCRMObject->getStatus(),
$createTaskPerfexCRMObject->getPriority(),
$createTaskPerfexCRMObject->getDuedate()
);
$this->createsPerfexCRMTask->execute($createTaskPerfexCRMObject);
return true;
}
@@ -0,0 +1,73 @@
<?php
namespace App\Classes\Modules\PerfexCRM\Processors;
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMInvoiceProcessor;
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMCustomer;
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMInvoice;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\FetchPerfexCRMInvoiceObject;
use Illuminate\Support\Facades\Log;
use App\Classes\General\Helper;
class FetchPerfexCRMInvoiceProcessor
{
private $fetchesPerfexCRMCustomer;
/** @var FetchesPerfexCRMCustomer */
/** @var FetchesPerfexCRMInvoice */
private $fetchesPerfexCRMInvoice;
/** @var CreatePerfexCRMInvoiceProcessor */
private $createPerfexCRMInvoiceProcessor;
/**
*
* FetchPerfexCRMInvoiceProcessor constructor.
* @param FetchesPerfexCRMCustomer $fetchesPerfexCRMCustomer
* @param FetchesPerfexCRMInvoice $fetchesPerfexCRMInvoice
* @param CreatePerfexCRMInvoiceProcessor $createPerfexCRMInvoiceProcessor
*/
public function __construct(FetchesPerfexCRMCustomer $fetchesPerfexCRMCustomer,
FetchesPerfexCRMInvoice $fetchesPerfexCRMInvoice,
CreatePerfexCRMInvoiceProcessor $createPerfexCRMInvoiceProcessor)
{
$this->fetchesPerfexCRMCustomer = $fetchesPerfexCRMCustomer;
$this->fetchesPerfexCRMInvoice = $fetchesPerfexCRMInvoice;
$this->createPerfexCRMInvoiceProcessor = $createPerfexCRMInvoiceProcessor;
}
public function execute(FetchPerfexCRMInvoiceObject $fetchPerfexCRMInvoiceObject)
{
//invoiceId to be returned - fetch or create
$invoiceId = 0;
//get the client id
$customer = $this->fetchesPerfexCRMCustomer->execute($fetchPerfexCRMInvoiceObject->getEmail());
$transaction = $fetchPerfexCRMInvoiceObject->getTransaction();
$number = $transaction->owner->bill_no;
$prefix = "INV-";
//This will remove the prefix if prefix already exist in the string
if (substr($number, 0, strlen($prefix)) == $prefix) {
$number = substr($number, strlen($prefix));
}
$invoice = $this->fetchesPerfexCRMInvoice->execute($customer->userid,"INV-", $number);
if(is_null($invoice)){
$result = $this->createPerfexCRMInvoiceProcessor->execute($transaction->owner);
if ($result) {
$invoiceId = $result->payload['id'];
} else {
$log['message'] = 'FetchPerfexCRMInvoiceProcessor failed for transaction > bill_no: '.$number;
Helper::debugLogger($log);
}
}
else{
$invoiceId = $invoice->id;
}
return $invoiceId;
}
}
@@ -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,57 +4,160 @@ 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
{
/**
* @param PackingList $packingList
* @return \Illuminate\Database\Eloquent\Model
* @return bool
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(PackingList $packingList)
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, UpdatePerfexCRM::class, null);
$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;
}
}
@@ -1,75 +0,0 @@
<?php
namespace App\Classes\Modules\PerfexCRM\Processors;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
use App\Classes\ValueObjects\Constants\PerfexCRMTasks;
use App\Classes\ValueObjects\Constants\PerfexCRMProjectStatus;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\Jobs\UpdatePerfexCRMInvoice;
use App\Classes\Jobs\UpdatePerfexCRM;
use App\Classes\Jobs\UpdatePerfexCRMPrelude;
use App\Classes\Jobs\CreatePerfexCRMInvoice;
use App\Models\Transaction;
use Illuminate\Support\Facades\Log;
class TransactionToPerfexCRMProcessor
{
/**
* @param Transaction $model
* @param int $status
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(Transaction $model, int $status)
{
try
{
if($model->owner instanceof \App\Models\Transaction && $status == ApprovalStatus::APPROVED)
{
$packingList = $model->owner->owner;
$order = $packingList->owner()->first();
$companyModule = $order->companyModule()->first();
$companyName = $companyModule->name;
$companyReference = $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
$employee = $companyModule->employees()->first();
$contactEmail = $employee->email;
$contactName = $employee->name;
$orderReference = $order->reference;
$packingListReference = $packingList->reference;
$projectName = 'IZYIM | X1 Shipping | '.$orderReference.' | '.$packingListReference;
$bookingMarking = $packingList->id."-".$packingList->owner->id;
$updatePerfexCRMObject = new UpdatePerfexCRMObject(
$companyName,
$companyReference,
$contactName,
$contactEmail,
$bookingMarking,
$projectName,
PerfexCRMProjectStatus::IN_PROGRESS,
[],
[
PerfexCRMTasks::TASK_1,
PerfexCRMTasks::TASK_POST_PAYMENT_1,
PerfexCRMTasks::TASK_POST_PAYMENT_2,
PerfexCRMTasks::TASK_POST_PAYMENT_3,
PerfexCRMTasks::TASK_POST_PAYMENT_4,
]
);
UpdatePerfexCRMPrelude::dispatch(null, $model, $updatePerfexCRMObject, UpdatePerfexCRM::class, UpdatePerfexCRMInvoice::class);
}
else if($model->owner instanceof \App\Models\PackingList && $model->status == ApprovalStatus::PENDING_SUBMISSION && $status == ApprovalStatus::APPROVED)
{
CreatePerfexCRMInvoice::dispatch($model);
}
}
catch (\Exception $exception) {
Log::error('TransactionToPerfexCRMProcessor debug:');
Log::error($exception);
}
return true;
}
}
@@ -0,0 +1,145 @@
<?php
namespace App\Classes\Modules\PerfexCRM\Processors;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
use App\Classes\ValueObjects\Constants\PerfexCRMTasks;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\PerfexCRMProjectStatus;
use App\Classes\ValueObjects\Constants\PerfexCRMTaskStatus;
use App\Classes\Jobs\UpdatePerfexCRMPrelude;
use App\Classes\Jobs\CreatePerfexCRMInvoice;
use App\Models\Booking;
use App\Models\Transaction;
use Illuminate\Support\Facades\Log;
class TransactionToPerfexCRMV2Processor
{
public function execute(Transaction $model, int $status)
{
try {
if($model->owner instanceof \App\Models\Transaction && in_array($model->type, [TransactionType::PAYMENT])) {
//
$transaction = $model;
$info = $this->extractInfo($transaction);
$tasks = $this->defineTasks($model, $status);
//if(count($tasks) > 0) { //commented, otherwise when customer paid, invoice payment will not get created at crm because there is no tasks attached
$updatePerfexCRMObject = new UpdatePerfexCRMObject(
$info['companyName'],
$info['companyReference'],
$info['contactName'],
$info['contactEmail'],
$info['bookingMarking'],
$info['projectName'],
PerfexCRMProjectStatus::IN_PROGRESS,
0, //invoiceId
[], //milestoneNames
$tasks
);
$this->dispatchUpdateJob($transaction, $status, $updatePerfexCRMObject);
//}
}
else if($model->owner instanceof \App\Models\PackingList && $model->status == ApprovalStatus::PENDING_SUBMISSION && $status == ApprovalStatus::APPROVED)
{
CreatePerfexCRMInvoice::dispatch($model);
}
} catch (\Exception $exception) {
Log::error($exception);
}
return true;
}
//Level 1
private function extractInfo(Transaction $model): array
{
$packingList = $model->owner->owner;
$order = $packingList->owner()->first();
$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'] = $packingList->id."-".$packingList->owner->id;
$info['projectName'] = 'IZYIM | X1 Shipping | '.$order->reference.' | '.$packingList->reference;
return $info;
}
private function defineTasks(Transaction $model, int $status): array
{
$tasks = [];
if ($status === ApprovalStatus::PENDING_SUBMISSION) {
$tasks = $this->defineTasks_handlePendingVerificationStatus($model);
} elseif ($status === ApprovalStatus::APPROVED) {
$tasks = $this->defineTasks_handleApprovedStatus($model);
}
return $tasks;
}
private function dispatchUpdateJob(Transaction $model, int $status, UpdatePerfexCRMObject $updatePerfexCRMObject)
{
$withInvoice = ($model->type === TransactionType::PAYMENT && $model->owner instanceof \App\Models\Transaction && $status == ApprovalStatus::APPROVED);
UpdatePerfexCRMPrelude::dispatch(null, $model, $updatePerfexCRMObject, $withInvoice);
}
//Level Others: Nested
private function defineTasks_handlePendingVerificationStatus(Transaction $model): array
{
$tasks = [];
switch($model->type) {
case TransactionType::PAYMENT:
$tasks = $this->definePaymentTasks($model);
break;
}
return $tasks;
}
private function defineTasks_handleApprovedStatus(Transaction $model): array
{
$tasks = [];
switch($model->type) {
case TransactionType::PAYMENT:
$tasks = $this->defineTasks_handleApprovedStatus_handlePaymentApprovedStatus();
break;
}
return $tasks;
}
private function definePaymentTasks(Transaction $model): array //cief todo: to comfirm what tasks need to be created
{
$tasks = [];
return $tasks;
}
private function defineTasks_handleApprovedStatus_handlePaymentApprovedStatus(): array //cief todo: to comfirm what tasks need to be created
{
$tasks = [];
// $tasks = [
// PerfexCRMTasks::TASK_POST_PAYMENT_1,
// PerfexCRMTasks::TASK_POST_PAYMENT_2,
// PerfexCRMTasks::TASK_POST_PAYMENT_3,
// PerfexCRMTasks::TASK_POST_PAYMENT_4,
// ];
return $tasks;
}
private function completeTask($startTask, $endTask) {
$startTask['status'] = PerfexCRMTaskStatus::COMPLETED;
$endTask['status'] = PerfexCRMTaskStatus::IN_PROGRESS;
return [$startTask, $endTask];
}
}
@@ -15,10 +15,11 @@ use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMTask;
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMCustomer;
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMProject;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CustomerContactObject;
use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
use App\Classes\ValueObjects\Constants\PerfexCRMTaskStatus;
use App\Classes\ValueObjects\Constants\PerfexCRMProjectStatus;
use App\Classes\Exceptions\MalformedRequestException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Http\Request;
@@ -207,18 +208,46 @@ class UpdatePerfexCRMProcessor
}
// Get existing or create task
$result = $this->fetchesPerfexCRMTask->execute($tasks[$count]['name'], $milestoneId, 'project', $projectId);
$taskName = $tasks[$count]['name'];
$taskReference = $tasks[$count]['reference'];
$taskOnTaskCompletion = $tasks[$count]['on_task_completion'];
$taskIsAllowMultiple = $tasks[$count]['is_allow_multiple'];
$taskIsOnTaskCompletionUpdate = $tasks[$count]['is_on_task_completion_update'];
if($updatePerfexCRMObject->getInvoiceId() != 0 && $taskIsAllowMultiple){
$taskName = $taskName." (".$updatePerfexCRMObject->getInvoiceId().")";
$taskReference = $taskReference."_".$updatePerfexCRMObject->getInvoiceId();
if($taskOnTaskCompletion && $taskIsOnTaskCompletionUpdate){
$taskOnTaskCompletion = $taskOnTaskCompletion."_".$updatePerfexCRMObject->getInvoiceId();
}
}
$result = $this->fetchesPerfexCRMTask->execute($taskName, $milestoneId, 'project', $projectId, $updatePerfexCRMObject->getInvoiceId());
if(isset($result->payload)){
break; //Breaking the rest of the tasks in array assuming that they are all created as a batch previously
//The following are code not needed at Shipping Portal, Exchange need certain task's status to be updated dynamically
// if($taskStatus != PerfexCRMTaskStatus::NOT_STARTED && $result->payload[0]['status'] == PerfexCRMTaskStatus::NOT_STARTED)
// {
// $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']);
// }
//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']);
}
}
else{
$result = $this->createsPerfexCRMTask->execute($tasks[$count]['name'], $tasks[$count]['description'], '', $milestoneId, $projectId, $tasks[$count]['reference'], $tasks[$count]['on_task_completion'], $tasks[$count]['department'], $taskStatus, $tasks[$count]['priority'], $tasks[$count]['duedate']);
$createTaskPerfexCRMObject = new CreateTaskPerfexCRMObject(
"",
$taskName,
$tasks[$count]['description'],
"",
$projectId,
$milestoneId,
$taskReference,
$taskOnTaskCompletion,
$taskStatus,
$tasks[$count]['department'],
$tasks[$count]['priority'],
$tasks[$count]['duedate'],
$updatePerfexCRMObject->getInvoiceId()
);
$result = $this->createsPerfexCRMTask->execute($createTaskPerfexCRMObject);
}
}
}
@@ -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){
@@ -6,67 +6,47 @@ use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException;
use Illuminate\Support\Facades\Log;
use App\Classes\ValueObjects\Constants\PerfexCRMCustomFields;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
class CreatesPerfexCRMTask
{
/**
* @param string $taskName
* @param string $taskDescription
* @param string $leadId
* @param string $milestoneId
* @param string $projectId
* @param string $reference
* @param string $on_task_completion
* @param string $department
* @param string $status
* @param string $priority
* @param string $duedate
* @param CreateTaskPerfexCRMObject $createTaskPerfexCRMObject
* @return null|object
* @throws MalformedRequestException
*/
public function execute(string $taskName, string $taskDescription, string $leadId, string $milestoneId, string $projectId, string $reference, string $on_task_completion, string $department, string $status, string $priority, string $duedate) {
public function execute(CreateTaskPerfexCRMObject $createTaskPerfexCRMObject) {
try{
$custom_fields = [];
if($department != ""){
if($createTaskPerfexCRMObject->getDepartment() != ""){
$custom_fields = [
"tasks" => [
PerfexCRMCustomFields::TASKS_DEPARTMENT => $department
PerfexCRMCustomFields::TASKS_DEPARTMENT => $createTaskPerfexCRMObject->getDepartment()
]
];
}
$data = [
'name' => $taskName,
'description' => $taskDescription,
'milestone' => $milestoneId,
'name' => $createTaskPerfexCRMObject->getName(),
'description' => $createTaskPerfexCRMObject->getDescription(),
'milestone' => $createTaskPerfexCRMObject->getMilestoneId(),
'startdate' => date('Y-m-d'),
'rel_type' => 'project',
'rel_id' => $projectId,
'status' => $status,
'rel_id' => $createTaskPerfexCRMObject->getProjectId(),
'status' => $createTaskPerfexCRMObject->getStatus(),
'is_system_created' => 1,
'reference' => $reference,
'on_task_completion' => $on_task_completion,
'reference' => $createTaskPerfexCRMObject->getReference(),
'on_task_completion' => $createTaskPerfexCRMObject->getOnTaskCompletion(),
'custom_fields' => $custom_fields,
'priority' => $priority,
'duedate' => date('Y-m-d', strtotime('+' . $duedate . ' days')),
'priority' => $createTaskPerfexCRMObject->getPriority(),
'duedate' => date('Y-m-d', strtotime('+' . $createTaskPerfexCRMObject->getDuedate() . ' days')),
'invoice_id' => $createTaskPerfexCRMObject->getInvoiceId(),
];
if($leadId != '') {
$data = [
'name' => $taskName,
'description' => $taskDescription,
'milestone' => $milestoneId,
'startdate' => date('Y-m-d'),
'rel_type' => 'lead',
'rel_id' => $leadId,
'status' => $status,
'is_system_created' => 1,
'reference' => $reference,
'on_task_completion' => $on_task_completion,
'custom_fields' => $custom_fields,
'priority' => $priority,
'duedate' => date('Y-m-d', strtotime('+' . $duedate . ' days')),
];
if($createTaskPerfexCRMObject->getLeadId() != '') {
$data['rel_type'] = 'lead';
$data['rel_id'] = $createTaskPerfexCRMObject->getLeadId();
}
$response = Http::asForm()->withHeaders([
@@ -77,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){
@@ -17,7 +17,7 @@ class FetchesPerfexCRMTask
* @return null|object
* @throws MalformedRequestException
*/
public function execute(string $taskName, string $milestoneId, string $relType, string $relId) {
public function execute(string $taskName, string $milestoneId, string $relType, string $relId, string $invoiceId) {
try{
$data = [
'name' => $taskName,
@@ -30,6 +30,11 @@ class FetchesPerfexCRMTask
$data = array_merge($data, $newItem);
}
if($invoiceId != 0) {
$newItem = ['invoice_id' => $invoiceId ];
$data = array_merge($data, $newItem);
}
$response = Http::asForm()->withHeaders([
'authtoken' => config('perfexcrm.api_key')])
->post(config('perfexcrm.base_url').'/api/tasks/customsearch', $data);
@@ -39,7 +44,7 @@ class FetchesPerfexCRMTask
return (object) $data;
}else{
Helper::debugLoggerForPerfexCRM($response);
Helper::debugLogger($response);
return null;
}
}catch(\Exception $exception){
@@ -38,7 +38,7 @@ class UpdatesPerfexCRMCustomer
$data = $response->json();
return (object) $data;
}else{
Helper::debugLoggerForPerfexCRM($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){
@@ -31,7 +31,7 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic
private $createPaymentTransactionProcessor;
public function __construct(
FetchesTransaction $fetchesTransaction,
FetchesTransaction $fetchesTransaction,
CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
)
{
@@ -47,6 +47,20 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic
$payment_transaction = $this->createPaymentTransactionProcessor->execute($invoice_transaction, $payment_method , $request->input('bank_code'));
//cief todo: at exchange there is a transition step
// if(PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')] == PaymentMethodType::PAYMENT_GATEWAY){
// $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::PENDING_VERIFICATION);
// }
// if(config('perfexcrm.is_enabled') == 'true'){
// $this->transactionToPerfexCRMV2Processor->execute($transaction, $status);
// }
//To use
//ApprovalStatus::PENDING_VERIFICATION;
//use this to trigger $this->transactionToPerfexCRMV2Processor->execute > defineTasks > defineTasks_handlePendingVerificationStatus > definePaymentTasks
return $this->resourceResponse(new TransactionResource($payment_transaction));
}
}
@@ -5,9 +5,8 @@ namespace App\Classes\Modules\Transactions\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Transactions\Services\FetchesGroup;
use App\Classes\Modules\Transactions\Services\DeletesTransaction;
use App\Classes\Modules\Transactions\Services\DeletesGroup;
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Http\Resources\GroupResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -24,14 +23,11 @@ class DeleteGroupLogic extends AbstractControllerLogic
];
}
/** @var UpdatesTransactionStatus */
private $updatesTransactionStatus;
/** @var FetchesGroup */
private $fetchesGroup;
/** @var DeletesTransaction */
private $deletesTransaction;
/** @var DeletesGroup */
private $deletesGroup;
/**
* DeleteGroupLogic constructor.
@@ -39,11 +35,10 @@ class DeleteGroupLogic extends AbstractControllerLogic
* @param FetchesGroup $fetchesGroup
* @param DeletesTransaction $deletesTransaction
*/
public function __construct(updatesTransactionStatus $updatesTransactionStatus, FetchesGroup $fetchesGroup, DeletesTransaction $deletesTransaction)
public function __construct(FetchesGroup $fetchesGroup, DeletesGroup $deletesGroup)
{
$this->updatesTransactionStatus = $updatesTransactionStatus;
$this->fetchesGroup = $fetchesGroup;
$this->deletesTransaction = $deletesTransaction;
$this->deletesGroup = $deletesGroup;
}
/**
@@ -55,19 +50,9 @@ class DeleteGroupLogic extends AbstractControllerLogic
{
$group = $this->fetchesGroup->execute(['id' => $request->route('id')]);
$items = $group->transactions()->get();
$this->deletesGroup->execute($group);
foreach($items as $item) {
$bill = $item;
$payment = $bill->owner;
$group->transactions()->detach($bill->id);
$this->updatesTransactionStatus->execute($payment, ApprovalStatus::APPROVED);
$this->deletesTransaction->execute($bill);
}
$group->delete();
return $this->resourceResponse(new GroupResource($group));
return $this->response([]);
}
}
@@ -0,0 +1,56 @@
<?php
namespace App\Classes\Modules\Transactions\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Transactions\Services\ListsTransactions;
use App\Http\Resources\MappableTransactionWithDetailsResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Carbon\Carbon;
class ListMappableTransactionWithDetailsLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Transactions With Details',
'message' => 'You have successfully retrieved a list of transactions'
];
}
/** @var ListsTransactions */
private $listsTransactions;
/**
* ListTransactionsLogic constructor.
* @param ListsTransactions $listsTransactions
*/
public function __construct(ListsTransactions $listsTransactions)
{
$this->listsTransactions = $listsTransactions;
}
public function logic(Request $request) : JsonResponse
{
$filePath = storage_path('logs/list_mappable_transaction_with_details.log');
$textToAppend = Carbon::now()->format('[Y-m-d H:i:s]') . ' ' . $request->input('filters') . PHP_EOL;
file_put_contents($filePath, $textToAppend, FILE_APPEND);
$query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($request->input('filters')));
return $this->collectionResponse(MappableTransactionWithDetailsResource::collection($query));
}
}
@@ -0,0 +1,53 @@
<?php
namespace App\Classes\Modules\Transactions\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Transactions\Services\ListsTransactions;
use App\Http\Resources\BookingResource;
use App\Http\Resources\MappableTransactionResource;
use App\Http\Resources\TransactionResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ListMappableTransactionsLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Transactions',
'message' => 'You have successfully retrieved a list of transactions'
];
}
/** @var ListsTransactions */
private $listsTransactions;
/**
* ListTransactionsLogic constructor.
* @param ListsTransactions $listsTransactions
*/
public function __construct(ListsTransactions $listsTransactions)
{
$this->listsTransactions = $listsTransactions;
}
public function logic(Request $request) : JsonResponse
{
$query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($request->input('filters')));
return $this->collectionResponse(MappableTransactionResource::collection($query));
}
}
@@ -20,6 +20,7 @@ use App\Models\Wallet;
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
use Illuminate\Support\Facades\Log;
class CreatePaymentTransactionProcessor
{
@@ -38,7 +39,7 @@ class CreatePaymentTransactionProcessor
/** @var UpdatesWalletBalance */
private $updatesWalletBalance;
/** @var UpdateDoFromVTPortalProcessor */
private $updateDoFromVTPortalProcessor;
@@ -69,7 +70,7 @@ class CreatePaymentTransactionProcessor
UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor,
UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor,
UpdatesTransactionStatus $updatesTransactionStatus
)
)
{
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
$this->createsPaymentTransaction = $createsPaymentTransaction;
@@ -87,7 +88,8 @@ class CreatePaymentTransactionProcessor
public function execute(Transaction $invoice, $payment_method, $bank_code)
{
$amount = $invoice->amount;
$company_module = $invoice->owner()->first()->owner()->first()->companyModule()->first();
Log::info($invoice->owner);
$company_module = $invoice->owner->owner->companyModule()->first();
$approvalStatus = ApprovalStatus::PENDING_SUBMISSION;
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
$payment_reference = null;
@@ -97,12 +99,12 @@ class CreatePaymentTransactionProcessor
// create billplz transaction
$payment_method = PaymentMethodType::PAYMENT_GATEWAY;
$billPlzBill = $this->createsBillplzBill->execute(
$company_module->name,
$company_module->name,
(app()->environment(['production'])) ? $company_module->employees()->first()->email : 'uldvstar@gmail.com',
'This payment is for the invoice number . ' . $billNumber,
$amount,
$billNumber,
$bank_code,
$billNumber,
$bank_code,
true
);
@@ -117,7 +119,7 @@ class CreatePaymentTransactionProcessor
}
$walletPaymentBillNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
$transaction_object = new TransactionObject($walletPaymentBillNumber, TransactionType::PAYMENT, 1, $company_module->id, 1, PaymentMethodType::WALLET, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], '');
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
@@ -0,0 +1,19 @@
<?php
namespace App\Classes\Modules\Transactions\Services;
use App\Classes\General\Eloquent\AbstractDeleteRecord;
use App\Models\Group;
class DeletesGroup extends AbstractDeleteRecord
{
/**
* @param Group $model
* @return mixed
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(Group $model) {
return $this->handler($model);
}
}
@@ -0,0 +1,33 @@
<?php
namespace App\Classes\Modules\Transactions\Services;
use App\Classes\General\Eloquent\AbstractFetchRecord;
use Illuminate\Database\Eloquent\Builder;
use App\Models\Group;
class FetchesGroup extends AbstractFetchRecord
{
/** @var Transaction */
private $repository;
/**
* FetchesTransaction constructor.
* @param Transaction $repository
*/
public function __construct(Group $repository)
{
$this->repository = $repository;
}
/**
* @return Builder
*/
public function getRepository(): Builder
{
return $this->repository->newQuery();
}
}
@@ -4,20 +4,20 @@ namespace App\Classes\Modules\Transactions\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Models\Transaction;
use App\Classes\Modules\PerfexCRM\Processors\TransactionToPerfexCRMProcessor;
use App\Classes\Modules\PerfexCRM\Processors\TransactionToPerfexCRMV2Processor;
class UpdatesTransactionStatus extends AbstractUpdateRecord
{
/** @var TransactionToPerfexCRMProcessor */
private $transactionToPerfexCRMProcessor;
/** @var TransactionToPerfexCRMV2Processor */
private $transactionToPerfexCRMV2Processor;
/**
* UpdatesTransactionStatus constructor.
* @param TransactionToPerfexCRMProcessor $transactionToPerfexCRMProcessor
* @param TransactionToPerfexCRMProcessor $transactionToPerfexCRMV2Processor
*/
public function __construct(TransactionToPerfexCRMProcessor $transactionToPerfexCRMProcessor)
public function __construct(TransactionToPerfexCRMV2Processor $transactionToPerfexCRMV2Processor)
{
$this->transactionToPerfexCRMProcessor = $transactionToPerfexCRMProcessor;
$this->transactionToPerfexCRMV2Processor = $transactionToPerfexCRMV2Processor;
}
/**
@@ -33,7 +33,7 @@ class UpdatesTransactionStatus extends AbstractUpdateRecord
$result = $this->handler($model);
if(config('perfexcrm.is_enabled') == 'true'){
$this->transactionToPerfexCRMProcessor->execute($transaction, $status);
$this->transactionToPerfexCRMV2Processor->execute($transaction, $status);
}
return $result;
}
@@ -6,7 +6,6 @@ namespace App\Classes\Notifications;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Models\PackingList;
use App\Models\PasswordReset;
use App\Models\User;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Storage;
@@ -39,7 +38,7 @@ class InvoiceIssuedEmail extends AbstractEmail
return (new MailMessage)
->subject('Att: '.$this->user->name.' - Invoice for order no.'. $this->packingList->owner->reference)
->attach(Storage::disk('documents')->get($invoiceDocument->file->file_info->original->file), [
->attach(Storage::disk('documents')->get($invoiceDocument->first()->file->file_info->original->file), [
'as' => 'name.pdf',
'mime' => 'application/pdf',
])->view('emails.shipment.invoice', ['user' => $this->user, 'packingList' => $this->packingList]);
@@ -9,6 +9,7 @@ use App\Models\PackingList;
use App\Models\PasswordReset;
use App\Models\User;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Storage;
class ShipmentDepartureEmail extends AbstractEmail
{
@@ -42,7 +43,7 @@ class ShipmentDepartureEmail extends AbstractEmail
return (new MailMessage)
->subject('Your packages are on the way to malaysia - Invoice pending payment for order no.'. $this->packingList->owner->reference)
->attach(Storage::disk('documents')->get($invoiceDocument->file->file_info->original->file), [
->attach(Storage::disk('documents')->get($invoiceDocument->first()->file->file_info->original->file), [
'as' => 'name.pdf',
'mime' => 'application/pdf',
])->bcc(['email_test@cief-malaysia.com'])->view('emails.shipment.ETD', ['user' => $this->user, 'packingList' => $this->packingList]);
@@ -16,7 +16,9 @@ class PerfexCRMTasks
'department' => '',
'status' => PerfexCRMTaskStatus::COMPLETED,
'priority' => PerfexCRMTaskPriority::DEFAULT,
'duedate' => 0
'duedate' => 0,
'is_allow_multiple' => false,
'is_on_task_completion_update' => false
];
public const TASK_POST_PAYMENT_1 = [
@@ -35,7 +37,9 @@ class PerfexCRMTasks
'department' => 'Accounts',
'status' => PerfexCRMTaskStatus::IN_PROGRESS,
'priority' => PerfexCRMTaskPriority::HIGH,
'duedate' => 0
'duedate' => 0,
'is_allow_multiple' => false,
'is_on_task_completion_update' => false
];
public const TASK_POST_PAYMENT_2 = [
'name' => 'Approve Payment',
@@ -47,7 +51,9 @@ class PerfexCRMTasks
'department' => 'Accounts',
'status' => '',
'priority' => PerfexCRMTaskPriority::HIGH,
'duedate' => 0
'duedate' => 0,
'is_allow_multiple' => false,
'is_on_task_completion_update' => false
];
public const TASK_POST_PAYMENT_3 = [
'name' => 'Issue Shipping Autocount Invoince',
@@ -65,7 +71,9 @@ class PerfexCRMTasks
'department' => 'Accounts',
'status' => '',
'priority' => PerfexCRMTaskPriority::MEDIUM,
'duedate' => 1
'duedate' => 1,
'is_allow_multiple' => false,
'is_on_task_completion_update' => false
];
public const TASK_POST_PAYMENT_3_1 = [
'name' => 'Issue Shipping Autocount OR',
@@ -78,7 +86,9 @@ class PerfexCRMTasks
'department' => 'Accounts',
'status' => '',
'priority' => PerfexCRMTaskPriority::DEFAULT,
'duedate' => 0
'duedate' => 0,
'is_allow_multiple' => false,
'is_on_task_completion_update' => false
];
public const TASK_POST_PAYMENT_4 = [
'name' => 'Knockoff Invoice',
@@ -96,34 +106,11 @@ class PerfexCRMTasks
'department' => 'Accounts',
'status' => '',
'priority' => PerfexCRMTaskPriority::MEDIUM,
'duedate' => 1
'duedate' => 1,
'is_allow_multiple' => false,
'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
];
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
];
public const TASK_IDENTIFICATION_1 = [
@@ -142,6 +129,97 @@ class PerfexCRMTasks
'department' => 'Operations',
'status' => PerfexCRMTaskStatus::IN_PROGRESS,
'priority' => PerfexCRMTaskPriority::DEFAULT,
'duedate' => 0
'duedate' => 0,
'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;
}
@@ -77,7 +77,6 @@ class FixBillplzFailedCallbackPayment extends Command
{
ini_set('memory_limit', '-1');
$this->info(Carbon::now() . ' : Fix failled callback from billplz cron started.');
$this->outputArray = [];
$start = new Carbon();
@@ -85,6 +84,11 @@ class FixBillplzFailedCallbackPayment extends Command
$transactions = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
$totalTransactions = count($transactions);
if ($totalTransactions) {
$this->info(Carbon::now() . ' : Fix failled callback from billplz cron started.');
}
$counter = 1;
$totalAmount = 0;
foreach ($transactions as $transaction){
@@ -180,6 +184,9 @@ class FixBillplzFailedCallbackPayment extends Command
$end = new Carbon();
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
$this->info(Carbon::now() . ' : Done Billplz Failled Callback. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
if ($totalTransactions) {
$this->info(Carbon::now() . ' : Done Billplz Failled Callback. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
}
}
}
@@ -0,0 +1,77 @@
<?php
namespace App\Console\Commands;
use App\Models\Container;
use App\Models\ContainerPackingList;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class FixDuplicateContainerReference extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'fix-duplicate-container-reference';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Fix all duplicated container reference';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
ini_set('memory_limit', '-1');
$this->info(Carbon::now() . ' : Started.');
$start = new Carbon();
$duplicatedContainers = Container::select('reference', DB::raw('COUNT(reference) as count'))
->groupBy('reference')
->having('count', '>', 1)
->get();
foreach ($duplicatedContainers as $duplicatedContainer) {
$containers = Container::where('reference', $duplicatedContainer->reference)->get();
$containers = $containers->sortByDesc(function ($container) {
return $container->packingLists->count();
});
$firstContainer = $containers->shift();
foreach ($containers as $container) {
$firstContainer->packingLists()->syncWithoutDetaching($container->packingLists);
$container->packingLists()->detach();
$this->info('Deleted container ' . $container->id);
$container->delete();
}
}
$end = new Carbon();
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
$this->info(Carbon::now() . ' : Done. ElapsedTime: ' . $elapsedTime);
}
}
+88
View File
@@ -0,0 +1,88 @@
<?php
namespace App\Console\Commands;
use App\Models\PackingList;
use Carbon\Carbon;
use Illuminate\Console\Command;
class FixPackingList extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'fix-packinglist';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Fix PackingList';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$packingLists = PackingList::whereDoesntHave('packages')->get();
if ($packingLists->isNotEmpty()) {
$this->info(Carbon::now() . ' : ' . $this->description . ' cron started.');
$start = Carbon::now();
$restoredPackagesCount = 0;
$restoredPackagesIds = [];
// Eager loading packages for all packing lists
$packingLists->load(['packages' => function ($query) {
$query->onlyTrashed();
}]);
foreach ($packingLists as $packingList) {
$deletedPackages = $packingList->packages->filter(function ($package) use ($restoredPackagesIds) {
// Filter out packages that have already been restored
return !in_array($package->id, $restoredPackagesIds);
});
if ($deletedPackages->isNotEmpty()) {
$groupedPackages = $deletedPackages->groupBy(function ($item) {
return $item->only(['type', 'description', 'width', 'height', 'length', 'weight', 'quantity']);
});
foreach ($groupedPackages as $group) {
$latestPackage = $group->sortByDesc('created_at')->first();
// Check if the package ID is already restored before attempting to restore it
if (!in_array($latestPackage->id, $restoredPackagesIds)) {
$latestPackage->restore();
$this->info('Package ID: ' . $latestPackage->id . ' has been restored');
$restoredPackagesCount++;
$restoredPackagesIds[] = $latestPackage->id;
}
}
}
}
$end = Carbon::now();
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
$this->info(Carbon::now() . ' : Done ' . $this->description . '. ElapsedTime: ' . $elapsedTime . '.');
$this->info('Restored Packages Count: ' . $restoredPackagesCount);
}
}
}
+16 -6
View File
@@ -34,14 +34,24 @@ class Kernel extends ConsoleKernel
->appendOutputTo (storage_path().'/logs/curlvt.log');
$schedule->command('command:curlYdOrderListCommand')
->cron('30 9-18/3 * * *')
->cron('0 9-18/3 * * *')
->withoutOverlapping()
->appendOutputTo (storage_path().'/logs/curlyd.log');
$schedule->command('command:curlYdOrderListCommand')
->cron('0 9 * * *')
$schedule->command('fix-packinglist')
->cron('30 9-18/3 * * *')
->withoutOverlapping()
->appendOutputTo (storage_path().'/logs/departure_email.log');
->appendOutputTo (storage_path().'/logs/fix_packinglist.log');
// $schedule->command('command:curlYdOrderListCommand')
// ->cron('0 9 * * *')
// ->withoutOverlapping()
// ->appendOutputTo (storage_path().'/logs/departure_email.log');
$schedule->command('fix-duplicate-container-reference')
->cron('0 1 * * *')
->withoutOverlapping()
->appendOutputTo (storage_path().'/logs/fix_duplicate_container_reference.log');
$schedule->command('invoice:generate')
->hourly()
@@ -49,9 +59,9 @@ class Kernel extends ConsoleKernel
->appendOutputTo (storage_path().'/logs/auto_generate_invoice.log');
$schedule->command('billplz-failed-callback:fix')
->dailyAt('00:00')
->hourly()
->withoutOverlapping()
->appendOutputTo (storage_path().'/logs/dix_failed_callback_from_billplz.log');
->appendOutputTo (storage_path().'/logs/fix_failed_callback_from_billplz.log');
}
/**
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Controllers\PackingLists;
use App\Classes\Modules\PackingLists\ControllersLogic\CreateWarehouseTransportLogic;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class CreateWarehouseTransportController
{
/**
* @param Request $request
* @param CreateContainerLogic $logic
* @return JsonResponse
*/
public function create(Request $request, CreateWarehouseTransportLogic $logic): JsonResponse {
return $logic->execute($request);
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Controllers\Transactions;
use App\Classes\Modules\Transactions\ControllersLogic\ListMappableTransactionWithDetailsLogic;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ListMappableTransactionWithDetailsController
{
/**
* @param Request $request
* @return JsonResponse
*/
public function list(Request $request, ListMappableTransactionWithDetailsLogic $logic) : JsonResponse {
return $logic->execute($request);
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Controllers\Transactions;
use App\Classes\Modules\Transactions\ControllersLogic\ListMappableTransactionsLogic;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ListMappableTransactionsController
{
/**
* @param Request $request
* @return JsonResponse
*/
public function list(Request $request, ListMappableTransactionsLogic $logic) : JsonResponse {
return $logic->execute($request);
}
}
@@ -50,6 +50,7 @@ class CompanyModuleResource extends JsonResource
'warehouseCharges' => array_key_exists($this->id, $segmentConstant) ? $segmentConstant[$this->id] : null,
'connections' => $this->connections,
'contact' => new ContactResource ($this->when($this->has('contacts'), $this->contacts->first())),
'debtor' => $this->company->debtor,
];
}
@@ -0,0 +1,42 @@
<?php
namespace App\Http\Resources;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\DocumentType;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Models\Order;
use App\Models\Transaction;
use App\Models\Wallet;
use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;
class MappableTransactionResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
$reference = null;
if($this->type === TransactionType::TOP_UP) {
$reference = $this->owner->owner->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
}
if($this->type === TransactionType::PAYMENT && $this->owner !== Wallet::class){
$reference = $this->owner->owner->owner->reference;
}
return [
'status' => 'success',
'system' => 'SHIPPING_PORTAL',
'type' => $this->type,
'owner_type' => $this->owner_type,
'owner_id'=> $this->id,
'owner_reference'=> $reference,
];
}
}
@@ -0,0 +1,69 @@
<?php
namespace App\Http\Resources;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
use Illuminate\Http\Resources\Json\JsonResource;
use Exception;
class MappableTransactionWithDetailsResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
$data = [
'status' => 'success',
'id' => $this->id,
'updated_at' => $this->updated_at,
'type' => $this->type,
'amount' => $this->amount,
'debtor_code' => null,
'order_reference' => null,
'bill_no' => null,
'marking' => null,
];
if ($this->type === TransactionType::PAYMENT) {
$order = $this->owner->owner->owner;
$data['order_reference'] = $order->reference;
$data['debtor_code'] = $order->companyModule->company->debtor;
} elseif (in_array($this->type, [TransactionType::GROUP_PAYMENT, TransactionType::TOP_UP])) {
$connection = $this->owner->owner->inviters()->withPivot('invitee_reference')->first();
$data['marking'] = $connection ? $connection->pivot->invitee_reference : '';
$data['bill_no'] = $this->bill_no;
} else {
$payments = $this->transactions()
->payments()->where('status', ApprovalStatus::APPROVED)
->get();
if ($payments->count()) {
$data['payment_transactions'] = $payments->map(function ($payment) {
$order = $payment->owner->owner->owner;
return [
'id' => $payment->id,
'updated_at' => $payment->updated_at,
'debtor_code' => $order->companyModule->company->debtor,
'order_reference' => $order->reference,
'bill_no' => null,
'type' => $payment->type,
'marking' => null,
'amount' => $payment->amount,
];
})->toArray();
} else {
$data['status'] = 'error';
$data['amount'] = 'Transaction Type not allowed';
$data['transaction_type'] = $this->type;
$data['payment_transactions'] = null;
}
}
return $data;
}
}
+6 -2
View File
@@ -5,7 +5,9 @@ namespace App\Http\Resources;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
use App\Classes\ValueObjects\Constants\PackingListType;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\TransportType;
use App\Models\Transaction;
use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;
@@ -19,6 +21,8 @@ class OrderResource extends JsonResource
*/
public function toArray($request)
{
$orderId = $this->id;
return [
'id' => $this->id,
'reference' => $this->reference,
@@ -46,8 +50,8 @@ class OrderResource extends JsonResource
'received_packages' => PackingListResource::collection($this->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('packages')->get()),
];
}),
'invoices' => $this->whenLoaded('packingLists', function() {
return TransactionResource::collection($this->transactions()->whereNotIn('transactions.status', [0, 1])->get());
'invoices' => $this->whenLoaded('packingLists', function() use ($orderId) {
return TransactionResource::collection($this->transactions()->whereNotIn('transactions.status', [0, 1])->where('transactions.type', TransactionType::SHIPPING_INVOICE)->get());
}),
'remarks' => RemarkResource::collection($this->remarks),
'created_at' => $this->created_at->format('d-m-Y')
+2 -1
View File
@@ -5,6 +5,7 @@ namespace App\Http\Resources;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
use App\Classes\ValueObjects\Constants\PackingListType;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\TransportType;
use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;
@@ -30,7 +31,7 @@ class OrderV2Resource extends JsonResource
'address' => new AddressResource($this->addresses()->where('status', '=', ApprovalStatus::APPROVED)->first()),
'address_change_request' => new AddressResource($this->addressesPendingVerification()->first()),
'invoices' => $this->whenLoaded('packingLists', function() {
return TransactionResource::collection($this->transactions()->whereNotIn('transactions.status', [0, 1])->get());
return TransactionResource::collection($this->transactions()->whereNotIn('transactions.status', [0, 1])->where('transactions.type', TransactionType::SHIPPING_INVOICE)->get());
}),
'remarks' => RemarkResource::collection($this->remarks),
'created_at' => $this->created_at->format('d-m-Y')
@@ -22,6 +22,7 @@ class TransactionResource extends JsonResource
{
return [
'id' => $this->id,
'owner_type' => $this->owner_type,
'order' => ($this->owner instanceof Transaction) ? new OrderResource($this->owner->owner->owner) : new OrderResource($this->owner->owner),
'documents' => DocumentResource::collection($this->documents),
'type' => (int) $this->type,
+4
View File
@@ -22,6 +22,10 @@ class Transaction extends AbstractModel implements Documentable, Transactionable
use SoftDeletes;
use LogData;
protected $casts = [
'type' => 'int'
];
protected $table = 'transactions';
public function owner(): morphTo
@@ -63,7 +63,7 @@
<div class="row" v-if="selectedInvoice.length">
<div class="col">
<div v-if="section === 'customerPendingPaymentInvoiceComponent'" class="btn btn-success btn-xl pointer m-t-10 w-100 requestModal" data-type="makePayment">Make Payment</div>
<div v-if="section === 'customerPaidInvoiceComponent'" class="btn btn-info btn-xl pointer m-t-10 w-100" @click='generateSummaryInvoice'>Generate Summary Invoice</div>
<div v-if="['customerPaidInvoiceComponent', 'customerPendingPaymentInvoiceComponent'].includes(section)" class="btn btn-info btn-xl pointer m-t-10 w-100" @click='generateSummaryInvoice'>Generate Summary Invoice</div>
</div>
</div>
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="makePayment">
@@ -1,38 +1,96 @@
<template>
<div class="row m-b-15 align-items-end">
<div class="col-auto">
<div class="row m-b-20">
<div class="col">
<div class="row">
<div class="col">
<div class="font-heading fs-10 muted all-caps">Name</div>
<div class="col-3">
<div class="row">
<div class="col">
<div class="font-heading fs-10 muted all-caps">Name</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="font-heading all-caps fs-11">{{ item.company_module.name }}</div>
</div>
</div>
</div>
<div class="col-2">
<div class="row">
<div class="col">
<div class="font-heading fs-10 muted all-caps">Reference</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="font-heading all-caps fs-11">{{ item.connection.invitee_reference }}</div>
</div>
</div>
</div>
<div class="col-auto">
<a :href="route('customer.profile', item.connection.invitee_reference)" target="_blank">
<button type="button" class="btn btn-xs btn-primary fs-11">Open in new tab</button>
</a>
</div>
</div>
<div class="row">
<div class="col">
<div class="font-heading all-caps fs-11">{{this.item.name}}</div>
<!-- company_module_contact -->
<div class="row m-b-10 m-t-5" v-if="item.company_module_contact">
<div class="col-auto">
<div class="row">
<div class="col">
<div class="font-heading fs-10 muted all-caps">Company Module Phone</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="font-heading all-caps fs-11">{{ item.company_module_contact.phone }}</div>
</div>
</div>
</div>
<div class="col-auto">
<div class="row">
<div class="col">
<div class="font-heading fs-10 muted all-caps">Company Module Email</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="font-heading all-caps fs-11">{{ item.company_module_contact.email }}</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-2 text-right">
<div class="row">
<div class="col">
<div class="font-heading fs-10 muted all-caps">Reference</div>
<!-- company_contact -->
<div class="row m-t-5" v-if="item.company_contact">
<div class="col-auto">
<div class="row">
<div class="col">
<div class="font-heading fs-10 muted all-caps">Company Phone</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="font-heading all-caps fs-11">{{ item.company_contact.phone }}</div>
</div>
</div>
</div>
<div class="col-auto">
<div class="row">
<div class="col">
<div class="font-heading fs-10 muted all-caps">Company Email</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="font-heading all-caps fs-11">{{ item.company_contact.email }}</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="font-heading all-caps fs-11">{{this.item.reference}}</div>
</div>
</div>
</div>
<div class="col-auto">
<a :href="route('customer.profile', this.item.reference)" target="_blank">
<button type="button" class="btn btn-xs btn-primary fs-11">Open in new tab</button>
</a>
</div>
</div>
</template>
<script>
import componentHandler from '../../../general/mixins/componentHandler';
import componentHandler from '../../../general/mixins/componentHandler';
export default {
mixins: [componentHandler]
}
@@ -84,7 +84,7 @@
<div class="col bg-master-lightest p-1 p-sm-4">
<div class="row tabsContainer tabContent" tab-name="pendingPayment">
<div class="col">
<customer-payment-billing-inner-component :endpoint="route('api.transaction.list')" section="customerPendingPaymentInvoiceComponent" :company_module_id="company_module_id" :options="{'per_page': 10, order_by: {column: 'id', DESC: true}, 'status_in': [2], 'receiver': company_module_id, 'type': 1, 'does_not_have_payment_status_in': [0,1] ,'does_not_have_group_transactions': 1}"></customer-payment-billing-inner-component>
<customer-payment-billing-inner-component :endpoint="route('api.transaction.list')" section="customerPendingPaymentInvoiceComponent" :company_module_id="company_module_id" :options="{'per_page': 10, order_by: {column: 'id', DESC: true}, 'status_in': [2], 'receiver': company_module_id, 'type': 1, 'does_not_have_payment_status_in': [0,1] ,'does_not_have_groups': 1}"></customer-payment-billing-inner-component>
</div>
</div>
<div class="row tabsContainer tabContent hide" tab-name="groupPaymentInProgress">
@@ -0,0 +1,78 @@
<template>
<div class="row bg-white padding-40 b-rad-lg" @keyup.enter="submitForm">
<div class="col">
<div class="row m-b-20">
<div class="col">
<h4>Create Warehouse Transport</h4>
</div>
</div>
<div class="row">
<div class="col">
<validation-wrapper-component class="m-b-10" :validator="$v.parameters.receive_date">
<label class="text-primary text-left">Receive Date</label>
<date-picker-component :parameters="parameters" v-model.lazy="parameters.receive_date"></date-picker-component>
</validation-wrapper-component>
</div>
</div>
<div class="row">
<div class="col">
<validation-wrapper-component class="m-b-10" :validator="$v.parameters.tracking">
<label class="text-primary text-left">Tracking Number</label>
<input type="text" class="form-control" v-model="parameters.tracking">
</validation-wrapper-component>
</div>
</div>
<div class="row">
<div class="col p-r-5">
<div class="btn btn-sm btn-default btn-block bg-master-lighter" data-dismiss="modal">Cancel</div>
</div>
<div class="col p-l-5">
<div class="btn btn-sm btn-block b-rad-none btn-success" @click="submitForm">Confrim</div>
</div>
</div>
</div>
</div>
</template>
<script>
import componentHandler from '../../../general/mixins/componentHandler';
import { required } from "vuelidate/lib/validators";
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
export default {
props: {
packinglistId: {
type: Number,
required: true
},
section: {
type: String,
required: true
},
},
data() {
return {
error: '',
parameters: {
receive_date: this.receive_date,
tracking: this.tracking,
}
};
},
validations: {
parameters: {
receive_date: {
required
},
tracking: {
},
}
},
methods: {
submitForm() {
this.submit(this.route('api.packing_list.warehouse_transport.create', this.packinglistId), 'post', this.section, true, true);
}
},
mixins: [componentHandler, ModalFormHandler]
}
</script>
@@ -0,0 +1,55 @@
<template>
<div class="row">
<div class="col">
<loading-component style="height: 300px; top: 0;" key="1" color="success" v-show="isLoading" ></loading-component>
<div class="row justify-content-center" v-show="!isLoading">
<div class="col">
<div class="row m-b-20">
<div class="col">
<h3 class="all-caps">Are you Sure?</h3>
<div class="fs-11">{{ contentText }}</div>
</div>
</div>
<div class="row">
<div class="col p-r-5">
<div class="btn btn-sm btn-default btn-block bg-master-lighter" data-dismiss="modal">Cancel</div>
</div>
<div class="col p-l-5">
<div class="btn btn-sm btn-block b-rad-none" :class="[{'btn-danger': modalType !== 'confirm'}, {'btn-success': modalType === 'confirm'}]" @click="submit(apiRoute, apiMethod, section, true, true)">{{ buttonText }}</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import componentHandler from '../../../general/mixins/componentHandler';
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
export default {
props: {
contentText: {
type: String,
required: true
},
modalType: {
type: String,
default: 'confirm'
},
buttonText: {
type: String,
default: 'Confirm'
},
apiRoute: {
type: String,
required: true
},
apiMethod: {
type: String,
required: true
},
},
mixins: [componentHandler, ModalFormHandler]
}
</script>
@@ -65,6 +65,23 @@
<p class="no-margin fs-10 all-caps">Billing Question</p>
<div>{{ latestComment ? latestComment.content : '' }} </div>
</div>
<div class="col-auto" v-if="invoice_status == 'Suspended Invoice'">
<div class="btn bg-grey no-border muted requestModal" data-type="deleteInvoiceFunction">
<i class="fa fa-trash"></i>
</div>
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="deleteInvoiceFunction">
<general-confirmation-form-component
contentText="Are you sure you want to delete this Invoice?"
modalType="delete"
buttonText="Delete"
class="text-center"
:apiRoute="route('api.transaction.delete', item.suspended_invoice.id)"
apiMethod="delete"
:section="section"
>
</general-confirmation-form-component>
</modal-component>
</div>
</div>
</div>
</div>
@@ -61,6 +61,16 @@
</div>
</div>
<div class="col-auto">
<div class="row text-center parentContainer m-b-10" v-if="['Pending Invoice'].includes(invoice_status) && !item.receive_packing_list" >
<div class="col">
<div class="requestModal pointer btn btn-primary btn-xs" data-type="addWarehouseTransport">
Add Warehouse Transport
</div>
<modal-component class="animate_animated animatefast animate_fadeIn" styleType="fill-in" type="addWarehouseTransport">
<create-warehouse-transport-form-component :packinglistId="item.id" :section="section"></create-warehouse-transport-form-component>
</modal-component>
</div>
</div>
<div class="row">
<div class="col">
<div class="btn bg-grey no-border" @click="expanded = !expanded" v-if="['Pending Approval', 'Pending Payment'].includes(invoice_status)">
@@ -20,14 +20,30 @@
<p class="no-margin fs-10 all-caps">Payment Date</p>
<div>{{ item.created_at }}</div>
</div>
<div class="col-auto pointer btn btn-success" v-if="item.payment_method == 5 && item.status != 2">
<a :href="route('billplz.bill', item.reference)">
<div class=" no-border h-100">
<i class="fa fa-repeat fs-20 text-white"></i>
</div>
</a>
<div class="col-auto pointer btn btn-success" v-if="item.payment_method == 5 && item.status != 2" @click="retryPayment()">
<div class=" no-border h-100">
<i class="fa fa-repeat fs-20 text-white"></i>
</div>
</div>
<div class="col-auto pointer btn btn-success requestModal pointer" v-if="item.payment_method == 1 && item.status != 2" data-type="paymentProofModal" @click="selectedID(item.id)">
<div class="col-auto requestModal" v-if="item.status != 2" data-type="deleteGroupTransaction">
<div class="btn bg-grey no-border">
<i class="fa fa-times"></i>
</div>
</div>
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="deleteGroupTransaction">
<general-confirmation-form-component
contentText="Are you sure you want to delete this Group Payment?"
modalType="delete"
buttonText="Delete"
class="text-center"
:apiRoute="route('api.transaction.group.delete', item.id)"
apiMethod="delete"
:section="section"
>
</general-confirmation-form-component>
</modal-component>
<!-- payment method 1 -->
<!-- <div class="col-auto pointer btn btn-success requestModal pointer" v-if="item.payment_method == 1 && item.status != 2" data-type="paymentProofModal" @click="selectedID(item.id)">
<div class="no-border h-100">
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="30" height="30" viewBox="0 0 172 172" style=" fill:#000000;"><defs><linearGradient x1="86" y1="70.76994" x2="86" y2="116.46013" gradientUnits="userSpaceOnUse" id="color-1_52139_gr1"><stop offset="0" stop-color="#ffffff"></stop><stop offset="1" stop-color="#ffffff"></stop></linearGradient><linearGradient x1="61.8125" y1="34.48869" x2="61.8125" y2="144.97181" gradientUnits="userSpaceOnUse" id="color-2_52139_gr2"><stop offset="0" stop-color="#ffffff"></stop><stop offset="1" stop-color="#ffffff"></stop></linearGradient><linearGradient x1="130.34375" y1="34.48869" x2="130.34375" y2="144.97181" gradientUnits="userSpaceOnUse" id="color-3_52139_gr3"><stop offset="0" stop-color="#ffffff"></stop><stop offset="1" stop-color="#ffffff"></stop></linearGradient><linearGradient x1="86" y1="32.25" x2="86" y2="148.71013" gradientUnits="userSpaceOnUse" id="color-4_52139_gr4"><stop offset="0" stop-color="#ffffff"></stop><stop offset="1" stop-color="#ffffff"></stop></linearGradient></defs><g fill="none" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><path d="M0,172v-172h172v172z" fill="none"></path><g><path d="M102.45825,99.43213h-5.70825c-1.4835,0 -2.6875,1.16637 -2.6875,2.65256v8.10013c0,1.48081 -1.19862,2.68481 -2.67944,2.68481h-10.76612c-1.48081,0 -2.67944,-1.204 -2.67944,-2.68481v-8.10013c0,-1.48619 -1.204,-2.65256 -2.6875,-2.65256h-5.70825c-1.93769,0 -3.04225,-2.39188 -1.88125,-4.05275l14.577,-20.855c1.8275,-2.61494 5.69481,-2.61763 7.52231,-0.00538l14.577,20.86306c1.16369,1.66088 0.05644,4.05006 -1.87856,4.05006z" fill="url(#color-1_52139_gr1)"></path><path d="M51.0625,67.1875h5.375c0,-8.0625 7.23206,-16.12231 16.125,-16.12231v-5.375c-11.85456,0 -21.5,10.74731 -21.5,21.49731z" fill="url(#color-2_52139_gr2)"></path><path d="M139.75,80.625c0,-10.75 -8.44144,-18.80981 -18.8125,-18.80981v5.375c7.40944,0 13.4375,5.37231 13.4375,13.43481z" fill="url(#color-3_52139_gr3)"></path><path d="M148.09738,92.27263c1.59369,-3.68188 2.40263,-7.59219 2.40263,-11.64494c0,-16.29969 -13.26281,-29.5625 -29.5625,-29.5625c-6.5145,0 -12.68769,2.08819 -17.78588,5.96088c-4.30269,-13.03438 -16.52006,-22.08587 -30.58912,-22.08587c-17.78319,0 -32.25,14.46681 -32.25,32.25c0,4.14681 0.16662,8.05981 1.42437,10.74731h-1.42437c-13.33806,0 -24.1875,10.84944 -24.1875,24.1875c0,11.56431 8.16194,21.24737 19.0275,23.62044c1.02394,6.39894 6.53869,11.31706 13.2225,11.31706h56.4375h16.125h5.375c6.54944,0 12.00238,-4.71388 13.18488,-10.92469c9.2235,-1.20131 16.37762,-9.08913 16.37762,-18.63513c0,-6.09256 -2.924,-11.72019 -7.77762,-15.23006zM126.3125,131.6875h-5.375h-16.125h-56.4375c-3.49912,0 -6.45538,-2.6875 -7.568,-5.375h93.0735c-1.11263,2.6875 -4.06888,5.375 -7.568,5.375zM137.0625,120.9375h-96.75c-10.37106,0 -18.8125,-8.44144 -18.8125,-18.8125c0,-10.37106 8.44144,-18.8125 18.8125,-18.8125h9.51375l-1.68506,-3.78131c-2.23063,-5.01488 -2.45369,-7.48737 -2.45369,-12.341c0,-14.81888 12.05613,-26.875 26.875,-26.875c13.01825,0 24.13106,9.29875 26.42619,22.11275l0.92719,5.17075l3.64962,-3.77325c4.60638,-4.76225 10.77687,-7.38525 17.372,-7.38525c13.33806,0 24.1875,10.84944 24.1875,24.1875c0,3.6765 -0.81431,7.21056 -2.37575,10.41944l-1.763,3.32713l2.37037,1.26044c4.40481,2.34081 7.14338,6.88806 7.14338,11.868c0,7.40944 -6.02806,13.43481 -13.4375,13.43481z" fill="url(#color-4_52139_gr4)"></path></g></g></svg>
</div>
@@ -36,7 +52,7 @@
<div class=" no-border h-100">
<i class="fa fa-repeat fs-20 text-white"></i>
</div>
</div>
</div> -->
<div class="col-auto">
<div class="btn bg-grey no-border" @click="expanded = !expanded">
<i class="fa" :class="{'fa-angle-down': !expanded, 'fa-angle-up': expanded}" ></i>
@@ -83,6 +99,9 @@
},
selectedID(id){
this.selected_id = id;
},
retryPayment(){
window.location.href = route('billplz.bill', this.item.reference);
}
},
computed: {
@@ -18,6 +18,12 @@
{{item.currency.short_code}} {{(Math.round((item.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
</div>
</div>
<div class="col-auto p-l-0">
<div class="font-heading fs-8 muted all-caps">Bill Number</div>
<div class="font-heading fs-10 bold">
{{ item.bill_no }}
</div>
</div>
</div>
<div class="row">
<div class="col">
@@ -27,6 +27,10 @@
<p class="no-margin fs-10 all-caps">Payment Date</p>
<div>{{ item.payment_history[item.payment_history.length-1].created_at }}</div>
</div>
<div class="col" v-if="['customerPaidInvoiceComponent', 'customerPaidGroupInvoiceComponent'].includes(section)">
<p class="no-margin fs-10 all-caps">Bill Number</p>
<div>{{ item.payment_history[item.payment_history.length-1].payment_reference }}</div>
</div>
<div class="col-auto">
<div v-if="item.documents.length">
<div v-for="file in item.documents[0].files" v-bind:key="file.id" class="col-auto no-padding">
@@ -1,5 +1,5 @@
<template>
<div class="row">
<div class="row" @keyup.enter="submitForm">
<div class="col">
<loading-component style="height: 50px; top: 0;" key="1" color="success" v-show="$store.getters.isLoading(section)"></loading-component>
<div class="row" v-show="!$store.getters.isLoading(section)">
@@ -37,6 +37,7 @@
</template>
<script>
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
import { required } from "vuelidate/lib/validators";
export default {
props: {
data:{
@@ -58,9 +59,7 @@
},
validations: {
parameters: {
content: {
required: false
}
content:{ required },
}
},
methods: {
@@ -26,6 +26,11 @@
<div class="font-heading fs-8 all-caps" >Submitted On: {{ item.updated_at }}</div>
</div>
</div>
<div class="row" v-if="$store.getters.isAdmin && item.bill_no">
<div class="col">
<div class="font-heading fs-8 all-caps m-t-5">Bill Number: <b>{{ item.bill_no }}</b></div>
</div>
</div>
</div>
<div class="col-auto bg-master-light">
<div class="row align-items-center h-100">
@@ -66,6 +71,11 @@
<div class="font-heading fs-8 all-caps" >Paid On: {{ item.updated_at }}</div>
</div>
</div>
<div class="row" v-if="$store.getters.isAdmin && item.bill_no">
<div class="col">
<div class="font-heading fs-8 all-caps m-t-5">Bill Number: <b>{{ item.bill_no }}</b></div>
</div>
</div>
</div>
<div class="col-auto pointer bg-success">
<a :href="route('billplz.bill', item.reference)" target="_blank">
@@ -111,6 +121,11 @@
<div class="font-heading fs-8 all-caps" >{{ item.payment_method === 5 ? 'Failed' : 'Rejected' }} On: {{ item.updated_at }}</div>
</div>
</div>
<div class="row" v-if="$store.getters.isAdmin && item.bill_no">
<div class="col">
<div class="font-heading fs-8 all-caps m-t-5">Bill Number: <b>{{ item.bill_no }}</b></div>
</div>
</div>
</div>
<div class="col-auto p-l-5 p-r-5 bg-success pointer" v-if="item.payment_method === 5">
<a :href="route('billplz.bill', item.reference)">
+3 -1
View File
@@ -63,7 +63,9 @@
@if($markingReturn && !$markingNotFound)
<div class="row m-t-20">
<div class="col m-l-30">
<user-company-component class="m-l-5" :data="{{$markingReturn}}"></user-company-component>
@foreach($markingReturn as $marking)
<user-company-component class="m-l-5" :data="{{$marking}}"></user-company-component>
@endforeach
</div>
</div>
@endif
File diff suppressed because one or more lines are too long
+4 -1
View File
@@ -4,6 +4,9 @@ use Illuminate\Support\Facades\Route;
Route::group(['middleware' => 'apipub', 'prefix' => 'v1', 'as' => 'apipub.'], function () {
Route::group(['middleware' => 'token.check'], function () {
Route::get('/list', 'Transactions\ListTransactionsController@list')->name('list');
Route::get('transactions/query', 'Transactions\ListTransactionsController@list')->name('transaction.list');
Route::get('transactions/mappable/query/with-details', 'Transactions\ListMappableTransactionWithDetailsController@list')->name('transaction.mappable.list.with_details');
Route::get('transactions/mappable/query', 'Transactions\ListMappableTransactionsController@list')->name('transaction.mappable.list');
Route::get('groups/query', 'Transactions\ListGroupsController@list')->name('group.list');
});
});
+1
View File
@@ -20,6 +20,7 @@ Route::group(['namespace' => 'PackingLists', 'as' => 'packing_list.', 'prefix' =
Route::put('/assign-remark/{id}', 'AssignPackingListRemarkController@create')->name('assign.remark');
Route::put('/assign-order/{id}/{reference}', 'AssignPackingListOrderController@assign')->name('assign.order');
Route::post('/{id}/warehouse-transport/create', 'CreateWarehouseTransportController@create')->name('warehouse_transport.create');
Route::group(['namespace' => 'Containers', 'prefix' => 'container', 'as' => 'container.'], function () {
Route::get('/{id}/show', 'FetchContainerController@fetch')->name('show');
+70 -73
View File
@@ -169,12 +169,27 @@ Route::post('/support', function (Request $request) {
if ($marking) {
$orderNo = null;
$markingReturn = CompanyConnection::where('invitee_reference', $marking)->get();
$markingReturn = CompanyConnection::where('invitee_reference', 'LIKE', '%'. $marking .'%')->get();
$dataReturn = [];
if (count($markingReturn)) {
$markingReturn = $markingReturn->first();
$markingReturn = $markingReturn->invitee;
$markingReturn->reference = $marking;
$markingReturn = $markingReturn->toJson();
$markingReturn = $markingReturn;
foreach ($markingReturn as $connection) {
$company_module = $connection->invitee;
$company_module_contact = $company_module->contacts()->first();
$company = $company_module->company;
$company_contact = $company->contacts()->first();
$dataReturn[] = json_encode(
[
'connection' => $connection ? $connection->toArray() : null,
'company_module' => $company_module ? $company_module->toArray() : null,
'company_module_contact' => $company_module_contact ? $company_module_contact->toArray() : null,
'company' => $company ? $company->toArray() : null,
'company_contact' => $company_contact ? $company_contact->toArray() : null,
]
);
}
} else {
$markingNotFound = true;
}
@@ -185,7 +200,7 @@ Route::post('/support', function (Request $request) {
'orderNo' => $orderNo,
'orderNoNotFound' => $orderNoNotFound,
'marking' => $marking,
'markingReturn' => $markingReturn,
'markingReturn' => $dataReturn,
'markingNotFound' => $markingNotFound,
]);
})->name('support');
@@ -246,6 +261,11 @@ Route::get('/customer/{marking}/payment-and-billing', function ($marking) {
return view('pages.customers.paymentsBilling', ['company_module_id' => $company_module_id]);
})->name('customer.payment-and-billing');
Route::get('/customer-invoices/{company_module_id}/payment-and-billing', function ($company_module_id) {
// todo-new: check company_module_id
return view('pages.customers.paymentsBilling', ['company_module_id' => $company_module_id]);
})->name('customer.payment-and-billing-by-company-module-id');
Route::get('/orders/refresh', function(Request $request){
$packingLists = PackingList::where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->has('containers')->get();
dd($packingLists);
@@ -354,13 +374,12 @@ Route::group(['prefix' => 'yd', 'as' => 'yd.'], function () {
});
Route::get('/yd', function (Request $request){
// $start = $request->input('start_date') ? Carbon::parse($request->input('start_date')): null;
// $end = $request->input('end_date') ? Carbon::parse($request->input('end_date')): null;
// (App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute($start, $end);
// (App()->make(\App\Classes\Modules\PackingLists\Processors\FetchPackingListsFromYdPortalProcessor::class))->execute($start, $end);
// (App()->make(\App\Classes\Modules\PackingLists\Processors\FetchContainersFromYdPortalProcessor::class))->execute();
// (App()->make(\App\Classes\Modules\PackingLists\Processors\FetchContainersUpdatesFromYdPortalProcessor::class))->execute();
// (App()->make(FetchDeliveryUpdatesFromYdPortalProcessor::class))->execute();
$start = $request->input('start_date') ? Carbon::parse($request->input('start_date')): null;
$end = $request->input('end_date') ? Carbon::parse($request->input('end_date')): null;
(App()->make(FetchPackingListsFromYdPortalProcessor::class))->execute($start, $end);
(App()->make(FetchContainersFromYdPortalProcessor::class))->execute();
(App()->make(FetchContainersUpdatesFromYdPortalProcessor::class))->execute();
(App()->make(FetchDeliveryUpdatesFromYdPortalProcessor::class))->execute();
// (App()->make(FetchPackingListFromVTPortalProcessor::class))->execute();
})->name('yd.refresh');
@@ -495,18 +514,21 @@ Route::get('/customer/summary/{year}/monthly', function ($year) {
});
Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{inactive_end?}/{with_cbm?}', function ($active_start, $active_end, $inactive_start=null, $inactive_end=null, $with_cbm = false) {
$activeCompanies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($inactive_start, $inactive_end) {
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($inactive_start, $inactive_end) {
return $query->where('drop_date', '>=', Carbon::parse($inactive_start))->where('drop_date', '<=', Carbon::parse($inactive_end)->addDay());
});
})->pluck('id');
Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{inactive_end?}/{with_cbm?}', function ($active_start, $active_end, $inactive_start = null, $inactive_end = null, $with_cbm = false) {
/* $activeCompanies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($inactive_start, $inactive_end) {
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($inactive_start, $inactive_end) {
return $query->where('drop_date', '>=', Carbon::parse($inactive_start))->where('drop_date', '<=', Carbon::parse($inactive_end)->addDay());
});
})->pluck('id');
$companies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($active_start, $active_end) {
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($active_start, $active_end) {
return $query->whereDate('drop_date', '>=', Carbon::parse($active_start))->whereDate('drop_date', '<=', Carbon::parse($active_end)->addDay());
});
})->whereNotIn('id', $activeCompanies)->get();*/
$companies = getActiveCompanies($inactive_start, $inactive_end, $active_start, $active_end);
$companies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($active_start, $active_end) {
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($active_start, $active_end) {
return $query->whereDate('drop_date', '>=', Carbon::parse($active_start))->whereDate('drop_date', '<=', Carbon::parse($active_end)->addDay());
});
})->whereNotIn('id', $activeCompanies)->get();
echo '<h4>List of customers active between <span style="color: green; font-weight: bold">'. Carbon::parse($active_start)->format('d/m/Y'). ' - '. Carbon::parse($active_end)->format('d/m/Y').'</span> & inactive between <span style="color: red; font-weight: bold">'. Carbon::parse($inactive_start)->format('d/m/Y'). ' - '. Carbon::parse($inactive_end)->format('d/m/Y').'</span></h4>';
echo '<table>
@@ -1043,7 +1065,7 @@ Route::get('/wallet/{marking}/details', function ($marking) {
Route::get('/wallet/audit', function (Request $request) {
$wallets = \App\Models\Wallet::all();
$i = 0;
$i = 0;
foreach ($wallets as $wallet){
$topups = 0;
$credit = 0;
@@ -1067,31 +1089,6 @@ Route::get('/wallet/audit', function (Request $request) {
}
});
Route::get('/billplz/audit', function (Request $request) {
$transactions = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::APPROVED])->get();
$i = 0;
$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']){
} else {
$transaction->status = ApprovalStatus::REJECTED;
$transaction->save();
$invoice = $transaction->owner;
$invoice->status = ApprovalStatus::APPROVED;
$totalAmount += $transaction->amount;
echo 'Order: '. $transaction->owner->owner->owner->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount . " </br></br>";
}
}else{
echo "billplz error</br>";
}
Route::get('/final-duplicated-invoice-debug', function(){
$duplicatedTransactions = Transaction::select(DB::raw('owner_type, owner_id, receiver, type, GROUP_CONCAT(id) as transaction_ids, COUNT(*) as count'))
->whereNotIn('status', [ApprovalStatus::REJECTED,ApprovalStatus::SUSPENDED,ApprovalStatus::EXPIRED])
@@ -1115,31 +1112,31 @@ Route::get('/final-duplicated-invoice-debug', function(){
<th style="border: 1px solid black" >Invoices</th>
</tr>';
foreach ($duplicatedTransactions as $transaction) {
$transactionIds = explode(',', $transaction->transaction_ids);
foreach ($duplicatedTransactions as $transaction) {
$transactionIds = explode(',', $transaction->transaction_ids);
$duplicatedInvoice = Transaction::whereIn('id', $transactionIds)->get();
$order_reference = $duplicatedInvoice->first()->owner->owner->reference ?? null;
$duplicatedInvoice = Transaction::whereIn('id', $transactionIds)->get();
if ($transaction->type == TransactionType::PAYMENT) {
$order_reference = $duplicatedInvoice->first()->owner->owner->owner->reference ?? null;
}
$order_reference = $duplicatedInvoice->first()->owner->owner->reference ?? null;
echo '<tr>';
// echo '<td style="border: 1px solid black">' . $transaction->owner_type . '</td>';
// echo '<td style="border: 1px solid black">' . $transaction->owner_id . '</td>';
echo '<td style="border: 1px solid black">' . $transaction->receiver . '</td>';
echo '<td style="border: 1px solid black">' . '<a target="_blank" href="'.route('order.show', $order_reference).'">'. $order_reference .'</a>' . '</td>';
echo '<td style="border: 1px solid black">' . $transactionType[$transaction->type] . '</td>';
echo '<td style="border: 1px solid black">' . count($transactionIds) . '</td>';
echo '<td style="border: 1px solid black; text-align: left">';
foreach ($duplicatedInvoice as $invoice) {
echo '<p>ID: ' . $invoice->id . '. Status: ' . $approvalStatusArray[$invoice->status] . '. Amount: ' . $invoice->amount . '</p>';
if ($transaction->type == TransactionType::PAYMENT) {
$order_reference = $duplicatedInvoice->first()->owner->owner->owner->reference ?? null;
}
echo'</td>';
echo '</tr>';
}
echo '</table>';
echo '<tr>';
// echo '<td style="border: 1px solid black">' . $transaction->owner_type . '</td>';
// echo '<td style="border: 1px solid black">' . $transaction->owner_id . '</td>';
echo '<td style="border: 1px solid black">' . $transaction->receiver . '</td>';
echo '<td style="border: 1px solid black">' . '<a target="_blank" href="'.route('order.show', $order_reference).'">'. $order_reference .'</a>' . '</td>';
echo '<td style="border: 1px solid black">' . $transactionType[$transaction->type] . '</td>';
echo '<td style="border: 1px solid black">' . count($transactionIds) . '</td>';
echo '<td style="border: 1px solid black; text-align: left">';
foreach ($duplicatedInvoice as $invoice) {
echo '<p>ID: ' . $invoice->id . '. Status: ' . $approvalStatusArray[$invoice->status] . '. Amount: ' . $invoice->amount . '</p>';
}
echo'</td>';
echo '</tr>';
}
echo '</table>';
});