changed get active bank from backend instead of frontend

This commit is contained in:
Jack Goh
2018-07-26 11:22:03 +08:00
parent 45e8ce8620
commit 8f7a4ee6b6
2 changed files with 23 additions and 34 deletions
@@ -12,6 +12,7 @@ use App\SettingBeneficiary;
use App\SupplierBookingItem;
use App\SettingSupplier;
use App\SettingTaxRate;
use App\SettingActiveBank;
use Illuminate\Http\Request;
class BookingSupplierController extends Controller
@@ -67,6 +68,7 @@ class BookingSupplierController extends Controller
break;
}
$supplier_booking = $booking->supplierBooking()->first();
$dt = new \DateTime($supplier_booking->created_at);
$supplier_booking->date = $dt->format('j F Y');
@@ -75,6 +77,22 @@ class BookingSupplierController extends Controller
$supplier_booking->order_no = $booking->order_no;
$supplier_booking->payment_method = $payment_method;
$active_bank = SettingActiveBank::first();
// if setting is set to use customer's beneficiary
if ($active_bank->beneficiary_id == 0){
$supplier_booking->acc_name = $booking->account_name;
$supplier_booking->acc_no = $booking->account_num; // TODO : standardize acc_no
$supplier_booking->bank_name = $booking->bank_name;
}
else{
$beneficiary = SettingBeneficiary::find($active_bank->beneficiary_id);
$supplier_booking->acc_name = $beneficiary->company_name;
$supplier_booking->acc_no = $beneficiary->acc_no;
$supplier_booking->bank_name = $beneficiary->bank_name;
}
return response()->json($supplier_booking ,200);
}
@@ -313,43 +313,14 @@
axios.get('/api/supplier-booking/' + this.$route.params.id)
.then((response) => {
this.supplier_booking = response.data
loading.close()
}).catch((error) => {
console.log(error)
this.$router.push({
name: 'notfound'
})
loading.close()
})
axios.get('/api/active-bank')
.then((response) => {
axios.get('/api/setting-beneficiary/' + response.data.beneficiary_id)
.then((response) => {
loading.close();
this.supplier_booking.china_bank_name = response.data.bank_name;
this.supplier_booking.china_company_name = response.data.company_name;
this.supplier_booking.china_acc_no = response.data.acc_no;
})
.catch((error) => {
loading.close();
console.log(error);
this.$message({
showClose: true,
message: 'Fetch data fail',
type: 'error',
duration: 10000
});
});
})
.catch((error) => {
loading.close();
console.log(error);
this.$message({
showClose: true,
message: 'Fetch data fail',
type: 'error',
duration: 10000
});
});
},
methods: {
downloadReport(){
@@ -578,9 +549,9 @@
ctx.font = "bold 14px Arial";
ctx.textAlign = "center";
ctx.fillText("China beneficiary Account", column2X - 40, rowHeight[22] - 80);
ctx.fillText("户名 : " + binding.value.china_company_name, column2X - 40, rowHeight[22] - 60);
ctx.fillText(binding.value.china_acc_no, column2X - 40, rowHeight[22] - 40);
ctx.fillText(binding.value.china_bank_name , column2X - 40, rowHeight[22] - 20);
ctx.fillText("户名 : " + binding.value.acc_name, column2X - 40, rowHeight[22] - 60);
ctx.fillText(binding.value.acc_no, column2X - 40, rowHeight[22] - 40);
ctx.fillText(binding.value.bank_name , column2X - 40, rowHeight[22] - 20);
ctx.font = "13px Arial";
}, 1000,canvasElement,binding);