diff --git a/Dockerfile b/Dockerfile index dad9c2bd..5eb8b990 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ FROM php:7.1.3 -RUN apt-get update -y && apt-get install -y openssl zip unzip git zlib1g-dev netcat mysql-client +RUN apt-get update -y && apt-get install -y openssl zip unzip git zlib1g-dev netcat mysql-client libgd-dev libfreetype6-dev libjpeg62-turbo-dev libpng12-dev RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer -RUN docker-php-ext-install pdo pdo_mysql zip +RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ +RUN docker-php-ext-install pdo pdo_mysql zip gd WORKDIR /app COPY . /app RUN composer install diff --git a/app/Booking.php b/app/Booking.php index 1add81f2..cf9f2e21 100644 --- a/app/Booking.php +++ b/app/Booking.php @@ -7,8 +7,11 @@ use Illuminate\Database\Eloquent\Model; class Booking extends Model { // protected $guarded = []; - protected $fillable = ['term', 'amount', 'rate_id', 'user_id', 'account_name', 'account_num', 'bank_name', 'bank_branch', 'company_name', 'company_address', 'bank_address', 'swift_code', 'cnap' ,'verification_status']; + protected $fillable = ['term', 'rate_id', 'user_id', 'amount', 'account_name', 'account_num', 'bank_name', + 'bank_branch', 'company_name']; + public $timestamps = true; + public function user(){ return $this->belongsTo('app\User'); } diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index 179dfcb3..ef502cbb 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -19,7 +19,10 @@ class BookingController extends Controller { $rates = Rate::orderby('updated_at','desc')->first(); $term = $request->input('term'); - $rate = 1; // default + $amount = $request->input("amount"); + $user = Auth::user(); + $rate = 1; // default rate to 1 + switch ($term) { case "x1_cash": $rate = $rates->x1_cash; @@ -46,66 +49,65 @@ class BookingController extends Controller ], 422); break; } - - // Calculation Service charge - $amount = $request->input("amount"); - - //logic : if amount higher than 10,000, no service charge. if amount lower than 10,000, 20.00 service charge + + // Service charge (RMB) : if amount higher than 10,000, no service charge. if amount lower than 10,000, 20.00 service charge if ($amount >= 10000 && ($term == 'x2_cash' || $term = 'x2_cheque' || $term = 'x2_ba')) { $svcharge = 0; } else { $svcharge = 20.00; } - //initial calculation - $RMBinMYR = (($amount + $svcharge) / $rate); + // initial rmb to myr amount + $RMBinMYR = (($amount + $svcharge) / $rate); - //calculate gst, 0% after 1june 2018 - $gst = 0*$RMBinMYR; + // TODO : Should be remove this ? + // gst 0% + $gst = 0 * $RMBinMYR; - //calculate Sales Tax, 10% of initial calculation - $sales_tax = 0.10*$RMBinMYR; + // Sales tax : 10 % + $sales_tax = 0.10 * $RMBinMYR; - //calculate billing, 1.5% of initial calculation - $billing = 0.015*$RMBinMYR; + // Billing fees : 1.5% + $billing = 0.015 * $RMBinMYR; - //bia = bank in amount in MYR - $bia = round($RMBinMYR + $gst + $sales_tax + $billing,2); + // Bank in amount + $bia = round($RMBinMYR + $gst + $sales_tax + $billing, 2); - $user = Auth::user(); - $booking = new Booking(); - $booking->account_name = $request->input('account_name'); - $booking->account_num = $request->input('account_num'); - $booking->bank_name = $request->input('bank_name'); - $booking->bank_branch = $request->input('bank_branch'); - $booking->company_name = $request->input('company_name'); - $booking->company_address = $request->input('company_address'); - $booking->bank_address = $request->input('bank_address'); - $booking->swift_code = $request->input('swift_code'); - $booking->cnap = $request->input('cnap'); - $booking->term = $request->input('term'); - $booking->amount = $request->input('amount'); - $booking->rate_id = $rate; + + $booking = new Booking(); + $booking->account_name = $request->input('account_name'); + $booking->account_num = $request->input('account_num'); + $booking->bank_name = $request->input('bank_name'); + $booking->bank_branch = $request->input('bank_branch'); + $booking->amount = $request->input('amount'); + $booking->term = $term; + $booking->rate_id = $rates->id; + $booking->rmb_book_amount = $request->input('amount'); + $booking->bia = $bia; + //$booking->user_id = $user-; + $booking->user()->associate($user); + $booking->save(); - $booking->rmb_book_amount = $request->input('rmb_book_amount'); - $booking->rmb_book_pay_method = $request->input('rmb_book_pay_method'); - $booking->rmb_book_account_name = $request->input('rmb_book_account_name'); - $booking->rmb_book_acc_no = $request->input('rmb_book_acc_no'); - $booking->rmb_book_bank_branch = $request->input('rmb_book_bank_branch'); - - $booking->usd_book_amount = $request->input('usd_book_amount'); - $booking->usd_book_pay_method = $request->input('usd_book_pay_method'); - $booking->usd_book_company_name = $request->input('usd_book_company_name'); - $booking->usd_book_company_address = $request->input('usd_book_company_address'); - $booking->usd_book_swift_code = $request->input('usd_book_swift_code'); - $booking->usd_book_cnap = $request->input('usd_book_cnap'); - $booking->usd_book_bank_branch = $request->input('usd_book_bank_branch'); - $booking->verification_status = $request->input('verification_status'); - - $booking->user()->associate($user); - $booking->bia = $bia; - $booking->save(); + // TODO : handle RMB, MYR and USD (we can use exchange type: USDtoMYR, RMBtoMYR vise versa to switch case) + // $booking->rmb_book_pay_method = $request->input('payment_method'); + // $booking->rmb_book_account_name = $request->input('rmb_book_account_name'); + // $booking->rmb_book_acc_no = $request->input('rmb_book_acc_no'); + // $booking->rmb_book_bank_branch = $request->input('rmb_book_bank_branch'); + // $booking->company_name = $request->input('company_name'); + // $booking->company_address = $request->input('company_address'); + // $booking->bank_address = $request->input('bank_address'); + // $booking->swift_code = $request->input('swift_code'); + // $booking->cnap = $request->input('cnap'); + // $booking->term = $request->input('term'); + // $booking->usd_book_amount = $request->input('usd_book_amount'); + // $booking->usd_book_pay_method = $request->input('usd_book_pay_method'); + // $booking->usd_book_company_name = $request->input('usd_book_company_name'); + // $booking->usd_book_company_address = $request->input('usd_book_company_address'); + // $booking->usd_book_swift_code = $request->input('usd_book_swift_code'); + // $booking->usd_book_cnap = $request->input('usd_book_cnap'); + // $booking->usd_book_bank_branch = $request->input('usd_book_bank_branch'); + // $booking->verification_status = $request->input('verification_status'); return response()->json($booking, 201); } @@ -161,6 +163,7 @@ class BookingController extends Controller 'bankslip_url',/*folder name*/ $bankslip_file, $unique_image_url ); + // why ? $booking->cust_marking = $request->input('cust_marking'); $booking->bank_slip_type = $request->input('bank_slip_type'); @@ -298,4 +301,4 @@ class BookingController extends Controller 'china_beneficary' => $china_beneficiary ], 200); } -} +} \ No newline at end of file diff --git a/resources/assets/js/pages/home.vue b/resources/assets/js/pages/home.vue index 03914fb8..125f9ce1 100644 --- a/resources/assets/js/pages/home.vue +++ b/resources/assets/js/pages/home.vue @@ -196,7 +196,7 @@