mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-21 21:34:16 +00:00
supplier booking (multiple booking removed)
This commit is contained in:
@@ -7,6 +7,8 @@ use App\Booking;
|
||||
use App\Rate;
|
||||
use App\User;
|
||||
use App\UserBankSlip;
|
||||
use App\SettingBeneficiary;
|
||||
use App\SupplierBookingItem;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BookingSupplierController extends Controller
|
||||
@@ -15,20 +17,19 @@ class BookingSupplierController extends Controller
|
||||
public function index()
|
||||
{
|
||||
$bookingsupplier = BookingSupplier::all();
|
||||
|
||||
|
||||
$response = [
|
||||
'supplier-booking' => $bookingsupplier
|
||||
];
|
||||
return response()->json($response, 200);
|
||||
}
|
||||
|
||||
// function show($id)
|
||||
public function show($id)
|
||||
{
|
||||
$bookingsupplier = BookingSupplier::has('supplier-booking')->findOrFail($id);
|
||||
|
||||
$response = [
|
||||
'supplier-booking' => $booking
|
||||
'supplier-booking' => $bookingsupplier
|
||||
];
|
||||
return response()->json($response, 200);
|
||||
}
|
||||
@@ -40,7 +41,7 @@ class BookingSupplierController extends Controller
|
||||
// TODO: admin can access only
|
||||
// get current booking
|
||||
|
||||
$booking = Booking::where("admin_id", Auth::user()->id)->where('id', $id)->first();
|
||||
// $booking = Booking::where("admin_id", Auth::user()->id)->where('id', $id)->first();
|
||||
if (!$booking)
|
||||
{
|
||||
return response()->json(['message'=>'Access denied'], 200);
|
||||
@@ -50,7 +51,6 @@ class BookingSupplierController extends Controller
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function store(Request $request, $id)
|
||||
{
|
||||
//Calculation part
|
||||
@@ -59,11 +59,11 @@ class BookingSupplierController extends Controller
|
||||
$rate = $request->input("rate");
|
||||
$rebate = $request->input("rebate");
|
||||
|
||||
$amountInRMB = $amount * $rate;
|
||||
$billing = 0.015 * $amount;
|
||||
$sales_tax = 0.10 * $amount;
|
||||
$gst = 0 * $amount;
|
||||
$customerBankInAmount = round($amount + $gst + $sales_tax + $billing,2);
|
||||
$amountInRMB = $payment_amount * $rate;
|
||||
$billing = 0.015 * $payment_amount;
|
||||
$sales_tax = 0.10 * $payment_amount;
|
||||
$gst = 0 * $payment_amount;
|
||||
$customerBankInAmount = round($payment_amount + $gst + $sales_tax + $billing,2);
|
||||
$rmbBankAmount = $customerBankInAmount + $rebate;
|
||||
|
||||
$user = Auth::user();
|
||||
@@ -80,45 +80,34 @@ class BookingSupplierController extends Controller
|
||||
$bookingsupplier->user()->associate($user);
|
||||
$bookingsupplier->amountInRMB = $amountInRMB;
|
||||
$bookingsupplier->rmbBankAmount = $rmbBankAmount;
|
||||
|
||||
$bookingsupplier->save();
|
||||
|
||||
//one bookingsupplier has many booking
|
||||
foreach ($bookingsupplier as $booking)
|
||||
{
|
||||
$manybooking = new Booking(array(
|
||||
'book_id' => $booking->id,
|
||||
'term' => $booking['term'],
|
||||
'amount' => $booking['amount'],
|
||||
'account_name' => $booking['account_name'],
|
||||
'account_num' => $booking['account_num'],
|
||||
'bank_name' => $booking['bank_name'],
|
||||
'bank_branch' => $booking['account_name'],
|
||||
'company_name' => $booking['company_name'],
|
||||
'company_address' => $booking['company_address'],
|
||||
'bank_address' => $booking['bank_address'],
|
||||
'swift_code' => $booking['swift_code'],
|
||||
'cnap' => $booking['cnap'],
|
||||
'verification_status' => $booking['verification_status'],
|
||||
'rmb_book_amount' => $booking['rmb_book_amount'],
|
||||
'rmb_book_pay_method' => $booking['rmb_book_pay_method'],
|
||||
'rmb_book_account_name' => $booking['rmb_book_account_name'],
|
||||
'rmb_book_bank_name' => $booking['rmb_book_bank_name'],
|
||||
'rmb_book_acc_no' => $booking['rmb_book_acc_no'],
|
||||
'rmb_book_bank_branch' => $booking['rmb_book_bank_branch'],
|
||||
));
|
||||
//// one bookingsupplier has many booking
|
||||
// $bookings = $request->input("booking");
|
||||
// foreach ($bookings as $booking)
|
||||
// {
|
||||
// $bookingsupplierbooking = new Booking(array(
|
||||
// 'book_id' => $booking->id,
|
||||
// 'supplierbooking_id' => $supplier->id
|
||||
// ));
|
||||
// $bookingsupplierbooking->save();
|
||||
|
||||
$manybooking->save();
|
||||
}
|
||||
// $new_supplierbooking = new SupplierBookingItem(array(
|
||||
// 'book_id' => $booking->id,
|
||||
// 'bank_in_amount'=>$booking['bank_in_amount'],
|
||||
// 'date'=>$booking['date'],
|
||||
// 'details'=>$booking['details'],
|
||||
// 'supplierbooking_id' => $supplier->id
|
||||
// ));
|
||||
// $new_supplierbooking->save();
|
||||
|
||||
// }
|
||||
return response()->json($bookingsupplier, 201);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
|
||||
$bookingsupplier = BookingSupplier::find($id);
|
||||
$bookingsupplier->payment_method = $request->input('payment_method');
|
||||
$bookingsupplier->payment_amount = $request->input('payment_amount');
|
||||
@@ -138,6 +127,16 @@ class BookingSupplierController extends Controller
|
||||
$bookingsupplier->rmbBankAmount = $rmbBankAmount;
|
||||
$bookingsupplier->save();
|
||||
|
||||
// $supplierbookingitems = $request->input("supplierbookingitem");
|
||||
// foreach ($bookings as $booking)
|
||||
// {
|
||||
// $update_supplierbookingitem = SupplierBookingItem::where('supplierbooking_id', $id)->first();
|
||||
// $update_supplierbookingitem->china_bankslip_url = $booking['china_bankslip_url'];
|
||||
// $update_supplierbookingitem->bank_in_amount = $booking['bank_in_amount'];
|
||||
// $update_supplierbookingitem->date = $booking['date'];
|
||||
// $update_supplierbookingitem->details = $booking['details'];
|
||||
// $update_supplierbookingitem->save();
|
||||
// }
|
||||
return response()->json(['book_id'=>$book_id],201);
|
||||
}
|
||||
|
||||
@@ -153,10 +152,27 @@ class BookingSupplierController extends Controller
|
||||
{
|
||||
return response()->json(['message'=>'Access denied'], 200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// //get customer booking id, date,amount, rate, total, gst, rebate, bank in amount, beneficiary account number, bank slip.
|
||||
// return BookingSupplier::find($id);
|
||||
|
||||
// //display report
|
||||
// $bookingsupplier = BookingSupplier::with (['supplier_bookings' => function($query){
|
||||
// $query -> select ('book_id','date','transfer_amount','rate','rebate', 'amountInRMB', 'rmbBankAmount');
|
||||
// }])->get();
|
||||
|
||||
// //get uploaded customer booking bank slip
|
||||
// $userbankslip = UserBankSlip::with (['user_bank_slips' => function($query){
|
||||
// $query -> select ('book_id','bankslip_url');
|
||||
// }])->get();
|
||||
|
||||
// //get active beneficiary account
|
||||
// $beneficiary = SettingBeneficiary::with (['setting_beneficiaries' => function($query){
|
||||
// $query -> select ('bank_name','acc_no');
|
||||
// }])->get();
|
||||
|
||||
$supplier_booking = $booking->supplierBooking()->first();
|
||||
$user_bankslip = $booking->userBankSlip()->first();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user