Merge branch 'dillon/41-voucherify-phase-2b' into development

This commit is contained in:
Dillon
2023-08-26 06:33:35 +08:00
35 changed files with 1241 additions and 160 deletions
+43
View File
@@ -0,0 +1,43 @@
<?php
namespace App\Classes\Jobs;
use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionProcessor;
use App\Classes\Modules\Transactions\Processors\GeneratesGroupTransactionsWhiteForm;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\DocumentType;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Models\Booking;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class GenerateInvoice implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/** @var Booking */
private $booking;
/**
* @param Booking $booking
*/
public function __construct(Booking $booking)
{
$this->booking = $booking;
}
public function handle()
{
$this->booking->transactions()->whereIn('transactions.type', [TransactionType::INVOICE, TransactionType::SUPPLIER_DELIVER])->delete();
$this->booking->documents()->whereIn('document_type', [DocumentType::INVOICE, DocumentType::PURCHASE_ORDER, DocumentType::DELIVER_ORDER, DocumentType::SUPPLIER_DELIVER_ORDER])->delete();
$this->booking->status = ApprovalStatus::APPROVED;
$this->booking->save();
(App()->make(CreateInvoiceTransactionProcessor::class))->execute($this->booking);
}
}
@@ -0,0 +1,44 @@
<?php
namespace App\Classes\Modules\Companies\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\ValueObjects\Constants\BusinessType;
use App\Http\Resources\GeneralTypeResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ListBusinessTypesLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Business Types',
'message' => 'You have successfully retrieved a list of Business Types'
];
}
/**
* @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
{
$businessTypes = [];
foreach(BusinessType::BUSINESS_TYPE_LIST as $key => $val) {
$type = (object)["id" => $key, "type" => $val];
array_push($businessTypes, $type);
}
return $this->collectionResponse(GeneralTypeResource::collection($businessTypes));
}
}
@@ -0,0 +1,44 @@
<?php
namespace App\Classes\Modules\Companies\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\ValueObjects\Constants\CompanyType;
use App\Http\Resources\GeneralTypeResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ListCompanyTypesLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Company Types',
'message' => 'You have successfully retrieved a list of Company Types'
];
}
/**
* @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
{
$businessTypes = [];
foreach(CompanyType::COMPANY_TYPE_LIST as $key => $val) {
$type = (object)["id" => $key, "type" => $val];
array_push($businessTypes, $type);
}
return $this->collectionResponse(GeneralTypeResource::collection($businessTypes));
}
}
@@ -0,0 +1,65 @@
<?php
namespace App\Classes\Modules\Companies\ControllersLogic;
use App\Http\Resources\CompanyResource;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Companies\DataTransferObjects\CompanyProfileObject;
use App\Classes\Modules\Companies\Services\FetchesCompany;
use App\Classes\Modules\Companies\Services\UpdatesCompanyProfile;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class UpdateCompanyProfileLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Update Company Details',
'message' => 'You have successfully updated the Company Details'
];
}
/** @var FetchesCompany */
private $fetchesCompany;
/** @var UpdatesCompanyProfile */
private $updatesCompanyProfile;
/**
* UpdateCompanyProfileLogic constructor.
* @param FetchesCompany $fetchesCompany
* @param UpdatesCompanyProfile $updatesCompanyProfile
*/
public function __construct(
FetchesCompany $fetchesCompany,
UpdatesCompanyProfile $updatesCompanyProfile
)
{
$this->fetchesCompany = $fetchesCompany;
$this->updatesCompanyProfile = $updatesCompanyProfile;
}
/**
* @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
{
$object = new CompanyProfileObject($request->input('email'), $request->input('phone'), $request->input('type'));
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
$company_query = $this->updatesCompanyProfile->execute($company, $object);
return $this->resourceResponse(new CompanyResource($company_query));
}
}
@@ -0,0 +1,55 @@
<?php
namespace App\Classes\Modules\Companies\DataTransferObjects;
use App\Classes\General\Interfaces\DataTransferObject;
use App\Classes\ValueObjects\Constants\BusinessType;
class CompanyProfileObject implements DataTransferObject
{
/** @var string|null */
private $email;
/** @var string */
private $phone;
/** @var int|null */
private $companyType;
/**
* CompanyObject constructor.
* @param string|null $email
* @param string $phone
* @param int|null $businessType
*/
public function __construct(?string $email, string $phone, int $companyType)
{
$this->email = $email;
$this->phone = $phone;
$this->companyType = $companyType;
}
/**
* @return null|string
*/
public function getEmail(): ?string
{
return $this->email;
}
/**
* @return string
*/
public function getPhone(): string
{
return $this->phone;
}
/**
* @return int
*/
public function getCompanyType(): int
{
return $this->companyType;
}
}
@@ -0,0 +1,32 @@
<?php
namespace App\Classes\Modules\Companies\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Companies\DataTransferObjects\CompanyProfileObject;
use App\Models\Company;
class UpdatesCompanyProfile extends AbstractUpdateRecord
{
/**
* @param Company $model
* @param CompanyProfileObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(Company $model, CompanyProfileObject $object)
{
$model->type = $object->getCompanyType();
$contact = $model->contacts()->first();
if ($contact) {
$contact->email = $object->getEmail();
$contact->phone = $object->getPhone();
$contact->save();
}
return $this->handler($model);
}
}
@@ -24,7 +24,7 @@ class TransactionToPerfexCRMProcessorV2
$projectName = 'Exchange | ' . $bookingInfo['serviceTypeName'] . ' | ' . $bookingInfo['bookingMarking'];
$tasks = $this->defineTasks($model, $status);
Log::error("TransactionToPerfexCRMProcessorV2 status: ".$status." - for project name: ".$projectName);
//Log::error("TransactionToPerfexCRMProcessorV2 status: ".$status." - for project name: ".$projectName);
if(count($tasks) > 0) {
$updatePerfexCRMObject = new UpdatePerfexCRMObject(
@@ -55,6 +55,15 @@ class FetchCompanyTransactionStatementLogic extends AbstractControllerLogic
->where('owner_type', Wallet::class)
->where('type', '!=', TransactionType::PAYMENT);
})
->orWhere(function ($query) use ($companyId) {
$query
->where('type', TransactionType::INVOICE)
->where('owner_type', Booking::class)
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
->whereHas('booking', function ($query) use ($companyId) {
$query->where('company_id', $companyId);
});
})
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
->orderBy('created_at', 'desc')
->get();
@@ -12,4 +12,11 @@ final class BusinessType {
public const TRANSFER_AGENT = 4;
public const BUSINESS_TYPE_LIST = [
self::FREIGHT_FORWARDER => 'Freight Forwarder',
self::IMPORTER => 'Importer',
self::CURRENCY_VENDOR => 'Currency Vendor',
self::TRANSFER_AGENT => 'Transfer Agent',
];
}
@@ -13,4 +13,9 @@ final class CompanyType {
self::COMPANY_BUSINESS => 'COMPANY_BUSINESS',
];
public const COMPANY_TYPE_LIST = [
self::PERSONAL_BUSINESS => 'Personal Business',
self::COMPANY_BUSINESS => 'Company Business',
];
}
+11 -4
View File
@@ -5,6 +5,7 @@ namespace App\Console\Commands;
use Illuminate\Console\Command;
use Carbon\Carbon;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Models\Booking;
class DeleteOrderCommand extends Command
@@ -40,7 +41,8 @@ class DeleteOrderCommand extends Command
*/
public function handle()
{
$bookings_reference = $this->argument('bookings_reference');
// $bookings_reference = $this->argument('bookings_reference');
$bookings_reference = '28546,38599,44487,71086,70133,58580,42831,96028,41188,33894,95877,86732,31894,50962,44215,92894,40968,30303,89762,74693,45271,27169';
$bookings_reference = explode(',', $bookings_reference);
$start = new Carbon();
@@ -52,9 +54,14 @@ class DeleteOrderCommand extends Command
if (!$booking) {
$this->logOutput('Booking not found: ' . $reference);
} else {
$booking->status = ApprovalStatus::EXPIRED;
$booking->save();
$this->logOutput('Booking deleted: ' . $reference);
$payment = $booking->transactions()
->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
->first();
$payment->status = ApprovalStatus::EXPIRED;
$payment->save();
$this->logOutput('Booking ' . $reference . ' Payment deleted: ' . $payment->id);
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Controllers\Companies;
use App\Classes\Modules\Companies\ControllersLogic\ListBusinessTypesLogic;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ListBusinessTypesController
{
/**
* @param Request $request
* @param ListBusinessTypesLogic $logic
* @return JsonResponse
*/
public function list(Request $request, ListBusinessTypesLogic $logic): JsonResponse {
return $logic->execute($request);
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Controllers\Companies;
use App\Classes\Modules\Companies\ControllersLogic\ListCompanyTypesLogic;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ListCompanyTypesController
{
/**
* @param Request $request
* @param ListBusinessTypesLogic $logic
* @return JsonResponse
*/
public function list(Request $request, ListCompanyTypesLogic $logic): JsonResponse {
return $logic->execute($request);
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Controllers\Companies;
use App\Classes\Modules\Companies\ControllersLogic\UpdateCompanyProfileLogic;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class UpdateCompanyProfileController
{
/**
* @param Request $request
* @param UpdateCompanyProfileLogic $logic
* @return JsonResponse
*/
public function update(Request $request, UpdateCompanyProfileLogic $logic): JsonResponse {
return $logic->execute($request);
}
}
@@ -34,12 +34,20 @@ class ImportHoneyTrapController
$excelRows = $excelRows->toArray();
$returnArray = [];
$segment_name = 'honey trap campaign';
$segment = Segment::where('name', $segment_name)->first();
// $segment_name = 'honey trap campaign';
// $segment = Segment::where('name', $segment_name)->first();
$input_segment_id = $request->input('segment_id');
if (!$input_segment_id) {
$row['status'] = 'Failed';
$row['message'] = 'segment_id cannot be empty';
$returnArray[] = $row;
return response()->json($returnArray);
}
$segment = Segment::where('id', $input_segment_id)->first();
if (!$segment) {
$row['status'] = 'Failed';
$row['message'] = '"' . $segment_name . '"' . ' not found';
$row['message'] = 'Segment not found';
$returnArray[] = $row;
return response()->json($returnArray);
}
@@ -0,0 +1,22 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class GeneralTypeResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'type' => $this->type,
];
}
}
+2 -1
View File
@@ -31,7 +31,8 @@
"staudenmeir/eloquent-has-many-deep": "^1.7",
"timehunter/laravel-google-recaptcha-v3": "~2.5",
"tymon/jwt-auth": "^1.0",
"webklex/laravel-pdfmerger": "^1.3"
"webklex/laravel-pdfmerger": "^1.3",
"ext-bcmath": "*"
},
"require-dev": {
"facade/ignition": "^2.3.6",
@@ -24,7 +24,8 @@
<div class="col-2 fs-12">{{item.created_at}}</div>
<div class="col-3 fs-12">{{ convertTransactionType(item.type) }} {{ item.payment_reference ? ' - ' + item.payment_reference : '' }} <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 fs-12"><a :href="route('booking.details', item.booking_marking)">{{item.booking_marking}}</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-success text-center" v-if="parseFloat(item.type) !== 2">{{[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-success text-center" v-if="parseFloat(item.type) === 2">{{(Math.round(((parseFloat(item.amount) / parseFloat(item.currency_rate) + parseFloat(item.service_charge)) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}</div>
<div class="col-2 text-danger text-center">{{[1, 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>
</div>
@@ -104,7 +105,11 @@ export default {
if(this.transaction){
let transactions = this.transaction.slice().reverse();
transactions.slice(0, transactions.length - index).map(function(transaction) {
[1, 11].includes(transaction.type) ? tempBalance -= (transaction.amount) : tempBalance += (transaction.amount);
if (transaction.type === 2) {
tempBalance += (transaction.amount / transaction.currency_rate + transaction.service_charge);
} else {
[1, 11].includes(transaction.type) ? tempBalance -= (transaction.amount) : tempBalance += (transaction.amount);
}
return tempBalance
}, 0);
}
@@ -270,11 +270,11 @@
<span class="text-danger" v-if="voucherCodeFailedReason">{{ voucherCodeFailedReason }}</span>
<span class="text-success" v-if="voucherCodeFailedReason === '' && voucherValidated">Voucher applied</span>
</div>
<div class="row m-l-0 m-r-0">
<!-- <div class="row m-l-0 m-r-0">
<div class="col">
<available-vouchers-component :employee="data.company.employee" @selected-voucher="handleSelectedVoucher"></available-vouchers-component>
</div>
</div>
</div> -->
<div class="row m-t-5">
<div class="col">
<div class="row p-l-15 p-r-15">
@@ -0,0 +1,78 @@
<template>
<div class="row m-l-0 m-r-0 m-b-10 parentContainer align-items-center">
<div class="col-auto">
<div class="padding-5 bg-master-lightest">
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
width="30" height="30"
viewBox="0 0 172 172"
style=" fill:#000000;"><defs><linearGradient x1="86" y1="38.97413" x2="86" y2="57.78663" gradientUnits="userSpaceOnUse" id="color-1_77055_gr1"><stop offset="0" stop-color="#4ec9ff"></stop><stop offset="1" stop-color="#2bffe6"></stop></linearGradient><linearGradient x1="129" y1="77.49138" x2="129" y2="121.38631" gradientUnits="userSpaceOnUse" id="color-2_77055_gr2"><stop offset="0" stop-color="#4ec9ff"></stop><stop offset="1" stop-color="#2bffe6"></stop></linearGradient><linearGradient x1="43" y1="77.49138" x2="43" y2="121.38631" gradientUnits="userSpaceOnUse" id="color-3_77055_gr3"><stop offset="0" stop-color="#4ec9ff"></stop><stop offset="1" stop-color="#2bffe6"></stop></linearGradient><linearGradient x1="86" y1="64.94881" x2="86" y2="133.92888" gradientUnits="userSpaceOnUse" id="color-4_77055_gr4"><stop offset="0" stop-color="#4ec9ff"></stop><stop offset="1" stop-color="#2bffe6"></stop></linearGradient><linearGradient x1="86" y1="16.11963" x2="86" y2="155.875" gradientUnits="userSpaceOnUse" id="color-5_77055_gr5"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient></defs><g fill="none" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><path d="M0,172v-172h172v172z" fill="none"></path><g><path d="M86,40.31787c-4.4528,0 -8.0625,3.6097 -8.0625,8.0625c0,4.4528 3.6097,8.0625 8.0625,8.0625c4.4528,0 8.0625,-3.6097 8.0625,-8.0625c0,-4.4528 -3.6097,-8.0625 -8.0625,-8.0625z" fill="url(#color-1_77055_gr1)"></path><path d="M126.3125,80.625h5.375v37.625h-5.375z" fill="url(#color-2_77055_gr2)"></path><path d="M40.3125,80.625h5.375v37.625h-5.375z" fill="url(#color-3_77055_gr3)"></path><path d="M56.4375,69.875v59.125h59.125v-59.125zM99.4375,88.6875h-21.5v8.0625h16.125c2.96431,0 5.375,2.41069 5.375,5.375v8.0625c0,2.96431 -2.41069,5.375 -5.375,5.375h-5.375v5.375h-5.375v-5.375h-10.75v-5.375h21.5v-8.0625h-16.125c-2.96431,0 -5.375,-2.41069 -5.375,-5.375v-8.0625c0,-2.96431 2.41069,-5.375 5.375,-5.375h5.375v-5.375h5.375v5.375h10.75z" fill="url(#color-4_77055_gr4)"></path><path d="M86,59.125c-5.92862,0 -10.75,-4.82138 -10.75,-10.75c0,-5.92862 4.82138,-10.75 10.75,-10.75c5.92863,0 10.75,4.82138 10.75,10.75c0,5.92862 -4.82137,10.75 -10.75,10.75zM86,43c-2.96431,0 -5.375,2.41069 -5.375,5.375c0,2.96431 2.41069,5.375 5.375,5.375c2.96431,0 5.375,-2.41069 5.375,-5.375c0,-2.96431 -2.41069,-5.375 -5.375,-5.375zM108.84375,53.75c-2.22256,0 -4.03125,-1.80869 -4.03125,-4.03125c0,-2.22256 1.80869,-4.03125 4.03125,-4.03125c2.22256,0 4.03125,1.80869 4.03125,4.03125c0,2.22256 -1.80869,4.03125 -4.03125,4.03125zM108.84375,49.71606v0.00269zM63.15625,53.75c-2.22256,0 -4.03125,-1.80869 -4.03125,-4.03125c0,-2.22256 1.80869,-4.03125 4.03125,-4.03125c2.22256,0 4.03125,1.80869 4.03125,4.03125c0,2.22256 -1.80869,4.03125 -4.03125,4.03125zM63.15625,49.71606v0.00269zM150.5,69.875c2.96431,0 5.375,-2.39456 5.375,-5.34544v-1.29806c0,-1.72269 -0.84119,-3.34862 -2.30319,-4.39138l-60.03069,-40.40925c-4.58219,-3.08256 -10.49737,-3.08256 -15.07956,0l-60.08981,40.44956c-1.40825,1.00244 -2.24675,2.62838 -2.24675,4.35106v1.29806c0,2.95088 2.41069,5.34544 5.375,5.34544h8.0625v59.13037c-4.44513,0 -8.0625,3.61738 -8.0625,8.0625v3.182c-3.12019,1.11531 -5.375,4.06888 -5.375,7.568v8.05713h139.75v-8.05712c0,-3.49913 -2.25481,-6.45269 -5.375,-7.568v-3.182c0,-4.44513 -3.61738,-8.0625 -8.0625,-8.0625v-59.13038zM150.5,147.81788v2.68212h-129v-2.68212c0,-1.4835 1.204,-2.69288 2.6875,-2.69288h123.625c1.4835,0 2.6875,1.20937 2.6875,2.69288zM145.125,137.06788v2.68212h-118.25v-2.68212c0,-1.4835 1.204,-2.69288 2.6875,-2.69288h26.875h16.125h26.875h16.125h26.875c1.4835,0 2.6875,1.20937 2.6875,2.69288zM51.0625,80.625v37.625h-16.125v-37.625zM34.9375,75.25v-5.375h16.125v5.375zM51.0625,123.625v5.375h-16.125v-5.375zM56.4375,129v-59.125h5.375h10.75h5.375h16.125h5.375h5.375h10.75v59.125h-10.75h-5.375h-5.375h-16.125h-5.375h-10.75zM137.0625,80.625v37.625h-16.125v-37.625zM120.9375,75.25v-5.375h16.125v5.375zM137.0625,123.625v5.375h-16.125v-5.375zM115.5625,64.5h-16.125h-26.875v0.0215l-16.125,0.00269v-0.02419h-26.875h-8.0625l-0.06719,-1.21475l60.03069,-40.40387c1.376,-0.92987 2.95625,-1.38944 4.5365,-1.38944c1.58025,0 3.1605,0.46494 4.5365,1.39481l59.9635,40.33938l0.00806,1.27388c0,0 -0.00269,0 -0.00806,0h-8.0625z" fill="url(#color-5_77055_gr5)"></path></g></g></svg>
</div>
</div>
<div class="col-4">
<div class="row">
<div class="col-auto p-r-10">
<div class="font-heading all-caps fs-11">{{item.type === 2 ? item.reference : item.company_business_type === 1 ? 'Company\'s Bank Account' : 'Personal Bank Account'}}</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="font-heading all-caps fs-10 muted">{{item.bank_name}}</div>
</div>
</div>
</div>
<div class="col">
<div class="font-heading fs-10">{{item.holder_name}}</div>
<div class="font-heading fs-11 text-complete m-b-5">{{item.type === 3 ? item.account_no : item.account_no.replace(/[^\dA-Z]/g, '').replace(/(.{4})/g, '$1 ').trim() }}</div>
</div>
<div class="col-auto b-l b-grey">
<div class="row h-100">
<div class="col">
<div class="row no-margin">
<div class="col-auto text-right p-t-10 p-b-10 bg-master-lightest requestModal" data-type="editBankModal">
<a class="pointer">
<div data-toggle="tooltip" title="" data-placement="bottom" class="row link align-items-center justify-content-center" data-original-title="Edit">
<div class="col">
<i class="fa fa-pencil text-info"></i>
</div>
</div>
</a>
</div>
<div class="col-auto m-l-10 d-flex align-items-center">
<div class="row align-items-center">
<div class="col-auto text-right p-t-5 p-b-5" :class="[{'bg-warning-lighter': item.default}, {'bg-master-light': !item.default}]">
<div data-toggle="tooltip" class="row align-items-center justify-content-center" :class="{'link': !item.default}">
<div class="col">
<i class="fa fa-star" :class="[{'text-warning': item.default}, {'text-master': !item.default}]"></i>
</div>
</div>
</div>
<div class="col bg-white p-t-5 p-b-5">
<small class="fs-12 all-caps bold" :class="[{'text-warning': item.default}, {'text-master': !item.default}]">Default Bank</small>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="editBankModal">
<edit-bank-form-component :data="item" :section="section" :company_id="company_id"></edit-bank-form-component>
</modal-component>
</div>
</template>
<script>
import componentHandler from '../../../general/mixins/componentHandler';
export default {
props: {
company_id: {
type: Number,
required: true
},
section: {
default: 'companyBanksSection'
}
},
mixins: [componentHandler]
}
</script>
@@ -9,6 +9,15 @@
<label :style="minWidth">Business Type</label>
<label>{{this.company_details.business_type ? getBusinessTypeDesc(this.company_details.business_type) : ""}}</label>
</div>
<div class="col-12 p-0">
<label :style="minWidth">Company Type</label>
<label>
{{getCompanyTypeDesc(this.company_details.type)}}
<div class="btn btn-xs b-rad-none pointer requestModal d-inline rounded no-border hover-primary" data-type="changeCompanyType" >
<i class="fa fa-edit pointer fa-fw fs-15 m-l-5"></i>
</div>
</label>
</div>
<div class="col-12 p-0">
<label :style="minWidth">Email</label>
<label><i class="fa fa-envelope text-primary fs-10"></i>&nbsp;{{this.company_details.employee ? this.company_details.employee.email : ""}}</label>
@@ -19,7 +28,12 @@
</div>
<div class="col-12 p-0">
<label :style="minWidth">&nbsp;</label>
<label><i class="fa fa-phone text-primary fs-10"></i>&nbsp;{{this.company_details.contact ? this.company_details.contact.phone : ""}}</label>
<label>
<i class="fa fa-phone text-primary fs-10"></i>&nbsp;{{this.company_details.contact ? this.company_details.contact.phone : ""}}
<div class="btn btn-xs b-rad-none pointer requestModal d-inline rounded no-border hover-primary" data-type="changeCustomerContactNumber" >
<i class="fa fa-edit pointer fa-fw fs-15 m-l-5"></i>
</div>
</label>
</div>
<div class="col-12 p-0" v-if="this.company_details.identification && this.company_details.identification.document_type">
<label class="muted pull-left" :style="minWidth">Identification</label>
@@ -38,10 +52,25 @@
</div>
</div>
</div>
<div class="col-12 p-0">
<div class="col-12 p-0 p-b-5 d-none">
<div class="btn btn-xs btn-default bg-master-lighter btn-rounded p-r-20 p-l-15 requestModal" data-type="editProfileInfo">
<i class="fa fa-pencil m-r-10"></i>Edit Profile Info
</div>
</div>
<div class="col-12 p-0 p-t-5">
<label class="muted m-b-0" :style="minWidth">Recipients Bank Accounts&nbsp;</label>
</div>
<div class="col-12 b-t b-grey p-t-5 p-b-5 m-t-5 m-b-5 p-l-0 p-r-1">
<list-component key="2" section="companyBanksSection" :endpoint="route('api.bank.list')" :options="{'company_id': this.company_details.id}" v-if="this.company_details.id">
<template slot="list" slot-scope="{data}">
<company-bank-account-component :data="data" :company_id="parseInt(company_details.id)" section="companyBanksSection"></company-bank-account-component>
</template>
</list-component>
</div>
<div class="col-12 p-0 p-t-5">
<label class="muted m-b-0" :style="minWidth">Address&nbsp;</label>
</div>
<div class="col-12 b-t b-b b-grey p-t-5 p-b-5 m-t-5 m-b-5 p-l-0 p-r-0">
<div class="col-12 b-t b-b b-grey p-t-5 p-b-5 m-t-5 m-b-5 p-l-0 p-r-1">
<list-component key="2" section="addresslist" :endpoint="route('api.address.list')" :options="{'company_id':this.company_details.id}" v-if="this.company_details.id">
<template slot="list" slot-scope="{data}">
<address-component :data="data" section="addressListItem"></address-component>
@@ -61,7 +90,15 @@
<modal-component id="deleteAddressModal">
<address-modal-component section="deleteAddressModal" :address_id="this.address_id"></address-modal-component>
</modal-component>
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="editProfileInfo">
<edit-customer-profile-info-form-component :data="this.company_details" :section="section" v-if="this.company_details.id"></edit-customer-profile-info-form-component>
</modal-component>
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="changeCustomerContactNumber">
<edit-customer-contact-number-form-component :data="this.company_details" :section="section"></edit-customer-contact-number-form-component>
</modal-component>
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="changeCompanyType">
<edit-customer-company-type-form-component :data="this.company_details" :section="section"></edit-customer-company-type-form-component>
</modal-component>
</div>
</template>
@@ -75,6 +112,10 @@
type:Object,
required:true
},
section: {
type: String,
required: true
},
},
mounted(){
this.$root.$on('deleteAddressConfirm', (id) => {
@@ -93,7 +134,7 @@
data(){
return {
minWidth:{
minWidth:'100px',
minWidth:'120px',
},
minWidth150:{
minWidth:'150px',
@@ -173,8 +214,22 @@
backToCompanyList() {
this.$root.$emit('backToCompanyList');
},
getBusinessTypeDesc(type){
return (type==1) ? 'Company Account':'Personal Account';
getBusinessTypeDesc(business_type_id) {
switch (business_type_id) {
case 1:
return 'Freight Forwarder';
case 2:
return 'Importer';
case 3:
return 'Currency Vendor';
case 4:
return 'Transfer Agent';
default:
return null;
}
},
getCompanyTypeDesc(company_type_id) {
return (company_type_id == 1) ? 'Company Business' : 'Personal Business';
},
},
mixins: [componentHandler]
@@ -1,6 +1,7 @@
<template>
<div class="row m-b-15 align-items-end parentContainer">
<div class="col">
<!-- 1688 consent -->
<div class="row m-l-0 m-r-0 m-b-15 animate__animated animate__tada animate__repeat-2 animate__delay-3s" v-if="!data.segments.some(item => item.id === 13 || item.id === 16)">
<div class="col bg-white padding-15">
<div class="row">
@@ -68,6 +69,49 @@
</div>
</div>
</div>
<!-- C2C consent -->
<div class="row m-l-0 m-r-0 m-b-15 animate__animated animate__tada animate__repeat-2 animate__delay-3s" v-if="!data.segments.some(item => item.id === 29)">
<div class="col bg-white padding-15">
<!-- <div class="row">
<div class="col-4">
<img class="m-b-10 w-100" src="/images/1688_approved.png" />
</div>
<div class="col"></div>
<div class="col-4">
<img class="m-b-10 w-100" src="/images/best-rate-300x127.png" />
</div>
</div> -->
<div class="row">
<div class="col">
<div class="row ">
<div class="col">
<h4 class="m-t-0">Bank Transfer Security: Safeguard Your Transactions with <span class="bold">Enterprise Account Payment (公对公转账)</span></h4>
<p>This payment is designed to facilitate CNY payments from <span class="bold text-primary">an enterprise bank account to your suppliers' enterprise bank accounts</span></p>
<p class="m-t-15">With this method, you can:</p>
<ul>
<li>Enjoy a worry-free transaction experience</li>
<li>Obtain detailed and transparent invoices</li>
</ul>
</div>
</div>
<div class="row">
<div class="col text-center">
<!-- <div class="btn btn-lg block btn m-b-5 no-border text-white" :class="[{'bg-primary': acknowledge_c2c}, {'bg-primary-lighter': !acknowledge_c2c}]" :style="{ cursor: acknowledge_c2c ? 'pointer' : 'no-drop' }" @click="activateServiceC2C">Activate Service</div> -->
<div class="btn btn-lg block btn m-b-5 no-border text-white requestModal pointer bg-primary" data-type="deleteMappingTransaction">Activate Service</div>
</div>
</div>
</div>
</div>
</div>
</div>
<modal-component class="animate__animated animate__fast animate__fadeIn" type="deleteMappingTransaction" styleType="fill-in" size="large">
<c2c-confirmation-form-component
class="text-center"
section="activateService"
:data="data"
>
</c2c-confirmation-form-component>
</modal-component>
<modal-component small type="requirements">
<div class="row" v-if="!failed">
<div class="col text-center">
@@ -12,6 +12,14 @@
</div>
</div>
<error-message-component class="m-b-20" :error="error"></error-message-component>
<div class="row m-b-15">
<div class="col">
<validation-wrapper-component selectable :validator="$v.segment_id">
<label>Segment</label>
<selectable-component :endpoint="route('api.segment.list')" section="segmentsListSection_" valueColumn="id" :labelColumn="['name']" v-model="segment_id"></selectable-component>
</validation-wrapper-component>
</div>
</div>
<div class="row">
<div class="col">
<file-input-component :validator="$v.files" v-model="files">
@@ -59,12 +67,17 @@
return {
files: [],
parameters: {},
segment_id: null,
options: null,
returnData: null
}
},
validations: {
files: {
required
},
segment_id: {
required
}
},
computed: {
@@ -75,7 +88,8 @@
methods: {
submitForm(){
this.parameters = {
files: this.files
files: this.files,
segment_id: this.segment_id,
};
this.submit(this.route('api.honey_trap.upload'), 'post', this.section, true, false);
},
@@ -0,0 +1,145 @@
<template>
<div class="row" @keyup.enter="submitForm">
<div class="col">
<div class="row">
<div class="col">
<div class="row m-b-20">
<div class="col">
<h3 class="all-caps m-b-5 bold no-margin">Edit Bank Account</h3>
</div>
</div>
<div class="row m-b-5 animate__animated animate__fadeInUpBig animate__fast" v-if="error">
<div class="col">
<small class="bold fs-10 text-danger">{{error}}</small>
</div>
</div>
<div class="row m-b-10">
<div class="col">
<validation-wrapper-component :validator="$v.parameters.reference">
<label>Reference</label>
<input type="text" class="form-control" v-model="parameters.reference">
</validation-wrapper-component>
</div>
</div>
<div class="row m-b-10">
<div class="col">
<validation-wrapper-component :validator="$v.parameters.holder_name">
<label>Account Holder Name / Company Name</label>
<input type="text" class="form-control" v-model="parameters.holder_name">
</validation-wrapper-component>
</div>
</div>
<div class="row m-b-10">
<div class="col">
<validation-wrapper-component :validator="$v.parameters.account_no">
<label>Account No.</label>
<input type="text" class="form-control" v-model="parameters.account_no">
</validation-wrapper-component>
</div>
</div>
<div class="row" v-if="parameters.type === 2">
<div class="col">
<div class="row m-b-10">
<div class="col">
<validation-wrapper-component :validator="$v.parameters.bank_name">
<label>Bank Name</label>
<input type="text" class="form-control" v-model="parameters.bank_name">
</validation-wrapper-component>
</div>
</div>
<div class="row m-b-10">
<div class="col">
<validation-wrapper-component :validator="$v.parameters.bank_branch">
<label>Bank Branch / 所在地</label>
<input type="text" class="form-control" v-model="parameters.bank_branch">
</validation-wrapper-component>
</div>
</div>
</div>
</div>
<div class="row m-b-20" v-if="parameters.type !== 2">
<div class="col">
<validation-wrapper-component selectable :validator="$v.parameters.bank_name">
<label>Bank Name</label>
<selectable-component endpoint="malaysian_banks.json" section="banksListSection" valueColumn="name" :labelColumn="['name']" v-model="parameters.bank_name"></selectable-component>
</validation-wrapper-component>
</div>
</div>
<div class="row">
<div class="col p-r-5">
<div class="btn btn-sm btn-default bg-master-lightest btn-block b-rad-none" data-dismiss="modal">Cancel</div>
</div>
<div class="col p-l-5">
<div class="btn btn-sm btn-success btn-block b-rad-none" @click="submitForm()">Update</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import modalFormHandler from "../../../general/mixins/modalFormHandler";
import { required } from "vuelidate/lib/validators";
export default {
props : {
company_id: {
type: Number,
required: true
},
},
created() {
console.log(this.parameters)
this.parameters.company_id = this.company_id;
this.parameters.account_type = this.data.type;
},
watch: {
'data': function() {
this.parameters = this.data;
this.parameters.company_id = this.company_id;
this.parameters.account_type = this.data.type;
}
},
data(){
return {
parameters: {
company_id: this.company_id
}
}
},
validations: {
parameters: {
holder_name: {
required
},
account_no: {
required
},
bank_branch: {
// required
},
swift: {
// required
},
snap: {
// required
},
bank_name: {
required
},
reference: {
// required
}
}
},
methods: {
submitForm(){
console.log(this.company_id)
this.submit(route('api.bank.update', this.data.id), 'put', this.section, true, true);
},
},
mixins: [modalFormHandler]
}
</script>
@@ -0,0 +1,71 @@
<template>
<div class="row" @keyup.enter="submitForm">
<div class="col">
<div class="row">
<div class="col">
<div class="row m-b-10">
<div class="col">
<h3 class="all-caps m-b-5 no-margin text-center">Edit Company Type</h3>
<div class="fs-11 text-center">Please double confirm before ediiting the Company Type</div>
</div>
</div>
<div class="row m-b-10">
<div class="col">
<validation-wrapper-component selectable :validator="$v.parameters.type">
<label>Company Type</label>
<selectable-component :endpoint="route('api.company.company_type.list')" section="listCompanyTypeSection" valueColumn="id" :labelColumn="['type']" v-model="parameters.type"></selectable-component>
</validation-wrapper-component>
</div>
</div>
<div class="row">
<div class="col p-r-5">
<div class="btn btn-sm btn-default bg-master-lightest btn-block b-rad-none" data-dismiss="modal">Cancel</div>
</div>
<div class="col p-l-5">
<div class="btn btn-sm btn-success btn-block b-rad-none" @click="submitForm()">Update</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import modalFormHandler from "../../../general/mixins/modalFormHandler";
import { required, email } from "vuelidate/lib/validators";
export default {
props: {
data: {
type: Object,
default: null
},
},
created() {
this.parameters = {};
this.parameters.type = [0,1].includes(this.data.type) ? this.data.type: 0;
this.parameters.email = this.data.contact ? this.data.contact.email : "";
this.parameters.phone = this.data.contact ? this.data.contact.phone : "";
},
data(){
return {
parameters: {},
}
},
validations: {
parameters: {
type: {
required,
},
}
},
methods: {
submitForm(){
this.submit(route('api.company.profile.update', this.data.id), 'put', this.section, true, true);
},
successHandler(){
window.location.reload();
},
},
mixins: [modalFormHandler]
}
</script>
@@ -0,0 +1,70 @@
<template>
<div class="row" @keyup.enter="submitForm">
<div class="col">
<div class="row">
<div class="col">
<div class="row m-b-10">
<div class="col">
<h3 class="all-caps m-b-5 no-margin text-center">Edit Contact Number</h3>
</div>
</div>
<div class="row m-b-10">
<div class="col">
<validation-wrapper-component :validator="$v.parameters.phone">
<label>Phone</label>
<input type="text" class="form-control" v-model="parameters.phone">
</validation-wrapper-component>
</div>
</div>
<div class="row">
<div class="col p-r-5">
<div class="btn btn-sm btn-default bg-master-lightest btn-block b-rad-none" data-dismiss="modal">Cancel</div>
</div>
<div class="col p-l-5">
<div class="btn btn-sm btn-success btn-block b-rad-none" @click="submitForm()">Update</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import modalFormHandler from "../../../general/mixins/modalFormHandler";
import { required, email } from "vuelidate/lib/validators";
export default {
props: {
data: {
type: Object,
default: null
},
},
created() {
this.parameters = {};
this.parameters.type = [0,1].includes(this.data.type) ? this.data.type: 0;
this.parameters.email = this.data.contact ? this.data.contact.email : "";
this.parameters.phone = this.data.contact ? this.data.contact.phone : "";
},
data(){
return {
parameters: {},
}
},
validations: {
parameters: {
phone: {
required,
},
}
},
methods: {
submitForm(){
this.submit(route('api.company.profile.update', this.data.id), 'put', this.section, true, true);
},
successHandler(){
window.location.reload();
},
},
mixins: [modalFormHandler]
}
</script>
@@ -0,0 +1,89 @@
<template>
<div class="row" @keyup.enter="submitForm">
<div class="col">
<div class="row">
<div class="col">
<div class="row m-b-10">
<div class="col">
<h3 class="all-caps m-b-5 bold no-margin">Edit Customer Profile</h3>
</div>
</div>
<div class="row m-b-10">
<div class="col">
<validation-wrapper-component selectable :validator="$v.parameters.type">
<label>Company Type</label>
<selectable-component :endpoint="route('api.company.company_type.list')" section="listCompanyTypeSection" valueColumn="id" :labelColumn="['type']" v-model="parameters.type"></selectable-component>
</validation-wrapper-component>
</div>
</div>
<div class="row m-b-10">
<div class="col">
<validation-wrapper-component :validator="$v.parameters.email">
<label>Email</label>
<input type="text" class="form-control" v-model="parameters.email">
</validation-wrapper-component>
</div>
</div>
<div class="row m-b-10">
<div class="col">
<validation-wrapper-component :validator="$v.parameters.phone">
<label>Phone</label>
<input type="text" class="form-control" v-model="parameters.phone">
</validation-wrapper-component>
</div>
</div>
<div class="row">
<div class="col p-r-5">
<div class="btn btn-sm btn-default bg-master-lightest btn-block b-rad-none" data-dismiss="modal">Cancel</div>
</div>
<div class="col p-l-5">
<div class="btn btn-sm btn-success btn-block b-rad-none" @click="submitForm()">Update</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import modalFormHandler from "../../../general/mixins/modalFormHandler";
import { required, email } from "vuelidate/lib/validators";
export default {
props: {
data: {
type: Object,
default: null
},
},
created() {
this.parameters = {};
this.parameters.type = [0,1].includes(this.data.type) ? this.data.type: 0;
this.parameters.email = this.data.contact ? this.data.contact.email : "";
this.parameters.phone = this.data.contact ? this.data.contact.phone : "";
},
data(){
return {
parameters: {},
}
},
validations: {
parameters: {
type: {
required,
},
email: {
email,
},
phone: {
required,
},
}
},
methods: {
submitForm(){
this.submit(route('api.company.profile.update', this.data.id), 'put', this.section, true, true);
},
},
mixins: [modalFormHandler]
}
</script>
@@ -122,7 +122,7 @@
<div class="col">
<div class="row">
<div class="col">
<company-details-component :company_details="company_details" section="customerProfileSection"></company-details-component>
<company-details-component :company_details="company" section="customerProfileSection"></company-details-component>
</div>
</div>
</div>
@@ -0,0 +1,67 @@
<template>
<div class="row bg-white padding-25">
<div class="col">
<loading-component style="height: 300px; top: 0;" key="1" color="success" v-show="isLoading" ></loading-component>
<div class="row justify-content-center" v-show="!isLoading">
<div class="col">
<div class="row">
<div class="col">
<h3>To activate the service, please take note of the following important details:</h3>
<ol class="m-t-15">
<li class='text-left'>The minimum amount is <strong>CNY 10,000</strong> for each transfer.</li>
<li class='text-left'>The purchase order must be filled in before making payments.</li>
<li class='text-left'>The processing time for each transaction is <strong>3-7 working days</strong>.</li>
</ol>
</div>
</div>
<div class="row m-t-10">
<div class="col">
<div class="checkbox check-primary m-t-0">
<input type="checkbox" v-model="acknowledge_c2c" id="acknowledge_c2c">
<label for="acknowledge_c2c" style="white-space: pre-wrap;">I hereby acknowledge that I have read the requirements for this service.</label>
</div>
</div>
</div>
<div class="row">
<div class="col p-r-5">
<div class="btn btn-lg block btn m-b-5 no-border bg-master-lighter" data-dismiss="modal">Cancel</div>
</div>
<div class="col p-l-5">
<div class="btn btn-lg block btn m-b-5 no-border text-white" :class="[{'bg-primary': acknowledge_c2c}, {'bg-primary-lighter': !acknowledge_c2c}]" :style="{ cursor: acknowledge_c2c ? 'pointer' : 'no-drop' }" @click="activateServiceC2C">Activate Service</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import componentHandler from '../../../general/mixins/componentHandler';
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
export default {
data(){
return {
acknowledge_c2c: false,
parameters: {
segment_id: ''
},
}
},
methods: {
activateServiceC2C(){
this.parameters = {
segment_id: 29
};
if(this.acknowledge_c2c){
this.submit(this.route('api.company.segment.assign', this.data.id), 'post', 'activateService', true, true);
}
// location.reload();
},
successHandler(){
location.reload();
}
},
mixins: [componentHandler, ModalFormHandler]
}
</script>
+1 -1
View File
@@ -149,4 +149,4 @@
@yield('inner_content')
</body>
</html>
</html>
@@ -33,7 +33,8 @@
<div class="number">EDO: {{ $transaction->bill_no }}</div>
<div class="ref">REF: {{ $transaction->booking->marking }}</div>
<div class="date">Date: {{ $supplier->segments->whereIn('id', [23])->first() ? \Carbon\Carbon::now() : $po_order_transaction->created_at }}</div>
<div class="date">Date: {{
$supplier->segments->whereIn('id', [23])->first() ? \Carbon\Carbon::now() : $po_order_transaction->created_at }}</div>
<div>&nbsp;</div>
</td>
<tr>
@@ -69,6 +70,7 @@
<br>
<br>
<table class="line-table" style="overflow: wrap" autosize="1">
<!-- Table Header -->
<thead>
<tr>
<th width="5%">No</th>
@@ -81,34 +83,37 @@
</thead>
<tbody>
@php
$subtotal = 0;
$voucher_redemption = isset($voucher_redemption) ? $voucher_redemption : null;
$voucherDiscount = $voucher_redemption ? $voucher_redemption->value * -1 : 0;
$currencyRate = $transaction->currency_rate;
$subtotal = "0";
$voucherDiscount = $voucher_redemption ? bcmul((string)$voucher_redemption->value, "-1", 2) : "0";
$displayedSubtotal = 0;
@endphp
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
@php
$exactUnitPrice = bcdiv($transaction_detail->price, $transaction->currency_rate, 5);
$itemTotal = bcmul($exactUnitPrice, $transaction_detail->quantity, 5);
$displayedItemTotal = bcmul($exactUnitPrice, $transaction_detail->quantity, 2);
$displayedSubtotal = bcadd($displayedSubtotal, $displayedItemTotal, 2);
$subtotal = bcadd($subtotal, $displayedItemTotal, 2);
@endphp
<tr>
<td width="5%" class="center top">{{ $key + 1 }}</td>
<td class="stock-code top" width="10%">{{ $transaction_detail->product_code }}</td>
<td class="description">{{ $transaction_detail->product_name }}</td>
<td width="10%" class="center top">{{ $transaction_detail->quantity }}</td>
<td width="15%" class="center top">
@php
$unitPrice = $transaction_detail->price / $currencyRate;
@endphp
{{ number_format($unitPrice, 2) }}
{{ number_format($exactUnitPrice, 2) }}
</td>
<td width="20%" class="right top">
@php
$itemTotal = $unitPrice * $transaction_detail->quantity;
$subtotal += $itemTotal;
@endphp
{{ number_format($itemTotal, 2) }}
</td>
</tr>
@endforeach
</tbody>
<tfoot>
@php
$subtotalWithDiscount = bcsub($subtotal, $voucherDiscount, 5); // Use bcsub to subtract
@endphp
<tr class="subtotal">
<td colspan="4"></td>
<td class="right middle">Subtotal</td>
@@ -117,27 +122,17 @@
<tr class="billingcharges">
<td colspan="4"></td>
<td class="right">Service Charges</td>
<td class="right">
{{ number_format($transaction->service_charge, 2) }}
</td>
<td class="right">{{ number_format($transaction->service_charge, 2) }}</td>
</tr>
@if($voucher_redemption)
<tr class="voucher">
<td colspan="4"></td>
<td class="right middle">Voucher ({{ $voucher_redemption->voucher->code }})</td>
<td class="right middle">-{{ $voucherDiscount }}</td>
<td class="right middle">-{{ number_format($voucherDiscount, 2) }}</td>
</tr>
@endif
<tr class="billingcharges">
<td colspan="4"></td>
<td class="right">Adjustment</td>
<td class="right">
@php
$adjustment = $transaction->amount - $subtotal;
@endphp
{{ number_format($adjustment, 2) }}
</td>
</tr>
@if($transaction->tax > 0)
<tr class="billingcharges">
<td colspan="4"></td>
@@ -145,13 +140,21 @@
<td class="right">{{ number_format($transaction->tax, 2) }}</td>
</tr>
@endif
@php
$displayedTotal = bcadd(bcadd(bcadd($displayedSubtotal, $transaction->service_charge, 2), $transaction->tax, 2), $voucherDiscount, 2);
$expectedTotal = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5);
$discrepancy = bcsub($displayedTotal, $expectedTotal, 5);
$total = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5); // Keep precision
@endphp
<tr>
<td colspan="4"></td>
<td class="right middle">Adjustment</td>
<td class="right middle">{{number_format($discrepancy, 5)}}</td>
</tr>
<tr>
<td colspan="4"></td>
<td class="right middle">Total</td>
<td class="total right middle">
@php
$total = $subtotal + $transaction->service_charge + $transaction->tax + $voucherDiscount;
@endphp
{{ number_format($total, 2) }}
</td>
</tr>
+56 -60
View File
@@ -1,21 +1,21 @@
@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>
<!-- Header Section -->
<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-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>
@@ -23,14 +23,8 @@
Tel: 03-8082 1252
</td>
<td class="header-details">
<div class="title">
<strong>
Invoice
</strong>
</div>
<div class="title"><strong>Invoice</strong></div>
<div class="number">EI#: {{ $transaction->bill_no }}</div>
<div class="ref">Ref# {{ $po_order_transaction->booking->marking }}</div>
<div class="date">Date: {{ $supplier->segments->whereIn('id', [23])->first() ? \Carbon\Carbon::now() : $po_order_transaction->booking->created_at }}</div>
<div>&nbsp;</div>
@@ -38,37 +32,34 @@
</tr>
<tr>
<td colspan="3" class="bill-to">
<span class="sub-title">
Bill To
</span>
<span class="sub-title">Bill To</span>
</td>
</tr>
<tr>
<td colspan="3" class="address">
<div class="label">
{{ $supplier->name }}
</div>
<div class="label">{{ $supplier->name }}</div>
@php
$billingAddress = $supplier->addresses()->where('billing', '=', true)->first();
@endphp
<div class="address">
@php
$billingAddress = $supplier->addresses()->where('billing', '=', true)->first();
@endphp
{{ $billingAddress->street_one }}
{{ $billingAddress->street_two }} ,
{{ $billingAddress->street_two }},
{{ $billingAddress->district()->first()->name }},
{{ $billingAddress->postcode }}
{{ $billingAddress->state()->first()->name }},
{{ $billingAddress->country()->first()->name }}
</div>
<div>
Phone: {{ $supplier->contacts()->first()->phone }}
</div>
<div>Phone: {{ $supplier->contacts()->first()->phone }}</div>
</td>
</tr>
</table>
<br>
<br>
<!-- Invoice Table -->
<table class="line-table" style="overflow: wrap" autosize="1">
<!-- Table Header -->
<thead>
<tr>
<th width="5%">No</th>
@@ -81,35 +72,37 @@
</thead>
<tbody>
@php
$subtotal = 0;
$voucher_redemption = isset($voucher_redemption) ? $voucher_redemption : null;
$voucherDiscount = $voucher_redemption ? $voucher_redemption->value * -1 : 0;
$currencyRate = $transaction->currency_rate;
$subtotal = "0";
$voucherDiscount = $voucher_redemption ? bcmul((string)$voucher_redemption->value, "-1", 2) : "0";
$displayedSubtotal = 0;
@endphp
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
@php
$exactUnitPrice = bcdiv($transaction_detail->price, $transaction->currency_rate, 7);
$itemTotal = bcmul($exactUnitPrice, $transaction_detail->quantity, 5);
$displayedItemTotal = bcmul($exactUnitPrice, $transaction_detail->quantity, 2);
$displayedSubtotal = bcadd($displayedSubtotal, $displayedItemTotal, 2);
$subtotal = bcadd($subtotal, $itemTotal, 5);
@endphp
<tr>
<td width="5%" class="center top">{{ $key + 1 }}</td>
<td class="stock-code top" width="10%">{{ $transaction_detail->product_code }}</td>
<td class="description">{{ $transaction_detail->product_name }}</td>
<td width="10%" class="center top">{{ $transaction_detail->quantity }}</td>
<td width="15%" class="center top">
@php
$unitPrice = $transaction_detail->price / $currencyRate;
@endphp
{{ number_format($unitPrice, 2) }}
{{ number_format($exactUnitPrice, 2) }}
</td>
<td width="20%" class="right top">
@php
$itemTotal = $unitPrice * $transaction_detail->quantity;
$subtotal += $itemTotal;
@endphp
{{ number_format($itemTotal, 2) }}
</td>
</tr>
@endforeach
</tbody>
<tfoot>
@php
$subtotalWithDiscount = bcsub($subtotal, $voucherDiscount, 5);
@endphp
<tr class="subtotal">
<td colspan="4"></td>
<td class="right middle">Subtotal</td>
@@ -120,23 +113,15 @@
<td class="right">Service Charges</td>
<td class="right">{{ number_format($transaction->service_charge, 2) }}</td>
</tr>
@if($voucher_redemption)
<tr class="voucher">
<td colspan="4"></td>
<td class="right middle">Voucher ({{ $voucher_redemption->voucher->code }})</td>
<td class="right middle">-{{ $voucherDiscount }}</td>
<td class="right middle">-{{ number_format($voucherDiscount, 2) }}</td>
</tr>
@endif
<tr class="billingcharges">
<td colspan="4"></td>
<td class="right">Adjustment</td>
<td class="right">
@php
$adjustment = $transaction->amount - $subtotal;
@endphp
{{ number_format($adjustment, 2) }}
</td>
</tr>
@if($transaction->tax > 0)
<tr class="billingcharges">
<td colspan="4"></td>
@@ -144,24 +129,35 @@
<td class="right">{{ number_format($transaction->tax, 2) }}</td>
</tr>
@endif
@php
$displayedTotal = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5);
$expectedTotal = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5);
$discrepancy = bcsub($displayedTotal, $expectedTotal, 5);
$total = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5);
@endphp
<tr>
<td colspan="4"></td>
<td class="right middle">Adjustment</td>
<td class="right middle">{{number_format($discrepancy, 5)}}</td>
</tr>
<tr>
<td colspan="4"></td>
<td class="right middle">Total</td>
<td class="total right middle">
@php
$total = $subtotal + $transaction->service_charge + $transaction->tax + $voucherDiscount;
@endphp
{{ number_format($total, 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>
<br>
<div class="note">
<strong>Note:</strong> All items purchased are subject to our Terms & Conditions. Please refer to our official website for more information.
</div>
<br><br>
<div class="bank-info">
Please transfer the payment to:<br>
Bank: Maybank Berhad<br>
Account Name: CIEF Worldwide Sdn Bhd<br>
Account No: 564892103405<br>
</div>
@endsection
@@ -24,9 +24,9 @@
<table class="buyer-seller">
<tr>
<td width="50%" class="top">
<span class="buyer-seller-title">
Buyer
</span>
<span class="buyer-seller-title">
Buyer
</span>
<br>
<div class="buyer-company">
@@ -34,34 +34,34 @@
</div>
<span class="buyer-company">
{{ $supplier->name }}
</span>
{{ $supplier->name }}
</span>
<span class="reg">
{{-- {{ $supplier }} --}}
</span>
{{-- {{ $supplier }} --}}
</span>
<br>
<span class="address">
@php
$billingAddress = $supplier->addresses()->where('billing', '=', true)->first();
@endphp
@php
$billingAddress = $supplier->addresses()->where('billing', '=', true)->first();
@endphp
{{ $billingAddress->street_one }}
{{ $billingAddress->street_two }}
{{ $billingAddress->state()->first()->name }}
{{ $billingAddress->district()->first()->name }}
</span>
</span>
<br>
<span class="contact-no">
Phone: {{ $supplier->contacts()->first()->phone }}
</span>
Phone: {{ $supplier->contacts()->first()->phone }}
</span>
</td>
<td width="50%" class="top">
<span class="buyer-seller-title">
Seller
</span>
<span class="buyer-seller-title">
Seller
</span>
<br>
<span class="buyer-company">
CIEF Worldwide Sdn Bhd (1134596-M)
</span>
CIEF Worldwide Sdn Bhd (1134596-M)
</span>
<div class="address">
No. 72-3, Jalan Jalil 1,<br>
The Earth Bukit Jalil,<br>
@@ -77,6 +77,7 @@
<br>
<table class="line-table" style="overflow: wrap" autosize="1">
<!-- Table Header -->
<thead>
<tr>
<th width="5%">No</th>
@@ -89,34 +90,41 @@
</thead>
<tbody>
@php
$subtotal = 0;
$voucher_redemption = isset($voucher_redemption) ? $voucher_redemption : null;
$voucherDiscount = $voucher_redemption ? $voucher_redemption->value * -1 : 0;
$currencyRate = $transaction->currency_rate;
$subtotal = "0";
$displayedSubtotal = 0;
@endphp
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
@php
$exactUnitPrice = bcdiv($transaction_detail->price, $transaction->currency_rate, 5);
$itemTotal = bcmul($exactUnitPrice, $transaction_detail->quantity, 5);
$displayedItemTotal = bcmul($exactUnitPrice, $transaction_detail->quantity, 2);
$displayedSubtotal = bcadd($displayedSubtotal, $displayedItemTotal, 2);
@endphp
<tr>
<td width="5%" class="center top">{{ $key + 1 }}</td>
<td class="stock-code top" width="10%">{{ $transaction_detail->product_code }}</td>
<td class="description">{{ $transaction_detail->product_name }}</td>
<td width="10%" class="center top">{{ $transaction_detail->quantity }}</td>
<td width="15%" class="center top">
@php
$unitPrice = $transaction_detail->price / $currencyRate;
@endphp
{{ number_format($unitPrice, 2) }}
{{ number_format($exactUnitPrice, 2) }}
</td>
<td width="20%" class="right top">
@php
$itemTotal = $unitPrice * $transaction_detail->quantity;
$subtotal += $itemTotal;
@endphp
{{ number_format($itemTotal, 2) }}
</td>
</tr>
@endforeach
</tbody>
<tfoot>
@php
$voucherDiscount = $voucher_redemption ? bcmul((string)$voucher_redemption->value, "-1", 2) : "0";
$subtotalWithDiscount = bcsub($subtotal, $voucherDiscount, 5); // Use bcsub to subtract
$displayedTotal = bcadd(bcadd(bcadd($displayedSubtotal, $transaction->service_charge, 2), $transaction->tax, 2), $voucherDiscount, 2);
$expectedTotal = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5);
$discrepancy = bcsub($displayedTotal, $expectedTotal, 5);
$total = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5); // Keep precision
$subtotal = bcadd($subtotal, $displayedItemTotal, 2);
@endphp
<tr class="subtotal">
<td colspan="4"></td>
<td class="right middle">Subtotal</td>
@@ -125,27 +133,17 @@
<tr class="billingcharges">
<td colspan="4"></td>
<td class="right">Service Charges</td>
<td class="right">
{{ number_format($transaction->service_charge, 2) }}
</td>
<td class="right">{{ number_format($transaction->service_charge, 2) }}</td>
</tr>
@if($voucher_redemption)
<tr class="voucher">
<td colspan="4"></td>
<td class="right middle">Voucher ({{ $voucher_redemption->voucher->code }})</td>
<td class="right middle">-{{ $voucherDiscount }}</td>
<td class="right middle">-{{ number_format($voucherDiscount, 2) }}</td>
</tr>
@endif
<tr class="billingcharges">
<td colspan="4"></td>
<td class="right">Adjustment</td>
<td class="right">
@php
$adjustment = $transaction->amount - $subtotal;
@endphp
{{ number_format($adjustment, 2) }}
</td>
</tr>
@if($transaction->tax > 0)
<tr class="billingcharges">
<td colspan="4"></td>
@@ -153,13 +151,16 @@
<td class="right">{{ number_format($transaction->tax, 2) }}</td>
</tr>
@endif
<tr>
<td colspan="4"></td>
<td class="right middle">Adjustment</td>
<td class="right middle">{{number_format($discrepancy, 5)}}</td>
</tr>
<tr>
<td colspan="4"></td>
<td class="right middle">Total</td>
<td class="total right middle">
@php
$total = $subtotal + $transaction->service_charge + $transaction->tax + $voucherDiscount;
@endphp
{{ number_format($total, 2) }}
</td>
</tr>
+4
View File
@@ -7,10 +7,14 @@ Route::group(['prefix' => 'company', 'as' => 'company.', 'namespace' => 'Compani
Route::get('/list', 'ListCompaniesController@list')->name('list');
Route::post('/create', 'CreateCompanyController@create')->name('create');
Route::put('/update/{id}', 'UpdateCompanyController@update')->name('update');
Route::put('/update/{id}/profile', 'UpdateCompanyProfileController@update')->name('profile.update');
Route::put('update/{id}/status', 'UpdateCompanyStatusController@update')->name('status.update');
Route::delete('/delete/{id}', 'DeleteCompanyController@destroy')->name('delete');
Route::put('/name-and-debtor/update/{id}', 'UpdateCompanyNameAndDebtorController@update')->name('update.nameAndDebtor');
Route::get('/business-type/list', 'ListBusinessTypesController@list')->name('business_type.list');
Route::get('/company-type/list', 'ListCompanyTypesController@list')->name('company_type.list');
Route::put('/update/debtor/{id}', 'UpdateCompanyDebtorController@update')->name('delete');
Route::post('/team/create', 'AddNewMemberController@create')->name('team.create');
+37
View File
@@ -1,5 +1,6 @@
<?php
use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionProcessor;
use App\Http\Controllers\Accounting\BankStatementController;
use Carbon\Carbon;
use App\Models\User;
@@ -113,6 +114,27 @@ Route::get('/transfer/{marking}', function ($marking) {
return view('pages.bookings.profile', ['marking' => $marking]);
})->name('booking.details');
Route::get('/transfer/{marking}/latest-invoice', function ($marking) {
$booking= Booking::where('marking', $marking)->first();
$purchaseOrder = $booking->transactions()
->where('type', TransactionType::PURCHASE_ORDER)
->complete()
->first();
$transaction = $booking->transactions()
->where('type', TransactionType::PAYMENT)
->latest()->get()[0];
$supplier = Company::where('id', $transaction->receiver)->first();
$lowercaseDocumentType = strtolower(DocumentType::INVOICE);
$voucherRedemption = $transaction->voucherRedemption;
return view('pages.pdfs.' . $lowercaseDocumentType, ['transaction' => $transaction, 'po_order_transaction' => $purchaseOrder, 'supplier' => $supplier, 'voucher_redemption' => $voucherRedemption]);
})->name('booking.details.latest_invoice');
Route::get('/transfer/merge/{marking}', function ($marking) {
return view('pages.bookings.merge', ['marking' => $marking]);
})->name('booking.merge');
@@ -466,6 +488,21 @@ Route::get('/payments/manual', function(){
Route::get('/invoice/fix', function(){
set_time_limit(1800);
$bookings = Booking::where('status', ApprovalStatus::COMPLETED)->whereDate('updated_at', '>=', Carbon::parse('01-01-2023'))->get();
foreach($bookings as $booking){
$booking->transactions()->whereIn('transactions.type', [TransactionType::INVOICE, TransactionType::SUPPLIER_DELIVER])->delete();
$booking->documents()->whereIn('document_type', [DocumentType::INVOICE, DocumentType::PURCHASE_ORDER, DocumentType::DELIVER_ORDER, DocumentType::SUPPLIER_DELIVER_ORDER])->delete();
$booking->status = ApprovalStatus::APPROVED;
$booking->save();
(App()->make(CreateInvoiceTransactionProcessor::class))->execute($booking);
}
})->name('invoice.fix');
Route::get('/1688/fix/{reference}', function($reference){
$booking = Booking::where('marking', $reference)->first();