mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-21 13:33:57 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -16,27 +16,17 @@ class CreatePerfexCRMInvoice implements ShouldQueue
|
||||
/** @var $transaction*/
|
||||
private $transaction;
|
||||
|
||||
/** @var $purchaseOrder*/
|
||||
private $purchaseOrder;
|
||||
|
||||
/** @var $supplier*/
|
||||
private $supplier;
|
||||
|
||||
/**
|
||||
* CreatePerfexCRMInvoice constructor.
|
||||
* @param $transaction
|
||||
* @param $purchaseOrder
|
||||
* @param $supplier
|
||||
*/
|
||||
public function __construct($transaction, $purchaseOrder, $supplier)
|
||||
public function __construct($transaction)
|
||||
{
|
||||
$this->transaction = $transaction;
|
||||
$this->purchaseOrder = $purchaseOrder;
|
||||
$this->supplier = $supplier;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
(App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($this->transaction, $this->purchaseOrder, $this->supplier);
|
||||
(App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($this->transaction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Processors\FetchPerfexCRMInvoiceProcessor;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@@ -10,8 +11,10 @@ use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\FetchPerfexCRMInvoiceObject;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Logical\Boolean;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
|
||||
class UpdatePerfexCRM implements ShouldQueue
|
||||
{
|
||||
@@ -41,6 +44,9 @@ class UpdatePerfexCRM implements ShouldQueue
|
||||
|
||||
public function handle()
|
||||
{
|
||||
//To use invoice as a reference to decide whether more tasks should be created
|
||||
$this->updatePerfexCRMObject->setInvoiceId($this->getInvoiceIdOrCreateInvoice());
|
||||
|
||||
$result = (App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
|
||||
if($this->transaction != null && $this->shouldCreateInvoice){
|
||||
$updatePerfexCRMInvoiceObject = new UpdatePerfexCRMInvoiceObject(
|
||||
@@ -50,9 +56,19 @@ class UpdatePerfexCRM implements ShouldQueue
|
||||
$this->transaction,
|
||||
true
|
||||
);
|
||||
|
||||
UpdatePerfexCRMInvoice::dispatch($updatePerfexCRMInvoiceObject);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private function getInvoiceIdOrCreateInvoice(){
|
||||
if($this->transaction != null){
|
||||
$fetchPerfexCRMInvoiceObject = new FetchPerfexCRMInvoiceObject(
|
||||
$this->updatePerfexCRMObject->getContactEmail(),
|
||||
$this->transaction
|
||||
);
|
||||
$invoiceId = (App()->make(FetchPerfexCRMInvoiceProcessor::class))->execute($fetchPerfexCRMInvoiceObject);
|
||||
return $invoiceId;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
Log::error(json_encode('UpdatePerfexCRMInvoice debug $number: '.$number));
|
||||
|
||||
if(is_null($invoice)){
|
||||
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction, null, null, $this->updatePerfexCRMInvoiceObject->getIsPaid());
|
||||
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction);
|
||||
if ($result) {
|
||||
$invoiceId = $result->payload['id'];
|
||||
} else {
|
||||
|
||||
@@ -42,7 +42,10 @@ class CreateTaskPerfexCRMObject implements DataTransferObject
|
||||
/** @var string */
|
||||
private $duedate;
|
||||
|
||||
public function __construct(string $email, string $name, string $description, string $leadId, string $projectId, string $milestoneId, string $reference, string $onTaskCompletion, string $status, string $department, string $priority, string $duedate)
|
||||
/** @var int */
|
||||
private $invoiceId;
|
||||
|
||||
public function __construct(string $email, string $name, string $description, string $leadId, string $projectId, string $milestoneId, string $reference, string $onTaskCompletion, string $status, string $department, string $priority, string $duedate, int $invoiceId)
|
||||
{
|
||||
$this->email = $email;
|
||||
$this->name = $name;
|
||||
@@ -56,6 +59,7 @@ class CreateTaskPerfexCRMObject implements DataTransferObject
|
||||
$this->department = $department;
|
||||
$this->priority = $priority;
|
||||
$this->duedate = $duedate;
|
||||
$this->invoiceId = $invoiceId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,4 +162,12 @@ class CreateTaskPerfexCRMObject implements DataTransferObject
|
||||
{
|
||||
return $this->duedate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getInvoiceId(): int
|
||||
{
|
||||
return $this->invoiceId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Models\Transaction;
|
||||
|
||||
class FetchPerfexCRMInvoiceObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $email;
|
||||
|
||||
/** @var Transaction */
|
||||
private $transaction;
|
||||
|
||||
|
||||
public function __construct(string $email, Transaction $transaction)
|
||||
{
|
||||
$this->email = $email;
|
||||
$this->transaction = $transaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Transaction
|
||||
*/
|
||||
public function getTransaction(): Transaction
|
||||
{
|
||||
return $this->transaction;
|
||||
}
|
||||
}
|
||||
@@ -34,8 +34,11 @@ class UpdatePerfexCRMObject implements DataTransferObject
|
||||
/** @var array */
|
||||
private $tasks;
|
||||
|
||||
/** @var int */
|
||||
private $invoiceId = 0;
|
||||
|
||||
public function __construct(string $companyName, string $companyReference, string $contactName, string $contactEmail, string $bookingMarking, string $projectName, int $projectStatus, array $milestoneNames, array $tasks)
|
||||
|
||||
public function __construct(string $companyName, string $companyReference, string $contactName, string $contactEmail, string $bookingMarking, string $projectName, int $projectStatus, int $invoiceId, array $milestoneNames, array $tasks)
|
||||
{
|
||||
|
||||
$this->companyName = $companyName;
|
||||
@@ -45,6 +48,7 @@ class UpdatePerfexCRMObject implements DataTransferObject
|
||||
$this->bookingMarking = $bookingMarking;
|
||||
$this->projectName = $projectName;
|
||||
$this->projectStatus = $projectStatus;
|
||||
$this->$invoiceId = $invoiceId;
|
||||
$this->milestoneNames = $milestoneNames;
|
||||
$this->tasks = $tasks;
|
||||
}
|
||||
@@ -105,6 +109,14 @@ class UpdatePerfexCRMObject implements DataTransferObject
|
||||
return $this->projectStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getInvoiceId(): int
|
||||
{
|
||||
return $this->invoiceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -126,4 +138,9 @@ class UpdatePerfexCRMObject implements DataTransferObject
|
||||
$this->tasks = $tasks;
|
||||
}
|
||||
|
||||
public function setInvoiceId($invoiceId)
|
||||
{
|
||||
$this->invoiceId = $invoiceId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ class BookingToPerfexCRMProcessor
|
||||
$bookingMarking,
|
||||
$projectName,
|
||||
PerfexCRMProjectStatus::NOT_STARTED,
|
||||
0,
|
||||
[],
|
||||
[]
|
||||
);
|
||||
|
||||
@@ -59,23 +59,16 @@ class CreatePerfexCRMInvoiceProcessor
|
||||
|
||||
/**
|
||||
* @param $transaction
|
||||
* @param $purchaseOrder
|
||||
* @param $supplier
|
||||
* @return null|object
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute($transaction, $purchaseOrder, $supplier) {
|
||||
public function execute($transaction) {
|
||||
$booking = $transaction->booking;
|
||||
|
||||
if(is_null($supplier)){
|
||||
$supplier = $this->fetchesCompany->execute(['id' => $transaction->receiver]);
|
||||
}
|
||||
if(is_null($purchaseOrder)){
|
||||
$purchaseOrder = $booking->transactions()
|
||||
$supplier = $this->fetchesCompany->execute(['id' => $transaction->receiver]);
|
||||
$purchaseOrder = $booking->transactions()
|
||||
->where('type', TransactionType::PURCHASE_ORDER)
|
||||
->complete()
|
||||
->first();
|
||||
}
|
||||
|
||||
$clientId = "";
|
||||
$number = $transaction->bill_no;
|
||||
@@ -120,7 +113,6 @@ class CreatePerfexCRMInvoiceProcessor
|
||||
$bookingMarking = $transaction->owner->marking;
|
||||
$serviceTypeName = $transaction->owner->company->services()->where('id', $transaction->owner->service_id)->first()->name;
|
||||
$projectName = 'Exchange | '.$serviceTypeName.' | '.$bookingMarking;
|
||||
Log::error('CreatePerfexCRMInvoiceProcessor debug:'.json_encode($transaction));
|
||||
Log::error('$projectName: '.$projectName);
|
||||
return $email;
|
||||
}
|
||||
@@ -199,7 +191,7 @@ class CreatePerfexCRMInvoiceProcessor
|
||||
//When this transaction is of TransactionType::PAYMENT, the amount is actually in the currecy user choose to pay (RM)
|
||||
//So there is no need to convert it
|
||||
if ($transaction->type == TransactionType::PAYMENT){
|
||||
$total = $transaction->amount;
|
||||
$total = number_format($transaction->amount, 2,'.','') * 1;
|
||||
}
|
||||
else{
|
||||
if($booking->first()->fix_currency_id !== 1){
|
||||
@@ -229,26 +221,6 @@ class CreatePerfexCRMInvoiceProcessor
|
||||
);
|
||||
|
||||
$result = $this->createsPerfexCRMInvoice->execute($invoicePerfexCRMObject);
|
||||
|
||||
//cief todo: When invoices need to be regenerated, need to ensure payment do not get double created
|
||||
|
||||
// if(!is_null($result))
|
||||
// {
|
||||
// if($result->payload['id']){
|
||||
// $invoicePaymentPerfexCRMObject = new InvoicePaymentPerfexCRMObject(
|
||||
// $result->payload['id'],
|
||||
// $total,
|
||||
// $date,
|
||||
// 1,
|
||||
// "",
|
||||
// ""
|
||||
// );
|
||||
// $this->createsPerfexCRMInvoicePayment->execute($invoicePaymentPerfexCRMObject);
|
||||
// }
|
||||
// }
|
||||
//else: logs will record the following:
|
||||
//"status":false,"error":{"number":"The Invoice number is already in use"},"message":"<p>The Invoice number is already in use<\/p>"}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,19 +25,7 @@ class CreatePerfexCRMTaskProcessor
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(CreateTaskPerfexCRMObject $createTaskPerfexCRMObject) {
|
||||
$this->createsPerfexCRMTask->execute(
|
||||
$createTaskPerfexCRMObject->getName(),
|
||||
$createTaskPerfexCRMObject->getDescription(),
|
||||
$createTaskPerfexCRMObject->getLeadId(),
|
||||
$createTaskPerfexCRMObject->getMilestoneId(),
|
||||
$createTaskPerfexCRMObject->getProjectId(),
|
||||
$createTaskPerfexCRMObject->getReference(),
|
||||
$createTaskPerfexCRMObject->getOnTaskCompletion(),
|
||||
$createTaskPerfexCRMObject->getDepartment(),
|
||||
$createTaskPerfexCRMObject->getStatus(),
|
||||
$createTaskPerfexCRMObject->getPriority(),
|
||||
$createTaskPerfexCRMObject->getDuedate(),
|
||||
);
|
||||
$this->createsPerfexCRMTask->execute($createTaskPerfexCRMObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Processors;
|
||||
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMInvoiceProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMCustomer;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMInvoice;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\FetchPerfexCRMInvoiceObject;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\General\Helper;
|
||||
|
||||
class FetchPerfexCRMInvoiceProcessor
|
||||
{
|
||||
private $fetchesPerfexCRMCustomer;
|
||||
/** @var FetchesPerfexCRMCustomer */
|
||||
|
||||
/** @var FetchesPerfexCRMInvoice */
|
||||
private $fetchesPerfexCRMInvoice;
|
||||
|
||||
/** @var CreatePerfexCRMInvoiceProcessor */
|
||||
private $createPerfexCRMInvoiceProcessor;
|
||||
|
||||
/**
|
||||
*
|
||||
* FetchPerfexCRMInvoiceProcessor constructor.
|
||||
* @param FetchesPerfexCRMCustomer $fetchesPerfexCRMCustomer
|
||||
* @param FetchesPerfexCRMInvoice $fetchesPerfexCRMInvoice
|
||||
* @param CreatePerfexCRMInvoiceProcessor $createPerfexCRMInvoiceProcessor
|
||||
*/
|
||||
public function __construct(FetchesPerfexCRMCustomer $fetchesPerfexCRMCustomer,
|
||||
FetchesPerfexCRMInvoice $fetchesPerfexCRMInvoice,
|
||||
CreatePerfexCRMInvoiceProcessor $createPerfexCRMInvoiceProcessor)
|
||||
{
|
||||
$this->fetchesPerfexCRMCustomer = $fetchesPerfexCRMCustomer;
|
||||
$this->fetchesPerfexCRMInvoice = $fetchesPerfexCRMInvoice;
|
||||
$this->createPerfexCRMInvoiceProcessor = $createPerfexCRMInvoiceProcessor;
|
||||
}
|
||||
|
||||
public function execute(FetchPerfexCRMInvoiceObject $fetchPerfexCRMInvoiceObject)
|
||||
{
|
||||
//invoiceId to be returned - fetch or create
|
||||
$invoiceId = 0;
|
||||
|
||||
//get the client id
|
||||
$customer = $this->fetchesPerfexCRMCustomer->execute($fetchPerfexCRMInvoiceObject->getEmail());
|
||||
$transaction = $fetchPerfexCRMInvoiceObject->getTransaction();
|
||||
|
||||
$number = $transaction->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));
|
||||
}
|
||||
|
||||
$number = 'EXC-'.$number;
|
||||
$invoice = $this->fetchesPerfexCRMInvoice->execute($customer->userid,"INV-", $number);
|
||||
if(is_null($invoice)){
|
||||
$result = $this->createPerfexCRMInvoiceProcessor->execute($transaction);
|
||||
if ($result) {
|
||||
$invoiceId = $result->payload['id'];
|
||||
} else {
|
||||
$log['message'] = 'FetchPerfexCRMInvoiceProcessor failed for transaction > bill_no: '.$number;
|
||||
Helper::debugLogger($log);
|
||||
}
|
||||
}
|
||||
else{
|
||||
$invoiceId = $invoice->id;
|
||||
}
|
||||
|
||||
return $invoiceId;
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,8 @@ class NewLeadTaskToPerfexCRMProcessor
|
||||
PerfexCRMTasks::TASK_IDENTIFICATION_1['status'],
|
||||
PerfexCRMTasks::TASK_IDENTIFICATION_1['department'],
|
||||
PerfexCRMTaskPriority::DEFAULT,
|
||||
"0"
|
||||
"0",
|
||||
0
|
||||
);
|
||||
|
||||
CreatePerfexCRMSingleTask::dispatch($createTaskPerfexCRMObject);
|
||||
|
||||
@@ -114,6 +114,7 @@ class TransactionToPerfexCRMProcessor
|
||||
$bookingMarking,
|
||||
$projectName,
|
||||
PerfexCRMProjectStatus::IN_PROGRESS,
|
||||
0,
|
||||
[],
|
||||
$tasks
|
||||
);
|
||||
@@ -140,6 +141,7 @@ class TransactionToPerfexCRMProcessor
|
||||
$bookingMarking,
|
||||
$projectName,
|
||||
PerfexCRMProjectStatus::IN_PROGRESS,
|
||||
0,
|
||||
[],
|
||||
$tasks
|
||||
);
|
||||
|
||||
@@ -8,8 +8,6 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMProjectStatus;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTaskStatus;
|
||||
use App\Classes\Jobs\UpdatePerfexCRMInvoice;
|
||||
use App\Classes\Jobs\UpdatePerfexCRM;
|
||||
use App\Classes\Jobs\UpdatePerfexCRMPrelude;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Transaction;
|
||||
@@ -26,6 +24,8 @@ class TransactionToPerfexCRMProcessorV2
|
||||
$projectName = 'Exchange | ' . $bookingInfo['serviceTypeName'] . ' | ' . $bookingInfo['bookingMarking'];
|
||||
$tasks = $this->defineTasks($model, $status);
|
||||
|
||||
Log::error("TransactionToPerfexCRMProcessorV2 status: ".$status." - for project name: ".$projectName);
|
||||
|
||||
if(count($tasks) > 0) {
|
||||
$updatePerfexCRMObject = new UpdatePerfexCRMObject(
|
||||
$bookingInfo['companyName'],
|
||||
@@ -35,6 +35,7 @@ class TransactionToPerfexCRMProcessorV2
|
||||
$bookingInfo['bookingMarking'],
|
||||
$projectName,
|
||||
PerfexCRMProjectStatus::IN_PROGRESS,
|
||||
0,
|
||||
[],
|
||||
$tasks
|
||||
);
|
||||
@@ -42,7 +43,6 @@ class TransactionToPerfexCRMProcessorV2
|
||||
}
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
Log::error('TransactionToPerfexCRMProcessor debug:');
|
||||
Log::error($exception);
|
||||
}
|
||||
return true;
|
||||
@@ -233,7 +233,7 @@ class TransactionToPerfexCRMProcessorV2
|
||||
|
||||
private function dispatchUpdateJob(Transaction $model, int $status, UpdatePerfexCRMObject $updatePerfexCRMObject)
|
||||
{
|
||||
$withInvoice = ($model->type === TransactionType::PAYMENT && $model->owner === Booking::class && $status === ApprovalStatus::APPROVED);
|
||||
$withInvoice = ($model->type === TransactionType::PAYMENT && $model->owner instanceof Booking && $status === ApprovalStatus::APPROVED);
|
||||
UpdatePerfexCRMPrelude::dispatch($model, $updatePerfexCRMObject, $withInvoice);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMTask;
|
||||
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMCustomer;
|
||||
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMProject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CustomerContactObject;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMTaskStatus;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMProjectStatus;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
@@ -203,24 +203,49 @@ class UpdatePerfexCRMProcessor
|
||||
}
|
||||
|
||||
// Get existing or create task
|
||||
$result = $this->fetchesPerfexCRMTask->execute($tasks[$count]['name'], $milestoneId, 'project', $projectId);
|
||||
$taskName = $tasks[$count]['name'];
|
||||
$taskReference = $tasks[$count]['reference'];
|
||||
$taskOnTaskCompletion = $tasks[$count]['on_task_completion'];
|
||||
$taskIsAllowMultiple = $tasks[$count]['is_allow_multiple'];
|
||||
$taskIsOnTaskCompletionUpdate = $tasks[$count]['is_on_task_completion_update'];
|
||||
if($updatePerfexCRMObject->getInvoiceId() != 0 && $taskIsAllowMultiple){
|
||||
$taskName = $taskName." (".$updatePerfexCRMObject->getInvoiceId().")";
|
||||
$taskReference = $taskReference."_".$updatePerfexCRMObject->getInvoiceId();
|
||||
if($taskOnTaskCompletion && $taskIsOnTaskCompletionUpdate){
|
||||
$taskOnTaskCompletion = $taskOnTaskCompletion."_".$updatePerfexCRMObject->getInvoiceId();
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->fetchesPerfexCRMTask->execute($taskName, $milestoneId, 'project', $projectId, $updatePerfexCRMObject->getInvoiceId());
|
||||
// Log::error("UpdatePerfexCRMProcessor task: ".$taskName." , ".json_encode($result));
|
||||
Log::error("UpdatePerfexCRMProcessor task: ".$taskName);
|
||||
|
||||
if(isset($result->payload)){
|
||||
//&& $result->payload[0]['status'] == PerfexCRMTaskStatus::NOT_STARTED
|
||||
Log::info(json_encode([$taskStatus]));
|
||||
if($taskStatus != PerfexCRMTaskStatus::NOT_STARTED )
|
||||
if($taskStatus != PerfexCRMTaskStatus::NOT_STARTED)
|
||||
{
|
||||
$task = $result->payload[0];
|
||||
$result = $this->updatesPerfexCRMTask->execute($task['id'], $task['name'], $task['milestone'], $task['rel_id'], $taskStatus, $task['startdate'], is_null($task['duedate']) ? '': $task['duedate']);
|
||||
}
|
||||
}
|
||||
else{
|
||||
$result = $this->createsPerfexCRMTask->execute($tasks[$count]['name'], $tasks[$count]['description'], '', $milestoneId, $projectId, $tasks[$count]['reference'], $tasks[$count]['on_task_completion'], $tasks[$count]['department'], $taskStatus, $tasks[$count]['priority'], $tasks[$count]['duedate']);
|
||||
$createTaskPerfexCRMObject = new CreateTaskPerfexCRMObject(
|
||||
"",
|
||||
$taskName,
|
||||
$tasks[$count]['description'],
|
||||
"",
|
||||
$projectId,
|
||||
$milestoneId,
|
||||
$taskReference,
|
||||
$taskOnTaskCompletion,
|
||||
$taskStatus,
|
||||
$tasks[$count]['department'],
|
||||
$tasks[$count]['priority'],
|
||||
$tasks[$count]['duedate'],
|
||||
$updatePerfexCRMObject->getInvoiceId()
|
||||
);
|
||||
$result = $this->createsPerfexCRMTask->execute($createTaskPerfexCRMObject);
|
||||
}
|
||||
|
||||
//cief todo: to evaluate if this is still needed
|
||||
// if(is_null($result)){
|
||||
// break; //Breaking the rest of the tasks in array assuming that they are all created as a batch previously
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,67 +6,46 @@ use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMCustomFields;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
|
||||
|
||||
class CreatesPerfexCRMTask
|
||||
{
|
||||
/**
|
||||
* @param string $taskName
|
||||
* @param string $taskDescription
|
||||
* @param string $leadId
|
||||
* @param string $milestoneId
|
||||
* @param string $projectId
|
||||
* @param string $reference
|
||||
* @param string $on_task_completion
|
||||
* @param string $department
|
||||
* @param string $status
|
||||
* @param string $priority
|
||||
* @param string $duedate
|
||||
* @param CreateTaskPerfexCRMObject $createTaskPerfexCRMObject
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $taskName, string $taskDescription, string $leadId, string $milestoneId, string $projectId, string $reference, string $on_task_completion, string $department, string $status, string $priority, string $duedate) {
|
||||
public function execute(CreateTaskPerfexCRMObject $createTaskPerfexCRMObject) {
|
||||
try{
|
||||
$custom_fields = [];
|
||||
if($department != ""){
|
||||
if($createTaskPerfexCRMObject->getDepartment() != ""){
|
||||
$custom_fields = [
|
||||
"tasks" => [
|
||||
PerfexCRMCustomFields::TASKS_DEPARTMENT => $department
|
||||
PerfexCRMCustomFields::TASKS_DEPARTMENT => $createTaskPerfexCRMObject->getDepartment()
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'name' => $taskName,
|
||||
'description' => $taskDescription,
|
||||
'milestone' => $milestoneId,
|
||||
'name' => $createTaskPerfexCRMObject->getName(),
|
||||
'description' => $createTaskPerfexCRMObject->getDescription(),
|
||||
'milestone' => $createTaskPerfexCRMObject->getMilestoneId(),
|
||||
'startdate' => date('Y-m-d'),
|
||||
'rel_type' => 'project',
|
||||
'rel_id' => $projectId,
|
||||
'status' => $status,
|
||||
'rel_id' => $createTaskPerfexCRMObject->getProjectId(),
|
||||
'status' => $createTaskPerfexCRMObject->getStatus(),
|
||||
'is_system_created' => 1,
|
||||
'reference' => $reference,
|
||||
'on_task_completion' => $on_task_completion,
|
||||
'reference' => $createTaskPerfexCRMObject->getReference(),
|
||||
'on_task_completion' => $createTaskPerfexCRMObject->getOnTaskCompletion(),
|
||||
'custom_fields' => $custom_fields,
|
||||
'priority' => $priority,
|
||||
'duedate' => date('Y-m-d', strtotime('+' . $duedate . ' days')),
|
||||
'priority' => $createTaskPerfexCRMObject->getPriority(),
|
||||
'duedate' => date('Y-m-d', strtotime('+' . $createTaskPerfexCRMObject->getDuedate() . ' days')),
|
||||
'invoice_id' => $createTaskPerfexCRMObject->getInvoiceId(),
|
||||
];
|
||||
|
||||
if($leadId != '') {
|
||||
$data = [
|
||||
'name' => $taskName,
|
||||
'description' => $taskDescription,
|
||||
'milestone' => $milestoneId,
|
||||
'startdate' => date('Y-m-d'),
|
||||
'rel_type' => 'lead',
|
||||
'rel_id' => $leadId,
|
||||
'status' => $status,
|
||||
'is_system_created' => 1,
|
||||
'reference' => $reference,
|
||||
'on_task_completion' => $on_task_completion,
|
||||
'custom_fields' => $custom_fields,
|
||||
'priority' => $priority,
|
||||
'duedate' => date('Y-m-d', strtotime('+' . $duedate . ' days')),
|
||||
];
|
||||
if($createTaskPerfexCRMObject->getLeadId() != '') {
|
||||
$data['rel_type'] = 'lead';
|
||||
$data['rel_id'] = $createTaskPerfexCRMObject->getLeadId();
|
||||
}
|
||||
|
||||
$response = Http::asForm()->withHeaders([
|
||||
|
||||
@@ -17,7 +17,7 @@ class FetchesPerfexCRMTask
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $taskName, string $milestoneId, string $relType, string $relId) {
|
||||
public function execute(string $taskName, string $milestoneId, string $relType, string $relId, string $invoiceId) {
|
||||
try{
|
||||
$data = [
|
||||
'name' => $taskName,
|
||||
@@ -30,6 +30,11 @@ class FetchesPerfexCRMTask
|
||||
$data = array_merge($data, $newItem);
|
||||
}
|
||||
|
||||
if($invoiceId != 0) {
|
||||
$newItem = ['invoice_id' => $invoiceId ];
|
||||
$data = array_merge($data, $newItem);
|
||||
}
|
||||
|
||||
$response = Http::asForm()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->post(config('perfexcrm.base_url').'/api/tasks/customsearch', $data);
|
||||
|
||||
@@ -64,7 +64,6 @@ class UpdatesPerfexCRMInvoice
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
dd(json_encode($exception));
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Transactions\Processors\CreateSupplierTransactionProcessor;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
|
||||
class GenerateCreditNotePdfLogic
|
||||
{
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var CreateSupplierTransactionProcessor */
|
||||
private $createSupplierTransactionProcessor;
|
||||
|
||||
/**
|
||||
* GenerateCreditNotePdfLogic constructor.
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param CreateSupplierTransactionProcessor $createSupplierTransactionProcessor
|
||||
*/
|
||||
public function __construct(FetchesTransaction $fetchesTransaction, FetchesCompany $fetchesCompany, CreateSupplierTransactionProcessor $createSupplierTransactionProcessor)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->createSupplierTransactionProcessor = $createSupplierTransactionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return string|\Symfony\Component\HttpFoundation\Response
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Request $request)
|
||||
{
|
||||
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
||||
|
||||
$booking = $transaction->booking;
|
||||
|
||||
$supplier = $this->fetchesCompany->execute(['id' => $transaction->receiver]);
|
||||
|
||||
$pdf = LaravelMpdf::loadView('pages.pdfs.credit_note', ['transaction' => $transaction, 'booking' => $booking, 'supplier' => $supplier]);
|
||||
|
||||
return $pdf->stream('CreditNote.pdf');
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,9 @@ class PerfexCRMTasks
|
||||
'department' => '',
|
||||
'status' => PerfexCRMTaskStatus::COMPLETED,
|
||||
'priority' => PerfexCRMTaskPriority::DEFAULT,
|
||||
'duedate' => 0
|
||||
'duedate' => 0,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
|
||||
public const TASK_1_DAY_TRANSFER_1 = [
|
||||
@@ -27,7 +29,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Accounts',
|
||||
'status' => PerfexCRMTaskStatus::IN_PROGRESS,
|
||||
'priority' => PerfexCRMTaskPriority::HIGH,
|
||||
'duedate' => 0
|
||||
'duedate' => 0,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
public const TASK_1_DAY_TRANSFER_2 = [
|
||||
'name' => 'Approve Payment',
|
||||
@@ -47,7 +51,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Accounts',
|
||||
'status' => PerfexCRMTaskStatus::IN_PROGRESS,
|
||||
'priority' => PerfexCRMTaskPriority::HIGH,
|
||||
'duedate' => 0
|
||||
'duedate' => 0,
|
||||
'is_allow_multiple' => true,
|
||||
'is_on_task_completion_update' => true
|
||||
];
|
||||
public const TASK_1_DAY_TRANSFER_3 = [
|
||||
'name' => 'Issue Exchange Autocount Invoince',
|
||||
@@ -65,7 +71,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Accounts',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::MEDIUM,
|
||||
'duedate' => 1
|
||||
'duedate' => 1,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
public const TASK_1_DAY_TRANSFER_3_1 = [
|
||||
'name' => 'Issue Exchange Autocount OR',
|
||||
@@ -76,7 +84,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Accounts',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::DEFAULT,
|
||||
'duedate' => 0
|
||||
'duedate' => 0,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
public const TASK_1_DAY_TRANSFER_4 = [
|
||||
'name' => 'Knockoff Invoice',
|
||||
@@ -94,7 +104,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Accounts',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::MEDIUM,
|
||||
'duedate' => 1
|
||||
'duedate' => 1,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
public const TASK_1_DAY_TRANSFER_5 = [
|
||||
'name' => 'Order Placed in White Form',
|
||||
@@ -114,7 +126,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Operations',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::HIGH,
|
||||
'duedate' => 0
|
||||
'duedate' => 0,
|
||||
'is_allow_multiple' => true,
|
||||
'is_on_task_completion_update' => true
|
||||
];
|
||||
public const TASK_1_DAY_TRANSFER_6 = [
|
||||
'name' => 'Upload China Bank Slip',
|
||||
@@ -132,7 +146,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Operations',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::MEDIUM,
|
||||
'duedate' => 1
|
||||
'duedate' => 1,
|
||||
'is_allow_multiple' => true,
|
||||
'is_on_task_completion_update' => true
|
||||
];
|
||||
|
||||
public const TASK_3_DAY_TRANSFER_1 = [
|
||||
@@ -151,7 +167,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Accounts',
|
||||
'status' => PerfexCRMTaskStatus::IN_PROGRESS,
|
||||
'priority' => PerfexCRMTaskPriority::HIGH,
|
||||
'duedate' => 0
|
||||
'duedate' => 0,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
public const TASK_3_DAY_TRANSFER_2 = [
|
||||
'name' => 'Approve Payment',
|
||||
@@ -164,7 +182,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Accounts',
|
||||
'status' => PerfexCRMTaskStatus::IN_PROGRESS,
|
||||
'priority' => PerfexCRMTaskPriority::HIGH,
|
||||
'duedate' => 0
|
||||
'duedate' => 0,
|
||||
'is_allow_multiple' => true,
|
||||
'is_on_task_completion_update' => true
|
||||
];
|
||||
public const TASK_3_DAY_TRANSFER_3 = [
|
||||
'name' => 'Issue Exchange Autocount Invoince',
|
||||
@@ -182,7 +202,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Accounts',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::MEDIUM,
|
||||
'duedate' => 1
|
||||
'duedate' => 1,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
public const TASK_3_DAY_TRANSFER_3_1 = [
|
||||
'name' => 'Issue Exchange Autocount OR',
|
||||
@@ -193,7 +215,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Accounts',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::DEFAULT,
|
||||
'duedate' => 0
|
||||
'duedate' => 0,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
public const TASK_3_DAY_TRANSFER_4 = [
|
||||
'name' => 'Knockoff Invoice',
|
||||
@@ -211,7 +235,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Accounts',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::MEDIUM,
|
||||
'duedate' => 1
|
||||
'duedate' => 1,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
public const TASK_3_DAY_TRANSFER_5 = [
|
||||
'name' => 'Order Placed in White Form',
|
||||
@@ -231,7 +257,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Operations',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::HIGH,
|
||||
'duedate' => 0
|
||||
'duedate' => 0,
|
||||
'is_allow_multiple' => true,
|
||||
'is_on_task_completion_update' => true
|
||||
];
|
||||
public const TASK_3_DAY_TRANSFER_6 = [
|
||||
'name' => 'Upload China Bank Slip',
|
||||
@@ -249,7 +277,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Operations',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::MEDIUM,
|
||||
'duedate' => 1
|
||||
'duedate' => 1,
|
||||
'is_allow_multiple' => true,
|
||||
'is_on_task_completion_update' => true
|
||||
];
|
||||
|
||||
|
||||
@@ -270,7 +300,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Accounts',
|
||||
'status' => PerfexCRMTaskStatus::IN_PROGRESS,
|
||||
'priority' => PerfexCRMTaskPriority::HIGH,
|
||||
'duedate' => 0
|
||||
'duedate' => 0,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
public const TASK_1688_PAYMENT_2 = [
|
||||
'name' => 'Approve Payment',
|
||||
@@ -290,7 +322,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Accounts',
|
||||
'status' => PerfexCRMTaskStatus::IN_PROGRESS,
|
||||
'priority' => PerfexCRMTaskPriority::HIGH,
|
||||
'duedate' => 0
|
||||
'duedate' => 0,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
public const TASK_1688_PAYMENT_3 = [
|
||||
'name' => 'Issue Exchange Autocount Invoice',
|
||||
@@ -308,7 +342,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Accounts',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::MEDIUM,
|
||||
'duedate' => 1
|
||||
'duedate' => 1,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
public const TASK_1688_PAYMENT_3_1 = [
|
||||
'name' => 'Issue Exchange Autocount OR',
|
||||
@@ -320,7 +356,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Accounts',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::DEFAULT,
|
||||
'duedate' => 0
|
||||
'duedate' => 0,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
public const TASK_1688_PAYMENT_4 = [
|
||||
'name' => 'Knockoff Invoice',
|
||||
@@ -338,7 +376,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Accounts',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::MEDIUM,
|
||||
'duedate' => 1
|
||||
'duedate' => 1,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
public const TASK_1688_PAYMENT_5 = [
|
||||
'name' => 'Order Placed in White Form',
|
||||
@@ -357,7 +397,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Operations',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::HIGH,
|
||||
'duedate' => 0
|
||||
'duedate' => 0,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
public const TASK_1688_PAYMENT_6 = [
|
||||
'name' => 'Send White Form to Operation Department',
|
||||
@@ -375,7 +417,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Operations',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::DEFAULT,
|
||||
'duedate' => 0
|
||||
'duedate' => 0,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
public const TASK_1688_PAYMENT_7 = [
|
||||
'name' => 'Authorize Customer\'s 1688 Account',
|
||||
@@ -395,7 +439,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Operations',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::HIGH,
|
||||
'duedate' => 1
|
||||
'duedate' => 1,
|
||||
'is_allow_multiple' => true,
|
||||
'is_on_task_completion_update' => true
|
||||
];
|
||||
public const TASK_1688_PAYMENT_8 = [
|
||||
'name' => 'Make Payment for Customer 1688 Order',
|
||||
@@ -410,7 +456,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Operations',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::HIGH,
|
||||
'duedate' => 1
|
||||
'duedate' => 1,
|
||||
'is_allow_multiple' => true,
|
||||
'is_on_task_completion_update' => true
|
||||
];
|
||||
public const TASK_1688_PAYMENT_9 = [
|
||||
'name' => 'Upload China Bank Slip',
|
||||
@@ -422,7 +470,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Operations',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::MEDIUM,
|
||||
'duedate' => 1
|
||||
'duedate' => 1,
|
||||
'is_allow_multiple' => true,
|
||||
'is_on_task_completion_update' => true
|
||||
];
|
||||
public const TASK_1688_PAYMENT_10 = [
|
||||
'name' => 'Upload 1688 Purchase Order PDF',
|
||||
@@ -434,7 +484,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Operations',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::MEDIUM,
|
||||
'duedate' => 1
|
||||
'duedate' => 1,
|
||||
'is_allow_multiple' => true,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
public const TASK_1688_PAYMENT_11 = [
|
||||
'name' => 'Fill Up Purchase Order',
|
||||
@@ -446,7 +498,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Operations',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::LOW,
|
||||
'duedate' => 7
|
||||
'duedate' => 7,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
public const TASK_1688_PAYMENT_12 = [
|
||||
'name' => 'Approve Purchase Order',
|
||||
@@ -458,7 +512,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Operations',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::LOW,
|
||||
'duedate' => 1
|
||||
'duedate' => 1,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
public const TASK_1688_PAYMENT_13 = [
|
||||
'name' => 'Complete Order bookkeeping',
|
||||
@@ -476,7 +532,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Operations',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::DEFAULT,
|
||||
'duedate' => 0
|
||||
'duedate' => 0,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
|
||||
|
||||
@@ -497,7 +555,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Operations',
|
||||
'status' => PerfexCRMTaskStatus::IN_PROGRESS,
|
||||
'priority' => PerfexCRMTaskPriority::LOW,
|
||||
'duedate' => 1
|
||||
'duedate' => 1,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
|
||||
public const TASK_PURCHASE_ORDER_2 = [
|
||||
@@ -510,7 +570,9 @@ class PerfexCRMTasks
|
||||
'department' => 'Accounts',
|
||||
'status' => '',
|
||||
'priority' => PerfexCRMTaskPriority::DEFAULT,
|
||||
'duedate' => 0
|
||||
'duedate' => 0,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
|
||||
|
||||
@@ -530,6 +592,8 @@ class PerfexCRMTasks
|
||||
'department' => 'Operations',
|
||||
'status' => PerfexCRMTaskStatus::IN_PROGRESS,
|
||||
'priority' => PerfexCRMTaskPriority::DEFAULT,
|
||||
'duedate' => 0
|
||||
'duedate' => 0,
|
||||
'is_allow_multiple' => false,
|
||||
'is_on_task_completion_update' => false
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Booking;
|
||||
|
||||
class DeleteOrderCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'make-refunded-booking-expired {bookings_reference}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Change refunded booking status to expired';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$bookings_reference = $this->argument('bookings_reference');
|
||||
$bookings_reference = explode(',', $bookings_reference);
|
||||
|
||||
$start = new Carbon();
|
||||
$this->logOutput('Process started');
|
||||
|
||||
foreach ($bookings_reference as $reference) {
|
||||
$booking = Booking::where('marking', $reference)->first();
|
||||
|
||||
if (!$booking) {
|
||||
$this->logOutput('Booking not found: ' . $reference);
|
||||
} else {
|
||||
$booking->status = ApprovalStatus::EXPIRED;
|
||||
$booking->save();
|
||||
$this->logOutput('Booking deleted: ' . $reference);
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
$this->logOutput('Process ended. ElapsedTime: ' . $elapsedTime);
|
||||
}
|
||||
|
||||
public function logOutput($text)
|
||||
{
|
||||
if (is_array($text)) {
|
||||
$text = implode(', ', $text);
|
||||
}
|
||||
|
||||
$this->info(Carbon::now() . ' : ' . $text);
|
||||
|
||||
$filePath = storage_path('logs/delete-orders.log');
|
||||
$textToAppend = Carbon::now()->format('[Y-m-d H:i:s]') . ' ' . $text . PHP_EOL;
|
||||
file_put_contents($filePath, $textToAppend, FILE_APPEND);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\GenerateCreditNotePdfLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class GenerateCreditNotePdfController
|
||||
{
|
||||
public function download(Request $request, GenerateCreditNotePdfLogic $logic) {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@ class WalletTransactionResource extends JsonResource
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => (int) $this->id,
|
||||
'type' => (int) $this->type,
|
||||
'marking' => $this->owner->owner->reference,
|
||||
'bill_no' => $this->bill_no,
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
|
||||
<div class="row bg-white padding-10 m-b-10 rounded" v-for="(item, index) in transaction" v-bind:key="item.id" :data="item">
|
||||
<div class="col-2 fs-12">{{item.created_at}}</div>
|
||||
<div class="col-3 fs-12">{{ convertTransactionType(item.type) }} {{ item.payment_reference ? ' - ' + item.payment_reference : '' }}</div>
|
||||
<div class="col-3 fs-12">{{ convertTransactionType(item.type) }} {{ item.payment_reference ? ' - ' + item.payment_reference : '' }} <a target=”_blank” v-if="[9,11].includes(item.type) " :href="route('transaction.credit_note.download', item.id)"><i class="fa fa-download fs-11 m-l-5 text-secondary hover-primary"></i></a></div>
|
||||
<div class="col fs-12"><a :href="route('booking.details', item.booking_marking)">{{item.booking_marking}}</a></div>
|
||||
<div class="col-2 text-success text-center">{{[5, 9].includes(parseFloat(item.type)) ? (Math.round((parseFloat(item.amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : ''}}</div>
|
||||
<div class="col-2 text-danger text-center">{{[1, 11].includes(parseFloat(item.type)) ? '- ' + (Math.round((parseFloat(item.amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : ''}}</div>
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
|
||||
<div class="row bg-white padding-10 m-b-10 rounded" v-for="(item, index) in company.wallet.transactions" v-bind:key="item.id" :data="item">
|
||||
<div class="col-3 fs-12">{{item.created_at}}</div>
|
||||
<div class="col fs-12" v-html="item.description"></div>
|
||||
<div class="col fs-12"><span v-html="item.description"></span> <a target=”_blank” v-if="[9,11].includes(item.type) " :href="route('transaction.credit_note.download', item.id)"><i class="fa fa-download fs-11 m-l-5 text-secondary hover-primary"></i></a></div>
|
||||
<div class="col-2 text-success text-center">{{[5, 9].includes(parseFloat(item.type)) ? (Math.round((parseFloat(item.amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : ''}}</div>
|
||||
<div class="col-2 text-danger text-center">{{[1, 11].includes(parseFloat(item.type)) ? '- ' + (Math.round((parseFloat(item.amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : ''}}</div>
|
||||
<div class="col-2 text-right">{{remainingBalance(index)}}</div>
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
@extends('layouts.base_pdf')
|
||||
@section('inner_content')
|
||||
<br>
|
||||
<htmlpageheader name="page-header">
|
||||
<br><br>
|
||||
<div class="separator"><strong><i>{{ $transaction->bill_no }}</i></strong></div>
|
||||
</htmlpageheader>
|
||||
<table>
|
||||
<tr>
|
||||
<td class="header-logo">
|
||||
<img src="{{ asset('images/ri_1.png') }}" alt="logo" id="logo" class="logo">
|
||||
</td>
|
||||
<td class="header-cief-address">
|
||||
<span class="company-name">
|
||||
<strong>
|
||||
CIEF WORLDWIDE SDN BHD
|
||||
</strong>
|
||||
</span>
|
||||
<span class="company-reg">(1134596-M)</span><br>
|
||||
No. 72-3, Jalan Jalil 1,<br>
|
||||
The Earth Bukit Jalil,<br>
|
||||
57000 Kuala Lumpur<br>
|
||||
Tel: 03-8082 1252
|
||||
</td>
|
||||
<td class="header-details">
|
||||
<div class="title">
|
||||
<strong>
|
||||
{{ $transaction->type == 9 ? 'Credit' : 'Debit' }} Note
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<div class="ref">Ref# {{ $booking->marking }}</div>
|
||||
<div class="date">Date: {{ $transaction->created_at }}</div>
|
||||
<div> </div>
|
||||
</div>
|
||||
</td>
|
||||
<tr>
|
||||
<td colspan="3" class="bill-to">
|
||||
<span class="sub-title">
|
||||
{{ $transaction->type == 9 ? 'Credit' : 'Debit' }} To
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="address">
|
||||
<div class="label">
|
||||
{{ $supplier->name }}
|
||||
</div>
|
||||
<div class="address">
|
||||
@php
|
||||
$addresses = $supplier->addresses()->where('billing', '=', true)->first();
|
||||
@endphp
|
||||
{{ $addresses->street_one }}
|
||||
{{ $addresses->street_two }} ,
|
||||
{{ $addresses->district()->first()->name }},
|
||||
{{ $addresses->postcode }}
|
||||
{{ $addresses->state()->first()->name }},
|
||||
{{ $addresses->country()->first()->name }}
|
||||
</div>
|
||||
<div>
|
||||
Phone: {{ $supplier->contacts()->first()->phone }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<br>
|
||||
<table class="line-table" style="overflow: wrap" autosize="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">No</th>
|
||||
<th class="description">Description</th>
|
||||
<th width="10%">Quantity</th>
|
||||
<th width="15%">Unit Price (RM)</th>
|
||||
<th width="10%">Total Amount<br>(RM)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="5%" class="center top">1</td>
|
||||
<td class="description">{{ ucfirst($transaction->payment_reference) }}</td>
|
||||
<td width="10%" class="center top">1</td>
|
||||
<td width="15%" class="center top">
|
||||
{{ number_format($transaction->amount, 2) }}
|
||||
</td>
|
||||
<td width="20%" class="right top">
|
||||
{{ number_format($transaction->amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="3"></td>
|
||||
<td class="right middle">Total</td>
|
||||
<td class="total right middle">
|
||||
{{ number_format($transaction->amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<htmlpagefooter name="page-footer">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td style="text-align: right; ">This is generated by computer. No signature required.</td>
|
||||
<td style="text-align: right; ">Page {PAGENO} of {nbpg}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</htmlpagefooter>
|
||||
@endsection
|
||||
@@ -667,3 +667,5 @@ Route::get('/customer/vouchers/{marking}', function ($marking) {
|
||||
$id = \App\Models\Company::where('reference', '=', $marking)->first()->employees->first()->id;
|
||||
return view('pages.customers.reward', ['id' => $id]);
|
||||
})->name('customer.reward');
|
||||
|
||||
Route::get('transaction/{id}/credit_note/download', 'Transactions\GenerateCreditNotePdfController@download')->name('transaction.credit_note.download');
|
||||
|
||||
Reference in New Issue
Block a user