Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/exchange into feature/admin-home-frontend

# Conflicts:
#	resources/assets/js/pages/admin/booking/supplierBooking.vue
This commit is contained in:
Jack Goh
2018-06-27 14:23:19 +08:00
19 changed files with 9470 additions and 100 deletions
+5 -1
View File
@@ -27,11 +27,15 @@ class Booking extends Model
'bank_branch', 'company_name'];
public $timestamps = true;
public function user(){
return $this->belongsTo('app\User');
}
public function bookingSupplier(){
return $this->belongsTo('app\BookingSupplier ');
}
public function userBankSlip(){
return $this->hasOne(UserBankSlip::class);
}
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class BookingSupplier extends Model
{
// protected $guarded = [];
protected $fillable = ['rate','rebate','payment_amount','payment_method'];
public $timestamps = true;
public function user()
{
return $this->belongsTo('app\User');
}
public function booking(){
return $this->hasOne('App\Booking');
}
public function supplierBookingTtem()
{
return $this->hasMany('App\SupplierBookingItem');
}
}
+14 -1
View File
@@ -164,9 +164,9 @@ class BookingController extends Controller
public function store(Request $request)
{
$rates = Rate::orderby('updated_at','desc')->first();
$term = $request->input('term');
$amount = $request->input("amount"); // in RMB
$rates = Rate::orderby('updated_at','desc')->first();
$creditLimit = SettingCredit::orderby('updated_at','desc')->first();
if (!$creditLimit){
@@ -320,6 +320,19 @@ class BookingController extends Controller
if(!$bankslip_file = $request->file('file'))
{
$bankslip_file = $request->file('file');
$filename = $bankslip_file->getClientOriginalName();
$unique_name = 'bank_slip_' . md5($filename. time());
$file = $request->file('file');
$ext = $file->getClientOriginalExtension();
$input['bankslip_file'] = $filename;
Storage::putFileAs(
'bankslip_file',/*folder name*/ $file, $unique_name. '.' .$ext
);
$user_bankslip->bankslip_file = $unique_name. '.' .$ext; //update database
} //end if
else {
return response()->json(['message' => 'No file detected'], 400);
}
/* End Validation */
@@ -0,0 +1,144 @@
<?php
namespace App\Http\Controllers;
use App\BookingSupplier;
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
{
public function index()
{
$bookingsupplier = BookingSupplier::all();
$response = [
'supplier-booking' => $bookingsupplier
];
return response()->json($response, 200);
}
public function show($id)
{
$bookingsupplier = BookingSupplier::has('supplier-booking')->findOrFail($id);
$response = [
'supplier-booking' => $bookingsupplier
];
return response()->json($response, 200);
}
// Only for single booking
// TODO : Multiple booking
public function store(Request $request, $id)
{
$payment_amount = $request->input("payment_amount");
$rate = $request->input("rate");
$rebate = $request->input("rebate");
$supplier_id = $request->input("supplier_id");
// 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);
$rmbBankAmount = $customerBankInAmount + $rebate;
$user = Auth::user();
$supplier = SettingSupplier::find($supplier_id);
$booking = Booking::find($id);
$bookingsupplier = new BookingSupplier();
$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->amountInRMB = $amountInRMB;
$bookingsupplier->rmbBankAmount = $rmbBankAmount;
$bookingsupplier->booking()->associate($booking);
$bookingsupplier->save();
// update booking status
$booking->status = 4;
$booking->admin_status = 3;
$booking->save();
//// 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();
// $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');
$bookingsupplier->rate = $request->input('rate');
$bookingsupplier->rebate = $request->input('rebate');
// calculation
$amountInRMB = $amount * $rate;
$billing = 0.015 * $amount;
$sales_tax = 0.10 * $amount;
$gst = 0 * $amount;
$customerBankInAmount = round($amount + $gst + $sales_tax + $billing,2);
$rmbBankAmount = $customerBankInAmount + $rebate;
// save amount in rmb
$bookingsupplier->amountInRMB = $amountInRMB;
// save rmb bank amount
$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);
}
public function report(Request $request, $id)
{
$supplier_booking = Booking::firstOrFail($id)->supplierBooking()->firstOrFail();
return response()->json($supplier_booking ,200);
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SupplierBookingItem extends Model
{
protected $fillable = [
'id',
'china_bankslip_url',
'book_id',
'bank_in_amount',
'date',
'details',
'supplierbooking_id'
];
public function bookingsupplier()
{
return $this->belongsTo('App\BookingSupplier');
}
}
Executable → Regular
View File
@@ -0,0 +1,9 @@
<?php
use Faker\Generator as Faker;
$factory->define(App\SupplierBookingItem::class, function (Faker $faker) {
return [
//
];
});
@@ -0,0 +1,44 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class SupplierBookingTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('supplier_bookings', function (Blueprint $table) {
$table->increments('id');
$table->string('payment_method');
$table->double('transfer_amount');
$table->double('rate');
$table->double('rebate');
$table->double('amountInRMB');
$table->double('rmbBankAmount');
$table->integer('book_id')->unsigned();
$table->foreign('book_id')->references('id')->on('bookings');
$table->integer('supplier_id')->unsigned();
$table->foreign('supplier_id')->references('id')->on('setting_suppliers');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('booking_suppliers');
}
}
@@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class SupplierbookingCustomerbookingTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('supplierbooking_customerbooking', function (Blueprint $table) {
$table->integer('supplierbooking_id')->unsigned();
$table->integer('booking_id')->unsigned();
$table->foreign('supplierbooking_id')->references('id')->on('supplier_bookings');
$table->foreign('booking_id')->references('id')->on('bookings');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('supplierbooking_customerbooking');
}
}
@@ -0,0 +1,37 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSupplierBookingItemsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('supplier_booking_items', function (Blueprint $table) {
$table->increments('id');
$table->string('china_bankslip_url');
$table->integer('book_id')->unsigned();
$table->foreign('book_id')->references('id')->on('bookings');
$table->double('bank_in_amount');
$table->integer('supplierbooking_id')->unsigned();
$table->foreign('supplierbooking_id')->references('id')->on('supplier_bookings');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('supplier_booking_items');
}
}
Executable → Regular
View File

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 78 KiB

@@ -19,7 +19,7 @@
<div class="el-row" style="margin-left: -6px; margin-right: -6px;">
<div class="el-col el-col-12" style="padding-left: 6px; padding-right: 6px;">
<div class="el-table el-table--fit el-table--enable-row-hover el-table--enable-row-transition" align="center">
<div class="el-table__body-wrapper is-scrolling-none">
<table class="el-table__body" style="width: 400px;" cellspacing="0" cellpadding="0" border="0">
<colgroup>
@@ -147,7 +147,9 @@
<div class="cell"></div>
</td>
<td class="el-table_3_column_12 is-left ">
<div class="cell"><b>MYR {{ booking_details.bia }}</b></div>
<div class="cell">
<b>MYR {{ booking_details.bia }}</b>
</div>
</td>
</tr>
<tr class="el-table__row">
@@ -199,41 +201,32 @@
<el-row :gutter="12" style="text-align:center">
<el-col :span="20" style="text-align:center">
<el-form ref="supplierBookingForm" :model="supplierBookingForm" :rules="rules">
<div align="center">
<el-form-item prop="supplier">
<el-select prop="supplier" v-model="supplierBookingForm.supplier" placeholder="Choose Supplier">
<el-option
v-for="item in supplier_options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item prop="amount">
<el-input v-model="supplierBookingForm.amount" type="text" placeholder="Amount" style="width: 80%" />
</el-form-item>
<el-form-item prop="rate">
<el-input v-model="supplierBookingForm.rate" type="text" placeholder="Rate" style="width: 80%" />
</el-form-item>
<el-form-item prop="transfer_amount">
<el-input v-model="supplierBookingForm.transfer_amount" type="text" placeholder="Transfer Amount" style="width: 80%"
/>
</el-form-item>
<el-form-item>
<el-button :loading="loading_btn" type="primary" @click="generateReport('supplierBookingForm')">Generate Report</el-button>
</el-form-item>
</div>
</el-form>
<el-form ref="supplierBookingForm" :model="supplierBookingForm" :rules="rules">
<div align="center">
<el-form-item prop="supplier">
<el-select prop="supplier" v-model="supplierBookingForm.supplier" placeholder="Choose Supplier">
<el-option v-for="item in supplier_options" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item prop="rate">
<el-input v-model="supplierBookingForm.rate" type="text" placeholder="Rate" style="width: 80%" />
</el-form-item>
<el-form-item prop="rebate">
<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-form-item>
<el-form-item>
<el-button :loading="loading_btn" type="primary" @click="generateReport('supplierBookingForm')">Generate Report</el-button>
</el-form-item>
</div>
</el-form>
</el-col>
</el-row>
</el-card>
</el-row>
@@ -256,7 +249,7 @@
return {
status: 3,
loading_btn: false,
booking_details:{
booking_details: {
id: null,
amount: null,
bia: null,
@@ -264,7 +257,7 @@
},
supplier: null,
supplier_options: null,
supplierBookingForm:{
supplierBookingForm: {
supplier: null,
amount: null,
rate: null,
@@ -276,90 +269,89 @@
required: true,
message: 'Please input amount',
trigger: 'change'
} ],
amount: [{
}],
rebate: [{
required: true,
message: 'Please input bank name',
trigger: 'change'
} ],
}],
rate: [{
required: true,
message: 'Please input account name',
trigger: 'change'
}],
transfer_amount: [{
payment_amount: [{
required: true,
message: 'Please input branch',
trigger: 'change'
}]
},
},
}
},
beforeCreate () {
const loading = this.$loading({
lock: true,
text: 'Please wait..',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
axios
.get('/api/admin/booking/' + this.$route.params.id)
.then((response) => {
loading.close()
this.booking_details = response.data
}).catch((error) => {
console.log(error)
loading.close()
this.$router.push({
name: 'notfound'
})
beforeCreate() {
const loading = this.$loading({
lock: true,
text: 'Please wait..',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
axios
.get('/api/setting-supplier/')
.then((response) => {
loading.close()
this.supplier_options = response.data
}).catch((error) => {
loading.close()
console.log(error)
this.$router.push({
name: 'notfound'
axios
.get('/api/admin/booking/' + this.$route.params.id)
.then((response) => {
loading.close()
this.booking_details = response.data
}).catch((error) => {
console.log(error)
loading.close()
this.$router.push({
name: 'notfound'
})
})
})
},
axios
.get('/api/setting-supplier/')
.then((response) => {
loading.close()
this.supplier_options = response.data
}).catch((error) => {
loading.close()
console.log(error)
this.$router.push({
name: 'notfound'
})
})
},
methods: {
generateReport (formName) {
generateReport(formName) {
this.loading_btn = true
this.$refs[formName].validate((valid) => {
if (valid) {
let newSupplierBooking = this.supplierBookingForm
axios.post('/api/supplier-booking', newSupplierBooking)
.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)
})
}
else{
// 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)
// })
} else {
this.loading_btn = false
}
})
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
+7 -2
View File
@@ -92,6 +92,11 @@ Route::group(['middleware' => ['role:admin']], function() {
Route::get('marking/{beneficiary}', 'MarkingController@show');
Route::put('marking/{beneficiary}', 'MarkingController@update');
Route::delete('marking/{beneficiary}', 'MarkingController@delete');
Route::get('supplier-booking', 'BookingSupplierController@index');
Route::get('supplier-booking/{id}', 'BookingSupplierController@show');
Route::post('supplier-booking', 'BookingSupplierController@store');
Route::put('supplier-booking/{id}', 'BookingSupplierController@update');
});
Route::get('update-rate', 'RateController@index');
@@ -99,8 +104,8 @@ Route::get('update-rate/{rate}', 'RateController@show');
Route::post('upload-china-bankslip', 'ChinaBankSlipController@store');
//customer booking
Route::post('booking/{id}/upload-user-bankslip', 'BookingController@uploadbankslip');
Route::post('booking/{id}/upload-po', 'BookingController@uploadPurchaseOrder');
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff