mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b3a296f2eb | |||
| 5a723c5fd1 | |||
| 6e9a27024b | |||
| e2e8f69f90 | |||
| e5c28faba7 | |||
| f2007b25e4 | |||
| 6389fc6600 | |||
| eb6b2943af | |||
| 5fb7ddb0ec | |||
| 91feb5b8fa | |||
| 9c98693071 | |||
| 56fb250e6f | |||
| eabfeb6724 | |||
| 8902a09337 | |||
| 0a69faeb3b | |||
| bea9507dae | |||
| 4b81666cf2 | |||
| 5d9e621920 | |||
| 4a2fb8e9e4 | |||
| ea772c3916 | |||
| 28088f7d9a | |||
| de56c21734 | |||
| f8d65d05da |
@@ -16,13 +16,15 @@ class PackingListDeliveryStatus implements Filter
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $value == 1 ? $builder->whereDoesntHave('transports') : ($value == 2 ? $builder->whereHas('transports', function (Builder $query) use ($value) {
|
||||
return $value == 1 ? $builder->whereHas('containers', function ($query){
|
||||
$query->where('containers.status', ApprovalStatus::COMPLETED);
|
||||
})->whereDoesntHave('transports') : ($value == 2 ? $builder->whereHas('transports', function (Builder $query) use ($value) {
|
||||
$query->whereDoesntHave('schedules', function (Builder $query) use ($value) {
|
||||
$query->where('status', '!=', ApprovalStatus::EXPIRED)->where('eta', '>', Carbon::now());
|
||||
$query->where('status', '!=', ApprovalStatus::EXPIRED)->where('eta', '<=', Carbon::now());
|
||||
});
|
||||
}) : $builder->whereHas('transports', function (Builder $query) use ($value) {
|
||||
$query->whereHas('schedules', function (Builder $query) use ($value) {
|
||||
$query->where('status', '!=', ApprovalStatus::EXPIRED)->where('eta', '<', Carbon::now());
|
||||
$query->where('status', '!=', ApprovalStatus::EXPIRED)->where('eta', '<=', Carbon::now());
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class TargetId implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('target_type', User::class)->where('target_id', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use App\Models\Booking;
|
||||
use App\Models\User;
|
||||
use App\Models\Wallet;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
||||
use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CallbackBillplzLogic
|
||||
{
|
||||
|
||||
|
||||
/** @var GetBillplzBill */
|
||||
private $getBillplzBill;
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var UpdatesWalletBalance */
|
||||
private $updatesWalletBalance;
|
||||
|
||||
/**
|
||||
* CallbackBillplzLogic constructor.
|
||||
* @param GetBillplzBill $getBillplzBill
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||
*/
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdatesWalletBalance $updatesWalletBalance)
|
||||
{
|
||||
$this->getBillplzBill = $getBillplzBill;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return bool|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws MalformedRequestException
|
||||
* @throws ResourceNotFoundException
|
||||
*/
|
||||
public function execute(Request $request)
|
||||
{
|
||||
$billplzXSignatureObject = new BillplzXSignatureObject($request);
|
||||
|
||||
if(!$billplzXSignatureObject->isValidSignature()){
|
||||
throw new MalformedRequestException('Billplz Payment validation failed.');
|
||||
}
|
||||
|
||||
$billPlz = $this->getBillplzBill->execute($billplzXSignatureObject->getBillPlzId());
|
||||
|
||||
if(!$billPlz) throw new ResourceNotFoundException('Billplz bill not found.');
|
||||
|
||||
$transaction = $this->fetchesTransaction->execute(['payment_reference' => $billplzXSignatureObject->getBillPlzId()]);
|
||||
|
||||
if($billPlz->state === 'paid') {
|
||||
$status = ApprovalStatus::APPROVED;
|
||||
}
|
||||
|
||||
if($billPlz->state === 'due') {
|
||||
$status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION;
|
||||
}
|
||||
|
||||
if($transaction->status !== ApprovalStatus::COMPLETED){
|
||||
|
||||
if($transaction->owner instanceof Wallet && $transaction->status !== ApprovalStatus::APPROVED && $status === ApprovalStatus::APPROVED) {
|
||||
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
|
||||
}
|
||||
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||
|
||||
}
|
||||
|
||||
|
||||
$token = Auth::fromUser(User::find(1));
|
||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||
|
||||
$marking = $transaction->owner instanceof Booking ? $transaction->booking->marking : $transaction->owner->owner->bookings()->orderBy('id', 'DESC')->first()->marking;
|
||||
|
||||
return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $marking, 'transaction' => $transaction, 'status' => $status]);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
|
||||
use ErrorException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateBillplzBillLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Billplz Bill',
|
||||
'message' => 'You have successfully created a new Bill'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatesBillplzBill */
|
||||
private $createsBillplzBill;
|
||||
|
||||
/**
|
||||
* CreateBookingLogic constructor.
|
||||
* @param CreatesBillplzBill $createsBillplzBill
|
||||
*/
|
||||
public function __construct(CreatesBillplzBill $createsBillplzBill)
|
||||
{
|
||||
$this->createsBillplzBill = $createsBillplzBill;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$billPlz = $this->createsBillplzBill->execute($request->user()->name, $request->user()->email, $request->input('description'), 200, $request->input('bankName'));
|
||||
|
||||
if(!$billPlz) throw new MalformedRequestException('Unable to get correct response from billplz server.');
|
||||
|
||||
return $this->response(['data' => $billPlz]);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\DataTransferObjects;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use function PHPSTORM_META\map;
|
||||
|
||||
class BillplzXSignatureObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $billPlzId;
|
||||
|
||||
/** @var string */
|
||||
private $status;
|
||||
|
||||
/** @var array */
|
||||
private $billPlzConstructArray;
|
||||
|
||||
/** @var string */
|
||||
private $billPlzConstructString;
|
||||
|
||||
/** @var string */
|
||||
private $billPlzComputedXSignature;
|
||||
|
||||
/** @var string */
|
||||
private $type;
|
||||
|
||||
/** @var Request */
|
||||
private $request;
|
||||
|
||||
/** @var string */
|
||||
private $requestXSignature;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
|
||||
$this->type = $request->exists('billplz') ? 'redirect' : 'callback';
|
||||
|
||||
$this->request = $this->type === 'redirect' ? $request->input('billplz') : $request;
|
||||
|
||||
$this->billPlzId = $this->request['id'];
|
||||
|
||||
$this->status = $this->request['transaction_status'];
|
||||
|
||||
$this->requestXSignature = $this->request['x_signature'];
|
||||
|
||||
$this->_constructBillplzArray()->_natSortBillplzArray()->_constructBillplzString()->_computeBillplzXSignature();
|
||||
}
|
||||
|
||||
private function _constructBillplzArray(){
|
||||
|
||||
$this->billPlzConstructArray = collect($this->request)->forget('x_signature')->map(function($item, $key){
|
||||
return $this->type === 'redirect' ? 'billplz'.$key.$item : $key.$item;
|
||||
})->toArray();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function _natCaseSortBillplzArray(){
|
||||
natcasesort($this->billPlzConstructArray);
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function _natSortBillplzArray(){
|
||||
natsort($this->billPlzConstructArray);
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function _constructBillplzString(){
|
||||
$this->billPlzConstructString = implode('|', $this->billPlzConstructArray);
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function _computeBillplzXSignature(){
|
||||
$this->billPlzComputedXSignature = hash_hmac('sha256', $this->billPlzConstructString, config('billplz.x_signature_key'));
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBillPlzId(): string
|
||||
{
|
||||
return $this->billPlzId;
|
||||
}
|
||||
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getBillPlzConstructArray(): array
|
||||
{
|
||||
return $this->billPlzConstructArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBillPlzConstructString(): string
|
||||
{
|
||||
return $this->billPlzConstructString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBillPlzComputedXSignature(): string
|
||||
{
|
||||
return $this->billPlzComputedXSignature;
|
||||
}
|
||||
|
||||
public function isValidSignature(): bool
|
||||
{
|
||||
return $this->billPlzComputedXSignature === $this->requestXSignature ? true : false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
|
||||
class CreatesBillplzBill
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $email
|
||||
* @param string $description
|
||||
* @param float $amount
|
||||
* @param string $billNumber
|
||||
* @param null|string $bankCode
|
||||
* @param null|Boolean $wallet
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null, ?bool $wallet = null) {
|
||||
try{
|
||||
// config('billplz.maybank')
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
|
||||
'collection_id' => $wallet ? config('billplz.wallet_collection_id') : config('billplz.collection_id'),
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'description' => $description,
|
||||
'amount' => $this->finalizeAmount($amount),
|
||||
'redirect_url' => route('online_payment.redirect'),
|
||||
'callback_url' => route('api.online_payment.callback'),
|
||||
'reference_1_label' => 'Bank Code',
|
||||
'reference_1' => $bankCode ? $bankCode : '',
|
||||
'reference_2_label' => 'Bill Number',
|
||||
'reference_2' => $billNumber
|
||||
]);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
$data['url'] = $data['url'].'?auto_submit=true';
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from billplz server' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected function finalizeAmount($amount){
|
||||
$number = round($amount, 2) * 100;
|
||||
return (string) $number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class GetBillplzBill
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $billPlzId
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $billPlzId) {
|
||||
try{
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$billPlzId);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from billplz server');
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
-1
@@ -14,6 +14,8 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
||||
|
||||
use App\Classes\Modules\Documents\Services\ApprovesDocument;
|
||||
use App\Classes\Modules\Notifications\DataTransferObjects\NotificationObject;
|
||||
Use App\Classes\Modules\Notifications\Processors\CreateNotificationProcessor;
|
||||
|
||||
use App\Models\Document;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -50,6 +52,9 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
/** @var UpdatesOrdersStatus */
|
||||
private $updatesOrdersStatus;
|
||||
|
||||
/** @var CreateNotificationProcessor */
|
||||
private $createNotificationProcessor;
|
||||
|
||||
/**
|
||||
* ApproveIdentificationDocumentLogic constructor.
|
||||
* @param CanApproveDocument $canApproveDocument
|
||||
@@ -58,8 +63,9 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
* @param FetchesDocument $fetchesDocument
|
||||
* @param UpdatesCompanyStatus $updatesCompanyStatus
|
||||
* @param UpdatesOrdersStatus $updatesOrdersStatus
|
||||
* @param CreateNotificationProcessor $createNotificationProcessor
|
||||
*/
|
||||
public function __construct(CanApproveDocument $canApproveDocument, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument, UpdatesCompanyStatus $updatesCompanyStatus, UpdatesOrdersStatus $updatesOrdersStatus)
|
||||
public function __construct(CanApproveDocument $canApproveDocument, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument, UpdatesCompanyStatus $updatesCompanyStatus, UpdatesOrdersStatus $updatesOrdersStatus, CreateNotificationProcessor $createNotificationProcessor)
|
||||
{
|
||||
$this->canApproveDocument = $canApproveDocument;
|
||||
$this->approvesDocument = $approvesDocument;
|
||||
@@ -67,6 +73,7 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
$this->fetchesDocument = $fetchesDocument;
|
||||
$this->updatesCompanyStatus = $updatesCompanyStatus;
|
||||
$this->updatesOrdersStatus = $updatesOrdersStatus;
|
||||
$this->createNotificationProcessor = $createNotificationProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,6 +97,16 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Notifications\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Notifications\Services\ListsNotification;
|
||||
use App\Http\Resources\NotificationResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListNotificationsLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieve Notifications',
|
||||
'message' => 'You have successfully retrieved a list of Notifications'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ListsNotification */
|
||||
private $listsNotification;
|
||||
|
||||
/**
|
||||
* ListNotificationsLogic constructor.
|
||||
* @param ListsNotification $listsNotification
|
||||
*/
|
||||
public function __construct(
|
||||
ListsNotification $listsNotification
|
||||
)
|
||||
{
|
||||
$this->listsNotification = $listsNotification;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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
|
||||
{
|
||||
|
||||
$filters = [
|
||||
// 'target_id'=>auth()->user()->id,
|
||||
// 'per_page'=>$request->route('per_page')
|
||||
];
|
||||
|
||||
$notifications = $this->listsNotification->execute($filters);
|
||||
|
||||
return $this->collectionResponse(NotificationResource::collection($notifications));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Notifications\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Notification;
|
||||
|
||||
class ListsNotification extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var Bank */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsBank constructor.
|
||||
* @param Notification $repository
|
||||
*/
|
||||
public function __construct(Notification $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
+1
-6
@@ -373,12 +373,7 @@ class FetchOrderListsFromYdPortalProcessor
|
||||
}
|
||||
}
|
||||
|
||||
if($deliveryDate){
|
||||
|
||||
if($packingList->transports){
|
||||
continue;
|
||||
}
|
||||
|
||||
if($deliveryDate && !$packingList->transports){
|
||||
$packingList->status = ApprovalStatus::COMPLETED;
|
||||
$packingList->save();
|
||||
|
||||
|
||||
+3
-4
@@ -50,9 +50,10 @@ class FetchPackingListFromVTPortalProcessor
|
||||
$query->where('status', '=', ApprovalStatus::COMPLETED);
|
||||
})->get();
|
||||
|
||||
DB::beginTransaction();
|
||||
foreach($packingLists as $packingList){
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
|
||||
$filter = '["PoNumber:=%js%\"'.$packingList->reference.'\"\u0000"]';
|
||||
|
||||
@@ -75,14 +76,12 @@ class FetchPackingListFromVTPortalProcessor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
DB::commit();
|
||||
} catch (GuzzleException $exception) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
DB::commit();
|
||||
|
||||
return [];
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
|
||||
use App\Classes\Modules\Documents\Services\ApprovesDocument;
|
||||
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
||||
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 Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ApprovePaymentTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* ApprovePaymentVerificationLogic constructor.
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param ApprovesDocument $approvesDocument
|
||||
* @param RejectsDocument $rejectsDocument
|
||||
* @param FetchesDocument $fetchesDocument
|
||||
* @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor
|
||||
*/
|
||||
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->approvesDocument = $approvesDocument;
|
||||
$this->rejectsDocument = $rejectsDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Payment Status',
|
||||
'message' => 'You have successfully updated the payment status'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var ApprovesDocument */
|
||||
private $approvesDocument;
|
||||
|
||||
/** @var RejectsDocument */
|
||||
private $rejectsDocument;
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$status = $request->route('status');
|
||||
|
||||
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('transaction_id')]);
|
||||
|
||||
$status === 'approve' ? $this->approvesDocument->execute($transaction->documents()->first()) : $this->rejectsDocument->execute($transaction->documents()->first());
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, $status === 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
|
||||
// $this->createInvoiceTransactionProcessor->execute($transaction->booking);
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesPaymentTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionDetail;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionDetailObject;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class CreatePaymentTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Create Payment Transactions',
|
||||
'message' => 'You have successfully created currency supplier transactions'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var FetchesSegmentConstant */
|
||||
private $fetchesSegmentConstant;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesPaymentTransaction */
|
||||
private $createsPaymentTransaction;
|
||||
|
||||
/** @var CreatesBillplzBill */
|
||||
private $createsBillplzBill;
|
||||
|
||||
/** @var CreatesTransactionDetail */
|
||||
private $createsTransactionDetail;
|
||||
|
||||
public function __construct(
|
||||
FetchesTransaction $fetchesTransaction,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesPaymentTransaction $createsPaymentTransaction,
|
||||
CreatesTransactionDetail $createsTransactionDetail,
|
||||
CreatesBillplzBill $createsBillplzBill
|
||||
)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsPaymentTransaction = $createsPaymentTransaction;
|
||||
$this->createsTransactionDetail = $createsTransactionDetail;
|
||||
$this->createsBillplzBill = $createsBillplzBill;
|
||||
}
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$invoice_transaction = $this->fetchesTransaction->execute(['id' => $request->input('transaction_id')]);
|
||||
$amount = $request->input('amount');
|
||||
$company_module = $invoice_transaction->owner()->first()->owner()->first()->companyModule()->first();
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
$payment_reference = null;
|
||||
if ($request->input('payment_method') == 5) {
|
||||
$payment_method = PaymentMethodType::PAYMENT_GATEWAY;
|
||||
$billPlzBill = $this->createsBillplzBill->execute(
|
||||
$company_module->name,
|
||||
$company_module->employees()->first()->email,
|
||||
'This payment is credit topup for company ref. ' . $company_module->reference, $amount, $billNumber,
|
||||
$request->input('bank_code'), true
|
||||
);
|
||||
|
||||
$payment_reference = $billPlzBill->id;
|
||||
}
|
||||
else {
|
||||
$payment_method = PaymentMethodType::CASH;
|
||||
}
|
||||
|
||||
$object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::PAYMENT,
|
||||
$company_module->id,
|
||||
1,
|
||||
1,
|
||||
$payment_method,
|
||||
$request->input('amount'),
|
||||
$request->input('amount'),
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
ApprovalStatus::PENDING_SUBMISSION,
|
||||
null,
|
||||
$payment_reference
|
||||
);
|
||||
|
||||
$payment_transaction = $this->createsPaymentTransaction->execute($invoice_transaction, $object);
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
-32
@@ -21,23 +21,10 @@ use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
|
||||
// use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
// use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
// use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
|
||||
// use App\Models\Document;
|
||||
// use App\Models\Transaction;
|
||||
// use Barryvdh\DomPDF\PDF;
|
||||
// use Carbon\Carbon;
|
||||
|
||||
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
// use Meneses\LaravelLaravelMpdf\Facades\LaravelLaravelMpdf;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
@@ -74,16 +61,6 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
|
||||
/** @var CreatesFiles */
|
||||
private $createsFile;
|
||||
|
||||
// /** @var FetchesTransaction */
|
||||
// /** @var UpdatesTransactionStatus */
|
||||
// private $updatesTransactionStatus;
|
||||
// /** @var CreatesDocument */
|
||||
// private $createsDocument;
|
||||
// /** @var CreatesFiles */
|
||||
// private $createsFile;
|
||||
// /** @var PDF */
|
||||
// private $pdf;
|
||||
|
||||
public function __construct(
|
||||
FetchesPackingList $fetchesPackingList,
|
||||
@@ -93,10 +70,6 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
CreatesTransactionDetail $createsTransactionDetail,
|
||||
CreatesDocument $createsDocument,
|
||||
CreatesFiles $createsFile
|
||||
|
||||
// CreatesDocument $createsDocument,
|
||||
// CreatesFiles $createsFile,
|
||||
// PDF $pdf
|
||||
)
|
||||
{
|
||||
|
||||
@@ -107,11 +80,6 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
$this->createsTransactionDetail = $createsTransactionDetail;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFile = $createsFile;
|
||||
|
||||
// $this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
// $this->createsDocument = $createsDocument;
|
||||
// $this->createsFile = $createsFile;
|
||||
// $this->pdf = $pdf;
|
||||
}
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyStatus;
|
||||
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\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Models\Company;
|
||||
use App\Models\Document;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UploadPaymentVerificationDocumentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Payment Verify Document',
|
||||
'message' => 'You have successfully submitted your payment verify document'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var CreatesDocument */
|
||||
private $createsDocument;
|
||||
|
||||
/** @var CreatesFiles */
|
||||
private $createsFile;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/**
|
||||
* CreatePaymentVerificationDocumentLogic constructor.
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFiles $createsFile
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
*/
|
||||
public function __construct(FetchesTransaction $fetchesTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesTransactionStatus $updatesTransactionStatus)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFile = $createsFile;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('transaction_id')]);
|
||||
|
||||
$object = new DocumentObject(
|
||||
DocumentType::CUSTOMER_PAYMENT_PROOF,
|
||||
$request->input('files'),
|
||||
'',
|
||||
ApprovalStatus::PENDING_VERIFICATION,
|
||||
'payments'
|
||||
);
|
||||
|
||||
/** @var Document $document */
|
||||
$document = $this->createsDocument->execute($transaction, $object);
|
||||
|
||||
$this->createsFile->execute($document, $object);
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, ApprovalStatus::PENDING_VERIFICATION);
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,9 @@ class TransactionObject implements DataTransferObject
|
||||
/** @var array|null */
|
||||
private $details;
|
||||
|
||||
/** @var string */
|
||||
private $paymentReference;
|
||||
|
||||
/**
|
||||
* TransactionObject constructor.
|
||||
* @param string $billNo
|
||||
@@ -92,7 +95,8 @@ class TransactionObject implements DataTransferObject
|
||||
float $serviceCharge,
|
||||
?Carbon $expiresOn,
|
||||
?int $status = ApprovalStatus::PENDING_SUBMISSION,
|
||||
?array $details = []
|
||||
?array $details = [],
|
||||
?string $paymentReference = null
|
||||
)
|
||||
{
|
||||
$this->billNo = $billNo;
|
||||
@@ -111,6 +115,7 @@ class TransactionObject implements DataTransferObject
|
||||
$this->expiresOn = $expiresOn;
|
||||
$this->status = $status;
|
||||
$this->details = $details;
|
||||
$this->paymentReference = $paymentReference;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,7 +248,11 @@ class TransactionObject implements DataTransferObject
|
||||
}, $this->details);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPaymentReference(): ?string
|
||||
{
|
||||
return $this->paymentReference;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Models\Transaction;
|
||||
|
||||
class CreatesPaymentTransaction extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
/**
|
||||
* @param TransactionObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Transaction $transaction, TransactionObject $object) {
|
||||
$model = new Transaction();
|
||||
$model->bill_no = $object->getBillNo();
|
||||
$model->type = $object->getTransactionType();
|
||||
$model->issuer = $object->getIssuer();
|
||||
$model->receiver = $object->getReceiver();
|
||||
$model->recipient_bank_account_id = $object->getRecipientBankAccountId();
|
||||
$model->payment_method = $object->getPaymentMethod();
|
||||
$model->amount = $object->getAmount();
|
||||
$model->original_amount = $object->getOriginalAmount();
|
||||
$model->currency_id = $object->getCurrencyId();
|
||||
$model->original_currency_id = $object->getOriginalCurrencyId();
|
||||
$model->currency_rate = $object->getCurrencyRate();
|
||||
$model->tax = $object->getTax();
|
||||
$model->service_charge = $object->getServiceCharge();
|
||||
$model->expires_on = $object->getExpiresOn();
|
||||
$model->status = $object->getStatus();
|
||||
|
||||
return $this->handler($transaction->transactions(), $model);
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,10 @@ final class TransactionType {
|
||||
|
||||
public const SHIPPING_INVOICE = 1;
|
||||
|
||||
public const PAYMENT = 2;
|
||||
|
||||
// public const PAYMENT_ATTEMPT = 0;
|
||||
|
||||
// public const PAYMENT = 1;
|
||||
|
||||
// public const INVOICE = 2;
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Billplz;
|
||||
|
||||
use App\Classes\Modules\Billplzs\ControllersLogic\CallbackBillplzLogic;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CallbackBillplzController
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CallbackBillplzLogic $logic
|
||||
* @return bool|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\ResourceNotFoundException
|
||||
*/
|
||||
public function callback(Request $request, CallbackBillplzLogic $logic) {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Billplz;
|
||||
|
||||
use App\Classes\Modules\Billplzs\ControllersLogic\CreateBillplzBillLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateBillplzBillController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CreateBillplzBillLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, CreateBillplzBillLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Notifications;
|
||||
|
||||
use App\Classes\Modules\Notifications\ControllersLogic\ListNotificationsLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListNotificationsController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ListNotificationsLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function list(Request $request, ListNotificationsLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\ApprovePaymentTransactionLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ApprovePaymentTransactionController
|
||||
{
|
||||
|
||||
public function approve(Request $request, ApprovePaymentTransactionLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\CreatePaymentTransactionLogic;
|
||||
|
||||
class CreatePaymentTransactionController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CreatePaymentTransactionLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, CreatePaymentTransactionLogic $logic) : JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\UploadPaymentVerificationDocumentLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UploadPaymentVerificationDocumentController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UploadPaymentVerificationDocumentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function upload(Request $request, UploadPaymentVerificationDocumentLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
|
||||
class NotificationResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'description' => $this->description,
|
||||
'long_ago' => $this->created_at->diffForHumans(),
|
||||
'created_at' => $this->created_at->format('d-m-Y')
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
@@ -140,7 +140,7 @@ class CompanyModule extends AbstractModel implements Addressable, Documentable,
|
||||
*/
|
||||
public function banks(): HasMany
|
||||
{
|
||||
return $this->HasMany(Bank::class, 'company_id');
|
||||
return $this->HasMany(BankAccount::class, 'company_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Classes\General\Interfaces\Documentable;
|
||||
use App\Classes\General\Interfaces\Transactionable;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Carbon\Carbon;
|
||||
@@ -12,7 +13,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
class Transaction extends AbstractModel implements Documentable
|
||||
class Transaction extends AbstractModel implements Documentable, Transactionable
|
||||
{
|
||||
protected $table = 'transactions';
|
||||
|
||||
@@ -29,6 +30,14 @@ class Transaction extends AbstractModel implements Documentable
|
||||
return $this->morphMany(Order::class, 'owner');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function transactions(): MorphMany
|
||||
{
|
||||
return $this->MorphMany(Transaction::class, 'owner');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'base_url' => env('BILLPLZ_BASE_URL', 'https://www.billplz.com'),
|
||||
'api_key' => env('BILLPLZ_API_KEY', '0fa4c710-761b-4a7a-a501-c2c2d02643d5'),
|
||||
'x_signature_key' => env('BILLPLZ_X_SIGNATURE_KEY', 'S-pbNVthVRsvnPfZlgLwqqOg'),
|
||||
'collection_id' => env('BILLPLZ_COLLECTION_ID', 'hev2wdjy'),
|
||||
'wallet_collection_id' => env('BILLPLZ_WALLET_COLLECTION_ID', 'hev2wdjy'),
|
||||
'redirect_url' => env('BILLPLZ_REDIRECT_URL', 'localhost'),
|
||||
'callback_url' => env('BILLPLZ_CALLBACK_URL', 'localhost'),
|
||||
'maybank' => 'MB2U0227',
|
||||
'cimb' => 'BCBB0235'
|
||||
];
|
||||
@@ -317,6 +317,12 @@ hr{
|
||||
background-color: $color-primary-lighter !important;
|
||||
}
|
||||
|
||||
.bg-primary-lighter-hover {
|
||||
&:hover {
|
||||
background-color: $color-primary-lighter !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* Complete
|
||||
------------------------------------
|
||||
*/
|
||||
|
||||
+1
-22
@@ -137,28 +137,7 @@
|
||||
</button>
|
||||
</div>
|
||||
<modal-component small type="rejectDocument">
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<h5 class="all-caps">Reject Document</h5>
|
||||
<div class="fs-11">Are you sure you want to reject this customer's identification?</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div data-dismiss="modal" class="btn btn-sm btn-default bg-master-lighter btn-block b-rad-none">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div data-dismiss="modal" class="btn btn-sm btn-danger btn-block b-rad-none" @click="approveDocument('reject')">Reject</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<reject-identification-verification-form-component :section="section" :data="item"></reject-identification-verification-form-component>
|
||||
</modal-component>
|
||||
<div class="col no-padding ml-auto">
|
||||
<button class="btn btn-md btn-block btn-success b-rad-none p-t-10 p-b-10 requestModal" data-type="approveDocument">
|
||||
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-auto text-center">
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h5 class="all-caps">Reject Document</h5>
|
||||
<div class="fs-11">Are you sure you want to reject this customer's identification?</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row text-left margin-auto m-t-10 m-b-10">
|
||||
<div class="col">
|
||||
<span class="text-danger fs-9">{{ error }}</span>
|
||||
<div class="fs-11">Reason: </div>
|
||||
<div class="row">
|
||||
<div class="col fs-11">
|
||||
<div class="b-a padding-5 w-100 m-b-5 pointer b-grey muted" :class="{'b-primary': parameters.rejectRemark === rejectRemarkItem, 'text-primary': parameters.rejectRemark === rejectRemarkItem}" v-for="rejectRemarkItem in rejectRemarkArray" @click="chooseRejectRemark(rejectRemarkItem)">{{ rejectRemarkItem }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div data-dismiss="modal" class="btn btn-sm btn-default bg-master-lighter btn-block b-rad-none">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-sm btn-danger btn-block b-rad-none" @click="approveDocument('reject')">Reject</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
import modalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
import { required } from "vuelidate/lib/validators";
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
parameters: {
|
||||
rejectRemark: null,
|
||||
},
|
||||
rejectRemarkArray: null,
|
||||
documentType: this.data.document_type === 'IDENTITY_CARD' ? 'IC' : 'SSM',
|
||||
error: null,
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
parameters: {
|
||||
rejectRemark: { required },
|
||||
}
|
||||
},
|
||||
created(){
|
||||
this.rejectRemarkArray = [
|
||||
this.documentType + ' not clear',
|
||||
this.documentType + ' name different with registration name',
|
||||
'Wrong Document uploaded',
|
||||
'Non-Malaysian ' + this.documentType + ' Uploaded',
|
||||
this.documentType + ' not Genuine'
|
||||
];
|
||||
},
|
||||
methods: {
|
||||
approveDocument(status){
|
||||
this.parameters.rejectRemark === null ? this.error = 'Please choose a remark.' : null;
|
||||
this.isLoading = true;
|
||||
this.submit(this.route('api.company.identification.approval', this.item.owner.id, this.item.id, status), 'put', 'identificationVerificationSection', true, true);
|
||||
},
|
||||
chooseRejectRemark(remark) {
|
||||
this.parameters.rejectRemark = remark;
|
||||
}
|
||||
},
|
||||
mixins: [componentHandler, modalFormHandler]
|
||||
|
||||
}
|
||||
</script>
|
||||
-2
@@ -11,7 +11,6 @@
|
||||
<on-boarding-section-component v-if="!company.last_order"></on-boarding-section-component>
|
||||
<div class="row" v-if="company.last_order">
|
||||
<div class="col">
|
||||
<!-- new swction -->
|
||||
<div class="row tabsContainer">
|
||||
<div class="col no-padding">
|
||||
<div class="row m-l-0 m-r-0">
|
||||
@@ -127,7 +126,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end new swction -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="btn-group">
|
||||
<i class="fa fa-bell fs-18 m-t-5 muted pointer" :class="{'text-primary' : isClicked}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" @click="openNotification()"></i>
|
||||
<div class="b-rad-md dropdown-menu dropdown-menu-right p-l-15 p-b-15 p-r-15 p-t-0" style="width: 100vw; height: 100vh; background: transparent !important;" @click="openNotification()">
|
||||
<div class="row shadow" style="width: 320px; position: absolute; top: 50px; right: 50px; background: white!important;">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="bg-master-lighter col p-l-10 p-l-10 p-t-10 bg-white text-center">
|
||||
<p>Notification Center</p>
|
||||
</div>
|
||||
</div>
|
||||
<loading-component style="height: 200px; top: 0;" key="1" color="primary" v-show="isLoading"></loading-component>
|
||||
<div class="row" :class="{'h-100' : notificationsLength >= 5}" v-show="!isLoading" style="max-height: 400px; ">
|
||||
<div class="col page-container overflow-hidden">
|
||||
<div class="row b-b b-grey bg-primary-lighter-hover pointer w-100 m-l-0 m-r-0" v-for="(notification, index) in notifications">
|
||||
<div class="col-auto justify-content-center align-items-center d-flex hide">
|
||||
<div>
|
||||
<i class="fa fa-check-circle fs-20 p-l-5 text-success"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col padding-10 p-l-15 p-r-15">
|
||||
<p class="bold m-b-5 lh-16">{{ notification.title }}</p>
|
||||
<p class="fs-9 m-b-0 lh-10">{{ notification.description }}</p>
|
||||
<p class="fs-9 m-b-0 m-t-10 lh-10">{{ notification.long_ago }}</p>
|
||||
</div>
|
||||
<div class="col-auto justify-content-center align-items-center d-none" :class="{'d-flex' : index === 0}">
|
||||
<div>
|
||||
<i class="fa fa-circle fs-10 text-primary"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row text-center m-t-50 m-b-50" v-if="notificationsLength === 0" v-show="!isLoading">
|
||||
<div class="col">
|
||||
<div class="row align-items-center justify-content-center hint-text">
|
||||
<div class="col-4 hint-text"><img src="/images/not-found-illustration.png" class="w-100 hint-text"/></div>
|
||||
</div>
|
||||
<div class="row text-center">
|
||||
<div class="col">
|
||||
<div class="row m-t-20">
|
||||
<div class="col">
|
||||
<p class="all-caps no-margin fs-11" style="letter-spacing: 2px;">Nothing To Show Here</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-5 align-items-center justify-content-center hide">
|
||||
<div class="col">
|
||||
<small class="fs-9 muted all-caps font-lato" style="letter-spacing: 2px">There is no results found.</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row b-t muted">
|
||||
<div class="col p-l-10 p-l-10 p-t-10 m-b-10 bg-white text-center">
|
||||
<a href="#">View All Notifications</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
isLoading: true,
|
||||
error: '',
|
||||
notifications: null,
|
||||
isClicked: false,
|
||||
notificationsLength: 0,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
openNotification(){
|
||||
this.isClicked === false ? this.fetchNotification() : '';
|
||||
this.isClicked = !this.isClicked;
|
||||
},
|
||||
fetchNotification(){
|
||||
this.isLoading = true;
|
||||
this.submit(route('notifications.list'), 'get', this.section, false, false)
|
||||
},
|
||||
successHandler(response){
|
||||
this.isLoading = false;
|
||||
this.notifications = response.payload.data;
|
||||
this.notificationsLength = response.payload.data.length;
|
||||
},
|
||||
},
|
||||
mixins: [ModalFormHandler]
|
||||
}
|
||||
</script>
|
||||
@@ -85,7 +85,7 @@
|
||||
<div class="col">Delivery Date</div>
|
||||
<div class="col text-right">Action</div>
|
||||
</div>
|
||||
<list-component section="activeContainerListSection" :endpoint="route('api.packing_list.list')" :options="{'packing_list_delivery_status': 1, 'per_page': 30}">
|
||||
<list-component section="activeContainerListSection" :endpoint="route('api.packing_list.list')" :options="{type: 2, 'packing_list_delivery_status': 1, 'per_page': 30}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<warehouse-packing-list-component :data="data"></warehouse-packing-list-component>
|
||||
</template>
|
||||
@@ -103,7 +103,7 @@
|
||||
<div class="col">status</div>
|
||||
<div class="col">Delivery Date</div>
|
||||
</div>
|
||||
<list-component section="arrivedContainerListSection" :endpoint="route('api.packing_list.list')" :options="{'packing_list_delivery_status': 2 , 'per_page': 30}">
|
||||
<list-component section="arrivedContainerListSection" :endpoint="route('api.packing_list.list')" :options="{type: 2, 'packing_list_delivery_status': 2,'per_page': 30}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<warehouse-packing-list-component :data="data"></warehouse-packing-list-component>
|
||||
</template>
|
||||
@@ -121,7 +121,7 @@
|
||||
<div class="col">status</div>
|
||||
<div class="col">Delivery Date</div>
|
||||
</div>
|
||||
<list-component section="completeContainerListSection" :endpoint="route('api.packing_list.list')" :options="{'packing_list_delivery_status': 3, 'per_page': 30}">
|
||||
<list-component section="completeContainerListSection" :endpoint="route('api.packing_list.list')" :options="{type: 2, 'packing_list_delivery_status': 3, 'per_page': 30}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<warehouse-packing-list-component :data="data"></warehouse-packing-list-component>
|
||||
</template>
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<notification-section-component section="section"></notification-section-component>
|
||||
</div>
|
||||
<div class="col-auto p-r-20 d-md-none">
|
||||
<div class="row d-md-none">
|
||||
<div class="col padding-15 pointer" @click="$store.dispatch('toggleSection', {name: 'sideMenu', status: true})">
|
||||
|
||||
@@ -26,6 +26,8 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function
|
||||
|
||||
Route::get('/storage/{fileName}/fetch', 'Documents\RenderDocumentController@fileStorageServe')->where(['fileName' => '.*'])->name('storage.document.file');
|
||||
|
||||
Route::post('online_payment/callback', 'Billplz\CallbackBillplzController@callback')->name('online_payment.callback');
|
||||
|
||||
require __DIR__ . '/company.php';
|
||||
|
||||
require __DIR__ . '/document.php';
|
||||
|
||||
@@ -7,8 +7,20 @@ Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' =>
|
||||
Route::get('/list', 'ListTransactionsController@list')->name('list');
|
||||
// Route::delete('/suspend/{id}', 'SuspendTransactionController@suspend')->name('suspend');
|
||||
|
||||
Route::post('/payment/create', 'CreatePaymentTransactionController@create')->name('payment.create');
|
||||
Route::post('/payment/upload-verification-document/{transaction_id}', 'UploadPaymentVerificationDocumentController@upload')->name('verification.create');
|
||||
Route::put('/payment/approve/{transaction_id}/{status}', 'ApprovePaymentTransactionController@approve')->where('status', 'approve|reject')->name('approval');
|
||||
|
||||
|
||||
route::post('/shipping-invoice/create', 'CreateShippingInvoiceTransactionController@create')->name('supplier.create');
|
||||
|
||||
// Route::group(['prefix' => '{id}/payment', 'as' => 'payment.'], function () {
|
||||
// Route::post('quotation', 'FetchBookingPaymentQuotationController@fetch')->name('quotation');
|
||||
// Route::post('create', 'CreateBookingPaymentController@create')->name('create');
|
||||
// Route::post('{payment_id}/verification/create', 'CreatePaymentVerificationController@create')->name('verification.create');
|
||||
// Route::put('/{payment_id}/approval/{status}', 'ApprovePaymentVerificationController@approve')->where('status', 'approve|reject')->name('approval');
|
||||
// });
|
||||
|
||||
|
||||
// route::post('{id}/bill/verification', 'CreatePaymentProofDocumentController@verify')->name('bill.verification');
|
||||
|
||||
|
||||
+5
-1
@@ -271,4 +271,8 @@ Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{ina
|
||||
echo $key + 1 .'. <a href="'.\route('customer.profile', $marking).'" target="_blank">'.$marking.'</a> '.$totalCbm.'<br><br>';
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Route::get('/online_payment/redirect', 'Billplz\CallbackBillplzController@callback')->name('online_payment.redirect');
|
||||
|
||||
Route::get('/notifications/list', 'Notifications\ListNotificationsController@list')->name('notifications.list');
|
||||
|
||||
Reference in New Issue
Block a user