Compare commits

...

44 Commits

Author SHA1 Message Date
Jia Sheng Lee acfd16a4b1 export unclaim for arrived parcel 2023-10-05 22:53:32 +08:00
edmondlang c493b3786c update credit_note pdf 2023-09-25 22:34:13 +08:00
edmondlang 99f4699260 update wallet credit note 2023-09-15 18:42:14 +08:00
edmondlang 0ea52048e1 update wallet credit note 2023-09-15 18:37:04 +08:00
edmondlang a47bb95e50 update wallet credit note 2023-09-15 18:32:36 +08:00
edmondlang 431aed18d3 update wallet credit note 2023-09-15 18:03:39 +08:00
edmondlang 6ab289057b wallet credit note 2023-09-15 17:34:16 +08:00
JiaSheng c55a8e7af9 fix account statement mapping issue 2023-09-14 14:59:02 +08:00
Omair Saleh fbf097eb62 fix wallet transaction history and top up list bug 2023-09-13 14:22:36 +08:00
Omair Saleh 30c2673fdf fix wallet transaction history and top up list bug 2023-09-13 13:59:49 +08:00
Omair Saleh fd3709e103 fix wallet transaction history and top up list bug 2023-09-13 13:59:08 +08:00
Omair Saleh 08473d85ab fix wallet transaction history and top up list bug 2023-09-13 13:58:29 +08:00
Omair Saleh 489974ca5a fix wallet transaction history and top up list bug 2023-09-13 13:55:21 +08:00
Omair Saleh 6a6a0f0ee7 fix wallet transaction history and top up list bug 2023-09-13 13:46:20 +08:00
Omair Saleh 402f64364b export arrived parcel improvements 2023-09-01 05:27:13 +08:00
Omair Saleh a3bff9d079 export arrived parcel improvements 2023-09-01 05:26:32 +08:00
Omair Saleh 2a7a448059 export arrived parcel improvements 2023-09-01 05:25:41 +08:00
Omair Saleh 7d855064da export arrived parcel improvements 2023-09-01 05:24:47 +08:00
Omair Saleh efc0a3b94e export arrived parcel improvements 2023-09-01 05:24:05 +08:00
Omair Saleh 01654ee0d3 export arrived parcel improvements 2023-09-01 05:22:58 +08:00
Omair Saleh 23c2f92e6d export arrived parcel improvements 2023-09-01 05:21:32 +08:00
Omair Saleh 3945c47f52 export arrived parcel improvements 2023-09-01 05:20:36 +08:00
Omair Saleh 51ab6ce48b export arrived parcel improvements 2023-09-01 05:19:33 +08:00
Omair Saleh ca8140a1ba export arrived parcel improvements 2023-09-01 05:17:35 +08:00
Omair Saleh a84580c1dd export arrived parcel improvements 2023-09-01 05:14:07 +08:00
Omair Saleh 63b212a66c export arrived parcel improvements 2023-09-01 05:13:21 +08:00
Omair Saleh 7979d89997 export arrived parcel improvements 2023-09-01 05:00:36 +08:00
Omair Saleh bc603fc125 Merge remote-tracking branch 'origin/master' 2023-09-01 04:54:17 +08:00
Omair Saleh b55fd49830 export arrived parcel improvements 2023-09-01 04:54:00 +08:00
edmondlang 60ceac645f fix bug invoices/approve 2023-08-24 14:36:47 +08:00
Dillon Ngo 90c599049b Merge branch 'dillon/42-crm-code-sync-with-exchange-b' into 'master'
CRM invoice decimal problem fix + fetch invoice fail fix + debug log update

