diff --git a/app/Classes/General/Eloquent/Filters/IsPublished.php b/app/Classes/General/Eloquent/Filters/IsPublished.php new file mode 100644 index 00000000..3e9c8ca4 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/IsPublished.php @@ -0,0 +1,21 @@ +whereDate('starting_on', '<=', Carbon::now()) + ->whereDate('ending_on', '>=', Carbon::now()); + } +} diff --git a/app/Classes/General/ExcelHandel.php b/app/Classes/General/ExcelHandel.php new file mode 100644 index 00000000..3060ed8b --- /dev/null +++ b/app/Classes/General/ExcelHandel.php @@ -0,0 +1,87 @@ +makeDirectory($path); + return $folder; + } + + public static function insertExcel($path = '', $base64Set = []) + { + $file_info = []; + $folder_path = ExcelHandel::generateFolder('excels/' . $path); + + foreach ($base64Set as $key => $row) { + + $exceldata = $row; + $filename = (string) Str::uuid(); + + $f = finfo_open(); + $mime_type = finfo_file($f, $exceldata, FILEINFO_MIME_TYPE); + + $extension = 'xls'; + + switch ($mime_type) { + case 'application/vnd.ms-excel': + $extension = 'xls'; + break; + case 'application/zip': + $extension = 'xlsx'; + break; + } + + if (empty($extension)) { + return false; + } + + $exceldata = explode('base64,', $exceldata); + $exceldata = base64_decode($exceldata[1]); + + $filename_with_ext = $filename . '.' . $extension; + + $file = ExcelHandel::generateExcel($path, $exceldata, $filename, $extension); + + $file_info[] = [ + 'path' => $path, + 'filename' => $filename_with_ext, + 'mime_type' => $mime_type, + 'extension' => $extension, + 'file_info' => empty($file) ? [] : $file, + ]; + } + + return $file_info; + } + + public static function generateExcel($path = '', $exceldata = '', $filename = '', $extension = '') + { + $file_info = []; + $file = \Storage::disk('public')->put('excels/' . $path . '/' . $filename . '.' . $extension, $exceldata); + $file_info['original']['file'] = storage_path('app/public/excels/' . $path . '/' . $filename . '.' . $extension); + + return $file_info; + } + + public static function removeExcel($excel_info = []) + { + $excel_info = json_decode(json_encode($excel_info), true); + foreach ($excel_info as $key => $row) { + if (!empty($row['path'])) { + \File::delete([$row['file_info']['original']['file']]); + } + } + return true; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php b/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php index 69381d4d..85c9fe77 100644 --- a/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php +++ b/app/Classes/Modules/Billplzs/ControllersLogic/CallbackBillplzLogic.php @@ -88,6 +88,8 @@ class CallbackBillplzLogic $packingList = $invoice->owner; $order = $packingList->owner; + $status = ApprovalStatus::PENDING_VERIFICATION; + if($billPlz->state === 'paid') { $status = ApprovalStatus::APPROVED; } @@ -101,7 +103,7 @@ class CallbackBillplzLogic $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED); - if($transaction->amount - $invoice->amount < 0.01) { + if(($invoice->amount - $transaction->amount) < 0.01) { $this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED); $packingList->status = ApprovalStatus::APPROVED; @@ -118,4 +120,4 @@ class CallbackBillplzLogic 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/Documents/DataTransferObjects/FileObject.php b/app/Classes/Modules/Documents/DataTransferObjects/FileObject.php index ed289eac..148cfc07 100644 --- a/app/Classes/Modules/Documents/DataTransferObjects/FileObject.php +++ b/app/Classes/Modules/Documents/DataTransferObjects/FileObject.php @@ -28,7 +28,7 @@ class FileObject implements DataTransferObject */ public function getData() { - return $this->getExtension() === 'pdf' ? $this->data : (new imageManager())->make($this->data); + return in_array($this->getExtension(), ['pdf', 'excel']) ? $this->data : (new imageManager())->make($this->data); } /** @@ -66,7 +66,7 @@ class FileObject implements DataTransferObject */ public function getDecodedData(): string { - return $this->getExtension() === 'pdf' ? + return in_array($this->getExtension(), ['pdf', 'excel']) ? base64_decode((explode('base64,', $this->getData()))[1]): $this->getData()->encode('data-url')->encoded; } @@ -78,9 +78,4 @@ class FileObject implements DataTransferObject { $this->data = $data; } - - - - - -} \ No newline at end of file +} diff --git a/app/Classes/Modules/Documents/Services/ConvertsBase64ToFile.php b/app/Classes/Modules/Documents/Services/ConvertsBase64ToFile.php index a7a5c8b6..320916b1 100644 --- a/app/Classes/Modules/Documents/Services/ConvertsBase64ToFile.php +++ b/app/Classes/Modules/Documents/Services/ConvertsBase64ToFile.php @@ -36,7 +36,7 @@ class ConvertsBase64ToFile foreach ($files as $file) { $object = new FileObject($file); - $object->getExtension() === 'pdf' ? $this->generatePDF($object) : $this->generateImage($object); + in_array($object->getExtension(), ['pdf', 'excel']) ? $this->generatePDF($object) : $this->generateImage($object); } @@ -122,4 +122,4 @@ class ConvertsBase64ToFile ]); } -} \ No newline at end of file +} diff --git a/app/Classes/Modules/Exports/Services/ExportsNullDebtors.php b/app/Classes/Modules/Exports/Services/ExportsNullDebtors.php new file mode 100644 index 00000000..166b4005 --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsNullDebtors.php @@ -0,0 +1,97 @@ +whereNull('debtor')->orWhere('debtor', ''); + })->whereHas('companyModules', function($query){ + $query->where('type', BusinessType::IMPORTER); + })->whereHas('parcels')->where('status', ApprovalStatus::APPROVED); + } + + /** + * @param Company $company + * + * @return array + */ + public function map($company): array + { + $marking = $company->companyModules()->where('type', BusinessType::IMPORTER)->first()->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference; + + return [ + '<>', + '300-0000', + '300-0000', + $company->name.' (Shipping)', + $marking, + '', + 'PIA', + 'MYR', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '',//EmailAddress + '', + '', + '', + '' + ]; + } +} diff --git a/app/Classes/Modules/Exports/Services/ExportsParcelPostcodes.php b/app/Classes/Modules/Exports/Services/ExportsParcelPostcodes.php new file mode 100644 index 00000000..912e22f0 --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsParcelPostcodes.php @@ -0,0 +1,52 @@ +whereRaw('LENGTH(reference) > 8')->where('reference', 'not like', "%YW%")->where('owner_type', Order::class)->whereDate('created_at', '>=', Carbon::parse('20-09-2022'))->whereDoesntHave('containers'); + } + + /** + * @param $packingList + * @return array + */ + public function map($packingList): array + { + + $address = $packingList->owner->addresses()->where('status', ApprovalStatus::APPROVED)->first(); + return [ + $packingList->reference, + $address->postcode + ]; + } +} diff --git a/app/Classes/Modules/Exports/Services/ExportsPaymentTransactions.php b/app/Classes/Modules/Exports/Services/ExportsPaymentTransactions.php new file mode 100644 index 00000000..d810fc9b --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsPaymentTransactions.php @@ -0,0 +1,135 @@ +request = $request; + } + + public function headings(): array + { + return [ + 'DocNo', + 'DocDate', + 'DebtorCode', + 'ShipInfo', + 'AccNo', + 'DetailDescription', + 'FurtherDescription', + 'ProjNo', + 'DeptNo', + 'Qty', + 'UnitPrice' + ]; + } + + /** + * @return \Illuminate\Support\Collection|mixed + */ + public function query() + { + $start_date = $this->request->input('startDate', null); + if ($start_date) { + $start_date = Carbon::parse($this->request->input('startDate'))->format('Y-m-d'); + } + + $end_date = $this->request->input('endDate', null); + if ($end_date) { + $end_date = Carbon::parse($this->request->input('endDate'))->format('Y-m-d'); + } + + $query = Transaction::query(); + + $query->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::COMPLETED]); + + if($start_date && $end_date) { + $query->whereBetween('created_at', [ + Carbon::parse($start_date)->format('Y-m-d 0:00:00'), + Carbon::parse($end_date)->format('Y-m-d 23:59:59') + ]); + } + elseif($start_date && !$end_date) { + $query->whereHas('transactions', function($transaction) use ($start_date) { + $transaction->where('type', TransactionType::PAYMENT)->where('updated_at', '>=', Carbon::parse($start_date)->format('Y-m-d 0:00:00')); + }); + + } + elseif(!$start_date && $end_date) { + $query->whereHas('transactions', function($transaction) use ($end_date) { + $transaction->where('type', TransactionType::PAYMENT)->where('updated_at', '>=', Carbon::parse($end_date)->format('Y-m-d 0:00:00')); + }); + } + + return $query; + } + + public function map($transaction): array + { + $container = $transaction->owner->containers()->first(); + $order = $transaction->owner->owner; + $company = $order->companyModule->company; + $shippingTransactionDetails = $transaction->transactionDetails()->where('reference', 'SHIPPING_FEE')->first(); + + $furtherDescription = ''; + + foreach ($transaction->transactionDetails as $item){ + + if($item->reference === 'SHIPPING_FEE') + $furtherDescription .= str_replace('X1 Freight Service Charge
', '', $item->name)."\n"; + elseif($item->reference === 'OVER_WEIGHT_CHARGES') + $furtherDescription .= $item->name.' '.$item->quantity.' CBM'."\n"; + elseif($item->reference === 'MIN_CBM_CHARGES') + $furtherDescription .= $item->name.' '.$item->quantity.' CBM'."\n"; + else + $furtherDescription .= $item->name.' '.$item->quantity.' X '.$item->price."\n"; + } + + return [ + '<>', + $transaction->created_at->format('m/d/Y H:m'), + $company->debtor, + $order->reference, + '500-0000', + 'X1 Freight Service Charge', + $furtherDescription, + $container->reference, + 'CIEF', + $shippingTransactionDetails->quantity, + $shippingTransactionDetails->price + ]; + return [ + '<>', + $transaction->updated_at->format('m/d/Y H:m'), + $company->debtor, + $container->reference, + '500-0000', + 'X1 Freight Service Charge', + 'FurtherDescription', + $container->reference, + 'M3', + 'CIEF', + $shippingTransactionDetails->quantity, + $shippingTransactionDetails->price, + ]; + } +} diff --git a/app/Classes/Modules/Imports/Services/ImportsDebtor.php b/app/Classes/Modules/Imports/Services/ImportsDebtor.php new file mode 100644 index 00000000..a113911b --- /dev/null +++ b/app/Classes/Modules/Imports/Services/ImportsDebtor.php @@ -0,0 +1,56 @@ +whereHas('companyModules', function($query) use ($reference) { + $query->whereHas('connections', function($query) use ($reference) { + $query->where('invitee_reference', $reference); + }); + })->first(); + + if ($company) { + $company->debtor = $debtor; + $company->update(); + } + + } + + } catch (\Exception $exception){ + dd($exception); + } + } + + public function batchSize(): int + { + return 100; + } + + public function rules(): array + { + return [ + + ]; + } +} diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/DeletePackingListLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/DeletePackingListLogic.php index 09f6453f..19ded60f 100644 --- a/app/Classes/Modules/PackingLists/ControllersLogic/DeletePackingListLogic.php +++ b/app/Classes/Modules/PackingLists/ControllersLogic/DeletePackingListLogic.php @@ -8,6 +8,7 @@ use App\Classes\Modules\PackingLists\Services\DeletesPackingList; use App\Classes\Modules\PackingLists\Services\FetchesPackingList; use App\Classes\Modules\PackingLists\Standards\Rules\CanDeletePackingList; use App\Classes\ValueObjects\Constants\PackingListType; +use App\Models\PackingList; use ErrorException; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -59,11 +60,9 @@ class DeletePackingListLogic extends AbstractControllerLogic $this->canDeletePackingList->passes(); - $warehouseList = $this->fetchesPackingList->execute(['id' => $request->route('id')]); - $packingList = $this->fetchesPackingList->execute(['reference' => $warehouseList->reference, 'type' => PackingListType::SHIPPING_PACKING_LIST]); + $packingList = $this->fetchesPackingList->execute(['id' => $request->route('id')]); - $this->deletesPackingList->execute($warehouseList); - $this->deletesPackingList->execute($packingList); + PackingList::where('reference', $packingList->reference)->delete(); return $this->response([]); diff --git a/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php b/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php index 16205f62..a6f5bf7c 100644 --- a/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php +++ b/app/Classes/Modules/PackingLists/Processors/FetchOrderListsFromYdPortalProcessor.php @@ -2,6 +2,7 @@ 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; @@ -137,7 +138,7 @@ class FetchOrderListsFromYdPortalProcessor public function execute(?Carbon $start = null, ?Carbon $end = null) { try { - $start = $start ? $start : Carbon::today()->subMonths(1); + $start = $start ? $start : Carbon::today()->subDays(5); $startLimit = Carbon::parse('01-12-2021'); @@ -227,7 +228,7 @@ class FetchOrderListsFromYdPortalProcessor $unstuffingDate = Carbon::parse($trackingRow->trackingtime); } - if (Str::contains($trackingRow->tracking, ['派送中', '签收完成', ' 第三方提货', '货物已派送完成'])) { + if (Str::contains($trackingRow->tracking, ['派送中', '已签收', '签收完成', ' 第三方提货', '货物已派送完成', '派送', 'delivery', 'delivered'])) { $deliveryDate = Carbon::parse($trackingRow->trackingtime); } } diff --git a/app/Classes/Modules/Transactions/ControllersLogic/ApprovePaymentTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/ApprovePaymentTransactionLogic.php index 5fc9cc78..82924a35 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/ApprovePaymentTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/ApprovePaymentTransactionLogic.php @@ -81,7 +81,7 @@ class ApprovePaymentTransactionLogic extends AbstractControllerLogic $status = $request->route('status'); $transaction = $this->fetchesTransaction->execute(['id' => $request->route('transaction_id')]); - + $status === 'approve' ? $this->approvesDocument->execute($transaction->documents()->first()) : $this->rejectsDocument->execute($transaction->documents()->first()); $this->updatesTransactionStatus->execute($transaction, $status === 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED); @@ -90,7 +90,7 @@ class ApprovePaymentTransactionLogic extends AbstractControllerLogic $invoice = $transaction->owner; $packingList = $invoice->owner; - if($transaction->amount - $invoice->amount < 0.01) { + if(($invoice->amount - $transaction->amount) < 0.01) { $this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED); $packingList->status = ApprovalStatus::APPROVED; @@ -108,4 +108,4 @@ class ApprovePaymentTransactionLogic extends AbstractControllerLogic return $this->response([]); } -} \ No newline at end of file +} diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateShippingInvoiceTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateShippingInvoiceTransactionLogic.php index 0906275a..601f1ea5 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateShippingInvoiceTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateShippingInvoiceTransactionLogic.php @@ -213,7 +213,7 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic $object_detail = new TransactionDetailObject( 'SHIPPING_FEE', - TransactionDetailType::SHIPPING_FEE.'
'.round($packing_list->packages->sum('quantity'), 3).' CTNS - '.round($cbm, 3).' CBM', + TransactionDetailType::SHIPPING_FEE.'
'.round($packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum('quantity'), 3).' CTNS - '.round($cbm, 3).' CBM', $cbm, $price_cbm ); diff --git a/app/Classes/ValueObjects/Constants/FileType.php b/app/Classes/ValueObjects/Constants/FileType.php index a1325ad3..36032731 100644 --- a/app/Classes/ValueObjects/Constants/FileType.php +++ b/app/Classes/ValueObjects/Constants/FileType.php @@ -14,12 +14,16 @@ class FileType public const PDF = 'application/pdf'; + public const EXCEL = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; + public const EXTENSION = [ 'image/gif' => 'gif', 'image/png' => 'png', 'image/jpeg' => 'jpeg', 'application/pdf' => 'pdf', 'application/octet-stream' => 'pdf', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'excel', + 'application/vnd.ms-excel' => 'excel', ]; -} \ No newline at end of file +} diff --git a/app/Classes/ValueObjects/Constants/WarehouseReferences.php b/app/Classes/ValueObjects/Constants/WarehouseReferences.php index 3119e6a8..966ae665 100644 --- a/app/Classes/ValueObjects/Constants/WarehouseReferences.php +++ b/app/Classes/ValueObjects/Constants/WarehouseReferences.php @@ -47,7 +47,7 @@ final class WarehouseReferences { public const MIN_CBM_EXEMPT_LIST = [230, 294, 320, 652, 1248, 1726, 2349, 2574]; - public const REPLICA_WHITE_LIST = [502]; + public const REPLICA_WHITE_LIST = [502, 2237]; //2376 qce diff --git a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php index d4e050b5..bbc96a8c 100644 --- a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php +++ b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php @@ -4,10 +4,12 @@ namespace App\Http\Controllers\Exports; use App\Classes\Modules\Exports\Services\ExportsCustomersOrderLatestDate; +use App\Classes\Modules\Exports\Services\ExportsPaymentTransactions; use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Maatwebsite\Excel\Excel; +use App\Classes\Modules\Exports\Services\ExportsNullDebtors; class ExportCustomersToExcelController { @@ -16,4 +18,17 @@ class ExportCustomersToExcelController $request->headers->set('Authorization', 'Bearer '.$token); return $exportsCustomers->download('customer-latest-order-date.csv', Excel::CSV, ['Content-Type' => 'text/csv']); } + + public function nullDebtor(ExportsNullDebtors $exportsNullDebtors, Request $request){ + $response = $exportsNullDebtors->download('nullDebtor.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); + ob_end_clean(); + return $response; + } + + public function paymentTransactions(Request $request){ + $exportsTransactions = new ExportsPaymentTransactions($request); + $response = $exportsTransactions->download('payment-transactions.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); + ob_end_clean(); + return $response; + } } diff --git a/app/Http/Controllers/Exports/ExportParcelPostcodesController.php b/app/Http/Controllers/Exports/ExportParcelPostcodesController.php new file mode 100644 index 00000000..1fede8e5 --- /dev/null +++ b/app/Http/Controllers/Exports/ExportParcelPostcodesController.php @@ -0,0 +1,29 @@ +headers->set('Authorization', 'Bearer '.$token); + } + + public function export(Request $request) { + $exportsPendingArrangementDeliveryList = new ExportsParcelPostcodes($request); + $response = $exportsPendingArrangementDeliveryList->download('parcel-postcodes.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']); + ob_end_clean(); + return $response; + } +} diff --git a/app/Http/Controllers/Imports/ImportUpdateDebtorController.php b/app/Http/Controllers/Imports/ImportUpdateDebtorController.php new file mode 100644 index 00000000..f10f2d95 --- /dev/null +++ b/app/Http/Controllers/Imports/ImportUpdateDebtorController.php @@ -0,0 +1,30 @@ +input('files'), '', ApprovalStatus::APPROVED, 'imports'); + Excel::import(new ImportsDebtor(), 'documents/'.json_decode($object->getFiles()[0])->file_info->original->file); + return []; + } +} diff --git a/app/Http/Resources/CompanyModuleResource.php b/app/Http/Resources/CompanyModuleResource.php index 22a0557d..0fdb2c46 100644 --- a/app/Http/Resources/CompanyModuleResource.php +++ b/app/Http/Resources/CompanyModuleResource.php @@ -4,6 +4,7 @@ namespace App\Http\Resources; use App\Classes\Modules\Companies\Services\FetchesCompanyServices; use App\Classes\ValueObjects\Constants\AddressType; +use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\BankAccountType; use App\Classes\ValueObjects\Constants\BusinessType; use App\Classes\ValueObjects\Constants\DocumentType; @@ -42,7 +43,7 @@ class CompanyModuleResource extends JsonResource 'name' => $this->name, 'reference' => $this->reference, 'address' => new AddressResource($defaultAddress), - 'billingAddress' => new AddressResource($this->addresses()->where('type', AddressType::BILLING)->first()), + 'billingAddress' => new AddressResource($this->addresses()->where('type', AddressType::BILLING)->where('status', ApprovalStatus::APPROVED)->first()), 'company' => new CompanyResource($this->whenLoaded('company')), 'remarks' => RemarkResource::collection($this->remarks), 'marking' => $marking, diff --git a/app/Http/Resources/OrderResource.php b/app/Http/Resources/OrderResource.php index cbdaeccb..50bf14d7 100644 --- a/app/Http/Resources/OrderResource.php +++ b/app/Http/Resources/OrderResource.php @@ -46,7 +46,9 @@ 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()), + 'invoices' => $this->whenLoaded('packingLists', function() { + return 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 a085d094..462e4cdd 100644 --- a/app/Http/Resources/PackingListResource.php +++ b/app/Http/Resources/PackingListResource.php @@ -35,7 +35,7 @@ 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)->whereNotIn('status', [ApprovalStatus::SUSPENDED, ApprovalStatus::EXPIRED])->first()), + 'shipping_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/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 563eedf0..9e9e5771 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -5,6 +5,8 @@ namespace App\Http\Resources; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\DocumentType; use App\Classes\ValueObjects\Constants\TransactionType; +use App\Models\Order; +use App\Models\Transaction; use Carbon\Carbon; use Illuminate\Http\Resources\Json\JsonResource; @@ -18,10 +20,9 @@ class TransactionResource extends JsonResource */ public function toArray($request) { - return [ 'id' => $this->id, - // 'booking' => new BookingResource($this->booking), + 'order' => ($this->owner instanceof Transaction) ? new OrderResource($this->owner->owner->owner) : new OrderResource($this->owner->owner), 'documents' => DocumentResource::collection($this->documents), 'type' => (int) $this->type, 'bill_no' => $this->bill_no, @@ -29,6 +30,7 @@ class TransactionResource extends JsonResource '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')), + 'floating' => (double) $this->transactions()->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::PENDING_SUBMISSION, ApprovalStatus::PENDING_VERIFICATION])->sum('amount'), 'service_charge' => (double) $this->service_charge, 'tax' => (double) $this->tax, 'original_amount' => (double) $this->original_amount, @@ -51,7 +53,8 @@ class TransactionResource extends JsonResource ), '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') + 'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y'), + 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y') ]; } } diff --git a/app/Models/CompanyModule.php b/app/Models/CompanyModule.php index 6a6d53ed..4e9c0526 100644 --- a/app/Models/CompanyModule.php +++ b/app/Models/CompanyModule.php @@ -186,6 +186,15 @@ class CompanyModule extends AbstractModel implements Addressable, Documentable, return $this->morphMany(Remark::class, 'owner'); } + /** + * @return hasManyDeep + */ + public function transactions(): hasManyDeep + { + return $this->hasManyDeep(Transaction::class, [Order::class], ['company_module_id', 'owner_id'], ['id', 'id']); + } + + } diff --git a/database/migrations/2022_02_20_203803_add_debtor_to_companies_table.php b/database/migrations/2022_02_20_203803_add_debtor_to_companies_table.php new file mode 100644 index 00000000..2798b9e7 --- /dev/null +++ b/database/migrations/2022_02_20_203803_add_debtor_to_companies_table.php @@ -0,0 +1,32 @@ +string('debtor')->nullable()->after('reference'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('companies', function (Blueprint $table) { + + }); + } +} diff --git a/resources/assets/vue/components/companies/elements/IdentificationVerificationComponent.vue b/resources/assets/vue/components/companies/elements/IdentificationVerificationComponent.vue index 7a9fe7a8..bcb5b80c 100644 --- a/resources/assets/vue/components/companies/elements/IdentificationVerificationComponent.vue +++ b/resources/assets/vue/components/companies/elements/IdentificationVerificationComponent.vue @@ -56,7 +56,7 @@ -
+
diff --git a/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue b/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue index 749e7ef8..31189028 100644 --- a/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue +++ b/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue @@ -6,6 +6,11 @@
+ + +
@@ -113,4 +118,4 @@ } } } - \ No newline at end of file + diff --git a/resources/assets/vue/components/containers/elements/PackingListComponent.vue b/resources/assets/vue/components/containers/elements/PackingListComponent.vue index 6aaa5a3b..852b0940 100644 --- a/resources/assets/vue/components/containers/elements/PackingListComponent.vue +++ b/resources/assets/vue/components/containers/elements/PackingListComponent.vue @@ -3,6 +3,7 @@
{{item.order.company_module.marking}}/{{item.order.reference}} +

{{item.reference}}

{{item.receive_packing_list.transport.drop_date}}

Unclaimed Packing List
diff --git a/resources/assets/vue/components/containers/elements/UploadDebtorExcelComponent.vue b/resources/assets/vue/components/containers/elements/UploadDebtorExcelComponent.vue new file mode 100644 index 00000000..a956a07c --- /dev/null +++ b/resources/assets/vue/components/containers/elements/UploadDebtorExcelComponent.vue @@ -0,0 +1,81 @@ + + + \ No newline at end of file diff --git a/resources/assets/vue/components/orders/elements/UnclaimedPackinglistComponent.vue b/resources/assets/vue/components/orders/elements/UnclaimedPackinglistComponent.vue index 0f4e8360..b4b928c3 100644 --- a/resources/assets/vue/components/orders/elements/UnclaimedPackinglistComponent.vue +++ b/resources/assets/vue/components/orders/elements/UnclaimedPackinglistComponent.vue @@ -14,7 +14,7 @@

Arrival Date

{{data.transport ? data.transport.drop_date : 'n/a'}}

-
+
diff --git a/resources/assets/vue/components/paymentsBilling/elements/AdminDisputePaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/AdminDisputePaymentsBillingComponent.vue index 1f0416ca..10560438 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/AdminDisputePaymentsBillingComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/AdminDisputePaymentsBillingComponent.vue @@ -3,7 +3,7 @@
-
+

Marking

@@ -29,7 +29,7 @@

Billing Question

-
{{ latestComment.content }}
+
{{ latestComment ? latestComment.content : '' }}
diff --git a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue index d7756791..380ddbdd 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue @@ -3,7 +3,7 @@
-
+

Marking

@@ -20,13 +20,16 @@

Invoice Date

-
n/a
-
{{ item.shippng_transaction.updated_at }}
+
n/a
+
{{ item.shipping_transaction.updated_at }}
-

Address

-
{{ item.order.address.post_code_area}}
-
{{ item.order.address.district.name +' '+item.order.address.postcode+' '+item.order.address.state.name }}
+
+

Address

+
{{ item.order.address.post_code_area}}
+
{{ item.order.address.district.name +' '+item.order.address.postcode+' '+item.order.address.state.name }}
+
+
Unclaimed

Status

@@ -34,13 +37,13 @@

Amount

-
n/a
-
MYR {{ item.shippng_transaction.amount.toFixed(2) }}
+
n/a
+
MYR {{ item.shipping_transaction.amount.toFixed(2) }}
-
-
-
+
+
+
-
+
-
- -
-
-
-
-
Add Billing Address
- - - +
+
+
+
-
-
Define Location
- - - +
+
+
+
Add Billing Address
+ + + +
+
+
Define Location
+ + + +
+
Generate Invoice
+
+
+ +
-
Generate Invoice
-
-
- +
+ +
+
+ +
+ + + + + +
-
- +
+
+ Edit billing Address +
+ +
+
+ +
+
+
-
- -
- - - - - -
-
+
@@ -131,33 +150,33 @@
Invoice Details
- +

Subtotal

-
{{ item.shippng_transaction.amount - item.shippng_transaction.service_charge - item.shippng_transaction.tax }}
+
{{ item.shipping_transaction.amount - item.shipping_transaction.service_charge - item.shipping_transaction.tax }}

Service Charges

-
{{ item.shippng_transaction.service_charge }}
+
{{ item.shipping_transaction.service_charge }}

Tax

-
{{ item.shippng_transaction.tax }}
+
{{ item.shipping_transaction.tax }}

Total

-
{{ item.shippng_transaction.amount }}
+
{{ item.shipping_transaction.amount }}
-
+
-
+
@@ -166,12 +185,12 @@
- +
-
+
@@ -180,7 +199,7 @@
- +
@@ -198,7 +217,7 @@
Total Amount:
-
MYR {{(Math.round((item.shippng_transaction.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
+
MYR {{(Math.round((item.shipping_transaction.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
@@ -206,7 +225,7 @@
Paid Total:
- +
Paid Total
@@ -215,7 +234,7 @@
Floating Amount:
- +
Floating Amount
@@ -224,10 +243,10 @@
OutStanding Total:
-
MYR {{(Math.round((item.shippng_transaction.outstanding + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
+
MYR {{(Math.round((item.shipping_transaction.outstanding + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
-
+
Make Payment
@@ -235,7 +254,7 @@
- +
@@ -283,7 +302,7 @@ }, successHandler(response){ this.item = response.payload.data; - // this.$forceUpdate(); + this.updateList(); } }, mixins: [componentHandler] diff --git a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue index 25e29424..a5ede524 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue @@ -3,7 +3,7 @@
-
+

Invoice Date

{{ item.updated_at }}
@@ -56,17 +56,16 @@
-
+
-
-
- -
+
+
+ {{ expanded ? 'Cancel' : 'Make Payment' }}
@@ -84,7 +83,7 @@
- +
@@ -124,8 +123,7 @@
Paid Total:
- -
Paid Total
+
MYR {{(Math.round((item.amount - item.outstanding + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
@@ -133,8 +131,7 @@
Floating Amount:
- -
Floating Amount
+
MYR {{(Math.round((item.floating + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
@@ -145,7 +142,7 @@
MYR {{(Math.round((item.outstanding + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
-
+
Make Payment
@@ -191,7 +188,7 @@ packing_list_id: null, transaction_details: [], }, - expanded: false, + expanded: true, } }, computed: { diff --git a/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue index 7244fe17..a3ffd197 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue @@ -38,6 +38,33 @@
+
+
+
+ +
+
+
+
+
+
CIEF WORLDWIDE SDN. BHD.
+
+
+
+
+
Maybank: 562237009234
+
+
+
+
+
Bank In Amount: {{(Math.round((parseFloat(amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} MYR
+
+
+
+
diff --git a/resources/assets/vue/components/paymentsBilling/elements/PaymentVerificationComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/PaymentVerificationComponent.vue index 4c499bcd..045d726a 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/PaymentVerificationComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/PaymentVerificationComponent.vue @@ -13,17 +13,16 @@ {{ item.updated_at }}
- - +
Amount
diff --git a/resources/assets/vue/components/paymentsBilling/elements/ShippingTransactionComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/ShippingTransactionComponent.vue index 0d7d29f0..56401dda 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/ShippingTransactionComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/ShippingTransactionComponent.vue @@ -15,7 +15,7 @@ MYR {{(Math.round((item.original_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
-
+
diff --git a/resources/assets/vue/components/paymentsBilling/forms/DeletePaymentAttemptFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/DeletePaymentAttemptFormComponent.vue index ba371bd4..f3248ed8 100644 --- a/resources/assets/vue/components/paymentsBilling/forms/DeletePaymentAttemptFormComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/forms/DeletePaymentAttemptFormComponent.vue @@ -30,4 +30,4 @@ mixins: [componentHandler, ModalFormHandler] } - \ No newline at end of file + diff --git a/resources/assets/vue/components/paymentsBilling/forms/DeleteShippingInvoiceFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/DeleteShippingInvoiceFormComponent.vue index 2e27eb60..75029cc8 100644 --- a/resources/assets/vue/components/paymentsBilling/forms/DeleteShippingInvoiceFormComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/forms/DeleteShippingInvoiceFormComponent.vue @@ -14,7 +14,7 @@
Cancel
-
Confirm
+
Confirm
@@ -28,4 +28,4 @@ mixins: [modalFormHandler] } - \ No newline at end of file + diff --git a/resources/assets/vue/components/paymentsBilling/forms/DownloadBillingWithDatesComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/DownloadBillingWithDatesComponent.vue new file mode 100644 index 00000000..99be4562 --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/forms/DownloadBillingWithDatesComponent.vue @@ -0,0 +1,83 @@ + + + diff --git a/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue index 8f02c823..f61ac040 100644 --- a/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue @@ -13,11 +13,11 @@ {{error}}
-
+
- +
@@ -52,6 +52,42 @@
+
+
+
+
+
You can proceed by bank in {{(Math.round((parseFloat(parameters.amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} MYR to the bank account detailed below and upload your payment proof to proceed with your transfer after clicking on the proceed button below.
+
+
+
+
+
+ +
+
+
+
+
+
CIEF WORLDWIDE SDN. BHD.
+
+
+
+
+
Maybank: 562237009234
+
+
+
+
+
Bank In Amount: {{(Math.round((parseFloat(parameters.amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} MYR
+
+
+
+
+
+
@@ -99,7 +135,7 @@ methods:{ submitForm(){ this.parameters.payment_method = this.paymentMethod.id === 'payment_gateway' ? 5 : ''; - this.submit(this.route('api.transaction.payment.create'), 'post', this.section, true, true); + this.submit(this.route('api.transaction.payment.create'), 'post', 'orderProfileSection', true, true); }, updatePaymentType(payment){ this.paymentMethod = { @@ -115,9 +151,11 @@ window.location.href = this.route('billplz.bill', response.payload.data.payment_reference) + '?auto_submit=true'; } } + + this.updateList(); } }, mixins: [formHandler] } - \ No newline at end of file + diff --git a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue index 30c23bc3..fbfe5961 100644 --- a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue @@ -130,6 +130,11 @@
+
+
+ +
+