removed vee-validate which causes cief bank details not showing in user upload bank slip

added exception if userbankslip not save show error
added tax rate to supplier booking
added order number and payment for to booking seeder
This commit is contained in:
Jack Goh
2018-07-25 16:22:53 +08:00
parent 017f70391e
commit 4e0f1dbe0a
8 changed files with 75 additions and 29 deletions
+16 -9
View File
@@ -417,19 +417,26 @@ class BookingController extends Controller
'user_bankslip', $bankslip_file, $unique_image_path
);
$user_bankslip = $booking->userBankSlip()->first();
if($upload_path){
$user_bankslip = $booking->userBankSlip()->first();
// if user bankslip not exist, create new one
if(!$user_bankslip){
$user_bankslip = new UserBankSlip;
// if user bankslip not exist, create new one
if(!$user_bankslip){
$user_bankslip = new UserBankSlip;
}
$user_bankslip->booking_id = $booking->id;
$user_bankslip->bankslip_path = $upload_path;
$user_bankslip->transfer_amount = $request->input('transfer_amount');
$user_bankslip->save();
return response()->json(['message'=>"Success"],200);
}
else{
return response()->json(['message' => 'File not uploaded. Please contact support'], 400);
}
$user_bankslip->booking_id = $booking->id;
$user_bankslip->bankslip_path = $upload_path;
$user_bankslip->transfer_amount = $request->input('transfer_amount');
$user_bankslip->save();
return response()->json(['message'=>"Success"],200);
}
else {
return response()->json(['message' => 'No file detected'], 400);
@@ -11,6 +11,7 @@ use App\UserBankSlip;
use App\SettingBeneficiary;
use App\SupplierBookingItem;
use App\SettingSupplier;
use App\SettingTaxRate;
use Illuminate\Http\Request;
class BookingSupplierController extends Controller
@@ -30,15 +31,53 @@ class BookingSupplierController extends Controller
public function show($id)
{
$booking = Booking::where('id', $id)->first();
$tax_rate = SettingTaxRate::latest()->first()->tax_rate;
$bankin_amount = round($booking->amount / $booking->rate, 2);
if (!$booking){
return response()->json(['message' => 'Booking not found'], 404);
}
switch ($booking->term) {
case "x1_cash":
$payment_method = "CASH";
break;
case "x1_cheque":
$payment_method = "CHEQUE";
break;
case "x1_ba":
$payment_method = "BA";
break;
case "x2_cash":
$payment_method = "CASH";
break;
case "x2_cheque":
$payment_method = "CHEQUE";
break;
case "x2_ba":
$payment_method = "BA";
break;
default:
return response()->json([
'success' => false,
'message' => 'Invalid input',
], 422);
break;
}
$supplier_booking = $booking->supplierBooking()->first();
$dt = new \DateTime($supplier_booking->created_at);
$supplier_booking->date = $dt->format('j F Y');
$supplier_booking->marking = $booking->user->marking;
$supplier_booking->payment_for = $booking->payment_for;
$supplier_booking->order_no = $booking->order_no;
$supplier_booking->payment_method = $payment_method;
$supplier_booking->tax_rate = $tax_rate;
$supplier_booking->rate = $booking->rate;
$supplier_booking->bankin_amount = $bankin_amount;
return response()->json($supplier_booking ,200);
@@ -57,10 +96,10 @@ class BookingSupplierController extends Controller
// Calculation
$amountInRMB = $transfer_amount * $rate;
$billing = 0.015 * $transfer_amount;
$sales_tax = 0.10 * $transfer_amount;
$sales_tax = 0.0 * $transfer_amount;
$gst = 0 * $transfer_amount; // do we still need this ?
$customerBankInAmount = round($transfer_amount + $gst + $sales_tax + $billing,2);
$rmbBankAmount = $customerBankInAmount + $rebate;
$rmbBankAmount = round($customerBankInAmount + $rebate, 2);
$user = Auth::user();
$supplier = SettingSupplier::find($supplier_id);
@@ -90,6 +129,8 @@ class BookingSupplierController extends Controller
$booking->status = 4;
$booking->admin_status = 4;
$booking->save();
return response()->json($bookingsupplier, 201);
}