Merge remote-tracking branch 'origin/development' into development

This commit is contained in:
omair saleh
2021-11-28 16:29:11 +08:00
13 changed files with 344 additions and 48 deletions
@@ -20,7 +20,7 @@ class CreatesBillplzBill
*/
public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null) {
try{
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->withOptions(["verify"=>false])->post(config('billplz.base_url').'/api/v3/bills', [
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
'collection_id' => config('billplz.collection_id'),
'name' => $name,
'email' => $email,
@@ -0,0 +1,90 @@
<?php
namespace App\Classes\Modules\Bookings\ControllersLogic;
use App\Http\Resources\BookingResource;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Bookings\Services\FetchesBooking;
use App\Classes\Modules\Bookings\Standards\Rules\CanUpdateBooking;
use App\Classes\Modules\Bookings\Services\updatesBookingFixedAmount;
use App\Classes\Modules\Bookings\DataTransferObjects\BookingObject;
use App\Classes\Modules\Bookings\Services\CalculatesBookingOutstanding;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Classes\Exceptions\MalformedRequestException;
class UpdateBookingAmountLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Updated Booking',
'message' => 'You have successfully updated the Booking'
];
}
/** @var CanUpdateBooking */
private $canUpdateBooking;
/** @var UpdatesBookingFixedAmount */
private $updatesBookingFixedAmount;
/** @var FetchesBooking */
private $fetchesBooking;
/** @var CalculatesBookingOutstanding */
private $calculatesBookingOutstanding;
/**
* UpdateBookingAmountLogic constructor.
* @param CanUpdateBooking $canUpdateBooking
* @param UpdatesBookingFixedAmount $updatesBookingFixedAmount
* @param FetchesBooking $fetchesBooking
* @param CalculatesBookingOutstanding $calculatesBookingOutstanding
*/
public function __construct(
CanUpdateBooking $canUpdateBooking,
UpdatesBookingFixedAmount $updatesBookingFixedAmount,
FetchesBooking $fetchesBooking,
CalculatesBookingOutstanding $calculatesBookingOutstanding
)
{
$this->canUpdateBooking = $canUpdateBooking;
$this->updatesBookingFixedAmount = $updatesBookingFixedAmount;
$this->fetchesBooking = $fetchesBooking;
$this->calculatesBookingOutstanding = $calculatesBookingOutstanding;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
$booking = $this->fetchesBooking->execute(['id' => $request->route('id')]);
$input_amount = number_format( floatval(str_replace(',', '', $request->input('fix_amount', $booking->fix_amount))), 5, '.', '');
$minimum_amount = $booking->fix_amount - $this->calculatesBookingOutstanding->execute($booking);
if ((float)$input_amount < $minimum_amount) {
throw new MalformedRequestException('Booking Amount cannot be less than '. $minimum_amount .'.');
}
// $this->canUpdateBooking->passes($booking);
$booking = $this->updatesBookingFixedAmount->execute($booking, $input_amount);
return $this->resourceResponse(new BookingResource($booking));
}
}
@@ -17,8 +17,8 @@ class UpdatesBooking extends AbstractUpdateRecord
*/
public function execute(Booking $model, BookingObject $object)
{
$model->transferable_bank_id = $object->getTransferableBankId();
$model->reference = $object->getReference();
$model->bank_id = $object->getTransferableBankId();
$model->marking = $object->getMarking();
$model->fix_amount = $object->getFixAmount();
$model->fix_currency_id = $object->getFixCurrencyId();
$model->convertible_currency_id = $object->getConvertibleCurrencyId();
@@ -0,0 +1,23 @@
<?php
namespace App\Classes\Modules\Bookings\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Bookings\DataTransferObjects\BookingObject;
use App\Models\Booking;
class UpdatesBookingFixedAmount extends AbstractUpdateRecord
{
/**
* @param Booking $model
* @param BookingObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(Booking $model, float $fixedAmount)
{
$model->fix_amount = $fixedAmount;
return $this->handler($model);
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Controllers\Bookings;
use App\Classes\Modules\Bookings\ControllersLogic\UpdateBookingAmountLogic;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class UpdateBookingAmountController
{
/**
* @param Request $request
* @param CreateBookingRefundLogic $logic
* @return JsonResponse
*/
public function update(Request $request, UpdateBookingAmountLogic $logic): JsonResponse {
return $logic->execute($request);
}
}
@@ -70,8 +70,11 @@
<div class="font-heading all-caps fs-10">Transfer Total:</div>
</div>
<div class="col-auto text-right">
<div class="font-heading fs-12">{{this.data.fixed_currency.short_code}} {{(Math.round((this.data.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}</div>
<div class="font-heading fs-12"><i class="fa fa-edit fs-12 pointer fa-fw requestModal" data-type="editBookingAmount" v-if="$store.getters.isSuperAdmin"></i> {{this.data.fixed_currency.short_code}} {{(Math.round((this.data.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}</div>
</div>
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="editBookingAmount">
<edit-booking-amount-form-component :data="this.data" :section="section"></edit-booking-amount-form-component>
</modal-component>
</div>
<div class="row align-items-end m-b-10 text-success">
<div class="col">
@@ -0,0 +1,63 @@
<template>
<div class="row">
<div class="col">
<div class="row">
<div class="col">
<div class="row m-b-10">
<div class="col">
<h3 class="all-caps m-b-5 bold no-margin">Edit Booking Amount</h3>
</div>
</div>
<div class="row m-b-10">
<div class="col">
<validation-wrapper-component :validator="$v.fix_amount">
<label class="muted">Booking Amount ({{parameters.fixed_currency.short_code}})</label>
<input type="text" class="form-control" v-model="fix_amount" v-money="money">
</validation-wrapper-component>
</div>
</div>
<div class="row m-b-5 animate__animated animate__fadeInUpBig animate__fast" v-if="error">
<div class="col">
<small class="bold fs-10 text-danger">{{error}}</small>
</div>
</div>
<div class="row">
<div class="col p-r-5">
<div class="btn btn-sm btn-default bg-master-lightest btn-block b-rad-none" data-dismiss="modal">Cancel</div>
</div>
<div class="col p-l-5">
<div class="btn btn-sm btn-success btn-block b-rad-none" @click="submitForm()">Update</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import { required } from "vuelidate/lib/validators";
import FormHandler from '../../../general/mixins/formHandler';
export default {
data(){
return {
error: '',
fix_amount: (Math.round((this.data.amount + Number.EPSILON) * 100) / 100).toFixed(2),
}
},
validations: {
fix_amount: { required },
},
methods: {
submitForm(){
this.parameters = {fix_amount: this.fix_amount},
this.submit(this.route('api.booking.booking_amount.update', this.data.id), 'put', this.section, true, true)
},
successHandler(){
this.closeModal();
this.formHandler('');
},
},
mixins: [FormHandler]
}
</script>
@@ -29,6 +29,7 @@
</div>
<div class="col-auto text-center">
<button class="btn btn-xs btn-outline-success b-rad-none invisible"><i class="fa fa-check"></i></button>
<button class="btn btn-xs btn-outline-success b-rad-none invisible"><i class="fa fa-pencil"></i></button>
</div>
</div>
</div>
@@ -61,38 +62,14 @@
</div>
<div class="col-auto">
<button class="btn btn-xs btn-outline-success b-rad-none" @click="addProduct()"><i class="fa fa-check"></i></button>
<button class="btn btn-xs btn-outline-success b-rad-none invisible"><i class="fa fa-pencil"></i></button>
</div>
</div>
</div>
</div>
<div class="row" v-for="(product, index) in products">
<div class="col p-b-10 p-t-10 b-b b-grey">
<div class="row align-items-center">
<div class="col-auto p-r-0" style="min-width: 40px;">
<div class="font-heading all-caps fs-10">{{index + 1}}</div>
</div>
<div class="col p-r-5">
<div class="font-heading all-caps fs-10">{{product.stockCode}}</div>
</div>
<div class="col-4 p-r-5 p-l-5">
<div class="font-heading all-caps fs-10">{{product.description}}</div>
</div>
<div class="col text-center p-r-5 p-l-5">
<div class="font-heading all-caps fs-10">{{product.quantity}}</div>
</div>
<div class="col text-center p-r-5 p-l-5">
<div class="font-heading all-caps fs-10">{{product.unit_price}}</div>
</div>
<div class="col-1 text-center p-r-5 p-l-5">
<div class="font-heading all-caps fs-10">{{data.fixed_currency.short_code}}</div>
</div>
<div class="col-1 text-right p-r-5 p-l-5">
<div class="font-heading all-caps fs-10">{{(Math.round((product.total + Number.EPSILON) * 100) / 100).toFixed(2) }}</div>
</div>
<div class="col-auto">
<button class="btn btn-xs btn-outline-danger b-rad-none" v-if="!submitted" @click="removeProduct(index)"><i class="fa fa-times"></i></button>
</div>
</div>
<purchase-order-item-form-component :data="product" :index="index" :currency="data.fixed_currency.short_code" :section="section" @change="updateProduct($event, index)" v-on:remove="removeProduct(index)"></purchase-order-item-form-component>
</div>
</div>
</div>
@@ -130,7 +107,7 @@
<div class="col">
<div class="row m-b-10">
<div class="col">
<button class="btn btn-xs all-caps b-rad-none btn-primary btn-block" @click="submitForm()">{{(Math.round((poTotal + Number.EPSILON) * 1000) / 1000).toFixed(3) !== (Math.round((data.amount + Number.EPSILON) * 1000) / 1000).toFixed(3) ? 'Save Purchase Order' : 'Save & Confirm'}}</button>
<button class="btn btn-xs all-caps b-rad-none btn-primary btn-block" @click="submitForm()">{{(Math.round((poTotal + Number.EPSILON) * 1000) / 1000).toFixed(3) !== (Math.round((data.amount + Number.EPSILON) * 1000) / 1000).toFixed(3) ? 'Save Purchase Order' : 'Save & Confirm'}}</button>
</div>
</div>
<div class="row" v-if="(Math.round((poTotal + Number.EPSILON) * 1000) / 1000).toFixed(3) !== data.amount">
@@ -165,16 +142,16 @@
import formHandler from '../../../general/mixins/formHandler';
export default {
data(){
return {
submitted: false,
product: {
stockCode: '',
description: '',
quantity: 1,
unit_price: 0,
},
products: []
}
return {
submitted: false,
product: {
stockCode: '',
description: '',
quantity: 1,
unit_price: 0,
},
products: [],
}
},
created() {
this.products = this.data.purchase_order ? this.data.purchase_order.details : [];
@@ -231,7 +208,16 @@
quantity: 1,
unit_price: 0,
};
},
updateProduct(product, index){
console.log(product);
this.products[index] = {
stockCode: product.stockCode,
description: product.description,
quantity: product.quantity,
unit_price: product.unit_price,
total: product.quantity * parseFloat((product.unit_price).toString().replace(',', ''))
};
},
removeProduct(index){
this.products.splice(index, 1);
@@ -0,0 +1,92 @@
<template>
<div class="row align-items-center">
<div class="col-auto p-r-0" style="min-width: 40px;">
<div class="font-heading all-caps fs-10">{{index + 1}}</div>
</div>
<div class="col p-r-5">
<div v-if="!isEdit" class="font-heading all-caps fs-10">{{product.stockCode}}</div>
<input v-if="isEdit" type="text" class="form-control fs-10 b-rad-none" placeholder="Stock Code" v-model="product.stockCode" />
</div>
<div class="col-4 p-r-5 p-l-5">
<div v-if="!isEdit" class="font-heading all-caps fs-10">{{product.description}}</div>
<textarea v-if="isEdit" class="form-control fs-10 b-rad-none" placeholder="Description" rows="1" @keyup="onlyEnglish($event)" v-model="product.description"></textarea>
</div>
<div class="col text-center p-r-5 p-l-5">
<div v-if="!isEdit" class="font-heading all-caps fs-10">{{product.quantity}}</div>
<input v-if="isEdit" type="text" class="form-control fs-10 b-rad-none text-center" placeholder="Quantity" v-model.lazy="product.quantity" v-mask="'#########'"/>
</div>
<div class="col text-center p-r-5 p-l-5">
<div v-if="!isEdit" class="font-heading all-caps fs-10">{{product.unit_price}}</div>
<input v-if="isEdit" type="text" class="form-control fs-10 b-rad-none text-center" placeholder="Unit Price" v-model.lazy="product.unit_price" v-money="productPrice" />
</div>
<div class="col-1 text-center p-r-5 p-l-5">
<div class="font-heading all-caps fs-10">{{currency}}</div>
</div>
<div class="col-1 text-right p-r-5 p-l-5">
<div class="font-heading all-caps fs-10">{{(Math.round((productTotal + Number.EPSILON) * 100) / 100).toFixed(2) }}</div>
</div>
<div class="col-auto">
<button class="btn btn-xs btn-outline-danger b-rad-none" @click="$emit('remove')"><i class="fa fa-times"></i></button>
<button v-if="!isEdit" class="btn btn-xs btn-outline-warning b-rad-none" @click="isEdit = !isEdit"><i class="fa fa-pencil"></i></button>
<button v-if="isEdit" class="btn btn-xs btn-outline-success b-rad-none" @click="updateProduct()"><i class="fa fa-check"></i></button>
</div>
</div>
</template>
<script>
import formHandler from '../../../general/mixins/formHandler';
export default {
props: {
currency:{
type: String,
required: true
},
index:{
type: Number,
required: true
}
},
data(){
return {
isEdit: false,
product: {
stockCode: '',
description: '',
unit_price: 0,
},
products: []
}
},
created() {
this.product = this.data;
},
computed: {
productTotal(){
return this.product.quantity * parseFloat((this.product.unit_price).toString().replace(',', ''));
},
},
methods: {
updateProduct(){
this.isEdit = !this.isEdit;
this.$emit('change', {
stockCode: this.product.stockCode,
description: this.product.description,
quantity: this.product.quantity,
unit_price: this.product.unit_price,
total: this.productTotal
}, this.index);
},
onlyEnglish(event){
let value = event.target.value,
regex = /^[^~`!@#$%^&*()_+=[\]\{}|;':",.\/<>?a-zA-Z0-9-]+$/;
event.preventDefault();
if(regex.test(value)){
this.product.description = value.replace(regex, '');
}
},
},
mixins: [formHandler]
}
</script>
@@ -38,7 +38,7 @@
<i class="fa fa-circle text-success m-r-5" :class="[{'text-success': item.status === 2}, {'text-danger-darker': item.status === 5}, {'text-danger': item.status !== 2 || item.status !== 5}]"></i>{{item.status === 2 ? 'Active' : item.status === 5 ? 'Suspended' : 'Inactive'}}
</div>
</div>
<div class="col m-l-50">
<div class="col-auto m-l-50">
<div class="row align-items-center parentContainer">
<div class="col-auto padding-5 b-a b-grey b-rad-lg pointer requestModal" data-type="assignSegment">
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
@@ -64,6 +64,23 @@
</modal-component>
</div>
</div>
<div class="col m-l-50">
<div class="row">
<div class="col">
<p class="m-b-0 fs-11 muted bold"><b>Last Payment: </b>{{item.last_payment}}</p>
</div>
</div>
<div class="row">
<div class="col">
<p class="m-b-0 fs-11 muted bold"><b>Payment Amount: </b>MYR {{(Math.round((item.total_payments + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}</p>
</div>
</div>
<div class="row">
<div class="col">
<p class="m-b-0 fs-11 muted bold"><b>Created at: </b>{{item.created_at}}</p>
</div>
</div>
</div>
</div>
</div>
</div>
@@ -10,8 +10,8 @@
</div>
<div class="row m-b-10">
<div class="col">
<div class="fs-12">Full Name</div>
<validation-wrapper-component :validator="$v.parameters.name">
<label>Full Name</label>
<input type="text" class="form-control" v-model="parameters.name">
</validation-wrapper-component>
</div>
@@ -3,10 +3,10 @@
<div class="row">
<div class="col p-t-15 p-b-15">
<div class="row no-margin">
<div class="col">
<div class="col-12 col-md">
<div class="row tabsContainer">
<div class="col">
<div class="row m-l-0 m-r-0 d-none d-md-flex">
<div class="row m-l-0 m-r-0 d-flex">
<div class="col">
<div class="row justify-content-end">
<div class="col-4 b-r b-white">
@@ -75,7 +75,7 @@
</div>
</div>
<div class="row no-margin" v-if="$store.getters.isAdmin">
<div class="col bg-white padding-25">
<div class="col-12 col-md bg-white padding-25">
<div class="row tabsContainer tabContent m-l-0 m-r-0" tab-name="customer-list">
<list-component key="2" section="customerListSection" :endpoint="route('api.company.list')" :options="{'business_type': 2, with_bookings:true}">
<template slot="list" slot-scope="{data}">
@@ -105,7 +105,7 @@
<div class="col">
<div class="row tabsContainer">
<div class="col">
<div class="row m-l-0 m-r-0 d-none d-md-flex">
<div class="row m-l-0 m-r-0 d-flex">
<div class="col">
<div class="row justify-content-end">
<div class="col">
+2
View File
@@ -26,6 +26,8 @@ Route::group(['prefix' => 'booking', 'as' => 'booking.', 'namespace' => 'Booking
Route::post('{id}/purchase_order/verification', 'ApprovePurchaseOrderController@approve')->name('po.approval');
Route::put('{id}/updateAmount', 'UpdateBookingAmountController@update')->name('booking_amount.update');
Route::post('/merge', 'MergeBookingController@merge')->name('merge');
});