diff --git a/app/Classes/General/Eloquent/Filters/DoesNotHaveTransactionType.php b/app/Classes/General/Eloquent/Filters/DoesNotHaveTransactionType.php
index 3568ac3b..4996ac3c 100644
--- a/app/Classes/General/Eloquent/Filters/DoesNotHaveTransactionType.php
+++ b/app/Classes/General/Eloquent/Filters/DoesNotHaveTransactionType.php
@@ -2,6 +2,7 @@
namespace App\Classes\General\Eloquent\Filters;
+use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
class DoesNotHaveTransactionType implements Filter
@@ -15,6 +16,8 @@ class DoesNotHaveTransactionType implements Filter
{
return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
$query->where('type', $value);
+ })->whereHas('containers', function ($query){
+ return $query->whereDate('loading_date', '>=', Carbon::parse('01-09-2022'));
});
}
}
\ No newline at end of file
diff --git a/app/Classes/General/Eloquent/Filters/OwnerIdNotIn.php b/app/Classes/General/Eloquent/Filters/OwnerIdNotIn.php
new file mode 100644
index 00000000..97c7dcba
--- /dev/null
+++ b/app/Classes/General/Eloquent/Filters/OwnerIdNotIn.php
@@ -0,0 +1,20 @@
+whereNotIn('owner_id', $value);
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/General/Eloquent/Filters/PaymentReference.php b/app/Classes/General/Eloquent/Filters/PaymentReference.php
new file mode 100644
index 00000000..5f5d53f5
--- /dev/null
+++ b/app/Classes/General/Eloquent/Filters/PaymentReference.php
@@ -0,0 +1,20 @@
+where('payment_reference', '=', $value);
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/General/Eloquent/Filters/SegmentIdIn.php b/app/Classes/General/Eloquent/Filters/SegmentIdIn.php
new file mode 100644
index 00000000..de66a61f
--- /dev/null
+++ b/app/Classes/General/Eloquent/Filters/SegmentIdIn.php
@@ -0,0 +1,20 @@
+whereIn('segment_id', $value);
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Announcements/Services/CreatesAnnouncement.php b/app/Classes/Modules/Announcements/Services/CreatesAnnouncement.php
index 4a43bac8..dc2b271e 100644
--- a/app/Classes/Modules/Announcements/Services/CreatesAnnouncement.php
+++ b/app/Classes/Modules/Announcements/Services/CreatesAnnouncement.php
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\Announcements\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
use App\Models\Announcement;
+use DateTime;
class CreatesAnnouncement extends AbstractUpdateRecord
{
@@ -18,9 +19,17 @@ class CreatesAnnouncement extends AbstractUpdateRecord
$model = new Announcement();
$model->title = $object->getTitle();
$model->description = $object->getDescription();
- $model->starting_on = $object->getStartingOn();
- $model->ending_on = $object->getEndingOn();
+ // $model->starting_on = $object->getStartingOn();
+ $model->starting_on = $this->convertDateFormat($object->getStartingOn());
+ // $model->ending_on = $object->getEndingOn();
+ $model->ending_on = $this->convertDateFormat($object->getEndingOn());
return $this->handler($model);
}
+
+ public function convertDateFormat($value) {
+ $value = DateTime::createFromFormat('d-m-Y', $value)->format('Y-m-d H:i:s');
+
+ return $value;
+ }
}
diff --git a/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php b/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php
index 0f928a51..69381d4d 100644
--- a/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php
+++ b/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php
@@ -2,6 +2,8 @@
namespace App\Classes\Modules\Billplzs\ControllersLogic;
+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;
@@ -21,6 +23,7 @@ use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
+use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
@@ -35,21 +38,27 @@ class CallbackBillplzLogic
/** @var UpdatesTransactionStatus */
private $updatesTransactionStatus;
- /** @var UpdatesWalletBalance */
- private $updatesWalletBalance;
+ /** @var UpdateDoFromVTPortalProcessor */
+ private $updateDoFromVTPortalProcessor;
+
+ /** @var UpdateDoFromYDPortalProcessor */
+ private $updateDoFromYDPortalProcessor ;
/**
* CallbackBillplzLogic constructor.
* @param GetBillplzBill $getBillplzBill
* @param FetchesTransaction $fetchesTransaction
* @param UpdatesTransactionStatus $updatesTransactionStatus
- * @param UpdatesWalletBalance $updatesWalletBalance
+ * @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
+ * @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
*/
- public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus)
+ public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor)
{
$this->getBillplzBill = $getBillplzBill;
$this->fetchesTransaction = $fetchesTransaction;
$this->updatesTransactionStatus = $updatesTransactionStatus;
+ $this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
+ $this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
}
@@ -58,6 +67,8 @@ class CallbackBillplzLogic
* @return bool|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws MalformedRequestException
* @throws ResourceNotFoundException
+ * @throws \App\Classes\Exceptions\InternalServerErrorException
+ * @throws \GuzzleHttp\Exception\GuzzleException
*/
public function execute(Request $request)
{
@@ -73,6 +84,10 @@ class CallbackBillplzLogic
$transaction = $this->fetchesTransaction->execute(['payment_reference' => $billplzXSignatureObject->getBillPlzId()]);
+ $invoice = $transaction->owner;
+ $packingList = $invoice->owner;
+ $order = $packingList->owner;
+
if($billPlz->state === 'paid') {
$status = ApprovalStatus::APPROVED;
}
@@ -84,8 +99,23 @@ class CallbackBillplzLogic
$token = Auth::fromUser(User::find(1));
$request->headers->set('Authorization', 'Bearer '.$token);
- $marking = $transaction->owner()->first()->owner()->first();
+ $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED);
- return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $marking->reference, 'transaction' => $transaction, 'status' => $status]);
+ if($transaction->amount - $invoice->amount < 0.01) {
+ $this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
+
+ $packingList->status = ApprovalStatus::APPROVED;
+ $packingList->save();
+
+ if(app()->environment('production')){
+ $this->updateDoFromVTPortalProcessor->execute($packingList);
+ $this->updateDoFromYDPortalProcessor->execute($packingList);
+ }
+ }
+
+
+
+
+ return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $order->reference, 'transaction' => $transaction, 'status' => $status]);
}
}
\ No newline at end of file
diff --git a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php
index 5b331fca..4f40da24 100644
--- a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php
+++ b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php
@@ -23,7 +23,7 @@ class CreatesBillplzBill
try{
// config('billplz.maybank')
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
- 'collection_id' => $wallet ? config('billplz.wallet_collection_id') : config('billplz.collection_id'),
+ 'collection_id' => config('billplz.collection_id'),
'name' => $name,
'email' => $email,
'description' => $description,
diff --git a/app/Classes/Modules/Companies/Services/AssignsCompanyToSegment.php b/app/Classes/Modules/Companies/Services/AssignsCompanyToSegment.php
index 81b6e964..9c54d401 100644
--- a/app/Classes/Modules/Companies/Services/AssignsCompanyToSegment.php
+++ b/app/Classes/Modules/Companies/Services/AssignsCompanyToSegment.php
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Companies\Services;
use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
+use App\Classes\ValueObjects\Constants\BusinessType;
use App\Models\Company;
use App\Models\Segment;
use Illuminate\Database\QueryException;
@@ -19,8 +20,9 @@ class AssignsCompanyToSegment extends AbstractUpdateRecord
public function execute(Company $company, Segment $segment)
{
try {
-
- $company->segments()->attach($segment);
+ $companyModule = $company->companyModules()->where('type', BusinessType::IMPORTER)->first();
+ $connection = $companyModule->connections()->where('inviter_reference', 'CIEF');
+ $connection->segments()->attach($segment);
return $company;
diff --git a/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantLogic.php b/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantLogic.php
index 64c41820..99951553 100644
--- a/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantLogic.php
+++ b/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantLogic.php
@@ -102,7 +102,7 @@ class UpdateConstantLogic extends AbstractControllerLogic
$constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $request->input('reference')]);
- $constantValue = $this->updatesConstantValue->execute($constant->value, $request->input('id'), $request->input('value'));
+ $constantValue = $this->updatesConstantValue->execute($constant->value, $request->input('id'), $request->input('rate'));
$object = new ConstantObject($request->input('reference'), $constantValue);
diff --git a/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantPostcodeLogic.php b/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantPostcodeLogic.php
index f39fdb29..ac6dc26e 100644
--- a/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantPostcodeLogic.php
+++ b/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantPostcodeLogic.php
@@ -25,8 +25,8 @@ class UpdateConstantPostcodeLogic extends AbstractControllerLogic
*/
protected function notification():array {
return [
- 'title' => 'Updated Segment Constant',
- 'message' => 'You have successfully updated the Segment Constant'
+ 'title' => 'Updated Postcode Constant',
+ 'message' => 'You have successfully updated the Postcode Constant'
];
}
diff --git a/app/Classes/Modules/Segments/ControllersLogic/UpdateSegmentLogic.php b/app/Classes/Modules/Segments/ControllersLogic/UpdateSegmentLogic.php
index 43eaa54e..f0378691 100644
--- a/app/Classes/Modules/Segments/ControllersLogic/UpdateSegmentLogic.php
+++ b/app/Classes/Modules/Segments/ControllersLogic/UpdateSegmentLogic.php
@@ -70,7 +70,8 @@ class UpdateSegmentLogic extends AbstractControllerLogic
$segment_query = $this->fetchesSegment->execute(['id' => $request->route('id')]);
$segment_object = new SegmentObject(
- $request->input('name', $segment_query->name)
+ $request->input('name'),
+ $segment_query->company_module_id
);
$this->canUpdateSegment->passes($segment_object);
$segment_query = $this->updatesSegment->execute($segment_query, $segment_object);
diff --git a/app/Classes/Modules/Segments/ControllersLogic/UpdateSegmentPriceLogic.php b/app/Classes/Modules/Segments/ControllersLogic/UpdateSegmentPriceLogic.php
new file mode 100644
index 00000000..6f1567a8
--- /dev/null
+++ b/app/Classes/Modules/Segments/ControllersLogic/UpdateSegmentPriceLogic.php
@@ -0,0 +1,124 @@
+ 'Updated Segment Price',
+ 'message' => 'You have successfully updated the Segment Price'
+ ];
+ }
+
+ /** @var CanUpdateConstant */
+ private $canUpdateConstant;
+
+ /** @var UpdatesConstant */
+ private $updatesConstant;
+
+ /** @var FetchesSegment */
+ private $fetchesSegment;
+
+ /** @var FetchesConstant */
+ private $fetchesConstant;
+
+ /** @var CanCreateConstant */
+ private $canCreateConstant;
+
+ /** @var CreatesConstant */
+ private $createsConstant;
+
+ /** @var CreatesSegment */
+ private $createsSegment;
+
+ /** @var UpdatesConstantValue */
+ private $updatesConstantValue;
+
+ /**
+ * UpdateConstantLogic constructor.
+ * @param CanUpdateConstant $canUpdateConstant
+ * @param UpdatesConstant $updatesConstant
+ * @param FetchesSegment $fetchesSegment
+ * @param FetchesConstant $fetchesConstant
+ * @param CanCreateConstant $canCreateConstant
+ * @param CreatesConstant $createsConstant
+ * @param UpdatesConstantValueByState $updatesConstantValueByState
+ * @param CreatesSegment $createsSegment
+ */
+ public function __construct(
+ CanUpdateConstant $canUpdateConstant,
+ UpdatesConstant $updatesConstant,
+ FetchesSegment $fetchesSegment,
+ FetchesConstant $fetchesConstant,
+ CanCreateConstant $canCreateConstant,
+ CreatesConstant $createsConstant,
+ UpdatesConstantValue $updatesConstantValue,
+ CreatesSegment $createsSegment
+ )
+ {
+ $this->canUpdateConstant = $canUpdateConstant;
+ $this->updatesConstant = $updatesConstant;
+ $this->fetchesSegment = $fetchesSegment;
+ $this->fetchesConstant = $fetchesConstant;
+ $this->canCreateConstant = $canCreateConstant;
+ $this->createsConstant = $createsConstant;
+ $this->updatesConstantValue = $updatesConstantValue;
+ $this->createsSegment = $createsSegment;
+ }
+ /**
+ * @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
+ {
+ $segment = $this->fetchesSegment->execute(['id' => $request->route('id')]);
+
+ try {
+
+ $constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $request->input('reference')]);
+
+ $object = new ConstantObject($request->input('reference'), [$request->input('value')]);
+
+ $this->canUpdateConstant->passes($object);
+
+ } catch (ResourceNotFoundException $exception){
+
+ $object = new ConstantObject(
+ $request->input('reference'),
+ [$request->input('value')]
+ );
+
+ $constant = $this->createsConstant->execute($segment, $object);
+ }
+
+ $constant = $this->updatesConstant->execute($constant, $object);
+
+ return $this->resourceResponse(new ConstantResource($constant));
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Transactions/ControllersLogic/ApprovePaymentTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/ApprovePaymentTransactionLogic.php
index 5db49ddf..5fc9cc78 100644
--- a/app/Classes/Modules/Transactions/ControllersLogic/ApprovePaymentTransactionLogic.php
+++ b/app/Classes/Modules/Transactions/ControllersLogic/ApprovePaymentTransactionLogic.php
@@ -9,6 +9,8 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Documents\Services\ApprovesDocument;
use App\Classes\Modules\Documents\Services\FetchesDocument;
use App\Classes\Modules\Documents\Services\RejectsDocument;
+use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
+use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
@@ -20,20 +22,22 @@ use Illuminate\Http\Request;
class ApprovePaymentTransactionLogic extends AbstractControllerLogic
{
/**
- * ApprovePaymentVerificationLogic constructor.
+ * ApprovePaymentTransactionLogic constructor.
* @param FetchesTransaction $fetchesTransaction
* @param UpdatesTransactionStatus $updatesTransactionStatus
* @param ApprovesDocument $approvesDocument
* @param RejectsDocument $rejectsDocument
- * @param FetchesDocument $fetchesDocument
- * @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor
+ * @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
+ * @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
*/
- public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument)
+ public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor)
{
$this->fetchesTransaction = $fetchesTransaction;
$this->updatesTransactionStatus = $updatesTransactionStatus;
$this->approvesDocument = $approvesDocument;
$this->rejectsDocument = $rejectsDocument;
+ $this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
+ $this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
}
/**
@@ -58,10 +62,18 @@ class ApprovePaymentTransactionLogic extends AbstractControllerLogic
/** @var RejectsDocument */
private $rejectsDocument;
+ /** @var UpdateDoFromVTPortalProcessor */
+ private $updateDoFromVTPortalProcessor;
+
+ /** @var UpdateDoFromYDPortalProcessor */
+ private $updateDoFromYDPortalProcessor ;
+
/**
* @param Request $request
* @return JsonResponse
+ * @throws \App\Classes\Exceptions\InternalServerErrorException
* @throws \App\Classes\Exceptions\MalformedRequestException
+ * @throws \GuzzleHttp\Exception\GuzzleException
*/
public function logic(Request $request) : JsonResponse
{
@@ -74,7 +86,25 @@ class ApprovePaymentTransactionLogic extends AbstractControllerLogic
$this->updatesTransactionStatus->execute($transaction, $status === 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
- // $this->createInvoiceTransactionProcessor->execute($transaction->booking);
+ if($transaction->status === ApprovalStatus::APPROVED){
+ $invoice = $transaction->owner;
+ $packingList = $invoice->owner;
+
+ if($transaction->amount - $invoice->amount < 0.01) {
+ $this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
+
+ $packingList->status = ApprovalStatus::APPROVED;
+ $packingList->save();
+
+ if(app()->environment('production')){
+ $this->updateDoFromVTPortalProcessor->execute($packingList);
+ $this->updateDoFromYDPortalProcessor->execute($packingList);
+ }
+ }
+
+ }
+
+
return $this->response([]);
}
diff --git a/app/Classes/Modules/Transactions/ControllersLogic/ApproveShippingInvoiceTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/ApproveShippingInvoiceTransactionLogic.php
index 5bcb33ce..d038bae9 100644
--- a/app/Classes/Modules/Transactions/ControllersLogic/ApproveShippingInvoiceTransactionLogic.php
+++ b/app/Classes/Modules/Transactions/ControllersLogic/ApproveShippingInvoiceTransactionLogic.php
@@ -69,7 +69,7 @@ class ApproveShippingInvoiceTransactionLogic extends AbstractControllerLogic
{
$packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
- $invoice_transaction = $packing_list->transactions->where('type', TransactionType::SHIPPING_INVOICE)->first();
+ $invoice_transaction = $packing_list->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::PENDING_SUBMISSION])->first();
$this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php
index 04de4090..8ba7b2c8 100644
--- a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php
+++ b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php
@@ -18,6 +18,7 @@ use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\PaymentMethodType;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
+use App\Http\Resources\TransactionResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
@@ -83,7 +84,7 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic
$payment_method = PaymentMethodType::PAYMENT_GATEWAY;
$billPlzBill = $this->createsBillplzBill->execute(
$company_module->name,
- $company_module->employees()->first()->email,
+ (app()->environment(['production'])) ? $company_module->employees()->first()->email : 'uldvstar@gmail.com',
'This payment is for the invoice number . ' . $invoice_transaction->bill_no,
$amount,
$billNumber,
@@ -119,6 +120,6 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic
$payment_transaction = $this->createsPaymentTransaction->execute($invoice_transaction, $object);
- return $this->response([]);
+ return $this->resourceResponse(new TransactionResource($payment_transaction));
}
}
diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateShippingInvoiceTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateShippingInvoiceTransactionLogic.php
index 50b6165f..6715133b 100644
--- a/app/Classes/Modules/Transactions/ControllersLogic/CreateShippingInvoiceTransactionLogic.php
+++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateShippingInvoiceTransactionLogic.php
@@ -16,6 +16,7 @@ use App\Classes\Modules\Transactions\DataTransferObjects\TransactionDetailObject
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
+use App\Classes\ValueObjects\Constants\PackingListType;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\PaymentMethodType;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
@@ -25,6 +26,7 @@ use App\Classes\ValueObjects\Constants\SegmentConstants;
use App\Classes\ValueObjects\Constants\TransactionDetailType;
use App\Models\Document;
+use App\Models\PackingList;
use App\Models\Transaction;
use Carbon\Carbon;
use Illuminate\Http\JsonResponse;
@@ -91,16 +93,23 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
public function logic(Request $request) : JsonResponse
{
$packing_list = $this->fetchesPackingList->execute(['id' => $request->input('packing_list_id')]);
+ $packing_list = PackingList::where('reference', $packing_list->reference)->where('type', PackingListType::SHIPPING_PACKING_LIST)->first();
- $cbm = $packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum(function($package) {
+ $billable_packing_list = $packing_list->packingLists()->first();
+
+ $billable_packing_list = $billable_packing_list ? $billable_packing_list : $packing_list;
+
+ $cbm = $billable_packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum(function($package) {
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
});
- $over_weight_cbm = $packing_list->packages->where('type', PackageType::OVER_WEIGHT)->sum(function($package) {
+ $over_weight_cbm = $billable_packing_list->packages->where('type', PackageType::OVER_WEIGHT)->sum(function($package) {
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
});
$order = $packing_list->owner;
+ $companyModule = $order->companyModule;
+ $connection = $companyModule->connections()->first();
$address = $order->addresses()->first();
$base_price_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::BASE_PRICE]);
@@ -109,12 +118,22 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
$center_postcode_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::CENTER_POSTCODE]);
$outstation_postcode_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::OUTSTATION_POSTCODE]);
+ $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 = '';
- $base_price = $this->getConstantByKey($base_price_constant, date('Y-m-d'));
+ $segment_price = $connection->segments()->whereHas('constants')->get()->map(function($segment){
+ return (float) $segment->constants()->first()->value[0];
+ })->sort()->first();
+ $segment_price = $segment_price ? $segment_price : 0;
+
+ $packing_list_drop_date = PackingList::where('reference', $packing_list->reference)->where('type', 1)->first()->transports->first()->drop_date->format('Y-m-d');
+ $base_price = $this->getConstantByKey($base_price_constant, $packing_list_drop_date);
$warehouseId = $order->orderRoles()->where('role_id', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->company_module_id;
$selected_warehouse_rate = $this->getConstantByKey($warehouse_rate_constant, $warehouseId);
@@ -130,8 +149,42 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
$state_rate_constant = (array)$state_rate_constant;
$state_rate = $state_select == '' ? 0 : $state_rate_constant[$state_select];
- $price_cbm = $base_price + $warehouse_rate + $state_rate;
- $total_cbm = $price_cbm * ($cbm + $over_weight_cbm);
+ $container = $packing_list->containers()->first();
+ $containerPackingLists = collect();
+ $hasMinimumCharge = null;
+
+ foreach ($container->packingLists as $packingList){
+ if($packingList->owner->companyModule->id !== $companyModule->id) continue;
+ $containerPackingLists->push($packingList);
+
+ if(!$hasMinimumCharge) {
+ $hasMinimumCharge = $packingList->transactions()->whereHas('transactionDetails', function ($query){
+ $query->where('reference', 'MIN_CBM_CHARGES');
+ })->first();
+ }
+
+ }
+
+ $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->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 = $noMinimumCharge ? 0 : $minimum_charge;
+
+
+ if($hasMinimumCharge) {
+ $minimum_charge = 0;
+ }
+
+ $price_cbm = $base_price + $segment_price + $warehouse_rate + $state_rate;
+
+ $total_cbm = $price_cbm * ($cbm + $minimum_charge + $over_weight_cbm);
$billNumber = $this->generatesTransactionBillNumber->execute('SHIP-');
@@ -158,13 +211,13 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
$object_detail = new TransactionDetailObject(
'SHIPPING_FEE',
- TransactionDetailType::SHIPPING_FEE,
+ TransactionDetailType::SHIPPING_FEE.'
'.round($packing_list->packages->sum('quantity'), 3).' CTNS - '.round($cbm, 3).' CBM',
$cbm,
$price_cbm
);
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
-
+
if ($over_weight_cbm > 0) {
$object_detail = new TransactionDetailObject(
'OVER_WEIGHT_CHARGES',
@@ -176,6 +229,17 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
}
+ if ($minimum_charge > 0) {
+ $object_detail = new TransactionDetailObject(
+ 'MIN_CBM_CHARGES',
+ TransactionDetailType::MIN_CBM_CHARGES,
+ $minimum_charge,
+ $price_cbm
+ );
+
+ $this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
+ }
+
return $this->response([]);
}
@@ -183,6 +247,7 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
if ($segmentConstantObject) {
$base_rate = (array) $segmentConstantObject->value;
$base_rate = array_key_exists($key, $base_rate) === true ? $base_rate[$key] : 0;
+
return $base_rate;
}
}
diff --git a/app/Classes/Modules/Transactions/ControllersLogic/SuspendTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/SuspendTransactionLogic.php
index e824547e..94ec6433 100644
--- a/app/Classes/Modules/Transactions/ControllersLogic/SuspendTransactionLogic.php
+++ b/app/Classes/Modules/Transactions/ControllersLogic/SuspendTransactionLogic.php
@@ -50,10 +50,10 @@ class SuspendTransactionLogic extends AbstractControllerLogic
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
- $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::SUSPENDED);
-
- return $this->response([]);
+ $transaction = $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::SUSPENDED);
+ return $this->resourceResponse(new TransactionResource($transaction));
+
}
diff --git a/app/Classes/Modules/Transactions/ControllersLogic/UpdateShippingInvoiceTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/UpdateShippingInvoiceTransactionLogic.php
index f60130ac..a9bc8f99 100644
--- a/app/Classes/Modules/Transactions/ControllersLogic/UpdateShippingInvoiceTransactionLogic.php
+++ b/app/Classes/Modules/Transactions/ControllersLogic/UpdateShippingInvoiceTransactionLogic.php
@@ -85,7 +85,7 @@ class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic
{
$invoice_transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
- $old_transaction_details = $invoice_transaction->transactionDetails->whereNotIn('reference', ['SHIPPING_FEE', 'OVER_WEIGHT_CHARGES'])->pluck('id')->toArray();
+ $old_transaction_details = $invoice_transaction->transactionDetails->whereNotIn('reference', ['SHIPPING_FEE', 'OVER_WEIGHT_CHARGES', 'MIN_CBM_CHARGES'])->pluck('id')->toArray();
$new_transaction_details = collect($request->input('transaction_details'));
@@ -104,7 +104,7 @@ class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic
foreach($new_transaction_details as $transaction_detail){
$transaction_detail = (object) $transaction_detail;
- if(!in_array($transaction_detail->reference, ['SHIPPING_FEE', 'OVER_WHEIGHT_CHARGES'])){
+ if(!in_array($transaction_detail->reference, ['SHIPPING_FEE', 'OVER_WEIGHT_CHARGES', 'MIN_CBM_CHARGES'])){
$object_detail = new TransactionDetailObject(
'CUSTOM_CHARGES',
isset($transaction_detail->name) ? $transaction_detail->name : TransactionDetailType::CUSTOM_CHARGES,
@@ -117,8 +117,6 @@ class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic
}else{
$new_transaction_detail = $this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
}
-
- $total_cbm += $new_transaction_detail->amount;
}
}
@@ -129,8 +127,8 @@ class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic
$invoice_transaction->issuer,
1,
PaymentMethodType::CASH,
- $total_cbm,
- $total_cbm,
+ $invoice_transaction->transactionDetails()->sum('amount'),
+ $invoice_transaction->transactionDetails()->sum('amount'),
1,
1,
0,
diff --git a/app/Classes/Modules/Transactions/ControllersLogic/UpdateTransactionStatusLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/UpdateTransactionStatusLogic.php
new file mode 100644
index 00000000..1f6085e4
--- /dev/null
+++ b/app/Classes/Modules/Transactions/ControllersLogic/UpdateTransactionStatusLogic.php
@@ -0,0 +1,66 @@
+ 'Update Transaction Status',
+ 'message' => 'You have successfully updated the Transaction Status'
+ ];
+ }
+
+ /** @var FetchesTransaction */
+ private $fetchesTransaction;
+
+ /** @var UpdatesTransactionStatus */
+ private $updatesTransactionStatus;
+
+
+ /**
+ * SuspendTransactionLogic constructor.
+ * @param FetchesTransaction $fetchesTransaction
+ * @param UpdatesTransactionStatus $updatesTransactionStatus
+ */
+ public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus)
+ {
+ $this->fetchesTransaction = $fetchesTransaction;
+ $this->updatesTransactionStatus = $updatesTransactionStatus;
+ }
+
+
+ public function logic(Request $request) : JsonResponse
+ {
+ $approvalArray = [
+ 'approve' => ApprovalStatus::APPROVED,
+ 'expire' => ApprovalStatus::EXPIRED,
+ ];
+
+ $approvalStatus = $approvalArray[$request->route('status')];
+
+ $transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
+
+ $transaction = $this->updatesTransactionStatus->execute($transaction, $approvalStatus);
+
+ return $this->resourceResponse(new TransactionResource($transaction));
+ }
+
+
+
+}
diff --git a/app/Classes/Modules/Transactions/Services/CreatesPaymentTransaction.php b/app/Classes/Modules/Transactions/Services/CreatesPaymentTransaction.php
index 54afd914..98e02693 100644
--- a/app/Classes/Modules/Transactions/Services/CreatesPaymentTransaction.php
+++ b/app/Classes/Modules/Transactions/Services/CreatesPaymentTransaction.php
@@ -22,6 +22,7 @@ class CreatesPaymentTransaction extends AbstractUpdateRelationshipRecord
$model->receiver = $object->getReceiver();
$model->recipient_bank_account_id = $object->getRecipientBankAccountId();
$model->payment_method = $object->getPaymentMethod();
+ $model->payment_reference = $object->getPaymentReference();
$model->amount = $object->getAmount();
$model->original_amount = $object->getOriginalAmount();
$model->currency_id = $object->getCurrencyId();
diff --git a/app/Classes/ValueObjects/Constants/TransactionDetailType.php b/app/Classes/ValueObjects/Constants/TransactionDetailType.php
index b3e1541c..69a15293 100644
--- a/app/Classes/ValueObjects/Constants/TransactionDetailType.php
+++ b/app/Classes/ValueObjects/Constants/TransactionDetailType.php
@@ -4,9 +4,11 @@ namespace App\Classes\ValueObjects\Constants;
final class TransactionDetailType {
- public const SHIPPING_FEE = 'Shipping Fee';
+ public const SHIPPING_FEE = 'X1 Freight Service Charge';
- public const OVER_WEIGHT_CHARGES = 'Over weight charges';
+ public const OVER_WEIGHT_CHARGES = 'Overweight Charges';
+
+ public const MIN_CBM_CHARGES = 'Minimum Charge for 0.3 CBM Per Container';
public const CUSTOM_CHARGES = 'Custom charges';
}
diff --git a/app/Http/Controllers/Companies/AssignCompanyConnectionToConnectionSegmentController.php b/app/Http/Controllers/Companies/AssignCompanyConnectionToConnectionSegmentController.php
index fab9e692..e22c554f 100644
--- a/app/Http/Controllers/Companies/AssignCompanyConnectionToConnectionSegmentController.php
+++ b/app/Http/Controllers/Companies/AssignCompanyConnectionToConnectionSegmentController.php
@@ -10,7 +10,7 @@ class AssignCompanyConnectionToConnectionSegmentController
{
/**
* @param Request $request
- * @param AssignCompanyToSegmentLogic $logic
+ * @param AssignCompanyConnectionToConnectionSegmentLogic $logic
* @return JsonResponse
*/
public function assign(Request $request, AssignCompanyConnectionToConnectionSegmentLogic $logic): JsonResponse {
diff --git a/app/Http/Controllers/Segments/UpdateSegmentPriceController.php b/app/Http/Controllers/Segments/UpdateSegmentPriceController.php
new file mode 100644
index 00000000..4e403348
--- /dev/null
+++ b/app/Http/Controllers/Segments/UpdateSegmentPriceController.php
@@ -0,0 +1,20 @@
+execute($request);
+ }
+
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/Transactions/UpdateTransactionStatusController.php b/app/Http/Controllers/Transactions/UpdateTransactionStatusController.php
new file mode 100644
index 00000000..56ed9868
--- /dev/null
+++ b/app/Http/Controllers/Transactions/UpdateTransactionStatusController.php
@@ -0,0 +1,21 @@
+execute($request);
+ }
+}
diff --git a/app/Http/Resources/AddressResource.php b/app/Http/Resources/AddressResource.php
index f86d5c29..70461cd6 100644
--- a/app/Http/Resources/AddressResource.php
+++ b/app/Http/Resources/AddressResource.php
@@ -21,11 +21,11 @@ class AddressResource extends JsonResource
$centerPostcodeConstantObject = SegmentConstant::where('reference', SegmentConstants::CENTER_POSTCODE)->get();
$centerPostcodeConstant = $centerPostcodeConstantObject->isEmpty() ? [] : (array)$centerPostcodeConstantObject->first()->value;
- $postcodeArea = in_array($this->postcode, $centerPostcodeConstant) ? 'CENTER_POSTCODE' : '';
+ $postcodeArea = in_array((String)$this->postcode, $centerPostcodeConstant) ? 'CENTER_POSTCODE' : null;
$outstationPostcodeConstantObject = SegmentConstant::where('reference', SegmentConstants::OUTSTATION_POSTCODE)->get();
$outstationPostcodeConstant = $outstationPostcodeConstantObject->isEmpty() ? [] : (array)$outstationPostcodeConstantObject->first()->value;
- in_array($this->postcode, $outstationPostcodeConstant) ? $postcodeArea = 'OUTSTATION_POSTCODE' : '';
+ in_array((String)$this->postcode, $outstationPostcodeConstant) ? $postcodeArea = 'OUTSTATION_POSTCODE' : null;
return [
'id' => $this->id,
@@ -34,6 +34,7 @@ class AddressResource extends JsonResource
'street_two' => $this->street_two,
'district' => $this->district,
'state' => $this->state,
+ 'postcode' => $this->postcode,
'post_code' => $this->postcode,
'post_code_area' => $postcodeArea,
'country' => $this->country,
@@ -41,6 +42,7 @@ class AddressResource extends JsonResource
'status' => (int) $this->status,
'contact' => new ContactResource($this->contacts->first()),
'remark' => new RemarkResource($this->remarks->first()),
+ 'type' => $this->type,
$this->mergeWhen($this->relationLoaded('owner'), [
'owner' => $this->when($this->owner instanceof Order, [
'reference' => $this->owner->reference,
diff --git a/app/Http/Resources/CompanyModuleResource.php b/app/Http/Resources/CompanyModuleResource.php
index 51c651f7..22a0557d 100644
--- a/app/Http/Resources/CompanyModuleResource.php
+++ b/app/Http/Resources/CompanyModuleResource.php
@@ -3,6 +3,7 @@
namespace App\Http\Resources;
use App\Classes\Modules\Companies\Services\FetchesCompanyServices;
+use App\Classes\ValueObjects\Constants\AddressType;
use App\Classes\ValueObjects\Constants\BankAccountType;
use App\Classes\ValueObjects\Constants\BusinessType;
use App\Classes\ValueObjects\Constants\DocumentType;
@@ -41,10 +42,12 @@ class CompanyModuleResource extends JsonResource
'name' => $this->name,
'reference' => $this->reference,
'address' => new AddressResource($defaultAddress),
+ 'billingAddress' => new AddressResource($this->addresses()->where('type', AddressType::BILLING)->first()),
'company' => new CompanyResource($this->whenLoaded('company')),
'remarks' => RemarkResource::collection($this->remarks),
'marking' => $marking,
'warehouseCharges' => array_key_exists($this->id, $segmentConstant) ? $segmentConstant[$this->id] : null,
+ 'connections' => $this->connections,
];
}
diff --git a/app/Http/Resources/CompanyResource.php b/app/Http/Resources/CompanyResource.php
index 8e27ab73..899a9405 100644
--- a/app/Http/Resources/CompanyResource.php
+++ b/app/Http/Resources/CompanyResource.php
@@ -27,6 +27,7 @@ class CompanyResource extends JsonResource
'type' => (int) $this->type,
'business_type' => (int) $this->business_type,
'status' => (int) $this->status,
+ 'segments' => SegmentResource::collection($companyModule->connections()->first()->segments),
'contact' => new ContactResource ($this->when($this->has('contacts'), $this->contacts->first())),
'employee' => new UserResource($companyModule->employees()->first()),
'company_module' => new CompanyModuleResource($companyModule),
diff --git a/app/Http/Resources/OrderResource.php b/app/Http/Resources/OrderResource.php
index d2c72930..cbdaeccb 100644
--- a/app/Http/Resources/OrderResource.php
+++ b/app/Http/Resources/OrderResource.php
@@ -46,6 +46,7 @@ class OrderResource extends JsonResource
'received_packages' => PackingListResource::collection($this->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('packages')->get()),
];
}),
+ 'invoices' => TransactionResource::collection($this->transactions()->whereNotIn('transactions.status', [0, 1])->get()),
'remarks' => RemarkResource::collection($this->remarks),
'created_at' => $this->created_at->format('d-m-Y')
];
diff --git a/app/Http/Resources/PackingListResource.php b/app/Http/Resources/PackingListResource.php
index 5256e3de..7dcd6a68 100644
--- a/app/Http/Resources/PackingListResource.php
+++ b/app/Http/Resources/PackingListResource.php
@@ -2,6 +2,7 @@
namespace App\Http\Resources;
+use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\PackingListType;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\RoleTypes;
@@ -34,7 +35,9 @@ class PackingListResource extends JsonResource
$this->mergeWhen($this->owner instanceof Order, [
'order' => New OrderResource($this->owner)
]),
- 'shippng_transaction' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->first()),
+ 'shippng_transaction' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereNotIn('status', [ApprovalStatus::SUSPENDED, ApprovalStatus::EXPIRED])->first()),
+ 'suspended_invoice' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->first()),
+ // 'suspended_invoices' => TransactionResource::collection($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->get()),
];
}
}
diff --git a/app/Http/Resources/SegmentResource.php b/app/Http/Resources/SegmentResource.php
index a587a7ff..2ec22145 100644
--- a/app/Http/Resources/SegmentResource.php
+++ b/app/Http/Resources/SegmentResource.php
@@ -19,7 +19,7 @@ class SegmentResource extends JsonResource
return [
'id' => $this->id,
'name' => $this->name,
- 'price' => $constant ? $constant->value : 0
+ 'price' => $constant ? $constant->value[0] : 0
];
}
}
diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php
index 27840ad8..563eedf0 100644
--- a/app/Http/Resources/TransactionResource.php
+++ b/app/Http/Resources/TransactionResource.php
@@ -26,6 +26,8 @@ class TransactionResource extends JsonResource
'type' => (int) $this->type,
'bill_no' => $this->bill_no,
'amount' => (double) $this->amount,
+ 'payment_method' => (int) $this->payment_method,
+ 'payment_reference' => $this->payment_reference,
'outstanding' => (double) $this->amount - ($this->transactions()->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount')),
'service_charge' => (double) $this->service_charge,
'tax' => (double) $this->tax,
@@ -47,6 +49,7 @@ class TransactionResource extends JsonResource
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::COMPLETED, ApprovalStatus::REJECTED])
->get()
),
+ 'remarks' => RemarkResource::collection($this->remarks),
'expires_on' => Carbon::parse($this->expires_on)->format('d-m-Y h:s:i'),
'updated_at' => Carbon::parse($this->update_at)->format('d-m-Y')
];
diff --git a/app/Models/Order.php b/app/Models/Order.php
index 352f46fb..312cd244 100644
--- a/app/Models/Order.php
+++ b/app/Models/Order.php
@@ -16,10 +16,13 @@ use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphMany;
+use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
+use Staudenmeir\EloquentHasManyDeep\HasRelationships;
class Order extends AbstractModel implements Addressable, Packable, Remarkable, Notifiable
{
use SoftDeletes;
+ use HasRelationships;
protected $table = 'orders';
@@ -160,10 +163,10 @@ class Order extends AbstractModel implements Addressable, Packable, Remarkable,
}
/**
- * @return morphMany
+ * @return hasManyDeep
*/
- // public function transactions(): morphMany
- // {
- // return $this->morphMany(Transaction::class, 'owner');
- // }
+ public function transactions(): hasManyDeep
+ {
+ return $this->hasManyDeep(Transaction::class, [PackingList::class], ['owner_id', 'owner_id'], ['id', 'id']);
+ }
}
diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php
index d2432941..8bca16ed 100644
--- a/app/Models/Transaction.php
+++ b/app/Models/Transaction.php
@@ -3,6 +3,7 @@
namespace App\Models;
use App\Classes\General\Interfaces\Documentable;
+use App\Classes\General\Interfaces\Remarkable;
use App\Classes\General\Interfaces\Transactionable;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
@@ -12,9 +13,12 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\MorphTo;
+use Illuminate\Database\Eloquent\SoftDeletes;
-class Transaction extends AbstractModel implements Documentable, Transactionable
+class Transaction extends AbstractModel implements Documentable, Transactionable, Remarkable
{
+ use SoftDeletes;
+
protected $table = 'transactions';
public function owner(): morphTo
@@ -122,4 +126,12 @@ class Transaction extends AbstractModel implements Documentable, Transactionable
{
return $query->whereIn('status', [ApprovalStatus::COMPLETED]);
}
+
+ /**
+ * @return MorphMany
+ */
+ public function remarks(): morphMany
+ {
+ return $this->morphMany(Remark::class, 'owner');
+ }
}
diff --git a/database/seeders/SegmentConstantsTableSeeder.php b/database/seeders/SegmentConstantsTableSeeder.php
index ef47f580..159c8586 100644
--- a/database/seeders/SegmentConstantsTableSeeder.php
+++ b/database/seeders/SegmentConstantsTableSeeder.php
@@ -28,10 +28,7 @@ class SegmentConstantsTableSeeder extends Seeder
$today = date("Y-m-d");
$prices = [];
for($ii=0; $ii<$n_days;$ii++){
- $prices[] = [
- "date" => date('Y-m-d', strtotime($today. ' + '.$ii.' days')),
- "price" => rand(10, 30) / 10
- ];
+ $prices[date('Y-m-d', strtotime($today. ' + '.$ii.' days'))] = rand(10, 30) / 10;
}
$this->insertData(1, SegmentConstants::BASE_PRICE, $prices);
@@ -127,9 +124,7 @@ class SegmentConstantsTableSeeder extends Seeder
$this->insertData(1, SegmentConstants::OUTSTATION_POSTCODE, $prices);
// insert customer prices
- $prices = [
- ['id'=> 1, 'price' => 15 ]
- ];
+ $prices = [15];
$this->insertData(2, SegmentConstants::CUSTOMER_RATE, $prices);
}
diff --git a/database/seeders/SegmentsTableSeeder.php b/database/seeders/SegmentsTableSeeder.php
index 72545884..9eeca166 100644
--- a/database/seeders/SegmentsTableSeeder.php
+++ b/database/seeders/SegmentsTableSeeder.php
@@ -16,11 +16,11 @@ class SegmentsTableSeeder extends Seeder
'company_module_id' => 1,
'name' => 'Default Segment',
],
- [
- 'id' => 2,
- 'company_module_id' => 2,
- 'name' => 'Normal Member',
- ],
+ [
+ 'id' => 2,
+ 'company_module_id' => 1,
+ 'name' => 'No Minimum Charge',
+ ]
]
);
}
diff --git a/resources/assets/images/fpx-logo-vector-01.png b/resources/assets/images/fpx-logo-vector-01.png
new file mode 100644
index 00000000..e46fd21d
Binary files /dev/null and b/resources/assets/images/fpx-logo-vector-01.png differ
diff --git a/resources/assets/vue/components/addresses/elements/SelectAddressComponent.vue b/resources/assets/vue/components/addresses/elements/SelectAddressComponent.vue
index 492abb73..9b1e597e 100644
--- a/resources/assets/vue/components/addresses/elements/SelectAddressComponent.vue
+++ b/resources/assets/vue/components/addresses/elements/SelectAddressComponent.vue
@@ -52,8 +52,9 @@
value: {
required: false
},
- 'section': {
+ section: {
type: String,
+ default: 'addressSection'
}
},
diff --git a/resources/assets/vue/components/announcements/elements/AnnouncementListComponent.vue b/resources/assets/vue/components/announcements/elements/AnnouncementListComponent.vue
new file mode 100644
index 00000000..0e935c50
--- /dev/null
+++ b/resources/assets/vue/components/announcements/elements/AnnouncementListComponent.vue
@@ -0,0 +1,133 @@
+
+Assign Segment
+
+ Are you Sure?
+
+ {{item.title}}
+
{{item.commenter.name}}
+{{item.content}}
+You can view your invoices here and make payment.
+Marking
+Invoice Date
+Status
+Amount
+Billing Question
+{{item.receive_packing_list.transport.drop_date}}
+{{item.loading_days_ago}}
Container
+Invoice Date
Container Reference
-Due Date
Invoice Date
+Status
+Amount
+Billing Question
+Billing Question
+Total
{{currency}} {{(Math.round((productTotal + Number.EPSILON) * 100) / 100).toFixed(2)}}
{{ data }}
-Total
diff --git a/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue index 72d56a03..8f02c823 100644 --- a/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue @@ -3,16 +3,67 @@Online Banking
+Manual Transfer
+Thank you for your payment. {{$transaction->owner instanceof \App\Models\Booking ? 'Your transfer request is now being processed and you will be notified once its complete.' : 'The amount paid has been successfully credited into your wallet.'}}
+Thank you for your payment. The amount paid has been successfully applied to your invoice.