Compare commits

..

2 Commits

Author SHA1 Message Date
edmondlang ac8ec13433 push branch 2022-12-26 15:56:09 +08:00
94924240Jeko! c73e86e2cf multiple invoices with one payment SDEV-421 2022-12-20 21:14:09 +03:00
61 changed files with 1767 additions and 680 deletions
+807
View File
File diff suppressed because one or more lines are too long
+1
View File
@@ -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);
@@ -1,20 +0,0 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class Receiver implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return Builder|mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->where('receiver', '=', $value);
}
}
+36
View File
@@ -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;
}
}
-47
View File
@@ -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,21 +91,23 @@ 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;
}
if ($transaction->type == 'topUp') {
$this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED);
$this->multipleInvoicesWithOnePaymentLogic->verifypayment($transaction->id, $transaction->amount);
}
if($billPlz->state === 'due') {
$status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION;
}
@@ -123,6 +132,7 @@ class CallbackBillplzLogic
return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $order->reference, 'transaction' => $transaction, 'status' => $status]);
}
}
@@ -22,7 +22,7 @@ class CreatesBillplzBill
public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null, ?bool $wallet = null) {
try{
// config('billplz.maybank')
$requestBody = [
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
'collection_id' => config('billplz.collection_id'),
'name' => $name,
'email' => $email,
@@ -34,13 +34,7 @@ class CreatesBillplzBill
'reference_1' => $bankCode ? $bankCode : '',
'reference_2_label' => 'Bill Number',
'reference_2' => $billNumber
];
if (in_array(app()->environment(), ['development', 'staging', 'production'])) {
$response = Http::withBasicAuth(config('billplz.api_key') . ':', '')->post(config('billplz.base_url') . '/api/v3/bills', $requestBody);
} else {
$response = Http::withoutVerifying()->withBasicAuth(config('billplz.api_key') . ':', '')->post(config('billplz.base_url') . '/api/v3/bills', $requestBody);
}
]);
if($response->successful()){
$data = $response->json();
@@ -1,66 +0,0 @@
<?php
namespace App\Classes\Modules\Companies\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Transactions\Services\ListsTransactions;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Http\Resources\TransactionResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ListCompanyModuleInvoicesLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification(): array
{
return [
'title' => 'Retrieved Company Module Invoices',
'message' => 'You have successfully retrieved a list of Invoices'
];
}
/** @var ListsTransactions */
private $listsTransactions;
/**
* ListCompanyModuleInvoicesLogic constructor.
* @param ListsTransactions $listsTransactions
*/
public function __construct(ListsTransactions $listsTransactions)
{
$this->listsTransactions = $listsTransactions;
}
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\MalformedRequestException
* @throws \App\Classes\Exceptions\RequestValidationException
*/
public function logic(Request $request): JsonResponse
{
$filterArray = [
"per_page" => 10,
"order_by" => (object)[
"column" => 'id',
"DESC" => true,
],
"status_in" => [2],
"receiver" => intval($request->route('company_module_id')),
"type" => TransactionType::SHIPPING_INVOICE
];
// $this->canListTransactions->passes();
$query = $this->listsTransactions->execute($filterArray);
return $this->collectionResponse(TransactionResource::collection($query));
}
}
@@ -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);
}
}
}
@@ -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);
@@ -138,9 +138,11 @@ class multipleInvoicesWithOnePaymentLogic extends AbstractControllerLogic
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;
@@ -164,7 +166,8 @@ class multipleInvoicesWithOnePaymentLogic extends AbstractControllerLogic
$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);
@@ -172,9 +175,6 @@ class multipleInvoicesWithOnePaymentLogic extends AbstractControllerLogic
multipleInvoicesWithOnePayment::create([ 'topUp_request_id' => $transaction->id, 'transaction_id' => $value->id ]);
}
// payment gateway api call
return $this->response([]); ;
@@ -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;
@@ -1,20 +0,0 @@
<?php
namespace App\Http\Controllers\Companies;
use App\Classes\Modules\Companies\ControllersLogic\ListCompanyModuleInvoicesLogic;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ListCompanyModuleInvoicesController
{
/**
* @param Request $request
* @param ListCompanyModulesLogic $logic
* @return JsonResponse
*/
public function list(Request $request, ListCompanyModuleInvoicesLogic $logic): JsonResponse {
return $logic->execute($request);
}
}
@@ -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);
}
}
@@ -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,38 +0,0 @@
<?php
namespace App\Http\Controllers\Transactions;
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);
}
}
+2
View File
@@ -102,9 +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');
}
}
-2
View File
@@ -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';
-2
View File
@@ -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';
+4 -2
View File
@@ -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');
}
}
+31
View File
@@ -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',
];
}
-2
View File
@@ -3,7 +3,6 @@
namespace App\Models;
use App\Classes\General\Interfaces\Transactionable;
use App\Classes\General\Traits\LogData;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -13,7 +12,6 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
class Wallet extends AbstractModel implements Transactionable
{
use SoftDeletes;
use LogData;
protected $table = 'wallets';
/**
Executable → Regular
View File
+2 -1
View File
@@ -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,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
View File
@@ -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"
}
-21
View File
@@ -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>
View File
-55
View File
@@ -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);
-2
View File
@@ -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

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
File diff suppressed because one or more lines are too long
-28
View File
@@ -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>
@@ -1,153 +0,0 @@
<template>
<div class="row">
<div class="col">
<div class="row">
<div class="col-12 col-sm-12 col-md-9">
<div class="row m-b-15 m-l-5 m-r-10">
<div class="col b-a b-grey rounded bg-master-light">
<div class="row">
<div class="col padding-20">
<div class="row align-items-center justify-conten-center" @click="chooseAllInvoice()">
<div class="col-auto pointer">
<i class="fa fs-30 fa-fw" :class="{'fa-square-o': !selectAllInvoice, 'fa-check-square': selectAllInvoice, 'text-primary':selectAllInvoice}" ></i>
</div>
<div class="col">
<h5 class="no-margin font-heading">Invoice No</h5>
</div>
<div class="col">
<h5 class="no-margin">Invoice Date</h5>
</div>
<div class="col">
<h5 class="no-margin">Status</h5>
</div>
<div class="col">
<h5 class="no-margin">Amount</h5>
</div>
<div class="col-auto">
<div class="btn bg-grey no-border muted invisible">
<i class="fa fa-file-pdf-o"></i>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row" v-for="invoice in invoices">
<div class="col">
<payments-billing-components :data="invoice" :selectedInvoice="selectedInvoice" v-on:input="updateList($event)"></payments-billing-components>
</div>
</div>
</div>
<div class="col-12 col-sm-12 col-md-3">
<div class="row align-items-center">
<div class="col b-a b-grey rounded padding-25">
<div class="row">
<div class="col">
<h6 class="semi-bold muted">Payment Summary</h6>
</div>
</div>
<div class="row align-items-center justify-content-center">
<div class="col-auto">
<div class="padding-5">
<i class="fa fa-angle-up"></i>
</div>
</div>
<div class="col p-l-0">
<h6 class="semi-bold text-primary">{{selectedInvoice.length}} Invoice Selected</h6>
</div>
</div>
<div class="row">
<div class="col">
<div class="row" v-for="invoice in selectedInvoice">
<div class="col">
<h6 class="no-margin">lorem ipsum</h6>
</div>
<div class="col-auto">
<h6 class="no-margin">52x62x635 CM</h6>
</div>
</div>
</div>
</div>
<hr>
<div class="row">
<div class="col">
<h6 class="normal">Total Payments</h6>
</div>
<div class="col-auto">
<h6 class="text-primary bold">RM 3300.00</h6>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="btn btn-xl btn-success pointer m-t-10 w-100" @click='makePayment'>Make Payments</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
props: {
company_module_id: {
type: Number,
required: true,
},
},
data(){
return {
section: 'customerPaymentBillingSectionComponent',
isLoading: true,
invoices: null,
selectedInvoice: [],
selectAllInvoice: false,
}
},
computed: {
pendingQueue () {
return this.$store.getters.isInCompleteQueue(this.section);
}
},
watch: {
pendingQueue(inComplete){
if(inComplete){
this.fetchInvoice();
}
}
},
created(){
this.$store.dispatch('updateListQueue', {'name': this.section});
},
methods: {
fetchInvoice(){
this.isLoading = true;
this.submit(route('api.company.invoice.list', this.company_module_id), 'get', this.section, false, false)
},
successHandler(response){
this.$store.dispatch('completeList', {'name': this.section, 'data': []});
this.isLoading = false;
this.invoices = response.payload.data;
},
makePayment(){
var selectedId = this.selectedInvoice.map(s=>s.id);
console.log(selectedId);
},
updateList(packageList){
this.selectedInvoice.includes(packageList) ? this.selectedInvoice.splice(this.selectedInvoice.indexOf(packageList), 1) : this.selectedInvoice.push(packageList);
this.selectedInvoice.length === this.invoices.length ? this.selectAllInvoice = true : this.selectAllInvoice = false;
},
chooseAllInvoice(){
this.selectAllInvoice = !this.selectAllInvoice;
this.selectedInvoice = [];
if (this.selectAllInvoice) {
this.selectedInvoice = this.invoices;
}
}
}
}
</script>
@@ -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>
@@ -4,36 +4,110 @@
<div class="row">
<div class="col padding-20">
<div class="row align-items-center">
<div class="col-auto pointer align-items-center" @click="activate()">
<div class="col-auto pointer align-items-center" @click="selected = !selected">
<i class="fa fs-30 fa-fw" :class="{'fa-square-o': !selected, 'fa-check-square': selected, 'text-primary':selected}" ></i>
</div>
<div class="col">
<h5 class="no-margin">{{ item.bill_no }}</h5>
<h5 class="no-margin">{{item.country.id}}05052021</h5>
</div>
<div class="col">
<h5 class="no-margin">{{ item.created_at }}</h5>
<h5 class="no-margin">Invoice Date Invoice Date</h5>
</div>
<div class="col">
<h5 class="no-margin">Status</h5>
</div>
<div class="col">
<h5 class="no-margin">MYR {{ item.amount.toFixed(2) }}</h5>
<h5 class="no-margin">Amount</h5>
</div>
<div class="col-auto">
<div v-if="item.documents.length">
<div v-for="file in item.documents[0].files" v-bind:key="file.id" class="col-auto no-padding">
<document-file-viewer-component :file="file">
<template slot="button">
<div class="btn bg-grey no-border muted">
<i class="fa fa-file-pdf-o"></i>
</div>
</template>
</document-file-viewer-component>
<div class="btn bg-grey no-border" @click="expanded = !expanded">
<i class="fa" :class="{'fa-angle-down': !expanded, 'fa-angle-up': expanded}" ></i>
</div>
</div>
</div>
</div>
</div>
<div class="row b-t b-grey p-t-10" v-show="expanded">
<div class="col p-b-10">
<div class="row">
<div class="col p-l-20 p-r-20 p-t-10 p-b-10">
<div class="row align-items-center">
<div class="col-auto invisible">
<i class="fa fs-30 fa-fw" :class="{'fa-square-o': !selected, 'fa-check-square': selected, 'text-primary':selected}" ></i>
</div>
<div class="col">
<div class="row">
<div class="col">
<h5 class="m-b-0">Carrier Tracking Number</h5>
</div>
</div>
<div class="row">
<div class="col">
<h5 class="semi-bold m-t-0 m-b-0 large-text">#1zbr06tw403742920</h5>
</div>
</div>
</div>
<div class="col">
<div class="row">
<div class="col">
<h5 class="m-b-0">Due Date</h5>
</div>
</div>
<div class="row">
<div class="col">
<h5 class="semi-bold m-t-0 m-b-0 large-text">11.04.2021</h5>
</div>
</div>
</div>
<div class="col">
<div class="row">
<div class="col">
<h5 class="semi-bold m-t-0 m-b-0 large-text">Outstanding</h5>
</div>
</div>
<div class="row">
<div class="col">
<h5 class="semi-bold m-t-0 m-b-0 large-text">RM0.00</h5>
</div>
</div>
</div>
</div>
<div v-else>
<div class="btn bg-grey no-border muted invisible">
<i class="fa fa-file-pdf-o"></i>
</div>
</div>
<div class="row">
<div class="col p-l-20 p-r-20 p-t-10 p-b-10">
<div class="row align-items-center">
<div class="col-auto invisible">
<i class="fa fs-30 fa-fw" :class="{'fa-square-o': !selected, 'fa-check-square': selected, 'text-primary':selected}" ></i>
</div>
<div class="col">
<div class="row">
<div class="col">
<h5 class="m-b-0 normal-text">This package was delivered by</h5>
</div>
</div>
<div class="row">
<div class="col">
<h5 class="semi-bold m-t-0 m-b-0 large-text">#1zbr06tw403742920</h5>
</div>
</div>
</div>
<div class="col">
<div class="row">
<div class="col">
<h5 class="m-b-0">Date Paid</h5>
</div>
</div>
<div class="row">
<div class="col">
<h5 class="semi-bold m-t-0 m-b-0 large-text">21.01.2021</h5>
</div>
</div>
</div>
<div class="col">
<div class="btn btn-outline-complete btn-lg">
Invoice Detail
</div>
</div>
</div>
</div>
@@ -46,33 +120,10 @@
<script>
import componentHandler from '../../../general/mixins/componentHandler';
export default {
props: {
selectedInvoice: {
type: Array,
required: false,
}
},
data(){
return {
expanded: false,
selectedValue: false,
}
},
methods: {
activate(){
this.select = !this.select;
this.$emit('input', this.data);
}
},
computed: {
selected() {
var response = false;
this.selectedInvoice.forEach((value, index) => {
if (value.id == this.item.id) {
response = true;
}
});
return response;
selected: false,
}
},
mixins: [componentHandler]
+40
View File
@@ -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>
@@ -1,4 +0,0 @@
@extends('layouts.base_portal')
@section('inner_content')
<customer-payment-billing-section-component :company_module_id={{$company_module_id}}></customer-payment-billing-section-component>
@endsection
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -61,11 +61,11 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function
require __DIR__ . '/announcement.php';
require __DIR__ . '/report.php';
require __DIR__ . '/wallet.php';
});
require __DIR__ . '/invoice.php';
require __DIR__ . '/announcement.php';
-2
View File
@@ -33,6 +33,4 @@ Route::group(['prefix' => 'company', 'as' => 'company.', 'namespace' => 'Compani
});
Route::get('/module/list', 'ListCompanyModulesController@list')->name('module.list');
Route::get('/{company_module_id}/invoice/list', 'ListCompanyModuleInvoicesController@list')->name('invoice.list');
});
+10 -1
View File
@@ -6,4 +6,13 @@ use Illuminate\Support\Facades\Route;
Route::get('/group/paymenttransaction/{transactionsArray?}', 'Transactions\MultipleInvoiceOnePaymentController@getallivoiceid')->name('grouppayment');
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)]);
});
+12 -129
View File
@@ -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;
/*
@@ -33,7 +28,13 @@ use Illuminate\Support\Facades\Route;
|
*/
require __DIR__ . '/template.php';
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 () {
@@ -160,12 +161,6 @@ Route::get('/customer/{marking}/details', function ($marking) {
return view('pages.customers.profile_details', ['id' => $id]);
})->name('customer.profile.details');
Route::get('/customer/{marking}/payment-and-billing', function ($marking) {
$connection = CompanyConnection::where('invitee_reference', $marking)->first();
$company_module_id = $connection->invitee->id;
return view('pages.customers.paymentsBilling', ['company_module_id' => $company_module_id]);
})->name('customer.payment-and-billing');
Route::get('/orders/refresh', function(\Illuminate\Http\Request $request){
$packingLists = \App\Models\PackingList::where('type', \App\Classes\ValueObjects\Constants\PackingListType::WAREHOUSE_RECEIVE_LIST)->has('containers')->get();
dd($packingLists);
@@ -204,9 +199,9 @@ Route::get('/order/{id}/download', 'Orders\DownloadOrderQrPdfController@download
Route::get('/report/customclearance/{orderid}', 'Reports\CustomcClearanceReportController@download')->name('report.customclearance');
Route::group(['prefix' => 'template', 'as' => 'template.'], function () {
Route::get('/payment-and-billing', function () {
Route::get('/payments-and-billing', function () {
return view('pages.templates.paymentsBilling');
})->name('payment-and-billing');
})->name('payments-and-billing');
Route::get('/shipping-queue', function () {
return view('pages.templates.shippingQueue');
@@ -471,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;
@@ -500,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;
}
@@ -568,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>';
}
@@ -577,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>';
}
@@ -603,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
View File
Executable → Regular
View File
Executable → Regular
View File
View File
View File
View File
View File
View File
Executable → Regular
View File