mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ac8ec13433 | |||
| c73e86e2cf |
Vendored
+807
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
yarnPath: ".yarn/releases/yarn-berry.cjs"
|
||||
@@ -95,4 +95,4 @@ abstract class AbstractControllerLogic
|
||||
return $this->response(json_decode($collection->response()->getContent(), true));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,10 @@ abstract class AbstractUpdateRecord
|
||||
public function handler(Model $model){
|
||||
try{
|
||||
|
||||
if($model->save()){ return $model; }
|
||||
if($model->save()) {
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
} catch (QueryException $exception){
|
||||
throw new MalformedRequestException($exception);
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use DB;
|
||||
|
||||
trait logData
|
||||
{
|
||||
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
|
||||
static::updating(function($model)
|
||||
{
|
||||
|
||||
if (!Schema::hasTable(''.$model->table.'log')) {
|
||||
DB::statement('CREATE TABLE '.$model->table.'log LIKE '.$model->table);
|
||||
DB::statement('ALTER TABLE '.$model->table.'log DROP COLUMN id');
|
||||
DB::statement('ALTER TABLE '.$model->table.'log ADD id INTEGER FIRST');
|
||||
}
|
||||
|
||||
DB::table(''.$model->table.'log')->insert($model->getRawOriginal());
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function logs($model){
|
||||
$result = DB::table(''.$model->table.'log')
|
||||
->where('id', $model->id)
|
||||
->get();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Traits;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
trait LogData
|
||||
{
|
||||
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
|
||||
static::updating(function($model)
|
||||
{
|
||||
|
||||
$tableName = Str::singular($model->table).'_logs';
|
||||
$relationshipColumn = Str::singular($model->table).'_id';
|
||||
|
||||
$originalData = $model->getRawOriginal();
|
||||
|
||||
$originalData[$relationshipColumn] = $originalData['id'];
|
||||
unset($originalData['id']);
|
||||
|
||||
if (!Schema::hasTable($tableName)) {
|
||||
DB::statement('CREATE TABLE '.$tableName.' LIKE '.$model->table);
|
||||
|
||||
$indexs = DB::select('SHOW INDEX FROM '.$tableName.';');
|
||||
|
||||
$removedIndexes = [];
|
||||
foreach ($indexs as $index){
|
||||
if($index->Column_name === 'id' || in_array($index->Key_name, $removedIndexes)) continue;
|
||||
DB::statement('ALTER TABLE '.$tableName.' drop index '.$index->Key_name);
|
||||
$removedIndexes[] = $index->Key_name;
|
||||
}
|
||||
|
||||
DB::statement('ALTER TABLE '.$tableName.' ADD COLUMN `'.$relationshipColumn.'` BIGINT NOT NULL AFTER `id`');
|
||||
}
|
||||
|
||||
DB::table($tableName)->insert($originalData);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\multipleInvoicesWithOnePaymentLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
@@ -44,6 +46,10 @@ class CallbackBillplzLogic
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $multipleInvoicesWithOnePaymentLogic ;
|
||||
|
||||
/**
|
||||
* CallbackBillplzLogic constructor.
|
||||
* @param GetBillplzBill $getBillplzBill
|
||||
@@ -52,13 +58,14 @@ class CallbackBillplzLogic
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
*/
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor)
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor,multipleInvoicesWithOnePaymentLogic $multipleInvoicesWithOnePaymentLogic)
|
||||
{
|
||||
$this->getBillplzBill = $getBillplzBill;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->multipleInvoicesWithOnePaymentLogic= $multipleInvoicesWithOnePaymentLogic;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,12 +91,19 @@ class CallbackBillplzLogic
|
||||
|
||||
$transaction = $this->fetchesTransaction->execute(['payment_reference' => $billplzXSignatureObject->getBillPlzId()]);
|
||||
|
||||
|
||||
if ($transaction->type == 'topUp') {
|
||||
$this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED);
|
||||
$this->multipleInvoicesWithOnePaymentLogic->verifypayment($transaction->id, $transaction->amount);
|
||||
}
|
||||
|
||||
$invoice = $transaction->owner;
|
||||
$packingList = $invoice->owner;
|
||||
$order = $packingList->owner;
|
||||
|
||||
$status = ApprovalStatus::PENDING_VERIFICATION;
|
||||
|
||||
|
||||
if($billPlz->state === 'paid') {
|
||||
$status = ApprovalStatus::APPROVED;
|
||||
}
|
||||
@@ -118,6 +132,7 @@ class CallbackBillplzLogic
|
||||
|
||||
|
||||
|
||||
|
||||
return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $order->reference, 'transaction' => $transaction, 'status' => $status]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Imports\Services;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchOrderListsFromExcel;
|
||||
|
||||
class Importorder implements ToCollection
|
||||
{
|
||||
/**
|
||||
* @param Collection $collection
|
||||
*/
|
||||
public function collection(Collection $collection)
|
||||
{
|
||||
// dd($collection);
|
||||
(App()->make(FetchOrderListsFromExcel::class))->execute($collection);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,488 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromYDPortal;
|
||||
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
||||
use App\Classes\Modules\Steps\Services\CreatesStep;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\Modules\Unity\Processors\ActivateContractProcessor;
|
||||
use App\Classes\Modules\Unity\Processors\AssignContractEntityProcessor;
|
||||
use App\Classes\Modules\Unity\Processors\CreateContractEntityProcessor;
|
||||
use App\Classes\Modules\Unity\Services\CreatesContract;
|
||||
use App\Classes\Modules\Unity\Services\UpdatesContractObligation;
|
||||
use App\Classes\Notifications\ShipmentDepartureEmail;
|
||||
use App\Classes\Notifications\ShipmentRescheduleEmail;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\ContainerTypes;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Models\Container;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transport;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class FetchOrderListsFromExcel
|
||||
{
|
||||
/** @var FetchesDataFromYDPortal */
|
||||
private $fetchesDataFRomYDPortal;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/** @var UpdatesContractObligation */
|
||||
private $updatesContractObligations;
|
||||
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
/** @var CreatePackageProcessor */
|
||||
private $createPackageProcessor;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreateContainerProcessor */
|
||||
private $createContainerProcessor;
|
||||
|
||||
/** @var CreatesContract */
|
||||
private $unityCreateContract;
|
||||
|
||||
/** @var AssignContractEntityProcessor */
|
||||
private $unityAssignContractEntity;
|
||||
|
||||
/** @var CreateContractEntityProcessor */
|
||||
private $unityCreateContractEntity;
|
||||
|
||||
/** @var CreatesStep */
|
||||
private $createsStep;
|
||||
|
||||
/** @var ActivateContractProcessor */
|
||||
private $unityActivateContract;
|
||||
|
||||
/**
|
||||
* FetchOrderListsFromYdPortalProcessor constructor.
|
||||
* @param FetchesDataFromYDPortal $fetchesDataFRomYDPortal
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
* @param UpdatesContractObligation $updatesContractObligations
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
* @param CreatePackageProcessor $createPackageProcessor
|
||||
* @param CreatesTransport $createsTransport
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param CreateContainerProcessor $createContainerProcessor
|
||||
* @param CreatesContract $unityCreateContract
|
||||
* @param AssignContractEntityProcessor $unityAssignContractEntity
|
||||
* @param CreateContractEntityProcessor $unityCreateContractEntity
|
||||
* @param CreatesStep $createsStep
|
||||
* @param ActivateContractProcessor $unityActivateContract
|
||||
*/
|
||||
public function __construct(FetchesDataFromYDPortal $fetchesDataFRomYDPortal , FetchesOrder $fetchesOrder, UpdatesContractObligation $updatesContractObligations, CreatePackingListProcessor $createPackingListProcessor, CreatePackageProcessor $createPackageProcessor, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule, FetchesContainer $fetchesContainer, FetchesPackingList $fetchesPackingList, FetchesCompanyModule $fetchesCompanyModule, CreateContainerProcessor $createContainerProcessor, CreatesContract $unityCreateContract, AssignContractEntityProcessor $unityAssignContractEntity, CreateContractEntityProcessor $unityCreateContractEntity, CreatesStep $createsStep, ActivateContractProcessor $unityActivateContract)
|
||||
{
|
||||
$this->fetchesDataFRomYDPortal = $fetchesDataFRomYDPortal;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
$this->updatesContractObligations = $updatesContractObligations;
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
$this->createPackageProcessor = $createPackageProcessor;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createContainerProcessor = $createContainerProcessor;
|
||||
$this->unityCreateContract = $unityCreateContract;
|
||||
$this->unityAssignContractEntity = $unityAssignContractEntity;
|
||||
$this->unityCreateContractEntity = $unityCreateContractEntity;
|
||||
$this->createsStep = $createsStep;
|
||||
$this->unityActivateContract = $unityActivateContract;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @return void
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function execute( $excelData )
|
||||
{
|
||||
try {
|
||||
// dd($start);
|
||||
// $start = $start ? $start : Carbon::today()->subDays(30);
|
||||
|
||||
// $startLimit = Carbon::parse('01-12-2021');
|
||||
|
||||
// if($start->isBefore($startLimit)){
|
||||
// $start = $startLimit;
|
||||
// }
|
||||
|
||||
// $end = $end ? $end : Carbon::today()->addDay();
|
||||
|
||||
// $orderRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/GetOrderList.ashx', 'GET', [
|
||||
// 'begintime' => $start->timestamp,
|
||||
// 'endtime' => $end->timestamp,
|
||||
// ]);
|
||||
|
||||
// $rows = $this->fetchesDataFRomYDPortal->getResponseBody($orderRequest);
|
||||
|
||||
foreach($excelData as $row){
|
||||
|
||||
if("expressno"!= $row[0] && $row[0] != null){
|
||||
// dd($row[0]);
|
||||
|
||||
|
||||
$containerReference = null;
|
||||
$loadingDate = null;
|
||||
$unstuffingDate = null;
|
||||
$deliveryDate = null;
|
||||
$etd = null;
|
||||
$eta = null;
|
||||
$delayDate = null;
|
||||
|
||||
$trackingRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/ApiTracking.ashx', 'GET', [
|
||||
'trakingno' => $row[0]
|
||||
]);
|
||||
|
||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($trackingRequest);
|
||||
if($rows->data == null){
|
||||
continue;
|
||||
}else{
|
||||
|
||||
dd($rows);
|
||||
}
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
if(!$rows){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
foreach (array_reverse($rows->data) as $trackingRow) {
|
||||
if ($trackingRow->tracking === '货物已送达仓库准备入库中') {
|
||||
$receiveDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
|
||||
if (strpos($trackingRow->tracking, '货物装柜完成。') !== false) {
|
||||
$tracking = explode(':', $trackingRow->tracking);
|
||||
$containerReference = explode('预计到港时间', $tracking[1])[0];
|
||||
$loadingDate = Carbon::parse($trackingRow->trackingtime);
|
||||
$etd = Carbon::parse($tracking[2])->subDays(5);
|
||||
$eta = Carbon::parse($tracking[2])->addDays(2);
|
||||
}
|
||||
|
||||
$rescheduleETD = strpos($trackingRow->remark, '开') || strpos($trackingRow->remark, '到港');
|
||||
$rescheduleETA = strpos($trackingRow->remark, '到港');
|
||||
if (($rescheduleETD !== false || $rescheduleETA !== false) && strpos($trackingRow->tracking, '货物装柜完成。') === false) {
|
||||
preg_match_all('/([0-9]+.{3})/', $trackingRow->remark, $matches);
|
||||
$dates = collect();
|
||||
|
||||
foreach($matches[0] as $date){
|
||||
try {
|
||||
$dates->push(Carbon::parse(str_replace('.', '/', $date).Carbon::now()->format('Y')));
|
||||
} catch (\Exception $exception) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$rescheduleDate = $dates->sortDesc()->first();
|
||||
|
||||
if(!$delayDate || $rescheduleDate > $delayDate){
|
||||
/** @var Carbon $delayDate */
|
||||
$delayDate = $rescheduleDate;
|
||||
|
||||
if($rescheduleETA === false && $delayDate) {
|
||||
$delayDate = $delayDate->addDays('5');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($trackingRow->tracking === '到港') {
|
||||
$delayDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
|
||||
if ($trackingRow->tracking === '已开船') {
|
||||
$delayDate = Carbon::parse($trackingRow->trackingtime)->addDays('5');
|
||||
}
|
||||
|
||||
if ($trackingRow->tracking === '货物已进目的港仓库') {
|
||||
$unstuffingDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
|
||||
if (Str::contains($trackingRow->tracking, ['派送中', '已签收', '签收完成', ' 第三方提货', '货物已派送完成', '派送', 'delivery', 'delivered'])) {
|
||||
$deliveryDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
}
|
||||
|
||||
$client = new \GuzzleHttp\Client(['cookies' => true, 'headers' => ['Cookie' => 'utc_offset=480']]);
|
||||
|
||||
try {
|
||||
$request = $client->request('get', 'https://main.universe.com.my/Tracking/User/Paging?sEcho=1&sTrackingNo='.$row->expressno.'&sOrgId=sti');
|
||||
$deliveryTracking = json_decode($request->getBody()->getContents());
|
||||
foreach (array_reverse($deliveryTracking->aaData) as $trackingRow) {
|
||||
$trackingDate = Carbon::createFromFormat('d/m/y H:i', $trackingRow->LocalDateTime);
|
||||
if (Str::contains($trackingRow->PublicDescription, ['accepted/picked'])){
|
||||
$unstuffingDate = $trackingDate;
|
||||
}
|
||||
|
||||
if (Str::contains($trackingRow->PublicDescription, ['delivered'])) {
|
||||
$deliveryDate = $trackingDate;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $exception){
|
||||
Log::debug('failed to fetch delivery tracking');
|
||||
}
|
||||
|
||||
$customerno = preg_split('(-|\(|\)|\/)', $row->customerno);
|
||||
|
||||
$orderNumber = $customerno[array_key_last($customerno)];
|
||||
$allow_contract = true;
|
||||
|
||||
try {
|
||||
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
try {
|
||||
$order = $this->fetchesOrder->execute(['reference' => substr($orderNumber, -9)]);
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
$order = $this->fetchesCompanyModule->execute(['id' => 1]);
|
||||
$allow_contract = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$packingListReference = $row->expressno;
|
||||
|
||||
try{
|
||||
$packingList = $this->fetchesPackingList->execute(['reference' => $row->expressno, 'type' => PackingListType::SHIPPING_PACKING_LIST]);
|
||||
|
||||
$packingList->packages()->delete();
|
||||
$replica = $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
if($replica) $replica->packages()->delete();
|
||||
|
||||
$warehouseReceiveList = $this->fetchesPackingList->execute(['reference' => $row->expressno, 'type' => PackingListType::WAREHOUSE_RECEIVE_LIST]);
|
||||
$warehouseReceiveList->packages()->delete();
|
||||
$replica = $warehouseReceiveList->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST_REPLICA)->first();
|
||||
if($replica) $replica->packages()->delete();
|
||||
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
|
||||
if (!$allow_contract) {
|
||||
$appointee_id = 2037;
|
||||
} else {
|
||||
$appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
||||
}
|
||||
|
||||
$warehouseReceiveObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::WAREHOUSE_RECEIVE_LIST, $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
|
||||
/** @var PackingList $warehouseReceiveList */
|
||||
$warehouseReceiveList = $this->createPackingListProcessor->execute($warehouseReceiveObject, $order);
|
||||
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, $row->kuaidilist, Carbon::parse($receiveDate), Carbon::parse($receiveDate), $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
$transport = $this->createsTransport->execute($transportObject, $warehouseReceiveList);
|
||||
|
||||
if ($allow_contract) {
|
||||
|
||||
$contract = $this->unityCreateContract->execute();
|
||||
|
||||
$contractReference = $contract->hash_id;
|
||||
$contractObligations = $contract->contract_obligation_list;
|
||||
|
||||
$this->unityActivateContract->execute($contractReference);
|
||||
|
||||
$supervisorHashId = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->unity_hash_id;
|
||||
|
||||
$supervisorContractEntity = $this->unityCreateContractEntity->execute($contractReference, $supervisorHashId);
|
||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->update(['entity_hash_id' => $supervisorContractEntity->hash_id, 'entity_signature' => $supervisorContractEntity->entity_signature_hash_id]);
|
||||
|
||||
$importerContractEntity = $this->unityCreateContractEntity->execute($contractReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->appointee->unity_hash_id);
|
||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->update(['entity_hash_id' => $importerContractEntity->hash_id, 'entity_signature' => $importerContractEntity->entity_signature_hash_id]);
|
||||
|
||||
$this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations);
|
||||
}
|
||||
|
||||
$packingListObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::SUSPENDED, !$allow_contract ? null : $contractReference);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
if ($allow_contract) {
|
||||
foreach ($contractObligations as $obligation) {
|
||||
$stepObject = new StepsObject($order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->id, $obligation->reference, $obligation->sequence, $obligation->hash_id);
|
||||
$this->createsStep->execute($packingList, $stepObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($row->deliverysize as $package) {
|
||||
$packageObject = new PackageObject(PackageType::CARTON, $row->goodname, (float) $package->width, (float) $package->height, (float) $package->length, 0, (float) $package->num, ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $warehouseReceiveList);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
if(!count($row->deliverysize)){
|
||||
$measurement = round(((float) $row->volume / (float) $row->goodcount) ** (1/3) * 100, 2);
|
||||
$packageObject = new PackageObject(PackageType::CARTON, $row->goodname, (float) $measurement, (float) $measurement, (float) $measurement, 0, (float) $row->goodcount, ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $warehouseReceiveList);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
$weightCbm = (float) $row->weight / 500;
|
||||
$overWeightCbm = $weightCbm - $packingList->packages()->sum(DB::raw('(width/100) * (height/100) * (length/100) * quantity'));
|
||||
|
||||
if($overWeightCbm > 0){
|
||||
$measurement = round($overWeightCbm ** (1/3) * 100, 2);
|
||||
$packageObject = new PackageObject(PackageType::OVER_WEIGHT, 'Overweight CBM', (float) $measurement, (float) $measurement, (float) $measurement, 0, 1, ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
if($order instanceof Order){
|
||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
if(!in_array($marking, ['1290CSW', '8997ITB', '3992WHE', '962LOW', '1152AAT'])){
|
||||
$this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/confirmsendorder.ashx', 'GET', [
|
||||
'expressno' => $row->expressno
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($containerReference) {
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['reference' => $containerReference]);
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList);
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
|
||||
if (!$allow_contract) {
|
||||
$appointee_id = 2037;
|
||||
}
|
||||
else {
|
||||
$appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->id;
|
||||
}
|
||||
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $appointee_id]);
|
||||
|
||||
$containerObject = new ContainerObject($containerReference, '', '', ContainerTypes::FORTY_FEET_DRY_CONTAINER, $loadingDate, ApprovalStatus::PENDING_VERIFICATION);
|
||||
/** @var Container $container */
|
||||
$container = $this->createContainerProcessor->execute($containerObject, $originWarehouse);
|
||||
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList);
|
||||
|
||||
$transport = $container->transports()->first();
|
||||
|
||||
if(!$transport){
|
||||
$transportObject = new TransportObject(TransportType::SEA, null, null, $etd, null, ApprovalStatus::APPROVED);
|
||||
/** @var Transport $transport */
|
||||
$transport = $this->createsTransport->execute($transportObject, $container);
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $eta, ApprovalStatus::APPROVED));
|
||||
}
|
||||
}
|
||||
|
||||
if($delayDate){
|
||||
$delayDate = $delayDate->addDays(2);
|
||||
$transport = $container->transports()->first();
|
||||
|
||||
if(!$transport->schedules()->whereDate('eta', '>=', $delayDate)->first()) {
|
||||
$etd = $transport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->etd;
|
||||
$transport->schedules()->update(['status' => ApprovalStatus::EXPIRED]);
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $delayDate, ApprovalStatus::APPROVED));
|
||||
foreach ($container->packingLists as $packingList){
|
||||
if(!($packingList->owner instanceof Order)) continue;
|
||||
$user = $packingList->owner->companyModule->employees()->first();
|
||||
if(app()->environment(['production'])) {
|
||||
$user->notify(new ShipmentRescheduleEmail($user, $packingList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($unstuffingDate && $container->status !== ApprovalStatus::COMPLETED){
|
||||
$container->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
$container->transports()->first()->update(['drop_date' => $unstuffingDate, 'status' => ApprovalStatus::COMPLETED]);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
foreach($container->packingLists as $packingList){
|
||||
|
||||
if($packingList->status === ApprovalStatus::PENDING_VERIFICATION){
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
}
|
||||
|
||||
if ($allow_contract) {
|
||||
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
||||
foreach($packingList->steps()->where('reference', '!=', 'DELIVERY')->get() as $step){
|
||||
$this->updatesContractObligations->execute($signature, $step->obligation_hash_id);
|
||||
$step->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($deliveryDate && !$packingList->transports()->exists()){
|
||||
$packingList->status = ApprovalStatus::COMPLETED;
|
||||
$packingList->save();
|
||||
|
||||
$deliveryDate = Carbon::parse($deliveryDate);
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, null, $deliveryDate, $deliveryDate, ApprovalStatus::APPROVED);
|
||||
/** @var Transport $transport */
|
||||
$transport = $this->createsTransport->execute($transportObject, $packingList);
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($deliveryDate, $deliveryDate, ApprovalStatus::APPROVED));
|
||||
|
||||
|
||||
if ($allow_contract) {
|
||||
$deliveryStep = $packingList->steps()->where('reference', '=', 'LAST_MILE_DELIVERY')->first();
|
||||
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
||||
$this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id);
|
||||
$deliveryStep->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo 'successful';
|
||||
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
Log::debug($exception);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -25,7 +25,6 @@ use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\ValueObjects\Constants\TransactionDetailType;
|
||||
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Document;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transaction;
|
||||
@@ -121,7 +120,11 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
|
||||
$noMinimumCharge = $connection->segments()->where('segments.id', 2)->first();
|
||||
|
||||
$base_price = 0;
|
||||
$warehouse_rate = 0;
|
||||
$state_rate = 0;
|
||||
$minimum_cbm = 0.3;
|
||||
$segment_price = 0;
|
||||
$state_select = '';
|
||||
|
||||
$segment_price = $connection->segments()->whereHas('constants', function($query){
|
||||
@@ -153,7 +156,6 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
$hasMinimumCharge = null;
|
||||
|
||||
foreach ($container->packingLists as $packingList){
|
||||
if($packingList->owner instanceof CompanyModule) continue;
|
||||
if($packingList->owner->companyModule->id !== $companyModule->id) continue;
|
||||
$containerPackingLists->push($packingList);
|
||||
|
||||
@@ -168,13 +170,13 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
||||
$totalContainerCbm = $containerPackingLists->sum(function($packingList){
|
||||
$billable_packing_list = $packingList->packingLists()->first();
|
||||
$billable_packing_list = $billable_packing_list ? $billable_packing_list : $packingList;
|
||||
return $billable_packing_list->packages->sum(function($package) {
|
||||
return $billable_packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum(function($package) {
|
||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||
});
|
||||
});
|
||||
|
||||
$minimum_charge = $minimum_cbm - $totalContainerCbm;
|
||||
$minimum_charge = ($minimum_charge < 0) ? 0 : $minimum_charge;
|
||||
$minimum_charge = $minimum_charge < 0 ? 0 : $minimum_charge;
|
||||
$minimum_charge = $noMinimumCharge ? 0 : $minimum_charge;
|
||||
|
||||
$minimum_charge = $noMinimumCharge ? 0 : round($minimum_charge, 3);
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchPayments;
|
||||
use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
||||
use App\Http\Resources\InvoiceResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
class FetchInvoiceLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* ListTransactionsLogic constructor.
|
||||
* @param FetchPayments $fetchPayments
|
||||
*/
|
||||
public function __construct(FetchPayments $fetchPayments)
|
||||
{
|
||||
$this->fetchPayments = $fetchPayments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Transactions',
|
||||
'message' => 'You have successfully retrieved a list of transactions'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchPayments */
|
||||
private $fetchPayments;
|
||||
|
||||
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$query = $this->fetchPayments->execute($this->fetchPayments->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(InvoiceResource::collection($query));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Standards\Rules\CanCreateTransaction;
|
||||
use App\Classes\Modules\Transactions\Standards\Rules\CanCreateTransactionDetail;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionDetailObject;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionDetail;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use App\Http\Resources\TransactionDetailResource;
|
||||
|
||||
use App\Classes\Modules\Receipts\Standards\Rules\CanCreateReceipt;
|
||||
use App\Classes\Modules\Receipts\Standards\Rules\CanCreateReceiptDetail;
|
||||
use App\Classes\Modules\Receipts\DataTransferObjects\ReceiptObject;
|
||||
use App\Classes\Modules\Receipts\DataTransferObjects\ReceiptDetailObject;
|
||||
use App\Classes\Modules\Receipts\Services\CreatesReceipt;
|
||||
use App\Classes\Modules\Receipts\Services\CreatesReceiptDetail;
|
||||
use App\Classes\Modules\Receipts\Services\GeneratesReceiptBillNo;
|
||||
|
||||
use App\Classes\Modules\Currencies\Services\FetchesCurrency;
|
||||
use App\Classes\Modules\Currencies\Services\RateCalculatesCurrency;
|
||||
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransactionDetail;
|
||||
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
|
||||
|
||||
use App\Models\Transaction;
|
||||
use App\Models\multipleInvoicesWithOnePayment;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
use APP\models\PackingList;
|
||||
|
||||
|
||||
|
||||
class multipleInvoicesWithOnePaymentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Transaction',
|
||||
'message' => 'You have successfully created a transaction'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNo;
|
||||
|
||||
/** @var CanCreateTransaction */
|
||||
private $canCreateTransaction;
|
||||
|
||||
private $fetchesCurrency;
|
||||
|
||||
private $rateCalculatesCurrency;
|
||||
|
||||
private $fetchesCompany;
|
||||
|
||||
private $createsTransaction;
|
||||
|
||||
private $canCreateTransactionDetail;
|
||||
|
||||
private $createsTransactionDetail;
|
||||
|
||||
private $fetchesTransaction;
|
||||
|
||||
private $fetchesTransactionDetail;
|
||||
|
||||
private $generatesReceiptBillNo;
|
||||
|
||||
/** @var CanCreateReceipt */
|
||||
private $canCreateReceipt;
|
||||
|
||||
private $createsReceipt;
|
||||
|
||||
private $canCreateReceiptDetail;
|
||||
|
||||
private $createsReceiptDetail;
|
||||
|
||||
|
||||
public function __construct(
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNo, CanCreateTransaction $canCreateTransaction,
|
||||
FetchesCurrency $fetchesCurrency, RateCalculatesCurrency $rateCalculatesCurrency, FetchesCompany $fetchesCompany,
|
||||
CreatesTransaction $createsTransaction,
|
||||
CanCreateTransactionDetail $canCreateTransactionDetail, CreatesTransactionDetail $createsTransactionDetail,
|
||||
FetchesTransaction $fetchesTransaction , FetchesTransactionDetail $fetchesTransactionDetail,
|
||||
GeneratesReceiptBillNo $generatesReceiptBillNo, CanCreateReceipt $canCreateReceipt,
|
||||
CreatesReceipt $createsReceipt,
|
||||
CanCreateReceiptDetail $canCreateReceiptDetail, CreatesReceiptDetail $createsReceiptDetail
|
||||
){
|
||||
$this->generatesTransactionBillNo = $generatesTransactionBillNo;
|
||||
$this->canCreateTransaction = $canCreateTransaction;
|
||||
$this->fetchesCurrency = $fetchesCurrency;
|
||||
$this->rateCalculatesCurrency = $rateCalculatesCurrency;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->createsTransaction =$createsTransaction;
|
||||
$this->canCreateTransactionDetail =$canCreateTransactionDetail;
|
||||
$this->createsTransactionDetail = $createsTransactionDetail;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->fetchesTransactionDetail = $fetchesTransactionDetail;
|
||||
|
||||
$this->generatesReceiptBillNo = $generatesReceiptBillNo;
|
||||
$this->canCreateReceipt = $canCreateReceipt;
|
||||
$this->createsReceipt =$createsReceipt;
|
||||
$this->canCreateReceiptDetail =$canCreateReceiptDetail;
|
||||
$this->createsReceiptDetail = $createsReceiptDetail;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
|
||||
|
||||
public function logic( $transactionsArray) : JsonResponse
|
||||
{
|
||||
// dd($request);
|
||||
try {
|
||||
|
||||
|
||||
// dd(json_decode($transactionsArray));
|
||||
$transactions = Transaction::whereIn('id', json_decode($transactionsArray))->where('type', TransactionType::SHIPPING_INVOICE)->get();
|
||||
$total = $transactions->sum('amount');
|
||||
$packingList =$transactions[1]->owner;
|
||||
$order = $packingList->owner;
|
||||
$companyModule = $order->companyModule;
|
||||
$company = $companyModule->company;
|
||||
$wallet = $company->wallets()->first();
|
||||
|
||||
if (!$wallet) {
|
||||
$object = new WalletObject($company->id, 1, (App()->make(GeneratesWalletCode::class))->execute());
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = (App()->make(CreatesWallet::class))->execute($object, $company);
|
||||
}
|
||||
|
||||
$billNumber = (App()->make(GeneratesTransactionBillNumber::class))->execute('TOPUP-');
|
||||
|
||||
if($total < 0) {
|
||||
throw new MalformedRequestException('Top up credit value must be greater than zero.');
|
||||
}
|
||||
$billPlzBill = (App()->make(CreatesBillplzBill::class))->execute($company->name, 'example@gmail.com', 'This payment is credit topup for company ref. ' . $company->reference, $total, $billNumber, 'bank code', true);
|
||||
|
||||
$transaction_object = new TransactionObject($billNumber, TransactionType::TOP_UP, 1, $company->id, 1, PaymentMethodType::PAYMENT_GATEWAY, $total, $total, 1, 1, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], 'test');
|
||||
|
||||
// $transaction = $this->createsTransaction->execute($wallet, $transaction_object);
|
||||
|
||||
$transaction = (App()->make(CreatesTransaction::class))->execute($wallet, $transaction_object);
|
||||
$result= (App()->make(UpdatesWalletBalance::class))->execute($wallet, $total);
|
||||
|
||||
foreach ($transactions as $key => $value) {
|
||||
multipleInvoicesWithOnePayment::create([ 'topUp_request_id' => $transaction->id, 'transaction_id' => $value->id ]);
|
||||
|
||||
}
|
||||
return $this->response([]); ;
|
||||
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
public function verifypayment( $topUp_transaction_id, $amount) : JsonResponse
|
||||
{
|
||||
$totalamount =0;
|
||||
$topup = multipleInvoicesWithOnePayment::where('topUp_request_id',$topUp_transaction_id)->get();
|
||||
|
||||
foreach ($topup as $key => $value) {
|
||||
$transaction = Transaction::where('id',$value->transaction_id)->frist();
|
||||
$totalamount += $transaction->amount;
|
||||
(App()->make(updatesTransactionStatus::class))->execute($transaction, ApprovalStatus::APPROVED);
|
||||
|
||||
$transaction_object = new TransactionObject($transaction->bill_no, TransactionType::PAYMENT, 1, $topUp_transaction_id, 1, PaymentMethodType::PAYMENT_GATEWAY, $transaction->amount, $transaction->amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], 'test');
|
||||
$transaction = (App()->make(CreatesTransaction::class))->execute($transaction, $transaction_object);
|
||||
|
||||
}
|
||||
$amount = $amount - $totalamount;
|
||||
Transaction::where('id', $topUp_transaction_id)->update(['amount'=> $amount]);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ class CreatesTransaction extends AbstractUpdateRelationshipRecord
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(PackingList $packing_list, TransactionObject $object) {
|
||||
public function execute( $packing_list, TransactionObject $object) {
|
||||
$model = new Transaction();
|
||||
$model->bill_no = $object->getBillNo();
|
||||
$model->type = $object->getTransactionType();
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
use App\Classes\Modules\Wallets\Standards\Rules\CanCreateCompanyWallet;
|
||||
use App\Http\Resources\WalletResource;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Company Wallet',
|
||||
'message' => 'You have successfully created a company wallet'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatesWallet */
|
||||
private $createsWallet;
|
||||
|
||||
/** @var GeneratesWalletCode */
|
||||
private $generatesWalletCode;
|
||||
|
||||
/** @var CanCreateCompanyWallet */
|
||||
private $canCreateCompanyWallet;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CanCreateCompanyWallet $canCreateCompanyWallet
|
||||
*/
|
||||
public function __construct(CreatesWallet $createsWallet, GeneratesWalletCode $generatesWalletCode, CanCreateCompanyWallet $canCreateCompanyWallet, FetchesCompany $fetchesCompany)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->createsWallet = $createsWallet;
|
||||
$this->generatesWalletCode = $generatesWalletCode;
|
||||
$this->canCreateCompanyWallet = $canCreateCompanyWallet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new WalletObject($request->input('company_id'), $request->input('currency_id'), $this->generatesWalletCode->execute());
|
||||
|
||||
$this->canCreateCompanyWallet->passes($object);
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
$wallet = $this->createsWallet->execute($object, $company);
|
||||
|
||||
return $this->resourceResponse(new WalletResource($wallet));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\Standards\Rules\CanCreateWalletTransaction;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletTransactionObject;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWalletTransaction;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletTransactionBillNo;
|
||||
use App\Http\Resources\WalletTransactionResource;
|
||||
use App\Classes\Modules\Wallets\Services\FetchesWallet;
|
||||
|
||||
use App\Classes\Modules\Currencies\Services\FetchesCurrency;
|
||||
use App\Classes\Modules\Currencies\Services\RateCalculatesCurrency;
|
||||
/*
|
||||
use App\Classes\Modules\Accounts\Standards\Rules\CanCreateUser;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesUser;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\UserObject;
|
||||
use App\Http\Resources\UserResource;
|
||||
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanCreateCompany;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompany;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
|
||||
use App\Classes\Modules\Contacts\Standards\Rules\CanCreateContact;
|
||||
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanCreateCompanyEmployee;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompanyEmployee;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyEmployeeObject;
|
||||
|
||||
use App\Classes\Modules\SegmentCompanies\Standards\Rules\CanCreateSegmentCompany;
|
||||
use App\Classes\Modules\SegmentCompanies\Services\CreatesSegmentCompany;
|
||||
use App\Classes\Modules\SegmentCompanies\DataTransferObjects\SegmentCompanyObject;
|
||||
*/
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateWalletTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Wallet Transaction',
|
||||
'message' => 'You have successfully created a wallet transaction'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatesWalletTransaction */
|
||||
private $createsWalletTransaction;
|
||||
|
||||
/** @var GeneratesWalletTransactionBillNo */
|
||||
private $generatesWalletTransactionBillNo;
|
||||
|
||||
/** @var CanCreateWalletTransaction */
|
||||
private $canCreateWalletTransaction;
|
||||
|
||||
private $fetchesCurrency;
|
||||
|
||||
private $rateCalculatesCurrency;
|
||||
|
||||
private $fetchesWallet;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param CreatesWalletTransaction $createsWalletTransaction
|
||||
* @param GeneratesWalletTransactionBillNo $generatesWalletTransactionBillNo
|
||||
* @param CanCreateWalletTransaction $canCreateWalletTransaction
|
||||
* @param FetchesCurrency $fetchesCurrency
|
||||
* @param RateCalculatesCurrency $rateCalculatesCurrency
|
||||
* @param FetchesWallet $fetchesWallet
|
||||
*/
|
||||
public function __construct(
|
||||
CreatesWalletTransaction $createsWalletTransaction, GeneratesWalletTransactionBillNo $generatesWalletTransactionBillNo, CanCreateWalletTransaction $canCreateWalletTransaction,
|
||||
FetchesCurrency $fetchesCurrency,RateCalculatesCurrency $rateCalculatesCurrency, FetchesWallet $fetchesWallet
|
||||
)
|
||||
{
|
||||
$this->createsWalletTransaction = $createsWalletTransaction;
|
||||
$this->generatesWalletTransactionBillNo = $generatesWalletTransactionBillNo;
|
||||
$this->canCreateWalletTransaction = $canCreateWalletTransaction;
|
||||
$this->fetchesCurrency = $fetchesCurrency;
|
||||
$this->rateCalculatesCurrency = $rateCalculatesCurrency;
|
||||
$this->fetchesWallet = $fetchesWallet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
$wallet = $this->fetchesWallet->execute(['id' => $request->route('id')]);
|
||||
$conversion_currency = $this->fetchesCurrency->execute(['id' => $request->input('currency_id')]);
|
||||
$convertable_currency = $this->fetchesCurrency->execute(['id' => $wallet->currency_id]);//MYR
|
||||
|
||||
$convert_amount = $this->rateCalculatesCurrency->execute($conversion_currency, $convertable_currency, $request->input('amount'));
|
||||
$convert_rate = $this->rateCalculatesCurrency->execute_rate($conversion_currency, $convertable_currency);
|
||||
|
||||
|
||||
$object = new WalletTransactionObject(
|
||||
$wallet->id, $this->generatesWalletTransactionBillNo->execute(),$request->input('trans_type'),
|
||||
number_format( (float) $convert_amount, 5, '.', ''), $wallet->currency_id , number_format( (float) $request->input('amount'), 5, '.', ''),
|
||||
$request->input('currency_id'),number_format( (float) $convert_rate, 5, '.', '')
|
||||
);
|
||||
|
||||
$this->canCreateWalletTransaction->passes($object);
|
||||
|
||||
$wallet_transaction = $this->createsWalletTransaction->execute($object);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new WalletTransactionResource($wallet_transaction));
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Http\Resources\WalletResource;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Wallets\Processors\CreditWalletProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
|
||||
class CreditWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Credit into Company Wallet',
|
||||
'message' => 'You have successfully credit company wallet'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var GeneratesWalletCode */
|
||||
private $generatesWalletCode;
|
||||
|
||||
/** @var CreatesWallet */
|
||||
private $createsWallet;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
|
||||
/** @var UpdatesWallet */
|
||||
private $updatesWallet;
|
||||
|
||||
/** @var CreditWalletProcessor */
|
||||
private $creditWalletProcessor;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
* @param UpdatesWallet $updatesWallet
|
||||
* @param CreditWalletProcessor $creditWalletProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
FetchesCompany $fetchesCompany,
|
||||
GeneratesWalletCode $generatesWalletCode,
|
||||
CreatesWallet $createsWallet,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesTransaction $createsTransaction,
|
||||
UpdatesWallet $updatesWallet,
|
||||
CreditWalletProcessor $creditWalletProcessor
|
||||
)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->generatesWalletCode = $generatesWalletCode;
|
||||
$this->createsWallet = $createsWallet;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
$this->updatesWallet = $updatesWallet;
|
||||
$this->creditWalletProcessor = $creditWalletProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$amount = floatval(str_replace(',', '', $request->input('amount')));
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
$reference = $request->input('reference');
|
||||
|
||||
$type = $request->input('transaction_type');
|
||||
|
||||
$wallet = $this->creditWalletProcessor->execute($company, $type, $amount, $reference);
|
||||
|
||||
return $this->resourceResponse(new WalletResource($wallet));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\WalletResource;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class DebitWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Debit into Company Wallet',
|
||||
'message' => 'You have successfully debit company wallet'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
|
||||
/** @var UpdatesWallet */
|
||||
private $updatesWallet;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
* @param UpdatesWallet $updatesWallet
|
||||
*/
|
||||
public function __construct(
|
||||
FetchesCompany $fetchesCompany,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesTransaction $createsTransaction,
|
||||
UpdatesWallet $updatesWallet
|
||||
)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
$this->updatesWallet = $updatesWallet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$amount = floatval(str_replace(',', '', $request->input('amount')));
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
$reference = $request->input('reference');
|
||||
|
||||
if (!$company->wallets()->first()) {
|
||||
$object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute());
|
||||
$wallet = $this->createsWallet->execute($object, $company);
|
||||
}
|
||||
|
||||
$wallet = $company->wallets()->first();
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('DEBIT-NOTE-');
|
||||
|
||||
$transaction_object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::DEBIT_NOTE,
|
||||
1,
|
||||
$wallet->company->id,
|
||||
1,
|
||||
PaymentMethodType::CASH,
|
||||
$amount,
|
||||
$amount,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
ApprovalStatus::APPROVED,
|
||||
[],
|
||||
$reference
|
||||
);
|
||||
|
||||
$transaction = $this->createsTransaction->execute($wallet, $transaction_object);
|
||||
$updateWalletAmount = $wallet->amount - $transaction->amount;
|
||||
|
||||
$walletOject = new WalletObject($wallet->company->id, $wallet->currency_id, $wallet->code, $updateWalletAmount);
|
||||
|
||||
$wallet = $this->updatesWallet->execute($wallet, $walletOject);
|
||||
|
||||
return $this->resourceResponse(new WalletResource($wallet));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\ListsWallet;
|
||||
use App\Classes\Modules\Wallets\Standards\Rules\CanListWallet;
|
||||
use App\Http\Resources\WalletResource;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ListWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'List Company Wallet',
|
||||
'message' => 'You have successfully list company wallet'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ListWallet */
|
||||
private $listsWallet;
|
||||
|
||||
/** @var CanCreateCompanyWallet */
|
||||
private $canListWallet;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CanCreateCompanyWallet $canCreateCompanyWallet
|
||||
*/
|
||||
public function __construct(CanListWallet $canListWallet, ListsWallet $listsWallet)
|
||||
{
|
||||
$this->canListWallet = $canListWallet;
|
||||
$this->listsWallet = $listsWallet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
//$this->canListWallet->passes();
|
||||
|
||||
$query = $this->listsWallet->execute($this->listsWallet->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(WalletResource::collection($query));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWalletTransaction;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\WalletResource;
|
||||
use App\Http\Resources\WalletTransactionResource;
|
||||
use App\Models\Wallet;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class TopUpWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'TopUp into Company Wallet',
|
||||
'message' => 'You have successfully created a topup request for company\'s wallet'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var GeneratesWalletCode */
|
||||
private $generatesWalletCode;
|
||||
|
||||
/** @var CreatesWallet */
|
||||
private $createsWallet;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesBillplzBill */
|
||||
private $createsBillplzBill;
|
||||
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
|
||||
|
||||
/**
|
||||
* TopUpWalletLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CreatesBillplzBill $createsBillplzBill
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, GeneratesWalletCode $generatesWalletCode, CreatesWallet $createsWallet, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesBillplzBill $createsBillplzBill, CreatesTransaction $createsTransaction)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->generatesWalletCode = $generatesWalletCode;
|
||||
$this->createsWallet = $createsWallet;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsBillplzBill = $createsBillplzBill;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$amount = floatval(str_replace(',', '', $request->input('amount')));
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $company->wallets()->first();
|
||||
|
||||
if (!$wallet) {
|
||||
$object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute());
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $this->createsWallet->execute($object, $company);
|
||||
}
|
||||
|
||||
$user = $company->employees()->first();
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('TOPUP-');
|
||||
|
||||
if($amount < 0) {
|
||||
throw new MalformedRequestException('Top up credit value must be greater than zero.');
|
||||
}
|
||||
|
||||
$billPlzBill = $this->createsBillplzBill->execute($company->name, $user->email, 'This payment is credit topup for company ref. ' . $company->reference, $amount, $billNumber, $request->input('bank_code'), true);
|
||||
|
||||
$transaction_object = new TransactionObject($billNumber, TransactionType::TOP_UP, 1, $company->id, 1, PaymentMethodType::PAYMENT_GATEWAY, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], $billPlzBill->id);
|
||||
|
||||
$transaction = $this->createsTransaction->execute($wallet, $transaction_object);
|
||||
|
||||
return $this->resourceResponse(new WalletTransactionResource($transaction));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\ListsWallet;
|
||||
use App\Classes\Modules\Wallets\Services\FetchesWallet;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Classes\Modules\Wallets\Standards\Rules\CanListWallet;
|
||||
use App\Http\Resources\WalletResource;
|
||||
use App\Classes\Modules\Transactions\Processors\UpdateWalletTransactionProcessor;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateStatusWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update Status Transaction Company Wallet',
|
||||
'message' => 'You have successfully status transaction company wallet'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ListWallet */
|
||||
private $fetchesWallet;
|
||||
|
||||
/** @var CanCreateCompanyWallet */
|
||||
private $canListWallet;
|
||||
|
||||
/** @var UpdateWalletTransactionProcessor */
|
||||
private $updateWalletTransactionProcessor;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CanCreateCompanyWallet $canCreateCompanyWallet
|
||||
*/
|
||||
public function __construct(FetchesWallet $fetchesWallet, UpdateWalletTransactionProcessor $updateWalletTransactionProcessor)
|
||||
{
|
||||
$this->fetchesWallet = $fetchesWallet;
|
||||
$this->updateWalletTransactionProcessor = $updateWalletTransactionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$status = ($request->route('status')=='approve') ? 2 : 4;
|
||||
|
||||
$wallet = $this->updateWalletTransactionProcessor->execute($request->route('transaction_id'), $status);
|
||||
|
||||
return $this->resourceResponse(new WalletResource($wallet));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\ListsWallet;
|
||||
use App\Classes\Modules\Wallets\Services\FetchesWallet;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
|
||||
use App\Classes\Modules\Wallets\Standards\Rules\CanWithdrawWallet;
|
||||
use App\Http\Resources\WalletResource;
|
||||
use App\Classes\Modules\Transactions\Processors\CreateWalletTransactionProcessor;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class WithdrawWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Withdraw from Company Wallet',
|
||||
'message' => 'You have successfully withdraw company wallet'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesWallet */
|
||||
private $fetchesWallet;
|
||||
|
||||
/** @var CanWithdrawWallet */
|
||||
private $canWithdrawWallet;
|
||||
|
||||
/** @var CreateWalletTransactionProcessor */
|
||||
private $createWalletTransactionProcessor;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CanCreateCompanyWallet $canCreateCompanyWallet
|
||||
*/
|
||||
public function __construct(CanWithdrawWallet $canWithdrawWallet, FetchesWallet $fetchesWallet, CreateWalletTransactionProcessor $createWalletTransactionProcessor)
|
||||
{
|
||||
$this->canWithdrawWallet = $canWithdrawWallet;
|
||||
$this->fetchesWallet = $fetchesWallet;
|
||||
$this->createWalletTransactionProcessor = $createWalletTransactionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$wallet = $this->fetchesWallet->execute(['id' => $request->input('wallet_id')]);
|
||||
|
||||
$walletOject = new WalletObject( $wallet->company->id, $wallet->currency_id, $wallet->code, $request->input('amount'));
|
||||
|
||||
$this->canWithdrawWallet->passes($walletOject);
|
||||
|
||||
$transaction = $this->createWalletTransactionProcessor->execute($wallet, $walletOject, TransactionType::WITHDRAW);
|
||||
|
||||
return $this->resourceResponse(new WalletResource($wallet));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class WalletObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var int */
|
||||
private $company_id;
|
||||
|
||||
/** @var int */
|
||||
private $currency_id;
|
||||
|
||||
/** @var int */
|
||||
private $code;
|
||||
|
||||
private $amount;
|
||||
|
||||
/**
|
||||
* WalletObject constructor.
|
||||
* @param int $company_id
|
||||
* @param int $currency
|
||||
* @param int $code
|
||||
*/
|
||||
public function __construct(int $company_id, int $currency, int $code, float $amount=0)
|
||||
{
|
||||
$this->company_id = $company_id;
|
||||
$this->currency_id = $currency;
|
||||
$this->code = $code;
|
||||
$this->amount = $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCompanyId(): int
|
||||
{
|
||||
return $this->company_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCurrency(): int
|
||||
{
|
||||
return $this->currency_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCode(): int
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function getAmount(): float
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class WalletTransactionObject implements DataTransferObject
|
||||
{
|
||||
|
||||
private $wallet_id;
|
||||
|
||||
private $bill_no;
|
||||
|
||||
private $trans_type;
|
||||
|
||||
private $amount;
|
||||
|
||||
private $currency_id;
|
||||
|
||||
private $original_amount;
|
||||
|
||||
private $original_currency_id;
|
||||
|
||||
private $currency_rate;
|
||||
|
||||
public function __construct(
|
||||
int $wallet_id, int $bill_no,int $trans_type,
|
||||
float $amount, int $currency_id, int $original_amount,
|
||||
int $original_currency_id, float $currency_rate
|
||||
){
|
||||
$this->wallet_id = $wallet_id;
|
||||
$this->bill_no = $bill_no;
|
||||
$this->trans_type = $trans_type;
|
||||
$this->amount= $amount;
|
||||
$this->currency_id = $currency_id;
|
||||
$this->original_amount = $original_amount;
|
||||
$this->original_currency_id = $original_currency_id;
|
||||
$this->currency_rate = $currency_rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getWalletId(): int
|
||||
{
|
||||
return $this->wallet_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBillNo(): int
|
||||
{
|
||||
return $this->bill_no;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTransType(): int
|
||||
{
|
||||
return $this->trans_type;
|
||||
}
|
||||
|
||||
|
||||
public function getAmount(): float
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCurrency(): int
|
||||
{
|
||||
return $this->currency_id;
|
||||
}
|
||||
|
||||
|
||||
public function getOriginalAmount(): float
|
||||
{
|
||||
return $this->original_amount;
|
||||
}
|
||||
|
||||
public function getOriginalCurrency(): int
|
||||
{
|
||||
return $this->original_currency_id;
|
||||
}
|
||||
|
||||
public function getCurrencyRate(): float
|
||||
{
|
||||
return $this->currency_rate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Processors;
|
||||
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Company;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
|
||||
class CreditWalletProcessor
|
||||
{
|
||||
/** @var GeneratesWalletCode */
|
||||
private $generatesWalletCode;
|
||||
|
||||
/** @var CreatesWallet */
|
||||
private $createsWallet;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
|
||||
/** @var UpdatesWallet */
|
||||
private $updatesWallet;
|
||||
|
||||
/**
|
||||
* CreateWalletLogic constructor.
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
* @param UpdatesWallet $updatesWallet
|
||||
*/
|
||||
public function __construct(
|
||||
GeneratesWalletCode $generatesWalletCode,
|
||||
CreatesWallet $createsWallet,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesTransaction $createsTransaction,
|
||||
UpdatesWallet $updatesWallet
|
||||
)
|
||||
{
|
||||
$this->generatesWalletCode = $generatesWalletCode;
|
||||
$this->createsWallet = $createsWallet;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
$this->updatesWallet = $updatesWallet;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Company $company
|
||||
* @param int $transactionType
|
||||
* @param float $amount
|
||||
* @param string $reference
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Company $company, int $transactionType, float $amount, string $reference)
|
||||
{
|
||||
if (!$company->wallets()->first()) {
|
||||
$object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute());
|
||||
$this->createsWallet->execute($object, $company);
|
||||
}
|
||||
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $company->wallets()->first();
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute($transactionType === 2 ? 'DEBIT-NOTE-' : 'CREDIT-NOTE-');
|
||||
|
||||
$transaction_object = new TransactionObject($billNumber, $transactionType === 2 ? TransactionType::DEBIT_NOTE : TransactionType::CREDIT_NOTE, 1, $wallet->owner->id, 1, PaymentMethodType::CASH, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], $reference);
|
||||
$transaction = $this->createsTransaction->execute($wallet, $transaction_object);
|
||||
|
||||
$updateWalletAmount = $transactionType === 2 ? ($wallet->amount - $transaction->amount) : ($wallet->amount + $transaction->amount);
|
||||
|
||||
$walletObject = new WalletObject($wallet->owner->id, $wallet->currency_id, $wallet->code, $updateWalletAmount);
|
||||
|
||||
$wallet = $this->updatesWallet->execute($wallet, $walletObject);
|
||||
|
||||
return $wallet;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
|
||||
use App\Models\Wallet;
|
||||
|
||||
class ChecksIfWalletCodeExists
|
||||
{
|
||||
|
||||
/** @var wallet */
|
||||
private $repository;
|
||||
|
||||
|
||||
/**
|
||||
* ChecksIfWalletCodeExists constructor.
|
||||
* @param Wallet $repository
|
||||
*/
|
||||
public function __construct(wallet $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
public function execute(int $code): bool {
|
||||
return $this->repository->where('code', $code)->exists();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
|
||||
use App\Models\WalletTransaction;
|
||||
|
||||
class ChecksIfWalletTransactionBillNoExists
|
||||
{
|
||||
|
||||
private $repository;
|
||||
|
||||
public function __construct(WalletTransaction $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
public function execute(int $bill_no): bool {
|
||||
return $this->repository->where('bill_no', $bill_no)->exists();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Company;
|
||||
|
||||
class CreatesWallet extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(WalletObject $object, Company $company) {
|
||||
$model = new Wallet();
|
||||
//$model->company_id = $object->getCompanyId();
|
||||
$model->code = $object->getCode();
|
||||
$model->currency_id = $object->getCurrency();
|
||||
|
||||
return $this->handler($company->wallets(), $model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletTransactionObject;
|
||||
use App\Models\WalletTransaction;
|
||||
|
||||
class CreatesWalletTransaction extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param WalletTransactionObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(WalletTransactionObject $object) {
|
||||
$model = new WalletTransaction();
|
||||
$model->wallet_id = $object->getWalletId();
|
||||
$model->bill_no = $object->getBillNo();
|
||||
$model->trans_type = $object->getTransType();
|
||||
$model->amount = $object->getAmount();
|
||||
$model->currency_id = $object->getCurrency();
|
||||
$model->original_amount = $object->getOriginalAmount();
|
||||
$model->original_currency_id = $object->getOriginalCurrency();
|
||||
$model->currency_rate = $object->getCurrencyRate();
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Wallet;
|
||||
|
||||
class FetchesWallet extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var Wallet */
|
||||
private $repository;
|
||||
|
||||
|
||||
/**
|
||||
* FetchesWallet constructor.
|
||||
* @param Wallet $repository
|
||||
*/
|
||||
public function __construct(Wallet $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
|
||||
class GeneratesWalletCode
|
||||
{
|
||||
|
||||
/** @var ChecksIfWalletCodeExists */
|
||||
private $walletCodeExists;
|
||||
|
||||
/**
|
||||
* GeneratesWalletCode constructor.
|
||||
* @param ChecksIfWalletCodeExists $walletCodeExists
|
||||
*/
|
||||
public function __construct(ChecksIfWalletCodeExists $walletCodeExists)
|
||||
{
|
||||
$this->walletCodeExists = $walletCodeExists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function execute(): int {
|
||||
|
||||
$code = mt_rand(100000001, 999999999);
|
||||
return !$this->walletCodeExists->execute($code) ? $code : self::execute();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
|
||||
class GeneratesWalletTransactionBillNo
|
||||
{
|
||||
|
||||
|
||||
private $walletTransationBillNoExists;
|
||||
|
||||
|
||||
public function __construct(ChecksIfWalletTransactionBillNoExists $walletTransationBillNoExists)
|
||||
{
|
||||
$this->walletTransationBillNoExists = $walletTransationBillNoExists;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function execute(): int {
|
||||
|
||||
$code = mt_rand(100000001, 999999999);
|
||||
return !$this->walletTransationBillNoExists->execute($code) ? $code : self::execute();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+6
-7
@@ -1,22 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Services;
|
||||
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use App\Models\Wallet;
|
||||
|
||||
class FetchPayments extends AbstractListRecord
|
||||
class ListsWallet extends AbstractListRecord
|
||||
{
|
||||
/** @var Transaction */
|
||||
/** @var Booking */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsBookings constructor.
|
||||
* @param Transaction $repository
|
||||
* @param Booking $repository
|
||||
*/
|
||||
public function __construct(Transaction $repository)
|
||||
public function __construct(Wallet $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Company;
|
||||
|
||||
class UpdatesWallet extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Wallet $model, WalletObject $object) {
|
||||
$model->amount = $object->getAmount();
|
||||
$model->code = $object->getCode();
|
||||
$model->currency_id = $object->getCurrency();
|
||||
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Company;
|
||||
|
||||
class UpdatesWalletBalance extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param Wallet $model
|
||||
* @param $amount
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Wallet $model, $amount) {
|
||||
|
||||
$model->amount = $model->amount + $amount;
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Standards\Validators\CompanyWalletValidation;
|
||||
|
||||
class CanCreateCompanyWallet extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var CompanyWalletValidation */
|
||||
private $companyWalletValidation;
|
||||
|
||||
/**
|
||||
* CanCreateCompanyWallet constructor.
|
||||
* @param CompanyWalletValidation $companyWalletValidation
|
||||
*/
|
||||
public function __construct(CompanyWalletValidation $companyWalletValidation)
|
||||
{
|
||||
$this->companyWalletValidation = $companyWalletValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->companyWalletValidation->validate($object);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletTransactionObject;
|
||||
use App\Classes\Modules\Wallets\Standards\Validators\WalletTransactionValidation;
|
||||
|
||||
class CanCreateWalletTransaction extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var WalletTransactionValidation */
|
||||
private $walletTransactionValidation;
|
||||
|
||||
|
||||
public function __construct(WalletTransactionValidation $walletTransactionValidation)
|
||||
{
|
||||
$this->walletTransactionValidation = $walletTransactionValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletTransactionObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->walletTransactionValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletTransactionObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Standards\Validators\ListWalletValidation;
|
||||
|
||||
class CanListWallet extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var ListWalletValidation */
|
||||
private $listWalletValidation;
|
||||
|
||||
|
||||
public function __construct(ListWalletValidation $listWalletValidation)
|
||||
{
|
||||
$this->listWalletValidation = $listWalletValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->listWalletValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletTransactionObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Standards\Validators\TopUpWalletValidation;
|
||||
|
||||
class CanTopUpWallet extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var TopUpWalletValidation */
|
||||
private $topUpWalletValidation;
|
||||
|
||||
|
||||
public function __construct(TopUpWalletValidation $topUpWalletValidation)
|
||||
{
|
||||
$this->topUpWalletValidation = $topUpWalletValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->topUpWalletValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletTransactionObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Standards\Validators\WithdrawWalletValidation;
|
||||
|
||||
class CanWithdrawWallet extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var WithdrawWalletValidation */
|
||||
private $witdrawWalletValidation;
|
||||
|
||||
|
||||
public function __construct(WithdrawWalletValidation $witdrawWalletValidation)
|
||||
{
|
||||
$this->witdrawWalletValidation = $witdrawWalletValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->witdrawWalletValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WalletTransactionObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
|
||||
class CompanyWalletValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param WalletObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'company_id' => $object->getCompanyId(),
|
||||
'currency_id' => $object->getCurrency(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'company_id' => 'required',
|
||||
'currency_id' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
|
||||
class ListWalletValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
protected function data($object): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
|
||||
class TopUpWalletValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
protected function data($object): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
|
||||
class WalletTransactionValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'wallet_id' => $object->getWalletId(),
|
||||
'currency_id' => $object->getCurrency(),
|
||||
'amount' => $object->getAmount(),
|
||||
'trans_type'=>$object->getTransType()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'wallet_id' => 'required',
|
||||
'currency_id' => 'required',
|
||||
'amount' => 'required',
|
||||
'trans_type'=>'required'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
|
||||
class WithdrawWalletValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
protected function data($object): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ final class TransactionType {
|
||||
|
||||
// public const PERFORMA = 4;
|
||||
|
||||
// public const TOP_UP = 5;
|
||||
public const TOP_UP = 3;
|
||||
|
||||
// public const REFUND = 6;
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Invoice;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\multipleInvoicesWithOnePaymentLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Transaction;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
use APP\models\PackingList;
|
||||
use App\Models\multipleInvoicesWithOnePayment;
|
||||
use DB;
|
||||
|
||||
|
||||
class MultipleInvoiceOnePaymentController extends Controller
|
||||
{
|
||||
|
||||
public function getallivoiceid1($transactionsArray, multipleInvoicesWithOnePaymentLogic $logic): JsonResponse {
|
||||
|
||||
return $logic->logic($transactionsArray);
|
||||
}
|
||||
|
||||
public function getallivoiceid( $transactionsArray)
|
||||
{
|
||||
|
||||
|
||||
// dd(json_decode($transactionsArray));
|
||||
$transactions = Transaction::whereIn('id', json_decode($transactionsArray))->where('type', TransactionType::SHIPPING_INVOICE)->get();
|
||||
$total = $transactions->sum('amount');
|
||||
$packingList =$transactions[1]->owner;
|
||||
$order = $packingList->owner;
|
||||
$companyModule = $order->companyModule;
|
||||
$company = $companyModule->company;
|
||||
$wallet = $company->wallets()->first();
|
||||
|
||||
if (!$wallet) {
|
||||
$object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute());
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $this->createsWallet->execute($object, $company);
|
||||
}
|
||||
|
||||
$billNumber = (App()->make(GeneratesTransactionBillNumber::class))->execute('TOPUP-');
|
||||
|
||||
if($total < 0) {
|
||||
throw new MalformedRequestException('Top up credit value must be greater than zero.');
|
||||
}
|
||||
$billPlzBill = (App()->make(CreatesBillplzBill::class))->execute($company->name, 'example@gmail.com', 'This payment is credit topup for company ref. ' . $company->reference, $total, $billNumber, 'bank code', true);
|
||||
|
||||
$transaction_object = new TransactionObject($billNumber, TransactionType::TOP_UP, 1, $company->id, 1, PaymentMethodType::PAYMENT_GATEWAY, $total, $total, 1, 1, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], 'test');
|
||||
|
||||
// $transaction = $this->createsTransaction->execute($wallet, $transaction_object);
|
||||
|
||||
$transaction = (App()->make(CreatesTransaction::class))->execute($wallet, $transaction_object);
|
||||
$result= (App()->make(UpdatesWalletBalance::class))->execute($wallet, $total);
|
||||
|
||||
foreach ($transactions as $key => $value) {
|
||||
multipleInvoicesWithOnePayment::create([ 'topUp_request_id' => $transaction->id, 'transaction_id' => $value->id ]);
|
||||
|
||||
}
|
||||
dd($transaction->id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Orders;
|
||||
|
||||
use App\Classes\Modules\Orders\ControllersLogic\FetchOrderLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchMultipleOrderController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param FetchOrderLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function fetch(Request $request, FetchOrderLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Orders;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Imports\Services\Importorder;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class OrderFromExcelController extends Controller
|
||||
{
|
||||
public function importView(){
|
||||
|
||||
return view('importFile');
|
||||
}
|
||||
|
||||
|
||||
public function import(Request $request){
|
||||
Excel::import(new Importorder,
|
||||
$request->file('file')->store('files'));
|
||||
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\FetchInvoiceLogic;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\ListTransactionsLogic;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\InvoiceResource;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchInvoiceController extends Controller
|
||||
{
|
||||
public function list(Request $request)
|
||||
{
|
||||
try{
|
||||
return InvoiceResource::collection(Order::Paginate(10,['*'],'page',2));
|
||||
}catch(\Exception $ex) {
|
||||
return response()->json(['error' => [$ex->getMessage()]],404);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param FetchInvoiceLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function fetch(Request $request, FetchInvoiceLogic $logic) : JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\CreateWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateWalletController
|
||||
{
|
||||
|
||||
public function create(Request $request, CreateWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\CreateWalletTransactionLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateWalletTransactionController
|
||||
{
|
||||
|
||||
public function create(Request $request, CreateWalletTransactionLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\CreditWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreditWalletController
|
||||
{
|
||||
|
||||
public function credit(Request $request, CreditWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\DebitWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DebitWalletController
|
||||
{
|
||||
|
||||
public function debit(Request $request, DebitWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\ListWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListWalletController
|
||||
{
|
||||
public function list(Request $request, ListWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\TopUpWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TopUpWalletController
|
||||
{
|
||||
|
||||
public function topUp(Request $request, TopUpWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\UpdateStatusWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateStatusWalletController
|
||||
{
|
||||
public function updateStatus(Request $request, UpdateStatusWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\ValueObjects\Response\ApiResponseObject;
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\Wallet;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class WalletReportController
|
||||
{
|
||||
public function walletsReport(Request $request): JsonResponse
|
||||
{
|
||||
return (new ApiResponseObject(
|
||||
'fetch service report Successful',
|
||||
'',
|
||||
HttpStatus::OK_WITH_MESSAGE,
|
||||
['data' => [
|
||||
'walletSum' => (float) Wallet::all()->sum('amount'),
|
||||
'outgoingSum' => (float) Transaction::where('type', TransactionType::PAYMENT)->where('owner_type', Wallet::class)->sum('amount'),
|
||||
'incomingSum' => (float) Transaction::whereIn('type', [TransactionType::TOP_UP, TransactionType::CREDIT_NOTE])->where('owner_type', Wallet::class)->sum('amount'),
|
||||
]]
|
||||
))->handler();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wallets;
|
||||
|
||||
use App\Classes\Modules\Wallets\ControllersLogic\WithdrawWalletLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class WithdrawWalletController
|
||||
{
|
||||
|
||||
public function withdraw(Request $request, WithdrawWalletLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class InvoiceResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'invoice_id' => $this->reference,
|
||||
'carrier_tracking_number' => '1zbr06tw403742920',
|
||||
'this_package_was_delivered' => '1zbr06tw403742920',
|
||||
'due_date' => '11.04.2021',
|
||||
'date_paid' => '21.01.2021',
|
||||
'outstanding' => 92.01
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -102,4 +102,11 @@ class Company extends AbstractModel implements Documentable, Contactable
|
||||
return $this->hasManyDeep(Package::class, [CompanyModule::class, Order::class, PackingList::class], ['company_id', 'company_module_id', ['owner_type', 'owner_id'], 'packing_list_id'], ['id', 'id', null, 'id']);
|
||||
}
|
||||
|
||||
|
||||
public function wallets(): morphMany
|
||||
{
|
||||
return $this->morphMany(Wallet::class, 'owner');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Models;
|
||||
|
||||
use App\Classes\General\Interfaces\Remarkable;
|
||||
use App\Classes\General\Interfaces\Transportable;
|
||||
use App\Classes\General\Traits\LogData;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
@@ -15,7 +14,6 @@ class Container extends AbstractModel implements Transportable, Remarkable
|
||||
{
|
||||
use HasRelationships;
|
||||
use SoftDeletes;
|
||||
use LogData;
|
||||
|
||||
protected $table = 'containers';
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ use App\Classes\General\Interfaces\Transportable;
|
||||
use App\Classes\General\Interfaces\Packable;
|
||||
use App\Classes\General\Interfaces\Transactionable;
|
||||
|
||||
use App\Classes\General\Traits\LogData;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
@@ -24,7 +23,6 @@ class PackingList extends AbstractModel implements Transportable, Steppable, Pac
|
||||
use HasTableAlias;
|
||||
use HasRelationships;
|
||||
use SoftDeletes;
|
||||
use LogData;
|
||||
|
||||
protected $table = 'packing_lists';
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace App\Models;
|
||||
use App\Classes\General\Interfaces\Documentable;
|
||||
use App\Classes\General\Interfaces\Remarkable;
|
||||
use App\Classes\General\Interfaces\Transactionable;
|
||||
use App\Classes\General\Traits\LogData;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Carbon\Carbon;
|
||||
@@ -15,7 +14,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use App\Classes\General\Eloquent\LogData;
|
||||
class Transaction extends AbstractModel implements Documentable, Transactionable, Remarkable
|
||||
{
|
||||
use SoftDeletes;
|
||||
@@ -136,4 +135,7 @@ class Transaction extends AbstractModel implements Documentable, Transactionable
|
||||
{
|
||||
return $this->morphMany(Remark::class, 'owner');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TransactionLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'owner',
|
||||
'type',
|
||||
'issuer',
|
||||
'receiver',
|
||||
'recipient_bank_account_id',
|
||||
'payment_method',
|
||||
'payment_reference',
|
||||
'bill_no',
|
||||
'amount',
|
||||
'original_amount',
|
||||
'currency_id',
|
||||
'original_currency_id',
|
||||
'currency_rate',
|
||||
'tax',
|
||||
'service_charge',
|
||||
'expires_on',
|
||||
'status',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Classes\General\Interfaces\Transactionable;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
class Wallet extends AbstractModel implements Transactionable
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'wallets';
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
||||
*/
|
||||
public function owner(): morphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return morphMany
|
||||
*/
|
||||
public function transactions(): morphMany
|
||||
{
|
||||
return $this->morphMany(Transaction::class, 'owner');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
|
||||
class WalletTransaction extends AbstractModel
|
||||
{
|
||||
protected $table = 'wallet_transaction';
|
||||
|
||||
public function wallet(): HasOne
|
||||
{
|
||||
return $this->hasOne(Wallet::class, 'wallet_id', 'id');
|
||||
}
|
||||
|
||||
public function transaction(): HasOne
|
||||
{
|
||||
return $this->hasOne(Transaction::class, 'transaction_id', 'id');
|
||||
}
|
||||
|
||||
public function currency(): HasOne
|
||||
{
|
||||
return $this->hasOne(Currency::class, 'currency_id', 'id');
|
||||
}
|
||||
|
||||
public function original_currency(): HasOne
|
||||
{
|
||||
return $this->hasOne(Currency::class, 'original_currency_id', 'id');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class multipleInvoicesWithOnePayment extends AbstractModel
|
||||
{
|
||||
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'multiple_invoice_one_payments';
|
||||
|
||||
protected $fillable =[
|
||||
'topUp_request_id',
|
||||
'transaction_id'
|
||||
];
|
||||
}
|
||||
+2
-1
@@ -64,7 +64,8 @@
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
"sort-packages": true,
|
||||
"platform-check": false
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateCompaniesWalletTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('wallets', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->foreignId('company_id')->unsigned();
|
||||
$table->string('code');
|
||||
$table->foreignId('currency_id')->unsigned();
|
||||
$table->decimal('amount', 20, 5)->default(0.00);
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('company_id')->references('id')->on('companies');
|
||||
$table->foreign('currency_id')->references('id')->on('currencies');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('wallets');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AlterWalletCompanyId extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasColumn('wallets', 'company_id')) {
|
||||
Schema::table('wallets', function (Blueprint $table) {
|
||||
$table->dropForeign('wallets_company_id_foreign');
|
||||
$table->dropColumn('company_id');
|
||||
});
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('wallets', 'owner_id')) {
|
||||
Schema::table('wallets', function (Blueprint $table) {
|
||||
$table->morphs('owner');
|
||||
});
|
||||
|
||||
//In-case the model name lengthy
|
||||
Schema::table('wallets', function (Blueprint $table) {
|
||||
$table->string('owner_type', 250)->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateMultipleInvoiceOnePaymentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('multiple_invoice_one_payments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('topUp_request_id')->unsigned();
|
||||
$table->foreignId('transaction_id')->unsigned();
|
||||
$table->timestamps();
|
||||
$table->foreign('topUp_request_id')->references('id')->on('transactions');
|
||||
$table->foreign('transaction_id')->references('id')->on('transactions');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('multiple_invoice_one_payments');
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -54,7 +54,6 @@
|
||||
"gulp-print": "^5.0.2",
|
||||
"gulp-rename": "^2.0.0",
|
||||
"gulp-replace": "^1.0.0",
|
||||
"gulp-sass": "^4.1.0",
|
||||
"gulp-streamify": "^1.0.2",
|
||||
"gulp-uglify": "^3.0.0",
|
||||
"gulp-uglify-es": "^2.0.0",
|
||||
@@ -125,5 +124,9 @@
|
||||
"sourceFonts": [
|
||||
"./resources/assets/fonts/**/*"
|
||||
]
|
||||
}
|
||||
},
|
||||
"name": "yes",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"license": "MIT"
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
<IfModule mod_negotiation.c>
|
||||
Options -MultiViews -Indexes
|
||||
</IfModule>
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
# Handle Authorization Header
|
||||
RewriteCond %{HTTP:Authorization} .
|
||||
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||
|
||||
# Redirect Trailing Slashes If Not A Folder...
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_URI} (.+)/$
|
||||
RewriteRule ^ %1 [L,R=301]
|
||||
|
||||
# Send Requests To Front Controller...
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
</IfModule>
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Contracts\Http\Kernel;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Check If The Application Is Under Maintenance
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If the application is in maintenance / demo mode via the "down" command
|
||||
| we will load this file so that any pre-rendered content can be shown
|
||||
| instead of starting the framework, which could cause an exception.
|
||||
|
|
||||
*/
|
||||
|
||||
if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
|
||||
require __DIR__.'/../storage/framework/maintenance.php';
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Auto Loader
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Composer provides a convenient, automatically generated class loader for
|
||||
| this application. We just need to utilize it! We'll simply require it
|
||||
| into the script here so we don't need to manually load our classes.
|
||||
|
|
||||
*/
|
||||
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Run The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Once we have the application, we can handle the incoming request using
|
||||
| the application's HTTP kernel. Then, we will send the response back
|
||||
| to this client's browser, allowing them to enjoy our application.
|
||||
|
|
||||
*/
|
||||
|
||||
$app = require_once __DIR__.'/../bootstrap/app.php';
|
||||
|
||||
$kernel = $app->make(Kernel::class);
|
||||
|
||||
$response = tap($kernel->handle(
|
||||
$request = Request::capture()
|
||||
))->send();
|
||||
|
||||
$kernel->terminate($request, $response);
|
||||
@@ -1,2 +0,0 @@
|
||||
User-agent: *
|
||||
Disallow:
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 665 B |
Binary file not shown.
|
Before Width: | Height: | Size: 628 B |
-3
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Vendored
-4
File diff suppressed because one or more lines are too long
@@ -1,28 +0,0 @@
|
||||
<!--
|
||||
Rewrites requires Microsoft URL Rewrite Module for IIS
|
||||
Download: https://www.iis.net/downloads/microsoft/url-rewrite
|
||||
Debug Help: https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules
|
||||
-->
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<rewrite>
|
||||
<rules>
|
||||
<rule name="Imported Rule 1" stopProcessing="true">
|
||||
<match url="^(.*)/$" ignoreCase="false" />
|
||||
<conditions>
|
||||
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
|
||||
</conditions>
|
||||
<action type="Redirect" redirectType="Permanent" url="/{R:1}" />
|
||||
</rule>
|
||||
<rule name="Imported Rule 2" stopProcessing="true">
|
||||
<match url="^" ignoreCase="false" />
|
||||
<conditions>
|
||||
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
|
||||
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
|
||||
</conditions>
|
||||
<action type="Rewrite" url="index.php" />
|
||||
</rule>
|
||||
</rules>
|
||||
</rewrite>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
@@ -53,7 +53,7 @@
|
||||
</div>
|
||||
<div class="row text-center justify-content-center">
|
||||
<div class="col-8">
|
||||
<p class="m-b-0 text-danger m-t-15" v-if="parameters.warehouse_id === 3">疫情因管控松动飙升,其中几位仓库人员也不幸感染,整个操作可能会受到影响,我们会尽快跟进并恢复。<br>The pandemic spread due to the loosening of movement controls. Some warehouse employees were unfortunately infected and the entire operation may be disrupted. We will do our best to follow up and revert as soon as possible.</p>
|
||||
<p class="m-b-0 text-danger m-t-15" v-if="parameters.warehouse_id === 3">近期由于船期的安排和马来西亚海关的运作等一些不可控因数,导致船期延迟,请大家提前做好采购安排。若有不便之处,敬请谅解。 <br>Due to inevitable circumstances, shipping arrangements and Malaysia custom clearance may have delays. Kindly plan your purchases in advance, thank you for your cooperation.</p>
|
||||
<p class="m-b-0 text-danger m-t-15" v-if="false">由于义乌船期不稳定,建议发广州仓库。<br>Due to unexpected shipping delays for Yiwu warehouse, you may select an alternative warehouse.</p>
|
||||
<p class="m-b-0 text-danger m-t-15" v-if="parameters.warehouse_id === 4">由于义乌船期不稳定,建议发广州仓库。<br>Due to unexpected shipping delays for Yiwu warehouse, you may select an alternative warehouse.</p>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title> Import Excel data </title>
|
||||
<link rel="stylesheet"
|
||||
href=
|
||||
"https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" />
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
<h6>
|
||||
</h6>
|
||||
<div class="container">
|
||||
<div class="card bg-light mt-3">
|
||||
<div class="card-header">
|
||||
Import Excel data
|
||||
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ route('import') }}"
|
||||
method="POST"
|
||||
enctype="multipart/form-data">
|
||||
@csrf
|
||||
<input type="file" name="file"
|
||||
class="form-control">
|
||||
<br>
|
||||
<button class="btn btn-success">
|
||||
Import User Data
|
||||
</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
+6
-2
@@ -24,12 +24,12 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function
|
||||
|
||||
require __DIR__ . '/delivery.php';
|
||||
|
||||
Route::group([/*'middleware' => 'valid.token'*/], function () {
|
||||
Route::group(['middleware' => 'valid.token'], 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');
|
||||
|
||||
|
||||
Route::post('/import/update-debtor/f614e339d7058904a831aad742e24d55', 'Imports\ImportUpdateDebtorController@import')->name('debtor.import');
|
||||
|
||||
require __DIR__ . '/company.php';
|
||||
@@ -61,8 +61,12 @@ Route::group([/*'middleware' => 'valid.token'*/], function () {
|
||||
require __DIR__ . '/announcement.php';
|
||||
|
||||
require __DIR__ . '/report.php';
|
||||
|
||||
require __DIR__ . '/wallet.php';
|
||||
|
||||
|
||||
});
|
||||
require __DIR__ . '/invoice.php';
|
||||
|
||||
require __DIR__ . '/announcement.php';
|
||||
});
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Route::get('/group/paymenttransaction/{transactionsArray?}', 'Invoice\MultipleInvoiceOnePaymentController@getallivoiceid')->name('grouppayment');
|
||||
// Route::get('/refresh', 'RefreshAuthenticationTokenController@refresh')->name('refresh');
|
||||
|
||||
Route::get('/testgrouppayment', function () {
|
||||
|
||||
$ids = array(1,2,9);
|
||||
|
||||
|
||||
return redirect()->route('api.grouppayment',['transactionsArray' => json_encode($ids)]);
|
||||
});
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\Transactions\FetchInvoiceController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::group(['prefix' => 'order', 'as' => 'order.', 'namespace' => 'Orders'], function () {
|
||||
@@ -19,5 +18,4 @@ Route::group(['prefix' => 'order', 'as' => 'order.', 'namespace' => 'Orders'], f
|
||||
|
||||
Route::put('/assign-remark/{id}', 'AssignOrderRemarkController@create')->name('assign.remark');
|
||||
Route::get('/{id}/shipping-cost', 'ShippingCostController@calculate')->name('shipping.cost');
|
||||
Route::get('/payments_billings' , [FetchInvoiceController::class,'fetch'])->name('shipping.invoice');
|
||||
});
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::group(['prefix' => 'wallets', 'namespace' => 'Wallets', 'as' => 'wallet.'], function () {
|
||||
Route::get('/', 'ListWalletController@list')->name('list');
|
||||
Route::post('/create', 'CreateWalletController@create')->name('create');
|
||||
|
||||
Route::post('/topup', 'TopUpWalletController@topUp')->name('topup'); // user
|
||||
Route::post('/credit', 'CreditWalletController@credit')->name('credit'); // admin +
|
||||
|
||||
Route::put('/{transaction_id}/update-status/{status}', 'UpdateStatusWalletController@updateStatus')->where('status', 'approve|reject')->name('approval');
|
||||
|
||||
Route::get('/reports', 'WalletReportController@walletsReport')->name('reports');
|
||||
});
|
||||
+9
-120
@@ -7,19 +7,14 @@ use App\Classes\Jobs\FetchLoadedContainersFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchOrdersFromYDPortalJob;
|
||||
use App\Classes\Jobs\FetchPackingListFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchWarehouseReceiveListFromVTPortalJob;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchOrderListsFromYdPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchPackingListFromVTPortalProcessor;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Models\CompanyConnection;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\PackingList;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use App\Models\Container;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/*
|
||||
@@ -34,6 +29,12 @@ use Illuminate\Support\Facades\Route;
|
||||
*/
|
||||
|
||||
require __DIR__ . '/template.php';
|
||||
// /sdjn
|
||||
|
||||
|
||||
// test of orderfromexcel
|
||||
Route::get('file-import', [App\Http\Controllers\Orders\OrderFromExcelController::class, 'importView'])->name('file-import');
|
||||
Route::post('import', [App\Http\Controllers\Orders\OrderFromExcelController::class, 'import'])->name('import');
|
||||
|
||||
Route::domain('hywave.izyim.com')->group(function () {
|
||||
Route::group(['as' => 'last_mile_delivery.'], function () {
|
||||
@@ -465,23 +466,11 @@ Route::get('/container/billing/{month}/{year}', function($month, $year){
|
||||
$totalBilled = 0;
|
||||
$totalPaid = 0;
|
||||
|
||||
$basePrice = 315;
|
||||
$bigParcelDiscount = -15;
|
||||
|
||||
$yiwuCost = 15;
|
||||
|
||||
$discount = -20;
|
||||
$yiwuDiscount = -45;
|
||||
|
||||
$outstationStates = [8, 3, 16, 10];
|
||||
|
||||
|
||||
foreach($containers as $container) {
|
||||
$containerTotalBillable = 0;
|
||||
$containerBilled = 0;
|
||||
$containerTotalBilled = 0;
|
||||
$containerTotalPaid = 0;
|
||||
$containerCost = 0;
|
||||
|
||||
$packingLists = $container->packingLists;
|
||||
|
||||
@@ -494,58 +483,8 @@ Route::get('/container/billing/{month}/{year}', function($month, $year){
|
||||
->where('type', \App\Classes\ValueObjects\Constants\TransactionType::SHIPPING_INVOICE)->whereIn('status', [\App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED, \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED])
|
||||
->first();
|
||||
|
||||
|
||||
$warehouseList = PackingList::where('reference', $packingList->reference)->where('type', 1)->first();
|
||||
if($warehouseList){
|
||||
$packing_list_drop_date = $warehouseList->transports->first()->drop_date;
|
||||
} else {
|
||||
echo '<------------- can\'t find arrival date -------------->';
|
||||
}
|
||||
|
||||
$order = $packingList->owner;
|
||||
$address = $order->addresses()->where('status', \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED)->first();
|
||||
$warehouseId = $order->orderRoles()->where('role_id', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->company_module_id;
|
||||
|
||||
$cbm = round($packingList->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum(function($package) {
|
||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||
}), 2);
|
||||
|
||||
$over_weight_cbm = round($packingList->packages->where('type', PackageType::OVER_WEIGHT)->sum(function($package) {
|
||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||
}), 2);
|
||||
$price = $basePrice;
|
||||
|
||||
if($warehouseId === 2358){
|
||||
$price += $yiwuCost;
|
||||
if($packing_list_drop_date >= \Carbon\Carbon::parse('19-9-2022')){
|
||||
$price += $yiwuDiscount;
|
||||
}
|
||||
} else {
|
||||
if($cbm >= 2 && in_array($address->state_id, [4, 15])){
|
||||
$price += $bigParcelDiscount;
|
||||
}
|
||||
if($packing_list_drop_date >= \Carbon\Carbon::parse('19-9-2022')){
|
||||
$price += $discount;
|
||||
}
|
||||
}
|
||||
|
||||
if(in_array($address->state_id,$outstationStates)) {
|
||||
$price += 50;
|
||||
}
|
||||
|
||||
$cbm = max($cbm, 0.3);
|
||||
$cost = $price * ($cbm + $over_weight_cbm);
|
||||
|
||||
$containerCost += $cost;
|
||||
|
||||
if(in_array($address->state_id, [13, 14])) {
|
||||
echo 'East Malaysia - ';
|
||||
}
|
||||
echo 'estimated cost: [QTY: '.($cbm + $over_weight_cbm).' | Unit Price: '.$price.' | Total: '.$cost.']';
|
||||
echo '<br>';
|
||||
|
||||
if(!$invoice) {
|
||||
echo '<p style="color: red"><a href="'.route('order.show', $order->reference).'" target="_blank">'.$packingList->reference .'</a> Warning: no billing</p>';
|
||||
echo '<p style="color: red">'.$packingList->reference .' Warning: no billing</p>';
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -562,8 +501,8 @@ Route::get('/container/billing/{month}/{year}', function($month, $year){
|
||||
$totalPaid += $payments->sum('amount');
|
||||
$containerTotalPaid += $payments->sum('amount');
|
||||
|
||||
echo '<span style="color: '.(($invoice->amount - $payments->sum('amount')) < 0.01 ? 'green' : 'red').'"><p style="color: red"><a href="'.route('order.show', $order->reference).'" target="_blank">'.$packingList->reference .'</a> | Amount: '.$invoice->amount.' | Paid: '.$payments->sum('amount').' | Invoice Date: '.$invoice->created_at->format('d-m-Y'). (($invoice->amount - $payments->sum('amount')) < 0.01 ? '' : '('.$invoice->created_at->diffForHumans().')').'</span>';
|
||||
echo '<br><br>';
|
||||
echo '<span style="color: '.(($invoice->amount - $payments->sum('amount')) < 0.01 ? 'green' : 'red').'">'.$packingList->reference.' | Amount: '.$invoice->amount.' | Paid: '.$payments->sum('amount').' | Invoice Date: '.$invoice->created_at->format('d-m-Y'). (($invoice->amount - $payments->sum('amount')) < 0.01 ? '' : '('.$invoice->created_at->diffForHumans().')').'</span>';
|
||||
echo '<br>';
|
||||
|
||||
}
|
||||
|
||||
@@ -571,7 +510,6 @@ Route::get('/container/billing/{month}/{year}', function($month, $year){
|
||||
echo '<h4>Billed Total: '.$containerTotalBilled.'</h4>';
|
||||
echo '<h4>Total Paid: '.$containerTotalPaid.'</h4>';
|
||||
echo '<h4>Outstanding: '.($totalBilled - $containerTotalPaid).'</h4>';
|
||||
echo '<h4>Estimated Cost: '.$containerCost.'</h4>';
|
||||
echo '<br><br><br>';
|
||||
}
|
||||
|
||||
@@ -597,53 +535,4 @@ Route::get('/yd/fix', function(){
|
||||
}
|
||||
});
|
||||
|
||||
Route::get('/billplz/fix', function(){
|
||||
$payments = \App\Models\Transaction::where('type', \App\Classes\ValueObjects\Constants\TransactionType::PAYMENT)->where('payment_method',\App\Classes\ValueObjects\Constants\PaymentMethodType::PAYMENT_GATEWAY)->get();
|
||||
echo '<h3>fixed orders</h3>';
|
||||
foreach ($payments as $payment){
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$payment->payment_reference);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
$invoice = $payment->owner;
|
||||
if(!$invoice){
|
||||
continue;
|
||||
}
|
||||
$packingList = $invoice->owner;
|
||||
$order = $packingList->owner;
|
||||
|
||||
$orderNumber = $order->reference;
|
||||
if(!$data['paid'] && $payment->status === \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED) {
|
||||
echo '<br><span style="color: red">Fraude: <a href="'.route('order.show', $orderNumber).'" target="_blank">'.$orderNumber.'</a></span><br>';
|
||||
continue;
|
||||
}
|
||||
|
||||
if($data['paid']){
|
||||
if($payment->status !== \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED){
|
||||
echo '<a href="'.route('order.show', $orderNumber).'" target="_blank">'.$orderNumber.'</a><br>';
|
||||
}
|
||||
$payment->status = \App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED;
|
||||
$payment->save();
|
||||
|
||||
$invoice->status = \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED;
|
||||
$invoice->save();
|
||||
|
||||
$packingList = $payment->owner->owner;
|
||||
if(app()->environment('production')){
|
||||
try {
|
||||
(App()->make(UpdateDoFromVTPortalProcessor::class))->execute($packingList);
|
||||
(App()->make(UpdateDoFromYDPortalProcessor::class))->execute($packingList);
|
||||
} catch (\Exception $exception){
|
||||
echo '<br><span style="color: red">Malformed Address: <a href="'.route('order.show', $orderNumber).'" target="_blank">'.$orderNumber.'</a></span><br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
echo "billplz error";
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Reference in New Issue
Block a user