mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-30 09:44:15 +00:00
changed model from bookingsupplier to supplier booking
fix supplier booking controller make payment method nullable for supplier booking
This commit is contained in:
@@ -2,13 +2,15 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\BookingSupplier;
|
||||
use Auth;
|
||||
use App\SupplierBooking;
|
||||
use App\Booking;
|
||||
use App\Rate;
|
||||
use App\User;
|
||||
use App\UserBankSlip;
|
||||
use App\SettingBeneficiary;
|
||||
use App\SupplierBookingItem;
|
||||
use App\SettingSupplier;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BookingSupplierController extends Controller
|
||||
@@ -16,7 +18,7 @@ class BookingSupplierController extends Controller
|
||||
|
||||
public function index()
|
||||
{
|
||||
$bookingsupplier = BookingSupplier::all();
|
||||
$bookingsupplier = SupplierBooking::all();
|
||||
|
||||
$response = [
|
||||
'supplier-booking' => $bookingsupplier
|
||||
@@ -27,7 +29,7 @@ class BookingSupplierController extends Controller
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$bookingsupplier = BookingSupplier::has('supplier-booking')->findOrFail($id);
|
||||
$bookingsupplier = SupplierBooking::has('supplier-booking')->findOrFail($id);
|
||||
|
||||
$response = [
|
||||
'supplier-booking' => $bookingsupplier
|
||||
@@ -38,35 +40,35 @@ class BookingSupplierController extends Controller
|
||||
|
||||
// Only for single booking
|
||||
// TODO : Multiple booking
|
||||
public function store(Request $request, $id)
|
||||
public function store(Request $request)
|
||||
{
|
||||
$payment_amount = $request->input("payment_amount");
|
||||
$rate = $request->input("rate");
|
||||
$rebate = $request->input("rebate");
|
||||
$transfer_amount = $request->input("transfer_amount");
|
||||
$supplier_id = $request->input("supplier_id");
|
||||
$booking_id = $request->input("booking_id");
|
||||
$rate = $request->input('rate');
|
||||
$rebate = $request->input('rebate');
|
||||
|
||||
// Calculation
|
||||
$amountInRMB = $payment_amount * $rate;
|
||||
$billing = 0.015 * $payment_amount;
|
||||
$sales_tax = 0.10 * $payment_amount;
|
||||
$gst = 0 * $payment_amount; // do we still need this ?
|
||||
$customerBankInAmount = round($payment_amount + $gst + $sales_tax + $billing,2);
|
||||
$amountInRMB = $transfer_amount * $rate;
|
||||
$billing = 0.015 * $transfer_amount;
|
||||
$sales_tax = 0.10 * $transfer_amount;
|
||||
$gst = 0 * $transfer_amount; // do we still need this ?
|
||||
$customerBankInAmount = round($transfer_amount + $gst + $sales_tax + $billing,2);
|
||||
$rmbBankAmount = $customerBankInAmount + $rebate;
|
||||
|
||||
$user = Auth::user();
|
||||
$supplier = SettingSupplier::find($supplier_id);
|
||||
$booking = Booking::find($id);
|
||||
$booking = Booking::find($booking_id);
|
||||
|
||||
$bookingsupplier = new BookingSupplier();
|
||||
$bookingsupplier = new SupplierBooking();
|
||||
$bookingsupplier->supplier_id = $supplier->id;
|
||||
$bookingsupplier->payment_method = $request->input('payment_method');
|
||||
$bookingsupplier->payment_amount = $request->input('payment_amount');
|
||||
$bookingsupplier->rate = $request->input('rate');
|
||||
$bookingsupplier->rebate = $request->input('rebate');
|
||||
$bookingsupplier->user()->associate($user);
|
||||
$bookingsupplier->transfer_amount = $transfer_amount;
|
||||
$bookingsupplier->rate = $rate;
|
||||
$bookingsupplier->rebate = $rebate;
|
||||
$bookingsupplier->amountInRMB = $amountInRMB;
|
||||
$bookingsupplier->rmbBankAmount = $rmbBankAmount;
|
||||
$bookingsupplier->booking()->associate($booking);
|
||||
$bookingsupplier->book_id = $booking->id;
|
||||
$bookingsupplier->save();
|
||||
|
||||
// update booking status
|
||||
@@ -100,9 +102,9 @@ class BookingSupplierController extends Controller
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$bookingsupplier = BookingSupplier::find($id);
|
||||
$bookingsupplier = BSupplierBooking::find($id);
|
||||
$bookingsupplier->payment_method = $request->input('payment_method');
|
||||
$bookingsupplier->payment_amount = $request->input('payment_amount');
|
||||
$bookingsupplier->transfer_amount = $request->input('transfer_amount');
|
||||
$bookingsupplier->rate = $request->input('rate');
|
||||
$bookingsupplier->rebate = $request->input('rebate');
|
||||
// calculation
|
||||
|
||||
@@ -12,7 +12,7 @@ class SettingSupplierController extends Controller
|
||||
$suppliers = SettingSupplier::all();
|
||||
|
||||
foreach ($suppliers as $supplier) {
|
||||
$supplier->value = $supplier->company_name;
|
||||
$supplier->value = $supplier->id;
|
||||
$supplier->label = $supplier->company_name;
|
||||
}
|
||||
return $suppliers;
|
||||
|
||||
Reference in New Issue
Block a user