mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-22 22:14:08 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dbc57fdaac | |||
| 9c9cf0f96e | |||
| 8513309126 |
@@ -59,7 +59,3 @@ YD_API_CODE=''
|
|||||||
PERFEXCRM_BASE_URL=""
|
PERFEXCRM_BASE_URL=""
|
||||||
PERFEXCRM_API_KEY=""
|
PERFEXCRM_API_KEY=""
|
||||||
PERFEXCRM_IS_ENABLED="false"
|
PERFEXCRM_IS_ENABLED="false"
|
||||||
|
|
||||||
|
|
||||||
STORAGE_FEE_LAUNCH_DATE="2023-12-11 00:00:00"
|
|
||||||
SST_START_DATE="2024-04-01 00:00:00"
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Exceptions;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
|
||||||
|
|
||||||
final class JobResourceNotFoundException extends ServiceApiException {
|
|
||||||
public function __construct(?string $message = null) {
|
|
||||||
parent::__construct($message ?? 'Unable to find the requested resource', HttpStatus::RESOURCE_NOT_FOUND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,8 +15,6 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use App\Classes\Exceptions\JobResourceNotFoundException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
abstract class AbstractControllerLogic
|
abstract class AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -64,19 +62,6 @@ abstract class AbstractControllerLogic
|
|||||||
return $response;
|
return $response;
|
||||||
|
|
||||||
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
||||||
if ($exception instanceof JobResourceNotFoundException) {
|
|
||||||
Log::channel('vue_polling')->info(sprintf(
|
|
||||||
"Uncaught exception '%s' with message '%s' in %s:%d",
|
|
||||||
get_class($exception),
|
|
||||||
$exception->getMessage(),
|
|
||||||
$exception->getTrace()[0]['file'],
|
|
||||||
$exception->getTrace()[0]['line']
|
|
||||||
));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
Log::error($exception);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(),
|
return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(),
|
||||||
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ namespace App\Classes\General\Eloquent;
|
|||||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use App\Classes\Exceptions\JobResourceNotFoundException;
|
|
||||||
|
|
||||||
|
|
||||||
abstract class AbstractFetchRecord extends AbstractGetRecord
|
abstract class AbstractFetchRecord extends AbstractGetRecord
|
||||||
{
|
{
|
||||||
@@ -28,15 +26,9 @@ abstract class AbstractFetchRecord extends AbstractGetRecord
|
|||||||
* @return Model
|
* @return Model
|
||||||
* @throws ResourceNotFoundException
|
* @throws ResourceNotFoundException
|
||||||
*/
|
*/
|
||||||
public function getResults(Builder $query, array $param = []): Model {
|
public function getResults(Builder $query): Model {
|
||||||
if(!$query->exists()){
|
if(!$query->exists()){
|
||||||
$table = $query->getModel()->getTable();
|
throw new ResourceNotFoundException('Unable to find any record based on the criteria provided');
|
||||||
if($table ==='job_results'){
|
|
||||||
throw new JobResourceNotFoundException('Unable to find any job based on the criteria provided');
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
throw new ResourceNotFoundException('Unable to find any record based on the criteria provided');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $query->first();
|
return $query->first();
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ abstract class AbstractGetRecord
|
|||||||
* @param array $filters
|
* @param array $filters
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function handler(array $filters, array $params = []){
|
public function handler(array $filters){
|
||||||
$this->filters = collect($filters);
|
$this->filters = collect($filters);
|
||||||
return $this->getResults($this->applyFiltersToQuery(), $params);
|
return $this->getResults($this->applyFiltersToQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -65,6 +65,6 @@ abstract class AbstractGetRecord
|
|||||||
* @param Builder $query
|
* @param Builder $query
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
abstract function getResults(Builder $query, array $params = []);
|
abstract function getResults(Builder $query);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,10 +16,11 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
*/
|
*/
|
||||||
public function execute(array $filters = [], array $param = []){
|
public function execute(array $filters = []){
|
||||||
|
|
||||||
try{
|
try{
|
||||||
return $this->handler($filters, $param);
|
|
||||||
|
return $this->handler($filters);
|
||||||
|
|
||||||
} catch (QueryException $exception){
|
} catch (QueryException $exception){
|
||||||
throw new MalformedRequestException('Unable to fetch the list of records due to unexpected error');
|
throw new MalformedRequestException('Unable to fetch the list of records due to unexpected error');
|
||||||
@@ -31,7 +32,7 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
|||||||
* @param Builder $query
|
* @param Builder $query
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getResults(Builder $query, array $param = []) {
|
public function getResults(Builder $query) {
|
||||||
$filters = $this->getDecorationFilters();
|
$filters = $this->getDecorationFilters();
|
||||||
|
|
||||||
if($filters->has('order_by')){
|
if($filters->has('order_by')){
|
||||||
@@ -43,12 +44,8 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
|||||||
}
|
}
|
||||||
|
|
||||||
//dd($query->toSql());
|
//dd($query->toSql());
|
||||||
if(!empty($param)){
|
return $filters->has('per_page') ? $query->paginate($filters->get('per_page')) : $query->get();
|
||||||
return $filters->has('per_page') ? $query->paginate($filters->get('per_page'), ['*'], 'page', $param['page']) : $query->get(); //page data from query parameters e.g ?page=1
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return $filters->has('per_page') ? $query->paginate($filters->get('per_page')) : $query->get();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class CompanySegmentsIn implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereHas('companyModules', function ($module) use ($value) {
|
|
||||||
$module->whereHas('connections', function ($connection) use ($value) {
|
|
||||||
$connection->whereHas('connectionSegments', function ($segment) use ($value) {
|
|
||||||
$segment->whereIn('segment_id', $value);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class JobId implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('job_id', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class PackingListLimitOneByTypeOrderedByInvoiceDate implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->select('packing_lists.*')->join('transactions', function($join){
|
|
||||||
$join->on('transactions.owner_id', '=', 'packing_lists.id');
|
|
||||||
$join->where('transactions.owner_type', '=', PackingList::class);
|
|
||||||
$join->where('transactions.status', '=', ApprovalStatus::APPROVED);
|
|
||||||
$join->whereRaw('(transactions.type <> 16 OR transactions.id = (
|
|
||||||
SELECT id FROM transactions WHERE owner_id = packing_lists.id AND type = 16 LIMIT 1
|
|
||||||
))');
|
|
||||||
})->orderBy('transactions.updated_at', 'DESC');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class PostcodeLike implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('postcode', 'LIKE', '%'.$value.'%');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class RequestSignature implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('request_signature', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class ResultNotNull implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereNotNull('result');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class WithContainersPackages implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
// Log::info('WithContainersPackages: '.$value);
|
|
||||||
// return $builder->with(['containers', 'packages']);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Classes\General;
|
namespace App\Classes\General;
|
||||||
|
|
||||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
@@ -41,12 +40,4 @@ class Helper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ResourceCollection $collection
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
static function collectionResponse(ResourceCollection $collection){
|
|
||||||
return json_decode($collection->response()->getContent(), true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\ListPackingListsJobProcessor;
|
|
||||||
use App\Classes\Modules\Jobs\DataTransferObjects\ListGenericJobObject;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
class ListPackingListsJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
public $timeout = 900;
|
|
||||||
|
|
||||||
/** @var ListGenericJobObject */
|
|
||||||
private $listGenericJobObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ListPackingListsJob constructor.
|
|
||||||
* @param ListGenericJobObject $listGenericJobObject
|
|
||||||
*/
|
|
||||||
public function __construct(ListGenericJobObject $listGenericJobObject)
|
|
||||||
{
|
|
||||||
$this->listGenericJobObject = $listGenericJobObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
$rawPayload = $this->job->payload();
|
|
||||||
if(isset($rawPayload['data']['commandName'])){
|
|
||||||
$this->listGenericJobObject->setJobCommandName($rawPayload['data']['commandName']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($rawPayload['data']['command'])){
|
|
||||||
$this->listGenericJobObject->setJobCommand($rawPayload['data']['command']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = (App()->make(ListPackingListsJobProcessor::class))->execute($this->listGenericJobObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -47,7 +47,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
|||||||
$invoiceId = 0;
|
$invoiceId = 0;
|
||||||
$invoiceStatus = 0;
|
$invoiceStatus = 0;
|
||||||
$invoice = (App()->make(FetchesPerfexCRMInvoice::class))->execute($customer->userid,"INV-", $transaction->owner->bill_no);
|
$invoice = (App()->make(FetchesPerfexCRMInvoice::class))->execute($customer->userid,"INV-", $transaction->owner->bill_no);
|
||||||
Log::channel('perfex_crm')->info('UpdatePerfexCRMInvoice debug bill_no: ' . $transaction->owner->bill_no . ', Project Id: ' . $this->updatePerfexCRMInvoiceObject->getProjectId());
|
Log::error('UpdatePerfexCRMInvoice debug bill_no: ' . $transaction->owner->bill_no . ', Project Id: ' . $this->updatePerfexCRMInvoiceObject->getProjectId());
|
||||||
|
|
||||||
if(is_null($invoice)){
|
if(is_null($invoice)){
|
||||||
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction->owner, $this->updatePerfexCRMInvoiceObject->getIsPaid());
|
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction->owner, $this->updatePerfexCRMInvoiceObject->getIsPaid());
|
||||||
@@ -55,7 +55,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
|||||||
$invoiceId = $result->payload['id'];
|
$invoiceId = $result->payload['id'];
|
||||||
} else {
|
} else {
|
||||||
// Log::error(json_encode('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed'));
|
// Log::error(json_encode('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed'));
|
||||||
Log::channel('perfex_crm')->info('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
|
Helper::debugLogger('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ class CallbackBillplzLogic
|
|||||||
$pL = $invoice->owner;
|
$pL = $invoice->owner;
|
||||||
$order = $pL->owner;
|
$order = $pL->owner;
|
||||||
if($order){
|
if($order){
|
||||||
$this->storageInvoiceTransactionProcessor->executeOrder($order);
|
$this->storageInvoiceTransactionProcessor->executeOrder($order, false); //original was set true here so that no group is soft deleted or billplz bill got deleted
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,13 +80,12 @@ class CallbackBillplzProcessor
|
|||||||
if ($group) {
|
if ($group) {
|
||||||
foreach ($group->groupTransactions as $groupTransaction) {
|
foreach ($group->groupTransactions as $groupTransaction) {
|
||||||
$invoice = $groupTransaction->transaction;
|
$invoice = $groupTransaction->transaction;
|
||||||
if($invoice->status !== ApprovalStatus::COMPLETED){
|
|
||||||
$paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null, false);
|
|
||||||
|
|
||||||
if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){
|
$paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null, false);
|
||||||
$pL = $invoice->owner;
|
|
||||||
$this->releaseGoodsToCustomerProcessor->execute($pL, $invoice);
|
if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){
|
||||||
}
|
$pL = $invoice->owner;
|
||||||
|
$this->releaseGoodsToCustomerProcessor->execute($pL, $invoice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,9 +111,7 @@ class CallbackBillplzProcessor
|
|||||||
|
|
||||||
foreach ($group->groupTransactions as $groupTransaction) {
|
foreach ($group->groupTransactions as $groupTransaction) {
|
||||||
$invoice = $groupTransaction->transaction;
|
$invoice = $groupTransaction->transaction;
|
||||||
if($invoice->status !== ApprovalStatus::COMPLETED){
|
$totalAmountToBePaid += $invoice->amount;
|
||||||
$totalAmountToBePaid += $invoice->amount;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($totalAmountToBePaid - $actualAmountPaid) < 0.01){
|
if(($totalAmountToBePaid - $actualAmountPaid) < 0.01){
|
||||||
|
|||||||
+1
-13
@@ -7,8 +7,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\Modules\Companies\Processors\AssignConnectionSegmentProcessor;
|
use App\Classes\Modules\Companies\Processors\AssignConnectionSegmentProcessor;
|
||||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||||
use App\Classes\Modules\Companies\Services\FetchesCompanyConnection;
|
use App\Classes\Modules\Companies\Services\FetchesCompanyConnection;
|
||||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
|
||||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
|
||||||
use App\Http\Resources\CompanyResource;
|
use App\Http\Resources\CompanyResource;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -35,22 +33,17 @@ class AssignCompanyConnectionToConnectionSegmentLogic extends AbstractController
|
|||||||
/** @var AssignConnectionSegmentProcessor */
|
/** @var AssignConnectionSegmentProcessor */
|
||||||
private $assignCompanyConnectionToConnectionSegmentProcessor;
|
private $assignCompanyConnectionToConnectionSegmentProcessor;
|
||||||
|
|
||||||
/** @var CreateContactProcessor */
|
|
||||||
private $createContactProcessor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AssignCompanyToSegmentLogic constructor.
|
* AssignCompanyToSegmentLogic constructor.
|
||||||
* @param FetchesCompany $fetchesCompany
|
* @param FetchesCompany $fetchesCompany
|
||||||
* @param FetchesCompanyConnection $fetchesCompanyConnection
|
* @param FetchesCompanyConnection $fetchesCompanyConnection
|
||||||
* @param AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor
|
* @param AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor
|
||||||
* @param CreateContactProcessor $createContactProcessor
|
|
||||||
*/
|
*/
|
||||||
public function __construct(FetchesCompany $fetchesCompany, FetchesCompanyConnection $fetchesCompanyConnection, AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor, CreateContactProcessor $createContactProcessor)
|
public function __construct(FetchesCompany $fetchesCompany, FetchesCompanyConnection $fetchesCompanyConnection, AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor)
|
||||||
{
|
{
|
||||||
$this->fetchesCompany = $fetchesCompany;
|
$this->fetchesCompany = $fetchesCompany;
|
||||||
$this->fetchesCompanyConnection = $fetchesCompanyConnection;
|
$this->fetchesCompanyConnection = $fetchesCompanyConnection;
|
||||||
$this->assignCompanyConnectionToConnectionSegmentProcessor = $assignCompanyConnectionToConnectionSegmentProcessor;
|
$this->assignCompanyConnectionToConnectionSegmentProcessor = $assignCompanyConnectionToConnectionSegmentProcessor;
|
||||||
$this->createContactProcessor = $createContactProcessor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,11 +62,6 @@ class AssignCompanyConnectionToConnectionSegmentLogic extends AbstractController
|
|||||||
|
|
||||||
$this->assignCompanyConnectionToConnectionSegmentProcessor->execute($companyConnection, $request->input('segment_id'));
|
$this->assignCompanyConnectionToConnectionSegmentProcessor->execute($companyConnection, $request->input('segment_id'));
|
||||||
|
|
||||||
if ($request->input('segment_id') == 10 || $request->input('segment_id') == 11) {
|
|
||||||
$contactObject = new ContactObject('Whatsapp: ' . $request->input('name'), $request->input('phone'), null, null);
|
|
||||||
$this->createContactProcessor->execute($contactObject, $company);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->resourceResponse(new CompanyResource($company));
|
return $this->resourceResponse(new CompanyResource($company));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
-121
@@ -1,121 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
|
||||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyModuleIsCreditTerm;
|
|
||||||
use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompanyModule;
|
|
||||||
use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionIsWaived;
|
|
||||||
use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Models\Order;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class UpdateCompanyCreditTermStatusLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Update Company Credit Term Status',
|
|
||||||
'message' => 'You have successfully updated Company Credit Term Status'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var FetchesCompany */
|
|
||||||
private $fetchesCompany;
|
|
||||||
|
|
||||||
/** @var UpdatesCompanyModuleIsCreditTerm */
|
|
||||||
private $updatesCompanyModuleIsCreditTerm;
|
|
||||||
|
|
||||||
/** @var CanUpdateCompanyModule */
|
|
||||||
private $canUpdateCompanyModule;
|
|
||||||
|
|
||||||
/** @var ListsTransactions */
|
|
||||||
private $listsTransactions;
|
|
||||||
|
|
||||||
/** @var UpdatesTransactionIsWaived */
|
|
||||||
private $updatesTransactionIsWaived;
|
|
||||||
|
|
||||||
/** @var CheckStorageInvoiceTransactionProcessor */
|
|
||||||
private $storageInvoiceTransactionProcessor;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UpdateCompanyCreditTermStatusLogic constructor.
|
|
||||||
* @param FetchesCompany $fetchesCompany
|
|
||||||
* @param UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm
|
|
||||||
* @param CanUpdateCompanyModule $canUpdateCompanyModule
|
|
||||||
* @param UpdatesTransactionIsWaived $updatesTransactionIsWaived
|
|
||||||
* @param ListsTransactions $listsTransactions
|
|
||||||
* @param CheckStorageInvoiceTransactionProcessor $storageInvoiceTransactionProcessor
|
|
||||||
*/
|
|
||||||
public function __construct(FetchesCompany $fetchesCompany, UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm, CanUpdateCompanyModule $canUpdateCompanyModule, UpdatesTransactionIsWaived $updatesTransactionIsWaived, ListsTransactions $listsTransactions, CheckStorageInvoiceTransactionProcessor $storageInvoiceTransactionProcessor)
|
|
||||||
{
|
|
||||||
$this->fetchesCompany = $fetchesCompany;
|
|
||||||
$this->updatesCompanyModuleIsCreditTerm = $updatesCompanyModuleIsCreditTerm;
|
|
||||||
$this->canUpdateCompanyModule = $canUpdateCompanyModule;
|
|
||||||
$this->listsTransactions = $listsTransactions;
|
|
||||||
$this->updatesTransactionIsWaived = $updatesTransactionIsWaived;
|
|
||||||
$this->storageInvoiceTransactionProcessor = $storageInvoiceTransactionProcessor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
{
|
|
||||||
$this->canUpdateCompanyModule->passes();
|
|
||||||
|
|
||||||
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
|
||||||
$companyModule = $company->companyModules()->first();
|
|
||||||
$isCreditTerm = $companyModule->connections()->first()->is_credit_term;
|
|
||||||
|
|
||||||
if ($isCreditTerm == 1) {
|
|
||||||
$isCreditTerm = 0;
|
|
||||||
} else {
|
|
||||||
$isCreditTerm = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($isCreditTerm === 1){
|
|
||||||
//{"per_page":10,"order_by":{"column":"id","DESC":true},"status_in":[2],"receiver":190,"type_in":[1],"does_not_have_payment_status_in":[0,1],"does_not_have_groups":1,"check_for_storage_invoice":1}
|
|
||||||
|
|
||||||
$filters = [
|
|
||||||
'status_in' => [2],
|
|
||||||
'receiver' => $companyModule->id,
|
|
||||||
'type_in' => [TransactionType::STORAGE_INVOICE]
|
|
||||||
];
|
|
||||||
|
|
||||||
$transactions = $this->listsTransactions->execute($filters);
|
|
||||||
foreach($transactions as $transaction){
|
|
||||||
$this->updatesTransactionIsWaived->execute($transaction);
|
|
||||||
$packingList = $transaction->owner()->first();
|
|
||||||
if($packingList){
|
|
||||||
$order = $packingList->owner()->first();
|
|
||||||
if($order instanceof Order){
|
|
||||||
$storages = $this->storageInvoiceTransactionProcessor->executeOrder($order);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->updatesCompanyModuleIsCreditTerm->execute($company->companyModules()->first()->connections()->first(), $isCreditTerm);
|
|
||||||
Log::info(Auth::user()->email." updated credit term status for customer with id: " .$request->route('id'). " to status " . $isCreditTerm);
|
|
||||||
|
|
||||||
$result = ['is_credit_term' => $isCreditTerm];
|
|
||||||
return $this->response(['data' => $result]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Companies\Services;
|
|
||||||
|
|
||||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
|
||||||
use App\Models\CompanyConnection;
|
|
||||||
|
|
||||||
class UpdatesCompanyModuleIsCreditTerm extends AbstractUpdateRecord
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param CompanyConnection $model
|
|
||||||
* @param int $isCreditTerm
|
|
||||||
* @return \Illuminate\Database\Eloquent\Model
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(CompanyConnection $model, int $isCreditTerm)
|
|
||||||
{
|
|
||||||
$model->is_credit_term = $isCreditTerm;
|
|
||||||
|
|
||||||
return $this->handler($model);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Companies\Standards\Rules;
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractRule;
|
|
||||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
|
||||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
|
||||||
|
|
||||||
class CanUpdateCompanyModule extends AbstractRule
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CanUpdateCompanyModule constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function authorized($object): bool
|
|
||||||
{
|
|
||||||
$user = Auth()->user();
|
|
||||||
if($user){
|
|
||||||
$roleToCheck = Auth()->user()->type;
|
|
||||||
if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $object
|
|
||||||
* @return bool
|
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
||||||
*/
|
|
||||||
protected function validators($object): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param CompanyObject $object
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function criteria($object): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -70,31 +70,15 @@ class ExportsCustomersWalletTransactionHistory implements FromQuery, WithHeading
|
|||||||
$description = 'Credit Voucher for ' . $transaction->payment_reference;
|
$description = 'Credit Voucher for ' . $transaction->payment_reference;
|
||||||
break;
|
break;
|
||||||
case TransactionType::PAYMENT:
|
case TransactionType::PAYMENT:
|
||||||
$payment = Transaction::where('payment_reference', $transaction->bill_no)->first();
|
$booking = Transaction::where('payment_reference', $transaction->bill_no)->first()->owner;
|
||||||
if (!$payment) {
|
|
||||||
$description = 'Payment not found, please contact tech support.';
|
if (!$booking) {
|
||||||
|
$description = 'Payment for unknown booking, please contact tech support.';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$invoice = $payment->owner;
|
$marking = $booking->marking;
|
||||||
if (!$invoice) {
|
$description = 'Payment For booking refs' . $marking;
|
||||||
$description = 'Invoice not found, please contact tech support.';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$packingList = $invoice->owner;
|
|
||||||
if (!$packingList) {
|
|
||||||
$description = 'Packing List not found, please contact tech support.';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$order = $packingList->owner;
|
|
||||||
if (!$order) {
|
|
||||||
$description = 'Order not found, please contact tech support.';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$description = 'Payment For booking refs ' . $order->reference;
|
|
||||||
break;
|
break;
|
||||||
case TransactionType::DEBIT_NOTE:
|
case TransactionType::DEBIT_NOTE:
|
||||||
$description = 'Debit Voucher for ' . $transaction->payment_reference;
|
$description = 'Debit Voucher for ' . $transaction->payment_reference;
|
||||||
|
|||||||
@@ -41,9 +41,6 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
|||||||
'DeptNo',
|
'DeptNo',
|
||||||
'Qty',
|
'Qty',
|
||||||
'UnitPrice',
|
'UnitPrice',
|
||||||
'TaxType',
|
|
||||||
'TaxableAmt',
|
|
||||||
'TaxRate',
|
|
||||||
// 'marking',
|
// 'marking',
|
||||||
// 'contact person',
|
// 'contact person',
|
||||||
// 'contact number',
|
// 'contact number',
|
||||||
@@ -133,37 +130,6 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
|||||||
$furtherDescription .= $item->name.' '.$item->quantity.' X '.$item->price."\n";
|
$furtherDescription .= $item->name.' '.$item->quantity.' X '.$item->price."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$transactionDetails = $transaction->transactionDetails;
|
|
||||||
|
|
||||||
$firstItem = true;
|
|
||||||
$rows = [];
|
|
||||||
foreach ($transactionDetails as $detail) {
|
|
||||||
// Prepare each row based on the transaction detail
|
|
||||||
$rows[] = [
|
|
||||||
$firstItem ? '<<New>>' : '',
|
|
||||||
$transaction->created_at->format('m/d/Y H:m'),
|
|
||||||
$company->debtor,
|
|
||||||
$order->reference,
|
|
||||||
$order->reference,
|
|
||||||
'500-0000',
|
|
||||||
str_replace('<br>', ' ', $detail->name),
|
|
||||||
'',
|
|
||||||
$container->reference,
|
|
||||||
'CIEF',
|
|
||||||
$detail->quantity,
|
|
||||||
$detail->price,
|
|
||||||
floatval($detail->tax_percentage) > 0 ? 'SV-6' : '',
|
|
||||||
floatval($detail->tax_percentage) > 0 ? $detail->amount : '0',
|
|
||||||
$detail->tax_percentage,
|
|
||||||
];
|
|
||||||
|
|
||||||
if($firstItem) {
|
|
||||||
$firstItem = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $rows;
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'<<New>>',
|
'<<New>>',
|
||||||
$transaction->created_at->format('m/d/Y H:m'),
|
$transaction->created_at->format('m/d/Y H:m'),
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Imports\Services;
|
|
||||||
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
|
||||||
|
|
||||||
|
|
||||||
class GenericImport implements ToCollection, WithHeadingRow
|
|
||||||
{
|
|
||||||
function headingRow(): int { return 1; }
|
|
||||||
|
|
||||||
public $rows;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Collection $collection
|
|
||||||
*/
|
|
||||||
public function collection(Collection $collection)
|
|
||||||
{
|
|
||||||
$this->rows = $collection;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Jobs\ControllersLogic;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\Modules\Jobs\Processors\FetchesJobResultProcessor;
|
|
||||||
use App\Http\Resources\JobResultResource;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class FetchJobResultLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Retrieved Data',
|
|
||||||
'message' => 'You have successfully retrieved data'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var FetchesJobResultProcessor */
|
|
||||||
private $fetchesJobResultProcessor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* FetchJobResultLogic constructor.
|
|
||||||
* @param FetchesJobResultProcessor $fetchesJobResultProcessor
|
|
||||||
*/
|
|
||||||
public function __construct(FetchesJobResultProcessor $fetchesJobResultProcessor)
|
|
||||||
{
|
|
||||||
$this->fetchesJobResultProcessor = $fetchesJobResultProcessor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
{
|
|
||||||
$query = $this->fetchesJobResultProcessor->execute($request);
|
|
||||||
|
|
||||||
return $this->resourceResponse(new JobResultResource($query));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Jobs\DataTransferObjects;
|
|
||||||
|
|
||||||
use App\Classes\General\Interfaces\DataTransferObject;
|
|
||||||
|
|
||||||
class ListGenericJobObject implements DataTransferObject
|
|
||||||
{
|
|
||||||
/** @var string */
|
|
||||||
private $name;
|
|
||||||
|
|
||||||
/** @var array */
|
|
||||||
private $payload;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $jobId;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $requestSignature;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $resultSignature;
|
|
||||||
|
|
||||||
/** @var object */
|
|
||||||
private $userInfo;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $jobCommandName;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $jobCommand;
|
|
||||||
|
|
||||||
public function __construct(string $name, array $payload, string $requestSignature, ?string $resultSignature, string $jobId, object $userInfo = null)
|
|
||||||
{
|
|
||||||
$this->name = $name;
|
|
||||||
$this->payload = $payload;
|
|
||||||
$this->jobId = $jobId;
|
|
||||||
$this->requestSignature = $requestSignature;
|
|
||||||
$this->resultSignature = $resultSignature;
|
|
||||||
$this->userInfo = $userInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getName(): string
|
|
||||||
{
|
|
||||||
return $this->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getPayload(): array
|
|
||||||
{
|
|
||||||
return $this->payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getJobId(): string
|
|
||||||
{
|
|
||||||
return $this->jobId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getRequestSignature(): string
|
|
||||||
{
|
|
||||||
return $this->requestSignature;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getResultSignature(): ?string
|
|
||||||
{
|
|
||||||
return $this->resultSignature;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return object
|
|
||||||
*/
|
|
||||||
public function getUserInfo(): object
|
|
||||||
{
|
|
||||||
return $this->userInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getJobCommandName(): string
|
|
||||||
{
|
|
||||||
return $this->jobCommandName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getJobCommand(): string
|
|
||||||
{
|
|
||||||
return $this->jobCommand;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function setJobCommandName(string $jobCommandName)
|
|
||||||
{
|
|
||||||
$this->jobCommandName = $jobCommandName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setJobCommand(string $jobCommand)
|
|
||||||
{
|
|
||||||
$this->jobCommand = $jobCommand;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Jobs\DataTransferObjects;
|
|
||||||
|
|
||||||
use App\Classes\General\Interfaces\DataTransferObject;
|
|
||||||
|
|
||||||
class UpdateJobResultObject implements DataTransferObject
|
|
||||||
{
|
|
||||||
/** @var string */
|
|
||||||
private $result;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $resultSignature;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $jobCommandName;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $jobCommand;
|
|
||||||
|
|
||||||
public function __construct(string $result, string $resultSignature, string $jobCommandName, string $jobCommand)
|
|
||||||
{
|
|
||||||
$this->result = $result;
|
|
||||||
$this->resultSignature = $resultSignature;
|
|
||||||
$this->jobCommandName = $jobCommandName;
|
|
||||||
$this->jobCommand = $jobCommand;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getResult(): string
|
|
||||||
{
|
|
||||||
return $this->result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getResultSignature(): string
|
|
||||||
{
|
|
||||||
return $this->resultSignature;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getJobCommandName(): string
|
|
||||||
{
|
|
||||||
return $this->jobCommandName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getJobCommand(): string
|
|
||||||
{
|
|
||||||
return $this->jobCommand;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Jobs\Processors;
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\JobResourceNotFoundException;
|
|
||||||
use App\Classes\Modules\Jobs\Services\FetchesJobResult;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
|
|
||||||
class FetchesJobResultProcessor
|
|
||||||
{
|
|
||||||
/** @var FetchesJobResult */
|
|
||||||
private $fetchesJobResult;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* FetchesJobResultProcessor constructor.
|
|
||||||
* @param FetchesJobResult $fetchesJobResult
|
|
||||||
*/
|
|
||||||
public function __construct(FetchesJobResult $fetchesJobResult)
|
|
||||||
{
|
|
||||||
$this->fetchesJobResult = $fetchesJobResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return Model
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
* @throws \App\Classes\Exceptions\JobResourceNotFoundException
|
|
||||||
* @throws \App\Classes\Exceptions\ResourceNotFoundException
|
|
||||||
*/
|
|
||||||
public function execute(Request $request){
|
|
||||||
|
|
||||||
$res1 = $this->fetchesJobResult->execute(['job_id' => $request->route('job_id')]);
|
|
||||||
if($request->route('is_last')){
|
|
||||||
$res2 = $this->fetchesJobResult->execute(['request_signature' => $res1->request_signature, 'result_not_null' => true, 'order_by_id_desc' => true]);
|
|
||||||
return $res2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!$res1->result){
|
|
||||||
throw new JobResourceNotFoundException('Unable to find any job based on the criteria provided');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $res1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Jobs\Processors;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Modules\Jobs\Services\UpdatesJobResult;
|
|
||||||
use App\Classes\Modules\Jobs\Services\FetchesJobResult;
|
|
||||||
use App\Classes\Exceptions\JobResourceNotFoundException;
|
|
||||||
use App\Classes\Modules\Jobs\DataTransferObjects\ListGenericJobObject;
|
|
||||||
use App\Classes\Modules\Jobs\DataTransferObjects\UpdateJobResultObject;
|
|
||||||
|
|
||||||
class UpdateJobResultProcessor
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var FetchesJobResult */
|
|
||||||
private $fetchesJobResult;
|
|
||||||
|
|
||||||
/** @var UpdatesJobResult */
|
|
||||||
private $updatesJobResult;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UpdateJobResultProcessor constructor.
|
|
||||||
* @param FetchesJobResult $fetchesJobResult
|
|
||||||
* @param UpdatesJobResult $updatesJobResult
|
|
||||||
*/
|
|
||||||
public function __construct(FetchesJobResult $fetchesJobResult, UpdatesJobResult $updatesJobResult)
|
|
||||||
{
|
|
||||||
$this->fetchesJobResult = $fetchesJobResult;
|
|
||||||
$this->updatesJobResult = $updatesJobResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ListGenericJobObject $listGenericJobObject
|
|
||||||
* @param array $resultCurrent
|
|
||||||
* @return void
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
* @throws \App\Classes\Exceptions\JobResourceNotFoundException
|
|
||||||
*/
|
|
||||||
public function execute(ListGenericJobObject $listGenericJobObject, $resultCurrent) {
|
|
||||||
$jobResultCurrent = $this->fetchesJobResult->execute(['job_id' => $listGenericJobObject->getJobId()]);
|
|
||||||
$resultCurrentJson = json_encode($resultCurrent);
|
|
||||||
$resultSignatureCurrent = md5($resultCurrentJson);
|
|
||||||
|
|
||||||
try{
|
|
||||||
$jobResultExisting = $this->fetchesJobResult->execute(['request_signature' => $jobResultCurrent->request_signature, 'result_not_null' => true, 'order_by_id_desc' => true]);
|
|
||||||
$resultSignatureExisting = $jobResultExisting->result_signature;
|
|
||||||
//if($resultSignatureExisting != $resultSignatureCurrent){
|
|
||||||
$this->updateJobResult($jobResultCurrent, $resultCurrentJson, $resultSignatureCurrent, $listGenericJobObject->getJobCommandName(), $listGenericJobObject->getJobCommand());
|
|
||||||
//}
|
|
||||||
} catch (JobResourceNotFoundException $exception){
|
|
||||||
$this->updateJobResult($jobResultCurrent, $resultCurrentJson, $resultSignatureCurrent, $listGenericJobObject->getJobCommandName(), $listGenericJobObject->getJobCommand());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function updateJobResult($jobResultCurrent, $resultCurrentJson, $resultSignatureCurrent, $jobCommandName, $jobCommand){
|
|
||||||
$updateJobResultObject = new UpdateJobResultObject(
|
|
||||||
$resultCurrentJson,
|
|
||||||
$resultSignatureCurrent,
|
|
||||||
$jobCommandName,
|
|
||||||
$jobCommand
|
|
||||||
);
|
|
||||||
$create = $this->updatesJobResult->execute($jobResultCurrent, $updateJobResultObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Jobs\Services;
|
|
||||||
|
|
||||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
|
||||||
use App\Models\JobResult;
|
|
||||||
use App\Classes\Modules\Jobs\DataTransferObjects\ListGenericJobObject;
|
|
||||||
|
|
||||||
class CreatesJobResult extends AbstractUpdateRecord
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param ListGenericJobObject $listGenericJobObject
|
|
||||||
* @return \Illuminate\Database\Eloquent\Model
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(ListGenericJobObject $listGenericJobObject)
|
|
||||||
{
|
|
||||||
$model = new JobResult();
|
|
||||||
$model->job_id = $listGenericJobObject->getJobId();
|
|
||||||
$model->request_signature = $listGenericJobObject->getRequestSignature();
|
|
||||||
$model->result_signature = $listGenericJobObject->getResultSignature();
|
|
||||||
$model->url = $listGenericJobObject->getName();
|
|
||||||
|
|
||||||
return $this->handler($model);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Jobs\Services;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use App\Models\JobResult;
|
|
||||||
|
|
||||||
class FetchesJobResult extends AbstractFetchRecord
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var JobResult */
|
|
||||||
private $repository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* FetchesJobResult constructor.
|
|
||||||
* @param JobResult $repository
|
|
||||||
*/
|
|
||||||
public function __construct(JobResult $repository)
|
|
||||||
{
|
|
||||||
$this->repository = $repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function getRepository(): Builder
|
|
||||||
{
|
|
||||||
return $this->repository->newQuery();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Jobs\Services;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use App\Models\JobResult;
|
|
||||||
|
|
||||||
class ListsJobResult extends AbstractListRecord
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var JobResult */
|
|
||||||
private $repository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ListsJobResult constructor.
|
|
||||||
* @param JobResult $repository
|
|
||||||
*/
|
|
||||||
public function __construct(JobResult $repository)
|
|
||||||
{
|
|
||||||
$this->repository = $repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
function getRepository(): Builder
|
|
||||||
{
|
|
||||||
return $this->repository->newQuery();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Jobs\Services;
|
|
||||||
|
|
||||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
|
||||||
use App\Classes\Modules\Jobs\DataTransferObjects\UpdateJobResultObject;
|
|
||||||
use App\Models\JobResult;
|
|
||||||
|
|
||||||
class UpdatesJobResult extends AbstractUpdateRecord
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param JobResult $model
|
|
||||||
* @param UpdateJobResultObject $updateJobResultObject
|
|
||||||
* @return \Illuminate\Database\Eloquent\Model
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(JobResult $model, UpdateJobResultObject $updateJobResultObject) {
|
|
||||||
|
|
||||||
$model->result = $updateJobResultObject->getResult();
|
|
||||||
$model->result_signature = $updateJobResultObject->getResultSignature();
|
|
||||||
$model->job_command_name = $updateJobResultObject->getJobCommandName();
|
|
||||||
$model->job_command = $updateJobResultObject->getJobCommand();
|
|
||||||
|
|
||||||
return $this->handler($model);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+17
-11
@@ -56,21 +56,27 @@ class RescheduleContainerLogic extends AbstractControllerLogic
|
|||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
try {
|
||||||
$transport = $container->transports()->first();
|
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||||
|
$transport = $container->transports()->first();
|
||||||
|
|
||||||
$old_schedule = $transport->schedules()->delete();
|
$old_sechedule = $transport->schedules()->first();
|
||||||
|
|
||||||
// $this->updatesScheduleStatus->execute($old_schedule, ApprovalStatus::REJECTED);
|
$this->updatesScheduleStatus->execute($old_sechedule, ApprovalStatus::REJECTED);
|
||||||
|
|
||||||
$scheduleObject = new ScheduleObject(
|
$scheduleObject = new ScheduleObject(
|
||||||
Carbon::parse($request->input('etd')),
|
Carbon::parse($request->input('etd')),
|
||||||
Carbon::parse($request->input('eta')),
|
Carbon::parse($request->input('eta')),
|
||||||
ApprovalStatus::APPROVED
|
ApprovalStatus::APPROVED
|
||||||
);
|
);
|
||||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||||
|
|
||||||
|
return $this->resourceResponse(new ContainerResource($container));
|
||||||
|
|
||||||
|
} catch (\Exception $exception){
|
||||||
|
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||||
|
}
|
||||||
|
|
||||||
return $this->resourceResponse(new ContainerResource($container));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,78 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\Jobs\ListPackingListsJob;
|
|
||||||
use App\Classes\Modules\Jobs\DataTransferObjects\ListGenericJobObject;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use App\Classes\Modules\Jobs\Services\CreatesJobResult;
|
|
||||||
|
|
||||||
class ListPackingListsJobLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Job Retrieving PackingLists',
|
|
||||||
'message' => 'You have successfully submit a job to retrieve a list of PackingLists'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var CreatesJobResult */
|
|
||||||
private $createsJobResult;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ListPackingListsJobLogic constructor.
|
|
||||||
* @param CreatesJobResult $createsJobResult
|
|
||||||
*/
|
|
||||||
public function __construct(CreatesJobResult $createsJobResult)
|
|
||||||
{
|
|
||||||
$this->createsJobResult = $createsJobResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function logic(Request $request) : JsonResponse
|
|
||||||
{
|
|
||||||
$jobId = uniqid();
|
|
||||||
|
|
||||||
$user = Auth::user();
|
|
||||||
$userInfo = (object) [
|
|
||||||
// 'email' => $user->email,
|
|
||||||
'type' => $user->type,
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
$userInfoJson = json_encode($userInfo);
|
|
||||||
$requestSignature = md5($userInfoJson . $request->fullUrl());
|
|
||||||
|
|
||||||
|
|
||||||
$listGenericJobObject = new ListGenericJobObject(
|
|
||||||
$request->fullUrl(),
|
|
||||||
$request->all(),
|
|
||||||
$requestSignature,
|
|
||||||
null,
|
|
||||||
$jobId,
|
|
||||||
$userInfo
|
|
||||||
);
|
|
||||||
|
|
||||||
ListPackingListsJob::dispatch($listGenericJobObject)->onQueue('high_priority');
|
|
||||||
|
|
||||||
$result = [];
|
|
||||||
$result['job_id'] = $jobId;
|
|
||||||
|
|
||||||
|
|
||||||
$this->createsJobResult->execute($listGenericJobObject);
|
|
||||||
|
|
||||||
return $this->response(['data' => $result]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -6,8 +6,8 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
|||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
||||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanListPackingLists;
|
use App\Classes\Modules\PackingLists\Standards\Rules\CanListPackingLists;
|
||||||
|
use App\Http\Resources\PackingListNullOrderResource;
|
||||||
use App\Http\Resources\PackingListResource;
|
use App\Http\Resources\PackingListResource;
|
||||||
use App\Http\Resources\PackingListWithStorageResource;
|
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -54,14 +54,7 @@ class ListPackingListsLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($request->input('filters')));
|
$query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($request->input('filters')));
|
||||||
|
|
||||||
if($request->input('storages')){
|
return $this->collectionResponse(PackingListResource::collection($query));
|
||||||
foreach ($query->items() as $item) {
|
|
||||||
$item['storages'] = $request->input('storages');
|
|
||||||
}
|
|
||||||
return $this->collectionResponse(PackingListWithStorageResource::collection($query));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return $this->collectionResponse(PackingListResource::collection($query));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\PackingLists\Processors;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
|
||||||
use App\Classes\Modules\Jobs\Processors\UpdateJobResultProcessor;
|
|
||||||
use App\Classes\General\Helper;
|
|
||||||
use App\Classes\Modules\Jobs\DataTransferObjects\ListGenericJobObject;
|
|
||||||
use App\Http\Middleware\CheckForStorageInvoiceByPackingLists;
|
|
||||||
use App\Http\Resources\ListPackingListJobResource;
|
|
||||||
use App\Http\Resources\ListPackingListDetailsJobResource;
|
|
||||||
use App\Http\Resources\ListPackingListJobWithStorageResource;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class ListPackingListsJobProcessor
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var ListsPackingLists */
|
|
||||||
private $listsPackingLists;
|
|
||||||
|
|
||||||
/** @var UpdateJobResultProcessor */
|
|
||||||
private $updateJobResultProcessor;
|
|
||||||
|
|
||||||
/** @var CheckForStorageInvoiceByPackingLists */
|
|
||||||
private $checkForStorageInvoiceByPackingLists;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ListPackingListsJobProcessor constructor.
|
|
||||||
* @param ListsPackingLists $listsPackingLists
|
|
||||||
* @param UpdateJobResultProcessor $updateJobResultProcessor
|
|
||||||
*/
|
|
||||||
public function __construct(ListsPackingLists $listsPackingLists, UpdateJobResultProcessor $updateJobResultProcessor, CheckForStorageInvoiceByPackingLists $checkForStorageInvoiceByPackingLists)
|
|
||||||
{
|
|
||||||
$this->listsPackingLists = $listsPackingLists;
|
|
||||||
$this->updateJobResultProcessor = $updateJobResultProcessor;
|
|
||||||
$this->checkForStorageInvoiceByPackingLists = $checkForStorageInvoiceByPackingLists;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ListGenericJobObject $listGenericJobObject
|
|
||||||
* @return void
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
* @throws \App\Classes\Exceptions\JobResourceNotFoundException
|
|
||||||
*/
|
|
||||||
public function execute(ListGenericJobObject $listGenericJobObject) {
|
|
||||||
// $query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page'], 'with_containers_packages' => true]);
|
|
||||||
$query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page']]);
|
|
||||||
// $query = $this->listsPackingLists->execute(array_merge($this->listsPackingLists->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page'], 'with_containers_packages' => true]));
|
|
||||||
|
|
||||||
$filtersArray = json_decode($listGenericJobObject->getPayload()['filters'], true);
|
|
||||||
|
|
||||||
$storages = [];
|
|
||||||
if(isset($filtersArray['check_for_storage_invoice']))
|
|
||||||
{
|
|
||||||
$myRequest = new \Illuminate\Http\Request();
|
|
||||||
$myRequest->setMethod('POST');
|
|
||||||
$myRequest->request->add($listGenericJobObject->getPayload());
|
|
||||||
$next = function ($request) {
|
|
||||||
return $request;
|
|
||||||
};
|
|
||||||
|
|
||||||
$response = $this->checkForStorageInvoiceByPackingLists->handle($myRequest, $next);
|
|
||||||
$storages = $response->input('storages');
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($query->items() as &$item) {
|
|
||||||
$item['userInfo'] = $listGenericJobObject->getUserInfo();
|
|
||||||
$item['storages'] = $storages;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($filtersArray['does_not_have_transaction_type'])){ //For Payment and Billing page > Pending Invoice tab
|
|
||||||
$resultCurrent = Helper::collectionResponse(ListPackingListDetailsJobResource::collection($query));
|
|
||||||
$this->updateJobResultProcessor->execute($listGenericJobObject, $resultCurrent);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if($storages){ //For Payment and Billing page > Pending Payment tab, Paid Invoice tab
|
|
||||||
$resultCurrent = Helper::collectionResponse(ListPackingListJobWithStorageResource::collection($query));
|
|
||||||
$this->updateJobResultProcessor->execute($listGenericJobObject, $resultCurrent);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$resultCurrent = Helper::collectionResponse(ListPackingListJobResource::collection($query));
|
|
||||||
$this->updateJobResultProcessor->execute($listGenericJobObject, $resultCurrent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -61,7 +61,7 @@ class FetchPerfexCRMInvoiceProcessor
|
|||||||
$invoiceId = $result->payload['id'];
|
$invoiceId = $result->payload['id'];
|
||||||
} else {
|
} else {
|
||||||
$log['message'] = 'FetchPerfexCRMInvoiceProcessor failed for transaction > bill_no: '.$number;
|
$log['message'] = 'FetchPerfexCRMInvoiceProcessor failed for transaction > bill_no: '.$number;
|
||||||
Log::channel('perfex_crm')->info($log);
|
Helper::debugLogger($log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class ConvertsPerfexCRMLeadToCustomer
|
|||||||
|
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info('ConvertsPerfexCRMLeadToCustomer: '.$response);
|
Log::error('ConvertsPerfexCRMLeadToCustomer: '.$response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class CreatesPerfexCRMCustomer
|
|||||||
$data = $response->json();
|
$data = $response->json();
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info('CreatesPerfexCRMCustomer: '.$response);
|
Log::error('CreatesPerfexCRMCustomer: '.$response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class CreatesPerfexCRMCustomerContact
|
|||||||
$data = $response->json();
|
$data = $response->json();
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info('CreatesPerfexCRMCustomerContact: '.$response);
|
Log::error('CreatesPerfexCRMCustomerContact: '.$response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class CreatesPerfexCRMCustomerProject
|
|||||||
$data = $response->json();
|
$data = $response->json();
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info('CreatesPerfexCRMCustomerProject: '.$response);
|
Log::error('CreatesPerfexCRMCustomerProject: '.$response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class CreatesPerfexCRMInvoice
|
|||||||
$data = $response->json();
|
$data = $response->json();
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info('CreatesPerfexCRMInvoice: '.$response);
|
Log::error('CreatesPerfexCRMInvoice: '.$response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class CreatesPerfexCRMInvoicePayment
|
|||||||
$data = $response->json();
|
$data = $response->json();
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info('CreatesPerfexCRMInvoicePayment: '.$response);
|
Log::error('CreatesPerfexCRMInvoicePayment: '.$response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class CreatesPerfexCRMLead
|
|||||||
$data = $response->json();
|
$data = $response->json();
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info('CreatesPerfexCRMLead: '.$response);
|
Log::error('CreatesPerfexCRMLead: '.$response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class CreatesPerfexCRMMilestone
|
|||||||
$data = $response->json();
|
$data = $response->json();
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info('CreatesPerfexCRMMilestone: '.$response);
|
Log::error('CreatesPerfexCRMMilestone: '.$response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class CreatesPerfexCRMSupportTicket
|
|||||||
$data = $response->json();
|
$data = $response->json();
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info($response);
|
Log::error($response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class CreatesPerfexCRMTask
|
|||||||
$data = $response->json();
|
$data = $response->json();
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info('CreatesPerfexCRMTask: '.$response);
|
Log::error('CreatesPerfexCRMTask: '.$response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class FetchesPerfexCRMCustomer
|
|||||||
|
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info('FetchesPerfexCRMCustomer: '.$response);
|
Log::error('FetchesPerfexCRMCustomer: '.$response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class FetchesPerfexCRMInvoice
|
|||||||
|
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info('FetchesPerfexCRMInvoice: '.$response);
|
Log::error('FetchesPerfexCRMInvoice: '.$response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class FetchesPerfexCRMLead
|
|||||||
|
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info('FetchesPerfexCRMLead: '.$response);
|
Log::error('FetchesPerfexCRMLead: '.$response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class FetchesPerfexCRMMilestone
|
|||||||
|
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info('FetchesPerfexCRMMilestone: '.$response);
|
Log::error('FetchesPerfexCRMMilestone: '.$response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class FetchesPerfexCRMProject
|
|||||||
|
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info('FetchesPerfexCRMProject: '.$response);
|
Log::error('FetchesPerfexCRMProject: '.$response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class FetchesPerfexCRMTask
|
|||||||
|
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info($response);
|
Helper::debugLogger($response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class UpdatesPerfexCRMCustomer
|
|||||||
$data = $response->json();
|
$data = $response->json();
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
// Log::channel('perfex_crm')->info($response);
|
// Helper::debugLogger($response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class UpdatesPerfexCRMInvoice
|
|||||||
$data = $response->json();
|
$data = $response->json();
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info('UpdatesPerfexCRMInvoice: '.$response);
|
Log::error('UpdatesPerfexCRMInvoice: '.$response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class UpdatesPerfexCRMLead
|
|||||||
$data = $response->json();
|
$data = $response->json();
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info('UpdatesPerfexCRMLead: '.$response);
|
Log::error('UpdatesPerfexCRMLead: '.$response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class UpdatesPerfexCRMProject
|
|||||||
$data = $response->json();
|
$data = $response->json();
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info('UpdatesPerfexCRMProject: '.$response);
|
Log::error('UpdatesPerfexCRMProject: '.$response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class UpdatesPerfexCRMTask
|
|||||||
$data = $response->json();
|
$data = $response->json();
|
||||||
return (object) $data;
|
return (object) $data;
|
||||||
}else{
|
}else{
|
||||||
Log::channel('perfex_crm')->info('UpdatesPerfexCRMTask: '.$response);
|
Log::error('UpdatesPerfexCRMTask: '.$response);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,35 +82,16 @@ class CreateGroupsLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
|
$payment_method = PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')];
|
||||||
|
$groupPyamentStatus = ApprovalStatus::PENDING_VERIFICATION;
|
||||||
|
|
||||||
$invoice_ids = json_decode($request->route('transaction_ids'));
|
$invoice_ids = json_decode($request->route('transaction_ids'));
|
||||||
|
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||||
|
|
||||||
// todo-new: check why is this not working
|
// todo-new: check why is this not working
|
||||||
// $invoices = $this->fetchesTransaction->execute(['id_in' => $invoice_ids]);
|
// $invoices = $this->fetchesTransaction->execute(['id_in' => $invoice_ids]);
|
||||||
$invoices = Transaction::whereIn('id', $invoice_ids)->get();
|
$invoices = Transaction::whereIn('id', $invoice_ids)->get();
|
||||||
$isInvoicesApprove = $this->checkIfInvoicesAreApprove($invoices);
|
|
||||||
if(!$isInvoicesApprove){
|
|
||||||
$response = ['message' => 'One of the transactions might be suspended; please check if there are any disputes in progress.'];
|
|
||||||
return $this->response(['data' => $response]);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$paymentMethodStr = $request->input('payment_method');
|
|
||||||
$paymentMethod = PaymentMethodType::PAYMENT_METHODS[$paymentMethodStr];
|
|
||||||
$amount = $request->input('amount');
|
|
||||||
$bankCode = $request->input('bank_code');
|
|
||||||
$result = $this->processInvoices($invoices, $paymentMethodStr, $amount, $bankCode);
|
|
||||||
|
|
||||||
if ($paymentMethod === PaymentMethodType::PAYMENT_GATEWAY) {
|
|
||||||
return $this->resourceResponse(new WalletTransactionResource($result));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $this->response([]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function processInvoices($invoices, $reqPaymentMethod, $reqAmount, $reqBankCode){
|
|
||||||
$result = [];
|
|
||||||
$payment_method = PaymentMethodType::PAYMENT_METHODS[$reqPaymentMethod];
|
|
||||||
$groupPyamentStatus = ApprovalStatus::PENDING_VERIFICATION;
|
|
||||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
|
||||||
foreach ($invoices as $invoice) {
|
foreach ($invoices as $invoice) {
|
||||||
$order = null;
|
$order = null;
|
||||||
if ($invoice->owner instanceof Transaction) {
|
if ($invoice->owner instanceof Transaction) {
|
||||||
@@ -137,7 +118,7 @@ class CreateGroupsLogic extends AbstractControllerLogic
|
|||||||
$wallet = Wallet::where('owner_id', $companyModuleId)->first();
|
$wallet = Wallet::where('owner_id', $companyModuleId)->first();
|
||||||
|
|
||||||
// todo-new: verify currently checking wallet amount based on 'amount' value passed by frontend
|
// todo-new: verify currently checking wallet amount based on 'amount' value passed by frontend
|
||||||
if((float) number_format(($wallet->amount - $reqAmount),2) < 0){
|
if((float) number_format(($wallet->amount - $request->input('amount')),2) < 0){
|
||||||
throw new MalformedRequestException('Insufficient wallet balance. Please Top up your wallet.');
|
throw new MalformedRequestException('Insufficient wallet balance. Please Top up your wallet.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +154,7 @@ class CreateGroupsLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
foreach ($invoices as $invoice) {
|
foreach ($invoices as $invoice) {
|
||||||
if ($payment_method == PaymentMethodType::WALLET) {
|
if ($payment_method == PaymentMethodType::WALLET) {
|
||||||
$paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, $reqBankCode, false);
|
$paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, $request->input('bank_code'), false);
|
||||||
|
|
||||||
if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){
|
if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){
|
||||||
$pL = $invoice->owner;
|
$pL = $invoice->owner;
|
||||||
@@ -200,12 +181,11 @@ class CreateGroupsLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
if (in_array($payment_method, [PaymentMethodType::PAYMENT_GATEWAY, PaymentMethodType::CASH])) {
|
if (in_array($payment_method, [PaymentMethodType::PAYMENT_GATEWAY, PaymentMethodType::CASH])) {
|
||||||
// create only one billplz payment for wallet top up
|
// create only one billplz payment for wallet top up
|
||||||
$amount = floatval(str_replace(',', '', $reqAmount));
|
$amount = floatval(str_replace(',', '', $request->input('amount')));
|
||||||
$companyModuleId = $invoice->receiver;
|
$companyModuleId = $invoice->receiver;
|
||||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $companyModuleId]);
|
$companyModule = $this->fetchesCompanyModule->execute(['id' => $companyModuleId]);
|
||||||
|
|
||||||
$topUpTransaction = $this->createWalletTopUpTransactionProcessor->execute($companyModule, $amount, $reqBankCode, $payment_method, $billNumber, true);
|
$topUpTransaction = $this->createWalletTopUpTransactionProcessor->execute($companyModule, $amount, $request->input('bank_code'), $payment_method, $billNumber, true);
|
||||||
$result = $topUpTransaction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$group->issuer = $issuer;
|
$group->issuer = $issuer;
|
||||||
@@ -221,15 +201,11 @@ class CreateGroupsLogic extends AbstractControllerLogic
|
|||||||
$group->status = $groupPyamentStatus;
|
$group->status = $groupPyamentStatus;
|
||||||
$group->save();
|
$group->save();
|
||||||
|
|
||||||
return $result;
|
if ($payment_method === PaymentMethodType::PAYMENT_GATEWAY) {
|
||||||
}
|
return $this->resourceResponse(new WalletTransactionResource($topUpTransaction));
|
||||||
|
|
||||||
private function checkIfInvoicesAreApprove($invoices){
|
} else {
|
||||||
foreach ($invoices as $invoice) {
|
return $this->response([]);
|
||||||
if($invoice->status !== ApprovalStatus::APPROVED && $invoice->status !== ApprovalStatus::COMPLETED){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-9
@@ -52,18 +52,28 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$invoice_transaction = $this->fetchesTransaction->execute(['id' => $request->input('transaction_id')]);
|
$invoice_transaction = $this->fetchesTransaction->execute(['id' => $request->input('transaction_id')]);
|
||||||
|
|
||||||
if($invoice_transaction->status === ApprovalStatus::APPROVED){
|
$payment_transaction = $this->createPaymentTransactionProcessor->execute($invoice_transaction, $payment_method , $request->input('bank_code'), false);
|
||||||
$payment_transaction = $this->createPaymentTransactionProcessor->execute($invoice_transaction, $payment_method , $request->input('bank_code'), false);
|
|
||||||
|
|
||||||
if($payment_transaction && $payment_transaction->status === ApprovalStatus::APPROVED){
|
if($payment_transaction && $payment_transaction->status == ApprovalStatus::APPROVED){
|
||||||
$pL = $invoice_transaction->owner;
|
$pL = $invoice_transaction->owner;
|
||||||
$this->releaseGoodsToCustomerProcessor->execute($pL, $invoice_transaction);
|
$this->releaseGoodsToCustomerProcessor->execute($pL, $invoice_transaction);
|
||||||
}
|
|
||||||
return $this->resourceResponse(new TransactionResource($payment_transaction));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = ['message' => 'A transaction might be suspended; please check if there is any dispute in progress.'];
|
//cief todo: at exchange there is a transition step - starts
|
||||||
return $this->response(['data' => $response]);
|
// if(PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')] == PaymentMethodType::PAYMENT_GATEWAY){
|
||||||
|
// $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::PENDING_VERIFICATION);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if(config('perfexcrm.is_enabled') == 'true'){
|
||||||
|
// $this->transactionToPerfexCRMV2Processor->execute($transaction, $status);
|
||||||
|
// }
|
||||||
|
|
||||||
|
//To use
|
||||||
|
//ApprovalStatus::PENDING_VERIFICATION;
|
||||||
|
//use this to trigger $this->transactionToPerfexCRMV2Processor->execute > defineTasks > defineTasks_handlePendingVerificationStatus > definePaymentTasks
|
||||||
|
//cief todo: at exchange there is a transition step - ends
|
||||||
|
|
||||||
|
return $this->resourceResponse(new TransactionResource($payment_transaction));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -48,8 +48,6 @@ class DeleteGroupLogic extends AbstractControllerLogic
|
|||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
ini_set('memory_limit', '-1');
|
|
||||||
|
|
||||||
$group = $this->fetchesGroup->execute(['id' => $request->route('id')]);
|
$group = $this->fetchesGroup->execute(['id' => $request->route('id')]);
|
||||||
|
|
||||||
foreach ($group->groupTransactions as $groupTransaction) {
|
foreach ($group->groupTransactions as $groupTransaction) {
|
||||||
|
|||||||
@@ -1,90 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\General\Eloquent\Filters\PaymentMethod;
|
|
||||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
|
||||||
use App\Classes\Modules\Transactions\Services\FetchesGroup;
|
|
||||||
use App\Classes\Modules\Transactions\Services\DeletesTransaction;
|
|
||||||
use App\Classes\Modules\Transactions\Services\DeletesGroup;
|
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class DeletePaidGroupLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'title' => 'Delete Paid Group Transaction',
|
|
||||||
'message' => 'You have successfully deleted this Group Transaction'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var FetchesGroup */
|
|
||||||
private $fetchesGroup;
|
|
||||||
|
|
||||||
/** @var DeletesGroup */
|
|
||||||
private $deletesGroup;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DeleteGroupLogic constructor.
|
|
||||||
* @param updatesTransactionStatus $updatesTransactionStatus
|
|
||||||
* @param FetchesGroup $fetchesGroup
|
|
||||||
* @param DeletesTransaction $deletesTransaction
|
|
||||||
*/
|
|
||||||
public function __construct(FetchesGroup $fetchesGroup, DeletesGroup $deletesGroup)
|
|
||||||
{
|
|
||||||
$this->fetchesGroup = $fetchesGroup;
|
|
||||||
$this->deletesGroup = $deletesGroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return JsonResponse
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function logic(Request $request): JsonResponse
|
|
||||||
{
|
|
||||||
$group = $this->fetchesGroup->execute(['id' => $request->route('id')]);
|
|
||||||
|
|
||||||
foreach ($group->groupTransactions as $groupTransaction) {
|
|
||||||
$invoice = $groupTransaction->transaction;
|
|
||||||
$paymentTransaction = $invoice->transactions()->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->first();
|
|
||||||
|
|
||||||
if ($paymentTransaction->payment_method == PaymentMethodType::WALLET) {
|
|
||||||
// Store the transaction ID before deleting
|
|
||||||
$transactionId = Transaction::where('bill_no', $paymentTransaction->payment_reference)->first()->id;
|
|
||||||
|
|
||||||
// Delete the transaction
|
|
||||||
Transaction::where('id', $transactionId)->first()->delete();
|
|
||||||
|
|
||||||
// Now you have the transaction ID available in $transactionId
|
|
||||||
Log::channel('deletePaidGroupOrder')->info("Deleted payment reference transaction ID: " . $transactionId);
|
|
||||||
} else {
|
|
||||||
Log::channel('deletePaidGroupOrder')->info("no transaction found. Invoice Id ->" . $invoice->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store the transaction ID before deleting
|
|
||||||
$transactionId = $paymentTransaction->id;
|
|
||||||
|
|
||||||
// Delete the payment transaction
|
|
||||||
$paymentTransaction->delete();
|
|
||||||
Log::channel('deletePaidGroupOrder')->info("Deleted payment transaction ID: " . $transactionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::channel('deletePaidGroupOrder')->info("Deleted Group -> " . $group->id);
|
|
||||||
$this->deletesGroup->execute($group);
|
|
||||||
|
|
||||||
return $this->response([]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+3
-24
@@ -6,13 +6,9 @@ namespace App\Classes\Modules\Transactions\ControllersLogic;
|
|||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||||
use App\Classes\Modules\Transactions\Services\FetchesGroup;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Models\Transaction;
|
|
||||||
use App\Models\Wallet;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class DeletePaymentTransactionLogic extends AbstractControllerLogic
|
class DeletePaymentTransactionLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -27,9 +23,6 @@ class DeletePaymentTransactionLogic extends AbstractControllerLogic
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var FetchesGroup */
|
|
||||||
private $fetchesGroup;
|
|
||||||
|
|
||||||
/** @var FetchesTransaction */
|
/** @var FetchesTransaction */
|
||||||
private $fetchesTransaction;
|
private $fetchesTransaction;
|
||||||
|
|
||||||
@@ -41,13 +34,11 @@ class DeletePaymentTransactionLogic extends AbstractControllerLogic
|
|||||||
* SuspendTransactionLogic constructor.
|
* SuspendTransactionLogic constructor.
|
||||||
* @param FetchesTransaction $fetchesTransaction
|
* @param FetchesTransaction $fetchesTransaction
|
||||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||||
* @param FetchesGroup $fetchesGroup
|
|
||||||
*/
|
*/
|
||||||
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, FetchesGroup $fetchesGroup)
|
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus)
|
||||||
{
|
{
|
||||||
$this->fetchesTransaction = $fetchesTransaction;
|
$this->fetchesTransaction = $fetchesTransaction;
|
||||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||||
$this->fetchesGroup = $fetchesGroup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -55,23 +46,11 @@ class DeletePaymentTransactionLogic extends AbstractControllerLogic
|
|||||||
{
|
{
|
||||||
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
||||||
|
|
||||||
if($transaction->owner instanceof Wallet){
|
|
||||||
try{
|
|
||||||
$group = $this->fetchesGroup->execute(['reference' => $transaction->payment_reference]);
|
|
||||||
$group->status = ApprovalStatus::SUSPENDED;
|
|
||||||
$group->save();
|
|
||||||
}
|
|
||||||
catch(\Exception $excaption){
|
|
||||||
Log::info('No group associated with transaction with payment_reference - '.$transaction->payment_reference);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$transaction->delete();
|
$transaction->delete();
|
||||||
|
|
||||||
$invoice = $transaction->owner;
|
$invoice = $transaction->owner;
|
||||||
if ($invoice instanceof Transaction) {
|
|
||||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::APPROVED);
|
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::APPROVED);
|
||||||
}
|
|
||||||
|
|
||||||
return $this->response([]);
|
return $this->response([]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class DeleteTransactionLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DeleteTransactionLogic constructor.
|
* SuspendTransactionLogic constructor.
|
||||||
* @param FetchesTransaction $fetchesTransaction
|
* @param FetchesTransaction $fetchesTransaction
|
||||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ namespace App\Classes\Modules\Transactions\ControllersLogic;
|
|||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
||||||
use App\Http\Resources\TransactionWithStorageResource;
|
|
||||||
use App\Http\Resources\TransactionResource;
|
use App\Http\Resources\TransactionResource;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -43,18 +42,15 @@ class ListTransactionsLogic extends AbstractControllerLogic
|
|||||||
$query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($request->input('filters')));
|
$query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($request->input('filters')));
|
||||||
|
|
||||||
if($request->input('storages')){
|
if($request->input('storages')){
|
||||||
foreach ($query->items() as $item) {
|
foreach ($query->items() as &$item) {
|
||||||
$transactionId = $item['id'];
|
$transactionId = $item['id'];
|
||||||
$filteredStorages = array_filter($request->input('storages'), function ($storage) use ($transactionId) {
|
$filteredStorages = array_filter($request->input('storages'), function ($storage) use ($transactionId) {
|
||||||
return isset($storage['parentInvoiceId']) && $storage['parentInvoiceId'] == $transactionId;
|
return isset($storage['parentInvoiceId']) && $storage['parentInvoiceId'] == $transactionId;
|
||||||
});
|
});
|
||||||
$item['storages'] = $filteredStorages;
|
$item['storages'] = $filteredStorages;
|
||||||
}
|
}
|
||||||
//return $this->collectionResponse(TransactionWithStorageResource::collection($query));
|
|
||||||
}
|
}
|
||||||
// else{
|
|
||||||
// return $this->collectionResponse(TransactionResource::collection($query));
|
return $this->collectionResponse(TransactionResource::collection($query));
|
||||||
//
|
|
||||||
return $this->collectionResponse(TransactionWithStorageResource::collection($query));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-9
@@ -15,7 +15,6 @@ use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
|||||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||||
use App\Models\Document;
|
use App\Models\Document;
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
class RegenerateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
class RegenerateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -55,14 +54,7 @@ class RegenerateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$invoice->documents()->delete();
|
$invoice->documents()->delete();
|
||||||
|
|
||||||
$view = 'pages.pdfs.shipping_invoice';
|
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice]);
|
||||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
|
||||||
$shippingInvoiceTransactionCreatedDate = Carbon::parse($invoice->created_at);
|
|
||||||
if ($shippingInvoiceTransactionCreatedDate->isAfter($dateToCompare) && $invoice->tax > 0) {
|
|
||||||
$view = 'pages.pdfs.shipping_invoice_sst';
|
|
||||||
}
|
|
||||||
|
|
||||||
$transaction_invoice_pdf = LaravelMpdf::loadView($view, ['invoice_transaction' => $invoice]);
|
|
||||||
|
|
||||||
$document_object = new DocumentObject(
|
$document_object = new DocumentObject(
|
||||||
DocumentType::SHIPPING_INVOICE,
|
DocumentType::SHIPPING_INVOICE,
|
||||||
|
|||||||
+1
-9
@@ -16,7 +16,6 @@ use App\Classes\Modules\Documents\Services\CreatesDocument;
|
|||||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||||
use App\Models\Document;
|
use App\Models\Document;
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
class RegenerateSingleShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
class RegenerateSingleShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -55,14 +54,7 @@ class RegenerateSingleShippingInvoiceTransactionLogic extends AbstractController
|
|||||||
|
|
||||||
$invoice->documents()->delete();
|
$invoice->documents()->delete();
|
||||||
|
|
||||||
$view = 'pages.pdfs.shipping_invoice';
|
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice]);
|
||||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
|
||||||
$shippingInvoiceTransactionCreatedDate = Carbon::parse($invoice->created_at);
|
|
||||||
if ($shippingInvoiceTransactionCreatedDate->isAfter($dateToCompare) && $invoice->tax > 0) {
|
|
||||||
$view = 'pages.pdfs.shipping_invoice_sst';
|
|
||||||
}
|
|
||||||
|
|
||||||
$transaction_invoice_pdf = LaravelMpdf::loadView($view, ['invoice_transaction' => $invoice]);
|
|
||||||
|
|
||||||
$document_object = new DocumentObject(
|
$document_object = new DocumentObject(
|
||||||
DocumentType::SHIPPING_INVOICE,
|
DocumentType::SHIPPING_INVOICE,
|
||||||
|
|||||||
-67
@@ -1,67 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
|
||||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
|
||||||
use App\Classes\Modules\Transactions\Processors\CreateStorageInvoiceDocTransactionFixProcessor;
|
|
||||||
use App\Classes\Modules\Transactions\Standards\Rules\CanRegenerateStorageInvoice;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class RegenerateSingleStorageInvoiceTransactionLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Regenerate Storage Invoice',
|
|
||||||
'message' => 'You have successfully regenerated storage invoice'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** @var FetchesTransaction */
|
|
||||||
private $fetchesTransaction;
|
|
||||||
|
|
||||||
/** @var CreateStorageInvoiceDocTransactionFixProcessor */
|
|
||||||
private $createStorageInvoiceDocTransactionProcessor;
|
|
||||||
|
|
||||||
/** @var CanRegenerateStorageInvoice */
|
|
||||||
private $canRegenerateStorageInvoice;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param CreatesDocument $createsDocument
|
|
||||||
*/
|
|
||||||
public function __construct(FetchesTransaction $fetchesTransaction, CreateStorageInvoiceDocTransactionFixProcessor $createStorageInvoiceDocTransactionProcessor, CanRegenerateStorageInvoice $canRegenerateStorageInvoice)
|
|
||||||
{
|
|
||||||
$this->fetchesTransaction = $fetchesTransaction;
|
|
||||||
$this->createStorageInvoiceDocTransactionProcessor = $createStorageInvoiceDocTransactionProcessor;
|
|
||||||
$this->canRegenerateStorageInvoice = $canRegenerateStorageInvoice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function logic(Request $request) : JsonResponse
|
|
||||||
{
|
|
||||||
$this->canRegenerateStorageInvoice->passes();
|
|
||||||
|
|
||||||
$invoice = $this->fetchesTransaction->execute(['id' => $request->route('invoice_id')]);
|
|
||||||
$packingList = $invoice->owner;
|
|
||||||
$order = $packingList->owner;
|
|
||||||
$invoices = $order->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->get();
|
|
||||||
foreach ($invoices as $invoice){
|
|
||||||
$invoice->documents()->delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->createStorageInvoiceDocTransactionProcessor->execute($packingList, true);
|
|
||||||
Log::info(Auth::user()->email." regenerate storage invoice for transaction with id ".$request->route('invoice_id'));
|
|
||||||
|
|
||||||
return $this->response([]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+3
-19
@@ -25,8 +25,6 @@ use App\Classes\Modules\Transactions\Services\DeletesTransactionDetails;
|
|||||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionDetailObject;
|
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionDetailObject;
|
||||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||||
use App\Classes\ValueObjects\Constants\TaxPercentage;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -107,25 +105,11 @@ class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|||||||
$transaction_detail = (object) $transaction_detail;
|
$transaction_detail = (object) $transaction_detail;
|
||||||
|
|
||||||
if(!in_array($transaction_detail->reference, ['SHIPPING_FEE', 'OVER_WEIGHT_CHARGES', 'MIN_CBM_CHARGES'])){
|
if(!in_array($transaction_detail->reference, ['SHIPPING_FEE', 'OVER_WEIGHT_CHARGES', 'MIN_CBM_CHARGES'])){
|
||||||
$reference = 'CUSTOM_CHARGES';
|
|
||||||
$taxPercentage = TaxPercentage::DEFAULT;
|
|
||||||
|
|
||||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
|
||||||
$shippingInvoiceTransactionCreatedDate = Carbon::parse($invoice_transaction->created_at);
|
|
||||||
if ($shippingInvoiceTransactionCreatedDate->isAfter($dateToCompare)) {
|
|
||||||
$taxPercentage = TaxPercentage::SIX_PERCENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($transaction_detail->reference === "PAY_ON_BEHALF"){
|
|
||||||
$reference = "PAY_ON_BEHALF";
|
|
||||||
$taxPercentage = TaxPercentage::NO_TAX;
|
|
||||||
}
|
|
||||||
$object_detail = new TransactionDetailObject(
|
$object_detail = new TransactionDetailObject(
|
||||||
$reference,
|
'CUSTOM_CHARGES',
|
||||||
isset($transaction_detail->name) ? $transaction_detail->name : TransactionDetailType::CUSTOM_CHARGES,
|
isset($transaction_detail->name) ? $transaction_detail->name : TransactionDetailType::CUSTOM_CHARGES,
|
||||||
$transaction_detail->quantity,
|
$transaction_detail->quantity,
|
||||||
$transaction_detail->price,
|
$transaction_detail->price
|
||||||
$taxPercentage
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if(isset($transaction_detail->id)){
|
if(isset($transaction_detail->id)){
|
||||||
@@ -148,7 +132,7 @@ class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
$invoice_transaction->transactionDetails()->sum('tax_amount'),
|
0,
|
||||||
0,
|
0,
|
||||||
null,
|
null,
|
||||||
ApprovalStatus::PENDING_VERIFICATION
|
ApprovalStatus::PENDING_VERIFICATION
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\Modules\Transactions\DataTransferObjects\WaiveTransactionObject;
|
|
||||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionIsWaived;
|
|
||||||
use App\Classes\Modules\Transactions\Standards\Rules\CanWaiveTransaction;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class WaiveTransactionLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Waive Transaction',
|
|
||||||
'message' => 'You have successfully waived the transaction'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var FetchesTransaction */
|
|
||||||
private $fetchesTransaction;
|
|
||||||
|
|
||||||
/** @var UpdatesTransactionIsWaived */
|
|
||||||
private $updatesTransactionIsWaived;
|
|
||||||
|
|
||||||
/** @var CanWaiveTransaction */
|
|
||||||
private $canWaiveTransaction;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* WaiveTransactionLogic constructor.
|
|
||||||
* @param FetchesTransaction $fetchesTransaction
|
|
||||||
* @param UpdatesTransactionIsWaived $updatesTransactionIsWaived
|
|
||||||
* @param CanWaiveTransaction $canWaiveTransaction
|
|
||||||
*/
|
|
||||||
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionIsWaived $updatesTransactionIsWaived, CanWaiveTransaction $canWaiveTransaction)
|
|
||||||
{
|
|
||||||
$this->fetchesTransaction = $fetchesTransaction;
|
|
||||||
$this->updatesTransactionIsWaived = $updatesTransactionIsWaived;
|
|
||||||
$this->canWaiveTransaction = $canWaiveTransaction;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function logic(Request $request) : JsonResponse
|
|
||||||
{
|
|
||||||
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
|
||||||
|
|
||||||
$object = new WaiveTransactionObject($transaction->id, $transaction->bill_no, $transaction->type, $transaction->status);
|
|
||||||
$this->canWaiveTransaction->passes($object);
|
|
||||||
|
|
||||||
$this->updatesTransactionIsWaived->execute($transaction);
|
|
||||||
Log::info(Auth::user()->email." waive storage invoice charges with bill_no: ".$transaction->bill_no);
|
|
||||||
|
|
||||||
return $this->response([]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,25 +18,19 @@ class TransactionDetailObject implements DataTransferObject
|
|||||||
/** @var float|null */
|
/** @var float|null */
|
||||||
private $price;
|
private $price;
|
||||||
|
|
||||||
/** @var float|null */
|
|
||||||
private $taxPercentage;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TransactionDetailObject constructor.
|
* TransactionDetailObject constructor.
|
||||||
* @param string $reference
|
* @param string $reference
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param float $quantity
|
* @param float $quantity
|
||||||
* @param float $price
|
* @param float $price
|
||||||
* @param float $taxPercentage
|
|
||||||
*/
|
*/
|
||||||
public function __construct(?string $reference, ?string $name , ?float $quantity, ?float $price, ?float $taxPercentage)
|
public function __construct(?string $reference, ?string $name , ?float $quantity, ?float $price)
|
||||||
{
|
{
|
||||||
$this->reference = $reference;
|
$this->reference = $reference;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->quantity = $quantity;
|
$this->quantity = $quantity;
|
||||||
$this->price = $price;
|
$this->price = $price;
|
||||||
$this->taxPercentage = $taxPercentage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,28 +65,9 @@ class TransactionDetailObject implements DataTransferObject
|
|||||||
return $this->price;
|
return $this->price;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public function getAmount(): float
|
public function getAmount(): float
|
||||||
{
|
{
|
||||||
return ($this->getQuantity() * $this->getPrice()) + $this->getTaxAmount();
|
return $this->getQuantity() * $this->getPrice();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public function getTaxPercentage(): ?float
|
|
||||||
{
|
|
||||||
return $this->taxPercentage;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
public function getTaxAmount(): float
|
|
||||||
{
|
|
||||||
return ($this->getQuantity() * $this->getPrice()) * $this->getTaxPercentage() / 100;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -241,10 +241,10 @@ class TransactionObject implements DataTransferObject
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getDetails(): array //cief todo: not in used as of 20240407
|
public function getDetails(): array
|
||||||
{
|
{
|
||||||
return array_map(function($product){
|
return array_map(function($product){
|
||||||
return new TransactionDetailObject($product['stockCode'] ?? '', $product['description'] ?? '', $product['quantity'] ?? '', floatval(str_replace(',', '', $product['unit_price'])), 0.0 );
|
return new TransactionDetailObject($product['stockCode'] ?? '', $product['description'] ?? '', $product['quantity'] ?? '', floatval(str_replace(',', '', $product['unit_price'])));
|
||||||
}, $this->details);
|
}, $this->details);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Transactions\DataTransferObjects;
|
|
||||||
|
|
||||||
use App\Classes\General\Interfaces\DataTransferObject;
|
|
||||||
|
|
||||||
class WaiveTransactionObject implements DataTransferObject
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var int */
|
|
||||||
private $id;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $billNo;
|
|
||||||
|
|
||||||
/** @var int */
|
|
||||||
private $type;
|
|
||||||
|
|
||||||
/** @var int */
|
|
||||||
private $status;
|
|
||||||
|
|
||||||
public function __construct(int $id, string $billNo, int $type, int $status)
|
|
||||||
{
|
|
||||||
$this->id = $id;
|
|
||||||
$this->billNo = $billNo;
|
|
||||||
$this->type = $type;
|
|
||||||
$this->status = $status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getId(): int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getBillNo(): string
|
|
||||||
{
|
|
||||||
return $this->billNo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getType(): int
|
|
||||||
{
|
|
||||||
return $this->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getStatus(): int
|
|
||||||
{
|
|
||||||
return $this->status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-9
@@ -19,7 +19,6 @@ use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
|||||||
use App\Classes\Jobs\CreatePerfexCRMInvoice;
|
use App\Classes\Jobs\CreatePerfexCRMInvoice;
|
||||||
use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor;
|
use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
class ApproveShippingInvoiceTransactionProcessor
|
class ApproveShippingInvoiceTransactionProcessor
|
||||||
{
|
{
|
||||||
@@ -60,16 +59,9 @@ class ApproveShippingInvoiceTransactionProcessor
|
|||||||
/** @var Transaction $invoice_transaction */
|
/** @var Transaction $invoice_transaction */
|
||||||
$invoice_transaction = $packingList->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::PENDING_SUBMISSION])->first();
|
$invoice_transaction = $packingList->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::PENDING_SUBMISSION])->first();
|
||||||
|
|
||||||
$view = 'pages.pdfs.shipping_invoice';
|
|
||||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
|
||||||
$shippingInvoiceTransactionCreatedDate = Carbon::parse($invoice_transaction->created_at);
|
|
||||||
if ($shippingInvoiceTransactionCreatedDate->isAfter($dateToCompare) && $invoice_transaction->tax > 0) {
|
|
||||||
$view = 'pages.pdfs.shipping_invoice_sst';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
$this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
||||||
|
|
||||||
$transaction_invoice_pdf = LaravelMpdf::loadView($view, ['invoice_transaction' => $invoice_transaction]);
|
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice_transaction]);
|
||||||
|
|
||||||
$document_object = new DocumentObject(
|
$document_object = new DocumentObject(
|
||||||
DocumentType::SHIPPING_INVOICE,
|
DocumentType::SHIPPING_INVOICE,
|
||||||
|
|||||||
+50
-147
@@ -23,9 +23,8 @@ use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\PackageType;
|
use App\Classes\ValueObjects\Constants\PackageType;
|
||||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||||
use App\Classes\ValueObjects\Constants\TaxPercentage;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionDetailType;
|
use App\Classes\ValueObjects\Constants\TransactionDetailType;
|
||||||
use App\Http\Resources\TransactionWithStorageResource;
|
use App\Http\Resources\TransactionResource;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use App\Models\PackingList;
|
use App\Models\PackingList;
|
||||||
use App\Models\Transaction;
|
use App\Models\Transaction;
|
||||||
@@ -100,38 +99,33 @@ class CheckStorageInvoiceTransactionProcessor
|
|||||||
return $this->executeOrder($order);
|
return $this->executeOrder($order);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function executeOrder(Order $order){
|
public function executeOrder(Order $order, bool $isBackDoorCheck = false){
|
||||||
$results = [];
|
$results = [];
|
||||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||||
$is_credit_term = $order->companyModule->inviters()->withPivot('is_credit_term')->first()->pivot->is_credit_term;
|
$is_credit_term = $order->companyModule->inviters()->withPivot('is_credit_term')->first()->pivot->is_credit_term;
|
||||||
Log::channel('storage_invoices')->info('orderId: '.$order->id.', orderReference: '.$order->reference.', marking: '.$marking.', is_credit_term: '.$is_credit_term);
|
if(!$is_credit_term){
|
||||||
$packingLists = $order->destinationWarehousePackages;
|
Log::channel('storage_invoices')->info('orderId: '.$order->id.', orderReference: '.$order->reference.', marking: '.$marking.', is_credit_term: '.$is_credit_term);
|
||||||
|
$packingLists = $order->destinationWarehousePackages;
|
||||||
|
|
||||||
foreach ($packingLists as $packingList){
|
foreach ($packingLists as $packingList){
|
||||||
$arrivalDateAtChinaWarehouse = $this->getArrivalDateAtChinaWarehoue($packingList);
|
$arrivalDateAtChinaWarehouse = $this->getArrivalDateAtChinaWarehoue($packingList);
|
||||||
Log::channel('storage_invoices')->info('arrivalDateAtChinaWarehouse: '.json_encode($arrivalDateAtChinaWarehouse));
|
Log::channel('storage_invoices')->info('arrivalDateAtChinaWarehouse: '.json_encode($arrivalDateAtChinaWarehouse));
|
||||||
Log::channel('storage_invoices')->info('destinationWarehousePackage: '.json_encode($packingList));
|
Log::channel('storage_invoices')->info('destinationWarehousePackage: '.json_encode($packingList));
|
||||||
$eta = $this->getEtaFromPackingList($packingList);
|
$eta = $this->getEtaFromPackingList($packingList);
|
||||||
if($arrivalDateAtChinaWarehouse && $eta){
|
if($arrivalDateAtChinaWarehouse && $eta){
|
||||||
$transactions = $packingList->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
|
$transactions = $packingList->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
|
||||||
// $transactions = $destinationWarehousePackage->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->where('transactions.status', ApprovalStatus::APPROVED)->get();
|
// $transactions = $destinationWarehousePackage->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->where('transactions.status', ApprovalStatus::APPROVED)->get();
|
||||||
|
|
||||||
/** @var Transaction $invoice_transaction */
|
/** @var Transaction $invoice_transaction */
|
||||||
foreach ($transactions as $invoice_transaction){
|
foreach ($transactions as $invoice_transaction){
|
||||||
$result = null;
|
$result = $this->processSingleTransactionOfTypeShippingInvoice($invoice_transaction, $packingList, $order->company_module_id, $eta, $isBackDoorCheck);
|
||||||
if(!$is_credit_term){
|
if($result){
|
||||||
$result = $this->processSingleTransactionOfTypeShippingInvoice($invoice_transaction, $packingList, $order->company_module_id, $eta);
|
$results[] = $result;
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
$result = $this->isPaidOrWaivedStorageInvoiceExist($invoice_transaction, $packingList, $eta);
|
|
||||||
}
|
|
||||||
if($result){
|
|
||||||
$results[] = $result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +158,6 @@ class CheckStorageInvoiceTransactionProcessor
|
|||||||
if ($transport) {
|
if ($transport) {
|
||||||
$schedule = $transport->schedules->last();
|
$schedule = $transport->schedules->last();
|
||||||
if ($schedule) {
|
if ($schedule) {
|
||||||
Log::channel('storage_invoices')->info('schedule: '.json_encode($schedule));
|
|
||||||
return $schedule->eta;
|
return $schedule->eta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,18 +167,15 @@ class CheckStorageInvoiceTransactionProcessor
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processSingleTransactionOfTypeShippingInvoice($transaction, $destinationWarehousePackage, $company_module_id, $eta){
|
private function processSingleTransactionOfTypeShippingInvoice($transaction, $destinationWarehousePackage, $company_module_id, $eta, $isBackDoorCheck){
|
||||||
$pricePerCBM = 3;
|
$pricePerCBM = 3;
|
||||||
$resultNumberOfDaysFree = 10;
|
$resultNumberOfDaysFree = 10;
|
||||||
$dt1 = $eta->copy()->addDay()->startOfDay();
|
$dt1 = $eta->copy()->addDay()->startOfDay();
|
||||||
$dt2 = Carbon::now()->copy()->addDay()->startOfDay();
|
$resultStartDate = $dt1->format('Y-m-d');
|
||||||
|
$currentDatetime = Carbon::now();
|
||||||
|
$dt2 = $currentDatetime->copy()->addDay()->startOfDay();
|
||||||
|
$resultCurrentDate = $dt2->format('Y-m-d H:i:s');
|
||||||
$interval = Carbon::parse($dt2)->diff($dt1);
|
$interval = Carbon::parse($dt2)->diff($dt1);
|
||||||
Log::channel('storage_invoices')->info('eta: '.json_encode($eta));
|
|
||||||
Log::channel('storage_invoices')->info('dt1: '.json_encode($dt1));
|
|
||||||
Log::channel('storage_invoices')->info('dt2: '.json_encode($dt2));
|
|
||||||
Log::channel('storage_invoices')->info('interval: '.json_encode($interval));
|
|
||||||
Log::channel('storage_invoices')->info('Carbon now: '.json_encode(Carbon::now()));
|
|
||||||
|
|
||||||
|
|
||||||
$resultNumberOfDaysExceeded = $interval->days - $resultNumberOfDaysFree;
|
$resultNumberOfDaysExceeded = $interval->days - $resultNumberOfDaysFree;
|
||||||
$storageInvoice = $destinationWarehousePackage->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->first();
|
$storageInvoice = $destinationWarehousePackage->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->first();
|
||||||
@@ -200,78 +190,48 @@ class CheckStorageInvoiceTransactionProcessor
|
|||||||
$cbm = $cbm + $quantity;
|
$cbm = $cbm + $quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
$total_tax = 0;
|
|
||||||
$taxPercentage = TaxPercentage::DEFAULT;
|
|
||||||
$price_cbm = $pricePerCBM * $cbm * $resultNumberOfDaysExceeded;
|
$price_cbm = $pricePerCBM * $cbm * $resultNumberOfDaysExceeded;
|
||||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
Log::channel('storage_invoices')->info('storageInvoice: '.json_encode($storageInvoice).', $transaction->status: '.$transaction->status);
|
||||||
|
|
||||||
Log::channel('storage_invoices')->info('dateToCompare: '.json_encode($dateToCompare));
|
|
||||||
if(!$storageInvoice && $resultNumberOfDaysExceeded > 0 && $transaction->status != ApprovalStatus::COMPLETED){
|
if(!$storageInvoice && $resultNumberOfDaysExceeded > 0 && $transaction->status != ApprovalStatus::COMPLETED){
|
||||||
Log::channel('storage_invoices')->info('Created $transaction->id: '.$transaction->id);
|
Log::channel('storage_invoices')->info('Created $transaction->id: '.$transaction->id);
|
||||||
$billNumber = $this->generatesTransactionBillNumber->execute('STOR-');
|
$billNumber = $this->generatesTransactionBillNumber->execute('STOR-');
|
||||||
|
$storageInvoice = $this->createStorageInvoiceTransaction($destinationWarehousePackage, $billNumber, $company_module_id, $price_cbm);
|
||||||
if (Carbon::now()->isAfter($dateToCompare)) {
|
|
||||||
$taxPercentage = TaxPercentage::SIX_PERCENT;
|
|
||||||
$total_tax = $price_cbm * $taxPercentage / 100;
|
|
||||||
$price_cbm = $price_cbm + $total_tax;
|
|
||||||
}
|
|
||||||
|
|
||||||
$storageInvoice = $this->createStorageInvoiceTransaction($destinationWarehousePackage, $billNumber, $company_module_id, $price_cbm, $total_tax);
|
|
||||||
$storageInvoiceId = $storageInvoice->id;
|
$storageInvoiceId = $storageInvoice->id;
|
||||||
$this->createStorageInvoiceTransactionDetails($storageInvoice, $destinationWarehousePackage, $cbm, $pricePerCBM, $resultNumberOfDaysExceeded, $taxPercentage);
|
$this->createStorageInvoiceTransactionDetails($storageInvoice, $destinationWarehousePackage, $cbm, $pricePerCBM, $resultNumberOfDaysExceeded);
|
||||||
}
|
}
|
||||||
else if($storageInvoice){
|
else if($storageInvoice){
|
||||||
//Additional handling for giving selected storage invoice a waiver
|
|
||||||
if(isset($storageInvoice->is_waived) && $storageInvoice->is_waived){
|
|
||||||
$pricePerCBM = 0;
|
|
||||||
$price_cbm = $pricePerCBM * $cbm * $resultNumberOfDaysExceeded;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Additional handling for calculation of numberOfDaysExceeded in the event of the storage already paid
|
//Additional handling for calculation of numberOfDaysExceeded in the event of the storage already paid
|
||||||
$paymentStorageTransaction = $storageInvoice->transactions()->where('transactions.type', TransactionType::PAYMENT)->where('transactions.status', ApprovalStatus::APPROVED)->first();
|
$paymentStorageTransaction = $storageInvoice->transactions()->where('transactions.type', TransactionType::PAYMENT)->where('transactions.status', ApprovalStatus::APPROVED)->first();
|
||||||
if($paymentStorageTransaction){
|
if($paymentStorageTransaction){
|
||||||
$dateStorageInvoicePaid = $paymentStorageTransaction->created_at->copy()->addDay()->startOfDay();
|
$dateStorageInvoicePaid = $paymentStorageTransaction->created_at->copy()->addDay()->startOfDay();
|
||||||
Log::channel('storage_invoices')->info('dateStorageInvoicePaid: '.$dateStorageInvoicePaid.', resultCurrentDate: '.$dt2->format('Y-m-d H:i:s'));
|
Log::channel('storage_invoices')->info('dateStorageInvoicePaid: '.$dateStorageInvoicePaid.', resultCurrentDate: '.$resultCurrentDate);
|
||||||
$intervalRecalculate = Carbon::parse($dateStorageInvoicePaid)->diff($dt1);
|
$intervalRecalculate = Carbon::parse($dateStorageInvoicePaid)->diff($dt1);
|
||||||
$resultNumberOfDaysExceeded = $intervalRecalculate->days - $resultNumberOfDaysFree;
|
$resultNumberOfDaysExceeded = $intervalRecalculate->days - $resultNumberOfDaysFree;
|
||||||
$price_cbm = $pricePerCBM * $cbm * $resultNumberOfDaysExceeded;
|
$price_cbm = $pricePerCBM * $cbm * $resultNumberOfDaysExceeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Carbon::now()->isAfter($dateToCompare)) {
|
|
||||||
$taxPercentage = TaxPercentage::SIX_PERCENT;
|
|
||||||
$total_tax = $price_cbm * $taxPercentage / 100;
|
|
||||||
$price_cbm = $price_cbm + $total_tax;
|
|
||||||
}
|
|
||||||
|
|
||||||
$amount = $storageInvoice->amount;
|
$amount = $storageInvoice->amount;
|
||||||
$epsilon = 0.0001; // Tolerance for the comparison
|
$epsilon = 0.0001; // Tolerance for the comparison
|
||||||
Log::channel('storage_invoices')->info('Update $transaction->id: '.$transaction->id);
|
Log::channel('storage_invoices')->info('Update $transaction->id: '.$transaction->id);
|
||||||
Log::channel('storage_invoices')->info('$storageInvoice->status: '.$storageInvoice->status);
|
Log::channel('storage_invoices')->info('$storageInvoice->status: '.$storageInvoice->status);
|
||||||
Log::channel('storage_invoices')->info('price_cbm: '.$price_cbm."-".gettype($price_cbm));
|
Log::channel('storage_invoices')->info('price_cbm: '.$price_cbm."-".gettype($price_cbm));
|
||||||
Log::channel('storage_invoices')->info('amount: '.$amount);
|
|
||||||
|
|
||||||
$proceedToUpdate = false;
|
|
||||||
|
|
||||||
if(abs($price_cbm - $amount) > $epsilon && $storageInvoice->status !== ApprovalStatus::COMPLETED){
|
if(abs($price_cbm - $amount) > $epsilon && $storageInvoice->status !== ApprovalStatus::COMPLETED){
|
||||||
$paymentTransactions = $storageInvoice->transactions()->where('transactions.type', TransactionType::PAYMENT)->where('transactions.status', ApprovalStatus::PENDING_SUBMISSION)->get();
|
$paymentTransactions = $storageInvoice->transactions()->where('transactions.type', TransactionType::PAYMENT)->where('transactions.status', ApprovalStatus::PENDING_SUBMISSION)->get();
|
||||||
// if(!$isBackDoorCheck){
|
|
||||||
if(count($paymentTransactions) > 0){
|
if(!$isBackDoorCheck){
|
||||||
$this->updatePaymentTransactionViaNonGroupPayment($paymentTransactions);
|
if(count($paymentTransactions) > 0){
|
||||||
|
$this->updatePaymentTransactionViaNonGroupPayment($paymentTransactions);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$this->updatePaymentTransactionViaGroupPayment($storageInvoice);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
$this->updatePaymentTransactionViaGroupPayment($storageInvoice);
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
|
|
||||||
$proceedToUpdate = true;
|
$storageInvoice = $this->updateStorageInvoiceTransaction($storageInvoice, $price_cbm);
|
||||||
}
|
|
||||||
|
|
||||||
if($proceedToUpdate || ($pricePerCBM == 0 && $amount != 0)){
|
|
||||||
Log::channel('storage_invoices')->info('proceedToUpdate');
|
|
||||||
|
|
||||||
$storageInvoice = $this->updateStorageInvoiceTransaction($storageInvoice, $price_cbm, $total_tax);
|
|
||||||
$invoiceTransactionDetails = $storageInvoice->transactionDetails()->first();
|
$invoiceTransactionDetails = $storageInvoice->transactionDetails()->first();
|
||||||
$this->updateStorageInvoiceTransactionDetails($invoiceTransactionDetails, $destinationWarehousePackage, $cbm, $pricePerCBM, $resultNumberOfDaysExceeded, $taxPercentage);
|
$this->updateStorageInvoiceTransactionDetails($invoiceTransactionDetails, $destinationWarehousePackage, $cbm, $pricePerCBM, $resultNumberOfDaysExceeded);
|
||||||
}
|
}
|
||||||
|
|
||||||
$storageInvoiceId = $storageInvoice->id;
|
$storageInvoiceId = $storageInvoice->id;
|
||||||
@@ -283,75 +243,20 @@ class CheckStorageInvoiceTransactionProcessor
|
|||||||
'storageInvoiceId' => $storageInvoiceId,
|
'storageInvoiceId' => $storageInvoiceId,
|
||||||
'numberOfDaysExceeded' => $resultNumberOfDaysExceeded,
|
'numberOfDaysExceeded' => $resultNumberOfDaysExceeded,
|
||||||
'numberOfDaysFree' => $resultNumberOfDaysFree,
|
'numberOfDaysFree' => $resultNumberOfDaysFree,
|
||||||
'startDate' => $dt1->format('Y-m-d'),
|
'startDate' => $resultStartDate,
|
||||||
'currentDate' => $dt2->format('Y-m-d H:i:s'),
|
'currentDate' => $resultCurrentDate,
|
||||||
'cbm' => $cbm,
|
'cbm' => $cbm,
|
||||||
'pricePerCBM' => $pricePerCBM,
|
'pricePerCBM' => $pricePerCBM,
|
||||||
'storageInvoice' => new TransactionWithStorageResource($storageInvoice)
|
'storageInvoice' => new TransactionResource($storageInvoice)
|
||||||
];
|
];
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isPaidOrWaivedStorageInvoiceExist($transaction, $packingList, $eta){
|
|
||||||
$pricePerCBM = 3;
|
|
||||||
$resultNumberOfDaysFree = 10;
|
|
||||||
$dt1 = $eta->copy()->addDay()->startOfDay();
|
|
||||||
$resultStartDate = $dt1->format('Y-m-d');
|
|
||||||
$currentDatetime = Carbon::now();
|
|
||||||
$dt2 = $currentDatetime->copy()->addDay()->startOfDay();
|
|
||||||
$resultCurrentDate = $dt2->format('Y-m-d H:i:s');
|
|
||||||
$interval = Carbon::parse($dt2)->diff($dt1);
|
|
||||||
$resultNumberOfDaysExceeded = $interval->days - $resultNumberOfDaysFree;
|
|
||||||
$paidStorageInvoice = $packingList->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->whereIn('transactions.status', [ApprovalStatus::COMPLETED])->first();
|
|
||||||
if($paidStorageInvoice){
|
|
||||||
$storageInvoice = $paidStorageInvoice;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$waivedStorageInvoice = $packingList->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->where('transactions.is_waived', 1)->whereIn('transactions.status', [ApprovalStatus::APPROVED])->first();
|
|
||||||
$storageInvoice = $waivedStorageInvoice;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($storageInvoice){
|
|
||||||
$storageInvoiceId = $storageInvoice->id;
|
|
||||||
|
|
||||||
if(isset($storageInvoice->is_waived) && $storageInvoice->is_waived){
|
|
||||||
$pricePerCBM = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$transactionDetailsItems = $transaction->transactionDetails()->get();
|
|
||||||
$cbm = 0.00;
|
|
||||||
foreach ($transactionDetailsItems as $tdItem){
|
|
||||||
$quantity = $tdItem->quantity;
|
|
||||||
if($tdItem->price < 0.00){
|
|
||||||
$quantity = $quantity * -1;
|
|
||||||
}
|
|
||||||
$cbm = $cbm + $quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($storageInvoiceId !== 0){
|
|
||||||
$result = [
|
|
||||||
'parentInvoiceId' => $transaction->id,
|
|
||||||
'storageInvoiceId' => $storageInvoiceId,
|
|
||||||
'numberOfDaysExceeded' => $resultNumberOfDaysExceeded,
|
|
||||||
'numberOfDaysFree' => $resultNumberOfDaysFree,
|
|
||||||
'startDate' => $resultStartDate,
|
|
||||||
'currentDate' => $resultCurrentDate,
|
|
||||||
'cbm' => $cbm,
|
|
||||||
'pricePerCBM' => $pricePerCBM,
|
|
||||||
'storageInvoice' => new TransactionWithStorageResource($storageInvoice)
|
|
||||||
];
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function updatePaymentTransactionViaGroupPayment($storageInvoice){
|
private function updatePaymentTransactionViaGroupPayment($storageInvoice){
|
||||||
Log::channel('storage_invoices')->info('updatePaymentTransactionViaGroupPayment');
|
Log::channel('storage_invoices')->info('updatePaymentTransactionViaGroupPayment');
|
||||||
$groups = $storageInvoice->groups()->whereNotIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::SUSPENDED])->get();
|
$groups = $storageInvoice->groups()->get();
|
||||||
foreach ($groups as $grp){
|
foreach ($groups as $grp){
|
||||||
$groupReference = $grp->reference;
|
$groupReference = $grp->reference;
|
||||||
$walletTransaction = $this->fetchesTransaction->execute(['payment_reference' => $groupReference]);
|
$walletTransaction = $this->fetchesTransaction->execute(['payment_reference' => $groupReference]);
|
||||||
@@ -379,7 +284,7 @@ class CheckStorageInvoiceTransactionProcessor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateStorageInvoiceTransaction(Transaction $transaction, float $totalAmount, float $totalTax){
|
private function updateStorageInvoiceTransaction(Transaction $transaction, float $totalAmount){
|
||||||
|
|
||||||
$object = new TransactionObject(
|
$object = new TransactionObject(
|
||||||
$transaction->bill_no,
|
$transaction->bill_no,
|
||||||
@@ -393,7 +298,7 @@ class CheckStorageInvoiceTransactionProcessor
|
|||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
$totalTax,
|
0,
|
||||||
0,
|
0,
|
||||||
null,
|
null,
|
||||||
ApprovalStatus::APPROVED
|
ApprovalStatus::APPROVED
|
||||||
@@ -405,19 +310,18 @@ class CheckStorageInvoiceTransactionProcessor
|
|||||||
return $invoice_transaction;
|
return $invoice_transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateStorageInvoiceTransactionDetails($invoice_transaction_details, PackingList $packing_list, $cbm, $pricePerCBM, $numberOfDays, $taxPercentage){
|
private function updateStorageInvoiceTransactionDetails($invoice_transaction_details, PackingList $packing_list, $cbm, $pricePerCBM, $numberOfDays){
|
||||||
$object_detail = new TransactionDetailObject(
|
$object_detail = new TransactionDetailObject(
|
||||||
'STORAGE_FEE',
|
'STORAGE_FEE',
|
||||||
TransactionDetailType::STORAGE_FEE.' for '.$numberOfDays. ' days * RM'.$pricePerCBM.'<br>'.round($packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum('quantity'), 3).' CTNS - '.round($cbm, 3).' CBM',
|
TransactionDetailType::STORAGE_FEE.' for '.$numberOfDays. ' days * RM'.$pricePerCBM.'<br>'.round($packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum('quantity'), 3).' CTNS - '.round($cbm, 3).' CBM',
|
||||||
$cbm,
|
$cbm,
|
||||||
$pricePerCBM * $numberOfDays,
|
$pricePerCBM * $numberOfDays
|
||||||
$taxPercentage
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->updatesTransactionDetail->execute($invoice_transaction_details, $object_detail);
|
$this->updatesTransactionDetail->execute($invoice_transaction_details, $object_detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createStorageInvoiceTransaction(PackingList $packing_list, string $billNumber, int $companyModuleId, float $totalAmount, float $totalTax){
|
private function createStorageInvoiceTransaction(PackingList $packing_list, string $billNumber, int $companyModuleId, float $totalAmount){
|
||||||
|
|
||||||
$object = new TransactionObject(
|
$object = new TransactionObject(
|
||||||
$billNumber,
|
$billNumber,
|
||||||
@@ -431,7 +335,7 @@ class CheckStorageInvoiceTransactionProcessor
|
|||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
$totalTax,
|
0,
|
||||||
0,
|
0,
|
||||||
null,
|
null,
|
||||||
ApprovalStatus::APPROVED
|
ApprovalStatus::APPROVED
|
||||||
@@ -443,13 +347,12 @@ class CheckStorageInvoiceTransactionProcessor
|
|||||||
return $invoice_transaction;
|
return $invoice_transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createStorageInvoiceTransactionDetails($invoice_transaction, PackingList $packing_list, $cbm, $pricePerCBM, $numberOfDays, $taxPercentage){
|
private function createStorageInvoiceTransactionDetails($invoice_transaction, PackingList $packing_list, $cbm, $pricePerCBM, $numberOfDays){
|
||||||
$object_detail = new TransactionDetailObject(
|
$object_detail = new TransactionDetailObject(
|
||||||
'STORAGE_FEE',
|
'STORAGE_FEE',
|
||||||
TransactionDetailType::STORAGE_FEE.' for '.$numberOfDays. ' days * RM'.$pricePerCBM.'<br>'.round($packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum('quantity'), 3).' CTNS - '.round($cbm, 3).' CBM',
|
TransactionDetailType::STORAGE_FEE.' for '.$numberOfDays. ' days * RM'.$pricePerCBM.'<br>'.round($packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum('quantity'), 3).' CTNS - '.round($cbm, 3).' CBM',
|
||||||
$cbm,
|
$cbm,
|
||||||
$pricePerCBM * $numberOfDays,
|
$pricePerCBM * $numberOfDays
|
||||||
$taxPercentage
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||||
|
|||||||
@@ -22,17 +22,14 @@ use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\PackageType;
|
use App\Classes\ValueObjects\Constants\PackageType;
|
||||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||||
use App\Classes\ValueObjects\Constants\TaxPercentage;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionDetailType;
|
use App\Classes\ValueObjects\Constants\TransactionDetailType;
|
||||||
|
|
||||||
use App\Models\CompanyModule;
|
use App\Models\CompanyModule;
|
||||||
use App\Models\Document;
|
use App\Models\Document;
|
||||||
use App\Models\PackingList;
|
use App\Models\PackingList;
|
||||||
use App\Models\Transaction;
|
use App\Models\Transaction;
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||||
|
|
||||||
class CreateInvoiceTransactionProcessor
|
class CreateInvoiceTransactionProcessor
|
||||||
@@ -174,16 +171,6 @@ class CreateInvoiceTransactionProcessor
|
|||||||
|
|
||||||
$billNumber = $this->generatesTransactionBillNumber->execute('SHIP-');
|
$billNumber = $this->generatesTransactionBillNumber->execute('SHIP-');
|
||||||
|
|
||||||
$total_tax = 0;
|
|
||||||
$taxPercentage = TaxPercentage::DEFAULT;
|
|
||||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
|
||||||
$shippingInvoiceTransactionCreatedDate = Carbon::now();
|
|
||||||
if ($shippingInvoiceTransactionCreatedDate->isAfter($dateToCompare)) {
|
|
||||||
$taxPercentage = TaxPercentage::SIX_PERCENT;
|
|
||||||
$total_tax = $total_cbm * $taxPercentage / 100;
|
|
||||||
$total_cbm = $total_cbm + $total_tax;
|
|
||||||
}
|
|
||||||
|
|
||||||
$object = new TransactionObject(
|
$object = new TransactionObject(
|
||||||
$billNumber,
|
$billNumber,
|
||||||
TransactionType::SHIPPING_INVOICE,
|
TransactionType::SHIPPING_INVOICE,
|
||||||
@@ -196,7 +183,7 @@ class CreateInvoiceTransactionProcessor
|
|||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
$total_tax,
|
0,
|
||||||
0,
|
0,
|
||||||
null,
|
null,
|
||||||
ApprovalStatus::PENDING_SUBMISSION
|
ApprovalStatus::PENDING_SUBMISSION
|
||||||
@@ -209,8 +196,7 @@ class CreateInvoiceTransactionProcessor
|
|||||||
'SHIPPING_FEE',
|
'SHIPPING_FEE',
|
||||||
TransactionDetailType::SHIPPING_FEE.'<br>'.round($packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum('quantity'), 3).' CTNS - '.round($cbm, 3).' CBM',
|
TransactionDetailType::SHIPPING_FEE.'<br>'.round($packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum('quantity'), 3).' CTNS - '.round($cbm, 3).' CBM',
|
||||||
$cbm,
|
$cbm,
|
||||||
$price_cbm,
|
$price_cbm
|
||||||
$taxPercentage
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||||
@@ -220,8 +206,7 @@ class CreateInvoiceTransactionProcessor
|
|||||||
'OVER_WEIGHT_CHARGES',
|
'OVER_WEIGHT_CHARGES',
|
||||||
TransactionDetailType::OVER_WEIGHT_CHARGES,
|
TransactionDetailType::OVER_WEIGHT_CHARGES,
|
||||||
$over_weight_cbm,
|
$over_weight_cbm,
|
||||||
$price_cbm,
|
$price_cbm
|
||||||
$taxPercentage
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||||
@@ -232,8 +217,7 @@ class CreateInvoiceTransactionProcessor
|
|||||||
'MIN_CBM_CHARGES',
|
'MIN_CBM_CHARGES',
|
||||||
TransactionDetailType::MIN_CBM_CHARGES,
|
TransactionDetailType::MIN_CBM_CHARGES,
|
||||||
$minimum_charge,
|
$minimum_charge,
|
||||||
$price_cbm,
|
$price_cbm
|
||||||
$taxPercentage
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||||
|
|||||||
+1
-3
@@ -9,7 +9,6 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|||||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||||
use App\Classes\ValueObjects\Constants\TaxPercentage;
|
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
|
|
||||||
class CreateShippingCostTransactionProcessor
|
class CreateShippingCostTransactionProcessor
|
||||||
@@ -58,8 +57,7 @@ class CreateShippingCostTransactionProcessor
|
|||||||
TransactionType::SHIPPING_COST,
|
TransactionType::SHIPPING_COST,
|
||||||
'Shipping Cost',
|
'Shipping Cost',
|
||||||
$quantity,
|
$quantity,
|
||||||
$totalShippingCost/$totalCBM,
|
$totalShippingCost/$totalCBM
|
||||||
TaxPercentage::SIX_PERCENT
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$shippingCostTransaction = $this->createsShippingCostTransaction->execute($order, $transactionObject, $transactionDetailObject);
|
$shippingCostTransaction = $this->createsShippingCostTransaction->execute($order, $transactionObject, $transactionDetailObject);
|
||||||
|
|||||||
-89
@@ -1,89 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Transactions\Processors;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Notifications\InvoiceIssuedEmail;
|
|
||||||
use App\Models\Document;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
|
||||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
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 Carbon\Carbon;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class CreateStorageInvoiceDocTransactionFixProcessor
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var UpdatesTransactionStatus */
|
|
||||||
private $updatesTransactionStatus;
|
|
||||||
|
|
||||||
/** @var CreatesDocument */
|
|
||||||
private $createsDocument;
|
|
||||||
|
|
||||||
/** @var CreatesFiles */
|
|
||||||
private $createsFiles;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
|
||||||
* @param CreatesDocument $createsDocument
|
|
||||||
* @param CreatesFiles $createsFiles
|
|
||||||
*/
|
|
||||||
public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, CreatesDocument $createsDocument, CreatesFiles $createsFiles)
|
|
||||||
{
|
|
||||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
|
||||||
$this->createsDocument = $createsDocument;
|
|
||||||
$this->createsFiles = $createsFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(PackingList $packingList)
|
|
||||||
{
|
|
||||||
/** @var Transaction $invoice_transaction */
|
|
||||||
$invoice_transaction = $packingList->transactions()->where('transactions.type', TransactionType::STORAGE_INVOICE)->whereIn('status', [ApprovalStatus::COMPLETED])->first();
|
|
||||||
|
|
||||||
// $this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
|
||||||
$view = 'pages.pdfs.shipping_invoice';
|
|
||||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
|
||||||
Log::info('$dateToCompare 2: '.$dateToCompare);
|
|
||||||
$storageInvoiceTransactionCreatedDate = Carbon::parse($invoice_transaction->created_at);
|
|
||||||
Log::info('$storageInvoiceTransactionCreatedDate 2: '.$storageInvoiceTransactionCreatedDate);
|
|
||||||
if ($storageInvoiceTransactionCreatedDate->isAfter($dateToCompare) && $invoice_transaction->tax > 0) {
|
|
||||||
$view = 'pages.pdfs.shipping_invoice_sst';
|
|
||||||
}
|
|
||||||
|
|
||||||
$transaction_invoice_pdf = LaravelMpdf::loadView($view, ['invoice_transaction' => $invoice_transaction]);
|
|
||||||
|
|
||||||
$document_object = new DocumentObject(
|
|
||||||
DocumentType::STORAGE_INVOICE,
|
|
||||||
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
|
|
||||||
'',
|
|
||||||
ApprovalStatus::COMPLETED,
|
|
||||||
'storage_invoice'
|
|
||||||
);
|
|
||||||
|
|
||||||
// $invouce_transaction_document = $invoice_transaction->documents()->where('document_type', DocumentType::STORAGE_INVOICE)->first();
|
|
||||||
// if(!$invouce_transaction_document){
|
|
||||||
/** @var Document $document */
|
|
||||||
$document = $this->createsDocument->execute($invoice_transaction, $document_object);
|
|
||||||
|
|
||||||
$this->createsFiles->execute($document, $document_object);
|
|
||||||
// $user = $packingList->owner->companyModule->employees()->first();
|
|
||||||
// if(app()->environment(['production'])) {
|
|
||||||
// $user->notify(new InvoiceIssuedEmail($user, $packingList));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+1
-12
@@ -16,8 +16,6 @@ use App\Classes\Modules\Documents\Services\CreatesFiles;
|
|||||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class CreateStorageInvoiceDocTransactionProcessor
|
class CreateStorageInvoiceDocTransactionProcessor
|
||||||
{
|
{
|
||||||
@@ -55,16 +53,7 @@ class CreateStorageInvoiceDocTransactionProcessor
|
|||||||
|
|
||||||
// $this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
// $this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
||||||
|
|
||||||
$view = 'pages.pdfs.shipping_invoice';
|
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice_transaction]);
|
||||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
|
||||||
Log::info('$dateToCompare: '.$dateToCompare);
|
|
||||||
$storageInvoiceTransactionCreatedDate = Carbon::parse($invoice_transaction->created_at);
|
|
||||||
Log::info('$storageInvoiceTransactionCreatedDate: '.$storageInvoiceTransactionCreatedDate);
|
|
||||||
if ($storageInvoiceTransactionCreatedDate->isAfter($dateToCompare) && $invoice_transaction->tax > 0) {
|
|
||||||
$view = 'pages.pdfs.shipping_invoice_sst';
|
|
||||||
}
|
|
||||||
|
|
||||||
$transaction_invoice_pdf = LaravelMpdf::loadView($view, ['invoice_transaction' => $invoice_transaction]);
|
|
||||||
|
|
||||||
$document_object = new DocumentObject(
|
$document_object = new DocumentObject(
|
||||||
DocumentType::STORAGE_INVOICE,
|
DocumentType::STORAGE_INVOICE,
|
||||||
|
|||||||
@@ -44,8 +44,6 @@ class CreatesShippingCostTransaction extends AbstractUpdateRelationshipRecord
|
|||||||
$model->quantity = $transactionDetailObject->getQuantity();
|
$model->quantity = $transactionDetailObject->getQuantity();
|
||||||
$model->price = $transactionDetailObject->getPrice();
|
$model->price = $transactionDetailObject->getPrice();
|
||||||
$model->amount = $transactionDetailObject->getAmount();
|
$model->amount = $transactionDetailObject->getAmount();
|
||||||
$model->tax_amount = $transactionDetailObject->getTaxAmount();
|
|
||||||
$model->tax_percentage = $transactionDetailObject->getTaxPercentage();
|
|
||||||
|
|
||||||
return $this->handler($transaction->transactionDetails(), $model);
|
return $this->handler($transaction->transactionDetails(), $model);
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,8 @@ namespace App\Classes\Modules\Transactions\Services;
|
|||||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Models\PackingList;
|
use App\Models\PackingList;
|
||||||
use App\Models\Transaction;
|
use App\Models\Transaction;
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
class CreatesTransaction extends AbstractUpdateRelationshipRecord
|
class CreatesTransaction extends AbstractUpdateRelationshipRecord
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ class CreatesTransactionDetail extends AbstractUpdateRelationshipRecord
|
|||||||
$model->quantity = $object->getQuantity();
|
$model->quantity = $object->getQuantity();
|
||||||
$model->price = $object->getPrice();
|
$model->price = $object->getPrice();
|
||||||
$model->amount = $object->getAmount();
|
$model->amount = $object->getAmount();
|
||||||
$model->tax_amount = $object->getTaxAmount();
|
|
||||||
$model->tax_percentage = $object->getTaxPercentage();
|
|
||||||
|
|
||||||
return $this->handler($transaction->transactionDetails(), $model);
|
return $this->handler($transaction->transactionDetails(), $model);
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ class UpdatesTransactionDetail extends AbstractUpdateRecord
|
|||||||
$transactionDetail->quantity = $object->getQuantity();
|
$transactionDetail->quantity = $object->getQuantity();
|
||||||
$transactionDetail->price = $object->getPrice();
|
$transactionDetail->price = $object->getPrice();
|
||||||
$transactionDetail->amount = $object->getAmount();
|
$transactionDetail->amount = $object->getAmount();
|
||||||
$transactionDetail->tax_amount = $object->getTaxAmount();
|
|
||||||
$transactionDetail->tax_percentage = $object->getTaxPercentage();
|
|
||||||
|
|
||||||
return $this->handler($transactionDetail);
|
return $this->handler($transactionDetail);
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Transactions\Services;
|
|
||||||
|
|
||||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
|
|
||||||
class UpdatesTransactionIsWaived extends AbstractUpdateRecord
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Transaction $model
|
|
||||||
* @return \Illuminate\Database\Eloquent\Model
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(Transaction $model)
|
|
||||||
{
|
|
||||||
$model->is_waived = 1;
|
|
||||||
|
|
||||||
return $this->handler($model);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Transactions\Standards\Rules;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractRule;
|
|
||||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
|
||||||
|
|
||||||
class CanRegenerateStorageInvoice extends AbstractRule
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function authorized($object): bool
|
|
||||||
{
|
|
||||||
$user = Auth()->user();
|
|
||||||
if($user){
|
|
||||||
$roleToCheck = Auth()->user()->type;
|
|
||||||
if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $object
|
|
||||||
* @return bool
|
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
||||||
*/
|
|
||||||
protected function validators($object): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $object
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function criteria($object): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Transactions\Standards\Rules;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractRule;
|
|
||||||
use App\Classes\Modules\Transactions\DataTransferObjects\WaiveTransactionObject;
|
|
||||||
use App\Classes\Modules\Transactions\Standards\Validators\WaiveTransactionValidation;
|
|
||||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
|
||||||
|
|
||||||
class CanWaiveTransaction extends AbstractRule
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var WaiveTransactionValidation */
|
|
||||||
private $waiveTransactionValidation;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(WaiveTransactionValidation $waiveTransactionValidation)
|
|
||||||
{
|
|
||||||
$this->waiveTransactionValidation = $waiveTransactionValidation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function authorized($object): bool
|
|
||||||
{
|
|
||||||
$user = Auth()->user();
|
|
||||||
if($user){
|
|
||||||
$roleToCheck = Auth()->user()->type;
|
|
||||||
if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param WaiveTransactionObject $object
|
|
||||||
* @return bool
|
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
||||||
*/
|
|
||||||
protected function validators($object): bool
|
|
||||||
{
|
|
||||||
return $this->waiveTransactionValidation->validate($object);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $object
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function criteria($object): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Transactions\Standards\Validators;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractValidation;
|
|
||||||
use App\Classes\Modules\Transactions\DataTransferObjects\WaiveTransactionObject;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
|
|
||||||
class WaiveTransactionValidation extends AbstractValidation
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param WaiveTransactionObject $object
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function data($object): array {
|
|
||||||
return [
|
|
||||||
'id' => $object->getId(),
|
|
||||||
'billNo' => $object->getBillNo(),
|
|
||||||
'type' => $object->getType(),
|
|
||||||
'status' => $object->getStatus(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function rules(): array {
|
|
||||||
return [
|
|
||||||
'id' => 'required',
|
|
||||||
'type' => ['required', 'numeric', 'in:'.TransactionType::STORAGE_INVOICE], //Only storage invoice (type 16) can be waived
|
|
||||||
'status' => ['required', 'numeric', 'in:'.ApprovalStatus::APPROVED], //Approve storage invoice only, paid invoice stricly forbidden
|
|
||||||
// 'billNo' => 'required',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function messages(): array {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -15,7 +15,6 @@ use App\Classes\Modules\Transactions\Services\CreatesTransactionableTransaction;
|
|||||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
|
||||||
use App\Models\CompanyModule;
|
use App\Models\CompanyModule;
|
||||||
|
|
||||||
class CreditWalletProcessor
|
class CreditWalletProcessor
|
||||||
@@ -38,9 +37,6 @@ class CreditWalletProcessor
|
|||||||
/** @var UpdatesWallet */
|
/** @var UpdatesWallet */
|
||||||
private $updatesWallet;
|
private $updatesWallet;
|
||||||
|
|
||||||
/** @var UpdatesWalletBalance */
|
|
||||||
private $updatesWalletBalance;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CreateWalletLogic constructor.
|
* CreateWalletLogic constructor.
|
||||||
* @param GeneratesWalletCode $generatesWalletCode
|
* @param GeneratesWalletCode $generatesWalletCode
|
||||||
@@ -49,7 +45,6 @@ class CreditWalletProcessor
|
|||||||
* @param CreatesTransaction $createsTransaction
|
* @param CreatesTransaction $createsTransaction
|
||||||
* @param CreatesTransactionableTransaction $createsTransactionableTransaction
|
* @param CreatesTransactionableTransaction $createsTransactionableTransaction
|
||||||
* @param UpdatesWallet $updatesWallet
|
* @param UpdatesWallet $updatesWallet
|
||||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
GeneratesWalletCode $generatesWalletCode,
|
GeneratesWalletCode $generatesWalletCode,
|
||||||
@@ -57,8 +52,7 @@ class CreditWalletProcessor
|
|||||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||||
CreatesTransaction $createsTransaction,
|
CreatesTransaction $createsTransaction,
|
||||||
CreatesTransactionableTransaction $createsTransactionableTransaction,
|
CreatesTransactionableTransaction $createsTransactionableTransaction,
|
||||||
UpdatesWallet $updatesWallet,
|
UpdatesWallet $updatesWallet
|
||||||
UpdatesWalletBalance $updatesWalletBalance
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$this->generatesWalletCode = $generatesWalletCode;
|
$this->generatesWalletCode = $generatesWalletCode;
|
||||||
@@ -67,7 +61,6 @@ class CreditWalletProcessor
|
|||||||
$this->createsTransaction = $createsTransaction;
|
$this->createsTransaction = $createsTransaction;
|
||||||
$this->createsTransactionableTransaction = $createsTransactionableTransaction;
|
$this->createsTransactionableTransaction = $createsTransactionableTransaction;
|
||||||
$this->updatesWallet = $updatesWallet;
|
$this->updatesWallet = $updatesWallet;
|
||||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -94,13 +87,11 @@ class CreditWalletProcessor
|
|||||||
$transaction_object = new TransactionObject($billNumber, $transactionType === 2 ? TransactionType::DEBIT_NOTE : TransactionType::CREDIT_NOTE, 1, $wallet->owner->id, 1, PaymentMethodType::CASH, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], $reference);
|
$transaction_object = new TransactionObject($billNumber, $transactionType === 2 ? TransactionType::DEBIT_NOTE : TransactionType::CREDIT_NOTE, 1, $wallet->owner->id, 1, PaymentMethodType::CASH, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], $reference);
|
||||||
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
|
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
|
||||||
|
|
||||||
$this->updatesWalletBalance->execute($wallet, $transaction->amount);
|
$updateWalletAmount = $transactionType === 2 ? ($wallet->amount - $transaction->amount) : ($wallet->amount + $transaction->amount);
|
||||||
|
|
||||||
// $updateWalletAmount = $transactionType === 2 ? ($wallet->amount - $transaction->amount) : ($wallet->amount + $transaction->amount);
|
$walletObject = new WalletObject($wallet->owner->id, $wallet->currency_id, $wallet->code, $updateWalletAmount);
|
||||||
|
|
||||||
// $walletObject = new WalletObject($wallet->owner->id, $wallet->currency_id, $wallet->code, $updateWalletAmount);
|
$wallet = $this->updatesWallet->execute($wallet, $walletObject);
|
||||||
|
|
||||||
// $wallet = $this->updatesWallet->execute($wallet, $walletObject);
|
|
||||||
|
|
||||||
return $wallet;
|
return $wallet;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use App\Classes\ValueObjects\Constants\TransactionType;
|
|||||||
use App\Models\PackingList;
|
use App\Models\PackingList;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class InvoiceIssuedEmail extends AbstractEmail
|
class InvoiceIssuedEmail extends AbstractEmail
|
||||||
@@ -36,14 +35,10 @@ class InvoiceIssuedEmail extends AbstractEmail
|
|||||||
$invoice = $this->packingList->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::APPROVED)->first();
|
$invoice = $this->packingList->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::APPROVED)->first();
|
||||||
$invoiceDocument = $invoice->documents()->first()->files;
|
$invoiceDocument = $invoice->documents()->first()->files;
|
||||||
|
|
||||||
// $fileContent = Storage::disk('documents')->get($invoiceDocument->first()->file->file_info->original->file);
|
|
||||||
$filePath = storage_path('app/documents/' . $invoiceDocument->first()->file->file_info->original->file);
|
|
||||||
|
|
||||||
Log::info('InvoiceIssuedEmail sent - Att: '.$this->user->name.' - Invoice for order no.'. $this->packingList->owner->reference);
|
|
||||||
|
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->subject('Att: '.$this->user->name.' - Invoice for order no.'. $this->packingList->owner->reference)
|
->subject('Att: '.$this->user->name.' - Invoice for order no.'. $this->packingList->owner->reference)
|
||||||
->attach($filePath, [
|
->attach(Storage::disk('documents')->get($invoiceDocument->first()->file->file_info->original->file), [
|
||||||
'as' => 'name.pdf',
|
'as' => 'name.pdf',
|
||||||
'mime' => 'application/pdf',
|
'mime' => 'application/pdf',
|
||||||
])->view('emails.shipment.invoice', ['user' => $this->user, 'packingList' => $this->packingList]);
|
])->view('emails.shipment.invoice', ['user' => $this->user, 'packingList' => $this->packingList]);
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Notifications;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
|
||||||
|
|
||||||
class PermitsReminderEmail extends AbstractEmail
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var User */
|
|
||||||
private $user;
|
|
||||||
|
|
||||||
private $reminders;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SendResetPasswordEmail constructor.
|
|
||||||
* @param User $user
|
|
||||||
* @param PasswordReset $attempt
|
|
||||||
*/
|
|
||||||
public function __construct(User $user, $reminders)
|
|
||||||
{
|
|
||||||
$this->user = $user;
|
|
||||||
$this->reminders = $reminders;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toMail()
|
|
||||||
{
|
|
||||||
return (new MailMessage)
|
|
||||||
->subject('Permits Renew Remidner Email')
|
|
||||||
->view('emails.reminder.permits_reminder', ['user' => $this->user, 'reminders' => $this->reminders]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,6 @@ use App\Models\PackingList;
|
|||||||
use App\Models\PasswordReset;
|
use App\Models\PasswordReset;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class ShipmentDepartureEmail extends AbstractEmail
|
class ShipmentDepartureEmail extends AbstractEmail
|
||||||
@@ -41,14 +40,10 @@ class ShipmentDepartureEmail extends AbstractEmail
|
|||||||
|
|
||||||
$invoiceDocument = $invoice->documents()->first()->files;
|
$invoiceDocument = $invoice->documents()->first()->files;
|
||||||
|
|
||||||
// $fileContent = Storage::disk('documents')->get($invoiceDocument->first()->file->file_info->original->file);
|
|
||||||
$filePath= storage_path('app/documents/' . $invoiceDocument->first()->file->file_info->original->file);
|
|
||||||
|
|
||||||
Log::info('ShipmentDepartureEmail sent - Att: '.$this->user->name.' - Invoice for order no.'. $this->packingList->owner->reference);
|
|
||||||
|
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->subject('Your packages are on the way to malaysia - Invoice pending payment for order no.'. $this->packingList->owner->reference)
|
->subject('Your packages are on the way to malaysia - Invoice pending payment for order no.'. $this->packingList->owner->reference)
|
||||||
->attach($filePath, [
|
->attach(Storage::disk('documents')->get($invoiceDocument->first()->file->file_info->original->file), [
|
||||||
'as' => 'name.pdf',
|
'as' => 'name.pdf',
|
||||||
'mime' => 'application/pdf',
|
'mime' => 'application/pdf',
|
||||||
])->bcc(['email_test@cief-malaysia.com'])->view('emails.shipment.ETD', ['user' => $this->user, 'packingList' => $this->packingList]);
|
])->bcc(['email_test@cief-malaysia.com'])->view('emails.shipment.ETD', ['user' => $this->user, 'packingList' => $this->packingList]);
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\ValueObjects\Constants;
|
|
||||||
|
|
||||||
final class TaxPercentage {
|
|
||||||
|
|
||||||
public const DEFAULT = 0;
|
|
||||||
|
|
||||||
public const NO_TAX = 0;
|
|
||||||
|
|
||||||
public const SIX_PERCENT = 6;
|
|
||||||
}
|
|
||||||
@@ -13,6 +13,4 @@ final class TransactionDetailType {
|
|||||||
public const CUSTOM_CHARGES = 'Custom charges';
|
public const CUSTOM_CHARGES = 'Custom charges';
|
||||||
|
|
||||||
public const STORAGE_FEE = 'Malaysia Warehouse Storage Fee';
|
public const STORAGE_FEE = 'Malaysia Warehouse Storage Fee';
|
||||||
|
|
||||||
public const PAY_ON_BEHALF = 'Pay on behalf';
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ namespace App\Console\Commands;
|
|||||||
|
|
||||||
|
|
||||||
use App\Classes\Modules\Transactions\Services\FetchesGroup;
|
use App\Classes\Modules\Transactions\Services\FetchesGroup;
|
||||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
|
||||||
use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor;
|
use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor;
|
||||||
use App\Classes\Modules\Transactions\Processors\CreateStorageInvoiceDocTransactionFixProcessor;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
@@ -32,24 +30,17 @@ class FixGroupPaymentProblem extends Command
|
|||||||
/** @var ReleaseGoodsToCustomerProcessor */
|
/** @var ReleaseGoodsToCustomerProcessor */
|
||||||
private $releaseGoodsToCustomerProcessor;
|
private $releaseGoodsToCustomerProcessor;
|
||||||
|
|
||||||
/** @var FetchesOrder */
|
|
||||||
private $fetchesOrder;
|
|
||||||
|
|
||||||
/** @var CreateStorageInvoiceDocTransactionFixProcessor */
|
|
||||||
private $createStorageInvoiceDocTransactionProcessor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new command instance.
|
* Create a new command instance.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(FetchesGroup $fetchesGroup, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor, FetchesOrder $fetchesOrder, CreateStorageInvoiceDocTransactionFixProcessor $createStorageInvoiceDocTransactionProcessor)
|
public function __construct(FetchesGroup $fetchesGroup, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->fetchesGroup = $fetchesGroup;
|
$this->fetchesGroup = $fetchesGroup;
|
||||||
$this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor;
|
$this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor;
|
||||||
$this->fetchesOrder = $fetchesOrder;
|
|
||||||
$this->createStorageInvoiceDocTransactionProcessor = $createStorageInvoiceDocTransactionProcessor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -65,25 +56,22 @@ class FixGroupPaymentProblem extends Command
|
|||||||
$this->info(Carbon::now() . ': Start data patch.');
|
$this->info(Carbon::now() . ': Start data patch.');
|
||||||
$start = new Carbon();
|
$start = new Carbon();
|
||||||
|
|
||||||
/*
|
|
||||||
$group = $this->fetchesGroup->execute(['id' => 325]);
|
$group = $this->fetchesGroup->execute(['id' => 325]);
|
||||||
|
|
||||||
$this->info('FixGroupPaymentProblem group: '.json_encode($group));
|
$this->info('FixGroupPaymentProblem group: '.json_encode($group));
|
||||||
if ($group) {
|
if ($group) {
|
||||||
foreach ($group->groupTransactions as $groupTransaction) {
|
foreach ($group->groupTransactions as $groupTransaction) {
|
||||||
$invoice = $groupTransaction->transaction;
|
$invoice = $groupTransaction->transaction;
|
||||||
$this->info('FixGroupPaymentProblem group: '.json_encode($invoice));
|
$this->info('FixGroupPaymentProblem group: '.json_encode($invoice));
|
||||||
$pL = $invoice->owner;
|
//$paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null);
|
||||||
$this->releaseGoodsToCustomerProcessor->execute($pL, $invoice);
|
|
||||||
|
//if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){
|
||||||
|
$pL = $invoice->owner;
|
||||||
|
$this->releaseGoodsToCustomerProcessor->execute($pL, $invoice);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
// $group->status = $status;
|
||||||
*/
|
// $group->save();
|
||||||
|
|
||||||
$order = $this->fetchesOrder->execute(['reference' => '729251424']);
|
|
||||||
$packingLists = $order->destinationWarehousePackages;
|
|
||||||
|
|
||||||
foreach ($packingLists as $packingList){
|
|
||||||
$this->createStorageInvoiceDocTransactionProcessor->execute($packingList, true);
|
|
||||||
dd(json_encode($packingList));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -63,14 +63,7 @@ class FixInvoice extends Command
|
|||||||
|
|
||||||
$invoice->documents()->delete();
|
$invoice->documents()->delete();
|
||||||
|
|
||||||
$view = 'pages.pdfs.shipping_invoice';
|
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice]);
|
||||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
|
||||||
$shippingInvoiceTransactionCreatedDate = Carbon::parse($invoice->created_at);
|
|
||||||
if ($shippingInvoiceTransactionCreatedDate->isAfter($dateToCompare) && $invoice->tax > 0) {
|
|
||||||
$view = 'pages.pdfs.shipping_invoice_sst';
|
|
||||||
}
|
|
||||||
|
|
||||||
$transaction_invoice_pdf = LaravelMpdf::loadView($view, ['invoice_transaction' => $invoice]);
|
|
||||||
|
|
||||||
$document_object = new DocumentObject(
|
$document_object = new DocumentObject(
|
||||||
DocumentType::SHIPPING_INVOICE,
|
DocumentType::SHIPPING_INVOICE,
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzProcessor;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
|
|
||||||
class OneTimeTransactionFixBillplzFailedCallback extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'one-time-transaction-fix-billplz-failed-callback';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'This is a one time fix billplz failed callback for transaction with id 15205';
|
|
||||||
|
|
||||||
protected $output = null;
|
|
||||||
|
|
||||||
protected $outputArray = [];
|
|
||||||
|
|
||||||
/** @var CallbackBillplzProcessor */
|
|
||||||
private $callbackBillplzProcessor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct(CallbackBillplzProcessor $callbackBillplzProcessor)
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
$this->callbackBillplzProcessor = $callbackBillplzProcessor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
ini_set('memory_limit', '-1');
|
|
||||||
|
|
||||||
$this->outputArray = [];
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
//This transaction, 15205 has approve payment but not its owner, shipping invoice
|
|
||||||
$transaction = Transaction::whereIn('id', [15205])->first();
|
|
||||||
$this->info(Carbon::now() . ' : One time fix failled callback from billplz for transaction with id 15205 cron started.');
|
|
||||||
|
|
||||||
if($transaction && $transaction->id == 15205){
|
|
||||||
|
|
||||||
$status = ApprovalStatus::APPROVED;
|
|
||||||
$this->callbackBillplzProcessor->execute($transaction, $status);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
$this->info(Carbon::now() . ' : One time fix failled callback from billplz for transaction with id 15205 cron ended. ElapsedTime: ' . $elapsedTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use App\Classes\Notifications\PermitsReminderEmail;
|
|
||||||
use App\Models\PermitsReminder;
|
|
||||||
use App\Models\User;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class SendPermitsReminderEmails extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'permitsReminder:send';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Send Permits Reminders Email';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
$currentDateTime = now();
|
|
||||||
$startRange = $currentDateTime->subDays(3)->startOfDay();
|
|
||||||
$endRange = $currentDateTime->copy()->addDays(6)->endOfDay();
|
|
||||||
|
|
||||||
$reminders = PermitsReminder::whereDate('reminder_date', '>=', $startRange)
|
|
||||||
->whereDate('reminder_date', '<=', $endRange)
|
|
||||||
->orWhere('reminder_date', '<', now())
|
|
||||||
->pluck('model');
|
|
||||||
|
|
||||||
if ($reminders->isEmpty()) {
|
|
||||||
$this->info('No reminders expiring within the specified range.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->info($this->getTimeStamp() . 'Reminders: ' . $reminders->toJson());
|
|
||||||
|
|
||||||
$users = User::whereIn('email', $this->getEmailList())->get();
|
|
||||||
|
|
||||||
foreach ($users as $user) {
|
|
||||||
$this->info($this->getTimeStamp() . 'Reminder email sent to ' . $user->email);
|
|
||||||
if (app()->environment('production')) {
|
|
||||||
$user->notify(new PermitsReminderEmail($user, $reminders));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTimeStamp()
|
|
||||||
{
|
|
||||||
return '[' . Carbon::now()->format('Y-m-d H:i:s') . '] - ';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getEmailList(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'edmond.wuiming2021@gmail.com',
|
|
||||||
'anithagurl96@gmail.com'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -67,11 +67,6 @@ class Kernel extends ConsoleKernel
|
|||||||
->dailyAt('0:01')
|
->dailyAt('0:01')
|
||||||
->withoutOverlapping()
|
->withoutOverlapping()
|
||||||
->appendOutputTo(storage_path().'/logs/check_storage_invoices.log');
|
->appendOutputTo(storage_path().'/logs/check_storage_invoices.log');
|
||||||
|
|
||||||
$schedule->command('permitsReminder:send')
|
|
||||||
->dailyAt('09:30')
|
|
||||||
->withoutOverlapping()
|
|
||||||
->appendOutputTo(storage_path().'/logs/permits-reminder-send.log');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user