mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-24 14:54:38 +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;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BookingSupplier extends Model
|
||||
class SupplierBooking extends Model
|
||||
{
|
||||
// protected $guarded = [];
|
||||
protected $fillable = ['rate','rebate','payment_amount','payment_method'];
|
||||
@@ -39,6 +39,6 @@ class SupplierBookingTable extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('booking_suppliers');
|
||||
Schema::dropIfExists('supplier_bookings');
|
||||
}
|
||||
}
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class MakePaymentmethodNulltableInSupplierbookingTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('supplier_bookings', function($table)
|
||||
{
|
||||
$table->string('payment_method')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -219,7 +219,7 @@
|
||||
<el-input v-model="supplierBookingForm.rebate" type="text" placeholder="Rebate" style="width: 80%" />
|
||||
</el-form-item>
|
||||
<el-form-item prop="transfer_amount">
|
||||
<el-input v-model="supplierBookingForm.payment_amount" type="text" placeholder="Payment Amount" style="width: 80%" />
|
||||
<el-input v-model="supplierBookingForm.transfer_amount" type="text" placeholder="Payment Amount" style="width: 80%" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button :loading="loading_btn" type="primary" @click="generateReport('supplierBookingForm')">Generate Report</el-button>
|
||||
@@ -260,6 +260,7 @@
|
||||
supplierBookingForm: {
|
||||
supplier: null,
|
||||
amount: null,
|
||||
rebate: null,
|
||||
rate: null,
|
||||
transfer_amount: null,
|
||||
},
|
||||
@@ -329,30 +330,34 @@
|
||||
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
let newConfirmation = {
|
||||
amount: this.booking.amount,
|
||||
term: this.term
|
||||
let newReport = {
|
||||
booking_id: this.$route.params.id,
|
||||
supplier_id: this.supplierBookingForm.supplier,
|
||||
amount: this.supplierBookingForm.amount,
|
||||
rebate: this.supplierBookingForm.rebate,
|
||||
rate: this.supplierBookingForm.rate,
|
||||
transfer_amount: this.supplierBookingForm.transfer_amount,
|
||||
}
|
||||
|
||||
// axios.post('api/booking/calculation', newConfirmation)
|
||||
// .then((response) => {
|
||||
// this.loading = false
|
||||
// console.log(response)
|
||||
// this.bookingConfirmTable.date = response.data.date
|
||||
// this.bookingConfirmTable.marking = response.data.marking
|
||||
// this.bookingConfirmTable.payment_method = response.data.payment_method
|
||||
// this.bookingConfirmTable.amount = response.data.amount
|
||||
// this.bookingConfirmTable.service_charge = response.data.service_charge
|
||||
// this.bookingConfirmTable.rate = response.data.rate
|
||||
// this.bookingConfirmTable.bankin_amount = response.data.bankin_amount
|
||||
// this.bookingConfirmTable.account_name = this.bookingForm.account_name
|
||||
// this.dialogFormVisible = false
|
||||
// this.dialogFormVisible1 = true
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// this.loading = false
|
||||
// console.log(error)
|
||||
// })
|
||||
axios.post('/api/supplier-booking', newReport)
|
||||
.then((response) => {
|
||||
this.loading_btn = false
|
||||
console.log(response)
|
||||
// this.bookingConfirmTable.date = response.data.date
|
||||
// this.bookingConfirmTable.marking = response.data.marking
|
||||
// this.bookingConfirmTable.payment_method = response.data.payment_method
|
||||
// this.bookingConfirmTable.amount = response.data.amount
|
||||
// this.bookingConfirmTable.service_charge = response.data.service_charge
|
||||
// this.bookingConfirmTable.rate = response.data.rate
|
||||
// this.bookingConfirmTable.bankin_amount = response.data.bankin_amount
|
||||
// this.bookingConfirmTable.account_name = this.bookingForm.account_name
|
||||
// this.dialogFormVisible = false
|
||||
// this.dialogFormVisible1 = true
|
||||
})
|
||||
.catch((error) => {
|
||||
this.loading_btn = false
|
||||
console.log(error)
|
||||
})
|
||||
|
||||
} else {
|
||||
this.loading_btn = false
|
||||
|
||||
@@ -62,13 +62,13 @@ export default [
|
||||
{ path: '/booking/:id/po-complete', name: 'booking.user.pocomplete', component: PoComplete },
|
||||
{ path: '/booking/:id/complete', name: 'booking.complete', component: Completed },
|
||||
|
||||
{ path: '/admin',
|
||||
component: Admin,
|
||||
children: [
|
||||
{ path: '', redirect: { name: 'admin.index' } },
|
||||
{ path: 'index', name: 'admin.index', component: Admin },
|
||||
{ path: 'home', name: 'admin.home', component: AdminHome }
|
||||
] },
|
||||
// { path: '/admin',
|
||||
// component: Admin,
|
||||
// children: [
|
||||
// { path: '', redirect: { name: 'admin.index' } },
|
||||
// { path: 'index', name: 'admin.index', component: Admin },
|
||||
// { path: 'home', name: 'admin.home', component: AdminHome }
|
||||
// ] },
|
||||
// Admin booking
|
||||
{ path: '/booking/:id/verification', name: 'booking.admin.verification', component: Verification },
|
||||
{ path: '/booking/:id/supplier', name: 'booking.admin.supplier', component: Supplier },
|
||||
|
||||
+1
-1
@@ -7,7 +7,6 @@ $baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'App\\Booking' => $baseDir . '/app/Booking.php',
|
||||
'App\\BookingSupplier' => $baseDir . '/app/BookingSupplier.php',
|
||||
'App\\ChinaBankSlip' => $baseDir . '/app/ChinaBankSlip.php',
|
||||
'App\\Console\\Kernel' => $baseDir . '/app/Console/Kernel.php',
|
||||
'App\\Exceptions\\EmailTakenException' => $baseDir . '/app/Exceptions/EmailTakenException.php',
|
||||
@@ -55,6 +54,7 @@ return array(
|
||||
'App\\SettingBeneficiary' => $baseDir . '/app/SettingBeneficiary.php',
|
||||
'App\\SettingCredit' => $baseDir . '/app/SettingCredit.php',
|
||||
'App\\SettingSupplier' => $baseDir . '/app/SettingSupplier.php',
|
||||
'App\\SupplierBooking' => $baseDir . '/app/SupplierBooking.php',
|
||||
'App\\SupplierBookingItem' => $baseDir . '/app/SupplierBookingItem.php',
|
||||
'App\\User' => $baseDir . '/app/User.php',
|
||||
'App\\UserBankSlip' => $baseDir . '/app/UserBankSlip.php',
|
||||
|
||||
Vendored
+1
-1
@@ -429,7 +429,6 @@ class ComposerStaticInit51a2977d18ddf089cd82402f3476f1a0
|
||||
|
||||
public static $classMap = array (
|
||||
'App\\Booking' => __DIR__ . '/../..' . '/app/Booking.php',
|
||||
'App\\BookingSupplier' => __DIR__ . '/../..' . '/app/BookingSupplier.php',
|
||||
'App\\ChinaBankSlip' => __DIR__ . '/../..' . '/app/ChinaBankSlip.php',
|
||||
'App\\Console\\Kernel' => __DIR__ . '/../..' . '/app/Console/Kernel.php',
|
||||
'App\\Exceptions\\EmailTakenException' => __DIR__ . '/../..' . '/app/Exceptions/EmailTakenException.php',
|
||||
@@ -477,6 +476,7 @@ class ComposerStaticInit51a2977d18ddf089cd82402f3476f1a0
|
||||
'App\\SettingBeneficiary' => __DIR__ . '/../..' . '/app/SettingBeneficiary.php',
|
||||
'App\\SettingCredit' => __DIR__ . '/../..' . '/app/SettingCredit.php',
|
||||
'App\\SettingSupplier' => __DIR__ . '/../..' . '/app/SettingSupplier.php',
|
||||
'App\\SupplierBooking' => __DIR__ . '/../..' . '/app/SupplierBooking.php',
|
||||
'App\\SupplierBookingItem' => __DIR__ . '/../..' . '/app/SupplierBookingItem.php',
|
||||
'App\\User' => __DIR__ . '/../..' . '/app/User.php',
|
||||
'App\\UserBankSlip' => __DIR__ . '/../..' . '/app/UserBankSlip.php',
|
||||
|
||||
Reference in New Issue
Block a user