diff --git a/routes/web.php b/routes/web.php
index e744480f..15a092c2 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -10,8 +10,11 @@ use App\Classes\Jobs\FetchWarehouseReceiveListFromVTPortalJob;
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;
@@ -460,11 +463,23 @@ 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;
@@ -498,6 +513,48 @@ Route::get('/container/billing/{month}/{year}', function($month, $year){
echo ''.$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().')').'';
echo '
';
+ $packing_list_drop_date = PackingList::where('reference', $packingList->reference)->where('type', 1)->first()->transports->first()->drop_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);
+ }), 3);
+
+ $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);
+ }), 3);
+ $price = $basePrice;
+
+ if($warehouseId === 2358){
+ $price += $yiwuCost;
+ if($packing_list_drop_date >= \Carbon\Carbon::parse('19-9-2022')){
+ $price += $yiwuDiscount;
+ }
+ } else {
+ if($cbm >= 2){
+ $price += $bigParcelDiscount;
+ }
+ if($packing_list_drop_date >= \Carbon\Carbon::parse('19-9-2022')){
+ $price += $discount;
+ }
+ }
+
+ if(in_array($address->state_id,$outstationStates)) {
+ $price += 50;
+ }
+
+ $cost = $price * ($cbm + $over_weight_cbm);
+
+ $containerCost += $cost;
+
+ if(in_array($address->state_id, [13, 14])) {
+ echo 'East Malaysia - ';
+ }
+ echo 'supplier cost:'.$cost;
+ echo '
';
+
}
echo '