Merge remote-tracking branch 'origin/master'

This commit is contained in:
Omair Saleh
2023-08-30 11:49:49 +08:00
15 changed files with 295 additions and 25 deletions
@@ -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();
@@ -14,6 +14,9 @@ class CreateVoucherifyOrderObject implements DataTransferObject
/** @var int */
private $companyId;
/** @var int */
private $transactionId;
/** @var float */
private $amount;
@@ -27,14 +30,16 @@ class CreateVoucherifyOrderObject implements DataTransferObject
* CreateVoucherifyOrderObject constructor.
* @param User $employee
* @param int $companyId
* @param int $transactionId
* @param float $amount
* @param bool $isNoVoucher
* @param bool $isTopUpWallet
*/
public function __construct(User $employee, int $companyId, float $amount, bool $isNoVoucher, bool $isTopUpWallet)
public function __construct(User $employee, int $companyId, int $transactionId, float $amount, bool $isNoVoucher, bool $isTopUpWallet)
{
$this->employee = $employee;
$this->companyId = $companyId;
$this->transactionId = $transactionId;
$this->amount = $amount;
$this->isNoVoucher = $isNoVoucher;
$this->isTopUpWallet = $isTopUpWallet;
@@ -48,6 +53,14 @@ class CreateVoucherifyOrderObject implements DataTransferObject
return $this->companyId;
}
/**
* @return int
*/
public function getTransactionId(): int
{
return $this->transactionId;
}
/**
* @return float
*/
@@ -9,6 +9,9 @@ class RedeemVoucherifyVoucherObject implements DataTransferObject
/** @var int */
private $companyId;
/** @var int */
private $transactionId;
/** @var string */
private $promoCode;
@@ -21,13 +24,15 @@ class RedeemVoucherifyVoucherObject implements DataTransferObject
/**
* RedeemVoucherifyVoucherObject constructor.
* @param int $companyId
* @param int $transactionId
* @param string $name
* @param string $email
* @param object $employee
*/
public function __construct(int $companyId, string $promoCode, string $amount, object $employee)
public function __construct(int $companyId, int $transactionId, string $promoCode, string $amount, object $employee)
{
$this->companyId = $companyId;
$this->transactionId = $transactionId;
$this->promoCode = $promoCode;
$this->amount = $amount;
$this->employee = $employee;
@@ -42,6 +47,15 @@ class RedeemVoucherifyVoucherObject implements DataTransferObject
}
/**
* @return int
*/
public function getTransactionId(): int
{
return $this->transactionId;
}
/**
* @return string
*/
@@ -82,7 +82,7 @@ class BookingToVoucherifyProcessor
$voucherify_customer_id = "";
$voucherify_order_id = "";
if($voucherCode){
$redeemVoucherifyVoucherObject = new RedeemVoucherifyVoucherObject($companyId, $voucherCode, $amount, $user);
$redeemVoucherifyVoucherObject = new RedeemVoucherifyVoucherObject($companyId, $transaction->id, $voucherCode, $amount, $user);
$redeemVoucherResult = $this->redeemsVoucherifyVoucher->execute($redeemVoucherifyVoucherObject);
$redeemedVoucher = $redeemVoucherResult->voucher;
$redemptionId = $redeemVoucherResult->id;
@@ -100,7 +100,7 @@ class BookingToVoucherifyProcessor
$this->recordVoucherForUserInfo($user, $voucher);
}
else{
$createVoucherifyOrderObject = new CreateVoucherifyOrderObject($user, $companyId, $amount, true, $transaction->type == TransactionType::TOP_UP);
$createVoucherifyOrderObject = new CreateVoucherifyOrderObject($user, $companyId, $transaction->id, $amount, true, $transaction->type == TransactionType::TOP_UP);
$createVoucherufyOrderResult = $this->createsVoucherifyOrder->execute($createVoucherifyOrderObject);
if($createVoucherufyOrderResult && isset($createVoucherufyOrderResult->id)){
@@ -31,6 +31,7 @@ class CreatesVoucherifyOrder
{
try {
$orderObj = [
"source_id" => $obj->getTransactionId(),
"customer" => [
"source_id" => $obj->getEmployee()->id,
"name" => $obj->getEmployee()->name,
@@ -39,6 +39,7 @@ class RedeemsVoucherifyVoucher
]
],
"order" => [
"source_id" => $redeemVoucherifyVoucherObject->getTransactionId(),
"amount" => $redeemVoucherifyVoucherObject->getAmount() * 100 //converting it to cents
]
]);
+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);
}
}
@@ -1,7 +1,6 @@
<template>
<div class="row">
<div class="col">
<loading-component style="height: 100px; top: 0;" key="1" color="success" v-show="isLoading"></loading-component>
<div class="row text-left no-margin bg-white" v-if="!isLoading" v-for="item in vouchers" v-bind:key="item.id" >
<div id="select-option" name="select-option" class="col b-b b-grey p-t-10 p-b-10 pointer p-t-10 p-b-10" @click="selectVoucher(item)">
<div class="row parentContainer">
@@ -28,11 +27,7 @@
props: {
section: {
type: String,
default: 'vouchersDropDownListSection',
},
isClicked: {
type: Boolean,
default: false,
default: 'availableVouchersSection',
},
employee: {
type: Object,
@@ -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);
}
@@ -0,0 +1,93 @@
<template>
<div class="row">
<div class="col">
<loading-component style="height: 100px; top: 0;" key="1" color="success" v-show="isLoading"></loading-component>
<div class="row align-items-center justify-content-center bg-white p-t-50 p-b-50" v-show="!isLoading && vouchers.length === 0">
<div class="col-10">
<div class="row align-items-center justify-content-center hint-text">
<div class="col-4 hint-text"><img src="/images/not-found-illustration.png" class="w-100 hint-text"/></div>
</div>
<div class="row text-center">
<div class="col">
<div class="row m-t-20">
<div class="col">
<p class="all-caps no-margin fs-11" style="letter-spacing: 2px;">You have no vouchers</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row text-left no-margin bg-white" v-if="!isLoading" v-for="item in vouchers" v-bind:key="item.id" >
<div id="select-option" name="select-option" class="col b-b b-grey p-t-10 p-b-10 pointer p-t-10 p-b-10" @click="selectVoucher(item)">
<div class="row parentContainer">
<div class="col">
<p>{{ 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>
<div class="col" v-if="item.voucher.end_date">
Valid till {{ item.voucher.end_date }}
</div>
<div class="col" v-else>
No expiry date
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
props: {
section: {
type: String,
default: 'vouchersDropDownListSection',
},
employee: {
type: Object,
default: null
},
},
data(){
return {
vouchers: null,
isLoading: true,
}
},
computed: {
pendingQueue () {
return this.$store.getters.isInCompleteQueue(this.section);
},
},
watch: {
pendingQueue(inComplete){
if(inComplete){
this.fetchVouchers();
}
},
},
created(){
this.$store.dispatch('updateListQueue', {'name': this.section});
},
methods: {
fetchVouchers(){
this.isLoading = true;
if(this.employee){
this.submit(route('api.voucher.user.list') + '?filters=' + JSON.stringify( { 'has_active_reward': this.employee.id} ), 'get', this.section, false, false);
}
},
successHandler(response){
this.isLoading = false;
this.$store.dispatch('completeList', {'name': this.section, 'data': []});
this.vouchers = response.payload.data;
},
selectVoucher(item){
this.$emit('selected-voucher', item.voucher.code);
this.closeModal();
},
}
}
</script>
@@ -253,7 +253,7 @@
</validation-wrapper-component>
</div>
<!-- <modal-component id="choose-voucher-modal" class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="voucherList">
<list-vouchers :isClicked="!voucherListDropDownStatus" :employee="data.company.employee" @selected-voucher="handleSelectedVoucher"></list-vouchers>
<list-vouchers-component :employee="data.company.employee" @selected-voucher="handleSelectedVoucher"></list-vouchers-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>
@@ -262,6 +262,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="col">
<available-vouchers-component :employee="data.company.employee" @selected-voucher="handleSelectedVoucher"></available-vouchers-component>
</div>
</div> -->
<div class="row m-t-5">
<div class="col">
<div class="row p-l-15 p-r-15">
@@ -600,7 +605,6 @@
voucherValidated: false,
voucherIsChecking: false,
showApplyVoucher: false,
voucherListDropDownStatus: false,
}
},
validations () {
@@ -702,12 +706,8 @@
this.voucherValidated = false;
this.voucherCode = event.target.value;
},
toggleDropdown() {
this.voucherListDropDownStatus = !this.voucherListDropDownStatus;
},
handleSelectedVoucher(value){
this.voucherCode = value;
this.voucherListDropDownStatus = !this.voucherListDropDownStatus;
}
},
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">
@@ -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>
+3 -3
View File
@@ -79,11 +79,11 @@
@foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail)
@php
$exactUnitPrice = bcdiv($transaction_detail->price, $transaction->currency_rate, 5);
$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, $displayedItemTotal, 2);
$subtotal = bcadd($subtotal, $itemTotal, 5);
@endphp
<tr>
<td width="5%" class="center top">{{ $key + 1 }}</td>
@@ -130,7 +130,7 @@
</tr>
@endif
@php
$displayedTotal = bcadd(bcadd(bcadd($displayedSubtotal, $transaction->service_charge, 2), $transaction->tax, 2), $voucherDiscount, 2);
$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);
+21
View File
@@ -110,6 +110,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');