mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b9c411c3d |
@@ -55,7 +55,3 @@ EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
|
||||
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
YD_API_CODE=''
|
||||
|
||||
PERFEXCRM_BASE_URL=""
|
||||
PERFEXCRM_API_KEY=""
|
||||
PERFEXCRM_IS_ENABLED="false"
|
||||
|
||||
@@ -21,6 +21,7 @@ gox.iml
|
||||
rebuild_docker.sh
|
||||
docker/*
|
||||
db/*
|
||||
docker-compose.yml
|
||||
package-lock.json
|
||||
public/*
|
||||
/public/*
|
||||
|
||||
@@ -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);
|
||||
})->whereHas('containers', function ($query){
|
||||
return $query->whereDate('loading_date', '>=', Carbon::parse('20-09-2022'));
|
||||
});
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMLeadProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMLead;
|
||||
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMLead;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateLeadPerfexCRMObject;
|
||||
|
||||
class CreatePerfexCRMCustomer implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var CreateLeadPerfexCRMObject */
|
||||
private $createLeadPerfexCRMObject;
|
||||
|
||||
/**
|
||||
* CreatePerfexCRMCustomer constructor.
|
||||
* @param CreateLeadPerfexCRMObject $createLeadPerfexCRMObject
|
||||
*/
|
||||
public function __construct(CreateLeadPerfexCRMObject $createLeadPerfexCRMObject)
|
||||
{
|
||||
$this->createLeadPerfexCRMObject = $createLeadPerfexCRMObject;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$lead = (App()->make(FetchesPerfexCRMLead::class))->execute($this->createLeadPerfexCRMObject->getEmail());
|
||||
if(!is_null($lead)){
|
||||
(App()->make(UpdatesPerfexCRMLead::class))->execute($lead, $this->createLeadPerfexCRMObject->getCompanyReference());
|
||||
}
|
||||
else{
|
||||
(App()->make(CreatePerfexCRMLeadProcessor::class))->execute($this->createLeadPerfexCRMObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMInvoiceProcessor;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Models\Transaction;
|
||||
|
||||
class CreatePerfexCRMInvoice implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var Transaction $transaction*/
|
||||
private $transaction;
|
||||
|
||||
/**
|
||||
* CreatePerfexCRMInvoice constructor.
|
||||
* @param Transaction $transaction
|
||||
*/
|
||||
public function __construct(Transaction $transaction)
|
||||
{
|
||||
$this->transaction = $transaction;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
(App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($this->transaction);
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMTaskProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMLead;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class CreatePerfexCRMSingleTask implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var FetchesPerfexCRMLead */
|
||||
private $fetchesPerfexCRMLead;
|
||||
|
||||
/** @var CreateTaskPerfexCRMObject */
|
||||
private $createTaskPerfexCRMObject;
|
||||
|
||||
/**
|
||||
* CreatePerfexCRMSingleTask constructor.
|
||||
* @param CreateTaskPerfexCRMObject $createTaskPerfexCRMObject
|
||||
*/
|
||||
public function __construct(CreateTaskPerfexCRMObject $createTaskPerfexCRMObject)
|
||||
{
|
||||
$this->createTaskPerfexCRMObject = $createTaskPerfexCRMObject;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$lead = (App()->make(FetchesPerfexCRMLead::class))->execute($this->createTaskPerfexCRMObject->getEmail());
|
||||
if(!is_null($lead))
|
||||
{
|
||||
$this->createTaskPerfexCRMObject->setLeadId($lead->id);
|
||||
(App()->make(CreatePerfexCRMTaskProcessor::class))->execute($this->createTaskPerfexCRMObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\InitializePerfexCRMProcessor;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InitialPerfexCRMObject;
|
||||
|
||||
class InitializePerfexCRM implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var InitialPerfexCRMObject */
|
||||
private $initialPerfexCRMObject;
|
||||
|
||||
/**
|
||||
* InitializePerfexCRM constructor.
|
||||
* @param InitialPerfexCRMObject $initialPerfexCRMObject
|
||||
*/
|
||||
public function __construct(InitialPerfexCRMObject $initialPerfexCRMObject)
|
||||
{
|
||||
$this->initialPerfexCRMObject = $initialPerfexCRMObject;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
(App()->make(InitializePerfexCRMProcessor::class))->execute($this->initialPerfexCRMObject);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||
|
||||
class UpdatePerfexCRM implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var UpdatePerfexCRMObject */
|
||||
private $updatePerfexCRMObject;
|
||||
|
||||
/**
|
||||
* UpdatePerfexCRM constructor.
|
||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||
*/
|
||||
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject)
|
||||
{
|
||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
(App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMInvoiceProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMInvoicePayment;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMCustomer;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMInvoice;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMProject;
|
||||
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMInvoice;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMInvoiceStatus;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var UpdatePerfexCRMInvoiceObject */
|
||||
private $updatePerfexCRMInvoiceObject;
|
||||
|
||||
/**
|
||||
* CreatePerfexCRMSingleTask constructor.
|
||||
* @param UpdatePerfexCRMInvoiceObject $createTaskPerfexCRMObject
|
||||
*/
|
||||
public function __construct(UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject)
|
||||
{
|
||||
$this->updatePerfexCRMInvoiceObject = $updatePerfexCRMInvoiceObject;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
//get the client id
|
||||
$customer = (App()->make(FetchesPerfexCRMCustomer::class))->execute($this->updatePerfexCRMInvoiceObject->getEmail());
|
||||
$transaction = $this->updatePerfexCRMInvoiceObject->getTransaction();
|
||||
|
||||
//get the invoice id
|
||||
$invoiceId = 0;
|
||||
$invoiceStatus = 0;
|
||||
$invoice = (App()->make(FetchesPerfexCRMInvoice::class))->execute($customer->userid,"INV-", $transaction->owner->bill_no);
|
||||
|
||||
if(is_null($invoice)){
|
||||
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction->owner, $this->updatePerfexCRMInvoiceObject->getIsPaid());
|
||||
$invoiceId = $result->payload['id'];
|
||||
}
|
||||
else{
|
||||
$invoiceId = $invoice->id;
|
||||
$invoiceStatus = $invoice->status;
|
||||
|
||||
//This only run when invoice already exist and the invoice does not have a PAID status
|
||||
if($invoiceStatus != PerfexCRMInvoiceStatus::PAID){
|
||||
//get project
|
||||
$projectId = "";
|
||||
$projectName = "";
|
||||
if($transaction->owner instanceof Transaction){
|
||||
$orderReference = $transaction->owner->owner->owner()->first()->reference;
|
||||
$packingListReference = $transaction->owner->owner->reference;
|
||||
$projectName = 'IZYIM | X1 Shipping | '.$orderReference.' | '.$packingListReference;
|
||||
$project = (App()->make(FetchesPerfexCRMProject::class))->execute($projectName, $customer->userid);
|
||||
if(!is_null($project)){
|
||||
$projectId = $project->id;
|
||||
}
|
||||
}
|
||||
|
||||
if($projectId == ""){
|
||||
Log::error(json_encode('UpdatePerfexCRMInvoice debug: '.$projectName));
|
||||
Log::error(json_encode($transaction->owner));
|
||||
}
|
||||
|
||||
//update invoice
|
||||
(App()->make(UpdatesPerfexCRMInvoice::class))->execute($invoice, $projectId);
|
||||
}
|
||||
}
|
||||
|
||||
//create invoice payment
|
||||
if($invoiceId != 0 && $invoiceStatus != PerfexCRMInvoiceStatus::PAID){
|
||||
|
||||
$date = Carbon::parse($transaction->created_at)->format('Y-m-d');
|
||||
|
||||
$invoicePaymentPerfexCRMObject = new InvoicePaymentPerfexCRMObject(
|
||||
$invoiceId,
|
||||
"$transaction->amount",
|
||||
$date,
|
||||
1,
|
||||
"",
|
||||
""
|
||||
);
|
||||
(App()->make(CreatesPerfexCRMInvoicePayment::class))->execute($invoicePaymentPerfexCRMObject);
|
||||
}
|
||||
}
|
||||
|
||||
public function delay($delay)
|
||||
{
|
||||
// Add delay in seconds to the job
|
||||
$this->delay = $delay;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -8,27 +8,23 @@ use App\Classes\General\Services\GeneratesInitials;
|
||||
use App\Classes\Modules\Accounts\Processors\AuthenticationProcessor;
|
||||
use App\Classes\Modules\Accounts\Processors\CreateUserProcessor;
|
||||
use App\Classes\Modules\Accounts\Processors\GenerateEmailVerificationAttemptProcessor;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyConnectionObject;
|
||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
||||
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
|
||||
use App\Classes\Modules\Companies\Processors\CreateCompanyModuleProcessor;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||
use App\Classes\Modules\Companies\Services\ApprovesCompanyConnection;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMLeadProcessor;
|
||||
use App\Classes\Modules\Documents\Processors\UploadIdentityDocumentProcessor;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyConnectionObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateLeadPerfexCRMObject;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\Documents\Processors\UploadIdentityDocumentProcessor;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
|
||||
use App\Classes\Jobs\CreatePerfexCRMCustomer;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\User;
|
||||
@@ -84,9 +80,6 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreatePerfexCRMLeadProcessor */
|
||||
private $createPerfexCRMLeadProcessor;
|
||||
|
||||
/**
|
||||
* CreateCustomerLogic constructor.
|
||||
* @param CreateUserProcessor $createUserProcessor
|
||||
@@ -100,9 +93,8 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
* @param AuthenticationProcessor $authenticationProcessor
|
||||
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor
|
||||
*/
|
||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, FetchesCompanyModule $fetchesCompanyModule, CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor)
|
||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, FetchesCompanyModule $fetchesCompanyModule)
|
||||
{
|
||||
$this->createUserProcessor = $createUserProcessor;
|
||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
||||
@@ -115,7 +107,6 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
$this->authenticationProcessor = $authenticationProcessor;
|
||||
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createPerfexCRMLeadProcessor = $createPerfexCRMLeadProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,18 +146,6 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
|
||||
$this->uploadIdentityDocumentProcessor->execute($request, $company);
|
||||
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
// $this->createPerfexCRMLeadProcessor->execute($request);
|
||||
$createLeadPerfexCRMObject = new CreateLeadPerfexCRMObject(
|
||||
$request->input('name'),
|
||||
$request->input('email'),
|
||||
$request->input('phone'),
|
||||
$request->input('type') === CompanyType::COMPANY_BUSINESS ? $request->input('company_name') : $request->input('name'),
|
||||
$connection->invitee_reference
|
||||
);
|
||||
CreatePerfexCRMCustomer::dispatch($createLeadPerfexCRMObject);
|
||||
}
|
||||
|
||||
// $this->generateEmailVerificationAttemptProcessor->execute($user);
|
||||
|
||||
return $this->response($this->authenticationProcessor->execute($request));
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use App\Models\CompanyModule;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateBillingAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Billing Address',
|
||||
'message' => 'You have successfully created a new Billing Address'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateAddress */
|
||||
private $canCreateAddress;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
|
||||
/** @var FetchesAddress */
|
||||
private $fetchesAddress;
|
||||
|
||||
/**
|
||||
* CreateAddressLogic constructor.
|
||||
* @param CanCreateAddress $canCreateAddress
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param CreatesAddress $createsAddress
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
*/
|
||||
public function __construct(CanCreateAddress $canCreateAddress, FetchesCompanyModule $fetchesCompanyModule, CreatesAddress $createsAddress, FetchesAddress $fetchesAddress)
|
||||
{
|
||||
$this->canCreateAddress = $canCreateAddress;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createsAddress = $createsAddress;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
{
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
||||
|
||||
if ($address->type !== AddressType::BILLING || $address->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
|
||||
// delete all current billing address
|
||||
Address::where('owner_type', CompanyModule::class)->where('owner_id', $request->input('company_module_id'))->where('type', AddressType::BILLING)->delete();
|
||||
|
||||
// create addrress
|
||||
$billingAddress = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode, AddressType::BILLING, ApprovalStatus::APPROVED, $address->reference);
|
||||
$this->canCreateAddress->passes($billingAddress);
|
||||
$this->createsAddress->execute($companyModule, $billingAddress);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,6 @@ use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -102,11 +101,9 @@ class CallbackBillplzLogic
|
||||
$token = Auth::fromUser(User::find(1));
|
||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||
$this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED);
|
||||
|
||||
$totalPaidAmount = $invoice->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
|
||||
|
||||
if(($invoice->amount - $totalPaidAmount) < 0.01) {
|
||||
if(($invoice->amount - $transaction->amount) < 0.01) {
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompany;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use App\Http\Resources\CompanyResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyTypeLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Company Type',
|
||||
'message' => 'You have successfully updated the Company Tyoe'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateCompany */
|
||||
private $canUpdateCompany;
|
||||
|
||||
/** @var UpdatesCompany */
|
||||
private $updatesCompany;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/**
|
||||
* UpdateCompanyControllersLogic constructor.
|
||||
* @param CanUpdateCompany $canUpdateCompany
|
||||
* @param UpdatesCompany $updatesCompany
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
*/
|
||||
public function __construct(CanUpdateCompany $canUpdateCompany, UpdatesCompany $updatesCompany, FetchesCompany $fetchesCompany)
|
||||
{
|
||||
$this->canUpdateCompany = $canUpdateCompany;
|
||||
$this->updatesCompany = $updatesCompany;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$query = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new CompanyObject($query->name, $query->reference, $request->input('type'));
|
||||
|
||||
$this->canUpdateCompany->passes($object);
|
||||
|
||||
$query = $this->updatesCompany->execute($query, $object);
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($query));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,7 +7,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\PerfexCRM\Processors\NewLeadTaskToPerfexCRMProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
|
||||
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
||||
@@ -40,8 +39,6 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
/** @var GeneratesOrderNumber */
|
||||
private $generatesOrderNumber;
|
||||
|
||||
/** @var NewLeadTaskToPerfexCRMProcessor */
|
||||
private $newLeadTaskToPerfexCRMProcessor;
|
||||
/**
|
||||
* CreateOrderLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
@@ -49,24 +46,22 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
* @param CreateOrderProcessor $createOrderProcessor
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param GeneratesOrderNumber $generatesOrderNumber
|
||||
* @param NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber, NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor)
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->createOrderProcessor = $createOrderProcessor;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->generatesOrderNumber = $generatesOrderNumber;
|
||||
$this->newLeadTaskToPerfexCRMProcessor = $newLeadTaskToPerfexCRMProcessor;
|
||||
}
|
||||
|
||||
|
||||
public function logic(Request $request) : JsonResponse {
|
||||
|
||||
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->input('address_id')]);
|
||||
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]);
|
||||
@@ -81,10 +76,6 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
|
||||
$order = $this->createOrderProcessor->execute($company, $originWarehouse, $address, $this->generatesOrderNumber->execute());
|
||||
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
$this->newLeadTaskToPerfexCRMProcessor->execute($company);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
|
||||
use App\Classes\General\Interfaces\Packable;
|
||||
use App\Classes\Modules\PerfexCRM\Processors\PackingListToPerfexCRMProcessor;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\Services\CreatesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanCreatePackingList;
|
||||
@@ -26,20 +25,16 @@ class CreatePackingListProcessor
|
||||
/** @var CreatesPackingList */
|
||||
private $createsPackingList;
|
||||
|
||||
/** @var PackingListToPerfexCRMProcessor */
|
||||
private $packingListToPerfexCRMProcessor;
|
||||
|
||||
/**
|
||||
* CreatePackingListProcessor constructor.
|
||||
* @param CanCreatePackingList $canCreatePackingList
|
||||
* @param CreatesPackingList $createsPackingList
|
||||
* @param PackingListToPerfexCRMProcessor $packingListToPerfexCRMProcessor
|
||||
*/
|
||||
public function __construct(CanCreatePackingList $canCreatePackingList, CreatesPackingList $createsPackingList, PackingListToPerfexCRMProcessor $packingListToPerfexCRMProcessor)
|
||||
public function __construct(CanCreatePackingList $canCreatePackingList, CreatesPackingList $createsPackingList)
|
||||
{
|
||||
$this->canCreatePackingList = $canCreatePackingList;
|
||||
$this->createsPackingList = $createsPackingList;
|
||||
$this->packingListToPerfexCRMProcessor = $packingListToPerfexCRMProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,10 +59,6 @@ class CreatePackingListProcessor
|
||||
$object = new PackingListObject($object->getReference().'_01', $appointee_id, $type, ApprovalStatus::PENDING_SUBMISSION);
|
||||
$this->createsPackingList->execute($object, $packingList);
|
||||
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
$this->packingListToPerfexCRMProcessor->execute($packingList);
|
||||
}
|
||||
|
||||
return $packingList;
|
||||
}
|
||||
|
||||
|
||||
+60
-7
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromYDPortal;
|
||||
@@ -40,7 +38,6 @@ use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transport;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -50,6 +47,18 @@ class FetchContainersFromYdPortalProcessor
|
||||
/** @var FetchesDataFromYDPortal */
|
||||
private $fetchesDataFRomYDPortal;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/** @var UpdatesContractObligation */
|
||||
private $updatesContractObligations;
|
||||
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
/** @var CreatePackageProcessor */
|
||||
private $createPackageProcessor;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
@@ -59,31 +68,75 @@ class FetchContainersFromYdPortalProcessor
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreateContainerProcessor */
|
||||
private $createContainerProcessor;
|
||||
|
||||
/** @var CreatesContract */
|
||||
private $unityCreateContract;
|
||||
|
||||
/** @var AssignContractEntityProcessor */
|
||||
private $unityAssignContractEntity;
|
||||
|
||||
/** @var CreateContractEntityProcessor */
|
||||
private $unityCreateContractEntity;
|
||||
|
||||
/** @var CreatesStep */
|
||||
private $createsStep;
|
||||
|
||||
/** @var ActivateContractProcessor */
|
||||
private $unityActivateContract;
|
||||
|
||||
/**
|
||||
* FetchOrderListsFromYdPortalProcessor constructor.
|
||||
* @param FetchesDataFromYDPortal $fetchesDataFRomYDPortal
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
* @param UpdatesContractObligation $updatesContractObligations
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
* @param CreatePackageProcessor $createPackageProcessor
|
||||
* @param CreatesTransport $createsTransport
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param CreateContainerProcessor $createContainerProcessor
|
||||
* @param CreatesContract $unityCreateContract
|
||||
* @param AssignContractEntityProcessor $unityAssignContractEntity
|
||||
* @param CreateContractEntityProcessor $unityCreateContractEntity
|
||||
* @param CreatesStep $createsStep
|
||||
* @param ActivateContractProcessor $unityActivateContract
|
||||
*/
|
||||
public function __construct(FetchesDataFromYDPortal $fetchesDataFRomYDPortal, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule, FetchesContainer $fetchesContainer, CreateContainerProcessor $createContainerProcessor)
|
||||
public function __construct(FetchesDataFromYDPortal $fetchesDataFRomYDPortal, FetchesOrder $fetchesOrder, UpdatesContractObligation $updatesContractObligations, CreatePackingListProcessor $createPackingListProcessor, CreatePackageProcessor $createPackageProcessor, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule, FetchesContainer $fetchesContainer, FetchesPackingList $fetchesPackingList, FetchesCompanyModule $fetchesCompanyModule, CreateContainerProcessor $createContainerProcessor, CreatesContract $unityCreateContract, AssignContractEntityProcessor $unityAssignContractEntity, CreateContractEntityProcessor $unityCreateContractEntity, CreatesStep $createsStep, ActivateContractProcessor $unityActivateContract)
|
||||
{
|
||||
$this->fetchesDataFRomYDPortal = $fetchesDataFRomYDPortal;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
$this->updatesContractObligations = $updatesContractObligations;
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
$this->createPackageProcessor = $createPackageProcessor;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createContainerProcessor = $createContainerProcessor;
|
||||
$this->unityCreateContract = $unityCreateContract;
|
||||
$this->unityAssignContractEntity = $unityAssignContractEntity;
|
||||
$this->unityCreateContractEntity = $unityCreateContractEntity;
|
||||
$this->createsStep = $createsStep;
|
||||
$this->unityActivateContract = $unityActivateContract;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @return void
|
||||
* @throws MalformedRequestException
|
||||
* @throws AccessForbiddenException
|
||||
* @throws RequestValidationException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
|
||||
+1
-1
@@ -51,7 +51,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
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class CreateLeadPerfexCRMObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
/** @var string */
|
||||
private $email;
|
||||
|
||||
/** @var string */
|
||||
private $phone;
|
||||
|
||||
/** @var string */
|
||||
private $companyName;
|
||||
|
||||
/** @var string */
|
||||
private $companyReference;
|
||||
|
||||
public function __construct(string $name, string $email, string $phone, string $companyName, string $companyReference)
|
||||
{
|
||||
|
||||
$this->name = $name;
|
||||
$this->email = $email;
|
||||
$this->phone = $phone;
|
||||
$this->companyName = $companyName;
|
||||
$this->companyReference = $companyReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPhone(): string
|
||||
{
|
||||
return $this->phone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCompanyName(): string
|
||||
{
|
||||
return $this->companyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCompanyReference(): string
|
||||
{
|
||||
return $this->companyReference;
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class CreateTaskPerfexCRMObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $email;
|
||||
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
/** @var string */
|
||||
private $description;
|
||||
|
||||
/** @var string */
|
||||
private $leadId;
|
||||
|
||||
/** @var string */
|
||||
private $milestoneId;
|
||||
|
||||
/** @var string */
|
||||
private $projectId;
|
||||
|
||||
/** @var string */
|
||||
private $reference;
|
||||
|
||||
/** @var string */
|
||||
private $onTaskCompletion;
|
||||
|
||||
/** @var string */
|
||||
private $status;
|
||||
|
||||
/** @var string */
|
||||
private $department;
|
||||
|
||||
public function __construct(string $email, string $name, string $description, string $leadId, string $projectId, string $milestoneId, string $reference, string $onTaskCompletion, string $status, string $department)
|
||||
{
|
||||
$this->email = $email;
|
||||
$this->name = $name;
|
||||
$this->description = $description;
|
||||
$this->leadId = $leadId;
|
||||
$this->projectId = $projectId;
|
||||
$this->milestoneId = $milestoneId;
|
||||
$this->reference = $reference;
|
||||
$this->onTaskCompletion = $onTaskCompletion;
|
||||
$this->status = $status;
|
||||
$this->department = $department;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLeadId(): string
|
||||
{
|
||||
return $this->leadId;
|
||||
}
|
||||
|
||||
public function setLeadId(string $leadId)
|
||||
{
|
||||
$this->leadId = $leadId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProjectId(): string
|
||||
{
|
||||
return $this->projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMilestoneId(): string
|
||||
{
|
||||
return $this->milestoneId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReference(): string
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOnTaskCompletion(): string
|
||||
{
|
||||
return $this->onTaskCompletion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDepartment(): string
|
||||
{
|
||||
return $this->department;
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class CustomerContactObject implements DataTransferObject
|
||||
{
|
||||
/** @var int */
|
||||
private $customerId;
|
||||
|
||||
/** @var string */
|
||||
private $firstname;
|
||||
|
||||
/** @var string */
|
||||
private $lastname;
|
||||
|
||||
/** @var string */
|
||||
private $email;
|
||||
|
||||
/** @var string */
|
||||
private $password;
|
||||
|
||||
/** @var string */
|
||||
private $isPrimary;
|
||||
|
||||
/** @var string */
|
||||
private $sendSetPasswordEmail;
|
||||
|
||||
|
||||
public function __construct(string $customerId, string $firstname, string $lastname, string $email, string $password, string $isPrimary, string $sendSetPasswordEmail)
|
||||
{
|
||||
|
||||
$this->customerId = $customerId;
|
||||
$this->firstname = $firstname;
|
||||
$this->lastname = $lastname;
|
||||
$this->email = $email;
|
||||
$this->password = $password;
|
||||
$this->isPrimary = $isPrimary;
|
||||
$this->sendSetPasswordEmail = $sendSetPasswordEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCustomerId(): int
|
||||
{
|
||||
return $this->customerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFirstName(): string
|
||||
{
|
||||
return $this->firstname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLastName(): string
|
||||
{
|
||||
return $this->lastname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPassword(): string
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIsPrimary(): string
|
||||
{
|
||||
return $this->isPrimary;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSendSetPasswordEmail(): string
|
||||
{
|
||||
return $this->sendSetPasswordEmail;
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class InitialPerfexCRMObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $companyName;
|
||||
|
||||
/** @var string */
|
||||
private $companyReference;
|
||||
|
||||
/** @var string */
|
||||
private $contactName;
|
||||
|
||||
/** @var string */
|
||||
private $contactEmail;
|
||||
|
||||
/** @var string */
|
||||
private $bookingMarking;
|
||||
|
||||
/** @var string */
|
||||
private $projectName;
|
||||
|
||||
/** @var int */
|
||||
private $projectStatus;
|
||||
|
||||
/** @var array */
|
||||
private $milestoneNames;
|
||||
|
||||
/** @var array */
|
||||
private $taskNames;
|
||||
|
||||
|
||||
public function __construct(string $companyName, string $companyReference, string $contactName, string $contactEmail, string $bookingMarking, string $projectName, int $projectStatus, array $milestoneNames, array $taskNames)
|
||||
{
|
||||
|
||||
$this->companyName = $companyName;
|
||||
$this->companyReference = $companyReference;
|
||||
$this->contactName = $contactName;
|
||||
$this->contactEmail = $contactEmail;
|
||||
$this->bookingMarking = $bookingMarking;
|
||||
$this->projectName = $projectName;
|
||||
$this->projectStatus = $projectStatus;
|
||||
$this->milestoneNames = $milestoneNames;
|
||||
$this->taskNames = $taskNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCompanyName(): string
|
||||
{
|
||||
return $this->companyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCompanyReference(): string
|
||||
{
|
||||
return $this->companyReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContactName(): string
|
||||
{
|
||||
return $this->contactName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContactEmail(): string
|
||||
{
|
||||
return $this->contactEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBookingMarking(): string
|
||||
{
|
||||
return $this->bookingMarking;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProjectName(): string
|
||||
{
|
||||
return $this->projectName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProjectStatus(): int
|
||||
{
|
||||
return $this->projectStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getMilestoneNames(): array
|
||||
{
|
||||
return $this->milestoneNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getTaskNames(): array
|
||||
{
|
||||
return $this->taskNames;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class InvoicePaymentPerfexCRMObject implements DataTransferObject
|
||||
{
|
||||
/** @var int */
|
||||
private $invoiceId;
|
||||
|
||||
/** @var float */
|
||||
private $amount;
|
||||
|
||||
/** @var string */
|
||||
private $date;
|
||||
|
||||
/** @var int */
|
||||
private $paymentMode;
|
||||
|
||||
/** @var string */
|
||||
private $transactionId;
|
||||
|
||||
/** @var string */
|
||||
private $note;
|
||||
|
||||
|
||||
public function __construct(int $invoiceId, float $amount, string $date, int $paymentMode, string $transactionId, string $note)
|
||||
{
|
||||
$this->invoiceId = $invoiceId;
|
||||
$this->amount = $amount;
|
||||
$this->date = $date;
|
||||
$this->paymentMode = $paymentMode;
|
||||
$this->transactionId = $transactionId;
|
||||
$this->note = $note;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getInvoiceId(): int
|
||||
{
|
||||
return $this->invoiceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getAmount(): float
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDate(): string
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPaymentMode(): int
|
||||
{
|
||||
return $this->paymentMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTransactionId(): string
|
||||
{
|
||||
return $this->transactionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNote(): string
|
||||
{
|
||||
return $this->note;
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class InvoicePerfexCRMObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $clientId;
|
||||
|
||||
/** @var string */
|
||||
private $number;
|
||||
|
||||
/** @var string */
|
||||
private $date;
|
||||
|
||||
/** @var string */
|
||||
private $dueDate;
|
||||
|
||||
/** @var string */
|
||||
private $currency;
|
||||
|
||||
/** @var float */
|
||||
private $subTotal;
|
||||
|
||||
/** @var float */
|
||||
private $total;
|
||||
|
||||
/** @var string */
|
||||
private $billingStreet;
|
||||
|
||||
/** @var string */
|
||||
private $projectId;
|
||||
|
||||
/** @var array */
|
||||
private $allowedPaymentModes;
|
||||
|
||||
/** @var array */
|
||||
private $invoiceItems;
|
||||
|
||||
public function __construct(string $clientId, string $number, string $date, string $dueDate, string $currency, float $subTotal, float $total, string $billingStreet, string $projectId, array $allowedPaymentModes, array $invoiceItems)
|
||||
{
|
||||
$this->clientId = $clientId;
|
||||
$this->number = $number;
|
||||
$this->date = $date;
|
||||
$this->dueDate = $dueDate;
|
||||
$this->currency = $currency;
|
||||
$this->subTotal = $subTotal;
|
||||
$this->total = $total;
|
||||
$this->billingStreet = $billingStreet;
|
||||
$this->projectId = $projectId;
|
||||
$this->allowedPaymentModes = $allowedPaymentModes;
|
||||
$this->invoiceItems = $invoiceItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClientId(): string
|
||||
{
|
||||
return $this->clientId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNumber(): string
|
||||
{
|
||||
return $this->number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDate(): string
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDueDate(): string
|
||||
{
|
||||
return $this->dueDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrency(): string
|
||||
{
|
||||
return $this->currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getSubTotal(): float
|
||||
{
|
||||
return $this->subTotal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getTotal(): float
|
||||
{
|
||||
return $this->total;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBillingStreet(): string
|
||||
{
|
||||
return $this->billingStreet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProjectId(): string
|
||||
{
|
||||
return $this->projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAllowedPaymentModes(): array
|
||||
{
|
||||
return $this->allowedPaymentModes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getInvoiceItems(): array
|
||||
{
|
||||
return $this->invoiceItems;
|
||||
}
|
||||
}
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class InvoiceSingleItemPerfexCRMObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
public $description;
|
||||
|
||||
/** @var string */
|
||||
public $longDescription;
|
||||
|
||||
/** @var float */
|
||||
public $qty;
|
||||
|
||||
/** @var float */
|
||||
public $rate;
|
||||
|
||||
/** @var int */
|
||||
public $order;
|
||||
|
||||
/** @var string */
|
||||
public $unit;
|
||||
|
||||
public function __construct(string $description, string $longDescription, float $qty, float $rate, int $order, string $unit)
|
||||
{
|
||||
$this->description = $description;
|
||||
$this->longDescription = $longDescription;
|
||||
$this->qty = $qty;
|
||||
$this->rate = $rate;
|
||||
$this->order = $order;
|
||||
$this->unit = $unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLongDescription(): string
|
||||
{
|
||||
return $this->longDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getQty(): float
|
||||
{
|
||||
return $this->qty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getRate(): float
|
||||
{
|
||||
return $this->rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getOrder(): int
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUnit(): string
|
||||
{
|
||||
return $this->unit;
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Models\Transaction;
|
||||
|
||||
class UpdatePerfexCRMInvoiceObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $email;
|
||||
|
||||
/** @var Transaction */
|
||||
private $transaction;
|
||||
|
||||
/** @var bool */
|
||||
private $isPaid;
|
||||
|
||||
public function __construct(string $email, Transaction $transaction, bool $isPaid)
|
||||
{
|
||||
$this->email = $email;
|
||||
$this->transaction = $transaction;
|
||||
$this->isPaid = $isPaid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Transaction
|
||||
*/
|
||||
public function getTransaction(): Transaction
|
||||
{
|
||||
return $this->transaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getIsPaid(): bool
|
||||
{
|
||||
return $this->isPaid;
|
||||
}
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class UpdatePerfexCRMObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $companyName;
|
||||
|
||||
/** @var string */
|
||||
private $companyReference;
|
||||
|
||||
/** @var string */
|
||||
private $contactName;
|
||||
|
||||
/** @var string */
|
||||
private $contactEmail;
|
||||
|
||||
/** @var string */
|
||||
private $bookingMarking;
|
||||
|
||||
/** @var string */
|
||||
private $projectName;
|
||||
|
||||
/** @var int */
|
||||
private $projectStatus;
|
||||
|
||||
/** @var array */
|
||||
private $milestoneNames;
|
||||
|
||||
/** @var array */
|
||||
private $taskNames;
|
||||
|
||||
|
||||
public function __construct(string $companyName, string $companyReference, string $contactName, string $contactEmail, string $bookingMarking, string $projectName, int $projectStatus, array $milestoneNames, array $taskNames)
|
||||
{
|
||||
|
||||
$this->companyName = $companyName;
|
||||
$this->companyReference = $companyReference;
|
||||
$this->contactName = $contactName;
|
||||
$this->contactEmail = $contactEmail;
|
||||
$this->bookingMarking = $bookingMarking;
|
||||
$this->projectName = $projectName;
|
||||
$this->projectStatus = $projectStatus;
|
||||
$this->milestoneNames = $milestoneNames;
|
||||
$this->taskNames = $taskNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCompanyName(): string
|
||||
{
|
||||
return $this->companyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCompanyReference(): string
|
||||
{
|
||||
return $this->companyReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContactName(): string
|
||||
{
|
||||
return $this->contactName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContactEmail(): string
|
||||
{
|
||||
return $this->contactEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBookingMarking(): string
|
||||
{
|
||||
return $this->bookingMarking;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProjectName(): string
|
||||
{
|
||||
return $this->projectName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getProjectStatus(): int
|
||||
{
|
||||
return $this->projectStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getMilestoneNames(): array
|
||||
{
|
||||
return $this->milestoneNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getTaskNames(): array
|
||||
{
|
||||
return $this->taskNames;
|
||||
}
|
||||
}
|
||||
@@ -1,172 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
||||
|
||||
use App\Models\Transaction;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMInvoice;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMInvoicePayment;
|
||||
use App\Classes\Modules\PerfexCRM\Services\ConvertsPerfexCRMLeadToCustomer;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMProject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePerfexCRMObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoiceSingleItemPerfexCRMObject;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomerProject;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMProjectStatus;
|
||||
use App\Models\PackingList;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreatePerfexCRMInvoiceProcessor
|
||||
{
|
||||
|
||||
/** @var CreatesPerfexCRMInvoice */
|
||||
private $createsPerfexCRMInvoice;
|
||||
|
||||
/** @var CreatesPerfexCRMInvoicePayment */
|
||||
private $createsPerfexCRMInvoicePayment;
|
||||
|
||||
/** @var ConvertsPerfexCRMLeadToCustomer */
|
||||
private $convertsPerfexCRMLeadToCustomer;
|
||||
|
||||
/** @var FetchesPerfexCRMProject */
|
||||
private $fetchesPerfexCRMProject;
|
||||
|
||||
/** @var CreatesPerfexCRMCustomerProject */
|
||||
private $createsPerfexCRMCustomerProject;
|
||||
|
||||
/**
|
||||
* CreatePerfexCRMInvoiceProcessor constructor.
|
||||
* @param CreatesPerfexCRMInvoice $createsPerfexCRMInvoice
|
||||
*/
|
||||
public function __construct(CreatesPerfexCRMInvoice $createsPerfexCRMInvoice,
|
||||
CreatesPerfexCRMInvoicePayment $createsPerfexCRMInvoicePayment,
|
||||
ConvertsPerfexCRMLeadToCustomer $convertsPerfexCRMLeadToCustomer,
|
||||
FetchesPerfexCRMProject $fetchesPerfexCRMProject,
|
||||
CreatesPerfexCRMCustomerProject $createsPerfexCRMCustomerProject)
|
||||
{
|
||||
$this->createsPerfexCRMInvoice = $createsPerfexCRMInvoice;
|
||||
$this->createsPerfexCRMInvoicePayment = $createsPerfexCRMInvoicePayment;
|
||||
$this->convertsPerfexCRMLeadToCustomer = $convertsPerfexCRMLeadToCustomer;
|
||||
$this->fetchesPerfexCRMProject = $fetchesPerfexCRMProject;
|
||||
$this->createsPerfexCRMCustomerProject = $createsPerfexCRMCustomerProject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Transaction $transaction
|
||||
* @param bool $isPaid, default: false
|
||||
* @return null|object
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Transaction $transaction, bool $isPaid = false) {
|
||||
$clientId = "";
|
||||
$number = $transaction->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));
|
||||
}
|
||||
|
||||
$date = Carbon::parse($transaction->created_at)->format('Y-m-d');
|
||||
$dueDate = Carbon::parse($transaction->created_at)->addDays(6)->startOfDay()->format('Y-m-d');
|
||||
$currency = 1; //cief TODO: To look into Malaysia and Chinese currency
|
||||
$subTotal = 0.00;
|
||||
$total = 0.00;
|
||||
|
||||
$companyModule = $transaction->owner->owner->companyModule;
|
||||
$billingStreet = "";
|
||||
$addresses = $companyModule
|
||||
->addresses()
|
||||
->where('status', '=', \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED)
|
||||
->where('type', '=', \App\Classes\ValueObjects\Constants\AddressType::BILLING)->first();
|
||||
|
||||
$billingStreet = $billingStreet.$addresses->street_one;
|
||||
$billingStreet = $billingStreet.$addresses->street_two.',';
|
||||
$billingStreet = $billingStreet.$addresses->district()->first()->name.',';
|
||||
$billingStreet = $billingStreet.$addresses->postcode;
|
||||
$billingStreet = $billingStreet.$addresses->state()->first()->name.',';
|
||||
$billingStreet = $billingStreet.$addresses->country()->first()->name;
|
||||
|
||||
$allowedPaymentModes = [];
|
||||
$invoiceItems = [];
|
||||
|
||||
$employee = $companyModule->employees()->first();
|
||||
$email = $employee->email;
|
||||
|
||||
$result = $this->convertsPerfexCRMLeadToCustomer->execute($email);
|
||||
if(isset($result->payload)){
|
||||
$clientId = $result->payload['client_id'];
|
||||
}
|
||||
|
||||
//get project
|
||||
$projectId = ""; //Project only exist in CRM if the customer already made payment
|
||||
$projectName = "";
|
||||
if($isPaid){
|
||||
if($transaction->owner instanceof PackingList){
|
||||
$orderReference = $transaction->owner->owner->reference;
|
||||
$packingListReference = $transaction->owner->reference;
|
||||
$projectName = 'IZYIM | X1 Shipping | '.$orderReference.' | '.$packingListReference;
|
||||
$project = $this->fetchesPerfexCRMProject->execute($projectName, $clientId);
|
||||
if(!is_null($project)){
|
||||
$projectId = $project->id;
|
||||
}
|
||||
else{
|
||||
$result = $this->createsPerfexCRMCustomerProject->execute($projectName, PerfexCRMProjectStatus::NOT_STARTED, $clientId);
|
||||
if(isset($result->payload)){ //Here means project creation successful
|
||||
$projectId = $result->payload['project_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($projectId == ""){
|
||||
Log::error(json_encode('CreatePerfexCRMInvoiceProcessor debug: '.$projectName));
|
||||
Log::error(json_encode($transaction->owner));
|
||||
}
|
||||
}
|
||||
|
||||
//newitems
|
||||
foreach ($transaction->transactionDetails as $key => $transaction_detail){
|
||||
$order = $key + 1;
|
||||
$description = $transaction_detail->name;
|
||||
$quantity = $transaction_detail->quantity;
|
||||
$unitPrice = $transaction_detail->price;
|
||||
|
||||
$subTotal = $subTotal + $transaction_detail->amount;
|
||||
|
||||
//string $description, string $longDescription, int $qty, int $rate, int $order, string $unit
|
||||
$invoiceSingleItem = new InvoiceSingleItemPerfexCRMObject(
|
||||
$description,
|
||||
"",
|
||||
$quantity,
|
||||
$unitPrice,
|
||||
$order,
|
||||
""
|
||||
);
|
||||
array_push($invoiceItems, $invoiceSingleItem);
|
||||
}
|
||||
|
||||
$total = $transaction->amount;
|
||||
|
||||
//This setting is similar to Setup > Leads > Sources, Setup > Leads > Statuses
|
||||
//Can be found at Finance > Payment Modes
|
||||
array_push($allowedPaymentModes, 1, 2);
|
||||
$invoicePerfexCRMObject = new InvoicePerfexCRMObject(
|
||||
$clientId,
|
||||
$number,
|
||||
$date,
|
||||
$dueDate,
|
||||
$currency,
|
||||
$subTotal,
|
||||
$total,
|
||||
$billingStreet,
|
||||
$projectId,
|
||||
$allowedPaymentModes,
|
||||
$invoiceItems
|
||||
);
|
||||
|
||||
$result = $this->createsPerfexCRMInvoice->execute($invoicePerfexCRMObject);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
||||
|
||||
// use App\Classes\Modules\PerfexCRM\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMLead;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateLeadPerfexCRMObject;
|
||||
|
||||
class CreatePerfexCRMLeadProcessor
|
||||
{
|
||||
|
||||
/** @var CreatesPerfexCRMLead */
|
||||
private $createsPerfexCRMLead;
|
||||
|
||||
/**
|
||||
* CreatePerfexCRMLeadProcessor constructor.
|
||||
* @param CreatesPerfexCRMLead $createsPerfexCRMLead
|
||||
*/
|
||||
public function __construct(CreatesPerfexCRMLead $createsPerfexCRMLead)
|
||||
{
|
||||
$this->createsPerfexCRMLead = $createsPerfexCRMLead;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CreateLeadPerfexCRMObject $createLeadPerfexCRMObject
|
||||
* @return null|object
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(CreateLeadPerfexCRMObject $createLeadPerfexCRMObject) {
|
||||
return $this->createsPerfexCRMLead->execute($createLeadPerfexCRMObject);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMTask;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
|
||||
|
||||
class CreatePerfexCRMTaskProcessor
|
||||
{
|
||||
/** @var CreatesPerfexCRMTask */
|
||||
private $createsPerfexCRMTask;
|
||||
|
||||
/**
|
||||
* @param CreatesPerfexCRMTask $createsPerfexCRMTask
|
||||
*/
|
||||
public function __construct(CreatesPerfexCRMTask $createsPerfexCRMTask)
|
||||
{
|
||||
$this->createsPerfexCRMTask = $createsPerfexCRMTask;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CreateTaskPerfexCRMObject $createTaskPerfexCRMObject
|
||||
* @return true
|
||||
* @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(),
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,195 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Services\ConvertsPerfexCRMLeadToCustomer;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomerProject;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMMilestone;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMTask;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMProject;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMMilestone;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMTask;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomer;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomerContact;
|
||||
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMCustomer;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CustomerContactObject;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InitialPerfexCRMObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMMilestones;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTasks;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTaskStatus;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class InitializePerfexCRMProcessor
|
||||
{
|
||||
/** @var ConvertsPerfexCRMLeadToCustomer */
|
||||
private $convertsPerfexCRMLeadToCustomer;
|
||||
|
||||
/** @var CreatesPerfexCRMCustomerProject */
|
||||
private $createsPerfexCRMCustomerProject;
|
||||
|
||||
/** @var CreatesPerfexCRMMilestone */
|
||||
private $createsPerfexCRMMilestone;
|
||||
|
||||
/** @var CreatesPerfexCRMTask */
|
||||
private $createsPerfexCRMTask;
|
||||
|
||||
/** @var FetchesPerfexCRMProject */
|
||||
private $fetchesPerfexCRMProject;
|
||||
|
||||
/** @var FetchesPerfexCRMMilestone */
|
||||
private $fetchesPerfexCRMMilestone;
|
||||
|
||||
/** @var FetchesPerfexCRMTask */
|
||||
private $fetchesPerfexCRMTask;
|
||||
|
||||
/** @var CreatesPerfexCRMCustomer */
|
||||
private $createsPerfexCRMCustomer;
|
||||
|
||||
/** @var CreatesPerfexCRMCustomerContact */
|
||||
private $createsPerfexCRMCustomerContact;
|
||||
|
||||
/** @var UpdatesPerfexCRM */
|
||||
private $updatePerfexCRM;
|
||||
|
||||
/** @var UpdatesPerfexCRMCustomer */
|
||||
private $updatesPerfexCRMCustomer;
|
||||
|
||||
/**
|
||||
* @param ConvertsPerfexCRMLeadToCustomer $convertsPerfexCRMLeadToCustomer
|
||||
* @param CreatesPerfexCRMCustomerProject $createsPerfexCRMCustomerProject
|
||||
* @param CreatesPerfexCRMMilestone $createsPerfexCRMMilestone
|
||||
* @param CreatesPerfexCRMTask $createsPerfexCRMTask
|
||||
* @param FetchesPerfexCRMProject $fetchesPerfexCRMProject
|
||||
* @param FetchesPerfexCRMMilestone $fetchesPerfexCRMMilestone
|
||||
* @param FetchesPerfexCRMTask $fetchesPerfexCRMTask
|
||||
* @param CreatesPerfexCRMCustomer $createsPerfexCRMCustomer
|
||||
* @param CreatesPerfexCRMCustomerContact $createsPerfexCRMCustomerContact
|
||||
* @param UpdatesPerfexCRMCustomer $updatesPerfexCRMCustomer
|
||||
*/
|
||||
public function __construct(ConvertsPerfexCRMLeadToCustomer $convertsPerfexCRMLeadToCustomer,
|
||||
CreatesPerfexCRMCustomerProject $createsPerfexCRMCustomerProject,
|
||||
CreatesPerfexCRMMilestone $createsPerfexCRMMilestone,
|
||||
CreatesPerfexCRMTask $createsPerfexCRMTask,
|
||||
FetchesPerfexCRMProject $fetchesPerfexCRMProject,
|
||||
FetchesPerfexCRMMilestone $fetchesPerfexCRMMilestone,
|
||||
FetchesPerfexCRMTask $fetchesPerfexCRMTask,
|
||||
CreatesPerfexCRMCustomer $createsPerfexCRMCustomer,
|
||||
CreatesPerfexCRMCustomerContact $createsPerfexCRMCustomerContact,
|
||||
UpdatesPerfexCRMCustomer $updatesPerfexCRMCustomer)
|
||||
{
|
||||
$this->convertsPerfexCRMLeadToCustomer = $convertsPerfexCRMLeadToCustomer;
|
||||
$this->createsPerfexCRMCustomerProject = $createsPerfexCRMCustomerProject;
|
||||
$this->createsPerfexCRMMilestone = $createsPerfexCRMMilestone;
|
||||
$this->createsPerfexCRMTask = $createsPerfexCRMTask;
|
||||
$this->fetchesPerfexCRMProject = $fetchesPerfexCRMProject;
|
||||
$this->fetchesPerfexCRMMilestone = $fetchesPerfexCRMMilestone;
|
||||
$this->fetchesPerfexCRMTask = $fetchesPerfexCRMTask;
|
||||
$this->createsPerfexCRMCustomer = $createsPerfexCRMCustomer;
|
||||
$this->createsPerfexCRMCustomerContact = $createsPerfexCRMCustomerContact;
|
||||
$this->updatesPerfexCRMCustomer = $updatesPerfexCRMCustomer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InitialPerfexCRMObject $initialPerfexCRMObject
|
||||
* @return null|object
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(InitialPerfexCRMObject $initialPerfexCRMObject) {
|
||||
|
||||
// Customer has to exist first before Project can appear under it
|
||||
// Check with Perfex CRM, if this user (email) was previously a lead, should automatically now become a customer
|
||||
$crmCompany = $initialPerfexCRMObject->getCompanyName();
|
||||
$result = $this->convertsPerfexCRMLeadToCustomer->execute($initialPerfexCRMObject->getContactEmail());
|
||||
if(isset($result->payload)){
|
||||
$crmClientId = $result->payload['client_id'];
|
||||
if (isset($result->payload['company'])) {
|
||||
$crmCompany = $result->payload['company'];
|
||||
}
|
||||
}
|
||||
else{
|
||||
//if reach this point, this means this user is not a official customer nor is a lead in crm
|
||||
//Create Customer has 2 parts: Create Company (client), Create Contact
|
||||
$result = $this->createsPerfexCRMCustomer->execute($crmCompany);
|
||||
if(is_null($result)){
|
||||
$crmCompany = $crmCompany." 2";
|
||||
$result = $this->createsPerfexCRMCustomer->execute($crmCompany);
|
||||
}
|
||||
|
||||
$crmClientId = $result->payload['clientId'];
|
||||
|
||||
$customerContactObject = new CustomerContactObject(
|
||||
$crmClientId,
|
||||
$initialPerfexCRMObject->getContactName(),
|
||||
$initialPerfexCRMObject->getContactName(),
|
||||
$initialPerfexCRMObject->getContactEmail(),
|
||||
"pU^T@sC#9Q",
|
||||
"on",
|
||||
"on"
|
||||
);
|
||||
$result = $this->createsPerfexCRMCustomerContact->execute($customerContactObject);
|
||||
}
|
||||
|
||||
//Update custom fields to identify company reference from exchange or shipping portal
|
||||
$value_exists = false;
|
||||
if (isset($result->payload['customfields'])) {
|
||||
foreach ($result->payload['customfields'] as $element) {
|
||||
if ($element['value'] === $initialPerfexCRMObject->getCompanyReference()) {
|
||||
$value_exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!$value_exists);
|
||||
{
|
||||
$result = $this->updatesPerfexCRMCustomer->execute($crmClientId, $crmCompany, $initialPerfexCRMObject->getCompanyReference());
|
||||
}
|
||||
|
||||
// Get existing or create project, project has to exist first before milestone can appear under it
|
||||
$result = $this->createsPerfexCRMCustomerProject->execute($initialPerfexCRMObject->getProjectName(), $initialPerfexCRMObject->getProjectStatus(), $crmClientId);
|
||||
if(isset($result->payload)){ //Here means project creation successful
|
||||
$projectId = $result->payload['project_id'];
|
||||
}
|
||||
else{
|
||||
$projectId = $this->fetchesPerfexCRMProject->execute($initialPerfexCRMObject->getProjectName(), $crmClientId)->id;
|
||||
}
|
||||
|
||||
$tasks = $initialPerfexCRMObject->getTaskNames();
|
||||
if(count($tasks) > 0){
|
||||
|
||||
//Create tasks with milestone
|
||||
for($count=0; $count < count($tasks); $count++) {
|
||||
$milestoneId = 0; //By default milestoneId is 0, having this set at individual task is optional
|
||||
if($tasks[$count]['milestone'] != "") //Create milestone only if it is defined
|
||||
{
|
||||
// Get existing or create milestone, milestone has to exist first before task can appear under it
|
||||
$result = $this->createsPerfexCRMMilestone->execute($tasks[$count]['milestone'], $projectId, $count);
|
||||
if(isset($result->payload)){
|
||||
$milestoneId = $result->payload['milestone_id'];
|
||||
}
|
||||
else{
|
||||
$milestone = $this->fetchesPerfexCRMMilestone->execute($tasks[$count]['milestone'], $projectId);
|
||||
$array = json_decode(json_encode($milestone), true);
|
||||
$milestoneId = $array[0]['id'];
|
||||
}
|
||||
}
|
||||
|
||||
$taskStatus = PerfexCRMTaskStatus::NOT_STARTED;
|
||||
if($tasks[$count]['status'] != ''){
|
||||
$taskStatus = $tasks[$count]['status'];
|
||||
}
|
||||
|
||||
// Get existing or create task
|
||||
$result = $this->createsPerfexCRMTask->execute($tasks[$count]['name'], $tasks[$count]['description'], '', $milestoneId, $projectId, $tasks[$count]['reference'], $tasks[$count]['on_task_completion'],$tasks[$count]['department'], $taskStatus);
|
||||
if(is_null($result)){
|
||||
break; //Breaking the rest of the tasks in array assuming that they are all created as a batch previously
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
|
||||
use App\Classes\Jobs\CreatePerfexCRMSingleTask;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTasks;
|
||||
use App\Models\Company;
|
||||
|
||||
class NewLeadTaskToPerfexCRMProcessor
|
||||
{
|
||||
/**
|
||||
* @param Company $company
|
||||
* @return true
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Company $company)
|
||||
{
|
||||
$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']
|
||||
);
|
||||
|
||||
CreatePerfexCRMSingleTask::dispatch($createTaskPerfexCRMObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,60 +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\Jobs\UpdatePerfexCRM;
|
||||
use App\Models\PackingList;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMProjectStatus;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class PackingListToPerfexCRMProcessor
|
||||
{
|
||||
/**
|
||||
* @param PackingList $packingList
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(PackingList $packingList)
|
||||
{
|
||||
try {
|
||||
if($packingList->owner instanceof \App\Models\Order) {
|
||||
Log::error(json_encode($packingList));
|
||||
$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;
|
||||
|
||||
$updatePerfexCRMObject = new UpdatePerfexCRMObject(
|
||||
$companyName,
|
||||
$companyReference,
|
||||
$contactName,
|
||||
$contactEmail,
|
||||
"",
|
||||
$projectName,
|
||||
PerfexCRMProjectStatus::NOT_STARTED,
|
||||
[],
|
||||
[
|
||||
PerfexCRMTasks::TASK_LOADED_CONTAINER_1,
|
||||
PerfexCRMTasks::TASK_LOADED_CONTAINER_2,
|
||||
]
|
||||
);
|
||||
UpdatePerfexCRM::dispatch($updatePerfexCRMObject);
|
||||
}
|
||||
} catch (\Exception $exception){
|
||||
Log::error(json_encode('PackingListToPerfexCRMProcessor debug:'));
|
||||
Log::error(json_encode($packingList));
|
||||
Log::error($exception);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Processors\InitializePerfexCRMProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Services\Init;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMMilestones;
|
||||
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\Models\Transaction;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class TransactionToPerfexCRMProcessor
|
||||
{
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var UpdatePerfexCRMProcessor */
|
||||
private $updatePerfexCRMProcessor;
|
||||
|
||||
/** @var InitializePerfexCRMProcessor */
|
||||
private $initializePerfexCRMProcessor;
|
||||
|
||||
/**
|
||||
* TransactionToPerfexCRMProcessor constructor.
|
||||
* @param UpdatePerfexCRMProcessor $updatePerfexCRMProcessor
|
||||
* @param InitializePerfexCRMProcessor $initializePerfexCRMProcessor
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
*/
|
||||
public function __construct(UpdatePerfexCRMProcessor $updatePerfexCRMProcessor, InitializePerfexCRMProcessor $initializePerfexCRMProcessor, FetchesCompany $fetchesCompany)
|
||||
{
|
||||
$this->updatePerfexCRMProcessor = $updatePerfexCRMProcessor;
|
||||
$this->initializePerfexCRMProcessor = $initializePerfexCRMProcessor;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Transaction $model
|
||||
* @param int $status
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Transaction $model, int $status)
|
||||
{
|
||||
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,
|
||||
]
|
||||
);
|
||||
|
||||
UpdatePerfexCRM::dispatch($updatePerfexCRMObject);
|
||||
|
||||
$updatePerfexCRMInvoiceOject = new UpdatePerfexCRMInvoiceObject(
|
||||
$contactEmail,
|
||||
$model,
|
||||
true
|
||||
);
|
||||
UpdatePerfexCRMInvoice::dispatch($updatePerfexCRMInvoiceOject)->delay(6);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,206 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Services\ConvertsPerfexCRMLeadToCustomer;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomerProject;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMMilestone;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMTask;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMProject;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMMilestone;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMTask;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomer;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomerContact;
|
||||
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\ValueObjects\Constants\PerfexCRMTaskStatus;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMProjectStatus;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdatePerfexCRMProcessor
|
||||
{
|
||||
/** @var ConvertsPerfexCRMLeadToCustomer */
|
||||
private $convertsPerfexCRMLeadToCustomer;
|
||||
|
||||
/** @var CreatesPerfexCRMCustomerProject */
|
||||
private $createsPerfexCRMCustomerProject;
|
||||
|
||||
/** @var CreatesPerfexCRMMilestone */
|
||||
private $createsPerfexCRMMilestone;
|
||||
|
||||
/** @var CreatesPerfexCRMTask */
|
||||
private $createsPerfexCRMTask;
|
||||
|
||||
/** @var FetchesPerfexCRMProject */
|
||||
private $fetchesPerfexCRMProject;
|
||||
|
||||
/** @var FetchesPerfexCRMMilestone */
|
||||
private $fetchesPerfexCRMMilestone;
|
||||
|
||||
/** @var FetchesPerfexCRMTask */
|
||||
private $fetchesPerfexCRMTask;
|
||||
|
||||
/** @var CreatesPerfexCRMCustomer */
|
||||
private $createsPerfexCRMCustomer;
|
||||
|
||||
/** @var CreatesPerfexCRMCustomerContact */
|
||||
private $createsPerfexCRMCustomerContact;
|
||||
|
||||
/** @var UpdatesPerfexCRM */
|
||||
private $updatePerfexCRM;
|
||||
|
||||
/** @var UpdatesPerfexCRMCustomer */
|
||||
private $updatesPerfexCRMCustomer;
|
||||
|
||||
/** @var UpdatesPerfexCRMProject */
|
||||
private $updatesPerfexCRMProject;
|
||||
|
||||
/**
|
||||
* @param ConvertsPerfexCRMLeadToCustomer $convertsPerfexCRMLeadToCustomer
|
||||
* @param CreatesPerfexCRMCustomerProject $createsPerfexCRMCustomerProject
|
||||
* @param CreatesPerfexCRMMilestone $createsPerfexCRMMilestone
|
||||
* @param CreatesPerfexCRMTask $createsPerfexCRMTask
|
||||
* @param FetchesPerfexCRMProject $fetchesPerfexCRMProject
|
||||
* @param FetchesPerfexCRMMilestone $fetchesPerfexCRMMilestone
|
||||
* @param FetchesPerfexCRMTask $fetchesPerfexCRMTask
|
||||
* @param CreatesPerfexCRMCustomer $createsPerfexCRMCustomer
|
||||
* @param CreatesPerfexCRMCustomerContact $createsPerfexCRMCustomerContact
|
||||
* @param UpdatesPerfexCRMCustomer $updatesPerfexCRMCustomer
|
||||
* @param UpdatesPerfexCRMProject $updatesPerfexCRMProject
|
||||
*/
|
||||
public function __construct(ConvertsPerfexCRMLeadToCustomer $convertsPerfexCRMLeadToCustomer,
|
||||
CreatesPerfexCRMCustomerProject $createsPerfexCRMCustomerProject,
|
||||
CreatesPerfexCRMMilestone $createsPerfexCRMMilestone,
|
||||
CreatesPerfexCRMTask $createsPerfexCRMTask,
|
||||
FetchesPerfexCRMProject $fetchesPerfexCRMProject,
|
||||
FetchesPerfexCRMMilestone $fetchesPerfexCRMMilestone,
|
||||
FetchesPerfexCRMTask $fetchesPerfexCRMTask,
|
||||
CreatesPerfexCRMCustomer $createsPerfexCRMCustomer,
|
||||
CreatesPerfexCRMCustomerContact $createsPerfexCRMCustomerContact,
|
||||
UpdatesPerfexCRMCustomer $updatesPerfexCRMCustomer,
|
||||
UpdatesPerfexCRMProject $updatesPerfexCRMProject)
|
||||
{
|
||||
$this->convertsPerfexCRMLeadToCustomer = $convertsPerfexCRMLeadToCustomer;
|
||||
$this->createsPerfexCRMCustomerProject = $createsPerfexCRMCustomerProject;
|
||||
$this->createsPerfexCRMMilestone = $createsPerfexCRMMilestone;
|
||||
$this->createsPerfexCRMTask = $createsPerfexCRMTask;
|
||||
$this->fetchesPerfexCRMProject = $fetchesPerfexCRMProject;
|
||||
$this->fetchesPerfexCRMMilestone = $fetchesPerfexCRMMilestone;
|
||||
$this->fetchesPerfexCRMTask = $fetchesPerfexCRMTask;
|
||||
$this->createsPerfexCRMCustomer = $createsPerfexCRMCustomer;
|
||||
$this->createsPerfexCRMCustomerContact = $createsPerfexCRMCustomerContact;
|
||||
$this->updatesPerfexCRMCustomer = $updatesPerfexCRMCustomer;
|
||||
$this->updatesPerfexCRMProject = $updatesPerfexCRMProject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||
* @return null|object
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(UpdatePerfexCRMObject $updatePerfexCRMObject) {
|
||||
|
||||
// Customer has to exist first before Project can appear under it
|
||||
// Check with Perfex CRM, if this user (email) was previously a lead, should automatically now become a customer
|
||||
$crmCompany = $updatePerfexCRMObject->getCompanyName();
|
||||
$result = $this->convertsPerfexCRMLeadToCustomer->execute($updatePerfexCRMObject->getContactEmail());
|
||||
if(isset($result->payload)){
|
||||
$crmClientId = $result->payload['client_id'];
|
||||
if (isset($result->payload['company'])) {
|
||||
$crmCompany = $result->payload['company'];
|
||||
}
|
||||
}
|
||||
else{
|
||||
//if reach this point, this means this user is not a official customer nor is a lead in crm
|
||||
//Create Customer has 2 parts: Create Company (client), Create Contact
|
||||
$result = $this->createsPerfexCRMCustomer->execute($crmCompany);
|
||||
if(is_null($result)){
|
||||
$crmCompany = $crmCompany." 2";
|
||||
$result = $this->createsPerfexCRMCustomer->execute($crmCompany);
|
||||
}
|
||||
|
||||
$crmClientId = $result->payload['clientId'];
|
||||
|
||||
$customerContactObject = new CustomerContactObject(
|
||||
$crmClientId,
|
||||
$updatePerfexCRMObject->getContactName(),
|
||||
$updatePerfexCRMObject->getContactName(),
|
||||
$updatePerfexCRMObject->getContactEmail(),
|
||||
"pU^T@sC#9Q",
|
||||
"on",
|
||||
"on"
|
||||
);
|
||||
$result = $this->createsPerfexCRMCustomerContact->execute($customerContactObject);
|
||||
}
|
||||
|
||||
//Update custom fields to identify company reference from exchange or shipping portal
|
||||
$value_exists = false;
|
||||
if (isset($result->payload['customfields'])) {
|
||||
foreach ($result->payload['customfields'] as $element) {
|
||||
if ($element['value'] === $updatePerfexCRMObject->getCompanyReference()) {
|
||||
$value_exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!$value_exists);
|
||||
{
|
||||
$result = $this->updatesPerfexCRMCustomer->execute($crmClientId, $crmCompany, $updatePerfexCRMObject->getCompanyReference());
|
||||
}
|
||||
|
||||
// Get existing or create project, project has to exist first before milestone can appear under it
|
||||
$result = $this->createsPerfexCRMCustomerProject->execute($updatePerfexCRMObject->getProjectName(), $updatePerfexCRMObject->getProjectStatus(), $crmClientId);
|
||||
if(isset($result->payload)){ //Here means project creation successful
|
||||
$projectId = $result->payload['project_id'];
|
||||
}
|
||||
else{
|
||||
$project = $this->fetchesPerfexCRMProject->execute($updatePerfexCRMObject->getProjectName(), $crmClientId);
|
||||
$projectId = $project->id;
|
||||
//if the project status is anything but PerfexCRMProjectStatus::NOT_STARTED, update the project
|
||||
if($updatePerfexCRMObject->getProjectStatus() != PerfexCRMProjectStatus::NOT_STARTED)
|
||||
{
|
||||
$this->updatesPerfexCRMProject->execute($project, $updatePerfexCRMObject->getProjectStatus());
|
||||
}
|
||||
}
|
||||
|
||||
$tasks = $updatePerfexCRMObject->getTaskNames();
|
||||
if(count($tasks) > 0){
|
||||
|
||||
//Create tasks with milestone
|
||||
for($count=0; $count < count($tasks); $count++) {
|
||||
$milestoneId = 0; //By default milestoneId is 0, having this set at individual task is optional
|
||||
if($tasks[$count]['milestone'] != "") //Create milestone only if it is defined
|
||||
{
|
||||
// Get existing or create milestone, milestone has to exist first before task can appear under it
|
||||
$result = $this->createsPerfexCRMMilestone->execute($tasks[$count]['milestone'], $projectId, $count);
|
||||
if(isset($result->payload)){
|
||||
$milestoneId = $result->payload['milestone_id'];
|
||||
}
|
||||
else{
|
||||
$milestone = $this->fetchesPerfexCRMMilestone->execute($tasks[$count]['milestone'], $projectId);
|
||||
$array = json_decode(json_encode($milestone), true);
|
||||
$milestoneId = $array[0]['id'];
|
||||
}
|
||||
}
|
||||
|
||||
$taskStatus = PerfexCRMTaskStatus::NOT_STARTED;
|
||||
if($tasks[$count]['status'] != ''){
|
||||
$taskStatus = $tasks[$count]['status'];
|
||||
}
|
||||
|
||||
// Get existing or create task
|
||||
$result = $this->createsPerfexCRMTask->execute($tasks[$count]['name'], $tasks[$count]['description'], '', $milestoneId, $projectId, $tasks[$count]['reference'], $tasks[$count]['on_task_completion'], $tasks[$count]['department'], $taskStatus);
|
||||
if(is_null($result)){
|
||||
break; //Breaking the rest of the tasks in array assuming that they are all created as a batch previously
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ConvertsPerfexCRMLeadToCustomer
|
||||
{
|
||||
/**
|
||||
* @param string $email
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $email) {
|
||||
try{
|
||||
$response = Http::withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key'),])
|
||||
->get(config('perfexcrm.base_url').'/api/leads/convertocustomer/'.$email);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreatesPerfexCRMCustomer
|
||||
{
|
||||
/**
|
||||
* @param string $companyName
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $companyName) {
|
||||
try{
|
||||
$data = [
|
||||
'company' => $companyName
|
||||
];
|
||||
|
||||
$response = Http::asForm()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->post(config('perfexcrm.base_url').'/api/customers',$data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CustomerContactObject;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreatesPerfexCRMCustomerContact
|
||||
{
|
||||
/**
|
||||
* @param CustomerContactObject $customerContactObject
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(CustomerContactObject $customerContactObject) {
|
||||
try{
|
||||
$data = [
|
||||
'customer_id' => $customerContactObject->getCustomerId(),
|
||||
'firstname' => $customerContactObject->getFirstName(),
|
||||
'lastname' => $customerContactObject->getLastName(),
|
||||
'email' => $customerContactObject->getEmail(), //$email
|
||||
'password' => $customerContactObject->getPassword(),
|
||||
'is_primary' => $customerContactObject->getIsPrimary(),
|
||||
//'send_set_password_email' => $customerContactObject->getSendSetPasswordEmail(),
|
||||
];
|
||||
|
||||
$response = Http::asForm()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->post(config('perfexcrm.base_url').'/api/contacts',$data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreatesPerfexCRMCustomerProject
|
||||
{
|
||||
/**
|
||||
* @param string $projectName
|
||||
* @param string $clientId
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $projectName, int $status, string $clientId) {
|
||||
try{
|
||||
$data = [
|
||||
'name' => $projectName,
|
||||
'rel_type' => 'customer',
|
||||
'billing_type' => 1,
|
||||
'clientid' => $clientId,
|
||||
'start_date' => date('Y-m-d'),
|
||||
'status' => $status
|
||||
];
|
||||
|
||||
$response = Http::asForm()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->post(config('perfexcrm.base_url').'/api/projects',$data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePerfexCRMObject;
|
||||
|
||||
class CreatesPerfexCRMInvoice
|
||||
{
|
||||
/**
|
||||
* @param InvoicePerfexCRMObject $invoicePerfexCRMObject
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(InvoicePerfexCRMObject $invoicePerfexCRMObject) {
|
||||
try{
|
||||
$subtotal = floor($invoicePerfexCRMObject->getSubTotal() * 100) / 100;
|
||||
$total = floor($invoicePerfexCRMObject->getTotal() * 100) / 100;
|
||||
|
||||
$data = [
|
||||
'clientid' => $invoicePerfexCRMObject->getClientId(),
|
||||
'number' => $invoicePerfexCRMObject->getNumber(),
|
||||
'date' => $invoicePerfexCRMObject->getDate(),
|
||||
'duedate' => $invoicePerfexCRMObject->getDueDate(),
|
||||
'currency' => $invoicePerfexCRMObject->getCurrency(),
|
||||
'subtotal' => number_format($subtotal, 2, '.', ''),
|
||||
'total' => number_format($total, 2, '.', ''),
|
||||
'billing_street' => $invoicePerfexCRMObject->getBillingStreet(),
|
||||
'project_id' => $invoicePerfexCRMObject->getProjectId(),
|
||||
'allowed_payment_modes[0]' => 1,
|
||||
'allowed_payment_modes[1]' => 2,
|
||||
];
|
||||
|
||||
for($count=0; $count < count($invoicePerfexCRMObject->getInvoiceItems()); $count++) {
|
||||
$oneItem = [
|
||||
"newitems[".$count."][description]" => $invoicePerfexCRMObject->getInvoiceItems()[$count]->description,
|
||||
"newitems[".$count."][long_description]" => $invoicePerfexCRMObject->getInvoiceItems()[$count]->longDescription,
|
||||
"newitems[".$count."][qty]" => $invoicePerfexCRMObject->getInvoiceItems()[$count]->qty,
|
||||
"newitems[".$count."][rate]" => $invoicePerfexCRMObject->getInvoiceItems()[$count]->rate,
|
||||
"newitems[".$count."][order]" => $invoicePerfexCRMObject->getInvoiceItems()[$count]->order,
|
||||
"newitems[".$count."][unit]" => $invoicePerfexCRMObject->getInvoiceItems()[$count]->unit,
|
||||
];
|
||||
$data = array_merge($data, $oneItem);
|
||||
}
|
||||
|
||||
$response = Http::asForm()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->post(config('perfexcrm.base_url').'/api/invoices',$data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
||||
|
||||
class CreatesPerfexCRMInvoicePayment
|
||||
{
|
||||
/**
|
||||
* @param InvoicePaymentPerfexCRMObject $invoicePaymentPerfexCRMObject
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(InvoicePaymentPerfexCRMObject $invoicePaymentPerfexCRMObject) {
|
||||
try{
|
||||
$data = [
|
||||
'invoiceid' => $invoicePaymentPerfexCRMObject->getInvoiceId(),
|
||||
'amount' => number_format($invoicePaymentPerfexCRMObject->getAmount(), 2, '.', ''),
|
||||
'date' => $invoicePaymentPerfexCRMObject->getDate(),
|
||||
'paymentmode' => $invoicePaymentPerfexCRMObject->getPaymentMode(),
|
||||
'transactionid' => $invoicePaymentPerfexCRMObject->getTransactionId(),
|
||||
'note' => $invoicePaymentPerfexCRMObject->getNote(),
|
||||
];
|
||||
|
||||
$response = Http::asForm()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->post(config('perfexcrm.base_url').'/api/invoices/recordpayment',$data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateLeadPerfexCRMObject;
|
||||
|
||||
class CreatesPerfexCRMLead
|
||||
{
|
||||
/**
|
||||
* @param CreateLeadPerfexCRMObject $createLeadPerfexCRMObject
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(CreateLeadPerfexCRMObject $createLeadPerfexCRMObject) {
|
||||
try{
|
||||
$custom_fields = [
|
||||
"leads" => [
|
||||
4 => $createLeadPerfexCRMObject->getCompanyReference()
|
||||
]
|
||||
];
|
||||
|
||||
$data = [
|
||||
'name' => $createLeadPerfexCRMObject->getName(),
|
||||
'email' => $createLeadPerfexCRMObject->getEmail(),
|
||||
'phonenumber' => $createLeadPerfexCRMObject->getPhone(),
|
||||
'company' => $createLeadPerfexCRMObject->getCompanyName(),
|
||||
'source' => 2, //1: Exchange, 2: Shipping Portal
|
||||
'status' => 2, //2: Lead, 1: Customer
|
||||
'custom_fields' => $custom_fields
|
||||
];
|
||||
|
||||
$response = Http::asForm()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->post(config('perfexcrm.base_url').'/api/leads/byemail',$data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreatesPerfexCRMMilestone
|
||||
{
|
||||
/**
|
||||
* @param string $$milestoneName
|
||||
* @param string $projectId
|
||||
* @param string $milestoneOrder
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $milestoneName, string $projectId, string $milestoneOrder = "") {
|
||||
try{
|
||||
$data = [
|
||||
'name' => $milestoneName,
|
||||
'project_id' => $projectId,
|
||||
'due_date' => date('Y-m-d'),
|
||||
'start_date' => date('Y-m-d')
|
||||
];
|
||||
|
||||
if($milestoneOrder != ""){
|
||||
$data['milestone_order'] = $milestoneOrder;
|
||||
}
|
||||
|
||||
$response = Http::asForm()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->post(config('perfexcrm.base_url').'/api/milestones',$data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMCustomFields;
|
||||
|
||||
class CreatesPerfexCRMTask
|
||||
{
|
||||
/**
|
||||
* @param string $taskName
|
||||
* @param string $taskDescription
|
||||
* @param string $leadId
|
||||
* @param string $milestoneId
|
||||
* @param string $projectId
|
||||
* @param string $reference, default: ''
|
||||
* @param string $on_task_completion, default: ''
|
||||
* @param string $status, default: 1
|
||||
* @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 = "1") {
|
||||
try{
|
||||
$custom_fields = [];
|
||||
if($department != ""){
|
||||
$custom_fields = [
|
||||
"tasks" => [
|
||||
PerfexCRMCustomFields::TASKS_DEPARTMENT => $department
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'name' => $taskName,
|
||||
'description' => $taskDescription,
|
||||
'milestone' => $milestoneId,
|
||||
'startdate' => date('Y-m-d'),
|
||||
'rel_type' => 'project',
|
||||
'rel_id' => $projectId,
|
||||
'status' => $status,
|
||||
'is_system_created' => 1,
|
||||
'reference' => $reference,
|
||||
'on_task_completion' => $on_task_completion,
|
||||
'custom_fields' => $custom_fields
|
||||
];
|
||||
|
||||
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
|
||||
];
|
||||
}
|
||||
|
||||
$response = Http::asForm()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->post(config('perfexcrm.base_url').'/api/tasks',$data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchesPerfexCRMCustomer
|
||||
{
|
||||
/**
|
||||
* @param string $email
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $email) {
|
||||
try{
|
||||
$response = Http::withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key'),])
|
||||
->get(config('perfexcrm.base_url').'/api/customers/byemail/'.$email);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchesPerfexCRMInvoice
|
||||
{
|
||||
/**
|
||||
* @param string $clientId
|
||||
* @param string $invoicePrefix
|
||||
* @param string $invoiceNumber
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $clientId, string $invoicePrefix, string $invoiceNumber) {
|
||||
try{
|
||||
$response = Http::withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key'),])
|
||||
->get(config('perfexcrm.base_url').'/api/invoices/customsearch/'.$clientId.'/'.$invoicePrefix.'/'.$invoiceNumber);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchesPerfexCRMLead
|
||||
{
|
||||
/**
|
||||
* @param string $email
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $email) {
|
||||
try{
|
||||
$response = Http::withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key'),])
|
||||
->get(config('perfexcrm.base_url').'/api/leads/byemail/'.$email);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchesPerfexCRMMilestone
|
||||
{
|
||||
/**
|
||||
* @param string $milestoneName
|
||||
* @param string $projectId
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $milestoneName, string $projectId) {
|
||||
try{
|
||||
$response = Http::withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key'),])
|
||||
->get(config('perfexcrm.base_url').'/api/milestones/bynameandprojectid/'.rawurlencode($milestoneName).'/'.$projectId);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchesPerfexCRMProject
|
||||
{
|
||||
/**
|
||||
* @param string $projectName
|
||||
* @param string $clientId
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $projectName, string $clientId) {
|
||||
try{
|
||||
$data = [
|
||||
'name' => $projectName,
|
||||
'clientid' => $clientId,
|
||||
];
|
||||
|
||||
$response = Http::asForm()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->post(config('perfexcrm.base_url').'/api/projects/bynameandclientid', $data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchesPerfexCRMTask
|
||||
{
|
||||
/**
|
||||
* @param string $taskName
|
||||
* @param string $milestoneId
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $taskName, string $milestoneId) {
|
||||
try{
|
||||
$response = Http::withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key'),])
|
||||
->get(config('perfexcrm.base_url').'/api/tasks/bynameandmilestoneid/'.rawurlencode($taskName).'/'.$milestoneId);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMCustomFields;
|
||||
|
||||
class UpdatesPerfexCRMCustomer
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $customerId
|
||||
* @param string $companyReference
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $customerId, string $companyName, string $companyReference) {
|
||||
try{
|
||||
$custom_fields = [
|
||||
"customers" => [
|
||||
PerfexCRMCustomFields::CUSTOMERS_SHIPPING_PORTAL_REFERENCE => $companyReference
|
||||
]
|
||||
];
|
||||
|
||||
$data = [
|
||||
'company' => $companyName,
|
||||
'custom_fields' => $custom_fields
|
||||
];
|
||||
|
||||
$response = Http::asJson()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->put(config('perfexcrm.base_url').'/api/customers/'.$customerId, $data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdatesPerfexCRMInvoice
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $invoice
|
||||
* @param string $projectId
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute($invoice, string $projectId) {
|
||||
try{
|
||||
// <p>The Invoice number field is required.<\/p>
|
||||
// <p>The Invoice date field is required.<\/p>
|
||||
// <p>The Currency field is required.<\/p>
|
||||
// <p>The Items field is required.<\/p>
|
||||
// <p>The Allow Payment Mode field is required.<\/p>
|
||||
// <p>The Billing Street field is required.<\/p>
|
||||
// <p>The Sub Total field is required.<\/p>
|
||||
// <p>The Total field is required.<\/p>
|
||||
|
||||
$newInvoiceItems = [];
|
||||
foreach ($invoice->items as $item) {
|
||||
$item['itemid'] = $item['id'];
|
||||
unset($item['id']);
|
||||
$item['order'] = $item['item_order'];
|
||||
unset($item['item_order']);
|
||||
array_push($newInvoiceItems,$item);
|
||||
}
|
||||
|
||||
$allowedPaymentModes = [];
|
||||
array_push($allowedPaymentModes, 1, 2);
|
||||
|
||||
$data = [
|
||||
'number' => $invoice->number,
|
||||
'date' => $invoice->date,
|
||||
'duedate' => $invoice->duedate,
|
||||
'currency' => $invoice->currency,
|
||||
'subtotal' => $invoice->subtotal,
|
||||
'total' => $invoice->total,
|
||||
'billing_street' => $invoice->billing_street,
|
||||
'shipping_street' => $invoice->billing_street,
|
||||
'project_id' => $projectId,
|
||||
'items' => $newInvoiceItems,
|
||||
'allowed_payment_modes' => $allowedPaymentModes,
|
||||
];
|
||||
|
||||
$response = Http::asJson()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->put(config('perfexcrm.base_url').'/api/invoices/'.$invoice->id, $data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMCustomFields;
|
||||
|
||||
class UpdatesPerfexCRMLead
|
||||
{
|
||||
/**
|
||||
* @param $lead
|
||||
* @param string $companyReference
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute($lead, string $companyReference) {
|
||||
try{
|
||||
$custom_fields = [
|
||||
"leads" => [
|
||||
PerfexCRMCustomFields::LEADS_SHIPPING_PORTAL_REFERENCE => $companyReference
|
||||
]
|
||||
];
|
||||
|
||||
$data = [
|
||||
'name' => $lead->name,
|
||||
'email' => $lead->email,
|
||||
'phonenumber' => $lead->phonenumber,
|
||||
'company' => $lead->company,
|
||||
'custom_fields' => $custom_fields,
|
||||
'source' => $lead->source,
|
||||
'status' => $lead->status,
|
||||
];
|
||||
|
||||
$response = Http::asJson()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->put(config('perfexcrm.base_url').'/api/leads/'.$lead->id, $data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdatesPerfexCRMProject
|
||||
{
|
||||
/**
|
||||
* @param $project
|
||||
* @param int $status
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute($project, int $status) {
|
||||
try{
|
||||
$data = [
|
||||
'name' => $project->name,
|
||||
'clientid' => $project->clientid,
|
||||
// 'rel_type' => 'customer',
|
||||
'billing_type' => 1,
|
||||
'start_date' => $project->start_date,
|
||||
'status' => $status
|
||||
];
|
||||
|
||||
$response = Http::asJson()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->put(config('perfexcrm.base_url').'/api/projects/'.$project->id, $data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdatesPerfexCRMTask
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $taskName
|
||||
* @param string $milestoneId
|
||||
* @param string $projectId
|
||||
* @param string $status, default: 1
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $taskId, string $taskName, string $milestoneId, string $projectId, string $status = "1") {
|
||||
try{
|
||||
$data = [
|
||||
'name' => $taskName,
|
||||
'milestone' => $milestoneId,
|
||||
'startdate' => date('Y-m-d'),
|
||||
'duedate' => date('Y-m-d'),
|
||||
'rel_type' => 'project',
|
||||
'rel_id' => $projectId,
|
||||
'status' => $status,
|
||||
'repeat_every' => '',
|
||||
];
|
||||
|
||||
$response = Http::asJson()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->put(config('perfexcrm.base_url').'/api/tasks/'.$taskId, $data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,17 @@ namespace App\Classes\Modules\Segments\ControllersLogic;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Http\Resources\ConstantResource;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\Processors\UpdatePostcodeSegmentProcessor;
|
||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
||||
use App\Classes\Modules\Segments\Services\UpdatesConstant;
|
||||
use App\Classes\Modules\Segments\Standards\Rules\CanUpdateConstant;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Classes\Modules\Segments\Services\AddItemToConstantValueArray;
|
||||
use App\Classes\Modules\Segments\Services\RemoveItemFromConstantValueArray;
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Segments\Services\CreatesConstant;
|
||||
|
||||
class UpdateConstantPostcodeLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -21,18 +30,54 @@ class UpdateConstantPostcodeLogic extends AbstractControllerLogic
|
||||
];
|
||||
}
|
||||
|
||||
/** @var UpdatePostcodeSegmentProcessor */
|
||||
private $updatePostcodeSegmentProcessor;
|
||||
/** @var CanUpdateConstant */
|
||||
private $canUpdateConstant;
|
||||
|
||||
/** @var UpdatesConstant */
|
||||
private $updatesConstant;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var FetchesConstant */
|
||||
private $fetchesConstant;
|
||||
|
||||
/** @var AddItemToConstantValueArray */
|
||||
private $addItemToConstantValueArray;
|
||||
|
||||
/** @var RemoveItemFromConstantValueArray */
|
||||
private $removeItemFromConstantValueArray;
|
||||
|
||||
/** @var CreatesConstant */
|
||||
private $createsConstant;
|
||||
|
||||
/**
|
||||
* UpdateConstantLogic constructor.
|
||||
* @param UpdatePostcodeSegmentProcessor $updatePostcodeSegmentProcessor
|
||||
* @param CanUpdateConstant $canUpdateConstant
|
||||
* @param UpdatesConstant $updatesConstant
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
* @param FetchesConstant $fetchesConstant
|
||||
* @param AddItemToConstantValueArray $addItemToConstantValueArray
|
||||
* @param CreatesConstant $createsConstant
|
||||
* @param RemoveItemFromConstantValueArray $removeItemFromConstantValueArray
|
||||
*/
|
||||
public function __construct(
|
||||
UpdatePostcodeSegmentProcessor $updatePostcodeSegmentProcessor,
|
||||
CanUpdateConstant $canUpdateConstant,
|
||||
UpdatesConstant $updatesConstant,
|
||||
FetchesSegment $fetchesSegment,
|
||||
FetchesConstant $fetchesConstant,
|
||||
AddItemToConstantValueArray $addItemToConstantValueArray,
|
||||
RemoveItemFromConstantValueArray $removeItemFromConstantValueArray,
|
||||
CreatesConstant $createsConstant
|
||||
)
|
||||
{
|
||||
$this->updatePostcodeSegmentProcessor = $updatePostcodeSegmentProcessor;
|
||||
$this->canUpdateConstant = $canUpdateConstant;
|
||||
$this->updatesConstant = $updatesConstant;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
$this->fetchesConstant = $fetchesConstant;
|
||||
$this->addItemToConstantValueArray = $addItemToConstantValueArray;
|
||||
$this->removeItemFromConstantValueArray = $removeItemFromConstantValueArray;
|
||||
$this->createsConstant = $createsConstant;
|
||||
}
|
||||
/**
|
||||
* @param Request $request
|
||||
@@ -43,7 +88,42 @@ class UpdateConstantPostcodeLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$constant = $this->updatePostcodeSegmentProcessor->execute($request->route('id'), $request->input('reference'), $request->input('postcode'));
|
||||
$segment = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
||||
|
||||
try {
|
||||
$constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $request->input('reference')]);
|
||||
|
||||
$constantValue = $this->addItemToConstantValueArray->execute($constant->value, $request->input('postcode'));
|
||||
|
||||
$object = new ConstantObject($request->input('reference'), $constantValue);
|
||||
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
|
||||
$constantObject = [$request->input('postcode')];
|
||||
|
||||
$object = new ConstantObject(
|
||||
$request->input('reference'),
|
||||
$constantObject
|
||||
);
|
||||
|
||||
$constant = $this->createsConstant->execute($segment, $object);
|
||||
}
|
||||
|
||||
try {
|
||||
// check if postcode exist in the opposite constant, and delete it
|
||||
$oppositeConstant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $request->input('reference') == SegmentConstants::CENTER_POSTCODE ? SegmentConstants::OUTSTATION_POSTCODE : SegmentConstants::CENTER_POSTCODE]);
|
||||
|
||||
$oppositeConstantValue = $this->removeItemFromConstantValueArray->execute($oppositeConstant->value, $request->input('postcode'));
|
||||
|
||||
$oppositeObject = new ConstantObject($request->input('reference') == SegmentConstants::CENTER_POSTCODE ? SegmentConstants::OUTSTATION_POSTCODE : SegmentConstants::CENTER_POSTCODE, $oppositeConstantValue);
|
||||
|
||||
$this->updatesConstant->execute($oppositeConstant, $oppositeObject);
|
||||
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
// if opposite constant does not exist, do nothing
|
||||
}
|
||||
|
||||
$constant = $this->updatesConstant->execute($constant, $object);
|
||||
|
||||
return $this->resourceResponse(new ConstantResource($constant));
|
||||
}
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Processors;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Http\Resources\ConstantResource;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
||||
use App\Classes\Modules\Segments\Services\UpdatesConstant;
|
||||
use App\Classes\Modules\Segments\Standards\Rules\CanUpdateConstant;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Classes\Modules\Segments\Services\AddItemToConstantValueArray;
|
||||
use App\Classes\Modules\Segments\Services\RemoveItemFromConstantValueArray;
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Segments\Services\CreatesConstant;
|
||||
|
||||
class UpdatePostcodeSegmentProcessor
|
||||
{
|
||||
/** @var CanUpdateConstant */
|
||||
private $canUpdateConstant;
|
||||
|
||||
/** @var UpdatesConstant */
|
||||
private $updatesConstant;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var FetchesConstant */
|
||||
private $fetchesConstant;
|
||||
|
||||
/** @var AddItemToConstantValueArray */
|
||||
private $addItemToConstantValueArray;
|
||||
|
||||
/** @var RemoveItemFromConstantValueArray */
|
||||
private $removeItemFromConstantValueArray;
|
||||
|
||||
/** @var CreatesConstant */
|
||||
private $createsConstant;
|
||||
/**
|
||||
* UpdatePostcodeSegmentProcessor constructor.
|
||||
* @param CanUpdateConstant $canUpdateConstant
|
||||
* @param UpdatesConstant $updatesConstant
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
* @param FetchesConstant $fetchesConstant
|
||||
* @param AddItemToConstantValueArray $addItemToConstantValueArray
|
||||
* @param CreatesConstant $createsConstant
|
||||
* @param RemoveItemFromConstantValueArray $removeItemFromConstantValueArray
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateConstant $canUpdateConstant,
|
||||
UpdatesConstant $updatesConstant,
|
||||
FetchesSegment $fetchesSegment,
|
||||
FetchesConstant $fetchesConstant,
|
||||
AddItemToConstantValueArray $addItemToConstantValueArray,
|
||||
RemoveItemFromConstantValueArray $removeItemFromConstantValueArray,
|
||||
CreatesConstant $createsConstant
|
||||
)
|
||||
{
|
||||
$this->canUpdateConstant = $canUpdateConstant;
|
||||
$this->updatesConstant = $updatesConstant;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
$this->fetchesConstant = $fetchesConstant;
|
||||
$this->addItemToConstantValueArray = $addItemToConstantValueArray;
|
||||
$this->removeItemFromConstantValueArray = $removeItemFromConstantValueArray;
|
||||
$this->createsConstant = $createsConstant;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param int $companyModuleId
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute($segment_id, $reference, $postcode){
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $segment_id]);
|
||||
|
||||
try {
|
||||
$constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $reference]);
|
||||
|
||||
$constantValue = $this->addItemToConstantValueArray->execute($constant->value, $postcode);
|
||||
|
||||
$object = new ConstantObject($reference, $constantValue);
|
||||
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
|
||||
$constantObject = [$postcode];
|
||||
|
||||
$object = new ConstantObject(
|
||||
$reference,
|
||||
$constantObject
|
||||
);
|
||||
|
||||
$constant = $this->createsConstant->execute($segment, $object);
|
||||
}
|
||||
|
||||
try {
|
||||
// check if postcode exist in the opposite constant, and delete it
|
||||
$oppositeConstant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $reference == SegmentConstants::CENTER_POSTCODE ? SegmentConstants::OUTSTATION_POSTCODE : SegmentConstants::CENTER_POSTCODE]);
|
||||
|
||||
$oppositeConstantValue = $this->removeItemFromConstantValueArray->execute($oppositeConstant->value, $postcode);
|
||||
|
||||
$oppositeObject = new ConstantObject($reference == SegmentConstants::CENTER_POSTCODE ? SegmentConstants::OUTSTATION_POSTCODE : SegmentConstants::CENTER_POSTCODE, $oppositeConstantValue);
|
||||
|
||||
$this->updatesConstant->execute($oppositeConstant, $oppositeObject);
|
||||
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
// if opposite constant does not exist, do nothing
|
||||
}
|
||||
|
||||
$constant = $this->updatesConstant->execute($constant, $object);
|
||||
|
||||
return $constant;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-8
@@ -16,7 +16,6 @@ use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\Jobs\CreatePerfexCRMInvoice;
|
||||
|
||||
class ApproveShippingInvoiceTransactionProcessor
|
||||
{
|
||||
@@ -30,7 +29,6 @@ class ApproveShippingInvoiceTransactionProcessor
|
||||
/** @var CreatesFiles */
|
||||
private $createsFiles;
|
||||
|
||||
|
||||
/**
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param CreatesDocument $createsDocument
|
||||
@@ -74,12 +72,6 @@ class ApproveShippingInvoiceTransactionProcessor
|
||||
if(app()->environment(['production'])) {
|
||||
$user->notify(new InvoiceIssuedEmail($user, $packingList));
|
||||
}
|
||||
|
||||
// update perfex crm
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
CreatePerfexCRMInvoice::dispatch($invoice_transaction);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,27 +4,9 @@ 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\NewLeadTaskToPerfexCRMProcessor;
|
||||
|
||||
class UpdatesTransactionStatus extends AbstractUpdateRecord
|
||||
{
|
||||
/** @var TransactionToPerfexCRMProcessor */
|
||||
private $transactionToPerfexCRMProcessor;
|
||||
|
||||
/** @var NewLeadTaskToPerfexCRMProcessor */
|
||||
private $newLeadTaskToPerfexCRMProcessor;
|
||||
|
||||
/**
|
||||
* UpdatesTransactionStatus constructor.
|
||||
* @param TransactionToPerfexCRMProcessor $transactionToPerfexCRMProcessor
|
||||
* @param NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor
|
||||
*/
|
||||
public function __construct(TransactionToPerfexCRMProcessor $transactionToPerfexCRMProcessor, NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor)
|
||||
{
|
||||
$this->transactionToPerfexCRMProcessor = $transactionToPerfexCRMProcessor;
|
||||
$this->newLeadTaskToPerfexCRMProcessor = $newLeadTaskToPerfexCRMProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Transaction $model
|
||||
@@ -34,11 +16,7 @@ class UpdatesTransactionStatus extends AbstractUpdateRecord
|
||||
*/
|
||||
public function execute(Transaction $model, int $status)
|
||||
{
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
$this->transactionToPerfexCRMProcessor->execute($model, $status);
|
||||
// $this->newLeadTaskToPerfexCRMProcessor->execute();
|
||||
}
|
||||
$model->status = $status;
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,4 @@ final class ApprovalStatus {
|
||||
|
||||
public const EXPIRED = 6;
|
||||
|
||||
public const APPROVAL_STATUS_ID = [
|
||||
self::PENDING_SUBMISSION => "Pending Submission",
|
||||
self::PENDING_VERIFICATION => "Pending Verification",
|
||||
self::APPROVED => "Approved",
|
||||
self::COMPLETED => "Completed",
|
||||
self::REJECTED => "Rejected",
|
||||
self::SUSPENDED => "Suspended",
|
||||
self::EXPIRED => "Expired",
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -8,9 +8,4 @@ final class CompanyType {
|
||||
|
||||
public const COMPANY_BUSINESS = 1;
|
||||
|
||||
public const COMPANY_TYPE_ID = [
|
||||
self::PERSONAL_BUSINESS => "Personal Business",
|
||||
self::COMPANY_BUSINESS => "Company Business",
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class PerfexCRMCustomFields {
|
||||
|
||||
public const CUSTOMERS_EXCHANGE_REFERENCE = 1;
|
||||
|
||||
public const CUSTOMERS_SHIPPING_PORTAL_REFERENCE = 2;
|
||||
|
||||
public const LEADS_EXCHANGE_REFERENCE = 3;
|
||||
|
||||
public const LEADS_SHIPPING_PORTAL_REFERENCE = 4;
|
||||
|
||||
public const TICKETS_CUSTOM_TAGS = 5;
|
||||
|
||||
public const TASKS_DEPARTMENT = 6;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class PerfexCRMInvoiceStatus {
|
||||
|
||||
public const UNPAID = 1;
|
||||
|
||||
public const PAID = 2;
|
||||
|
||||
public const PARTIALLY_PAID = 3;
|
||||
|
||||
public const OVERDUE = 4;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
class PerfexCRMMilestones
|
||||
{
|
||||
public const MILESTONE_1 = 'MILESTONE 1 - Customer Paid';
|
||||
public const MILESTONE_2 = 'MILESTONE 2 - Order Placed';
|
||||
public const MILESTONE_3 = 'MILESTONE 3 - Purchase Order Approved';
|
||||
public const MILESTONE_4 = 'MILESTONE 4';
|
||||
public const MILESTONE_5 = 'MILESTONE 5';
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class PerfexCRMProjectStatus {
|
||||
|
||||
public const NOT_STARTED = 1;
|
||||
|
||||
public const IN_PROGRESS = 2;
|
||||
|
||||
public const ON_HOLD = 3;
|
||||
|
||||
public const FINISHED = 4;
|
||||
|
||||
public const CANCELLED = 5;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class PerfexCRMTaskStatus {
|
||||
|
||||
public const NOT_STARTED = 1;
|
||||
|
||||
public const AWAITING_FEEDBACK = 2;
|
||||
|
||||
public const TESTING = 3;
|
||||
|
||||
public const IN_PROGRESS = 4;
|
||||
|
||||
public const COMPLETED = 5;
|
||||
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
class PerfexCRMTasks
|
||||
{
|
||||
//IMPORTANT NOTE: TASK NAME MUST BE UNIQUE ACCORDING TO REL_TYPE
|
||||
//e.g. rel_type: lead, project
|
||||
|
||||
public const TASK_1 = [
|
||||
'name' => 'Customer Paid',
|
||||
'description' => '',
|
||||
'milestone' => 'MILESTONE 1 - Customer Paid',
|
||||
'reference' => '',
|
||||
'on_task_completion' => '',
|
||||
'department' => '',
|
||||
'status' => PerfexCRMTaskStatus::COMPLETED
|
||||
];
|
||||
|
||||
public const TASK_POST_PAYMENT_1 = [
|
||||
'name' => 'Map Bank Transaction Record',
|
||||
'description' => '○ Purpose: To map a transaction to bank transaction in the bank statement<br>
|
||||
○ Initial Status: In Progress<br>
|
||||
○ Deadline: Same day<br>
|
||||
○ Responsible department: Accounts<br>
|
||||
○ Next step: Change the status of the Approve payment status to "In Progress" upon successful completion of the operation.<br>
|
||||
○ Additional details: ** Any specific requirements or notes for the operation.**<br>
|
||||
○ Dependencies: None<br>
|
||||
○ Outcomes: Bank transaction is mapped successfully, allowing the next steps in the process to be initiated.<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_POST_PAYMENT_1',
|
||||
'on_task_completion' => 'TASK_POST_PAYMENT_2',
|
||||
'department' => 'Accounts',
|
||||
'status' => PerfexCRMTaskStatus::IN_PROGRESS
|
||||
];
|
||||
public const TASK_POST_PAYMENT_2 = [
|
||||
'name' => 'Approve Payment',
|
||||
'description' => '○ Purpose: To verify and approve the customer\'s payment on IZYIM<br>
|
||||
○ Initial Status: Not Started<br>
|
||||
○ Deadline:Same day<br>
|
||||
○ Responsible department: Accounts<br>
|
||||
○ Next step: Change the status of the Issue Shipping Autocount Invoice operation to "In Progress"<br>
|
||||
○ Additional details: When the payment method is FPX or Wallet this task is performed automatically by the system.<br>
|
||||
○ Dependencies: Map Transaction operation must be completed before this operation can begin.<br>
|
||||
○ Outcomes: The payment will be approved in IZYIM, which will release the customer’s goods for delivery.<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_POST_PAYMENT_2',
|
||||
'on_task_completion' => 'TASK_POST_PAYMENT_3',
|
||||
'department' => 'Accounts',
|
||||
'status' => ''
|
||||
];
|
||||
public const TASK_POST_PAYMENT_3 = [
|
||||
'name' => 'Issue Shipping Autocount Invoince',
|
||||
'description' => '○ Purpose: To issue an invoice for the customer\'s payment in accounting software.<br>
|
||||
○ Initial Status: Not Started<br>
|
||||
○ Deadline: Next day<br>
|
||||
○ Responsible department: Accounts<br>
|
||||
○ Next step: Change the status of the Knockoff Invoice operation to "In Progress" upon successful completion.<br>
|
||||
○ Additional details: ** Any specific requirements or notes for the operation.**<br>
|
||||
○ Dependencies: Approve Payment operation must be completed before this operation can begin.<br>
|
||||
○ Outcomes: An invoice will be issued in accounting software for the customer\'s payment.<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_POST_PAYMENT_3',
|
||||
'on_task_completion' => 'TASK_POST_PAYMENT_4',
|
||||
'department' => 'Accounts',
|
||||
'status' => ''
|
||||
];
|
||||
public const TASK_POST_PAYMENT_4 = [
|
||||
'name' => 'Knockoff Invoice',
|
||||
'description' => '○ Purpose: The purpose of this operation is to issue the official receipt and knockoff with invoice for the customer\'s payment.<br>
|
||||
○ Initial Status: Not Started<br>
|
||||
○ Deadline: Next day.<br>
|
||||
○ Responsible Department: Accounts<br>
|
||||
○ Next Step: None<br>
|
||||
○ Additional Details: ** Any specific requirements or notes for the operation.**<br>
|
||||
○ Dependencies: Issue Shipping Autocount Invoice operation must be completed before this operation can begin.<br>
|
||||
○ Outcomes: The customer’s payment is applied to the accounting software invoice and invoice is marked as paid.<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_POST_PAYMENT_4',
|
||||
'on_task_completion' => '',
|
||||
'department' => 'Accounts',
|
||||
'status' => ''
|
||||
];
|
||||
|
||||
public const TASK_LOADED_CONTAINER_1 = [
|
||||
'name' => 'Generate Shipping Invoices',
|
||||
'description' => '○ Purpose: -<br>
|
||||
○ Initial Status: In Progress<br>
|
||||
○ Deadline: Next day<br>
|
||||
○ Responsible department: Operation<br>
|
||||
○ Assignee: -<br>
|
||||
○ Next step: Approve Shipping Invoice change to in progress.<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_LOADED_CONTAINER_1',
|
||||
'on_task_completion' => 'TASK_LOADED_CONTAINER_2',
|
||||
'department' => 'Operations',
|
||||
'status' => PerfexCRMTaskStatus::IN_PROGRESS
|
||||
];
|
||||
|
||||
public const TASK_LOADED_CONTAINER_2 = [
|
||||
'name' => 'Approve Shipping Invoices',
|
||||
'description' => '○ Purpose: -<br>
|
||||
○ Initial Status: Not Starteds<br>
|
||||
○ Deadline: Next day<br>
|
||||
○ Responsible department: Customer Services<br>
|
||||
○ Next step: -<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_LOADED_CONTAINER_2',
|
||||
'on_task_completion' => '',
|
||||
'department' => 'Customer Services',
|
||||
'status' => ''
|
||||
];
|
||||
|
||||
|
||||
public const TASK_IDENTIFICATION_1 = [
|
||||
'name' => 'Approve Identification Verification (Shipping)',
|
||||
'description' => '○ Purpose: To ensure the customer submit information matches the information in their identification document.<br>
|
||||
○ Initial Status: In Progress<br>
|
||||
○ Deadline: Same Day<br>
|
||||
○ Responsible department: Operation<br>
|
||||
○ Next step: None<br>
|
||||
○ Additional details: ** Any specific requirements or notes for the operation.**<br>
|
||||
○ Dependencies: None<br>
|
||||
○ Outcomes: Customer account identification is verified<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_IDENTIFICATION_1',
|
||||
'on_task_completion' => '',
|
||||
'department' => 'Operations',
|
||||
'status' => PerfexCRMTaskStatus::IN_PROGRESS
|
||||
];
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class AuditBillplzInvoice extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'billplz-invoice:audit';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check all unpaid invoice but marked at paid at out system';
|
||||
|
||||
/**
|
||||
* 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() . ' : Audit Billplz Invoice cron started.');
|
||||
$start = new Carbon();
|
||||
|
||||
$transactions = Transaction::where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::COMPLETED)->whereHas('transactions', function($query){
|
||||
return $query->where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->where('status', ApprovalStatus::REJECTED);
|
||||
})->get();
|
||||
|
||||
$totalTransactions = count($transactions);
|
||||
$counter = 1;
|
||||
$totalAmount = 0;
|
||||
foreach ($transactions as $transaction){
|
||||
$payment_transaction = $transaction->transactions->sortByDesc('created_at')->first();
|
||||
|
||||
if ($payment_transaction->status === ApprovalStatus::REJECTED) {
|
||||
$this->info($counter . ' of ' . $totalTransactions . '. Order Marking: '. $payment_transaction->owner->owner->owner->reference . '. Transaction Id: '. $payment_transaction->id . '. Invoice Id: '. $transaction->id . ' - Date: '.$payment_transaction->created_at->format('d-m-Y').' - Amount: '. $payment_transaction->amount);
|
||||
|
||||
$totalAmount += $transaction->amount;
|
||||
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
$this->info(Carbon::now() . ' : Done Audit Billplz. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class AuditBillplzPayment extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'billplz-payment:audit';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check all failed payment in billplz, but marked at success at our system';
|
||||
|
||||
/**
|
||||
* 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() . ' : Audit Billplz Payment cron started.');
|
||||
$start = new Carbon();
|
||||
|
||||
$transactions = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::APPROVED])->get();
|
||||
$totalTransactions = count($transactions);
|
||||
$counter = 1;
|
||||
$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 {
|
||||
$totalAmount += $transaction->amount;
|
||||
$this->info($counter . ' of ' . $totalTransactions . '. Order: '. $transaction->owner->owner->owner->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount);
|
||||
}
|
||||
}else{
|
||||
$this->info("billplz error</br>");
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
$this->info(Carbon::now() . ' : Done Audit Billplz. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class BillplzFailedCallbackPayment extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'billplz-failed-callback';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check all failled callback from billplz';
|
||||
|
||||
protected $output = null;
|
||||
|
||||
protected $outputArray = [];
|
||||
|
||||
|
||||
/**
|
||||
* 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->appendToOutput(Carbon::now() . ' : Billplz Failled Callback cron started.');
|
||||
$this->outputArray = [];
|
||||
$start = new Carbon();
|
||||
|
||||
$approvalStatusArray = ApprovalStatus::APPROVAL_STATUS_ID;
|
||||
|
||||
$transactions = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::PENDING_VERIFICATION])->get();
|
||||
$totalTransactions = count($transactions);
|
||||
$counter = 1;
|
||||
$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']){
|
||||
$totalAmount += $transaction->amount;
|
||||
$this->appendToOutput($counter . ' of ' . $totalTransactions . '. Order: '. $transaction->owner->owner->owner->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount . '. Status: ' . $approvalStatusArray[$transaction->status]);
|
||||
} else {
|
||||
// $totalAmount += $transaction->amount;
|
||||
// $this->appendToOutput($counter . ' of ' . $totalTransactions . '. Order: '. $transaction->owner->owner->owner->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount);
|
||||
}
|
||||
}else{
|
||||
$this->appendToOutput("billplz error</br>");
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
$this->appendToOutput(Carbon::now() . ' : Done Billplz Failled Callback. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
||||
|
||||
$this->output = json_encode($this->outputArray);
|
||||
}
|
||||
|
||||
public function appendToOutput($string) {
|
||||
$this->outputArray[] = $string;
|
||||
$this->info($string);
|
||||
}
|
||||
|
||||
public function getOutput()
|
||||
{
|
||||
return $this->output;
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
||||
use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\CompanyConnection;
|
||||
use App\Models\Order;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class FixInvoice extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'invoice:fix {--marking=}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Fix Invoice By Company Module Marking';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$connection = CompanyConnection::where('invitee_reference', $this->option('marking'))->first();
|
||||
$company_module_id = $connection->invitee->id;
|
||||
|
||||
$orders = Order::where('company_module_id', $company_module_id)->get();
|
||||
|
||||
foreach ($orders as $order){
|
||||
$invoices = $order->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->get();
|
||||
foreach ($invoices as $invoice){
|
||||
|
||||
dump($invoice->id);
|
||||
|
||||
$invoice->documents()->delete();
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice]);
|
||||
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::SHIPPING_INVOICE,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'shipping_invoice'
|
||||
);
|
||||
|
||||
/** @var Document $document */
|
||||
$document = (App()->make(CreatesDocument::class))->execute($invoice, $document_object);
|
||||
|
||||
(App()->make(CreatesFiles::class))->execute($document, $document_object);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\Modules\Transactions\Processors\ApproveShippingInvoiceTransactionProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class approveInvoice extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'approve:invoice';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$invoices = Transaction::where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::PENDING_SUBMISSION)->get();
|
||||
|
||||
foreach ($invoices as $invoice) {
|
||||
$packingList = $invoice->owner;
|
||||
$order = $packingList->owner;
|
||||
|
||||
try {
|
||||
(App()->make(ApproveShippingInvoiceTransactionProcessor::class))->execute($packingList);
|
||||
$this->info('Invoice Approved for reference ' . $order->reference . '.');
|
||||
} catch (Exception $exception) {
|
||||
$this->info('Failed to Approve invoice for reference ' . $order->reference . '. Exception: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class debugBillplzFailedPayment extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'billplz-failed-payment:debug';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$transactions = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('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);
|
||||
|
||||
// dd($response);
|
||||
|
||||
// dd($transaction->owner->owner->owner->reference);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
if($data['paid']){
|
||||
if (!in_array($transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) {
|
||||
$this->returnLog('Paid transaction', $transaction);
|
||||
}
|
||||
}
|
||||
// else {
|
||||
// $totalAmount += $transaction->amount;
|
||||
// $this->returnLog('Unpaid Transaction', $transaction);
|
||||
// }
|
||||
}else{
|
||||
$this->returnLog('billplz error', $transaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function returnLog($text, $transaction) {
|
||||
$approvalStatusArray = ApprovalStatus::APPROVAL_STATUS_ID;
|
||||
$this->info($text . ' - id: '. $transaction->id . '. Order Marking: '. $transaction->owner->owner->owner->reference . ' - Date: '.$transaction->created_at->format('d-m-Y').' - Amount: '. $transaction->amount . '. Current Status: ' . $approvalStatusArray[$transaction->status]);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Addresses;
|
||||
|
||||
use App\Classes\Modules\Addresses\ControllersLogic\CreateBillingAddressLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateBillingAddressController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CreateBillingAddressLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, CreateBillingAddressLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Companies;
|
||||
|
||||
use App\Classes\Modules\Companies\ControllersLogic\UpdateCompanyTypeLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyTypeController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param AddNewMemberLogic $execute
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, UpdateCompanyTypeLogic $execute) : JsonResponse
|
||||
{
|
||||
return $execute->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
@@ -20,8 +19,6 @@ class CompanyResource extends JsonResource
|
||||
public function toArray($request)
|
||||
{
|
||||
$companyModule = $this->companyModules()->first();
|
||||
$companyTypeArray = CompanyType::COMPANY_TYPE_ID;
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'hash_id' => Crypt::encryptString($this->id),
|
||||
@@ -29,7 +26,6 @@ class CompanyResource extends JsonResource
|
||||
'debtor' => $this->debtor,
|
||||
'reference' => $this->reference,
|
||||
'type' => (int) $this->type,
|
||||
'type_name' => ($companyTypeArray[(int) $this->type]),
|
||||
'business_type' => (int) $this->business_type,
|
||||
'status' => (int) $this->status,
|
||||
'segments' => SegmentResource::collection($companyModule->connections()->first()->segments),
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Classes\General\Interfaces\Documentable;
|
||||
use App\Classes\General\Interfaces\Transactionable;
|
||||
use App\Classes\General\Traits\LogData;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use App\Scopes\CustomerBookingsScope;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
/**
|
||||
* Class Booking
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Company company_id
|
||||
* @property \App\Models\Bank transferable_bank_id
|
||||
* @property string marking
|
||||
* @property string reference
|
||||
* @property float fix_amount
|
||||
* @property int convertible_currency_id
|
||||
* @property int conversion_currency_id
|
||||
*/
|
||||
class Booking extends AbstractModel implements Documentable, Transactionable
|
||||
{
|
||||
use HasRelationships;
|
||||
use SoftDeletes;
|
||||
use LogData;
|
||||
|
||||
protected $table = 'bookings';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(Company::class, 'company_id')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function service(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(ServiceType::class, 'service_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function bank(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(Bank::class, 'bank_id')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function fixedCurrency(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(Currency::class, 'fix_currency_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function convertibleCurrency(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(Currency::class, 'convertible_currency_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function conversionCurrency(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(Currency::class, 'conversion_currency_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function documents(): MorphMany
|
||||
{
|
||||
return $this->MorphMany(Document::class, 'owner');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function transactions(): MorphMany
|
||||
{
|
||||
return $this->MorphMany(Transaction::class, 'owner');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return hasManyDeep
|
||||
*/
|
||||
public function bills(): hasManyDeep
|
||||
{
|
||||
return $this->hasManyDeep(Transaction::class, [Transaction::class.' as alias'], [['owner_type', 'owner_id'], ['owner_type', 'owner_id']], [null, null]);
|
||||
}
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
if (auth()->user()) {
|
||||
if (auth()->user()->type === RoleTypes::USER) {
|
||||
static::addGlobalScope(new CustomerBookingsScope);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'base_url' => env('PERFEXCRM_BASE_URL', 'http://192.168.1.100:8084'), //cief todo: Update crm api domain here
|
||||
'api_key' => env('PERFEXCRM_API_KEY', ''),
|
||||
'is_enabled' => env('PERFEXCRM_IS_ENABLED', 'true'),
|
||||
];
|
||||
@@ -46,23 +46,19 @@ use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Classes\Modules\Segments\Processors\UpdatePostcodeSegmentProcessor;
|
||||
use App\Models\Address;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Container;
|
||||
use App\Models\Document;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\SegmentConstant;
|
||||
use App\Models\Transport;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class DummyDataSeeder extends Seeder
|
||||
{
|
||||
@@ -587,32 +583,6 @@ class DummyDataSeeder extends Seeder
|
||||
// 3. overweight cbm
|
||||
}
|
||||
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //
|
||||
// Generate and Approve Dummmy Invoice //
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //
|
||||
ini_set('memory_limit', '-1');
|
||||
$randomCompanyModule = CompanyModule::latest('id')->take(5)->get();
|
||||
|
||||
$centerPostcodeConstantObject = SegmentConstant::where('reference', SegmentConstants::CENTER_POSTCODE)->get();
|
||||
$centerPostcodeConstant = $centerPostcodeConstantObject->isEmpty() ? [] : (array)$centerPostcodeConstantObject->first()->value;
|
||||
|
||||
foreach($randomCompanyModule as $companyModule) {
|
||||
foreach($companyModule->addresses as $address) {
|
||||
$postcode = $address->postcode;
|
||||
$postcodeArea = in_array($postcode, $centerPostcodeConstant) ? 'CENTER_POSTCODE' : null;
|
||||
|
||||
if (!$postcodeArea) {
|
||||
$random = rand(0, 1);
|
||||
$postcodeArray = ['OUTSTATION_POSTCODE', 'CENTER_POSTCODE'];
|
||||
(App()->make(UpdatePostcodeSegmentProcessor::class))->execute('1', $postcodeArray[$random],$postcode);
|
||||
$this->command->info($postcodeArray[$random]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Artisan::call('invoice:generate');
|
||||
Artisan::call('approve:invoice');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class SegmentConstantsTableSeeder extends Seeder
|
||||
Segmentconstant::create( [
|
||||
'segment_id'=>1,
|
||||
'reference'=>'STATE_RATE',
|
||||
'value'=>'[{"state_id":1,"center":"10.00","outstation":"2.00"},{"center":"10.00","outstation":"10.00"},{"center":"10.00","outstation":"10.00"},{"center":"50.00","outstation":"50.00"},{"center":"12.00","outstation":"12.00"},{"center":"345.00","outstation":"345.00"},{"center":"10.00","outstation":"10.00"},{"center":"10.00","outstation":"10.00"},{"center":"10.00","outstation":"30.00"},{"center":"10.00","outstation":"20.00"},{"center":"10.00","outstation":"10.00"},{"center":"10.00","outstation":"10.00"},{"center":"15.00","outstation":"15.00"},{"center":"185.00","outstation":"23.00"},{"center":"185.00","outstation":"185.00"},{"center":"30.00","outstation":"30.00"},{"center":"50.00","outstation":"50.00"}]',
|
||||
'value'=>'[{"state_id":1,"center":"10.00","outstation":"2.00"},{"center":"10.00","outstation":"0.00"},{"center":"10.00","outstation":"0.00"},{"center":"50.00","outstation":"0.00"},{"center":"0.00","outstation":"0.00"},{"center":"345.00","outstation":"0.00"},{"center":"10.00","outstation":"0.00"},{"center":"10.00","outstation":"0.00"},{"center":"10.00","outstation":"0.00"},{"center":"10.00","outstation":"0.00"},{"center":"10.00","outstation":"0.00"},{"center":"10.00","outstation":"0.00"},{"center":"0.00","outstation":"0.00"},{"center":"185.00","outstation":"0.00"},{"center":"185.00","outstation":"0.00"},{"center":"0.00","outstation":"0.00"},{"center":"50.00","outstation":"0.00"}]',
|
||||
'deleted_at'=>NULL,
|
||||
'created_at'=>NULL,
|
||||
'updated_at'=>'2022-09-27 01:18:15'
|
||||
@@ -71,7 +71,7 @@ class SegmentConstantsTableSeeder extends Seeder
|
||||
Segmentconstant::create( [
|
||||
'segment_id'=>1,
|
||||
'reference'=>'OUTSTATION_POSTCODE',
|
||||
'value'=>'["93250","93350","94200","94300","94600","78556","78557","94700","94750","94760","93050","93250","94000","94500","93050","93350","93350","79466","93050","94100","94500","93050","93050","93250","93350","93050","94200","94200","93010","93010","94700","94800","94807","94809","93250","94000","93050","93050","93250","86900","82300","86800","86810","81600","86800","71600","71650","72400","71600","72200","72300","71750","71770","69000","26800","26810","26820","39000","39007","39009","39010","33300","33310","33320","33100","42425","42500","42507","42509","42800","45500","43950","47507","47600","47610","47620","47640","47650","47200","40000","40100","40470","40500","40502","40503","40505","40512","40517","40520","40529","40542","40548","40550","40551","40560","40564","40570","40572","40576","40578","40582","40590","40592","40594","40596","40598","40604","40607","40608","40610","40612","40620","40622","40626","40632","40646","40648","40660","40664","40670","40672","40673","40674","40675","40676","40680","40690","40700","40702","40704","40706","40708","40710","40712","40714","40716","40718","40720","40722","40724","40726","40728","40730","40732","40800","40802","40804","40806","40808","40810","40990"]',
|
||||
'value'=>'["93250","93350","94200","94300","94600","78556","78557","94700","94750","94760","93050","93250","94000","94500","93050","93350","93350","79466","93050","94100","94500","93050","93050","93250","93350","93050","94200","94200","93010","93010","94700","94800","94807","94809","93250","94000","93050","93050","93250","86900","82300","86800","86810","81600","86800","71600","71650","72400","71600","72200","72300","71750","71770","69000","26800","26810","26820","39000","39007","39009","39010","33300","33310","33320","33100"]',
|
||||
'deleted_at'=>NULL,
|
||||
'created_at'=>NULL,
|
||||
'updated_at'=>'2022-09-21 03:35:19'
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
FROM php:7.4-fpm
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
RUN docker-php-ext-install pdo pdo_mysql
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libfreetype6-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libpng-dev \
|
||||
libzip-dev \
|
||||
zip \
|
||||
cron \
|
||||
supervisor \
|
||||
nano \
|
||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||
&& docker-php-ext-install -j$(nproc) gd \
|
||||
&& docker-php-ext-install zip \
|
||||
&& docker-php-ext-install bcmath
|
||||
|
||||
COPY --from=composer:1.9.3 /usr/bin/composer /usr/bin/composer
|
||||
|
||||
#NODEJS & NPM
|
||||
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
|
||||
RUN apt-get -y install nodejs
|
||||
|
||||
RUN chown -R www-data:www-data /var/www
|
||||
RUN chmod 755 /var/www
|
||||
@@ -1,54 +0,0 @@
|
||||
version: '3'
|
||||
|
||||
networks:
|
||||
shipping-portal-staging:
|
||||
|
||||
services:
|
||||
#################################################################
|
||||
nginx:
|
||||
image: nginx:stable-alpine
|
||||
container_name: shipping-portal-ngnix
|
||||
ports:
|
||||
- "8081:80"
|
||||
volumes:
|
||||
- ../:/var/www/html
|
||||
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
|
||||
depends_on:
|
||||
- php
|
||||
- mysql
|
||||
networks:
|
||||
- shipping-portal-staging
|
||||
#################################################################
|
||||
mysql:
|
||||
image: mysql:5.7.29
|
||||
container_name: shipping-portal-mysql
|
||||
restart: unless-stopped
|
||||
tty: true
|
||||
ports:
|
||||
- 3307:3306
|
||||
environment:
|
||||
MYSQL_ROOT_USER: root
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_DATABASE: shipping-portal-db
|
||||
MYSQL_USER: master
|
||||
MYSQL_PASSWORD: cDe7gcrRBWetaAP
|
||||
volumes:
|
||||
- mysql-data:/var/lib/mysql
|
||||
networks:
|
||||
- shipping-portal-staging
|
||||
#################################################################
|
||||
php:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: shipping-portal-php
|
||||
volumes:
|
||||
- ../:/var/www/html
|
||||
ports:
|
||||
- "9001:9000"
|
||||
networks:
|
||||
- shipping-portal-staging
|
||||
#################################################################
|
||||
|
||||
volumes:
|
||||
mysql-data:
|
||||
@@ -1,27 +0,0 @@
|
||||
server {
|
||||
listen 80;
|
||||
index index.php index.html;
|
||||
server_name localhost;
|
||||
error_log /var/log/nginx/error.log;
|
||||
access_log /var/log/nginx/access.log;
|
||||
root /var/www/html/public;
|
||||
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
try_files $uri =404;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass php:9000;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_intercept_errors on;
|
||||
fastcgi_keep_conn on;
|
||||
fastcgi_param PHP_VALUE "auto_prepend_file= \n allow_url_include=Off \n output_buffering=Off \n output_buffering=4096";
|
||||
}
|
||||
}
|
||||
-123
@@ -1,123 +0,0 @@
|
||||
<style>
|
||||
@media screen and (min-width: 570px) {
|
||||
.extend-modal-body{
|
||||
width: 700px;
|
||||
max-width: calc(100% - 20px);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div class="row m-b-20 bg-white text-black padding-15 rounded extend-modal-body">
|
||||
<div class="col">
|
||||
<div class="row m-b-20 text-info">
|
||||
<div class="col text-center">
|
||||
<h3>Please select the <b>Billing Address</b></h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row b-rounded justify-content-center m-b-15" @click="updateBillingAddressFilters">
|
||||
<div class="col col-md-10 bg-master-lightest margin-auto padding-15">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col pointer d-flex justtify-content-center align-items-center">
|
||||
<i class="fa fs-30 fa-fw" :class="{'fa-square-o': !useDeliveryAddress, 'fa-check-square': useDeliveryAddress, 'text-primary':useDeliveryAddress}" ></i>
|
||||
<p class="m-b-0">Use Delivery Address</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-center m-b-15" v-if="error">
|
||||
<div class="col-10">
|
||||
<small class="text-danger">{{error}}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col col-md-10">
|
||||
<list-component :key="currentKey" style="min-height: 50px;" section="addressList" :emptyListSection=false :endpoint="route('api.address.list')" :options="billingAddressFilters">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<select-address-component :data="data" :value="parameters.billing_address_id" v-model="parameters.billing_address_id"></select-address-component>
|
||||
</template>
|
||||
</list-component>
|
||||
<div class="row m-b-10 animate__animated animate__fadeInUpBig animate__delay-1 animate__fast">
|
||||
<div class="col b-a p-t-15 p-b-15 pointer" :class="{ 'b-primary': !parameters.billing_address_id, 'b-grey': parameters.billing_address_id}" @click="parameters.billing_address_id = null">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-auto p-r-0">
|
||||
<i class="fa fs-20 p-t-5" :class="{'fa-circle-o': parameters.billing_address_id, 'fa-check-circle': !parameters.billing_address_id, 'text-primary': !parameters.billing_address_id}"></i>
|
||||
</div>
|
||||
<div class="col-auto semi-bold">New Address</div>
|
||||
</div>
|
||||
<div class="row" v-show="!parameters.billing_address_id">
|
||||
<div class="col">
|
||||
<address-form-component :type="1" :id="company_module_id" section="addressList" @input="parameters.billing_address_id = $event"></address-form-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col"></div>
|
||||
<div class="col-auto">
|
||||
<button type="button" class="btn btn-lg rounded btn-primary" v-if="parameters.billing_address_id" @click="submitForm()">Confirm</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
section: {
|
||||
type: String,
|
||||
default: 'addressList'
|
||||
},
|
||||
company_module_id: {
|
||||
type: Number,
|
||||
default: 1
|
||||
},
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
useDeliveryAddress: false,
|
||||
isLoading: false,
|
||||
error: '',
|
||||
billingAddressFilters: {
|
||||
per_page: 10,
|
||||
HasMorphCompanyModule: this.company_module_id,
|
||||
type: 1
|
||||
},
|
||||
parameters : {
|
||||
company_module_id: this.company_module_id,
|
||||
billing_address_id: '',
|
||||
},
|
||||
item:{
|
||||
id:null
|
||||
},
|
||||
currentKey: 1,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateBillingAddressFilters(){
|
||||
if(this.useDeliveryAddress) {
|
||||
// if use delivery address
|
||||
this.billingAddressFilters = {
|
||||
per_page: 10,
|
||||
HasMorphCompanyModule: this.company_module_id,
|
||||
type: 1
|
||||
}
|
||||
this.parameters.billing_address_id = '';
|
||||
} else {
|
||||
this.billingAddressFilters = {per_page: 10, HasMorphCompanyModule: this.company_module_id,};
|
||||
}
|
||||
this.useDeliveryAddress = !this.useDeliveryAddress;
|
||||
this.currentKey++;
|
||||
},
|
||||
submitForm(){
|
||||
this.submit(this.route('api.address.billingAddress.create'), 'post', this.section, true, true)
|
||||
},
|
||||
successHandler(response){
|
||||
this.closeModal();
|
||||
location.reload();
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -16,8 +16,7 @@
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="changeCustomerName">
|
||||
<change-customer-name-form-component :section="'customerProfileSection'" :data="item"></change-customer-name-form-component>
|
||||
</modal-component>
|
||||
<div class="font-heading fs-20 light">
|
||||
{{item.name}}
|
||||
<div class="font-heading fs-20 light">{{item.name}}
|
||||
<div class="btn btn-xs b-rad-none pointer requestModal d-inline rounded no-border hover-primary" data-type="changeCustomerName" >
|
||||
<i class="fa fa-edit pointer fa-fw fs-15 m-l-5"></i>
|
||||
</div>
|
||||
@@ -93,24 +92,10 @@
|
||||
<h6 class="no-margin">{{item.contact.phone}}</h6>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="row align-items-center">
|
||||
<div class="col">
|
||||
<h6 class="no-margin fs-12">WeChat ID</h6>
|
||||
<h6 class="no-margin">{{item.contact.wechat_id}}</h6>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
<h6 class="no-margin fs-12">Company Type </h6>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="changeBusinessType">
|
||||
<change-business-type-form-component :section="'customerProfileSection'" :data="item"></change-business-type-form-component>
|
||||
</modal-component>
|
||||
<h6 class="no-margin">
|
||||
{{item.type_name}}
|
||||
<div class="btn btn-xs b-rad-none pointer requestModal d-inline rounded no-border hover-primary" data-type="changeBusinessType" v-if="$store.getters.isAdmin">
|
||||
<i class="fa fa-edit pointer fa-fw fs-15 m-l-5"></i>
|
||||
</div>
|
||||
</h6>
|
||||
<h6 class="no-margin fs-12">WeChat ID</h6>
|
||||
<h6 class="no-margin">{{item.contact.wechat_id}}</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -58,12 +58,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="btn-lg btn-primary b-a b-white pointer fs-14 position-relative bg-transparent requestModal" data-type="billingAddressComponent" style="z-index: 2;">Change Billing Address</div>
|
||||
</div>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="billingAddressComponent">
|
||||
<billing-address-section-component :company_module_id="company.company_module.id" :section="section"></billing-address-section-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
<template>
|
||||
<div class="row" style="width: 450px; margin: auto;" @keyup.enter="submitForm">
|
||||
<div class="col bg-white padding-40 b-rad-lg">
|
||||
<div class="row m-b-10">
|
||||
<div class="col text-center">
|
||||
<h3>Edit Company Type</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-15 m-b-15">
|
||||
<div class="col p-r-5">
|
||||
<div class="b-grey b-a w-100 text-center p-l-15 p-r-15 p-t-10 p-b-10 pointer fs-15" :class="[{'b-primary': parameters.type === 0}]" @click="updateType(0)">Personal<br>Business</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="b-grey b-a w-100 text-center p-l-15 p-r-15 p-t-10 p-b-10 pointer fs-15" :class="[{'b-primary': parameters.type === 1}]" @click="updateType(1)">Company<br>Business</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-15">
|
||||
<div class="col-auto p-r-5">
|
||||
<div class="btn btn-lg btn-default b-rad-none" data-dismiss="modal">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-primary w-100 btn-lg" @click="submitForm">Confirm</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import modalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
parameters: {
|
||||
type: this.data.type,
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
successHandler(response) {
|
||||
window.location.replace(this.route('customers', response.payload.data.reference));
|
||||
},
|
||||
submitForm() {
|
||||
this.submit(this.route('api.company.update.type', this.data.id), 'put', this.section, true, true)
|
||||
},
|
||||
updateType(type) {
|
||||
this.parameters.type = type;
|
||||
},
|
||||
},
|
||||
mixins: [modalFormHandler]
|
||||
}
|
||||
|
||||
</script>
|
||||
+4
-6
@@ -27,6 +27,10 @@
|
||||
<div v-if="!item.suspended_invoice">n/a</div>
|
||||
<div v-if="item.suspended_invoice">MYR {{ item.suspended_invoice.amount.toFixed(2) }}</div>
|
||||
</div>
|
||||
<div class="col" v-if="invoice_status == 'Suspended Invoice'">
|
||||
<p class="no-margin fs-10 all-caps">Billing Question</p>
|
||||
<div>{{ latestComment ? latestComment.content : '' }} </div>
|
||||
</div>
|
||||
<div class="col-auto p-l-0 p-r-0" v-if="['Suspended Invoice'].includes(invoice_status)">
|
||||
<div class="btn bg-grey no-border muted requestModal" data-type="deleteDispute">
|
||||
<i class="fa fa-close"></i>
|
||||
@@ -60,12 +64,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col" v-if="invoice_status == 'Suspended Invoice'">
|
||||
<p class="no-margin fs-10 all-caps">Billing Question</p>
|
||||
<div>{{ latestComment ? latestComment.content : '' }} </div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row b-t b-grey p-t-10 m-l-5 m-r-5" v-show="expanded">
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<template>
|
||||
<div class="row bg-white padding-25">
|
||||
<div class="col">
|
||||
<div class="row m-b-20 text-info">
|
||||
<div class="col text-center">
|
||||
<h3>Please select the address where you want to receive this order</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-center m-b-15" v-if="error">
|
||||
<div class="col-10">
|
||||
<small class="text-danger">{{error}}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col col-md-10">
|
||||
<list-component style="min-height: 50px;" class="m-b-20" section="addressList" :emptyListSection=false :endpoint="route('api.address.list')" :options="{per_page: 5, HasMorphCompanyModule: data.order.company_module.id}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<select-address-component :data="data" :value="parameters.address_id" v-model="parameters.address_id"></select-address-component>
|
||||
</template>
|
||||
</list-component>
|
||||
<div class="row m-b-10 animate__animated animate__fadeInUpBig animate__delay-1 animate__fast">
|
||||
<div class="col b-a p-t-15 p-b-15 pointer" :class="{ 'b-primary': !parameters.address_id, 'b-grey': parameters.address_id}" @click="parameters.address_id = null">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-auto p-r-0">
|
||||
<i class="fa fs-20 p-t-5" :class="{'fa-circle-o': parameters.address_id, 'fa-check-circle': !parameters.address_id, 'text-primary': !parameters.address_id}"></i>
|
||||
</div>
|
||||
<div class="col-auto semi-bold">New Address</div>
|
||||
</div>
|
||||
<div class="row" v-show="!parameters.address_id">
|
||||
<div class="col">
|
||||
<address-form-component :id="data.order.company_module.id" section="addressList" @input="parameters.address_id = $event"></address-form-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row m-t-15 justify-content-center">
|
||||
<div class="col-6 col-md-4 p-r-5">
|
||||
<div class="btn btn-default w-100 btn-lg b-rad-none" data-dismiss="modal">Cancel</div>
|
||||
</div>
|
||||
<div class="col-6 col-md-4 p-l-5">
|
||||
<!-- <div class="btn btn-primary w-100 btn-lg" @click="submit(route('api.segment.constant.update.postcode', 1), 'put', section, true, true)">Confirm</div> -->
|
||||
<div class="btn btn-primary w-100 btn-lg">Confirm</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import modalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
error: '',
|
||||
parameters : {
|
||||
warehouse_id: '',
|
||||
address_id: '',
|
||||
}
|
||||
}
|
||||
},
|
||||
mixins: [modalFormHandler]
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,179 @@
|
||||
@extends('layouts.base_portal')
|
||||
@section('inner_content')
|
||||
<div class="row">
|
||||
<div class="col bg-white p-t-15 p-b-15">
|
||||
<div class="row no-margin">
|
||||
<div class="col-12">
|
||||
<form method="post" >
|
||||
@csrf
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<input class="form-control" type="text" name="marking" placeholder="Marking" value="{{$marking}}">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input class="form-control" type="text" name="customer_email" placeholder="Email" value="{{$email}}">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input class="form-control" type="text" name="booking_reference" placeholder="Booking Reference" value="{{$bookingReference}}">
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button class="btn btn-complete" type="submit">Search</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<main>
|
||||
@if($company)
|
||||
@php
|
||||
$employees = $company->employees;
|
||||
$primaryEmployee = $employees->first();
|
||||
$identification = $company->documents->whereIn('document_type', \App\Classes\ValueObjects\Constants\DocumentType::IDENTIFICATION_DOCUMENTS)->first()
|
||||
@endphp
|
||||
<section id="customer-account" class="m-b-50">
|
||||
<h3>Customer Account</h3>
|
||||
<p>Marking: <span><a href="{{route('customer.profile', $company->reference)}}" target="_blank">{{$company->reference}}</a></span></p>
|
||||
<p>Account Type: <span>{{$company->type === 1 ? 'Business' : 'Personal'}}</span></p>
|
||||
@if($company->type === 1)<p>Company's Name: <span>{{$company->name}}</span></p>@endif
|
||||
<p>Customer's Name: <span>{{$employees->pluck('name')->implode(', ')}}</span></p>
|
||||
<p>Email: <span>{{$employees->pluck('email')->implode(', ')}}</span></p>
|
||||
<p>Phone: <span>{{$company->contacts->pluck('phone')->implode(', ')}}</span></p>
|
||||
<p>Registration Date: <span>{{$company->created_at->format('d-m-Y')}}</span></p>
|
||||
</section>
|
||||
<section id="customer-verification" class="m-b-50">
|
||||
<h3>Customer Verification</h3>
|
||||
<p>Email Verification Status: <span>{{ $primaryEmployee->status === 2 ? 'Verified' : 'Pending Verification'}}</span></p>
|
||||
<p>Identification Verification Status: <span>{{$identification ? ($identification->status === 2 ? 'Verified' : 'Pending Verification') : 'Not Submitted'}}</span></p>
|
||||
</section>
|
||||
@if(!$booking)
|
||||
<section>
|
||||
<h3>Customer Bookings</h3>
|
||||
@php
|
||||
$bookings = $company->bookings()->whereIn('status', [2, 3])->get();
|
||||
@endphp
|
||||
<section>
|
||||
@foreach($bookings as $booking)
|
||||
@php
|
||||
$payments = $booking->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PAYMENT)->get();
|
||||
$purchaseOrder = $booking->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PURCHASE_ORDER)->first();
|
||||
@endphp
|
||||
<section class="m-b-50">
|
||||
<h5 class="bold">Booking Reference: {{$booking->marking}}</h5>
|
||||
<p>Amount: <span>{{$booking->fix_amount.' '.$booking->fixedCurrency->short_code}}</span></p>
|
||||
<p>Status: <span>{{$booking->status === 3 ? 'Complete' : 'In Progress'}}</span></p>
|
||||
<p>Purchase Order Status: <span>{{$purchaseOrder ? ($purchaseOrder->status === 3 ? 'Approved' : ($purchaseOrder->status === 1 ? 'Pending Approval' : 'Incomplete Submission')) : 'Pending Submission'}}</span></p>
|
||||
@if($payments)<p class="m-t-35 bold">Payment History:</p>@endif
|
||||
@php $i = 1; @endphp
|
||||
@foreach($payments as $payment)
|
||||
@php
|
||||
$bill = $payment->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::BILL)->first();
|
||||
$transferProof = null;
|
||||
$status = 'Pending Submission';
|
||||
|
||||
if($payment->status === 1) {
|
||||
$status = 'Pending Approval';
|
||||
}
|
||||
|
||||
if($payment->status === 2) {
|
||||
$status = 'Pending Confirmation';
|
||||
}
|
||||
|
||||
if(in_array($payment->status, [4, 5])) {
|
||||
$status = 'Rejected/Failed Payment';
|
||||
}
|
||||
|
||||
if($bill) {
|
||||
if($bill->status === 1) {
|
||||
$status = 'Pending Transfer Proof';
|
||||
}
|
||||
|
||||
if(in_array($bill->status, [2, 3])) {
|
||||
$status = 'Transfer Complete';
|
||||
$transferProof = $bill->documents()->first();
|
||||
}
|
||||
}
|
||||
|
||||
@endphp
|
||||
<section class="m-b-35">
|
||||
<p>{{$i++}}.</p>
|
||||
<p>Amount: <span>{{$payment->original_amount.' '.$payment->original_currency->short_code}}</span></p>
|
||||
<p>Status: <span>{{$status}}</span></p>
|
||||
<p>Payment Date: <span>{{$payment->created_at->format('d-m-Y')}}</span></p>
|
||||
@if($bill)
|
||||
<p>Supplier: <span>{{$bill->issuerCompany->name}}</span></p>
|
||||
<p>Supplier Order Date: <span>{{$bill->created_at->format('d-m-Y')}}</span></p>
|
||||
@if($transferProof)<p>Transfer Proof Upload Date: <span>{{$transferProof->created_at->format('d-m-Y')}}</span></p>@endif
|
||||
@endif
|
||||
</section>
|
||||
@endforeach
|
||||
</section>
|
||||
@endforeach
|
||||
</section>
|
||||
</section>
|
||||
@endif
|
||||
@endif
|
||||
@if($booking)
|
||||
@php
|
||||
$payments = $booking->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PAYMENT)->get();
|
||||
$purchaseOrder = $booking->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::PURCHASE_ORDER)->first();
|
||||
@endphp
|
||||
<section>
|
||||
<h5 class="bold">Booking Reference: {{$booking->marking}}</h5>
|
||||
<p>Amount: <span>{{$booking->fix_amount.' '.$booking->fixedCurrency->short_code}}</span></p>
|
||||
<p>Status: <span>{{$booking->status === 3 ? 'Complete' : 'In Progress'}}</span></p>
|
||||
<p>Purchase Order Status: <span>{{$purchaseOrder ? ($purchaseOrder->status === 3 ? 'Approved' : ($purchaseOrder->status === 1 ? 'Pending Approval' : 'Incomplete Submission')) : 'Pending Submission'}}</span></p>
|
||||
@if($payments)<p class="m-t-35 bold">Payment History:</p>@endif
|
||||
@php $i = 1; @endphp
|
||||
@foreach($payments as $payment)
|
||||
@php
|
||||
$bill = $payment->transactions()->where('type', \App\Classes\ValueObjects\Constants\TransactionType::BILL)->first();
|
||||
$transferProof = null;
|
||||
|
||||
$status = 'Pending Submission';
|
||||
|
||||
if($payment->status === 1) {
|
||||
$status = 'Pending Approval';
|
||||
}
|
||||
|
||||
if($payment->status === 2) {
|
||||
$status = 'Pending Confirmation';
|
||||
}
|
||||
|
||||
if(in_array($payment->status, [4, 5])) {
|
||||
$status = 'Rejected/Failed Payment';
|
||||
}
|
||||
|
||||
if($bill) {
|
||||
if($bill->status === 1) {
|
||||
$status = 'Pending Transfer Proof';
|
||||
}
|
||||
|
||||
if(in_array($bill->status, [2, 3])) {
|
||||
$status = 'Transfer Complete';
|
||||
$transferProof = $bill->documents()->first();
|
||||
}
|
||||
}
|
||||
|
||||
@endphp
|
||||
<section class="m-b-35">
|
||||
<p>{{$i++}}.</p>
|
||||
<p>Amount: <span>{{$payment->original_amount.' '.$payment->original_currency->short_code}}</span></p>
|
||||
<p>Status: <span>{{$status}}</span></p>
|
||||
<p>Payment Date: <span>{{$payment->created_at->format('d-m-Y')}}</span></p>
|
||||
@if($bill)
|
||||
<p>Supplier: <span>{{$bill->issuerCompany->name}}</span></p>
|
||||
<p>Supplier Order Date: <span>{{$bill->created_at->format('d-m-Y')}}</span></p>
|
||||
@if($transferProof)<p>Transfer Proof Upload Date: <span>{{$transferProof->created_at->format('d-m-Y')}}</span></p>@endif
|
||||
@endif
|
||||
</section>
|
||||
@endforeach
|
||||
</section>
|
||||
@endif
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
+1
-1
@@ -35,7 +35,7 @@ Route::group(['prefix' => 'account', 'namespace' => 'Accounts', 'as' => 'account
|
||||
});
|
||||
|
||||
Route::group(['middleware' => 'valid.token', 'prefix' => 'user', 'as' => 'user.'], function () {
|
||||
Route::get('/email/{email}', 'FetchUserByEmailController@fetch')->name('company');
|
||||
Route::get('/{email}', 'FetchUserByEmailController@fetch')->name('company');
|
||||
Route::post('/show', 'FetchUserController@fetch')->name('show');
|
||||
Route::get('/list', 'ListUsersController@list')->name('list');
|
||||
Route::put('/update/{id}', 'UpdateUserController@update')->name('update');
|
||||
|
||||
@@ -14,8 +14,6 @@ Route::group(['prefix' => 'address', 'as' => 'address.', 'namespace' => 'Address
|
||||
Route::get('state/list', 'ListStatesController@list')->name('state.list');
|
||||
|
||||
Route::post('/create', 'CreateAddressController@create')->name('create');
|
||||
|
||||
Route::post('billingAddress/create', 'CreateBillingAddressController@create')->name('billingAddress.create');
|
||||
|
||||
Route::put('/update/{id}', 'UpdateAddressController@update')->name('update');
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ Route::group(['prefix' => 'company', 'as' => 'company.', 'namespace' => 'Compani
|
||||
Route::put('/update/{id}', 'UpdateCompanyController@update')->name('update');
|
||||
Route::delete('/delete/{id}', 'DeleteCompanyController@destroy')->name('delete');
|
||||
Route::put('/name-and-debtor/update/{id}', 'UpdateCompanyNameAndDebtorController@update')->name('update.nameAndDebtor');
|
||||
Route::put('/type/update/{id}', 'UpdateCompanyTypeController@create')->name('update.type');
|
||||
|
||||
Route::post('/team/create', 'AddNewMemberController@create')->name('team.create');
|
||||
|
||||
|
||||
+64
-209
@@ -44,6 +44,8 @@ use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Models\Company;
|
||||
use App\Models\Booking;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -727,8 +729,6 @@ Route::get('/invoices/fix/{company_module_id}', function($company_module_id) {
|
||||
$document = (App()->make(CreatesDocument::class))->execute($invoice, $document_object);
|
||||
|
||||
(App()->make(CreatesFiles::class))->execute($document, $document_object);
|
||||
|
||||
dump($document);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -744,33 +744,33 @@ Route::get('/invoices/combine/{ids}', function($ids){
|
||||
return $pdf->download('combined_invoice_.pdf');
|
||||
})->name('invoice.combined_summary');
|
||||
|
||||
// Route::get('/generate/invoices', function(){
|
||||
// $packingLists = (App()->make(ListsPackingLists::class))->execute(['does_not_have_transaction_type' => 1, 'type' => 2]);
|
||||
// foreach ($packingLists as $packingList){
|
||||
// $order = $packingList->owner;
|
||||
// if(!($order instanceof Order)) {
|
||||
// echo '<span style="color: red;">failed to generate...</span><br>';
|
||||
// continue;
|
||||
// }
|
||||
Route::get('/generate/invoices', function(){
|
||||
$packingLists = (App()->make(ListsPackingLists::class))->execute(['does_not_have_transaction_type' => 1, 'type' => 2]);
|
||||
foreach ($packingLists as $packingList){
|
||||
$order = $packingList->owner;
|
||||
if(!($order instanceof Order)) {
|
||||
echo '<span style="color: red;">failed to generate...</span><br>';
|
||||
continue;
|
||||
}
|
||||
|
||||
// $companyModule = $order->companyModule;
|
||||
// $billingAddress = $companyModule->addresses()->where('type', \App\Classes\ValueObjects\Constants\AddressType::BILLING)->first();
|
||||
// $deliveryAddress = $order->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
||||
$companyModule = $order->companyModule;
|
||||
$billingAddress = $companyModule->addresses()->where('type', \App\Classes\ValueObjects\Constants\AddressType::BILLING)->first();
|
||||
$deliveryAddress = $order->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
||||
|
||||
// $postCodes = \App\Models\SegmentConstant::whereIn('reference', ['CENTER_POSTCODE', 'OUTSTATION_POSTCODE'])->get()->pluck('value')->flatten();
|
||||
$postCodes = \App\Models\SegmentConstant::whereIn('reference', ['CENTER_POSTCODE', 'OUTSTATION_POSTCODE'])->get()->pluck('value')->flatten();
|
||||
|
||||
// if(!!$billingAddress && in_array($deliveryAddress->postcode, $postCodes->toArray())){
|
||||
// try {
|
||||
// (App()->make(CreateInvoiceTransactionProcessor::class))->execute($packingList);
|
||||
// echo '<span style="color: green;">Invoice Generated...</span><br>';
|
||||
if(!!$billingAddress && in_array($deliveryAddress->postcode, $postCodes->toArray())){
|
||||
try {
|
||||
(App()->make(CreateInvoiceTransactionProcessor::class))->execute($packingList);
|
||||
echo '<span style="color: green;">Invoice Generated...</span><br>';
|
||||
|
||||
// } catch (Exception $exception){
|
||||
// echo '<span style="color: red;">failed to generate...</span><br>';
|
||||
// }
|
||||
// }
|
||||
// echo '<span style="color: red;">failed to generate...</span><br>';
|
||||
// }
|
||||
// })->name('generate.invoices');
|
||||
} catch (Exception $exception){
|
||||
echo '<span style="color: red;">failed to generate...</span><br>';
|
||||
}
|
||||
}
|
||||
echo '<span style="color: red;">failed to generate...</span><br>';
|
||||
}
|
||||
})->name('generate.invoices');
|
||||
|
||||
Route::get('/invoices/approve', function(Request $request){
|
||||
// whereDoesntHave
|
||||
@@ -780,10 +780,8 @@ Route::get('/invoices/approve', function(Request $request){
|
||||
$packingList = $invoice->owner;
|
||||
$order = $packingList->owner;
|
||||
|
||||
if ($request->input('exclude')){
|
||||
if(in_array($order->reference, json_decode($request->input('exclude')))){
|
||||
continue;
|
||||
}
|
||||
if(in_array($order->reference, json_decode($request->input('exclude')))){
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -799,189 +797,46 @@ Route::get('/invoices/approve', function(Request $request){
|
||||
|
||||
})->name('invoices.approve');
|
||||
|
||||
Route::get('/invoices/show-duplicated', function(Request $request){
|
||||
$transactionWithMultipleInvoice = DB::table('transactions')
|
||||
->where('type', TransactionType::SHIPPING_INVOICE)
|
||||
->where('status', '!=' , ApprovalStatus::EXPIRED)
|
||||
->where('deleted_at', null)
|
||||
->select('owner_id', DB::raw('count(*) as count'))
|
||||
->groupBy('owner_id')
|
||||
->having('count', '>', 1)
|
||||
->get();
|
||||
Route::get('/support', function () {
|
||||
return view('pages.customer_support', [
|
||||
'marking' => null,
|
||||
'email' => null,
|
||||
'bookingReference' => null,
|
||||
'company' => null,
|
||||
'booking' => null
|
||||
]);
|
||||
})->name('support');
|
||||
|
||||
echo 'Total Duplicates: ' . count($transactionWithMultipleInvoice) . '<br>';
|
||||
Route::post('/support', function (Request $request) {
|
||||
|
||||
$duplicatedOrderId = [];
|
||||
$duplicatedOrderArray = [];
|
||||
foreach($transactionWithMultipleInvoice as $invoice) {
|
||||
$duplicatedOrderId[] = $invoice->owner_id;
|
||||
$duplicatedOrderArray[$invoice->owner_id] = $invoice->count;
|
||||
$marking = $request->input('marking');
|
||||
$email = $request->input('customer_email');
|
||||
$bookingReference = $request->input('booking_reference');
|
||||
|
||||
$company = null;
|
||||
$booking = null;
|
||||
|
||||
if($email) {
|
||||
$company = Company::whereHas('Employees', function($user) use($email) {
|
||||
return $user->where('email', $email);
|
||||
})->first();
|
||||
}
|
||||
|
||||
$duplicatedInvoice = Transaction::whereIn('owner_id', $duplicatedOrderId)->orderByDesc('owner_id')->get();
|
||||
echo '<br>';
|
||||
echo '<table>';
|
||||
echo "<tr>";
|
||||
echo "<td style='border:1px solid'>Order Reference</td>";
|
||||
echo "<td style='border:1px solid'>Status</td>";
|
||||
echo "<td style='border:1px solid'>Invoice Owner ID</td>";
|
||||
echo "<td style='border:1px solid'>Amount</td>";
|
||||
echo "<td style='border:1px solid'>Count</td>";
|
||||
echo "</tr>";
|
||||
|
||||
foreach($duplicatedInvoice as $invoice) {
|
||||
$order = $invoice->owner->owner;
|
||||
echo "<tr>";
|
||||
echo '<td style="border:1px solid"><a target="_blank" href="'.route('order.show', $order->reference).'">'. $order->reference.' - </a>' . $order->created_at . '</td>';
|
||||
echo "<td style='border:1px solid'>".ApprovalStatus::APPROVAL_STATUS_ID[$invoice->status]."</td>";
|
||||
echo "<td style='border:1px solid'>$invoice->owner_id</td>";
|
||||
echo "<td style='border:1px solid'>$invoice->amount</td>";
|
||||
echo "<td style='border:1px solid'>".$duplicatedOrderArray[$invoice->owner_id]."</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo '</table>';
|
||||
});
|
||||
|
||||
Route::get('/invoices/delete-duplicated', function(Request $request){
|
||||
$duplicatedInvoices = DB::table('transactions')
|
||||
->where('type', TransactionType::SHIPPING_INVOICE)
|
||||
->where('status', '!=' , ApprovalStatus::EXPIRED)
|
||||
->where('deleted_at', null)
|
||||
->select('owner_id', DB::raw('count(*) as count'))
|
||||
->groupBy('owner_id')
|
||||
->having('count', '>', 1)
|
||||
->get();
|
||||
|
||||
$duplicatedInvoices = Transaction::whereIn('owner_id', $duplicatedInvoices->pluck('owner_id'))->get()->groupBy('owner_id');
|
||||
|
||||
foreach($duplicatedInvoices as $invoice) {
|
||||
$packingList = $invoice->first()->owner;
|
||||
$order = $packingList->owner;
|
||||
|
||||
$paidInvoice = $packingList->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::COMPLETED)->get();
|
||||
|
||||
// if have completed invoice (verified payment)
|
||||
if (count($paidInvoice)) {
|
||||
$packingList->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->where('status', '!=', ApprovalStatus::COMPLETED)->delete();
|
||||
continue;
|
||||
} else {
|
||||
dump($order->reference . ' -no');
|
||||
}
|
||||
|
||||
// if have unverified payment
|
||||
// $paymentHistory = $packingList->transactions()->whereHas('transactions', function($query){
|
||||
// return $query->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::PENDING_SUBMISSION ,ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::COMPLETED, ApprovalStatus::REJECTED]);
|
||||
// })->get();
|
||||
// if (count($paymentHistory)) {
|
||||
// $packingList->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->where('id', '!=', $paymentHistory->first()->id)->delete();
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// // delete duplicated invoices
|
||||
// $unpaidInvoices = $packingList->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::PENDING_SUBMISSION, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED])->orderBy('id', 'desc')->get();
|
||||
|
||||
// $unpaidInvoicesIds = $unpaidInvoices->pluck('id')->toArray();
|
||||
// array_shift($unpaidInvoicesIds);
|
||||
// Transaction::whereIn('id', $unpaidInvoicesIds)->delete();
|
||||
|
||||
// // delete expired invoices
|
||||
// $packingList->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->where('status', '!=', ApprovalStatus::EXPIRED)->delete();
|
||||
|
||||
// // delete suspended invoices
|
||||
// $suspendedInvoices = $packingList->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->where('status', '!=', ApprovalStatus::SUSPENDED)->orderBy('id', 'desc')->get();
|
||||
// $suspendedInvoicesIds = $suspendedInvoices->pluck('id')->toArray();
|
||||
// array_shift($suspendedInvoicesIds);
|
||||
// Transaction::whereIn('id', $suspendedInvoicesIds)->delete();
|
||||
}
|
||||
});
|
||||
|
||||
Route::get('/packing-lists/show-duplicated', function(Request $request){
|
||||
$results = PackingList::select('reference', 'type', DB::raw('count(*) as total'))
|
||||
->groupBy('reference', 'type')
|
||||
->having('total', '>', 1)
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
echo '<table>';
|
||||
echo "<tr>";
|
||||
echo "<td style='border:1px solid'>reference</td>";
|
||||
echo "<td style='border:1px solid'>type</td>";
|
||||
echo "<td style='border:1px solid'>count</td>";
|
||||
echo "</tr>";
|
||||
|
||||
foreach($results as $result) {
|
||||
// dd($result);
|
||||
echo "<tr>";
|
||||
echo "<td style='border:1px solid'>" . $result['reference'] . "</td>";
|
||||
echo "<td style='border:1px solid'>" . $result['type'] . "</td>";
|
||||
echo "<td style='border:1px solid'>" . $result['total'] . "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo '</table>';
|
||||
});
|
||||
|
||||
Route::get('/packing-lists/delete-duplicated', function(Request $request){
|
||||
$results = PackingList::select('reference', 'type', DB::raw('count(*) as total'))
|
||||
->groupBy('reference', 'type')
|
||||
->having('total', '>', 1)
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
foreach($results as $result) {
|
||||
$duplicatedPackingList = PackingList::where('reference', $result['reference'])->where('type', $result['type'])->orderBy('id', 'desc')->get();
|
||||
|
||||
// if packinglist has paid inivoice
|
||||
$paidPackinglist = PackingList::where('reference', $result['reference'])->where('type', $result['type'])->whereHas('transactions', function($query){
|
||||
return $query->where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::COMPLETED);
|
||||
})->get();
|
||||
|
||||
if (count($paidPackinglist)) {
|
||||
// delete all the other packing list
|
||||
$paidPackinglistID = $paidPackinglist->first()->id;
|
||||
$duplicatedPackingList = PackingList::where('reference', $result['reference'])->where('type', $result['type'])->where('id', '!=', $paidPackinglistID)->get();
|
||||
// $duplicatedPackingList->delete();
|
||||
foreach ($duplicatedPackingList as $p) {
|
||||
$p->delete();
|
||||
dump('have paid packinglist, deleting id:' . $p->id);
|
||||
}
|
||||
} else {
|
||||
// delete all but left the latest packing list
|
||||
$firstItem = $duplicatedPackingList->shift();
|
||||
// dump('dont have paid packinglist, keep first and delete others');
|
||||
foreach ($duplicatedPackingList as $p) {
|
||||
$p->delete();
|
||||
dump('dont have paid packinglist, keep latest id:' . $firstItem->id . ', and deleting id:' . $p->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
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>";
|
||||
}
|
||||
if($marking) {
|
||||
$company = Company::where('reference', $marking)->first();
|
||||
}
|
||||
|
||||
echo 'Total: ' . $totalAmount;
|
||||
});
|
||||
if($bookingReference) {
|
||||
$booking = Booking::where('marking', $bookingReference)->first();
|
||||
$company = $booking->company;
|
||||
}
|
||||
|
||||
return view('pages.customer_support', [
|
||||
'marking' => $marking,
|
||||
'email' => $email,
|
||||
'bookingReference' => $bookingReference,
|
||||
'company' => $company,
|
||||
'booking' => $booking,
|
||||
]);
|
||||
|
||||
})->name('support');
|
||||
Reference in New Issue
Block a user