mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-24 06:44:20 +00:00
fixed incorrect calculation when storing booking
This commit is contained in:
@@ -249,7 +249,9 @@ class BookingController extends Controller
|
||||
$term = $request->input('term');
|
||||
$amount = $request->input("amount"); // in RMB
|
||||
$rates = Rate::orderby('updated_at','desc')->first();
|
||||
$creditLimit = SettingCredit::orderby('updated_at','desc')->first();
|
||||
$creditLimit = SettingCredit::orderby('updated_at','desc')->first();
|
||||
$taxrate = SettingTaxRate::latest()->first()->tax_rate;
|
||||
$billingChargeRate = SettingBillingCharge::latest()->first()->billing_charge_rate;
|
||||
|
||||
if (!$creditLimit){
|
||||
return response()->json("Credit limit not set, please contact admin", 405);
|
||||
@@ -291,15 +293,31 @@ class BookingController extends Controller
|
||||
}
|
||||
|
||||
// Service charge (RMB) : if amount higher than 10,000, no service charge. if amount lower than 10,000, 20.00 service charge
|
||||
if ($amount >= 10000 && ($term == 'x2_cash' || $term == 'x2_cheque' || $term == 'x2_ba')) {
|
||||
if ($amount >= 10000 && ($term == 'x2_cash' || $term == 'x2_cheque' || $term == 'x2_ba')) {
|
||||
$svcharge = 0;
|
||||
} else {
|
||||
$svcharge = 20.00;
|
||||
}
|
||||
|
||||
$bia = round(round($amount + $svcharge / $rate,2)
|
||||
+ round(round($amount + $svcharge / $rate,2) * $taxrate,2)
|
||||
+ round(($amount + $svcharge) * $billingChargeRate, 2) , 2);
|
||||
|
||||
$subtotal = round(($amount + $svcharge) / $rate,2);
|
||||
|
||||
// TODO : refactor
|
||||
if ($taxrate !=0){
|
||||
$taxAmount = round($subtotal * $taxrate - $subtotal,2);
|
||||
}
|
||||
else{
|
||||
$taxAmount = 0;
|
||||
}
|
||||
|
||||
if ($billingChargeRate !=0){
|
||||
$billingChargeAmount = round(($amount + $svcharge) * $billingChargeRate - ($amount + $svcharge), 2);
|
||||
}
|
||||
else{
|
||||
$billingChargeAmount = 0;
|
||||
}
|
||||
|
||||
$billingChargeAmount = round((($amount / $rate) * $billingChargeRate) - ($amount / $rate), 2);
|
||||
$bankin_amount = round($subtotal + $taxAmount + $billingChargeAmount , 2);
|
||||
|
||||
$booking = new Booking();
|
||||
$booking->account_name = $request->input('account_name');
|
||||
@@ -310,9 +328,9 @@ class BookingController extends Controller
|
||||
$booking->term = $term;
|
||||
$booking->rate_id = $rates->id;
|
||||
$booking->rate = $rate;
|
||||
$booking->rmb_book_amount = $request->input('amount');
|
||||
$booking->rmb_book_amount = $request->input('amount'); // BIG TODO : amount change variable name to rmb_book_amount
|
||||
$booking->status = 2;
|
||||
$booking->bia = $bia;
|
||||
$booking->bia = $bankin_amount; // BID TODO : change bia viariable name
|
||||
// $booking->user_id = $user->id;
|
||||
$booking->user()->associate($user);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user