mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-24 23:13:59 +00:00
Merge branch 'dillon/34.6-jenkins-vapor' into vapor/development
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Models\Bank;
|
||||
use App\Models\Booking;
|
||||
|
||||
|
||||
class DeleteDuplicate1688BankAccountV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Delete duplicate 1688 account in banks table.');
|
||||
$start = new Carbon();
|
||||
|
||||
// account_no: 1688 LOGIN ID/EMAIL/PHONE
|
||||
// holder_name: password
|
||||
// bank_branch: 6-digit pin
|
||||
|
||||
$records = Bank::where('type', 3)->get();
|
||||
|
||||
$groupedBanks = $records->groupBy(function($item, $key) {
|
||||
return $item['company_id'] . '-' . $item['account_no'];
|
||||
});
|
||||
|
||||
foreach ($groupedBanks as $key => $banksWithSameUserAndAccountNo) {
|
||||
// Sort banks by created_at or updated_at to find the latest one
|
||||
$sortedBanks = $banksWithSameUserAndAccountNo->sortByDesc('created_at');
|
||||
|
||||
// Retain the latest bank
|
||||
$latestBank = $sortedBanks->first();
|
||||
|
||||
// Get all IDs except the latest one
|
||||
$idsToDelete = $sortedBanks->pluck('id')->slice(1);
|
||||
|
||||
foreach ($idsToDelete as $id) {
|
||||
Booking::where('bank_id', $id)->update([
|
||||
'bank_id' => $latestBank->id
|
||||
]);
|
||||
}
|
||||
|
||||
Log::info('for company id: ' . $latestBank->company_id . ', account no: ' . $latestBank->account_no . ', duplicated id: ' . $idsToDelete);
|
||||
// Delete the rest
|
||||
Bank::whereIn('id', $idsToDelete)->delete();
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Delete duplicate 1688 account in banks table. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -25,41 +25,42 @@ class ExpiredBookingV2CommandJob implements ShouldQueue
|
||||
Log::info(Carbon::now() . ': Start job - Expiring booking that do not have further action by user.');
|
||||
$start = new Carbon();
|
||||
|
||||
// 1. Cancel booking without payment & purchase order (1 month)
|
||||
$bookings = Booking::where('status', ApprovalStatus::APPROVED)
|
||||
->where('created_at', '<', now()->subDays(30)->endOfDay())
|
||||
->where(function ($query) {
|
||||
$query->whereDoesntHave('transactions')
|
||||
->orWhereDoesntHave('transactions', function($transaction) {
|
||||
return $transaction->where('type', TransactionType::PURCHASE_ORDER)->orWhere(function ($q) {
|
||||
$q->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
});
|
||||
});
|
||||
})->get();
|
||||
// 1. Cancel booking without payment & purchase order (1 month)
|
||||
$bookings = Booking::where('status', ApprovalStatus::APPROVED)
|
||||
->where('created_at', '<', now()->subDays(30)->endOfDay())
|
||||
->where('service_id', '!=', 4)
|
||||
->where(function ($query) {
|
||||
$query->whereDoesntHave('transactions')
|
||||
->orWhereDoesntHave('transactions', function($transaction) {
|
||||
return $transaction->where('type', TransactionType::PURCHASE_ORDER)->orWhere(function ($q) {
|
||||
$q->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED, ApprovalStatus::REFUNDED]);
|
||||
});
|
||||
});
|
||||
})->get();
|
||||
|
||||
foreach ($bookings as $booking) {
|
||||
(App()->make(UpdatesBookingStatus::class))->execute($booking, ApprovalStatus::EXPIRED);
|
||||
Log::info(Carbon::now() . " : Expired Booking without payment & purchase order, booking id: " . $booking->id);
|
||||
$transactions = $booking->transactions;
|
||||
Log::info(Carbon::now() . " : Expired Booking without payment & purchase order, booking id: " . $booking->id);
|
||||
$transactions = $booking->transactions;
|
||||
|
||||
foreach ($transactions as $transaction) {
|
||||
$prevStatus = $transaction->status;
|
||||
$transaction->status = ApprovalStatus::EXPIRED;
|
||||
$transaction->save();
|
||||
Log::info(Carbon::now() . " : Expired Transaction id: {$transaction->id} from Booking id: {$booking->id}. Status before update: {$prevStatus}");
|
||||
}
|
||||
foreach ($transactions as $transaction) {
|
||||
$prevStatus = $transaction->status;
|
||||
$transaction->status = ApprovalStatus::EXPIRED;
|
||||
$transaction->save();
|
||||
Log::info(Carbon::now() . " : Expired Transaction id: {$transaction->id} from Booking id: {$booking->id}. Status before update: {$prevStatus}");
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Cancel booking without payment but with purchase order (2 month)
|
||||
$bookings = Booking::where('status', ApprovalStatus::APPROVED)
|
||||
->where('created_at', '<', now()->subDays(60)->endOfDay())
|
||||
->where(function ($query) {
|
||||
$query->whereDoesntHave('transactions', function($transaction) {
|
||||
return $transaction->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
})->whereHas('transactions', function($transaction) {
|
||||
return $transaction->where('type', TransactionType::PURCHASE_ORDER);
|
||||
});
|
||||
})->get();
|
||||
->where('created_at', '<', now()->subDays(60)->endOfDay())
|
||||
->where(function ($query) {
|
||||
$query->whereDoesntHave('transactions', function($transaction) {
|
||||
return $transaction->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED, ApprovalStatus::REFUNDED]);
|
||||
})->whereHas('transactions', function($transaction) {
|
||||
return $transaction->where('type', TransactionType::PURCHASE_ORDER);
|
||||
});
|
||||
})->get();
|
||||
|
||||
foreach ($bookings as $booking) {
|
||||
(App()->make(UpdatesBookingStatus::class))->execute($booking, ApprovalStatus::EXPIRED);
|
||||
|
||||
@@ -76,49 +76,84 @@ class ExpiredRefundedBookingV2CommandJob implements ShouldQueue
|
||||
if (!$bookingPayment) {
|
||||
$bookingPayment = $booking->transactions()->payments()->whereIn('status', [ApprovalStatus::SUSPENDED, ApprovalStatus::EXPIRED, ApprovalStatus::REJECTED])->orderBy('id', 'DESC')->first();
|
||||
}
|
||||
}
|
||||
|
||||
if ($bookingPayment) {
|
||||
$status = ApprovalStatus::APPROVAL_STATUS_ID[$bookingPayment->status];
|
||||
Log::info("Credit note transaction id: {$transaction->id}, the payment for the booking is in status {$status}");
|
||||
}
|
||||
$bookingPaymentAmount = $bookingPayment->amount;
|
||||
// check if the booking is fully refund
|
||||
$amountDifference = bcsub($transaction->amount, $bookingPaymentAmount, 7);
|
||||
|
||||
if (abs($amountDifference) < 0.01) {
|
||||
// rejecting booking payment transaction
|
||||
// $bookingPayment->status = ApprovalStatus::REJECTED;
|
||||
// $bookingPayment->save();
|
||||
$bookingPaymentAmount = $bookingPayment->amount;
|
||||
// check if the booking is fully refund
|
||||
$amountDifference = bcsub($transaction->amount, $bookingPaymentAmount, 7);
|
||||
|
||||
//expired booking
|
||||
// $this->updatesBookingStatus->execute($booking, ApprovalStatus::EXPIRED);
|
||||
Log::info("Credit note transaction id: {$transaction->id} is fully refunded, the refunded amount was {$transaction->amount} the payment reference is: {$transaction->payment_reference}");
|
||||
// Log::info("Credit note transaction id: {$transaction->id}, Rejected Booking Transaction Payment id: {$bookingPayment->id}, the payment amount was {$bookingPayment->amount}");
|
||||
// Log::info("Credit note transaction id: {$transaction->id}, Expired Booking id: {$booking->id}");
|
||||
$isFullyRefund = false;
|
||||
if (abs($amountDifference) < 0.01) {
|
||||
$isFullyRefund = true;
|
||||
// update fully refunded booking payment transaction
|
||||
$bookingPayment->status = ApprovalStatus::REFUNDED;
|
||||
$bookingPayment->save();
|
||||
|
||||
//expired booking
|
||||
// $this->updatesBookingStatus->execute($booking, ApprovalStatus::EXPIRED);
|
||||
Log::info("Credit note transaction id: {$transaction->id} is fully refunded, the refunded amount was {$transaction->amount} the payment reference is: {$transaction->payment_reference}");
|
||||
// Log::info("Credit note transaction id: {$transaction->id}, Rejected Booking Transaction Payment id: {$bookingPayment->id}, the payment amount was {$bookingPayment->amount}");
|
||||
// Log::info("Credit note transaction id: {$transaction->id}, Expired Booking id: {$booking->id}");
|
||||
} else {
|
||||
Log::info("Credit note transaction id: {$transaction->id} is not fully refunded, the refunded amount was {$transaction->amount}, the payment amount was {$bookingPayment->amount}, the payment reference is: {$transaction->payment_reference}");
|
||||
}
|
||||
|
||||
$refund = $bookingPayment->transactions()->refunds()->where('amount', $transaction->amount)->where('status', ApprovalStatus::APPROVED)->first();
|
||||
|
||||
$bookingInWhiteForm = $bookingPayment->transactions()->bills()->first();
|
||||
|
||||
if ($refund) {
|
||||
Log::info("Credit note transaction id: {$transaction->id}, already created same amount of refund transaction for same booking payment transaction");
|
||||
}
|
||||
|
||||
if (!$refund) {
|
||||
$billNumber = (App()->make(GeneratesTransactionBillNumber::class))->execute('RFD-');
|
||||
|
||||
$object = new TransactionObject($billNumber, TransactionType::REFUND, 1, $booking->company->id,
|
||||
1, PaymentMethodType::CASH,
|
||||
$transaction->amount, $isFullyRefund ? $bookingPayment->original_amount : $transaction->amount * $bookingPayment->currency_rate, 1,
|
||||
$bookingPayment->original_currency_id, $bookingPayment->currency_rate,
|
||||
0, 0, null, ApprovalStatus::APPROVED, [], $bookingPayment->bill_no);
|
||||
|
||||
$transaction = (App()->make(CreatesTransaction::class))->execute($bookingPayment, $object);
|
||||
}
|
||||
|
||||
if ($bookingInWhiteForm) {
|
||||
$original_amount = $isFullyRefund ? $bookingPayment->original_amount : bcmul($transaction->amount, $bookingPayment->currency_rate, 7);
|
||||
$supplier_refund_amount = bcdiv($original_amount, $bookingInWhiteForm->currency_rate, 7);
|
||||
|
||||
Log::info("Credit note transaction id: {$transaction->id}, booking is in white form, white form currency rate is {$bookingInWhiteForm->currency_rate}");
|
||||
|
||||
// if ($isFullyRefund && $bookingInWhiteForm->currency_rate == 1) {
|
||||
// dd ($bookingInWhiteForm->owner_id);
|
||||
// }
|
||||
|
||||
$refund = $bookingPayment->transactions()->supplierRefunds()->where('original_amount', $original_amount)->first();
|
||||
|
||||
if (!$refund) {
|
||||
$billNumber = (App()->make(GeneratesTransactionBillNumber::class))->execute('SRFD-');
|
||||
|
||||
$object = new TransactionObject($billNumber, TransactionType::SUPPLIER_REFUND, 1, $bookingInWhiteForm->issuer,
|
||||
1, PaymentMethodType::CASH,
|
||||
$supplier_refund_amount, $original_amount, 1,
|
||||
$bookingPayment->original_currency_id, $bookingInWhiteForm->currency_rate,
|
||||
0, 0, null, ApprovalStatus::APPROVED, [], $bookingPayment->bill_no);
|
||||
|
||||
$transaction = (App()->make(CreatesTransaction::class))->execute($bookingPayment, $object);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log::info("Credit note transaction id: {$transaction->id} is not fully refunded, the refunded amount was {$transaction->amount}, the payment amount was {$bookingPayment->amount}, the payment reference is: {$transaction->payment_reference}");
|
||||
}
|
||||
// $bookingPayment = $booking->transactions()->payments()->where('status', ApprovalStatus::REFUNDED)->orderBy('id', 'DESC')->first();
|
||||
|
||||
$refund = $bookingPayment->transactions()->refunds()->where('amount', $transaction->amount)->where('status', ApprovalStatus::APPROVED)->first();
|
||||
|
||||
$bookingInWhiteForm = $bookingPayment->transactions()->bills()->first();
|
||||
|
||||
if ($refund) {
|
||||
Log::info("Credit note transaction id: {$transaction->id}, already created same amount of refund transaction for same booking payment transaction");
|
||||
}
|
||||
|
||||
if ($bookingInWhiteForm) {
|
||||
Log::info("Credit note transaction id: {$transaction->id}, booking is in white form");
|
||||
}
|
||||
|
||||
if (!$refund && !$bookingInWhiteForm) {
|
||||
$billNumber = (App()->make(GeneratesTransactionBillNumber::class))->execute('RFD-');
|
||||
|
||||
$object = new TransactionObject($billNumber, TransactionType::REFUND, 1, $booking->company->id,
|
||||
1, PaymentMethodType::CASH,
|
||||
$transaction->amount, $transaction->amount * $bookingPayment->currency_rate, 1,
|
||||
$bookingPayment->original_currency_id, $bookingPayment->currency_rate,
|
||||
0, 0, null, ApprovalStatus::APPROVED, [], $bookingPayment->bill_no);
|
||||
|
||||
$transaction =(App()->make(CreatesTransaction::class))->execute($bookingPayment, $object);
|
||||
// if ($bookingPayment) {
|
||||
// Log::info("Credit note transaction id: {$transaction->id}, booking payment refunded");
|
||||
// } else {
|
||||
Log::info("Credit note transaction id: {$transaction->id}, booking payment not found, the payment reference is: {$transaction->payment_reference}");
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
Log::info("Credit note transaction id: {$transaction->id}, booking marking not found, the payment reference is: {$transaction->payment_reference}");
|
||||
@@ -129,7 +164,6 @@ class ExpiredRefundedBookingV2CommandJob implements ShouldQueue
|
||||
}
|
||||
|
||||
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Expiring refunded booking. ElapsedTime: ' . $elapsedTime . '.');
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Booking;
|
||||
|
||||
class FixExpiredBookingV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Change the EXPIRED payment transaction of EXPIRED booking to REFUNDED if the payment transaction is fully refunded.');
|
||||
$start = new Carbon();
|
||||
|
||||
$bookings = Booking::where('status', ApprovalStatus::EXPIRED)->whereHas('transactions', function ($q) {
|
||||
$q->where('type', TransactionType::PAYMENT)->where('status', ApprovalStatus::EXPIRED)->whereHas('transactions', function ($q2) {
|
||||
$q2->where('type', TransactionType::REFUND)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
});
|
||||
})->get();
|
||||
|
||||
foreach ($bookings as $booking) {
|
||||
$payment_transactions = $booking->transactions()->where('type', TransactionType::PAYMENT)->whereHas('transactions', function ($q2) {
|
||||
$q2->where('type', TransactionType::REFUND)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
})->get();
|
||||
|
||||
foreach ($payment_transactions as $payment) {
|
||||
$payment_original_amount = $payment->original_amount;
|
||||
$refund_original_amount = $payment->transactions()->where('type', TransactionType::REFUND)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('original_amount');
|
||||
|
||||
if ($payment_original_amount - $refund_original_amount < 0.01) {
|
||||
Log::info("Updated booking id: $booking->id, payment transaction id: $payment->id, from EXPIRED to REFUNDED");
|
||||
|
||||
$payment->status = ApprovalStatus::REFUNDED;
|
||||
$payment->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Change the EXPIRED payment transaction of EXPIRED booking to REFUNDED if the payment transaction is fully refunded. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Models\User;
|
||||
use App\Classes\ValueObjects\Constants\Vouchers;
|
||||
use App\Classes\Jobs\SendWelcomeVoucherEmail;
|
||||
use App\Classes\Modules\Vouchers\Services\FetchesVoucher;
|
||||
use App\Classes\Jobs\SendUserVerificationEmail;
|
||||
use App\Classes\Modules\Accounts\Services\GeneratesEmailVerificationAttempt;
|
||||
use App\Classes\Jobs\SendResetPasswordEmail;
|
||||
use App\Classes\Modules\Accounts\Services\GeneratesPasswordReset;
|
||||
|
||||
|
||||
class OneTimeTestVoucherifyEmailV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - One time test sending voucherify email to see out of alignment issue.');
|
||||
$start = new Carbon();
|
||||
|
||||
try{ //In case voucher got deleted unintentionally
|
||||
$user = User::where('id', 3974)->first(); //5436, 3974
|
||||
|
||||
Log::info(json_encode($user));
|
||||
$voucher = (App()->make(FetchesVoucher::class))->execute(['code' => Vouchers::WELCOME_50_PERCENT_OFF]);
|
||||
Log::info(json_encode($voucher));
|
||||
if($voucher) SendWelcomeVoucherEmail::dispatch($user, $voucher, 1);
|
||||
|
||||
// $attempt = (App()->make(GeneratesEmailVerificationAttempt::class))->execute($user);
|
||||
// $this->sendUserVerificationEmail::dispatch($user, $attempt);
|
||||
|
||||
// $attempt = (App()->make(GeneratesPasswordReset::class))->execute($user);
|
||||
// $this->sendResetPasswordEmail::dispatch($user, $attempt);
|
||||
}
|
||||
catch(\Exception $e){}
|
||||
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - One time test sending voucherify email to see out of alignment issue. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\UpdateGroupLogic;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\BillGroup;
|
||||
use App\Models\Group;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Route;
|
||||
use Illuminate\Support\Facades\Route as FacadesRoute;
|
||||
|
||||
class UpdateBillGroupAndMoreV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Update bill group and group to include transfer fee calculation.');
|
||||
$start = new Carbon();
|
||||
|
||||
// update group to include transfer fee
|
||||
$groups = Group::where('created_at', '>=', '2024-06-01')->get();
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$group_transfer_fee = 0;
|
||||
|
||||
$morph_transaction = $group->morphTransactions()->where('type', TransactionType::TRANSFER_FEE)->first();
|
||||
|
||||
if ($morph_transaction) {
|
||||
$group_transfer_fee = $morph_transaction->original_amount;
|
||||
}
|
||||
|
||||
|
||||
$originalTransferFees = (float)Transaction::where('type', TransactionType::TRANSFER_FEE)->whereIn('owner_id', $group->transactions->pluck('id'))->sum('service_charge');
|
||||
$correctOriginalAmount = $group->transactions()->sum('original_amount');
|
||||
$correctOriginalAmount = $correctOriginalAmount + $originalTransferFees + $group_transfer_fee;
|
||||
$correctAmount = $group->transactions()->sum('amount');
|
||||
$transferFees = $originalTransferFees / $group->currency_rate;
|
||||
$correctAmount = $correctAmount + $transferFees + ($group_transfer_fee / $group->currency_rate) + $group->service_charge;
|
||||
|
||||
if ($group->original_amount != $correctOriginalAmount || $group->amount != $correctAmount) {
|
||||
$group->original_amount = $correctOriginalAmount;
|
||||
$group->amount = $correctAmount;
|
||||
$group->save();
|
||||
|
||||
Log::info("updated group id: {$group->id}, added transfer fee CNY {$correctOriginalAmount}");
|
||||
}
|
||||
}
|
||||
|
||||
// update group calculation to include individual group transfer fee
|
||||
// $groups = Group::whereHas('morphTransactions', function ($q) {
|
||||
// $q->where('type', TransactionType::TRANSFER_FEE);
|
||||
// })->get();
|
||||
|
||||
// foreach ($groups as $group) {
|
||||
// $route = FacadesRoute::getRoutes()->getByName('api.transaction.group.update');
|
||||
// $request = Request::create(route('api.transaction.group.update', $group->id));
|
||||
// $uri = $route->uri;
|
||||
// $request->setRouteResolver(function () use ($request, $uri) {
|
||||
// // Associate Route to request so we can access route parameters.
|
||||
// return (new Route('PUT', $uri, []))->bind($request);
|
||||
// });
|
||||
|
||||
// $request['rate'] = $group->currency_rate;
|
||||
// $request['supplier_id'] = $group->issuer;
|
||||
// $this->updateGroupLogic->execute($request);
|
||||
|
||||
// $group_transfer_fee = $group->morphTransactions()->where('type', TransactionType::TRANSFER_FEE)->first();
|
||||
// Log::info("updated group id: {$group->id}, added transfer fee to individual white form CNY {$group_transfer_fee->original_amount}");
|
||||
// }
|
||||
|
||||
// update bill group calculation to include individual group transfer fee
|
||||
$billGroups = BillGroup::all();
|
||||
|
||||
foreach ($billGroups as $billGroup) {
|
||||
// ignore those has bill group refund
|
||||
if ($billGroup->billRefunds()->count() > 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$totalOriginal = round($billGroup->groups()->sum('original_amount'), 2);
|
||||
$total = round($billGroup->groups()->sum('amount') + $billGroup->service_charge, 2);
|
||||
|
||||
// update bill group payment transaction amount if there is only 1 payment transaction
|
||||
$payment_transactions = $billGroup->transactions()->whereIn('status', [ApprovalStatus::PENDING_SUBMISSION, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
|
||||
|
||||
if ($payment_transactions->count() === 1) {
|
||||
$payment_transaction = $payment_transactions->first();
|
||||
|
||||
if ($payment_transaction->amount - ($billGroup->amount + $billGroup->service_charge) < 0.01) {
|
||||
$payment_transaction->original_amount = $total;
|
||||
$payment_transaction->amount = $total;
|
||||
$payment_transaction->save();
|
||||
Log::info("updated bill group payment transaction id: {$payment_transaction->id}, update original amount to CNY {$totalOriginal}");
|
||||
}
|
||||
}
|
||||
|
||||
// update bill group amount and original amount
|
||||
$billGroup->original_amount = $totalOriginal;
|
||||
$billGroup->amount = $total;
|
||||
$billGroup->save();
|
||||
|
||||
Log::info("updated bill group id: {$billGroup->id}, added transfer fee, final original amount is CNY {$totalOriginal}");
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Update bill group and group to include transfer fee calculation. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class UpdateWrongFullyRefundPaymentReferenceV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Update those payment reference that actually should be showing partially refund instead of fully refund.');
|
||||
$start = new Carbon();
|
||||
|
||||
$transactions = Transaction::where('payment_reference', 'LIKE', '%Fully Refund%')->whereDate('created_at', '>=', Carbon::createFromDate(2024, 4, 2))->get();
|
||||
|
||||
foreach ($transactions as $transaction) {
|
||||
$booking_marking = trim(explode('.', $transaction->payment_reference)[1]);
|
||||
$booking = Booking::where('marking', $booking_marking)->first();
|
||||
|
||||
if ($booking) {
|
||||
$payments = $booking->transactions()->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED, ApprovalStatus::REFUNDED])->get();
|
||||
|
||||
if ($payments->count() === 0) {
|
||||
Log::info("Booking ID: {$booking->id}, payment not found");
|
||||
} else if ($payments->count() > 1) {
|
||||
Log::info("Booking ID: {$booking->id}, more than 1 payment found");
|
||||
} else {
|
||||
$payment = $payments->first();
|
||||
|
||||
if (!($payment->amount - $transaction->amount < 0.01)) {
|
||||
$transaction->payment_reference = str_replace('Fully', 'Partially', $transaction->payment_reference);
|
||||
$transaction->save();
|
||||
Log::info("Updated Payment Reference of Transaction ID: {$transaction->id}, corrected from Fully Refund to Partially Refund");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Update those payment reference that actually should be showing partially refund instead of fully refund. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Models\Document;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Group;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class UpdateWrongGroupCurrencyRateV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Update those group with currency rate more than 100.');
|
||||
$start = new Carbon();
|
||||
|
||||
$groups = Group::where('currency_rate', '>', 100)->get();
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$transactions = $group->transactions()->get();
|
||||
|
||||
$rate = DB::table('transaction_logs')->where('transaction_id', $transactions->first()->id)->latest('updated_at')->first()->currency_rate;
|
||||
|
||||
$supplier = $group->issuerCompany;
|
||||
|
||||
foreach ($transactions as $transaction) {
|
||||
$transaction->currency_rate = $rate;
|
||||
$transaction->amount = $transaction->original_amount / $rate;
|
||||
$transaction->save();
|
||||
|
||||
$supplierRefundTransactions = $transaction->owner->transactions()->supplierRefunds()->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED])->get();
|
||||
|
||||
foreach ($supplierRefundTransactions as $supplierRefundTransaction) {
|
||||
$claimBefore = $supplierRefundTransaction->transactions()->where('type', TransactionType::BILL_REFUND)->where('status', ApprovalStatus::APPROVED)->exists();
|
||||
|
||||
if (!$claimBefore) {
|
||||
$supplierRefundTransaction->currency_rate = $rate;
|
||||
$supplierRefundTransaction->amount = $supplierRefundTransaction->original_amount / $rate;
|
||||
$supplierRefundTransaction->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$group_transfer_fee = $group->morphTransactions()->where('type', TransactionType::TRANSFER_FEE)->first();
|
||||
|
||||
$group_transfer_fee_original_amount = 0;
|
||||
|
||||
if ($group_transfer_fee) {
|
||||
$group_transfer_fee_original_amount = $group_transfer_fee->original_amount;
|
||||
}
|
||||
|
||||
$transferFeeTransactions = $group->transactions()->with([
|
||||
'transactions' => function ($transaction) {
|
||||
return $transaction->where('type', TransactionType::TRANSFER_FEE);
|
||||
}
|
||||
])->get()->pluck('transactions')->flatten();
|
||||
|
||||
$group->original_amount = $group->transactions()->sum('original_amount') + ((float)$transferFeeTransactions->sum('service_charge') + (float)$group_transfer_fee_original_amount);
|
||||
$group->amount = $group->transactions()->sum('amount') + (((float)$transferFeeTransactions->sum('service_charge') + (float)$group_transfer_fee_original_amount) / $rate) + $group->transactions()->sum('service_charge');
|
||||
$group->currency_rate = $rate;
|
||||
$group->tax = $group->transactions()->sum('tax');
|
||||
$group->service_charge = $group->transactions()->sum('service_charge');
|
||||
|
||||
$group->save();
|
||||
|
||||
$group->documents()->delete();
|
||||
|
||||
$pdf = LaravelMpdf::loadView('pages.pdfs.currency_vendor_order', ['transactions' => $group->transactions, 'transferFeeTransactions' => $transferFeeTransactions, 'supplier' => $supplier, 'groupTransferFeeOriginalAmount' => $group_transfer_fee_original_amount]);
|
||||
|
||||
$object = new DocumentObject(
|
||||
DocumentType::CURRENCY_VENDOR_ORDER,
|
||||
[chunk_split('data:application/pdf;base64,' . base64_encode($pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'currency_vendor_order'
|
||||
);
|
||||
|
||||
/** @var Document $document */
|
||||
$document = (App()->make(CreatesDocument::class))->execute($group, $object);
|
||||
(App()->make(CreatesFiles::class))->execute($document, $object);
|
||||
|
||||
Log::info("Group ID: {$group->id} updated to currency rate {$rate}");
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
Log::info(Carbon::now() . ': End job - Update those group with currency rate more than 100. ElapsedTime: ' . $elapsedTime . '.');
|
||||
}
|
||||
}
|
||||
@@ -73,12 +73,14 @@ class FetchesBookingQuotation
|
||||
$employeeWhoOwnsTheVoucher = null;
|
||||
|
||||
$employees = $company->first()->employees;
|
||||
foreach($employees as $singleEmployee){
|
||||
$userRewards = $singleEmployee->rewards;
|
||||
foreach($userRewards as $userReward){
|
||||
if ($userReward->voucher && $userReward->voucher->code === $voucherCode) {
|
||||
Log::info('1. Company with multiple employees: ' . json_encode($singleEmployee) . ", voucher: " . $voucherCode);
|
||||
$employeeWhoOwnsTheVoucher = $singleEmployee;
|
||||
if(count($employees) > 1){
|
||||
foreach($employees as $singleEmployee){
|
||||
$userRewards = $singleEmployee->rewards;
|
||||
foreach($userRewards as $userReward){
|
||||
if ($userReward->voucher && $userReward->voucher->code === $voucherCode) {
|
||||
Log::info('1. Company with multiple employees: ' . json_encode($singleEmployee) . ", voucher: " . $voucherCode);
|
||||
$employeeWhoOwnsTheVoucher = $singleEmployee;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ class CheckMilestonesForRewardProcessor
|
||||
$voucherEndDate = $result->expiration_date;
|
||||
|
||||
//create voucher
|
||||
$voucherObject = new VoucherObject($result->code, isset($voucherName) ? $voucherName : "", $voucherType, $voucherValue, null, $voucherStartDate, $voucherEndDate);
|
||||
$voucherObject = new VoucherObject($result->code, isset($voucherName) ? $voucherName : "", null, $voucherType, $voucherValue, null, $voucherStartDate, $voucherEndDate);
|
||||
$voucher = $this->createsVoucher->execute($voucherObject);
|
||||
if(!$voucher) $voucher = $this->fetchesVoucher->execute(['code' => $voucherObject->getCode()]);
|
||||
$voucherId = $voucher->id;
|
||||
|
||||
@@ -113,8 +113,8 @@ class CreateSupplierBillGroupLogic extends AbstractControllerLogic
|
||||
$original_amount = 0;
|
||||
|
||||
foreach ($payments as $payment) {
|
||||
$amount += round($payment['amount'], 2);
|
||||
$original_amount += round($payment['original_amount'], 2);
|
||||
$amount += $payment['amount'];
|
||||
$original_amount += $payment['original_amount'];
|
||||
}
|
||||
|
||||
$service_charges = 0;
|
||||
@@ -122,7 +122,7 @@ class CreateSupplierBillGroupLogic extends AbstractControllerLogic
|
||||
// if ($supplier->id === 4548 || $supplier->id === 2729) {
|
||||
// $amount = round(floatval(str_replace(',', '', $request->input('payment_total'))), 2);
|
||||
// } else {
|
||||
$service_charges = round(floatval(str_replace(',', '', $request->input('service_charges'))), 2);
|
||||
$service_charges = floatval(str_replace(',', '', $request->input('service_charges')));
|
||||
// }
|
||||
|
||||
$rate = $original_amount / $amount;
|
||||
@@ -140,13 +140,13 @@ class CreateSupplierBillGroupLogic extends AbstractControllerLogic
|
||||
$billGroup->issuer = $supplier->id;
|
||||
$billGroup->receiver = 1;
|
||||
$billGroup->reference = $this->generatesTransactionBillNumber->execute('BSPO-');
|
||||
$billGroup->amount = $amount + $service_charges;
|
||||
$billGroup->original_amount = $original_amount;
|
||||
$billGroup->amount = round(($amount + $service_charges), 2);
|
||||
$billGroup->original_amount = round($original_amount, 2);
|
||||
$billGroup->currency_id = 1;
|
||||
$billGroup->original_currency_id = $payments[0]['original_currency']['id'];
|
||||
$billGroup->currency_rate = $rate;
|
||||
$billGroup->tax = 0;
|
||||
$billGroup->service_charge = $service_charges;
|
||||
$billGroup->service_charge = round($service_charges, 2);
|
||||
$billGroup->status = ApprovalStatus::PENDING_SUBMISSION;
|
||||
$billGroup->save();
|
||||
|
||||
@@ -160,8 +160,8 @@ class CreateSupplierBillGroupLogic extends AbstractControllerLogic
|
||||
foreach ($supplierRefunds as $supplierRefund) {
|
||||
$refund = Transaction::find($supplierRefund['id']);
|
||||
$deductedRefunds = $refund->transactions()->where('type', TransactionType::BILL_REFUND)->where('status', ApprovalStatus::APPROVED)->get();
|
||||
$refundDeductableAmount = round(($refund->amount - $deductedRefunds->sum('amount')), 2);
|
||||
$refundDeductableOriginalAmount = round(($refund->original_amount - $deductedRefunds->sum('original_amount')), 2);
|
||||
$refundDeductableAmount = $refund->amount - $deductedRefunds->sum('amount');
|
||||
$refundDeductableOriginalAmount = $refund->original_amount - $deductedRefunds->sum('original_amount');
|
||||
|
||||
$amount -= $refundDeductableAmount;
|
||||
$original_amount -= $refundDeductableOriginalAmount;
|
||||
@@ -204,7 +204,7 @@ class CreateSupplierBillGroupLogic extends AbstractControllerLogic
|
||||
$billGroup->billRefunds()->sync($transaction->id, false);
|
||||
}
|
||||
|
||||
$billGroup->amount = $amount;
|
||||
$billGroup->amount = round($amount, 2);
|
||||
$billGroup->save();
|
||||
|
||||
return $this->response([]);
|
||||
|
||||
+50
-26
@@ -24,6 +24,7 @@ use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Document;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
|
||||
class CreateProformaInvoiceTransactionProcessor
|
||||
@@ -102,37 +103,55 @@ class CreateProformaInvoiceTransactionProcessor
|
||||
*/
|
||||
public function execute(Booking $booking)
|
||||
{
|
||||
|
||||
$po_order_transaction = $booking->transactions()
|
||||
->where('type', TransactionType::PURCHASE_ORDER)
|
||||
->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED])
|
||||
->first();
|
||||
|
||||
$outstanding = $this->calculatesBookingOutstanding->execute($booking);
|
||||
$transaction = $booking->transactions()
|
||||
->where('type', TransactionType::PAYMENT)
|
||||
->first();
|
||||
|
||||
$conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', $outstanding)), $booking->convertible_currency_id, $booking->service_id, $booking->fix_currency_id === 1 ? 0:1, PaymentMethodType::CASH);
|
||||
if (!$transaction) {
|
||||
$outstanding = $this->calculatesBookingOutstanding->execute($booking);
|
||||
|
||||
$configurations = $this->fetchesBookingQuotation->execute($booking->company, $conversionObject);
|
||||
$conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', $outstanding)), $booking->convertible_currency_id, $booking->service_id, $booking->fix_currency_id === 1 ? 0 : 1, PaymentMethodType::CASH);
|
||||
|
||||
$configurations = $this->fetchesBookingQuotation->execute($booking->company, $conversionObject);
|
||||
|
||||
$paymentAttemptLimit = $this->fetchesCompanyPaymentAttemptLimit->execute($booking->company);
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
|
||||
$paymentAttemptLimit = $this->fetchesCompanyPaymentAttemptLimit->execute($booking->company);
|
||||
$object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::PAYMENT,
|
||||
1,
|
||||
$booking->company->id,
|
||||
$configurations->getConfigurations()->getBankId(),
|
||||
$configurations->getConversionObject()->getPaymentMethod(),
|
||||
$configurations->getTotal(),
|
||||
$configurations->getForeignTotal(),
|
||||
1,
|
||||
$configurations->getConversionObject()->getCurrencyId(),
|
||||
$configurations->getConfigurations()->getRate(),
|
||||
$configurations->getTax(),
|
||||
$configurations->getServiceCharge(),
|
||||
Carbon::now()->addMinutes($paymentAttemptLimit),
|
||||
ApprovalStatus::PENDING_SUBMISSION,
|
||||
[],
|
||||
isset($billPlzBill) ? $billPlzBill->id : NULL
|
||||
);
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
|
||||
|
||||
$object = new TransactionObject($billNumber, TransactionType::PAYMENT, 1, $booking->company->id,
|
||||
$configurations->getConfigurations()->getBankId(), $configurations->getConversionObject()->getPaymentMethod(),
|
||||
$configurations->getTotal(), $configurations->getForeignTotal(), 1,
|
||||
$configurations->getConversionObject()->getCurrencyId(), $configurations->getConfigurations()->getRate(),
|
||||
$configurations->getTax(), $configurations->getServiceCharge(), Carbon::now()->addMinutes($paymentAttemptLimit), ApprovalStatus::PENDING_SUBMISSION, [], isset($billPlzBill) ? $billPlzBill->id : NULL);
|
||||
|
||||
$this->createsTransaction->execute($booking, $object);
|
||||
$this->createsTransaction->execute($booking, $object);
|
||||
}
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PROFORMA-');
|
||||
|
||||
$payable_amount = $booking->transactions()->payments()->where(function($query){
|
||||
return $query->where(function($query){
|
||||
$payable_amount = $booking->transactions()->payments()->where(function ($query) {
|
||||
return $query->where(function ($query) {
|
||||
return $query->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString());
|
||||
})->orWhere(function($query){
|
||||
})->orWhere(function ($query) {
|
||||
return $query->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
});
|
||||
})->sum('amount');
|
||||
@@ -142,14 +161,16 @@ class CreateProformaInvoiceTransactionProcessor
|
||||
->where('type', TransactionType::PAYMENT)
|
||||
->first();
|
||||
|
||||
$booking_currency_average_rate = $booking_amount / $booking->transactions()->payments()->where(function($query){
|
||||
return $query->where(function($query){
|
||||
$paymentAmount = $booking->transactions()->payments()->where(function ($query) {
|
||||
return $query->where(function ($query) {
|
||||
return $query->where('status', ApprovalStatus::PENDING_SUBMISSION)->whereDate('expires_on', '>=', Carbon::now())->where('expires_on', '>', Carbon::now()->toTimeString());
|
||||
})->orWhere(function($query){
|
||||
})->orWhere(function ($query) {
|
||||
return $query->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
});
|
||||
})->selectRaw('sum(amount - service_charge - tax) as sub_total')->get()->sum('sub_total');
|
||||
|
||||
$booking_currency_average_rate = $booking_amount / $paymentAmount;
|
||||
|
||||
$total_service_charge = $booking->transactions()
|
||||
->where('type', TransactionType::PAYMENT)
|
||||
->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::SUSPENDED])
|
||||
@@ -160,6 +181,11 @@ class CreateProformaInvoiceTransactionProcessor
|
||||
->whereIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::SUSPENDED])
|
||||
->sum('tax');
|
||||
|
||||
// delete prev proforma transactions
|
||||
$booking->transactions()
|
||||
->where('type', TransactionType::PROFORMA)
|
||||
->delete();
|
||||
|
||||
$transaction_object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::PROFORMA,
|
||||
@@ -178,14 +204,14 @@ class CreateProformaInvoiceTransactionProcessor
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
|
||||
$perofrma_transaction = $this->createsTransaction->execute($po_order_transaction->booking, $transaction_object);
|
||||
$proforma_transaction = $this->createsTransaction->execute($po_order_transaction->booking, $transaction_object);
|
||||
|
||||
$supplier = $this->fetchesCompany->execute(['id' => $transaction->receiver]);
|
||||
|
||||
$purchase_order_pdf = LaravelMpdf::loadView('pages.pdfs.proforma_invoice', ['invoice_transaction' => $perofrma_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
|
||||
$purchase_order_pdf = LaravelMpdf::loadView('pages.pdfs.proforma_invoice', ['invoice_transaction' => $proforma_transaction, 'po_order_transaction' => $po_order_transaction, 'supplier' => $supplier]);
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::PROFORMA_INVOICE,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($purchase_order_pdf->output()))],
|
||||
[chunk_split('data:application/pdf;base64,' . base64_encode($purchase_order_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'proforma_invoices'
|
||||
@@ -194,7 +220,5 @@ class CreateProformaInvoiceTransactionProcessor
|
||||
/** @var Document $document */
|
||||
$document = $this->createsDocument->execute($po_order_transaction->booking, $document_object);
|
||||
$this->createsFile->execute($document, $document_object);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,12 +47,14 @@ class ValidateVoucherLogic extends AbstractControllerLogic
|
||||
$booking = Booking::find($request->input('itemId'));
|
||||
$employees = $booking->company->employees()->get();
|
||||
|
||||
foreach($employees as $singleEmployee){
|
||||
$userRewards = $singleEmployee->rewards;
|
||||
foreach($userRewards as $userReward){
|
||||
if ($userReward->voucher && $userReward->voucher->code === $request->input('voucherCode')) {
|
||||
Log::info('2. Company with multiple employees: ' . json_encode($singleEmployee) . ", voucher: " . $request->input('voucherCode'));
|
||||
$employeeWhoOwnsTheVoucher = $singleEmployee;
|
||||
if(count($employees) > 1){
|
||||
foreach($employees as $singleEmployee){
|
||||
$userRewards = $singleEmployee->rewards;
|
||||
foreach($userRewards as $userReward){
|
||||
if ($userReward->voucher && $userReward->voucher->code === $request->input('voucherCode')) {
|
||||
Log::info('2. Company with multiple employees: ' . json_encode($singleEmployee) . ", voucher: " . $request->input('voucherCode'));
|
||||
$employeeWhoOwnsTheVoucher = $singleEmployee;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ class VoucherObject implements DataTransferObject
|
||||
/** @var string|null */
|
||||
private $name;
|
||||
|
||||
/** @var string|null */
|
||||
private $description;
|
||||
|
||||
/** @var string|null */
|
||||
private $type;
|
||||
|
||||
@@ -34,16 +37,18 @@ class VoucherObject implements DataTransferObject
|
||||
* VoucherObject constructor.
|
||||
* @param string $code
|
||||
* @param string $name
|
||||
* @param string $description
|
||||
* @param string $type
|
||||
* @param float $value
|
||||
* @param int $voucherCampaignId
|
||||
* @param string $startDate
|
||||
* @param string $endDate
|
||||
*/
|
||||
public function __construct(string $code, ?string $name, ?string $type, ?float $value, ?int $voucherCampaignId, ?string $startDate = '', ?string $endDate = '')
|
||||
public function __construct(string $code, ?string $name, ?string $description, ?string $type, ?float $value, ?int $voucherCampaignId, ?string $startDate = '', ?string $endDate = '')
|
||||
{
|
||||
$this->code = $code;
|
||||
$this->name = $name;
|
||||
$this->description = $description;
|
||||
$this->type = $type;
|
||||
$this->value = $value;
|
||||
$this->voucherCampaignId = $voucherCampaignId;
|
||||
@@ -67,6 +72,14 @@ class VoucherObject implements DataTransferObject
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
||||
@@ -48,6 +48,8 @@ class CreateVoucherProcessor
|
||||
public function execute(?User $user, string $voucherCodeInput, ?int $campaignId = null) {
|
||||
//Remotely - Get Voucher Voucherify
|
||||
$voucherifyVoucherFetched = $this->fetchesVoucherifyVoucher->execute($user, $voucherCodeInput);
|
||||
$voucherName = null;
|
||||
$voucherDescription = null;
|
||||
|
||||
//Voucher stored locally need a name, by default use campaign name, else look into campaign metadata for displayname
|
||||
if(isset($voucherifyVoucherFetched->metadata) && isset($voucherifyVoucherFetched->metadata->displayname)){
|
||||
@@ -57,6 +59,10 @@ class CreateVoucherProcessor
|
||||
$voucherName = $voucherifyVoucherFetched->campaign;
|
||||
}
|
||||
|
||||
if(isset($voucherifyVoucherFetched->metadata) && isset($voucherifyVoucherFetched->metadata->display_description)){
|
||||
$voucherDescription = $voucherifyVoucherFetched->metadata->display_description;
|
||||
}
|
||||
|
||||
$voucherType = $voucherifyVoucherFetched->discount->type;
|
||||
$voucherValue = isset($voucherifyVoucherFetched->discount->amount_off) ? $voucherifyVoucherFetched->discount->amount_off : $voucherifyVoucherFetched->discount->percent_off;
|
||||
$voucherCode = $voucherifyVoucherFetched->code;
|
||||
@@ -66,7 +72,8 @@ class CreateVoucherProcessor
|
||||
//Locally - Create and Fetch Voucher
|
||||
$voucherObject = new VoucherObject(
|
||||
$voucherCode,
|
||||
isset($voucherName) ? $voucherName : "Voucher ".Carbon::now()->format('Ymd'),
|
||||
$voucherName ?? "Voucher ".Carbon::now()->format('Ymd'),
|
||||
$voucherDescription,
|
||||
$voucherType,
|
||||
$voucherValue,
|
||||
$campaignId,
|
||||
|
||||
@@ -86,12 +86,14 @@ class BookingToVoucherifyProcessor
|
||||
$employeeWhoOwnsTheVoucher = null;
|
||||
|
||||
$employees = $user->company()->first()->employees;
|
||||
foreach($employees as $singleEmployee){
|
||||
$userRewards = $singleEmployee->rewards;
|
||||
foreach($userRewards as $userReward){
|
||||
if ($userReward->voucher && $userReward->voucher->code === $voucherCode) {
|
||||
Log::info('3. Company with multiple employees: ' . json_encode($singleEmployee) . ", voucher: " . $voucherCode);
|
||||
$employeeWhoOwnsTheVoucher = $singleEmployee;
|
||||
if(count($employees) > 1){
|
||||
foreach($employees as $singleEmployee){
|
||||
$userRewards = $singleEmployee->rewards;
|
||||
foreach($userRewards as $userReward){
|
||||
if ($userReward->voucher && $userReward->voucher->code === $voucherCode) {
|
||||
Log::info('3. Company with multiple employees: ' . json_encode($singleEmployee) . ", voucher: " . $voucherCode);
|
||||
$employeeWhoOwnsTheVoucher = $singleEmployee;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,7 +153,7 @@ class BookingToVoucherifyProcessor
|
||||
$voucherCampaign = VoucherCampaign::where('campaign_id', $voucherifyCampaignId)->first();
|
||||
}
|
||||
|
||||
$voucherObject= new VoucherObject($redeemedVoucher->code, isset($redeemedVoucher->metadata->displayname) ? $redeemedVoucher->metadata->displayname : "", $voucherType, $voucherValue, $voucherCampaign ? $voucherCampaign->id : null);
|
||||
$voucherObject= new VoucherObject($redeemedVoucher->code, isset($redeemedVoucher->metadata->displayname) ? $redeemedVoucher->metadata->displayname : "", null, $voucherType, $voucherValue, $voucherCampaign ? $voucherCampaign->id : null);
|
||||
$voucher = $this->createsVoucher->execute($voucherObject);
|
||||
if(!$voucher) $voucher = $this->fetchesVoucher->execute(['code' => $voucherObject->getCode()]);
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ class CreatesVoucher extends AbstractUpdateRecord
|
||||
$model = new Voucher();
|
||||
$model->code = $object->getCode();
|
||||
$model->name = $object->getName();
|
||||
$model->description = $object->getDescription();
|
||||
$model->type = $object->getType();
|
||||
$model->value = $object->getValue();
|
||||
$model->voucher_campaign_id = $object->getVoucherCampaignId();
|
||||
|
||||
@@ -9,10 +9,12 @@ final class Vouchers {
|
||||
public const SORRY_50 = 'SORRY50';
|
||||
public const SORRY_100 = 'SORRY100';
|
||||
public const SORRY_200 = 'SORRY200';
|
||||
public const PROM150PERCENT = 'PROM150%';
|
||||
|
||||
const OPTIONS_SORRY = [
|
||||
['text' => 'SORRY 50', 'id' => Vouchers::SORRY_50],
|
||||
['text' => 'SORRY 100', 'id' => Vouchers::SORRY_100],
|
||||
['text' => 'SORRY 200', 'id' => Vouchers::SORRY_200],
|
||||
['text' => 'PROM150%', 'id' => Vouchers::PROM150PERCENT],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\V2;
|
||||
|
||||
|
||||
use App\Classes\Jobs\Commands\V2\DeleteDuplicate1688BankAccountV2CommandJob;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class DeleteDuplicate1688BankAccountV2Command extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'banks-deleteDuplicate1688Account-command';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Delete duplicate 1688 account in banks table';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
DeleteDuplicate1688BankAccountV2CommandJob::dispatch();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\V2;
|
||||
|
||||
|
||||
use App\Classes\Jobs\Commands\V2\FixExpiredBookingV2CommandJob;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class FixExpiredBookingV2Command extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'fix-expired-payment-transaction-command';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Change the EXPIRED payment transaction of EXPIRED booking to REFUNDED if the payment transaction is fully refunded';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
FixExpiredBookingV2CommandJob::dispatch();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\V2;
|
||||
|
||||
|
||||
use App\Classes\Jobs\Commands\V2\OneTimeTestVoucherifyEmailV2CommandJob;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class OneTimeTestVoucherifyEmailV2Command extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
||||
protected $signature = 'one-time-test-voucherify-email-command';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'One time test sending voucherify email to see out of alignment issue';
|
||||
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
OneTimeTestVoucherifyEmailV2CommandJob::dispatch();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\V2;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Classes\Jobs\Commands\V2\UpdateBillGroupAndMoreV2CommandJob;
|
||||
|
||||
class UpdateBillGroupAndMoreV2Command extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'update-bill-group-and-more-command';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update bill group and group to include transfer fee calculation';
|
||||
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
UpdateBillGroupAndMoreV2CommandJob::dispatch();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\V2;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Classes\Jobs\Commands\V2\UpdateWrongFullyRefundPaymentReferenceV2CommandJob;
|
||||
|
||||
class UpdateWrongFullyRefundPaymentReferenceV2Command extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'payment-reference:update-wrong-fully-refund-command';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update those payment reference that actually should be showing partially refund instead of fully refund';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
UpdateWrongFullyRefundPaymentReferenceV2CommandJob::dispatch();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\V2;
|
||||
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Classes\Jobs\Commands\V2\UpdateWrongGroupCurrencyRateV2CommandJob;
|
||||
|
||||
class UpdateWrongGroupCurrencyRateV2Command extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'group-update-wrong-currency-rate-command';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update those group with currency rate more than 100';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
UpdateWrongGroupCurrencyRateV2CommandJob::dispatch();
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ class VoucherResource extends JsonResource
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
'code' => $this->code,
|
||||
'type' => $this->type,
|
||||
'value' => (float) $this->value,
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddDescriptionToVouchersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('vouchers', function (Blueprint $table) {
|
||||
$table->text('description')->after('name')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('vouchers', function (Blueprint $table) {
|
||||
$table->dropColumn('description');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,9 @@
|
||||
<div class="col text-right no-padding" v-if="item.voucher.type == 'AMOUNT'">
|
||||
RM{{ item.voucher.value/100 }} Discount
|
||||
</div>
|
||||
<!-- <div class="col text-right no-padding" v-if="item.voucher.type == 'PERCENT'">
|
||||
{{ item.voucher.value }}% Discount
|
||||
</div> -->
|
||||
<div class="col text-right no-padding" v-if="item.voucher.type == 'PERCENT'">
|
||||
<span v-if="item.voucher.value === 1">50% Discount</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-8 text-left no-padding">
|
||||
@@ -47,7 +47,7 @@
|
||||
<li>CIEF vouchers are not exchangeable for cash at <a href="https://exchange.cief-malaysia.com/" target="_blank">https://exchange.cief-malaysia.com/</a>.</li>
|
||||
<li>This voucher can only be used and redeemed by a registered customer who has already logged into their account during purchase.</li>
|
||||
<li>CIEF reserves the right to amend the terms & conditions or cancel any vouchers/promotions without prior notice.</li>
|
||||
<li>Additional terms & conditions are stated on the respective promotion banners (e.g., duration, discount amounts, validity for campaigns/promotions or certain services).</li>
|
||||
<li>Additional terms & conditions are stated on the respective promotion banners (e.g. duration, discount amounts, validity for campaigns/promotions or certain services).</li>
|
||||
</ol>
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal">OK</button>
|
||||
</div>
|
||||
|
||||
@@ -246,9 +246,9 @@
|
||||
</div>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<modal-component id="choose-voucher-modal" class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="voucherList">
|
||||
<!-- <modal-component id="choose-voucher-modal" class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="voucherList">
|
||||
<list-vouchers-component :employee="data.company.employee" @selected-voucher="handleSelectedVoucher"></list-vouchers-component>
|
||||
</modal-component>
|
||||
</modal-component> -->
|
||||
</div>
|
||||
<span class="text-primary bold text-underline m-l-5 cursor text-small fs-12" style="margin-bottom: -10px; margin-top: -5px;" @click="showApplyVoucher=!showApplyVoucher" v-show="!showApplyVoucher">Apply a voucher</span>
|
||||
<div class="row m-l-0 m-r-0" v-show="showApplyVoucher" style="height: 20px">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="row" :class="{'bg-danger-lighter': $store.getters.isAdmin && companySegmentIds.includes(24)}">
|
||||
<div class="col">
|
||||
<div class="row no-margin">
|
||||
<div class="col p-b-15 p-l-0 p-r-0">
|
||||
@@ -12,9 +12,12 @@
|
||||
</div>
|
||||
<div class="row" v-if="!submitted">
|
||||
<div class="col-auto">
|
||||
<div class="bg-danger p-l-15 p-r-15 p-t-5 p-b-5">
|
||||
<div class="bg-danger p-l-15 p-r-15 p-t-5 p-b-5 m-b-10">
|
||||
<p class="m-b-0 text-white fs-12" >Any Purchase Orders that aren't submitted within 60 days will be closed for editing.</p>
|
||||
</div>
|
||||
<div class="bg-danger p-l-15 p-r-15 p-t-5 p-b-5" v-if="$store.getters.isAdmin && companySegmentIds.includes(24)">
|
||||
<p class="m-b-0 text-white fs-12" >Please note that this customer request to manual fill up the PO.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@@ -173,7 +176,7 @@
|
||||
</div>
|
||||
</template>
|
||||
</document-file-viewer-component>
|
||||
<button class="btn btn-sm btn-danger b-rad-none btn-block" v-if="data.documents.proforma_invoice && data.outstanding_amount > 0" @click="submit(route('api.booking.proforma.create', data.id), 'post', section, true, true)">Regenerate Proforma Invoice</button>
|
||||
<button class="btn btn-sm btn-danger b-rad-none btn-block" v-if="data.documents.proforma_invoice" @click="submit(route('api.booking.proforma.create', data.id), 'post', section, true, true)">Regenerate Proforma Invoice</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15" v-if="($store.getters.isAdmin && data.purchase_order.status === 1) || ($store.getters.isCustomer && data.purchase_order.status === 1 && $store.getters.getCompanyId === 199)" >
|
||||
@@ -203,6 +206,12 @@
|
||||
import { required, requiredIf } from "vuelidate/lib/validators";
|
||||
|
||||
export default {
|
||||
props:{
|
||||
companySegmentIds: {
|
||||
type: Array,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
interval:false,
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.parameters.service_charges">
|
||||
<label class="all-caps">Service Charges</label>
|
||||
<input type="text" class="form-control" v-model="parameters.service_charges" v-money="productPrice">
|
||||
<input type="text" class="form-control" v-model="parameters.service_charges" v-money="money">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -284,7 +284,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<purchase-order-form-component v-if="!oneSixEightEightServiceIds.includes(booking.service.id) || $store.getters.isAdmin || [199, 510].includes($store.getters.getCompanyId) || companySegmentIds.includes(24)" :data="booking" :section="section"></purchase-order-form-component>
|
||||
<purchase-order-form-component v-if="!oneSixEightEightServiceIds.includes(booking.service.id) || $store.getters.isAdmin || [199, 510].includes($store.getters.getCompanyId) || companySegmentIds.includes(24) || companySegmentIds.includes(36)" :data="booking" :section="section" :companySegmentIds="companySegmentIds"></purchase-order-form-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-15" v-if="booking.status === 3 && $store.getters.isSuperAdmin || ($store.getters.isCustomer && $store.getters.getCompanyId === 199)">
|
||||
|
||||
+48
-24
@@ -1,32 +1,56 @@
|
||||
<template>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 v-if="item.reward" class="card-title"> {{ item.reward.name }}</h5>
|
||||
<h5 v-else="item.voucher" class="card-title"> {{ item.voucher.name }}</h5>
|
||||
<p v-if="item.reward" class="card-text">{{ item.reward.description }}</p>
|
||||
<p v-if="item.voucher && item.voucher.is_redeemed" class="text-secondary"> {{ item.voucher.code }}</p>
|
||||
<p v-else class="text-primary"> {{ item.voucher.code }}</p>
|
||||
<p v-if="item.voucher.type == 'AMOUNT'">RM{{ item.voucher.value/100 }} Discount</p>
|
||||
<p v-if="item.voucher.type == 'PERCENT'">{{ item.voucher.value }}% Discount</p>
|
||||
<div class="row border p-3 mb-4 parentContainer">
|
||||
<div class="col-md-4">
|
||||
<p v-if="item.reward">{{ item.reward.name }}</p>
|
||||
<p v-else>{{ item.voucher.name }}</p>
|
||||
<p v-if="item.voucher.description">{{ item.voucher.description }}</p>
|
||||
<p v-if="item.reward">{{ item.reward.description }}</p>
|
||||
|
||||
<p v-if="item.voucher && item.voucher.is_redeemed">Voucher claimed</p>
|
||||
<p v-else-if="item.voucher.end_date && new Date() > new Date(item.voucher.end_date)">This voucher has expired</p>
|
||||
<p v-else-if="item.voucher && item.voucher.end_date">Valid till {{ item.voucher.end_date }}</p>
|
||||
<p v-else>Non-expired</p>
|
||||
</div>
|
||||
<div class="card-body border-top" v-if="$store.getters.isAdmin && item.voucher.email && item.voucher.email.key === item.voucher.code + '_EMAIL_COUNT'">
|
||||
<button disabled type="button" v-if="item.voucher.email && item.voucher.email.key === item.voucher.code + '_EMAIL_COUNT' && item.voucher.email.value == '1'" class="btn btn-lg btn-primary">Email Reminder #1 Sent</button>
|
||||
<!-- <button type="button" v-else @click="submit()" class="btn btn-lg btn-primary">Send Email Reminder #1</button> -->
|
||||
<div class="col-md-3">
|
||||
<p v-if="item.voucher && item.voucher.is_redeemed" class="text-secondary">{{ item.voucher.code }}</p>
|
||||
<p v-else class="text-primary">{{ item.voucher.code }}</p>
|
||||
</div>
|
||||
<div class="card-footer text-muted">
|
||||
<p v-if="item.voucher && item.voucher.is_redeemed">
|
||||
Voucher claimed
|
||||
</p>
|
||||
<p v-else-if="item.voucher.end_date && new Date() > new Date(item.voucher.end_date)">
|
||||
This voucher has expired.
|
||||
</p>
|
||||
<p v-else-if="item.voucher && item.voucher.end_date">
|
||||
Valid till {{ item.voucher.end_date }}
|
||||
</p>
|
||||
<p v-else>
|
||||
Non-expired
|
||||
<div class="col-md-4">
|
||||
<p v-if="item.voucher.type == 'AMOUNT'">RM{{ item.voucher.value / 100 }} Discount</p>
|
||||
<p v-if="item.voucher.type == 'PERCENT'">
|
||||
<span v-if="item.voucher.value === 1">50% discount on service fee only</span>
|
||||
<span v-else>{{ item.voucher.value }}% Discount</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<a class="pointer requestModal" :data-type="'showVoucherTnC-' + item.id">Terms</a>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" size="extra-large" :type="'showVoucherTnC-' + item.id">
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Terms & Conditions
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<ol>
|
||||
<li>Vouchers are only valid for purchases made on <a href="https://exchange.cief-malaysia.com/" target="_blank">https://exchange.cief-malaysia.com/</a>.</li>
|
||||
<li>Each voucher is applicable for a single transaction (unless stated otherwise).</li>
|
||||
<li>Each voucher is only applicable for new orders.</li>
|
||||
<li>Voucher codes are to be entered at the checkout or cart page (unless stated otherwise).</li>
|
||||
<li>Vouchers are not valid for promotions or discounted products (unless stated otherwise).</li>
|
||||
<li>Customers should take note of the expiry dates of the voucher(s) that they wish to redeem. Any voucher(s) which have expired will be invalid.</li>
|
||||
<li>Individual vouchers are only valid during its respective promotion period. This guideline overrides any individual voucher policy (unless stated otherwise).</li>
|
||||
<li>CIEF reserves the right to cancel any order if a customer’s purchasing behavior appears to be suspicious or potentially fraudulent.</li>
|
||||
<li>CIEF vouchers are not exchangeable for cash at <a href="https://exchange.cief-malaysia.com/" target="_blank">https://exchange.cief-malaysia.com/</a>.</li>
|
||||
<li>This voucher can only be used and redeemed by a registered customer who has already logged into their account during purchase.</li>
|
||||
<li>CIEF reserves the right to amend the terms & conditions or cancel any vouchers/promotions without prior notice.</li>
|
||||
<li>Additional terms & conditions are stated on the respective promotion banners (e.g. duration, discount amounts, validity for campaigns/promotions or certain services).</li>
|
||||
</ol>
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
<div class="col">
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
<div class="font-heading fs-16 all-caps bold m-b-15">Add Sorry Voucher</div>
|
||||
<div class="font-heading fs-16 all-caps bold m-b-15">Add Voucher Select</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
@@ -69,100 +69,15 @@
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<table class="line-table" style="overflow: wrap" autosize="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">No</th>
|
||||
<th class="stock-code" width="10%">Stock Code</th>
|
||||
<th class="description">Description</th>
|
||||
<th width="10%">Quantity</th>
|
||||
<th width="15%">Unit Price (RM)</th>
|
||||
<th width="10%">Total Amount<br>(RM)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php
|
||||
$subtotal = 0;
|
||||
@endphp
|
||||
|
||||
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
|
||||
<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">
|
||||
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
|
||||
{{ number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2) }}
|
||||
@else
|
||||
{{ number_format($transaction_detail->price, 2) }}
|
||||
@endif
|
||||
</td>
|
||||
<td width="20%" class="right top">
|
||||
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
|
||||
<?php
|
||||
$transaction = $invoice_transaction;
|
||||
$voucher_redemption = $voucher_redemption ?? null;
|
||||
?>
|
||||
|
||||
{{ number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
|
||||
<!-- Invoice Table -->
|
||||
@include('pages.pdfs.purchase_order_table')
|
||||
|
||||
@php
|
||||
$subtotal += number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
|
||||
@endphp
|
||||
@else
|
||||
{{ number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2) }}
|
||||
|
||||
@php
|
||||
$subtotal += number_format((float)number_format($transaction_detail->price, 2,'.','')*$transaction_detail->quantity,2,'.','');
|
||||
@endphp
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="subtotal">
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Subtotal</td>
|
||||
<td class="right middle">
|
||||
{{ number_format($subtotal, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="billingcharges">
|
||||
<td colspan="4"></td>
|
||||
<td class="right">Service Charges</td>
|
||||
<td class="right">
|
||||
{{ number_format($invoice_transaction->service_charge, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="billingcharges">
|
||||
<td colspan="4"></td>
|
||||
<td class="right">Adjustment</td>
|
||||
<td class="right">
|
||||
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
|
||||
{{ number_format((float)number_format( (1/$invoice_transaction->currency_rate) * $invoice_transaction->original_amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
|
||||
@else
|
||||
{{ number_format((float)number_format($invoice_transaction->amount, 2,'.','') - (float)number_format($subtotal, 2,'.',''),2) }}
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@if($invoice_transaction->tax > 0)
|
||||
<tr class="billingcharges">
|
||||
<td colspan="4"></td>
|
||||
<td class="right">Tax</td>
|
||||
<td class="right">{{ number_format($invoice_transaction->tax, 2) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
<tr>
|
||||
<td colspan="4"></td>
|
||||
<td class="right middle">Total</td>
|
||||
<td class="total right middle">
|
||||
@if($invoice_transaction->booking()->first()->fix_currency_id !== 1)
|
||||
{{ number_format( ((1/$invoice_transaction->currency_rate) * $invoice_transaction->original_amount) + $invoice_transaction->service_charge + $invoice_transaction->tax, 2) }}
|
||||
@else
|
||||
{{ number_format($invoice_transaction->amount + $invoice_transaction->service_charge + $invoice_transaction->tax, 2) }}
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<htmlpagefooter name="page-footer">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
|
||||
Reference in New Issue
Block a user