mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 679d53ab57 | |||
| d9377c0196 | |||
| e6fa771ecc | |||
| b2a22d2739 | |||
| 928430caec | |||
| 5d01757d60 | |||
| 4f704ef6a0 |
+1
-8
@@ -39,7 +39,7 @@ MAIL_FROM_NAME="${APP_NAME}"
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=shipping-portal-localhost
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
PUSHER_APP_ID=
|
||||
@@ -60,13 +60,6 @@ PERFEXCRM_BASE_URL=""
|
||||
PERFEXCRM_API_KEY=""
|
||||
PERFEXCRM_IS_ENABLED="false"
|
||||
|
||||
VAPOR_ENV=local
|
||||
LARAVEL_VAPOR_ENABLED=false
|
||||
COMMANDS_V2_ENABLED=false
|
||||
|
||||
STORAGE_FEE_LAUNCH_DATE="2023-12-11 00:00:00"
|
||||
SST_START_DATE="2024-04-01 00:00:00"
|
||||
|
||||
E_INVOICE_START_DATE="2025-07-01 00:00:00"
|
||||
MAINTENANCE_MESSAGE_TITLE="We'll be back online on 00:00 1/7/2025"
|
||||
MAINTENANCE_MESSAGE="Sorry for the inconvenience but we're performing some maintenance at the moment."
|
||||
|
||||
@@ -25,7 +25,3 @@ package-lock.json
|
||||
public/*
|
||||
/public/*
|
||||
storage/framework/laravel-excel/*
|
||||
.vapor/
|
||||
.env.production
|
||||
.env.staging
|
||||
.env.development
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Site Under Maintenance</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f4f4f4;
|
||||
text-align: center;
|
||||
padding: 50px;
|
||||
}
|
||||
.content {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
display: inline-block;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<h1>We'll be back soon!</h1>
|
||||
<p>Sorry for the inconvenience but we're performing some maintenance at the moment. We'll be back online shortly!</p>
|
||||
<p>— CIEF IZYIM</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Vendored
-131
@@ -1,131 +0,0 @@
|
||||
// Webhook + Gitlab git pull + Vapor
|
||||
|
||||
// def payload = readJSON text: "${payload}"
|
||||
// String userName = payload.user_name
|
||||
// String userEmail = payload.user_email
|
||||
// String httpUrl = payload.project.http_url
|
||||
|
||||
|
||||
pipeline {
|
||||
agent {
|
||||
docker {
|
||||
args '--group-add 992 -v /var/run/docker.sock:/var/run/docker.sock'
|
||||
image '303644228504.dkr.ecr.ap-southeast-1.amazonaws.com/jenkins-pipeline-agent:latest'
|
||||
registryCredentialsId "ecr:ap-southeast-1:aws-ec2-instance-iam-role"
|
||||
registryUrl "https://303644228504.dkr.ecr.ap-southeast-1.amazonaws.com"
|
||||
}
|
||||
}
|
||||
environment {
|
||||
HOME = '.'
|
||||
DB_CONNECTION = 'mysql'
|
||||
DB_DATABASE = 'portal_development'
|
||||
APP_ENV = 'testing'
|
||||
}
|
||||
stages {
|
||||
stage('Download source code from Git') {
|
||||
steps {
|
||||
script{
|
||||
currentBuild.description = 'Step 1 of 6 Completed'
|
||||
println("GIT GIT_BRANCH: " + GIT_BRANCH)
|
||||
switch(GIT_BRANCH) {
|
||||
case "vapor/production":
|
||||
case "vapor/staging":
|
||||
case "vapor/development":
|
||||
git(
|
||||
url: 'https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git',
|
||||
credentialsId: 'gitlab-jenkins-localhost',
|
||||
branch: GIT_BRANCH
|
||||
)
|
||||
break
|
||||
case "origin/dillon/34-jenkins-vapor":
|
||||
git(
|
||||
url: 'https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git',
|
||||
credentialsId: 'gitlab-jenkins-localhost',
|
||||
branch: 'dillon/34-jenkins-vapor'
|
||||
)
|
||||
break
|
||||
}
|
||||
currentBuild.description = 'Step 2 of 6 Completed'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Install') {
|
||||
steps {
|
||||
sh 'composer update'
|
||||
script{
|
||||
currentBuild.description = 'Step 3 of 6 Completed'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Tests') {
|
||||
steps {
|
||||
//sh 'vendor/bin/phpunit tests/Unit'
|
||||
withCredentials([
|
||||
usernamePassword(
|
||||
credentialsId: 'shipping-portal-dev-db-credential',
|
||||
usernameVariable: 'DB_USERNAME',
|
||||
passwordVariable: 'DB_PASSWORD'
|
||||
),
|
||||
string(credentialsId: 'shipping-portal-dev-db-host', variable: 'DB_HOST')
|
||||
]) {
|
||||
// sh 'vendor/bin/phpunit --filter ListOrderTrackingLogicTest'
|
||||
}
|
||||
script{
|
||||
currentBuild.description = 'Step 4 of 6 Completed'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
script{
|
||||
String gitCommitMessage = getCommitMessage()
|
||||
println("GIT CommitMessage: " + gitCommitMessage)
|
||||
println("GIT GIT_BRANCH: " + GIT_BRANCH)
|
||||
switch(GIT_BRANCH) {
|
||||
case "vapor/production":
|
||||
sh "vendor/bin/vapor deploy production --message='${gitCommitMessage}'"
|
||||
break
|
||||
case "vapor/staging":
|
||||
sh "vendor/bin/vapor deploy staging --message='${gitCommitMessage}'"
|
||||
break
|
||||
case "vapor/development":
|
||||
sh "vendor/bin/vapor deploy development --message='${gitCommitMessage}'"
|
||||
break
|
||||
case "origin/dillon/34-jenkins-vapor":
|
||||
sh "vendor/bin/vapor deploy development --message='${gitCommitMessage}'"
|
||||
break
|
||||
}
|
||||
currentBuild.description = 'Step 5 of 6 Completed'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Cleanup') {
|
||||
steps {
|
||||
script {
|
||||
try {
|
||||
sh 'docker image prune -a -f'
|
||||
} catch (Exception e) {
|
||||
echo "Error during cleanup: ${e.message}"
|
||||
}
|
||||
currentBuild.description = 'Step 6 of 6 Completed'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NonCPS
|
||||
String getCommitMessage(){
|
||||
commitMessage = " "
|
||||
for ( changeLogSet in currentBuild.changeSets){
|
||||
for (entry in changeLogSet.getItems()){
|
||||
commitMessage = entry.msg
|
||||
}
|
||||
}
|
||||
commitMessage = commitMessage.replace("'", "`")
|
||||
return commitMessage
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Exceptions;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
|
||||
final class CriteriaNotFulfilledException extends ServiceApiException {
|
||||
public function __construct(?string $message = null) {
|
||||
parent::__construct(
|
||||
$message ?? 'One or more required criteria were not fulfilled.',
|
||||
HttpStatus::VALIDATION_FAILED
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
namespace App\Classes\General;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Carbon\Carbon;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
|
||||
class AWSS3Helper
|
||||
{
|
||||
/**
|
||||
* @param string $exportFileName
|
||||
* @param Exportable $exportableObject
|
||||
* @return string
|
||||
*/
|
||||
static function S3Exportable($exportFileName, $exportableObject){
|
||||
//Step 1: Upload to S3
|
||||
$filePathForS3 = 'temp/' . $exportFileName;
|
||||
$exportableObject->store($filePathForS3, 's3');
|
||||
|
||||
//Step 2: Return temporary URL from S3
|
||||
$temporaryUrl = Storage::disk('s3')->temporaryUrl(
|
||||
$filePathForS3,
|
||||
Carbon::now()->addMinutes(10)
|
||||
);
|
||||
|
||||
return $temporaryUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $exportFileName
|
||||
* @param string|resource $contents
|
||||
* @return string
|
||||
*/
|
||||
static function S3PDF($exportFileName, $contents){
|
||||
//Step 1: Upload to S3
|
||||
$filePathForS3 = 'temp/' . $exportFileName;
|
||||
Storage::disk('s3')->put($filePathForS3, $contents);
|
||||
|
||||
//Step 2: Return temporary URL from S3
|
||||
$temporaryUrl = Storage::disk('s3')->temporaryUrl(
|
||||
$filePathForS3,
|
||||
Carbon::now()->addMinutes(10)
|
||||
);
|
||||
|
||||
return $temporaryUrl;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,7 +16,6 @@ use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Classes\Exceptions\JobResourceNotFoundException;
|
||||
use App\Classes\General\LogHelper;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
abstract class AbstractControllerLogic
|
||||
@@ -66,7 +65,7 @@ abstract class AbstractControllerLogic
|
||||
|
||||
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
||||
if ($exception instanceof JobResourceNotFoundException) {
|
||||
LogHelper::channel('vue_polling')->info(sprintf(
|
||||
Log::channel('vue_polling')->info(sprintf(
|
||||
"Uncaught exception '%s' with message '%s' in %s:%d",
|
||||
get_class($exception),
|
||||
$exception->getMessage(),
|
||||
|
||||
@@ -17,4 +17,4 @@ class HasInvoiceStatusIn implements Filter
|
||||
$query->where('type', 1)->whereIn('status', $value);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class MarkingIn implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('companyModules', function ($module) use ($value) {
|
||||
$module->whereHas('connections', function ($connection) use ($value) {
|
||||
$connection->whereIn('invitee_reference', $value);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class OrderTrackingId implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('order_tracking_id', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,6 @@ class PackingListLimitOneByTypeOrderedByInvoiceDate implements Filter
|
||||
$join->on('transactions.owner_id', '=', 'packing_lists.id');
|
||||
$join->where('transactions.owner_type', '=', PackingList::class);
|
||||
$join->where('transactions.status', '=', ApprovalStatus::APPROVED);
|
||||
$join->whereNull('transactions.deleted_at');
|
||||
$join->whereRaw('(transactions.type <> 16 OR transactions.id = (
|
||||
SELECT id FROM transactions WHERE owner_id = packing_lists.id AND type = 16 LIMIT 1
|
||||
))');
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class TrackingNo implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('tracking_no', $value)
|
||||
->where(function ($query) {
|
||||
$query->whereNotNull('tracking_english')
|
||||
->orWhereNotNull('remark_english');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class TypeNotIn implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereNotIn('type', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,8 +3,6 @@ namespace App\Classes\General;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ExcelHandel
|
||||
{
|
||||
@@ -69,23 +67,9 @@ class ExcelHandel
|
||||
public static function generateExcel($path = '', $exceldata = '', $filename = '', $extension = '')
|
||||
{
|
||||
$file_info = [];
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
$filePathForS3 = 'public/excels/' . $path . '/' . $filename . '.' . $extension;
|
||||
Storage::disk('s3')->put($filePathForS3, $exceldata);
|
||||
|
||||
$temporaryUrl = Storage::disk('s3')->temporaryUrl(
|
||||
$filePathForS3,
|
||||
Carbon::now()->addMinutes(10)
|
||||
);
|
||||
|
||||
$file_info['original']['file'] = $temporaryUrl; //REMINDER: This is a path to AWS S3 URL (HTTPS) as a public anonymous user, NOT an internal system path
|
||||
}
|
||||
else{
|
||||
$file = Storage::disk('public')->put('excels/' . $path . '/' . $filename . '.' . $extension, $exceldata);
|
||||
$file_info['original']['file'] = storage_path('app/public/excels/' . $path . '/' . $filename . '.' . $extension);
|
||||
}
|
||||
|
||||
$file = \Storage::disk('public')->put('excels/' . $path . '/' . $filename . '.' . $extension, $exceldata);
|
||||
$file_info['original']['file'] = storage_path('app/public/excels/' . $path . '/' . $filename . '.' . $extension);
|
||||
|
||||
return $file_info;
|
||||
}
|
||||
|
||||
@@ -100,4 +84,4 @@ class ExcelHandel
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -49,12 +49,4 @@ class Helper
|
||||
static function collectionResponse(ResourceCollection $collection){
|
||||
return json_decode($collection->response()->getContent(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|string $json
|
||||
* @return array
|
||||
*/
|
||||
static function deserializeFilters(?string $json): array {
|
||||
return $json !== null ? collect(json_decode($json))->toArray() : [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LogHelper
|
||||
{
|
||||
private String $channelName;
|
||||
|
||||
public static function channel($channelName): self
|
||||
{
|
||||
$logHelper = new self;
|
||||
$logHelper->channelName = $channelName;
|
||||
return $logHelper;
|
||||
}
|
||||
|
||||
public function info($message)
|
||||
{
|
||||
$envVar = env('LARAVEL_VAPOR_ENABLED');
|
||||
$isLocal = env('VAPOR_ENV') === 'local';
|
||||
if($envVar)
|
||||
{
|
||||
Log::info("Info: {$message}, channelName: {$this->channelName}, envVar {$envVar}");
|
||||
}
|
||||
|
||||
if ($envVar && !$isLocal) {
|
||||
Log::channel($this->channelName.'_vapor')->info($message);
|
||||
}
|
||||
else{
|
||||
Log::channel($this->channelName)->info($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function warning($message)
|
||||
{
|
||||
$envVar = env('LARAVEL_VAPOR_ENABLED');
|
||||
$isLocal = env('VAPOR_ENV') === 'local';
|
||||
if($envVar)
|
||||
{
|
||||
Log::info("Warning: {$message}, channelName: {$this->channelName}, envVar {$envVar}");
|
||||
}
|
||||
|
||||
if ($envVar && !$isLocal) {
|
||||
Log::channel($this->channelName . '_vapor')->warning($message);
|
||||
} else {
|
||||
Log::channel($this->channelName)->warning($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function error($message)
|
||||
{
|
||||
$envVar = env('LARAVEL_VAPOR_ENABLED');
|
||||
$isLocal = env('VAPOR_ENV') === 'local';
|
||||
if($envVar)
|
||||
{
|
||||
Log::info("Error: {$message}, channelName: {$this->channelName}, envVar {$envVar}");
|
||||
}
|
||||
|
||||
if ($envVar && !$isLocal) {
|
||||
Log::channel($this->channelName . '_vapor')->error($message);
|
||||
} else {
|
||||
Log::channel($this->channelName)->error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UrlHelper {
|
||||
public static function getRouteParametersFromUrl($url) {
|
||||
$parsedUrl = parse_url($url);
|
||||
$path = $parsedUrl['path'];
|
||||
|
||||
$routes = Route::getRoutes();
|
||||
|
||||
foreach ($routes as $route) {
|
||||
$request = Request::create($path, 'GET');
|
||||
$route->bind($request);
|
||||
if ($route->matches($request)) {
|
||||
return $route->parameters();
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\Modules\Transactions\Processors\ApproveShippingInvoiceTransactionProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use Exception;
|
||||
|
||||
class ApproveInvoiceV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Approve Invoice Command.');
|
||||
$start = new Carbon();
|
||||
|
||||
$invoices = Transaction::where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::PENDING_SUBMISSION)->get();
|
||||
|
||||
foreach ($invoices as $invoice) {
|
||||
$packingList = $invoice->owner;
|
||||
$order = $packingList->owner;
|
||||
|
||||
try {
|
||||
(App()->make(ApproveShippingInvoiceTransactionProcessor::class))->execute($packingList);
|
||||
Log::info('Invoice Approved for reference ' . $order->reference . '.');
|
||||
} catch (Exception $exception) {
|
||||
Log::info('Failed to Approve invoice for reference ' . $order->reference . '. Exception: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Approve Invoice Command. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
class AuditBillplzInvoiceV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Audit Billplz Invoice.');
|
||||
$start = new Carbon();
|
||||
|
||||
// ini_set('memory_limit', '-1');
|
||||
|
||||
$transactions = Transaction::where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::COMPLETED)->whereHas('transactions', function($query){
|
||||
return $query->where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->where('status', ApprovalStatus::REJECTED);
|
||||
})->get();
|
||||
|
||||
$totalTransactions = count($transactions);
|
||||
$counter = 1;
|
||||
$totalAmount = 0;
|
||||
foreach ($transactions as $transaction){
|
||||
$payment_transaction = $transaction->transactions->sortByDesc('created_at')->first();
|
||||
|
||||
if ($payment_transaction->status === ApprovalStatus::REJECTED) {
|
||||
Log::info($counter . ' of ' . $totalTransactions . '. Order Marking: '. $payment_transaction->owner->owner->owner->reference . '. Transaction Id: '. $payment_transaction->id . '. Invoice Id: '. $transaction->id . ' - Date: '.$payment_transaction->created_at->format('d-m-Y').' - Amount: '. $payment_transaction->amount);
|
||||
|
||||
$totalAmount += $transaction->amount;
|
||||
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Audit Billplz Invoice. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class AuditBillplzPaymentV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Audit Billplz Payment.');
|
||||
$start = new Carbon();
|
||||
|
||||
// ini_set('memory_limit', '-1');
|
||||
|
||||
$transactions = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::APPROVED])->get();
|
||||
$totalTransactions = count($transactions);
|
||||
$counter = 1;
|
||||
$totalAmount = 0;
|
||||
foreach ($transactions as $transaction){
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
if($data['paid']){
|
||||
|
||||
} else {
|
||||
$totalAmount += $transaction->amount;
|
||||
Log::info($counter . ' of ' . $totalTransactions . '. Order: '. $transaction->owner->owner->owner->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount);
|
||||
}
|
||||
}else{
|
||||
Log::info("billplz error</br>");
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Audit Billplz Payment. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
||||
use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Order;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class AutoGenerateInvoiceV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Auto generate invoice.');
|
||||
$start = new Carbon();
|
||||
|
||||
$packingLists = (App()->make(ListsPackingLists::class))->execute(['does_not_have_transaction_type' => 1, 'type' => 2]);
|
||||
|
||||
if (count($packingLists)) {
|
||||
|
||||
foreach ($packingLists as $packingList) {
|
||||
$order = $packingList->owner;
|
||||
if (!($order instanceof Order)) {
|
||||
Log::info('Failed to generate invoice for reference' . $order->reference . '. It is not an instance of Order.');
|
||||
continue;
|
||||
}
|
||||
|
||||
$companyModule = $order->companyModule;
|
||||
$billingAddress = $companyModule->addresses()->where('type', \App\Classes\ValueObjects\Constants\AddressType::BILLING)->first();
|
||||
$deliveryAddress = $order->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
||||
|
||||
$postCodes = \App\Models\SegmentConstant::whereIn('reference', ['CENTER_POSTCODE', 'OUTSTATION_POSTCODE'])->get()->pluck('value')->flatten();
|
||||
|
||||
if (!!$billingAddress && in_array($deliveryAddress->postcode, $postCodes->toArray())) {
|
||||
try {
|
||||
(App()->make(CreateInvoiceTransactionProcessor::class))->execute($packingList);
|
||||
Log::info('Invoice generated for reference ' . $order->reference . '.');
|
||||
} catch (Exception $exception) {
|
||||
Log::info('Failed to generate invoice for reference ' . $order->reference . '. Exception: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
else{
|
||||
Log::info('Failed to generate invoice for reference ' . $order->reference . '. Billing Address is not defined / Postcode area is not defined.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Auto generate invoice. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CheckDeletedInvoiceButPaidV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Check all deleted invoice but has completed payment.');
|
||||
$start = new Carbon();
|
||||
|
||||
// ini_set('memory_limit', '-1');
|
||||
|
||||
$totalAmount = 0;
|
||||
|
||||
$softDeletedTransactions = Transaction::onlyTrashed()->where('type', TransactionType::SHIPPING_INVOICE)->whereHas('transactions', function (Builder $query) {
|
||||
$query->where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY);
|
||||
})->get();
|
||||
|
||||
foreach ($softDeletedTransactions as $invoice) {
|
||||
$invoice_payments = $invoice->transactions()->payments()->get();
|
||||
|
||||
foreach($invoice_payments as $invoice_payment) {
|
||||
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$invoice_payment->payment_reference);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
$orderReference = $invoice->owner->owner->reference ?? null;
|
||||
|
||||
if($data['paid']){
|
||||
Log::info('Invoice id: ' . $invoice->id. '. Payment id: ' . $invoice_payment->id . '. Order: ' . $orderReference);
|
||||
} else {
|
||||
|
||||
}
|
||||
}else{
|
||||
Log::info("billplz error</br>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Check all deleted invoice but has completed payment. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\Transactions\Services\ListsGroups;
|
||||
use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CheckStorageInvoicesGroupTransactionsV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Check all pending group payment with storage invoice is valid.');
|
||||
$start = new Carbon();
|
||||
|
||||
|
||||
$newfilters['order_by_updated_at_desc'] = true;
|
||||
$newfilters['status_in'] = [0, 1];
|
||||
$groups = (App()->make(ListsGroups::class))->execute($newfilters);
|
||||
|
||||
foreach ($groups as $group){
|
||||
Log::info('CheckForStorageInvoiceByTransactions group: '.json_encode($group));
|
||||
foreach ($group->groupTransactions as $groupTransaction) {
|
||||
$invoice = $groupTransaction->transaction;
|
||||
$packingList = $invoice->owner()->first();
|
||||
if($packingList){
|
||||
$order = $packingList->owner()->first();
|
||||
if($order instanceof Order){
|
||||
$storages = (App()->make(CheckStorageInvoiceTransactionProcessor::class))->executeOrder($order);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Check all pending group payment with storage invoice is valid. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\Orders\Services\ListsOrders;
|
||||
use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor;
|
||||
use App\Classes\ValueObjects\Constants\OrderType;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CheckStorageInvoicesOrdersV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Check all orders for storage invoice.');
|
||||
$start = new Carbon();
|
||||
|
||||
$orders = (App()->make(ListsOrders::class))->execute(['with_parcels' => true, 'type_in' => [OrderType::SHARED_CONTAINER, OrderType::DEDICATED_CONTAINER]]);
|
||||
|
||||
$count = 0;
|
||||
foreach ($orders as $order){
|
||||
try{
|
||||
$storages = (App()->make(CheckStorageInvoiceTransactionProcessor::class))->executeOrder($order);
|
||||
$count = $count + 1;
|
||||
Log::info('Order '.$count);
|
||||
}
|
||||
catch(\Exception $ex){
|
||||
Log::info('Exception '.$ex->getMessage());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Check all orders for storage invoice. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class DummyJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Dummy.');
|
||||
$start = new Carbon();
|
||||
|
||||
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Dummy. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Group;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FixApprovedPaymentFailedGroupV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Fix all payment is approved or completed but group failed to be updated.');
|
||||
$start = new Carbon();
|
||||
|
||||
// ini_set('memory_limit', '-1');
|
||||
|
||||
// $this->outputArray = [];
|
||||
|
||||
$groups = Group::whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
|
||||
->whereHas('payment', function ($query) {
|
||||
$query->whereIn('status', [2, 3]);
|
||||
})->get();
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$transaction = $group->payment;
|
||||
|
||||
$response = Http::withBasicAuth(config('billplz.api_key') . ':', '')->get(config('billplz.base_url') . '/api/v3/bills/' . $transaction->payment_reference);
|
||||
|
||||
dump($transaction->payment_reference);
|
||||
|
||||
if ($response->successful()) {
|
||||
$data = $response->json();
|
||||
if ($data['paid']) {
|
||||
$status = ApprovalStatus::PENDING_VERIFICATION;
|
||||
|
||||
if ($data['state'] === 'paid') {
|
||||
$status = ApprovalStatus::APPROVED;
|
||||
}
|
||||
|
||||
Log::info(Carbon::now() . ' : Fixing ' . $transaction->payment_reference);
|
||||
(App()->make(CallbackBillplzProcessor::class))->execute($transaction, $status);
|
||||
}
|
||||
} else {
|
||||
Log::info("billplz error");
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
// if ($groups) {
|
||||
// $this->info(Carbon::now() . ' : Done . ElapsedTime: ' . $elapsedTime);
|
||||
// }
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Fix all payment is approved or completed but group failed to be updated. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzProcessor;
|
||||
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FixBillplzFailedCallbackPaymentV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $transactionId;
|
||||
|
||||
public function __construct(int $transactionId)
|
||||
{
|
||||
$this->transactionId = $transactionId;
|
||||
}
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Fix failled callback from billplz.');
|
||||
$start = new Carbon();
|
||||
|
||||
$transaction = Transaction::where('id', $this->transactionId)->first();
|
||||
|
||||
Log::info('Billplz Url: '.config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference);
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
if($data['paid']) {
|
||||
$status = ApprovalStatus::PENDING_VERIFICATION;
|
||||
|
||||
if($data['state'] === 'paid') {
|
||||
$status = ApprovalStatus::APPROVED;
|
||||
}
|
||||
|
||||
Log::info(Carbon::now() . ' : Fixing ' . $transaction->payment_reference);
|
||||
(App()->make(CallbackBillplzProcessor::class))->execute($transaction, $status);
|
||||
}
|
||||
}
|
||||
else{
|
||||
Log::info("billplz error");
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Fix failled callback from billplz. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Models\Container;
|
||||
use App\Models\ContainerPackingList;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FixDuplicateContainerReferenceV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Fix Duplicate Container Reference.');
|
||||
$start = new Carbon();
|
||||
|
||||
// ini_set('memory_limit', '-1');
|
||||
|
||||
|
||||
$duplicatedContainers = Container::select('reference', DB::raw('COUNT(reference) as count'))
|
||||
->groupBy('reference')
|
||||
->having('count', '>', 1)
|
||||
->get();
|
||||
|
||||
foreach ($duplicatedContainers as $duplicatedContainer) {
|
||||
$containers = Container::where('reference', $duplicatedContainer->reference)->get();
|
||||
|
||||
$containers = $containers->sortByDesc(function ($container) {
|
||||
return $container->packingLists->count();
|
||||
});
|
||||
|
||||
$firstContainer = $containers->shift();
|
||||
|
||||
foreach ($containers as $container) {
|
||||
$firstContainer->packingLists()->syncWithoutDetaching($container->packingLists);
|
||||
$container->packingLists()->detach();
|
||||
Log::info('Deleted container ' . $container->id);
|
||||
$container->delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Fix Duplicate Container Reference. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\Transactions\Processors\CreateStorageInvoiceDocTransactionFixProcessor;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FixGroupPaymentProblemV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Fix Group Payment Problem.');
|
||||
$start = new Carbon();
|
||||
|
||||
// ini_set('memory_limit', '-1');
|
||||
|
||||
/*
|
||||
$group = $this->fetchesGroup->execute(['id' => 325]);
|
||||
$this->info('FixGroupPaymentProblem group: '.json_encode($group));
|
||||
if ($group) {
|
||||
foreach ($group->groupTransactions as $groupTransaction) {
|
||||
$invoice = $groupTransaction->transaction;
|
||||
$this->info('FixGroupPaymentProblem group: '.json_encode($invoice));
|
||||
$pL = $invoice->owner;
|
||||
$this->releaseGoodsToCustomerProcessor->execute($pL, $invoice);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
$order = (App()->make(FetchesOrder::class))->execute(['reference' => '729251424']);
|
||||
$packingLists = $order->destinationWarehousePackages;
|
||||
|
||||
foreach ($packingLists as $packingList){
|
||||
(App()->make(CreateStorageInvoiceDocTransactionFixProcessor::class))->execute($packingList, true);
|
||||
dd(json_encode($packingList));
|
||||
}
|
||||
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Fix Group Payment Problem. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\Modules\Jobs\DataTransferObjects\FixInvoiceV2CommandObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\CompanyConnection;
|
||||
use App\Models\Order;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FixInvoiceV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var FixInvoiceV2CommandObject*/
|
||||
private $fixInvoiceV2CommandObject;
|
||||
|
||||
/**
|
||||
* FixInvoiceV2CommandJob constructor.
|
||||
* @param FixInvoiceV2CommandObject $fixInvoiceV2CommandObject
|
||||
*/
|
||||
public function __construct(FixInvoiceV2CommandObject $fixInvoiceV2CommandObject)
|
||||
{
|
||||
$this->fixInvoiceV2CommandObject = $fixInvoiceV2CommandObject;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Fix invoice.');
|
||||
$start = new Carbon();
|
||||
|
||||
$connection = CompanyConnection::where('invitee_reference', $this->fixInvoiceV2CommandObject->getMarking())->first();
|
||||
$company_module_id = $connection->invitee->id;
|
||||
|
||||
$orders = Order::where('company_module_id', $company_module_id)->get();
|
||||
|
||||
foreach ($orders as $order){
|
||||
$invoices = $order->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->get();
|
||||
foreach ($invoices as $invoice){
|
||||
|
||||
dump($invoice->id);
|
||||
|
||||
$invoice->documents()->delete();
|
||||
|
||||
$view = 'pages.pdfs.shipping_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(
|
||||
DocumentType::SHIPPING_INVOICE,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'shipping_invoice'
|
||||
);
|
||||
|
||||
/** @var Document $document */
|
||||
$document = (App()->make(CreatesDocument::class))->execute($invoice, $document_object);
|
||||
|
||||
(App()->make(CreatesFiles::class))->execute($document, $document_object);
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Fix invoice. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchPackingListsFromYdPortalProcessor;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FixMissingPackingListV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Fix Missing PackingList.');
|
||||
$start = new Carbon();
|
||||
|
||||
$start_date = '2024-05-05';
|
||||
$end_date = '2024-05-05';
|
||||
|
||||
$start = $start_date ? Carbon::parse($start_date) : null;
|
||||
$end = $end_date ? Carbon::parse($end_date) : null;
|
||||
|
||||
if (!$start || !$end) {
|
||||
return;
|
||||
}
|
||||
|
||||
(App()->make(FetchPackingListsFromYdPortalProcessor::class))->execute($start, $end);
|
||||
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Fix Missing PackingList. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Models\PackingList;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FixPackingListV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Fix PackingList.');
|
||||
$start = new Carbon();
|
||||
|
||||
$packingLists = PackingList::whereDoesntHave('packages')->get();
|
||||
|
||||
if ($packingLists->isNotEmpty()) {
|
||||
|
||||
$restoredPackagesCount = 0;
|
||||
$restoredPackagesIds = [];
|
||||
|
||||
// Eager loading packages for all packing lists
|
||||
$packingLists->load(['packages' => function ($query) {
|
||||
$query->onlyTrashed();
|
||||
}]);
|
||||
|
||||
foreach ($packingLists as $packingList) {
|
||||
$deletedPackages = $packingList->packages->filter(function ($package) use ($restoredPackagesIds) {
|
||||
// Filter out packages that have already been restored
|
||||
return !in_array($package->id, $restoredPackagesIds);
|
||||
});
|
||||
|
||||
if ($deletedPackages->isNotEmpty()) {
|
||||
$groupedPackages = $deletedPackages->groupBy(function ($item) {
|
||||
return $item->only(['type', 'description', 'width', 'height', 'length', 'weight', 'quantity']);
|
||||
});
|
||||
|
||||
foreach ($groupedPackages as $group) {
|
||||
$latestPackage = $group->sortByDesc('created_at')->first();
|
||||
|
||||
// Check if the package ID is already restored before attempting to restore it
|
||||
if (!in_array($latestPackage->id, $restoredPackagesIds)) {
|
||||
$latestPackage->restore();
|
||||
Log::info('Package ID: ' . $latestPackage->id . ' has been restored');
|
||||
$restoredPackagesCount++;
|
||||
$restoredPackagesIds[] = $latestPackage->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log::info('Restored Packages Count: ' . $restoredPackagesCount);
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Fix PackingList. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzProcessor;
|
||||
use App\Classes\Modules\Documents\Services\ApprovesDocument;
|
||||
use App\Classes\Modules\Documents\Services\RejectsDocument;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Group;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FixPaymentApprovalTimedOutErrorV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Fix payment approval timed out error (status 504: Endpoint request timed out).');
|
||||
$start = new Carbon();
|
||||
|
||||
$status= 'approve';
|
||||
$transactionId = 23160;
|
||||
|
||||
$transaction = (App()->make(FetchesTransaction::class))->execute(['id' => $transactionId]);
|
||||
$document = $transaction->documents()
|
||||
->where('status', ApprovalStatus::PENDING_VERIFICATION)
|
||||
->first();
|
||||
|
||||
Log::info("FixApprovedPaymentFailedGroupV2CommandJob document: ".json_encode($document));
|
||||
|
||||
if($status === 'approve') {
|
||||
// (App()->make(ApprovesDocument::class))->execute($document);
|
||||
$document->status = ApprovalStatus::APPROVED;
|
||||
// $document->approver = Auth()->user()->id;
|
||||
$document->approval_date = Carbon::now();
|
||||
$document->save();
|
||||
}
|
||||
else {
|
||||
(App()->make(RejectsDocument::class))->execute($document);
|
||||
}
|
||||
|
||||
(App()->make(UpdatesTransactionStatus::class))->execute($transaction, $status === 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
|
||||
if ($status === 'approve') {
|
||||
(App()->make(CallbackBillplzProcessor::class))->execute($transaction, ApprovalStatus::APPROVED);
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Fix payment approval timed out error (status 504: Endpoint request timed out). ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class HouseKeepingS3FilesV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Housekeeping temporary files in S3 Bucket.');
|
||||
$start = new Carbon();
|
||||
|
||||
$s3 = Storage::disk('s3');
|
||||
$directories = [
|
||||
'temp',
|
||||
];
|
||||
foreach ($directories as $directory) {
|
||||
$startInner = Carbon::now();
|
||||
Log::info(Carbon::now() . ' [HouseKeepingS3FilesV2] Start cleaning - ' . $directory);
|
||||
|
||||
$objects = $s3->allFiles($directory);
|
||||
|
||||
foreach ($objects as $object) {
|
||||
$s3->delete($object);
|
||||
Log::info('[HouseKeepingS3FilesV2] Deleted object: ' . $object);
|
||||
}
|
||||
|
||||
Log::info('[HouseKeepingS3FilesV2] All files have been deleted.');
|
||||
|
||||
$endInner = Carbon::now();
|
||||
$elapsedTime = $startInner->diff($endInner)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ' [HouseKeepingS3FilesV2] Process ended. ElapsedTime: ' . $elapsedTime);
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Housekeeping temporary files in S3 Bucket. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use App\Classes\Modules\Accounts\Services\ExpiresEmailVerificationAttempt;
|
||||
use App\Models\UserEmailVerification;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class NewUserRegistrationExpireCheckV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - New user email verification expiration check.');
|
||||
$start = new Carbon();
|
||||
|
||||
$attempts = UserEmailVerification::active()->twoDaysOld()->get();
|
||||
|
||||
Log::info('NewUser Carbon now()->subHours(48): '. Carbon::now()->subHours(48));
|
||||
Log::info('NewUser Attempts count: '.count($attempts));
|
||||
|
||||
foreach ($attempts as $attempt){
|
||||
(new ExpiresEmailVerificationAttempt())->execute($attempt);
|
||||
Log::info('NewUser Expired: '.$attempt->id.', '.$attempt->created_at);
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - New user email verification expiration check. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzProcessor;
|
||||
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzDataPatchProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class OneTimeTransactionFixBillplzFailedCbV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - One time fix failled callback from billplz cron ended.');
|
||||
$start = new Carbon();
|
||||
|
||||
//Transaction fix with this one time fix command: 15205, 16803, 17310, 22008, 6770
|
||||
//This transaction, 16803 has approve payment but not its owner, shipping invoice
|
||||
$transactions = Transaction::whereIn('id', [22008, 6770])->get();
|
||||
Log::info(Carbon::now() . ' : One time fix failled callback from billplz started.');
|
||||
|
||||
foreach ($transactions as $transaction){
|
||||
if($transaction){
|
||||
|
||||
Log::info(Carbon::now() . ' : '.$transaction->id);
|
||||
$status = ApprovalStatus::APPROVED;
|
||||
(App()->make(CallbackBillplzProcessor::class))->execute($transaction, $status);
|
||||
// (App()->make(CallbackBillplzDataPatchProcessor::class))->execute($transaction, $status);
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - One time fix failled callback from billplz cron ended. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use App\Classes\Modules\Accounts\Services\ExpiresPasswordReset;
|
||||
use App\Models\PasswordReset;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class PasswordResetTokenExpirationV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Password reset token expiration check.');
|
||||
$start = new Carbon();
|
||||
|
||||
$attempts = PasswordReset::active()->oneDayOld()->get();
|
||||
|
||||
Log::info('PasswordReset Carbon now()->subHours(24): '. Carbon::now()->subHours(24));
|
||||
Log::info('PasswordReset Attempts count: '.count($attempts));
|
||||
|
||||
foreach ($attempts as $attempt){
|
||||
(new ExpiresPasswordReset())->execute($attempt);
|
||||
Log::info('PasswordReset Expired: '.$attempt->id.', '.$attempt->created_at);
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Password reset token expiration check. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Notifications\ShipmentDepartureEmail;
|
||||
use App\Models\Order;
|
||||
use App\Models\Container;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SendContainerDepartureEmailV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Send Container Departure Email.');
|
||||
$start = new Carbon();
|
||||
|
||||
$containers = Container::whereHas('transports', function ($transport){
|
||||
return $transport->whereDate('dispatch_date', '=', Carbon::today());
|
||||
})->get();
|
||||
|
||||
foreach ($containers as $container){
|
||||
foreach ($container->packingLists as $packingList){
|
||||
if(!($packingList->owner instanceof Order)) continue;
|
||||
$user = $packingList->owner->companyModule->employees()->first();
|
||||
if(app()->environment(['production'])) {
|
||||
$user->notify(new ShipmentDepartureEmail($user, $packingList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Send Container Departure Email. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Notifications\PermitsReminderEmail;
|
||||
use App\Models\PermitsReminder;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SendPermitsReminderEmailsV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Send Permits Reminders Email.');
|
||||
$start = new Carbon();
|
||||
|
||||
$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()) {
|
||||
Log::info('No reminders expiring within the specified range.');
|
||||
return;
|
||||
}
|
||||
|
||||
Log::info($this->getTimeStamp() . 'Reminders: ' . $reminders->toJson());
|
||||
|
||||
$users = User::whereIn('email', $this->getEmailList())->get();
|
||||
|
||||
foreach ($users as $user) {
|
||||
Log::info($this->getTimeStamp() . 'Reminder email sent to ' . $user->email);
|
||||
if (app()->environment('production')) {
|
||||
$user->notify(new PermitsReminderEmail($user, $reminders));
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Send Permits Reminders Email. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
|
||||
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'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use App\Classes\Modules\Jobs\DataTransferObjects\ShowBillplzPaymentStatusV2CommandObject;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ShowBillplzPaymentStatusV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
/** @var ShowBillplzPaymentStatusV2CommandObject*/
|
||||
private $showBillplzPaymentStatusV2CommandObject;
|
||||
|
||||
/**
|
||||
* ShowBillplzPaymentStatusV2CommandJob constructor.
|
||||
* @param ShowBillplzPaymentStatusV2CommandObject $showBillplzPaymentStatusV2CommandObject
|
||||
*/
|
||||
public function __construct(ShowBillplzPaymentStatusV2CommandObject $showBillplzPaymentStatusV2CommandObject)
|
||||
{
|
||||
$this->showBillplzPaymentStatusV2CommandObject = $showBillplzPaymentStatusV2CommandObject;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Show Billplz payment status.');
|
||||
$start = new Carbon();
|
||||
|
||||
// ini_set('memory_limit', '-1');
|
||||
|
||||
$billplz_id = $this->showBillplzPaymentStatusV2CommandObject->getBillplzId();
|
||||
$billplz_id = explode(",", $billplz_id);
|
||||
|
||||
foreach ($billplz_id as $payment) {
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$payment);
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
dump($data);
|
||||
}else{
|
||||
Log::info("billplz error</br>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Show Billplz payment status. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ShowFailediBllplzCallbackV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Show all failled callback from billplz.');
|
||||
$start = new Carbon();
|
||||
|
||||
// ini_set('memory_limit', '-1');
|
||||
|
||||
$transactions = Transaction::whereIn('type', [TransactionType::PAYMENT, TransactionType::TOP_UP, TransactionType::GROUP_PAYMENT])->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
|
||||
$totalTransactions = count($transactions);
|
||||
|
||||
if ($totalTransactions) {
|
||||
Log::info(Carbon::now() . ' totalTransactions : ' . $totalTransactions);
|
||||
}
|
||||
|
||||
$counter = 1;
|
||||
$totalAmount = 0;
|
||||
foreach ($transactions as $transaction){
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
if($data['paid']){
|
||||
dump($transaction->payment_reference);
|
||||
dump($transaction->id);
|
||||
}
|
||||
}else{
|
||||
Log::info("billplz error</br>");
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
|
||||
// if ($totalTransactions) {
|
||||
// Log::info(Carbon::now() . ' : Done Billplz Failled Callback. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
||||
// }
|
||||
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Show all failled callback from billplz. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ShowFixBillplzFailedCallbackPaymentV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Show Billplz Failled Callback.');
|
||||
$start = new Carbon();
|
||||
|
||||
// ini_set('memory_limit', '-1');
|
||||
// $this->outputArray = [];
|
||||
|
||||
$approvalStatusArray = ApprovalStatus::APPROVAL_STATUS_ID;
|
||||
|
||||
$transactions = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
|
||||
$totalTransactions = count($transactions);
|
||||
$counter = 1;
|
||||
$totalAmount = 0;
|
||||
foreach ($transactions as $transaction){
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
if($data['paid']){
|
||||
$totalAmount += $transaction->amount;
|
||||
$invoiceStatus = null;
|
||||
|
||||
switch($transaction->owner->status) {
|
||||
case 3:
|
||||
$invoiceStatus = 'Payment Completed';
|
||||
break;
|
||||
case 5:
|
||||
$invoiceStatus = 'Dispute in progress';
|
||||
break;
|
||||
case 6:
|
||||
$invoiceStatus = 'Cancelled Invoice';
|
||||
break;
|
||||
default:
|
||||
$invoiceStatus = 'Pending Payment';
|
||||
}
|
||||
|
||||
$order = $transaction->owner->owner->owner;
|
||||
|
||||
if(!$order instanceof Order) {
|
||||
Log::info("Error transaction id:" . $transaction->id . 'Type: ' . get_class($order));
|
||||
} else {
|
||||
Log::info($counter . ' of ' . $totalTransactions . '. Order: '. $order->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount . '. Status: ' . $approvalStatusArray[$transaction->status] . '. Invoice Status: ' . $invoiceStatus);
|
||||
}
|
||||
|
||||
} else {
|
||||
// $totalAmount += $transaction->amount;
|
||||
// $this->appendToOutput($counter . ' of ' . $totalTransactions . '. Order: '. $transaction->owner->owner->owner->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount);
|
||||
}
|
||||
}else{
|
||||
Log::info("billplz error</br>");
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Show Billplz Failled Callback. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SuccessUpdatePaymentStatusV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Success Updated Payment Status.');
|
||||
$start = new Carbon();
|
||||
|
||||
// ini_set('memory_limit', '-1');
|
||||
// $this->outputArray = [];
|
||||
|
||||
$approvalStatusArray = ApprovalStatus::APPROVAL_STATUS_ID;
|
||||
|
||||
$transactions = Transaction::where('type', TransactionType::PAYMENT)
|
||||
->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)
|
||||
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
|
||||
->get();
|
||||
|
||||
foreach ($transactions as $payment) {
|
||||
$invoice = $payment->owner ?? null;
|
||||
if (!$invoice) {
|
||||
Log::info('Payment has no owner. Payment ID: ' . $payment->id);
|
||||
continue;
|
||||
}
|
||||
|
||||
$packingList = $invoice->owner ?? null;
|
||||
if (!$packingList) {
|
||||
Log::info('Invoice has no owner. Invoice ID: ' . $invoice->id);
|
||||
continue;
|
||||
}
|
||||
|
||||
$order = $packingList->owner;
|
||||
if (!$invoice) {
|
||||
Log::info('PackingList has no owner. PackingList ID: ' . $packingList->id);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($invoice->status == ApprovalStatus::APPROVED) {
|
||||
|
||||
$totalPaidAmount = $invoice->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
|
||||
|
||||
if(($invoice->amount - $totalPaidAmount) < 0.01) {
|
||||
(App()->make(UpdatesTransactionStatus::class))->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
|
||||
if(app()->environment('production')){
|
||||
(App()->make(UpdateDoFromVTPortalProcessor::class))->execute($packingList);
|
||||
(App()->make(UpdateDoFromYDPortalProcessor::class))->execute($packingList);
|
||||
}
|
||||
|
||||
dump('Updated invoice ' . $invoice->id . '. Order: '. $order->reference);
|
||||
} else {
|
||||
Log::info('Failed Update invoice ' . $invoice->id . ' because payment not enough. Invoice Amount: ' . $invoice->amount . ' . Paid Amount: ' . $totalPaidAmount . ' . Order: '. $order->reference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Success Updated Payment Status. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Models\Container;
|
||||
use App\Models\Order;
|
||||
use App\Models\User;
|
||||
use App\Classes\Notifications\ShipmentDepartureEmail;
|
||||
|
||||
class TestAttachingS3FileAndSendEmailV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Test to attach a file from S3 bucket and trigger an email send.');
|
||||
$start = new Carbon();
|
||||
|
||||
$containers = Container::whereHas('transports', function ($transport){
|
||||
return $transport->whereDate('dispatch_date', '<', Carbon::today())->whereDate('dispatch_date', '>', Carbon::now()->subdays(30));
|
||||
})->get();
|
||||
|
||||
Log::info("[TESTING] total containers: " . count($containers));
|
||||
|
||||
$sent = false;
|
||||
foreach ($containers as $container){
|
||||
if($sent){
|
||||
break;
|
||||
}
|
||||
foreach ($container->packingLists as $packingList){
|
||||
if($sent){
|
||||
break;
|
||||
}
|
||||
|
||||
if(!($packingList->owner instanceof Order)) continue;
|
||||
$user = $packingList->owner->companyModule->employees()->first();
|
||||
$user = User::where('email', 'dillonngoweijoon@gmail.com')->first();
|
||||
|
||||
Log::info("[TESTING] user: " . json_encode($user));
|
||||
Log::info("[TESTING] packingList: " . json_encode($packingList));
|
||||
|
||||
$user->notify(new ShipmentDepartureEmail($user, $packingList));
|
||||
$sent = true;
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Test to attach a file from S3 bucket and trigger an email send. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\Modules\Exports\Services\ExportsNullDebtors;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Models\Company;
|
||||
|
||||
class TestExportExcelToS3BucketV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Test Export Excel File to S3 Bucket.');
|
||||
$start = new Carbon();
|
||||
|
||||
Log::info('company 0');
|
||||
|
||||
$company = Company::where(function($query){
|
||||
$query->whereNull('debtor')->orWhere('debtor', '');
|
||||
})->get();
|
||||
|
||||
Log::info('company 1: ' . json_encode($company));
|
||||
|
||||
$company = Company::where(function($query){
|
||||
$query->whereNull('debtor')->orWhere('debtor', '');
|
||||
})->whereHas('companyModules', function($query){
|
||||
$query->where('type', BusinessType::IMPORTER);
|
||||
})->get();
|
||||
|
||||
Log::info('company 2: ' . json_encode($company));
|
||||
|
||||
$company = Company::where(function($query){
|
||||
$query->whereNull('debtor')->orWhere('debtor', '');
|
||||
})->whereHas('companyModules', function($query){
|
||||
$query->where('type', BusinessType::IMPORTER);
|
||||
})->whereHas('parcels', function ($query) {
|
||||
$query->where('packages.status', ApprovalStatus::APPROVED);
|
||||
|
||||
})
|
||||
->with(['companyModules', 'parcels'])
|
||||
->get();
|
||||
|
||||
Log::info('company 3: ' . json_encode($company));
|
||||
|
||||
$company = Company::where(function($query){
|
||||
$query->whereNull('debtor')->orWhere('debtor', '');
|
||||
})->whereHas('companyModules', function($query){
|
||||
$query->where('type', BusinessType::IMPORTER);
|
||||
})->whereHas('parcels')->where('status', ApprovalStatus::APPROVED)->get();
|
||||
|
||||
Log::info('company 4: ' . json_encode($company));
|
||||
|
||||
$export = new ExportsNullDebtors();
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
|
||||
if ($filesystemDriver === 's3') {
|
||||
$filePathForS3 = 'temp/nullDebtor.xlsx'; //documents/exports
|
||||
$excelFile = $export->store($filePathForS3, 's3');
|
||||
$temporaryUrl = Storage::disk('s3')->temporaryUrl(
|
||||
$filePathForS3,
|
||||
Carbon::now()->addMinutes(10)
|
||||
);
|
||||
Log::info('temporaryUrl: ' . $temporaryUrl);
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Test Export Excel File to S3 Bucket. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\Modules\PackingLists\Processors\TestFetchPackingListsFromYdPortalProcessor;
|
||||
|
||||
class TestReadDataFromYDAPIV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Test to read data from YD API.');
|
||||
$start = new Carbon();
|
||||
|
||||
(App()->make(TestFetchPackingListsFromYdPortalProcessor::class))->execute();
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Test to read data from YD API. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2\YD;
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\V2\FetchContainersFromYdPortalV2Processor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersUpdatesFromYdPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchDeliveryUpdatesFromYdPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchOrderListsFromYdPortalProcessor;
|
||||
use App\Models\PackingList;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchContainersFromYdPortalV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $packingList;
|
||||
|
||||
public function __construct(PackingList $packingList)
|
||||
{
|
||||
$this->packingList = $packingList;
|
||||
}
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info('Processing FetchContainersFromYdPortalV2CommandJob');
|
||||
$processor = app(FetchContainersFromYdPortalV2Processor::class);
|
||||
$processor->execute($this->packingList);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2\YD;
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersFromYdPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\V2\FetchContainersUpdatesFromYdPortalV2Processor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchDeliveryUpdatesFromYdPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchOrderListsFromYdPortalProcessor;
|
||||
use App\Models\Container;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchContainersUpdatesFromYdPortalV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $container;
|
||||
|
||||
public function __construct(Container $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info('Processing FetchContainersUpdatesFromYdPortalV2CommandJob');
|
||||
$processor = app(FetchContainersUpdatesFromYdPortalV2Processor::class);
|
||||
$processor->execute($this->container);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2\YD;
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersFromYdPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersUpdatesFromYdPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\V2\FetchDeliveryUpdatesFromYdPortalV2Processor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchOrderListsFromYdPortalProcessor;
|
||||
use App\Models\PackingList;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchDeliveryUpdatesFromYdPortalV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $packingListId;
|
||||
|
||||
public function __construct(int $packingListId)
|
||||
{
|
||||
$this->packingListId = $packingListId;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info('Processing FetchDeliveryUpdatesFromYdPortalV2CommandJob');
|
||||
$processor = app(FetchDeliveryUpdatesFromYdPortalV2Processor::class);
|
||||
$processor->execute($this->packingListId);
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2\YD;
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\V2\FetchOrderListsFromYdPortalV2Processor;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchOrderListsFromYdPortalV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $startDate;
|
||||
protected $endDate;
|
||||
|
||||
public function __construct(?Carbon $startDate, ?Carbon $endDate)
|
||||
{
|
||||
$this->startDate = $startDate;
|
||||
$this->endDate = $endDate;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info('Processing FetchOrderListsFromYdPortalV2CommandJob for start date: ' . $this->startDate. ', and end date: ' . $this->endDate);
|
||||
$processor = app(FetchOrderListsFromYdPortalV2Processor::class);
|
||||
$processor->execute($this->startDate, $this->endDate);
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2\YD;
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\V2\FetchPackingListsFromYdPortalV2Processor;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchPackingListsFromYdPortalV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $startDate;
|
||||
protected $endDate;
|
||||
|
||||
public function __construct(?Carbon $startDate, ?Carbon $endDate)
|
||||
{
|
||||
$this->startDate = $startDate;
|
||||
$this->endDate = $endDate;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info('Processing FetchPackingListsFromYdPortalV2CommandJob for start date: ' . $this->startDate. ', and end date: ' . $this->endDate);
|
||||
$processor = app(FetchPackingListsFromYdPortalV2Processor::class);
|
||||
$processor->execute($this->startDate, $this->endDate);
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2\YD;
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\V2\FetchByTrakingNoYdPortalV2Processor;
|
||||
use App\Models\PackingList;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchTrakingInfoYDByPackingListV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $packingList;
|
||||
|
||||
public function __construct(PackingList $packingList)
|
||||
{
|
||||
$this->packingList = $packingList;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info('Processing FetchTrakingInfoYDByPackingListV2CommandJob');
|
||||
$processor = app(FetchByTrakingNoYdPortalV2Processor::class);
|
||||
$processor->execute($this->packingList);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2\YD;
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\V2\FetchByTrakingNoYdPortalV2Processor;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchTrakingInfoYDByTrackingNoV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $trackingNo;
|
||||
|
||||
public function __construct(string $trackingNo)
|
||||
{
|
||||
$this->trackingNo = $trackingNo;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info('Processing FetchTrakingInfoYDByTrackingNoV2CommandJob');
|
||||
$processor = app(FetchByTrakingNoYdPortalV2Processor::class);
|
||||
$processor->processTrackingNo($this->trackingNo);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2\YD;
|
||||
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class ProcessYDByTrakingNoDataV2Job implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $trackingNo;
|
||||
|
||||
public function __construct($trackingNo)
|
||||
{
|
||||
$this->trackingNo = $trackingNo;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Artisan::call('process-yd-by-traking-no-data-command', [
|
||||
'trackingNo' => $this->trackingNo
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2\YD;
|
||||
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class ProcessYDPortalDataV2Job implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $start;
|
||||
protected $end;
|
||||
|
||||
public function __construct($start, $end)
|
||||
{
|
||||
$this->start = $start;
|
||||
$this->end = $end;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Artisan::call('process-yd-portal-data-command', [
|
||||
'start_date' => $this->start,
|
||||
'end_date' => $this->end
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V3\YD;
|
||||
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\V3\FetchContainersUpdatesYdPortalV3Processor;
|
||||
use App\Models\Container;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchContainersUpdatesYdPortalV3CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $container;
|
||||
|
||||
public function __construct(Container $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info('Processing FetchContainersUpdatesYdPortalV3CommandJob');
|
||||
$processor = app(FetchContainersUpdatesYdPortalV3Processor::class);
|
||||
$processor->execute($this->container);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V3\YD;
|
||||
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\V3\FetchContainersYdPortalV3Processor;
|
||||
use App\Models\PackingList;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchContainersYdPortalV3CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $packingList;
|
||||
|
||||
public function __construct(PackingList $packingList)
|
||||
{
|
||||
$this->packingList = $packingList;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info('Processing FetchContainersYdPortalV3CommandJob');
|
||||
$processor = app(FetchContainersYdPortalV3Processor::class);
|
||||
$processor->execute($this->packingList);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchOrdersFromYDPortalJob implements ShouldQueue
|
||||
{
|
||||
@@ -30,17 +29,12 @@ class FetchOrdersFromYDPortalJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Log::info('FetchOrdersFromYDPortalJob starts');
|
||||
Log::info('FetchPackingListsFromYdPortalProcessor starts');
|
||||
(App()->make(FetchPackingListsFromYdPortalProcessor::class))->execute();
|
||||
Log::info('FetchContainersFromYdPortalProcessor starts');
|
||||
(App()->make(FetchContainersFromYdPortalProcessor::class))->execute();
|
||||
Log::info('FetchContainersUpdatesFromYdPortalProcessor starts');
|
||||
(App()->make(FetchContainersUpdatesFromYdPortalProcessor::class))->execute();
|
||||
Log::info('FetchDeliveryUpdatesFromYdPortalProcessor starts');
|
||||
(App()->make(FetchDeliveryUpdatesFromYdPortalProcessor::class))->execute();
|
||||
Log::info('FetchOrdersFromYDPortalJob ends');
|
||||
// (App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute();
|
||||
|
||||
// (App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\ListPackingListsJobProcessor;
|
||||
use App\Classes\Modules\Jobs\DataTransferObjects\JobSubmissionObject;
|
||||
use App\Classes\Modules\Jobs\DataTransferObjects\ListGenericJobObject;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@@ -17,29 +17,29 @@ class ListPackingListsJob implements ShouldQueue
|
||||
|
||||
public $timeout = 900;
|
||||
|
||||
/** @var JobSubmissionObject */
|
||||
private $jobSubmissionObject;
|
||||
/** @var ListGenericJobObject */
|
||||
private $listGenericJobObject;
|
||||
|
||||
/**
|
||||
* ListPackingListsJob constructor.
|
||||
* @param JobSubmissionObject $JobSubmissionObject
|
||||
* @param ListGenericJobObject $listGenericJobObject
|
||||
*/
|
||||
public function __construct(JobSubmissionObject $jobSubmissionObject)
|
||||
public function __construct(ListGenericJobObject $listGenericJobObject)
|
||||
{
|
||||
$this->jobSubmissionObject = $jobSubmissionObject;
|
||||
$this->listGenericJobObject = $listGenericJobObject;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$rawPayload = $this->job->payload();
|
||||
if(isset($rawPayload['data']['commandName'])){
|
||||
$this->jobSubmissionObject->setJobCommandName($rawPayload['data']['commandName']);
|
||||
$this->listGenericJobObject->setJobCommandName($rawPayload['data']['commandName']);
|
||||
}
|
||||
|
||||
if(isset($rawPayload['data']['command'])){
|
||||
$this->jobSubmissionObject->setJobCommand($rawPayload['data']['command']);
|
||||
$this->listGenericJobObject->setJobCommand($rawPayload['data']['command']);
|
||||
}
|
||||
|
||||
$result = (App()->make(ListPackingListsJobProcessor::class))->execute($this->jobSubmissionObject);
|
||||
$result = (App()->make(ListPackingListsJobProcessor::class))->execute($this->listGenericJobObject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\Reports\Processors\MonthlyReportJobProcessor;
|
||||
use App\Classes\Modules\Jobs\DataTransferObjects\JobSubmissionObject;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
|
||||
class MonthlyReportJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $timeout = 900;
|
||||
|
||||
/** @var JobSubmissionObject */
|
||||
private $jobSubmissionObject;
|
||||
|
||||
/**
|
||||
* MonthlyReportJob constructor.
|
||||
* @param JobSubmissionObject $jobSubmissionObject
|
||||
*/
|
||||
public function __construct(JobSubmissionObject $jobSubmissionObject)
|
||||
{
|
||||
$this->jobSubmissionObject = $jobSubmissionObject;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$rawPayload = $this->job->payload();
|
||||
if(isset($rawPayload['data']['commandName'])){
|
||||
$this->jobSubmissionObject->setJobCommandName($rawPayload['data']['commandName']);
|
||||
}
|
||||
|
||||
if(isset($rawPayload['data']['command'])){
|
||||
$this->jobSubmissionObject->setJobCommand($rawPayload['data']['command']);
|
||||
}
|
||||
|
||||
$result = (App()->make(MonthlyReportJobProcessor::class))->execute($this->jobSubmissionObject);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ use Illuminate\Queue\SerializesModels;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\General\Helper;
|
||||
use App\Classes\General\LogHelper;
|
||||
|
||||
class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
{
|
||||
@@ -48,7 +47,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
$invoiceId = 0;
|
||||
$invoiceStatus = 0;
|
||||
$invoice = (App()->make(FetchesPerfexCRMInvoice::class))->execute($customer->userid,"INV-", $transaction->owner->bill_no);
|
||||
LogHelper::channel('perfex_crm')->info('UpdatePerfexCRMInvoice debug bill_no: ' . $transaction->owner->bill_no . ', Project Id: ' . $this->updatePerfexCRMInvoiceObject->getProjectId());
|
||||
Log::channel('perfex_crm')->info('UpdatePerfexCRMInvoice debug bill_no: ' . $transaction->owner->bill_no . ', Project Id: ' . $this->updatePerfexCRMInvoiceObject->getProjectId());
|
||||
|
||||
if(is_null($invoice)){
|
||||
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction->owner, $this->updatePerfexCRMInvoiceObject->getIsPaid());
|
||||
@@ -56,7 +55,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
$invoiceId = $result->payload['id'];
|
||||
} else {
|
||||
// Log::error(json_encode('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed'));
|
||||
LogHelper::channel('perfex_crm')->info('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
|
||||
Log::channel('perfex_crm')->info('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -32,12 +32,12 @@ class UpdatePerfexCRMPrelude implements ShouldQueue
|
||||
|
||||
/**
|
||||
* UpdatePerfexCRMPrelude constructor.
|
||||
* @param PackingList $packingList
|
||||
* @param $packingList
|
||||
* @param Transaction $transaction
|
||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||
* @param bool|null $shouldCreateInvoice
|
||||
*/
|
||||
public function __construct(?PackingList $packingList, $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, ?bool $shouldCreateInvoice = false)
|
||||
public function __construct($packingList, $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, ?bool $shouldCreateInvoice = false)
|
||||
{
|
||||
$this->packingList = $packingList;
|
||||
$this->transaction = $transaction;
|
||||
@@ -47,12 +47,6 @@ class UpdatePerfexCRMPrelude implements ShouldQueue
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info('UpdatePerfexCRMPrelude packingList: ' . json_encode($this->packingList));
|
||||
|
||||
if(env('APP_ENV') !== 'production'){
|
||||
return;
|
||||
}
|
||||
|
||||
if(is_null($this->packingList)){
|
||||
$this->packingList = $this->transaction->owner->owner;
|
||||
}
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\ResourceConflictException;
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounts\Processors\GenerateEmailVerificationAttemptProcessor;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\UserResource;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class AdminAddNewMemberLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
public function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Admin Updated Email',
|
||||
'message' => 'Successfully updated email'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @var AssignEmployeeProcessor
|
||||
*/
|
||||
private $assignEmployeeProcessor;
|
||||
|
||||
/**
|
||||
* @var GenerateEmailVerificationAttemptProcessor
|
||||
*/
|
||||
private $generateEmailVerificationAttemptProcessor;
|
||||
|
||||
/**
|
||||
* AddNewMemberLogic constructor.
|
||||
* @param AssignEmployeeProcessor $assignEmployeeProcessor
|
||||
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
||||
*/
|
||||
public function __construct(AssignEmployeeProcessor $assignEmployeeProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor)
|
||||
{
|
||||
$this->assignEmployeeProcessor = $assignEmployeeProcessor;
|
||||
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ResourceConflictException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
Log::info($request->input('employeeId'));
|
||||
|
||||
try {
|
||||
if (!$authUser = User::find($request->input('employeeId'))) {
|
||||
throw new ResourceNotFoundException('User not found.');
|
||||
}
|
||||
|
||||
$user = $authUser->replicate();
|
||||
$user->email = $request->input('email');
|
||||
$user->status = ApprovalStatus::PENDING_VERIFICATION;
|
||||
$user->save();
|
||||
|
||||
} catch (QueryException $e) {
|
||||
throw new ResourceConflictException('Email already exists.');
|
||||
}
|
||||
|
||||
Log::info($request->input('email'));
|
||||
|
||||
if ($company = $authUser->companyModule()->first()) {
|
||||
$this->assignEmployeeProcessor->execute(new EmploymentObject($company, $user));
|
||||
}
|
||||
|
||||
$this->generateEmailVerificationAttemptProcessor->execute($user);
|
||||
|
||||
return $this->resourceResponse(new UserResource($user));
|
||||
}
|
||||
}
|
||||
@@ -36,8 +36,6 @@ use App\Models\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreateCustomerLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -169,19 +167,6 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
CreatePerfexCRMCustomer::dispatch($createLeadPerfexCRMObject);
|
||||
}
|
||||
|
||||
if(app()->environment(['production'])){
|
||||
// call wac webhook
|
||||
$url = config('wagWebhookUrl.account_registration_url');
|
||||
$payload = [
|
||||
'name' => $request->input('name'),
|
||||
'email' => $request->input('email'),
|
||||
'phone' => $request->input('phone'),
|
||||
'portal' => 'izyim'
|
||||
];
|
||||
$response = Http::post($url, $payload);
|
||||
Log::channel('wac_webhook')->info('Register Account: ' . json_encode($response));
|
||||
}
|
||||
|
||||
// $this->generateEmailVerificationAttemptProcessor->execute($user);
|
||||
|
||||
return $this->response($this->authenticationProcessor->execute($request));
|
||||
|
||||
@@ -77,11 +77,11 @@ class GeneratePasswordResetLogic extends AbstractControllerLogic
|
||||
|
||||
$attempt = $this->generatesPasswordReset->execute($user);
|
||||
|
||||
// $this->passwordResetTokenExpiration::dispatch($attempt)->delay(now()->addHours(24)); //converted to schedule task
|
||||
$this->passwordResetTokenExpiration::dispatch($attempt)->delay(now()->addHours(24));
|
||||
$this->sendResetPasswordEmail::dispatch($user, $attempt);
|
||||
|
||||
return $this->response(['email' => $object->getEmail()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -50,7 +50,7 @@ class GenerateEmailVerificationAttemptProcessor
|
||||
|
||||
$attempt = $this->generatesEmailVerificationAttempt->execute($user);
|
||||
|
||||
//$this->emailVerificationAttemptExpiration::dispatch($attempt)->delay(now()->addHours(48)); //converted to schedule task
|
||||
$this->emailVerificationAttemptExpiration::dispatch($attempt)->delay(now()->addHours(48));
|
||||
|
||||
$this->sendUserVerificationEmail::dispatch($user, $attempt);
|
||||
|
||||
|
||||
@@ -15,10 +15,8 @@ use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\RemarkTypes;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use Carbon\Carbon;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -102,24 +100,6 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||
}
|
||||
|
||||
if ($request->input('pickup_time_to') <= $request->input('pickup_time_from')) {
|
||||
$pickupTimeFrom = Carbon::parse($request->input('pickup_time_from'));
|
||||
$request->merge([
|
||||
'pickup_time_to' => $pickupTimeFrom->addHour()->format('H:i') // Format to hh:mm
|
||||
]);
|
||||
}
|
||||
|
||||
$addressExtraFields = [
|
||||
'property_type' => $request->input('property_type'),
|
||||
'receive_goods_working_hours' => $request->input('receive_goods_working_hours'),
|
||||
'receive_goods_after_hours' => $request->input('receive_goods_after_hours'),
|
||||
'receive_goods_on_saturday' => $request->input('receive_goods_on_saturday'),
|
||||
];
|
||||
|
||||
$address->addressExtraFields()->delete();
|
||||
$addressExtraFieldsObject = new RemarkObject(json_encode($addressExtraFields), Auth()->user()->id, RemarkTypes::ADDRESS_EXTRA_COLUMNS);
|
||||
$remark = $this->createRemarkProcessor->execute($address, $addressExtraFieldsObject);
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -52,12 +51,13 @@ class ListAddressesLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$this->canListAddresses->passes();
|
||||
|
||||
//$query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters')));
|
||||
$query = $this->listsAddresses->execute(array_merge($this->listsAddresses->deserializeFilters($request->input('filters')), ['type_not_in' => [AddressType::E_INVOICE]]));
|
||||
$query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(AddressResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,10 @@ use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\RemarkTypes;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UpdateAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -104,24 +102,6 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||
}
|
||||
|
||||
if ($request->input('pickup_time_to') <= $request->input('pickup_time_from')) {
|
||||
$pickupTimeFrom = Carbon::parse($request->input('pickup_time_from'));
|
||||
$request->merge([
|
||||
'pickup_time_to' => $pickupTimeFrom->addHour()->format('H:i') // Format to hh:mm
|
||||
]);
|
||||
}
|
||||
|
||||
$addressExtraFields = [
|
||||
'property_type' => $request->input('property_type'),
|
||||
'receive_goods_working_hours' => $request->input('receive_goods_working_hours'),
|
||||
'receive_goods_after_hours' => $request->input('receive_goods_after_hours'),
|
||||
'receive_goods_on_saturday' => $request->input('receive_goods_on_saturday'),
|
||||
];
|
||||
|
||||
$address->addressExtraFields()->delete();
|
||||
$addressExtraFieldsObject = new RemarkObject(json_encode($addressExtraFields), Auth()->user()->id, RemarkTypes::ADDRESS_EXTRA_COLUMNS);
|
||||
$remark = $this->createRemarkProcessor->execute($address, $addressExtraFieldsObject);
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class AddressObject implements DataTransferObject
|
||||
/** @var int */
|
||||
private $districtId;
|
||||
|
||||
/** @var string */
|
||||
/** @var int */
|
||||
private $postCode;
|
||||
|
||||
/** @var int */
|
||||
@@ -42,12 +42,12 @@ class AddressObject implements DataTransferObject
|
||||
* @param int $countryId
|
||||
* @param int $stateId
|
||||
* @param int $districtId
|
||||
* @param string $postCode
|
||||
* @param int $postCode
|
||||
* @param int $type
|
||||
* @param int $status
|
||||
* @param null|string $reference
|
||||
*/
|
||||
public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, string $postCode, int $type, int $status, ?string $reference = null)
|
||||
public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, int $postCode, int $type, int $status, ?string $reference = null)
|
||||
{
|
||||
$this->streetOne = $streetOne;
|
||||
$this->streetTwo = $streetTwo;
|
||||
@@ -101,9 +101,9 @@ class AddressObject implements DataTransferObject
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return int
|
||||
*/
|
||||
public function getPostCode(): string
|
||||
public function getPostCode(): int
|
||||
{
|
||||
return $this->postCode;
|
||||
}
|
||||
@@ -133,4 +133,4 @@ class AddressObject implements DataTransferObject
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Addresses\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\General\Interfaces\Addressable;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Models\Address;
|
||||
use App\Models\CompanyModule;
|
||||
|
||||
class UpsertsAddress extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
/**
|
||||
* Create or update the company's address.
|
||||
*
|
||||
* @param Addressable $addressable
|
||||
* @param AddressObject $object
|
||||
* @param int $id
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Addressable $addressable, AddressObject $object, int $id)
|
||||
{
|
||||
//Create new or update?
|
||||
$model = $addressable->addresses()->where('id', $id)->first() ?? new Address();
|
||||
|
||||
$model->reference = $object->getReference();
|
||||
$model->street_one = $object->getStreetOne();
|
||||
$model->street_two = $object->getStreetTwo();
|
||||
$model->country_id = $object->getCountryId();
|
||||
$model->state_id = $object->getStateId();
|
||||
$model->district_id = $object->getDistrictId();
|
||||
$model->postcode = $object->getPostCode();
|
||||
$model->status = $object->getStatus();
|
||||
$model->type = $object->getType();
|
||||
|
||||
return $this->handler($addressable->addresses(), $model);
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\Processors;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Group;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||
use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
//Date: 20240817
|
||||
//This Processor is used for one time data patching with OneTimeTransactionFixBillplzFailedCallback.php
|
||||
class CallbackBillplzDataPatchProcessor
|
||||
{
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor;
|
||||
|
||||
/** @var UpdatesWalletBalance */
|
||||
private $updatesWalletBalance;
|
||||
|
||||
/** @var CreatePaymentTransactionProcessor */
|
||||
private $createPaymentTransactionProcessor;
|
||||
|
||||
/** @var ReleaseGoodsToCustomerProcessor */
|
||||
private $releaseGoodsToCustomerProcessor;
|
||||
|
||||
/**
|
||||
* CallbackBillplzDataPatchProcessor constructor.
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||
* @param ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor
|
||||
*/
|
||||
public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor)
|
||||
{
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||
$this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute($transaction, $status)
|
||||
{
|
||||
$invoice = $transaction->owner;
|
||||
$packingList = $invoice->owner;
|
||||
|
||||
$proceed = $this->checkForGroupPayment($transaction);
|
||||
if(!$proceed) return false;
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||
|
||||
Log::info('CallbackBillplzDataPatchProcessor 1');
|
||||
|
||||
// check if is wallet top up
|
||||
if ($transaction->owner instanceof Wallet && $status === ApprovalStatus::APPROVED) {
|
||||
|
||||
Log::info('CallbackBillplzDataPatchProcessor 2');
|
||||
|
||||
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
|
||||
|
||||
$group = Group::where('reference', $transaction->payment_reference)->first();
|
||||
|
||||
// check if is group payment
|
||||
if ($group) {
|
||||
foreach ($group->groupTransactions as $groupTransaction) {
|
||||
$invoice = $groupTransaction->transaction;
|
||||
Log::info('CallbackBillplzDataPatchProcessor 3: '.json_encode($invoice));
|
||||
|
||||
if($invoice->status !== ApprovalStatus::COMPLETED){
|
||||
$paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null, false);
|
||||
|
||||
if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){
|
||||
$pL = $invoice->owner;
|
||||
$this->releaseGoodsToCustomerProcessor->execute($pL, $invoice, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$group->status = $status;
|
||||
$group->save();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$transaction->owner instanceof Wallet) {
|
||||
Log::info('CallbackBillplzDataPatchProcessor 3');
|
||||
$this->releaseGoodsToCustomerProcessor->execute($packingList, $invoice);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function checkForGroupPayment($transaction){
|
||||
//This check is targetting group payment that expired and soft deleted
|
||||
//command:check-storage-invoices must already run for this part of the code to work properly
|
||||
$group = Group::withTrashed()->where('reference', $transaction->payment_reference)->first();
|
||||
if ($group) {
|
||||
$totalAmountToBePaid = 0;
|
||||
$actualAmountPaid = $transaction->amount;
|
||||
|
||||
foreach ($group->groupTransactions as $groupTransaction) {
|
||||
$invoice = $groupTransaction->transaction;
|
||||
if($invoice->status !== ApprovalStatus::COMPLETED){
|
||||
$totalAmountToBePaid += $invoice->amount;
|
||||
}
|
||||
}
|
||||
|
||||
if(($totalAmountToBePaid - $actualAmountPaid) < 0.01){
|
||||
|
||||
}
|
||||
else{
|
||||
Log::channel('storage_invoices')->info('Total amount from current transaction: '.$totalAmountToBePaid);
|
||||
Log::channel('storage_invoices')->info('Total amount from paid transaction: '.$transaction->amount);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\Processors;
|
||||
|
||||
use App\Classes\General\LogHelper;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Group;
|
||||
@@ -37,7 +36,7 @@ class CallbackBillplzProcessor
|
||||
private $releaseGoodsToCustomerProcessor;
|
||||
|
||||
/**
|
||||
* CallbackBillplzProcessor constructor.
|
||||
* CreateUserProcessor constructor.
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
@@ -122,8 +121,8 @@ class CallbackBillplzProcessor
|
||||
|
||||
}
|
||||
else{
|
||||
LogHelper::channel('storage_invoices')->info('Total amount from current transaction: '.$totalAmountToBePaid);
|
||||
LogHelper::channel('storage_invoices')->info('Total amount from paid transaction: '.$transaction->amount);
|
||||
Log::channel('storage_invoices')->info('Total amount from current transaction: '.$totalAmountToBePaid); //cief todo: to be removed
|
||||
Log::channel('storage_invoices')->info('Total amount from paid transaction: '.$transaction->amount); //cief todo: to be removed
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Classes\Modules\Billplzs\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\LogHelper;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class DeletesBillplzBill
|
||||
@@ -17,7 +16,7 @@ class DeletesBillplzBill
|
||||
public function execute(string $billID) {
|
||||
try{
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->delete(config('billplz.base_url').'/api/v3/bills/'.$billID);
|
||||
LogHelper::channel('storage_invoices')->info('DeletesBillplzBill response: '.json_encode($response));
|
||||
Log::channel('storage_invoices')->info('DeletesBillplzBill response: '.json_encode($response));
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
+30
-33
@@ -8,12 +8,15 @@ use App\Classes\Modules\Documents\Standards\Rules\CanApproveDocument;
|
||||
use App\Classes\Modules\Orders\Services\UpdatesOrdersStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
||||
|
||||
use App\Classes\Modules\Documents\Services\ApprovesDocument;
|
||||
use App\Classes\Modules\Documents\Services\PendingVerificationDocument;
|
||||
use App\Classes\Modules\Notifications\DataTransferObjects\NotificationObject;
|
||||
use App\Classes\Modules\Notifications\Processors\CreateNotificationProcessor;
|
||||
Use App\Classes\Modules\Notifications\Processors\CreateNotificationProcessor;
|
||||
|
||||
use App\Models\Document;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -24,11 +27,10 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update Document Status',
|
||||
'message' => 'You have successfully updated the Document Status'
|
||||
'title' => 'Approve Document',
|
||||
'message' => 'You have successfully approved the Document'
|
||||
];
|
||||
}
|
||||
|
||||
@@ -41,9 +43,6 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
/** @var RejectsDocument */
|
||||
private $rejectsDocument;
|
||||
|
||||
/** @var PendingVerificationDocument */
|
||||
private $pendingVerificationDocument;
|
||||
|
||||
/** @var FetchesDocument */
|
||||
private $fetchesDocument;
|
||||
|
||||
@@ -62,12 +61,11 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
* @param ApprovesDocument $approvesDocument
|
||||
* @param RejectsDocument $rejectsDocument
|
||||
* @param FetchesDocument $fetchesDocument
|
||||
* @param PendingVerificationDocument $pendingVerificationDocument
|
||||
* @param UpdatesCompanyStatus $updatesCompanyStatus
|
||||
* @param UpdatesOrdersStatus $updatesOrdersStatus
|
||||
* @param CreateNotificationProcessor $createNotificationProcessor
|
||||
*/
|
||||
public function __construct(CanApproveDocument $canApproveDocument, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument, UpdatesCompanyStatus $updatesCompanyStatus, UpdatesOrdersStatus $updatesOrdersStatus, CreateNotificationProcessor $createNotificationProcessor, PendingVerificationDocument $pendingVerificationDocument)
|
||||
public function __construct(CanApproveDocument $canApproveDocument, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument, UpdatesCompanyStatus $updatesCompanyStatus, UpdatesOrdersStatus $updatesOrdersStatus, CreateNotificationProcessor $createNotificationProcessor)
|
||||
{
|
||||
$this->canApproveDocument = $canApproveDocument;
|
||||
$this->approvesDocument = $approvesDocument;
|
||||
@@ -76,7 +74,6 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
$this->updatesCompanyStatus = $updatesCompanyStatus;
|
||||
$this->updatesOrdersStatus = $updatesOrdersStatus;
|
||||
$this->createNotificationProcessor = $createNotificationProcessor;
|
||||
$this->pendingVerificationDocument = $pendingVerificationDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,37 +83,37 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$status = $request->route('status');
|
||||
|
||||
/** @var Document $document */
|
||||
$document = $this->fetchesDocument->execute(['id' => $request->route('document_id')]);
|
||||
|
||||
$this->canApproveDocument->passes();
|
||||
|
||||
if ($status === 'approve') {
|
||||
$document = $this->approvesDocument->execute($document);
|
||||
$this->updatesCompanyStatus->execute($document->owner, ApprovalStatus::APPROVED);
|
||||
$this->updatesOrdersStatus->execute($document->owner, ApprovalStatus::APPROVED);
|
||||
} elseif ($status === 'reject') {
|
||||
$document = $this->rejectsDocument->execute($document);
|
||||
$this->updatesCompanyStatus->execute($document->owner, ApprovalStatus::REJECTED);
|
||||
} elseif ($status === 'pending') {
|
||||
$document = $this->pendingVerificationDocument->execute($document);
|
||||
$this->updatesCompanyStatus->execute($document->owner, ApprovalStatus::PENDING_VERIFICATION);
|
||||
$document = $status === 'approve' ? $this->approvesDocument->execute($document) : $this->rejectsDocument->execute($document);
|
||||
|
||||
$this->updatesCompanyStatus->execute($document->owner, $status === 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
|
||||
// $object = new NotificationObject(
|
||||
// 'ID Verification ' . ( $status === 'approve' ? 'Approved' : 'Rejected' ),
|
||||
// ( $status === 'approve' ? 'Dear user, congratulations that your ' : 'Dear user, we are sorry to inform you that your ' ) . ( $document->type === 'IDENTITY_CARD' ? 'IC' : 'SSM' ) . ( $status === 'approve' ? ' has been approved. Start your first order now!' : ' has been rejected due to ' . ( $request->input('rejectRemark') ?? '' ) . ', please resubmit it for further action.' ),
|
||||
// $document->owner,
|
||||
// $document->owner->companyModules()->first()->employees()->first(),
|
||||
// $document,
|
||||
// );
|
||||
//
|
||||
// $this->createNotificationProcessor->execute($object);
|
||||
|
||||
if($status === 'approve'){
|
||||
$orders = $this->updatesOrdersStatus->execute($document->owner, ApprovalStatus::APPROVED);
|
||||
}
|
||||
|
||||
// $object = new NotificationObject(
|
||||
// 'ID Verification ' . ( $status === 'approve' ? 'Approved' : 'Rejected' ),
|
||||
// ( $status === 'approve' ? 'Dear user, congratulations that your ' : 'Dear user, we are sorry to inform you that your ' ) . ( $document->type === 'IDENTITY_CARD' ? 'IC' : 'SSM' ) . ( $status === 'approve' ? ' has been approved. Start your first order now!' : ' has been rejected due to ' . ( $request->input('rejectRemark') ?? '' ) . ', please resubmit it for further action.' ),
|
||||
// $document->owner,
|
||||
// $document->owner->companyModules()->first()->employees()->first(),
|
||||
// $document,
|
||||
// );
|
||||
|
||||
// $this->createNotificationProcessor->execute($object);
|
||||
|
||||
return $this->resourceResponse(new DocumentResource($document));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
||||
use App\Http\Resources\ContactResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Http\Resources\CompanyResource;
|
||||
|
||||
class CreateCompanyContactNumberLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Company Contact Number',
|
||||
'message' => 'You have successfully created the Company Contact Number'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var CreatesContact */
|
||||
private $createsContact;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/**
|
||||
* UpdateCompanyControllersLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param CreatesContact $createsContact
|
||||
* @param CreateContactProcessor $createContactProcessor
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, CreatesContact $createsContact, CreateContactProcessor $createContactProcessor)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->createsContact = $createsContact;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('companyId')]);
|
||||
|
||||
$contact = new ContactObject(
|
||||
$company->reference,
|
||||
$request->input('contactNumber'),
|
||||
$company->email,
|
||||
$company->wechat_id
|
||||
);
|
||||
|
||||
$this->createContactProcessor->execute($contact, $company);
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($company));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,69 +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\Standards\Rules\CanFetchCompany;
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Http\Resources\EInvoiceInfoResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchCompanyEInvoiceInfoLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Company E-Invoice Info',
|
||||
'message' => 'You have successfully retrieved a Company E-Invoice Info'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanFetchCompany */
|
||||
private $canFetchCompany;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/**
|
||||
* FetchCompanyEInvoiceInfoLogic constructor.
|
||||
* @param CanFetchCompany $canFetchCompany
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
*/
|
||||
public function __construct(CanFetchCompany $canFetchCompany, FetchesCompany $fetchesCompany)
|
||||
{
|
||||
$this->canFetchCompany = $canFetchCompany;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canFetchCompany->passes();
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
$eInvoiceInfo = $company->companyModules()->first()->addresses()->where('type', '=', AddressType::E_INVOICE)->latest()->first();
|
||||
|
||||
if($eInvoiceInfo){
|
||||
$eInvoiceInfo->tin = $company->tin;
|
||||
$eInvoiceInfo->msic_code = $company->msic_code;
|
||||
$eInvoiceInfo->e_invoice = $company->e_invoice;
|
||||
}
|
||||
else{
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new EInvoiceInfoResource($eInvoiceInfo));
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Services\FetchesContact;
|
||||
use App\Classes\Modules\Contacts\Services\UpdatesContact;
|
||||
use App\Http\Resources\ContactResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyContactNumberLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Company Contact Number',
|
||||
'message' => 'You have successfully updated the Company Contact Number'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesContact */
|
||||
private $fetchesContact;
|
||||
|
||||
/** @var UpdatesContact */
|
||||
private $updatesContact;
|
||||
|
||||
/**
|
||||
* UpdateCompanyControllersLogic constructor.
|
||||
* @param FetchesContact $fetchesContact
|
||||
* @param UpdatesContact $updatesContact
|
||||
*/
|
||||
public function __construct(FetchesContact $fetchesContact, UpdatesContact $updatesContact)
|
||||
{
|
||||
$this->fetchesContact = $fetchesContact;
|
||||
$this->updatesContact = $updatesContact;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$query = $this->fetchesContact->execute(['id' => $request->input('id')]);
|
||||
|
||||
$contact = new ContactObject(
|
||||
$query->reference,
|
||||
$request->input('contactNumber'),
|
||||
$query->email,
|
||||
$query->wechat_id
|
||||
);
|
||||
|
||||
$this->updatesContact->execute($query, $contact);
|
||||
|
||||
return $this->resourceResponse(new ContactResource($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,153 +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\UpdatesCompany;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyDebtor;
|
||||
use App\Classes\Modules\Addresses\Services\UpsertsAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesDistrict;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyModuleName;
|
||||
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
||||
use App\Classes\Modules\Documents\Services\UpdatesDocumentReference;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyEInvoiceInfo;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompany;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\UpdateCompanyDetailsDTO;
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\CompanyResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyDetailsLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update Company Details',
|
||||
'message' => 'You have successfully updated the Company Details'
|
||||
];
|
||||
}
|
||||
/** @var CanUpdateCompany */
|
||||
private $canUpdateCompany;
|
||||
|
||||
/** @var UpdatesCompany */
|
||||
private $updatesCompany;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var UpdatesCompanyDebtor */
|
||||
private $updatesCompanyDebtor;
|
||||
|
||||
/** @var CanCreateAddress */
|
||||
private $canCreateAddress;
|
||||
|
||||
/** @var FetchesDistrict */
|
||||
private $fetchesDistrict;
|
||||
|
||||
/** @var UpsertsAddress */
|
||||
private $upsertsAddress;
|
||||
|
||||
/** @var UpdatesCompanyEInvoiceInfo */
|
||||
private $updatesCompanyEInvoiceInfo;
|
||||
|
||||
/** @var UpdatesCompanyModuleName */
|
||||
private $updatesCompanyModuleName;
|
||||
|
||||
/** @var FetchesDocument */
|
||||
private $fetchesDocument;
|
||||
|
||||
/** @var UpdatesDocumentReference */
|
||||
private $updatesDocumentReference;
|
||||
|
||||
/**
|
||||
* UpdateCompanyDetailsLogic constructor.
|
||||
* @param CanUpdateCompany $canUpdateCompany
|
||||
* @param UpdatesCompany $updatesCompany
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param UpdatesCompanyDebtor $updatesCompanyDebtor
|
||||
* @param CanCreateAddress $canCreateAddress
|
||||
* @param FetchesDistrict $fetchesDistrict
|
||||
* @param UpsertsAddress $upsertsAddress
|
||||
* @param UpdatesCompanyEInvoiceInfo $updatesCompanyEInvoiceInfo;
|
||||
* @param FetchesDocument $fetchesDocument
|
||||
* @param UpdatesDocumentReference $updatesDocumentReference
|
||||
*
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateCompany $canUpdateCompany,
|
||||
UpdatesCompany $updatesCompany,
|
||||
FetchesCompany $fetchesCompany,
|
||||
UpdatesCompanyDebtor $updatesCompanyDebtor,
|
||||
CanCreateAddress $canCreateAddress,
|
||||
FetchesDistrict $fetchesDistrict,
|
||||
UpsertsAddress $upsertsAddress,
|
||||
UpdatesCompanyEInvoiceInfo $updatesCompanyEInvoiceInfo,
|
||||
UpdatesCompanyModuleName $updatesCompanyModuleName,
|
||||
FetchesDocument $fetchesDocument,
|
||||
UpdatesDocumentReference $updatesDocumentReference
|
||||
)
|
||||
{
|
||||
$this->canUpdateCompany = $canUpdateCompany;
|
||||
$this->updatesCompany = $updatesCompany;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->updatesCompanyDebtor = $updatesCompanyDebtor;
|
||||
$this->canCreateAddress = $canCreateAddress;
|
||||
$this->fetchesDistrict = $fetchesDistrict;
|
||||
$this->upsertsAddress = $upsertsAddress;
|
||||
$this->updatesCompanyEInvoiceInfo = $updatesCompanyEInvoiceInfo;
|
||||
$this->updatesCompanyModuleName = $updatesCompanyModuleName;
|
||||
$this->fetchesDocument = $fetchesDocument;
|
||||
$this->updatesDocumentReference = $updatesDocumentReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$dto = new UpdateCompanyDetailsDTO($request->all());
|
||||
$object = new CompanyObject($dto->name, $dto->reference, $dto->type);
|
||||
|
||||
$this->canUpdateCompany->passes($object);
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->updatesCompanyModuleName->execute($company->companyModules()->first(), $object->getName());
|
||||
|
||||
//Update Name and Debtor, Type
|
||||
$company = $this->updatesCompany->execute($company, $object);
|
||||
|
||||
if ($request->input('debtor') || $company->first()->debtor !== null) {
|
||||
$this->updatesCompanyDebtor->execute($company, $request->input('debtor'));
|
||||
}
|
||||
|
||||
//Update EInvoice Related Info
|
||||
if($company->e_invoice){
|
||||
$district = $this->fetchesDistrict->execute(['id' => $dto->districtId]);
|
||||
$addObj = new AddressObject($dto->streetOne, $dto->streetTwo, $district->country_id, $dto->stateId, $district->id, $dto->postCode, AddressType::E_INVOICE, ApprovalStatus::APPROVED, 'E-Invoice');
|
||||
|
||||
$this->canCreateAddress->passes($addObj);
|
||||
|
||||
$this->upsertsAddress->execute($company->companyModules()->first(), $addObj, $dto->addressId);
|
||||
$this->updatesCompanyEInvoiceInfo->execute($company, $dto->tin, $dto->msicCode);
|
||||
}
|
||||
|
||||
//Update Identification Card / SSM Registration
|
||||
if($dto->identificationId){
|
||||
$document = $this->fetchesDocument->execute(['id' => $dto->identificationId]);
|
||||
$this->updatesDocumentReference->execute($document, $dto->identificationReference);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($company));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\CriteriaNotFulfilledException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesDistrict;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyEInvoiceInfo;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EInvoiceInfoDTO;
|
||||
use App\Classes\Modules\Rules\Services\RuleEvaluator;
|
||||
use App\Classes\Modules\Rules\Standards\Rules\CanPassEInvoicePromptedRule;
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyEInvoiceInfoLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'EInvoice Info Update',
|
||||
'message' => 'You have successfully updated company E-Invoice information'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateAddress */
|
||||
private $canCreateAddress;
|
||||
|
||||
/** @var FetchesDistrict */
|
||||
private $fetchesDistrict;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
|
||||
/** @var RuleEvaluator */
|
||||
private $ruleEvaluator;
|
||||
|
||||
/** @var UpdatesCompanyEInvoiceInfo */
|
||||
private $updatesCompanyEInvoiceInfo;
|
||||
|
||||
/** @var CanPassEInvoicePromptedRule */
|
||||
private $canPassEInvoicePromptedRule;
|
||||
|
||||
/**
|
||||
* UpdateCompanyEInvoiceInfoLogic constructor.
|
||||
* @param CanCreateAddress $canCreateAddress
|
||||
* @param FetchesDistrict $fetchesDistrict
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param CreatesAddress $createsAddress
|
||||
* @param RuleEvaluator $ruleEvaluator;
|
||||
* @param UpdatesCompanyEInvoiceInfo $updatesCompanyEInvoiceInfo;
|
||||
* @param CanPassEInvoicePromptedRule $canPassEInvoicePromptedRule
|
||||
*/
|
||||
public function __construct(CanCreateAddress $canCreateAddress, FetchesDistrict $fetchesDistrict, FetchesCompanyModule $fetchesCompanyModule, CreatesAddress $createsAddress, RuleEvaluator $ruleEvaluator, UpdatesCompanyEInvoiceInfo $updatesCompanyEInvoiceInfo, CanPassEInvoicePromptedRule $canPassEInvoicePromptedRule)
|
||||
{
|
||||
$this->canCreateAddress = $canCreateAddress;
|
||||
$this->fetchesDistrict = $fetchesDistrict;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createsAddress = $createsAddress;
|
||||
$this->ruleEvaluator = $ruleEvaluator;
|
||||
$this->updatesCompanyEInvoiceInfo = $updatesCompanyEInvoiceInfo;
|
||||
$this->canPassEInvoicePromptedRule = $canPassEInvoicePromptedRule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws \App\Classes\Exceptions\CriteriaNotFulfilledException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$dto = new EInvoiceInfoDTO($request->all());
|
||||
$result = $this->ruleEvaluator->evaluate([
|
||||
$this->canPassEInvoicePromptedRule,
|
||||
], $dto);
|
||||
|
||||
if ($result->failed()) {
|
||||
throw new CriteriaNotFulfilledException("- " . implode("<br>- ", $result->messages()));
|
||||
}
|
||||
|
||||
$district = $this->fetchesDistrict->execute(['id' => $dto->districtId]);
|
||||
$object = new AddressObject($dto->streetOne, $dto->streetTwo, $district->country_id, $dto->stateId, $district->id, $dto->postCode, AddressType::E_INVOICE, ApprovalStatus::APPROVED, 'E-Invoice');
|
||||
|
||||
//Update Address
|
||||
$this->canCreateAddress->passes($object);
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $dto->companyModuleId]);
|
||||
$this->createsAddress->execute($companyModule, $object);
|
||||
|
||||
//Update tin, msic code
|
||||
$this->updatesCompanyEInvoiceInfo->execute($companyModule->company, $dto->tin, $dto->msicCode);
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyEInvoiceRequest;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EInvoiceRequestDTO;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyEInvoiceRequestChangeLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated EInvoice Request',
|
||||
'message' => 'You have successfully updated company E-Invoice request'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var UpdatesCompanyEInvoiceRequest */
|
||||
private $updatesCompanyEInvoiceRequest;
|
||||
|
||||
|
||||
/**
|
||||
* UpdateCompanyEInvoiceRequestChangeLogic constructor.
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param UpdatesCompanyEInvoiceRequest $updatesCompanyEInvoiceRequest
|
||||
*/
|
||||
public function __construct(FetchesCompanyModule $fetchesCompanyModule, UpdatesCompanyEInvoiceRequest $updatesCompanyEInvoiceRequest)
|
||||
{
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->updatesCompanyEInvoiceRequest = $updatesCompanyEInvoiceRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
{
|
||||
$dto = new EInvoiceRequestDTO($request->all());
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $dto->companyModuleId]);
|
||||
|
||||
if($companyModule->company->e_invoice === 1){
|
||||
$this->updatesCompanyEInvoiceRequest->execute($companyModule->company, $dto->eInvoiceRequest);
|
||||
}
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyEInvoiceRequest;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EInvoiceRequestDTO;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyEInvoiceRequestLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated EInvoice Request',
|
||||
'message' => 'You have successfully updated company E-Invoice request'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var UpdatesCompanyEInvoiceRequest */
|
||||
private $updatesCompanyEInvoiceRequest;
|
||||
|
||||
|
||||
/**
|
||||
* UpdateCompanyEInvoiceRequestLogic constructor.
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param UpdatesCompanyEInvoiceRequest $updatesCompanyEInvoiceRequest
|
||||
*/
|
||||
public function __construct(FetchesCompanyModule $fetchesCompanyModule, UpdatesCompanyEInvoiceRequest $updatesCompanyEInvoiceRequest)
|
||||
{
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->updatesCompanyEInvoiceRequest = $updatesCompanyEInvoiceRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
{
|
||||
$dto = new EInvoiceRequestDTO($request->all());
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $dto->companyModuleId]);
|
||||
$this->updatesCompanyEInvoiceRequest->execute($companyModule->company, $dto->eInvoiceRequest);
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class EInvoiceInfoDTO implements DataTransferObject
|
||||
{
|
||||
public string $tin;
|
||||
public string $msicCode;
|
||||
public int $districtId;
|
||||
public int $stateId;
|
||||
public int $companyModuleId;
|
||||
public string $streetOne;
|
||||
public string $streetTwo;
|
||||
public string $postCode;
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->tin = (string) ($data['tin'] ?? '');
|
||||
$this->msicCode = (string) ($data['msic_code'] ?? '');
|
||||
$this->districtId = (int) ($data['district_id'] ?? 0);
|
||||
$this->stateId = (int) ($data['state_id'] ?? 0);
|
||||
$this->companyModuleId = (int) ($data['company_module_id'] ?? 0);
|
||||
$this->streetOne = (string) ($data['street_one'] ?? '');
|
||||
$this->streetTwo = (string) ($data['street_two'] ?? '');
|
||||
$this->postCode = (string) ($data['post_code'] ?? '');
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'tin' => $this->tin,
|
||||
'msic_code' => $this->msicCode,
|
||||
'district_id' => $this->districtId,
|
||||
'state_id' => $this->stateId,
|
||||
'company_module_id' => $this->companyModuleId,
|
||||
'street_one' => $this->streetOne,
|
||||
'street_two' => $this->streetTwo,
|
||||
'post_code' => $this->postCode,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class EInvoiceRequestDTO implements DataTransferObject
|
||||
{
|
||||
public bool $eInvoiceRequest;
|
||||
public int $companyModuleId;
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->eInvoiceRequest = $data['e_invoice_request'];
|
||||
$this->companyModuleId = $data['company_module_id'];
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'e_invoice_request' => $this->eInvoiceRequest,
|
||||
'company_module_id' => $this->companyModuleId,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class UpdateCompanyDetailsDTO implements DataTransferObject
|
||||
{
|
||||
public int $id;
|
||||
public string $name;
|
||||
public string $debtor;
|
||||
public string $reference;
|
||||
public int $type;
|
||||
|
||||
public string $tin;
|
||||
public string $msicCode;
|
||||
public int $addressId;
|
||||
public int $districtId;
|
||||
public int $stateId;
|
||||
public int $companyId;
|
||||
public string $streetOne;
|
||||
public string $streetTwo;
|
||||
public string $postCode;
|
||||
|
||||
public string $identificationReference;
|
||||
public int $identificationId;
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->id = (int) ($data['id'] ?? 0);
|
||||
$this->name = (string) ($data['name'] ?? '');
|
||||
$this->debtor = (string) ($data['debtor'] ?? '');
|
||||
$this->reference = (string) ($data['reference'] ?? '');
|
||||
$this->type = (int) ($data['type'] ?? 0);
|
||||
|
||||
$this->tin = (string) ($data['tin'] ?? 0);
|
||||
$this->msicCode = (string) ($data['msic_code'] ?? '');
|
||||
$this->addressId = (int) ($data['address_id'] ?? 0);
|
||||
$this->districtId = (int) ($data['district_id'] ?? 0);
|
||||
$this->stateId = (int) ($data['state_id'] ?? 0);
|
||||
$this->companyId = (int) ($data['company_id'] ?? 0);
|
||||
$this->streetOne = (string) ($data['street_one'] ?? '');
|
||||
$this->streetTwo = (string) ($data['street_two'] ?? '');
|
||||
$this->postCode = (string) ($data['post_code'] ?? '');
|
||||
$this->identificationReference = (string) ($data['identification_reference'] ?? '');
|
||||
$this->identificationId = (int) ($data['identification_id'] ?? 0);
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'debtor' => $this->debtor,
|
||||
'reference' => $this->reference,
|
||||
'type' => $this->type,
|
||||
|
||||
'tin' => $this->tin,
|
||||
'msic_code' => $this->msicCode,
|
||||
'address_id' => $this->addressId,
|
||||
'district_id' => $this->districtId,
|
||||
'state_id' => $this->stateId,
|
||||
'company_id' => $this->companyId,
|
||||
'street_one' => $this->streetOne,
|
||||
'street_two' => $this->streetTwo,
|
||||
'post_code' => $this->postCode,
|
||||
|
||||
'identification_reference' => $this->identificationReference,
|
||||
'identification_id' => $this->identificationId,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Company;
|
||||
|
||||
class UpdatesCompanyEInvoiceInfo extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Company $model
|
||||
* @param string $tin
|
||||
* @param string $msicCode
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Company $model, string $tin, string $msicCode)
|
||||
{
|
||||
$model->tin = $tin;
|
||||
$model->msic_code = $msicCode;
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Company;
|
||||
|
||||
class UpdatesCompanyEInvoiceRequest extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Company $model
|
||||
* @param bool $eInvoice
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Company $model, bool $eInvoice)
|
||||
{
|
||||
if($eInvoice){
|
||||
if (is_null($model->e_invoice_requested_at)) {
|
||||
if($eInvoice){
|
||||
$model->e_invoice_requested_at = now();
|
||||
}
|
||||
}
|
||||
$model->e_invoice = 1;
|
||||
}
|
||||
else{
|
||||
$model->e_invoice_requested_at = null;
|
||||
$model->e_invoice = 0;
|
||||
}
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -54,20 +54,11 @@ class RenderDocumentLogic extends AbstractControllerLogic
|
||||
|
||||
$this->canRenderDocument->passes();
|
||||
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
if(!Storage::disk('s3')->exists($file))
|
||||
{
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
return $this->response(['src' => explode('.', $file)[1] == 'pdf' ? chunk_split(base64_encode(Storage::disk('s3')->get($file))) : Storage::disk('s3')->get($file) ]);
|
||||
}
|
||||
else{
|
||||
if(!Storage::disk('documents')->exists($file))
|
||||
{
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
return $this->response(['src' => explode('.', $file)[1] == 'pdf' ? chunk_split(base64_encode(Storage::disk('documents')->get($file))) : Storage::disk('documents')->get($file) ]);
|
||||
if(!Storage::disk('documents')->exists($file))
|
||||
{
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
|
||||
return $this->response(['src' => explode('.', $file)[1] == 'pdf' ? chunk_split(base64_encode(Storage::disk('documents')->get($file))) : Storage::disk('documents')->get($file) ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,17 +98,13 @@ class ConvertsBase64ToFile
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
private function generateFile(FileObject $file, string $suffix = '') {
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
$filePath = 'documents/'.$this->path.'/'.$file->getFileName().$suffix.'.'.$file->getExtension();
|
||||
Storage::put($filePath, $file->getDecodedData(), 's3');
|
||||
return $filePath;
|
||||
}
|
||||
else{
|
||||
$filePath = $this->path.'/'.$file->getFileName().$suffix.'.'.$file->getExtension();
|
||||
Storage::disk('documents')->put($filePath, $file->getDecodedData());
|
||||
return $filePath;
|
||||
}
|
||||
|
||||
$filePath = $this->path.'/'.$file->getFileName().$suffix.'.'.$file->getExtension();
|
||||
|
||||
Storage::disk('documents')->put($filePath, $file->getDecodedData());
|
||||
|
||||
return $filePath;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Document;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class PendingVerificationDocument extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Document $model
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Document $model)
|
||||
{
|
||||
$model->status = ApprovalStatus::PENDING_VERIFICATION;
|
||||
$model->approver = Auth()->user()->id;
|
||||
$model->approval_date = Carbon::now();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,14 @@
|
||||
namespace App\Classes\Modules\Exports\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\General\Abstracts\Abstract2ControllerLogic;
|
||||
use App\Classes\Modules\Exports\Services\ExportsFeedback;
|
||||
use App\Classes\Modules\Exports\Standards\Rules\CanExportFeedback;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use App\Classes\General\AWSS3Helper;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
|
||||
class ExportFeedbackDataLogic extends AbstractControllerLogic
|
||||
class ExportFeedbackDataLogic extends Abstract2ControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
@@ -47,17 +44,14 @@ class ExportFeedbackDataLogic extends AbstractControllerLogic
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request) : BinaryFileResponse
|
||||
{
|
||||
$this->canExportFeedback->passes();
|
||||
|
||||
$exportFileName = 'feedback.xls';
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
return $this->response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $this->exportsFeedback) ]);
|
||||
}
|
||||
$response = $this->exportsFeedback->download('feedback.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
|
||||
return $this->response([ 'src' => null ]);
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\Abstract2ControllerLogic;
|
||||
use App\Classes\Modules\Exports\Services\ExportsFeedback;
|
||||
use App\Classes\Modules\Exports\Standards\Rules\CanExportFeedback;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use App\Classes\General\AWSS3Helper;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
||||
class ExportFeedbackDataReturnsBinaryLogic extends Abstract2ControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Feedback',
|
||||
'message' => 'You have successfully exported feedback data'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ExportsFeedback */
|
||||
private $exportsFeedback;
|
||||
|
||||
/** @var CanExportFeedback */
|
||||
private $canExportFeedback;
|
||||
|
||||
/**
|
||||
* ExportFeedbackDataLogic constructor.
|
||||
* @param ExportsFeedback $exportsFeedback
|
||||
* @param CanExportFeedback $canExportFeedback
|
||||
*/
|
||||
public function __construct(ExportsFeedback $exportsFeedback, CanExportFeedback $canExportFeedback)
|
||||
{
|
||||
$this->exportsFeedback = $exportsFeedback;
|
||||
$this->canExportFeedback = $canExportFeedback;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function logic(Request $request) : BinaryFileResponse
|
||||
{
|
||||
$this->canExportFeedback->passes();
|
||||
|
||||
$exportFileName = 'feedback.xls';
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $this->exportsFeedback) ]);
|
||||
}
|
||||
else{
|
||||
$response = $this->exportsFeedback->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,16 +3,15 @@
|
||||
namespace App\Classes\Modules\Exports\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\General\Abstracts\Abstract2ControllerLogic;
|
||||
use App\Classes\Modules\Exports\Standards\Rules\CanExportPackingList;
|
||||
use App\Classes\Modules\Exports\Services\ExportsOnHoldPackingList;
|
||||
use App\Classes\Modules\Exports\Services\ExportsPendingArrangementDeliveryList;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Classes\General\AWSS3Helper;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
|
||||
class ExportPackingListLogic extends AbstractControllerLogic
|
||||
class ExportPackingListLogic extends Abstract2ControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
@@ -51,24 +50,19 @@ class ExportPackingListLogic extends AbstractControllerLogic
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request) : BinaryFileResponse
|
||||
{
|
||||
$this->canExportPackingList->passes();
|
||||
$isSetPendingArrangement = $request->header('PendingArrangement');
|
||||
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
if($isSetPendingArrangement){
|
||||
$exportFileName = 'packing-list-delivery.xls';
|
||||
return $this->response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $this->exportsPendingArrangementDeliveryList) ]);
|
||||
}
|
||||
else{
|
||||
$exportFileName = 'packing-list-on-hold.xls';
|
||||
return $this->response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $this->exportsOnHoldPackingList) ]);
|
||||
}
|
||||
if($isSetPendingArrangement){
|
||||
$response = $this->exportsPendingArrangementDeliveryList->download('packing-list-delivery.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
}
|
||||
else {
|
||||
$response = $this->exportsOnHoldPackingList->download('packing-list-on-hold.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
}
|
||||
|
||||
return $this->response([ 'src' => null ]);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\Abstract2ControllerLogic;
|
||||
use App\Classes\Modules\Exports\Standards\Rules\CanExportPackingList;
|
||||
use App\Classes\Modules\Exports\Services\ExportsOnHoldPackingList;
|
||||
use App\Classes\Modules\Exports\Services\ExportsPendingArrangementDeliveryList;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Classes\General\AWSS3Helper;
|
||||
|
||||
class ExportPackingListReturnsBinaryLogic extends Abstract2ControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved PackingList',
|
||||
'message' => 'You have successfully exported PackingList'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ExportsOnHoldPackingList */
|
||||
private $exportsOnHoldPackingList;
|
||||
|
||||
/** @var ExportsPendingArrangementDeliveryList */
|
||||
private $exportsPendingArrangementDeliveryList;
|
||||
|
||||
/** @var CanExportPackingList */
|
||||
private $canExportPackingList;
|
||||
|
||||
/**
|
||||
* ExportPackingListLogic constructor.
|
||||
* @param ExportsPendingArrangementDeliveryList $exportsPendingArrangementDeliveryList
|
||||
* @param ExportsOnHoldPackingList $exportsOnHoldPackingList
|
||||
* @param CanExportPackingList $canExportPackingList
|
||||
*/
|
||||
public function __construct(ExportsPendingArrangementDeliveryList $exportsPendingArrangementDeliveryList, ExportsOnHoldPackingList $exportsOnHoldPackingList, CanExportPackingList $canExportPackingList)
|
||||
{
|
||||
$this->exportsPendingArrangementDeliveryList = $exportsPendingArrangementDeliveryList;
|
||||
$this->exportsOnHoldPackingList = $exportsOnHoldPackingList;
|
||||
$this->canExportPackingList = $canExportPackingList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function logic(Request $request) : BinaryFileResponse
|
||||
{
|
||||
$this->canExportPackingList->passes();
|
||||
$isSetPendingArrangement = $request->header('PendingArrangement');
|
||||
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
if($isSetPendingArrangement){
|
||||
$exportFileName = 'packing-list-delivery.xls';
|
||||
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $this->exportsPendingArrangementDeliveryList) ]);
|
||||
}
|
||||
else{
|
||||
$exportFileName = 'packing-list-on-hold.xls';
|
||||
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $this->exportsOnHoldPackingList) ]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
if($isSetPendingArrangement){
|
||||
$response = $this->exportsPendingArrangementDeliveryList->download('packing-list-delivery.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
}
|
||||
else {
|
||||
$response = $this->exportsOnHoldPackingList->download('packing-list-on-hold.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
}
|
||||
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,8 +24,8 @@ class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, Sho
|
||||
{
|
||||
$this->filters = [
|
||||
"has_invoice_status_in" => [2],
|
||||
// "packing_list_ordered_by_invoice_date" => true,
|
||||
// "with_aging_column" => true
|
||||
"packing_list_ordered_by_invoice_date" => true,
|
||||
"with_aging_column" => true
|
||||
];
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, Sho
|
||||
'Invoice Date',
|
||||
'Days',
|
||||
'Amount',
|
||||
'Credit Term Customer',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -56,16 +55,9 @@ class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, Sho
|
||||
$invDate = 'n/a';
|
||||
$invNo = 'n/a';
|
||||
$days = 'n/a';
|
||||
$isCreditTermCustomer = false;
|
||||
|
||||
if ($list->owner instanceof Order) {
|
||||
$inviterPivotInviteeReference = $list->owner->companyModule->inviters()->withPivot('invitee_reference')->first();
|
||||
$companyModule = $list->owner->companyModule;
|
||||
|
||||
$segment = $companyModule->connections()->first()->segments()->where('name', 'Credit Term Customer')->first();
|
||||
if ($segment) {
|
||||
$isCreditTermCustomer = true;
|
||||
}
|
||||
|
||||
if ($inviterPivotInviteeReference) {
|
||||
$marking = $inviterPivotInviteeReference->pivot->invitee_reference;
|
||||
@@ -95,7 +87,6 @@ class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, Sho
|
||||
$invDate,
|
||||
$days,
|
||||
$amt,
|
||||
$isCreditTermCustomer ? 'TRUE' : 'FALSE',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Models\CompanyConnection;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ExportsAllCustomersInfoForLarkSystem implements FromQuery, WithMapping, WithHeadings, ShouldAutoSize
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
protected $deduplicateMarking;
|
||||
protected $request;
|
||||
|
||||
public function __construct(Request $request, $deduplicateMarking = true)
|
||||
{
|
||||
$this->deduplicateMarking = $deduplicateMarking;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Marking',
|
||||
'Name',
|
||||
'Phone Number',
|
||||
'Email',
|
||||
'Registration Date',
|
||||
'Last Order Date',
|
||||
'Debtor Code',
|
||||
'Credit Term Customer',
|
||||
'Custom Segments',
|
||||
];
|
||||
}
|
||||
|
||||
public function query()
|
||||
{
|
||||
$baseQuery = CompanyConnection::has('invitee.company');
|
||||
|
||||
if ($this->deduplicateMarking) {
|
||||
$baseQuery->whereIn('id', function ($sub) {
|
||||
$sub->selectRaw('min(id)')
|
||||
->from('company_connections')
|
||||
->groupBy('invitee_reference');
|
||||
});
|
||||
}
|
||||
|
||||
return $baseQuery->with([
|
||||
'invitee.company.contacts',
|
||||
'invitee.company.companyModules.employees',
|
||||
'segments'
|
||||
]);
|
||||
}
|
||||
|
||||
public function map($connection): array
|
||||
{
|
||||
$company = optional(optional($connection)->invitee)->company;
|
||||
$companyModule = optional($company)->companyModules->first();
|
||||
$employee = optional($companyModule)->employees->first();
|
||||
$contact = optional($company)->contacts->first();
|
||||
|
||||
$marking = $connection->invitee_reference;
|
||||
$creditTermCustomer = $connection->is_credit_term ? 'YES' : 'NO';
|
||||
$employeeEmail = optional($employee)->email ?? '';
|
||||
$contactPhone = optional($contact)->phone ?? '';
|
||||
$segments = optional($connection->segments)->pluck('name')->implode(', ') ?: '';
|
||||
|
||||
return [
|
||||
$marking,
|
||||
optional($company)->name ?? '',
|
||||
$contactPhone,
|
||||
$employeeEmail,
|
||||
optional($company)->created_at ? $company->created_at->toDateString() : '',
|
||||
optional($company)->updated_at ? $company->updated_at->toDateString() : '',
|
||||
optional($company)->debtor ?? '',
|
||||
$creditTermCustomer,
|
||||
$segments,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -52,8 +52,7 @@ class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping,
|
||||
])
|
||||
->where('type', '=', 1)
|
||||
->where('status', '=', 2)
|
||||
->where('owner_type', Order::class)
|
||||
->whereBetween('created_at', [Carbon::now()->subMonths(12), Carbon::now()]); //Limit, 'expensive' query
|
||||
->where('owner_type', Order::class);
|
||||
|
||||
if (!is_null($this->start_date) && !is_null($this->end_date)) {
|
||||
$query->whereHas('transports', function ($q) {
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\CompanyModule;
|
||||
use Carbon\Carbon;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
@@ -30,7 +29,7 @@ class ExportsCustomersOrderLatestDate implements FromQuery, WithHeadingRow, With
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
return CompanyModule::where('type', '=', 1)->whereBetween('created_at', [Carbon::now()->subMonths(12), Carbon::now()]); //Limit, 'expensive' query;
|
||||
return CompanyModule::where('type', '=', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,4 +57,4 @@ class ExportsCustomersOrderLatestDate implements FromQuery, WithHeadingRow, With
|
||||
$order ? $order->drop_date : ''
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Group;
|
||||
use App\Models\Transaction;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ExportsGroupTransactions implements
|
||||
FromQuery,
|
||||
WithHeadings,
|
||||
WithHeadingRow,
|
||||
WithMapping,
|
||||
ShouldAutoSize
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
private $request;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'DocNo',
|
||||
'DocDate',
|
||||
'PaymentDate',
|
||||
'DebtorCode',
|
||||
'Ref',
|
||||
'ShipInfo',
|
||||
'AccNo',
|
||||
'DetailDescription',
|
||||
'FurtherDescription',
|
||||
'ProjNo',
|
||||
'DeptNo',
|
||||
'Qty',
|
||||
'UnitPrice',
|
||||
'TaxType',
|
||||
'TaxableAmt',
|
||||
'TaxRate'
|
||||
];
|
||||
}
|
||||
|
||||
public function query()
|
||||
{
|
||||
$start_date = $this->parseDate($this->request->input('startDate'));
|
||||
$end_date = $this->parseDate($this->request->input('endDate'));
|
||||
|
||||
return Group::when($start_date && $end_date, function ($query) use ($start_date, $end_date) {
|
||||
$query->whereBetween('created_at', [
|
||||
$start_date->startOfDay(),
|
||||
$end_date->endOfDay()
|
||||
]);
|
||||
})
|
||||
->when($start_date && !$end_date, function ($query) use ($start_date) {
|
||||
$query->where('created_at', '>=', $start_date->startOfDay());
|
||||
})
|
||||
->when(!$start_date && $end_date, function ($query) use ($end_date) {
|
||||
$query->where('created_at', '<=', $end_date->endOfDay());
|
||||
});
|
||||
}
|
||||
|
||||
private function parseDate($date)
|
||||
{
|
||||
return $date ? Carbon::parse($date)->startOfDay() : null;
|
||||
}
|
||||
|
||||
public function map($transaction): array
|
||||
{
|
||||
$company = $transaction->receiverCompany;
|
||||
return [
|
||||
'<<New>>', //'DocNo',
|
||||
'', //'DocDate',
|
||||
$transaction->created_at->format('m/d/Y H:m'), //'PaymentDate',
|
||||
$company->debtor, //'DebtorCode',
|
||||
$company->referece, //'Ref',
|
||||
$company->referece, //'ShipInfo',
|
||||
'500-0000', //'AccNo',
|
||||
'X1 Freight Service Charge', //'DetailDescription',
|
||||
'FurtherDescription', //'FurtherDescription',
|
||||
'M3', //'ProjNo',
|
||||
'CIEF', //'DeptNo',
|
||||
'', //'Qty',
|
||||
'', //'UnitPrice',
|
||||
'', //'TaxType',
|
||||
floatval($transaction->tax) > 0 ? number_format($transaction->tax, 2) : '0.00', //'TaxableAmt',
|
||||
'', //'TaxRate'
|
||||
];
|
||||
}
|
||||
|
||||
private function getTaxType($tax_percentage)
|
||||
{
|
||||
return floatval($tax_percentage) > 0 ? 'SV-6' : '';
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\Modules\Exports\Sheets\ContainersSheet;
|
||||
use App\Classes\Modules\Exports\Sheets\PackingListsSheet;
|
||||
use Carbon\Carbon;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;;
|
||||
|
||||
@@ -12,14 +11,6 @@ class ExportsParcel implements WithMultipleSheets
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
protected $startDate;
|
||||
protected $endDate;
|
||||
|
||||
public function __construct($startDate = null, $endDate = null) {
|
||||
$this->startDate = $startDate;
|
||||
$this->endDate = $endDate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
@@ -28,10 +19,10 @@ class ExportsParcel implements WithMultipleSheets
|
||||
{
|
||||
$sheets = [];
|
||||
|
||||
$sheets[] = new ContainersSheet($this->startDate, $this->endDate);
|
||||
$sheets[] = new PackingListsSheet($this->startDate, $this->endDate);
|
||||
$sheets[] = new ContainersSheet();
|
||||
$sheets[] = new PackingListsSheet();
|
||||
|
||||
return $sheets;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user