See merge request CIEFWorldwideSdnBhd/shipping-portal!170
2023-08-23 20:59:33 +00:00
Omair Saleh a45105f5ae fix yd api 2023-08-23 14:08:47 +08:00
Omair Saleh 2f1a8ee648 fix yd api 2023-08-23 14:06:43 +08:00
Omair Saleh aacf4ea53d fix yd api 2023-08-23 14:05:15 +08:00
Omair Saleh 1fa2b60871 fix duplicate packages 2023-08-22 15:40:44 +08:00
Omair Saleh 203dc0c230 fix duplicate packages 2023-08-22 15:39:42 +08:00
Omair Saleh fcc4da1a56 fix duplicate packages 2023-08-22 15:24:38 +08:00
Omair Saleh c5a49bbc44 fix duplicate packages 2023-08-22 15:21:47 +08:00
Omair Saleh f8131b3a1e fix duplicate packages 2023-08-22 15:20:06 +08:00
Omair Saleh 336cc0b37f Merge remote-tracking branch 'origin/master' 2023-08-22 15:05:58 +08:00
Omair Saleh 42f096b09c fix duplicate packages 2023-08-22 15:01:44 +08:00
Dillon Ngo 614167cac5 Merge branch 'dillon/42-crm-code-sync-with-exchange-a' into 'master'
Update condition to update CRM task status

See merge request CIEFWorldwideSdnBhd/shipping-portal!169
2023-08-20 08:02:07 +00:00
Dillon Ngo 8dc84baee0 Merge branch 'dillon/42-crm-code-sync-with-exchange-a' into 'master'
CRM Integration (Part 2 of code sync with Exchange-2.0)

See merge request CIEFWorldwideSdnBhd/shipping-portal!168
2023-08-19 21:43:07 +00:00
Dillon Ngo 0a98f8a8c6 Merge branch 'dillon/42-crm-code-sync-with-exchange-a' into 'master'
Quick fix

See merge request CIEFWorldwideSdnBhd/shipping-portal!167
2023-08-18 04:14:46 +00:00
19 changed files with 389 additions and 75 deletions
@@ -0,0 +1,20 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class PaymentMethodNotIn implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return Builder|mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->whereNotIn('payment_method', $value);
}
}
@@ -15,9 +15,17 @@ use App\Classes\ValueObjects\Constants\OrderRoleTypes;
class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, FromQuery
{
use Exportable;
private $start_date;
private $end_date;
public function __construct($start_date = null, $end_date = null)
{
$this->start_date = $start_date;
$this->end_date = $end_date;
}
public function headings(): array
{
return [
@@ -26,48 +34,66 @@ class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping,
'Warehouse',
'Cbm',
'Description',
'quantity',
'Quantity',
'Received Date',
'Recorded On',
'Days to Record',
'Remarks'
];
}
/**
* @return \Illuminate\Support\Collection|mixed
*/
public function query()
{
return PackingList::where('type', '=', 1)->where('status', '=', 2)->where('owner_type', Order::class);
$query = PackingList::with([
// 'owner.companyModule.inviters',
// 'owner.orderRoles',
'packages',
'transports'
])
->where('type', '=', 1);
// ->where('status', '=', 2)
// ->where('owner_type', Order::class);
if (!is_null($this->start_date) && !is_null($this->end_date)) {
$query->whereHas('transports', function ($q) {
$q->whereBetween('drop_date', [
Carbon::parse($this->start_date)->startOfDay(),
Carbon::parse($this->end_date)->endOfDay()
]);
});
}
return $query;
}
/**
* @param $packingList
* @return array
*/
public function map($packingList): array
{
$order = $packingList->owner;
$connection = $order->companyModule()->first()->inviters()->withPivot('invitee_reference')->first();
$marking = $connection ? $connection->pivot->invitee_reference:'';
$warehouse = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee;
$cbm = $packingList->packages->sum(function($package){
return (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
$order = null;
$marking = null;
$warehouse = null;
if ($packingList->owner instanceof Order) {
$order = $packingList->owner;
$marking = $order->companyModule->getMarking();
$warehouse = $order->orderRoles->firstWhere('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->appointee;
}
$cbm = $packingList->packages->sum(function ($package) {
return (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
});
$arrival_date = $packingList->transports()->first()->drop_date->format('d-m-Y');
$arrival_date = $packingList->transports->first()->drop_date->format('d-m-Y');
$recorded_on = $packingList->created_at->format('d-m-Y');
$days_to_record = Carbon::parse($arrival_date)->diffInDays(Carbon::parse($recorded_on));
return [
$packingList->owner->reference,
$marking,
$warehouse->reference,
$order ? $order->reference : 'Unclaimed',
$marking ? $marking : 'Unclaimed',
$warehouse ? $warehouse->reference : 'Unclaimed',
$cbm,
$packingList->packages->implode('description', ', '),
$packingList->packages->sum('quantity'),
$arrival_date,
$recorded_on,
$days_to_record,
''
];
}
}
}
@@ -94,7 +94,8 @@ class FetchContainersFromYdPortalProcessor
*/
public function execute()
{
$packingLists = PackingList::where('type', PackingListType::SHIPPING_PACKING_LIST)->doesntHave('containers')->get();
$maxFetchTime = Carbon::now()->subMonths(4);
$packingLists = PackingList::where('type', PackingListType::SHIPPING_PACKING_LIST)->whereDate('created_at', '>=', $maxFetchTime)->doesntHave('containers')->get();
foreach ($packingLists as $packingList) {
$time_start = microtime(true);
@@ -0,0 +1,48 @@
<?php
namespace App\Classes\Modules\Transactions\ControllersLogic;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
use App\Classes\ValueObjects\Constants\TransactionType;
class GenerateCreditNotePdfLogic
{
/** @var FetchesTransaction */
private $fetchesTransaction;
/** @var FetchesCompanyModule */
private $fetchesCompanyModule;
/**
* GenerateCreditNotePdfLogic constructor.
* @param FetchesTransaction $fetchesTransaction
* @param FetchesCompany $fetchesCompany
*/
public function __construct(FetchesTransaction $fetchesTransaction, FetchesCompanyModule $fetchesCompanyModule)
{
$this->fetchesTransaction = $fetchesTransaction;
$this->fetchesCompanyModule = $fetchesCompanyModule;
}
/**
* @param Request $request
* @return string|\Symfony\Component\HttpFoundation\Response
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(Request $request)
{
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
$supplier = $this->fetchesCompanyModule->execute(['id' => $transaction->receiver]);
$pdf = LaravelMpdf::loadView('pages.pdfs.credit_note', ['transaction' => $transaction, 'supplier' => $supplier]);
return $pdf->stream('CreditNote.pdf');
}
}
@@ -10,6 +10,7 @@ use App\Classes\Modules\Wallets\Services\UpdatesWallet;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Companies\Services\FetchesCompany;
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
@@ -29,6 +30,9 @@ class CreditWalletLogic extends AbstractControllerLogic
}
/** @var FetchesCompanyModule */
private $fetchesCompanyModule;
/** @var FetchesCompany */
private $fetchesCompany;
@@ -62,6 +66,7 @@ class CreditWalletLogic extends AbstractControllerLogic
*/
public function __construct(
FetchesCompany $fetchesCompany,
FetchesCompanyModule $fetchesCompanyModule,
GeneratesWalletCode $generatesWalletCode,
CreatesWallet $createsWallet,
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
@@ -71,6 +76,7 @@ class CreditWalletLogic extends AbstractControllerLogic
)
{
$this->fetchesCompany = $fetchesCompany;
$this->fetchesCompanyModule = $fetchesCompanyModule;
$this->generatesWalletCode = $generatesWalletCode;
$this->createsWallet = $createsWallet;
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
@@ -88,13 +94,13 @@ class CreditWalletLogic extends AbstractControllerLogic
{
$amount = floatval(str_replace(',', '', $request->input('amount')));
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
$reference = $request->input('reference');
$type = $request->input('transaction_type');
$wallet = $this->creditWalletProcessor->execute($company, $type, $amount, $reference);
$wallet = $this->creditWalletProcessor->execute($companyModule, $type, $amount, $reference);
return $this->resourceResponse(new WalletResource($wallet));
}
@@ -11,9 +11,11 @@ use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\PaymentMethodType;
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
use App\Classes\Modules\Transactions\Services\CreatesTransactionableTransaction;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
use App\Models\CompanyModule;
class CreditWalletProcessor
{
@@ -29,6 +31,9 @@ class CreditWalletProcessor
/** @var CreatesTransaction */
private $createsTransaction;
/** @var CreatesTransactionableTransaction */
private $createsTransactionableTransaction;
/** @var UpdatesWallet */
private $updatesWallet;
@@ -38,6 +43,7 @@ class CreditWalletProcessor
* @param CreatesWallet $createsWallet
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
* @param CreatesTransaction $createsTransaction
* @param CreatesTransactionableTransaction $createsTransactionableTransaction
* @param UpdatesWallet $updatesWallet
*/
public function __construct(
@@ -45,6 +51,7 @@ class CreditWalletProcessor
CreatesWallet $createsWallet,
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
CreatesTransaction $createsTransaction,
CreatesTransactionableTransaction $createsTransactionableTransaction,
UpdatesWallet $updatesWallet
)
{
@@ -52,32 +59,33 @@ class CreditWalletProcessor
$this->createsWallet = $createsWallet;
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
$this->createsTransaction = $createsTransaction;
$this->createsTransactionableTransaction = $createsTransactionableTransaction;
$this->updatesWallet = $updatesWallet;
}
/**
* @param Company $company
* @param CompanyModule $companyModule
* @param int $transactionType
* @param float $amount
* @param string $reference
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(Company $company, int $transactionType, float $amount, string $reference)
public function execute(CompanyModule $companyModule, int $transactionType, float $amount, string $reference)
{
if (!$company->wallets()->first()) {
$object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute());
$this->createsWallet->execute($object, $company);
if (!$companyModule->wallets()->first()) {
$object = new WalletObject($companyModule->id, 1, $this->generatesWalletCode->execute());
$this->createsWallet->execute($object, $companyModule);
}
/** @var Wallet $wallet */
$wallet = $company->wallets()->first();
$wallet = $companyModule->wallets()->first();
$billNumber = $this->generatesTransactionBillNumber->execute($transactionType === 2 ? 'DEBIT-NOTE-' : 'CREDIT-NOTE-');
$transaction_object = new TransactionObject($billNumber, $transactionType === 2 ? TransactionType::DEBIT_NOTE : TransactionType::CREDIT_NOTE, 1, $wallet->owner->id, 1, PaymentMethodType::CASH, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], $reference);
$transaction = $this->createsTransaction->execute($wallet, $transaction_object);
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
$updateWalletAmount = $transactionType === 2 ? ($wallet->amount - $transaction->amount) : ($wallet->amount + $transaction->amount);
@@ -75,14 +75,14 @@ class FixBillplzFailedCallbackPayment extends Command
*/
public function handle()
{
ini_set('memory_limit', '-1');
ini_set('memory_limit', '-1');
$this->outputArray = [];
$this->outputArray = [];
$start = new Carbon();
$approvalStatusArray = ApprovalStatus::APPROVAL_STATUS_ID;
$transactions = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
$transactions = Transaction::whereIn('type', [TransactionType::PAYMENT, TransactionType::TOP_UP])->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
$totalTransactions = count($transactions);
if ($totalTransactions) {
@@ -93,7 +93,7 @@ class FixBillplzFailedCallbackPayment extends Command
$totalAmount = 0;
foreach ($transactions as $transaction){
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference);
if($response->successful()){
$data = $response->json();
if($data['paid']){
@@ -122,36 +122,36 @@ class FixBillplzFailedCallbackPayment extends Command
// $billPlz = $this->getBillplzBill->execute($billplzXSignatureObject->getBillPlzId());
// if(!$billPlz) throw new ResourceNotFoundException('Billplz bill not found.');
// $transaction = $this->fetchesTransaction->execute(['payment_reference' => $billplzXSignatureObject->getBillPlzId()]);
$invoice = $transaction->owner;
$packingList = $invoice->owner;
$order = $packingList->owner;
$status = ApprovalStatus::PENDING_VERIFICATION;
if($data['state'] === 'paid') {
$status = ApprovalStatus::APPROVED;
}
// if($data->state === 'due') {
// $status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION;
// }
// $token = Auth::fromUser(User::find(1));
// $request->headers->set('Authorization', 'Bearer '.$token);
$this->updatesTransactionStatus->execute($transaction, $status);
$totalPaidAmount = $invoice->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
if(($invoice->amount - $totalPaidAmount) < 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);
@@ -170,7 +170,7 @@ class FixBillplzFailedCallbackPayment extends Command
$this->info($counter . ' of ' . $totalTransactions . '. Order: '. $order->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount . '. Status: ' . $approvalStatusArray[$transaction->status] . '. Invoice Status: ' . $invoiceStatus);
}
}
} else {
// $totalAmount += $transaction->amount;
// $this->appendToOutput($counter . ' of ' . $totalTransactions . '. Order: '. $transaction->owner->owner->owner->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount);
@@ -180,7 +180,7 @@ class FixBillplzFailedCallbackPayment extends Command
}
$counter++;
}
$end = new Carbon();
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
@@ -23,7 +23,11 @@ class ExportArrivedParcelController
}
public function export(Request $request) {
$exportsPendingArrangementDeliveryList = new ExportsArrivedParcel($request);
$startDate = $request->query('start_date');
$endDate = $request->query('end_date');
$exportsPendingArrangementDeliveryList = new ExportsArrivedParcel($startDate, $endDate);
$response = $exportsPendingArrangementDeliveryList->download('arrived-parcel.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
ob_end_clean();
return $response;
@@ -0,0 +1,15 @@
<?php
namespace App\Http\Controllers\Transactions;
use Illuminate\Http\Request;
use App\Classes\Modules\Transactions\ControllersLogic\GenerateCreditNotePdfLogic;
use Illuminate\Http\JsonResponse;
class GenerateCreditNotePdfController
{
public function download(Request $request, GenerateCreditNotePdfLogic $logic) {
return $logic->execute($request);
}
}
@@ -26,7 +26,7 @@ class MappableTransactionResource extends JsonResource
$reference = $this->owner->owner->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
}
if($this->type === TransactionType::PAYMENT && $this->owner !== Wallet::class){
if($this->type === TransactionType::PAYMENT && $this->owner_type !== Wallet::class){
$reference = $this->owner->owner->owner->reference;
}
@@ -34,7 +34,7 @@ class MappableTransactionResource extends JsonResource
'status' => 'success',
'system' => 'SHIPPING_PORTAL',
'type' => $this->type,
'owner_type' => $this->owner_type,
'owner_type' => Transaction::class,
'owner_id'=> $this->id,
'owner_reference'=> $reference,
];
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Http\Resources;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
use Illuminate\Http\Resources\Json\JsonResource;
@@ -21,8 +22,8 @@ class WalletResource extends JsonResource
'currency_id' => $this->currency_id,
'amount' => (double) $this->amount,
'company_id' => (int) $this->owner->id,
'transactions' => $this->whenLoaded('transactions', WalletTransactionResource::collection($this->transactions()->whereIn('status', [2, 3])->orderBy('id', 'DESC')->get()), []),
'top_up_records' => $this->whenLoaded('transactions', WalletTransactionResource::collection($this->transactions()->whereNotIn('status', [0])->where('type', TransactionType::TOP_UP)->orderBy('id', 'DESC')->get()), []),
'transactions' => $this->whenLoaded('transactions', WalletTransactionResource::collection($this->transactions()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->orderBy('id', 'DESC')->get()), []),
'top_up_records' => $this->whenLoaded('transactions', WalletTransactionResource::collection($this->transactions()->whereIn('type', [TransactionType::TOP_UP])->orderBy('id', 'DESC')->get()), []),
'company_module_marking' => $this->owner->connections->first()->invitee_reference,
];
}
@@ -45,6 +45,7 @@ class WalletTransactionResource extends JsonResource
}
return [
'id' => (int) $this->id,
'type' => (int) $this->type,
'marking' => $this->owner->owner->reference,
'bill_no' => $this->bill_no,
+8 -2
View File
@@ -29,7 +29,7 @@ use App\Classes\General\Interfaces\Remarkable;
* Class CompanyModule
* @package App\Models
*
* @property \App\Models\Company company_id
* @property \App\Models\Company company_id
* @property integer type
* @property integer status
*/
@@ -111,6 +111,12 @@ class CompanyModule extends AbstractModel implements Addressable, Documentable,
return $this->hasMany(CompanyConnection::class, 'invitee_id');
}
public function getMarking()
{
$connection = $this->connections()->first();
return $connection ? $connection->invitee_reference : '';
}
/**
* @return HasMany
*/
@@ -193,7 +199,7 @@ class CompanyModule extends AbstractModel implements Addressable, Documentable,
{
return $this->hasManyDeep(Transaction::class, [Order::class], ['company_module_id', 'owner_id'], ['id', 'id']);
}
/**
* @return MorphMany
*/
@@ -17,7 +17,7 @@
<div class="col">
<div class="row" v-if="section === 'customerPendingPaymentInvoiceComponent'">
<div class="col m-b-15">
<wallet-component :company_module_id="company_module_id" section="billingWalletSection"></wallet-component>
<wallet-component :company_module_id="company_module_id" section="billingWalletSection" :creditable=true></wallet-component>
</div>
</div>
<div class="b-a b-grey rounded padding-25 bg-white">
@@ -69,7 +69,7 @@
this.canSubmitChanges = !this.canSubmitChanges;
this.parameters.transaction_details = this.details;
console.log(this.parameters.transaction_details);
// console.log(this.parameters.transaction_details);
this.submit(this.route('api.transaction.invoice.update', this.data.id), 'put', this.section, true, true);
}
@@ -21,7 +21,7 @@
<div class="row bg-white padding-10 m-b-10 rounded align-items-center" v-for="(item, index) in wallet.transactions" v-bind:key="item.id" :data="item">
<div class="col-3 fs-12">{{item.created_at}}</div>
<div class="col fs-12" v-html="item.description"></div>
<div class="col fs-12"><span v-html="item.description"></span> <a target=”_blank” v-if="[9,11].includes(item.type) " :href="route('transaction.credit_note.download', item.id)"><i class="fa fa-download fs-11 m-l-5 text-secondary hover-primary"></i></a></div>
<div class="col-2 text-success text-center">{{[5, 9].includes(parseFloat(item.type)) ? (Math.round((parseFloat(item.amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : ''}}</div>
<div class="col-2 text-danger text-center">{{[2, 11].includes(parseFloat(item.type)) ? '- ' + (Math.round((parseFloat(item.amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : ''}}</div>
<div class="col-2 text-right">{{remainingBalance(index)}}</div>
@@ -52,7 +52,7 @@
</div>
</div>
<div class="col-4">
<wallet-component :data="wallet" :company_module_id="id" section="CompanyWalletTransactionSection"></wallet-component>
<wallet-component :data="wallet" :company_module_id="id" section="CompanyWalletTransactionSection" :creditable=true></wallet-component>
<div class="row m-t-20">
<div class="col">
<div class="row m-b-10">
@@ -0,0 +1,114 @@
@extends('layouts.base_pdf')
@section('inner_content')
<br>
<htmlpageheader name="page-header">
<br><br>
<div class="separator"><strong><i>{{ $transaction->bill_no }}</i></strong></div>
</htmlpageheader>
<table>
<tr>
<td class="header-logo">
<img src="{{ asset('images/ri_1.png') }}" alt="logo" id="logo" class="logo">
</td>
<td class="header-cief-address">
<span class="company-name">
<strong>
CIEF WORLDWIDE SDN BHD
</strong>
</span>
<span class="company-reg">(1134596-M)</span><br>
No. 72-3, Jalan Jalil 1,<br>
The Earth Bukit Jalil,<br>
57000 Kuala Lumpur<br>
Tel: 03-8082 1252
</td>
<td class="header-details">
<div class="title">
<strong>
{{ $transaction->type == 9 ? 'Credit' : 'Debit' }} Note
</strong>
</div>
<div class="date">Date: {{ $transaction->created_at }}</div>
<div>&nbsp;</div>
</div>
</td>
<tr>
<td colspan="3" class="bill-to">
<span class="sub-title">
{{ $transaction->type == 9 ? 'Credit' : 'Debit' }} To
</span>
</td>
</tr>
<tr>
<td colspan="3" class="address">
<div class="label">
{{ $supplier->name }}
</div>
<div class="address">
@php
$addresses = $supplier->addresses()->where('type', 1)->first();
@endphp
@if($addresses)
{{ $addresses->street_one }}
{{ $addresses->street_two }} ,
{{ $addresses->district()->first()->name }},
{{ $addresses->postcode }}
{{ $addresses->state()->first()->name }},
{{ $addresses->country()->first()->name }}
@endif
</div>
<div>
@php
$contact = $supplier->contacts()->first();
@endphp
Phone: {{ $contact ? $contact->phone : '' }}
</div>
</td>
</tr>
</table>
<br>
<br>
<table class="line-table" style="overflow: wrap" autosize="1">
<thead>
<tr>
<th width="5%">No</th>
<th class="description">Description</th>
<th width="10%">Quantity</th>
<th width="15%">Unit Price (RM)</th>
<th width="10%">Total Amount<br>(RM)</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%" class="center top">1</td>
<td class="description">{{ ucfirst($transaction->payment_reference) }}</td>
<td width="10%" class="center top">1</td>
<td width="15%" class="center top">
{{ number_format($transaction->amount, 2) }}
</td>
<td width="20%" class="right top">
{{ number_format($transaction->amount, 2) }}
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3"></td>
<td class="right middle">Total</td>
<td class="total right middle">
{{ number_format($transaction->amount, 2) }}
</td>
</tr>
</tfoot>
</table>
<htmlpagefooter name="page-footer">
<table width="100%">
<tr>
<td style="text-align: right; ">This is generated by computer. No signature required.</td>
<td style="text-align: right; ">Page {PAGENO} of {nbpg}</td>
</tr>
</table>
</htmlpagefooter>
@endsection
+23 -11
View File
@@ -1,22 +1,34 @@
@extends('layouts.base_portal')
@section('inner_content')
<div class="row">
<div class="col-5">
<div class="col-8">
<div class="row p-b-5 b-b b-grey m-b-10 m-l-0 m-r-0">
<div class="col no-padding">
<h6>Arrived Parcel</h6>
</div>
</div>
<a href="{{route('packing_list.arrived_parcel.export')}}" target="_blank">
<button type="button" class="btn btn-sm p-t-10 p-b-10 p-r-35 p-l-35 btn-primary b-rad-none">
<div class="row align-items-center">
<div class="col-auto p-r-0 p-l-0">
<i class="fa fa-file-excel-o fs-16"></i>
</div>
<div class="col p-r-5">Export To Excel</div>
<form action="{{route('packing_list.arrived_parcel.export')}}" method="GET" target="_blank">
<div class="form-group row">
<label for="start_date" class="col-sm-2 col-form-label">Start Date</label>
<div class="col-sm-10">
<input type="date" class="form-control" id="start_date" name="start_date">
</div>
</button>
</a>
</div>
<div class="form-group row">
<label for="end_date" class="col-sm-2 col-form-label">End Date</label>
<div class="col-sm-10">
<input type="date" class="form-control" id="end_date" name="end_date">
</div>
</div>
<div class="form-group row">
<div class="col-sm-10 offset-sm-2">
<button type="submit" class="btn btn-primary">Export</button>
</div>
</div>
</form>
<list-component section="warehouseListSection" :endpoint="route('api.packing_list.list')" :options="{packing_list_type: 1, per_page: 20, order_by: {column: 'arrival_date', DESC: true}, with_arrival_date: true}" >
<template slot="list" slot-scope="{data}">
<parcel-component v-for="packages in data.packages" :data="packages" :key="packages.id"></parcel-component>
@@ -48,4 +60,4 @@
</list-component>
</div>
</div>
@endsection
@endsection
+54 -2
View File
@@ -35,6 +35,7 @@ use App\Models\CompanyConnection;
use App\Models\CompanyModule;
use App\Models\Document;
use App\Models\Order;
use App\Models\Package;
use App\Models\PackingList;
use Carbon\Carbon;
use Illuminate\Http\Request;
@@ -379,7 +380,7 @@ Route::get('/yd', function (Request $request){
(App()->make(FetchPackingListsFromYdPortalProcessor::class))->execute($start, $end);
(App()->make(FetchContainersFromYdPortalProcessor::class))->execute();
(App()->make(FetchContainersUpdatesFromYdPortalProcessor::class))->execute();
(App()->make(FetchDeliveryUpdatesFromYdPortalProcessor::class))->execute();
// (App()->make(FetchDeliveryUpdatesFromYdPortalProcessor::class))->execute();
// (App()->make(FetchPackingListFromVTPortalProcessor::class))->execute();
})->name('yd.refresh');
@@ -864,11 +865,14 @@ Route::get('/invoices/combine/{ids}', function($ids){
// })->name('generate.invoices');
Route::get('/invoices/approve', function(Request $request){
// whereDoesntHave
$invoices = Transaction::where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::PENDING_SUBMISSION)->get();
foreach ($invoices as $invoice) {
$packingList = $invoice->owner;
if (!$packingList) {
dump ('Error packingList not found. Invoice ID - ' . $invoice->id);
continue;
}
$order = $packingList->owner;
if ($request->input('exclude')){
@@ -1140,3 +1144,51 @@ Route::get('/final-duplicated-invoice-debug', function(){
echo '</table>';
});
Route::get('/duplicate-package-clean-up', function(){
// Fetching duplicate rows based on given columns
$duplicates = Package::select('packing_list_id', 'description', 'width', 'height', 'weight', 'quantity', DB::raw('COUNT(*) as count'))
->groupBy('packing_list_id', 'description', 'width', 'height', 'weight', 'quantity')
->havingRaw('COUNT(*) > 1')
->get();
$totalGroups = 0;
// Loop through each group of duplicates
foreach ($duplicates as $duplicate) {
$totalGroups++;
// Fetch all rows of the current group and order by created_at
$rows = Package::where('packing_list_id', $duplicate->packing_list_id)
->where('description', $duplicate->description)
->where('width', $duplicate->width)
->where('height', $duplicate->height)
->where('weight', $duplicate->weight)
->where('quantity', $duplicate->quantity)
->orderBy('created_at')
->get();
// Echo the group details
echo "Group {$totalGroups} Details:<br>";
foreach ($rows as $row) {
echo "ID: {$row->id}, Packing List ID: {$row->packing_list_id}, Description: {$row->description}, Width: {$row->width}, Height: {$row->height}, Weight: {$row->weight}, Quantity: {$row->quantity}, Created At: {$row->created_at}<br>";
}
// Delete all rows in the group except the first one (oldest based on created_at)
$firstRow = $rows->shift();
foreach ($rows as $row) {
Package::where('id', $row->id)->delete();
}
// Calculate the case age for the group (assuming case age means difference between current date and created_at of the oldest row)
$caseAge = Carbon::now()->diffInDays(Carbon::parse($firstRow->created_at));
echo "Case Age for Group {$totalGroups}: {$caseAge} days<br><br>";
}
// Echo the total number of duplicate groups
echo "Total Number of Duplicate Groups: {$totalGroups}";
});
Route::get('transaction/{id}/credit_note/download', 'Transactions\GenerateCreditNotePdfController@download')->name('transaction.credit_note.download');