diff --git a/.env.prod b/.env.prod new file mode 100644 index 00000000..4b60c95c --- /dev/null +++ b/.env.prod @@ -0,0 +1,80 @@ +APP_NAME=IZYIM +APP_ENV=production +APP_KEY=base64:Fu2YulXExzm9HJ5LgVmZUmcbRkchHkc82q02MorN5GQ= +APP_DEBUG=true +APP_URL=http://localhost + +LOG_CHANNEL=stack + +DB_CONNECTION=mysql +DB_HOST=mysql +DB_PORT=3306 +DB_DATABASE=default +DB_USERNAME=default +DB_PASSWORD=secret + +BROADCAST_DRIVER=log +CACHE_DRIVER=file +SESSION_DRIVER=file +SESSION_LIFETIME=120 +QUEUE_DRIVER=sync + +REDIS_HOST=127.0.0.1 +REDIS_PASSWORD=null +REDIS_PORT=6379 + +MAIL_DRIVER=smtp +MAIL_HOST=smtp.mailtrap.io +MAIL_PORT=2525 +MAIL_USERNAME=null +MAIL_PASSWORD=null +MAIL_ENCRYPTION=null + +PUSHER_APP_ID= +PUSHER_APP_KEY= +PUSHER_APP_SECRET= +PUSHER_APP_CLUSTER=mt1 + +MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" +MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" +APP_NAME=exchange +APP_ENV=local +APP_KEY=base64:Fu2YulXExzm9HJ5LgVmZUmcbRkchHkc82q02MorN5GQ= +APP_DEBUG=true +APP_URL=http://localhost + +LOG_CHANNEL=stack + +DB_CONNECTION=mysql +DB_HOST=mysql +DB_PORT=3306 +DB_DATABASE=default +DB_USERNAME=default +DB_PASSWORD=secret + +BROADCAST_DRIVER=log +CACHE_DRIVER=file +SESSION_DRIVER=file +SESSION_LIFETIME=120 +QUEUE_DRIVER=sync + +REDIS_HOST=127.0.0.1 +REDIS_PASSWORD=null +REDIS_PORT=6379 + +MAIL_DRIVER=smtp +MAIL_HOST=smtp.mailtrap.io +MAIL_PORT=2525 +MAIL_USERNAME=null +MAIL_PASSWORD=null +MAIL_ENCRYPTION=null + +PUSHER_APP_ID= +PUSHER_APP_KEY= +PUSHER_APP_SECRET= +PUSHER_APP_CLUSTER=mt1 + +MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" +MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" + +JWT_SECRET=FwYZ3SPFgjpEDqAwcaSIV6eEmQiMtGWt \ No newline at end of file diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index 5c5fc19d..dcc1c17e 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -325,6 +325,8 @@ class BookingController extends Controller $booking->bank_name = $request->input('bank_name'); $booking->bank_branch = $request->input('bank_branch'); $booking->amount = $request->input('amount'); + $booking->order_no = $request->input('order_no'); + $booking->payment_for = $request->input('payment_for'); $booking->term = $term; $booking->rate_id = $rates->id; $booking->rate = $rate; @@ -422,19 +424,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); @@ -559,6 +568,8 @@ class BookingController extends Controller $amount = $request->input('amount'); $term = $request->input('term'); $china_beneficiary = $request->input('china_beneficiary'); + $order_no = $request->input('order_no'); + $payment_for = $request->input('payment_for'); $rates = Rate::orderby('updated_at','desc')->first(); $marking = $user = Auth::user()->marking; $taxrate = SettingTaxRate::latest()->first()->tax_rate; @@ -577,11 +588,11 @@ class BookingController extends Controller switch ($term) { case "x1_cash": $rate = $rates->x1_cash; - $payment_method = "cash"; + $payment_method = "CASH"; break; case "x1_cheque": $rate = $rates->x1_cheque; - $payment_method = "Cheque"; + $payment_method = "CHEQUE"; break; case "x1_ba": $rate = $rates->x1_ba; @@ -589,11 +600,11 @@ class BookingController extends Controller break; case "x2_cash": $rate = $rates->x2_cash; - $payment_method = "Cash"; + $payment_method = "CASH"; break; case "x2_cheque": $rate = $rates->x2_cheque; - $payment_method = "Cheque"; + $payment_method = "CHEQUE"; break; case "x2_ba": $rate = $rates->x2_ba; @@ -635,6 +646,8 @@ class BookingController extends Controller return response()->json([ 'date' => date('Y-m-d'), + 'order_no' => $order_no, + 'payment_for' => $payment_for, 'marking' => $marking, 'payment_method' => $payment_method, 'china_beneficary' => $china_beneficiary, @@ -845,23 +858,23 @@ class BookingController extends Controller } } - // public function adminShowCompletedOrders() - // { - // $bookings = Booking::select('id','created_at','user_id','rate','amount', 'bia', 'admin_status') - // ->where('admin_status', 7) - // ->orderBy('id', 'desc') - // ->get(); + public function adminShowCompletedOrders() + { + $bookings = Booking::select('id','created_at','user_id','rate','amount', 'bia', 'admin_status') + ->where('admin_status', 7) + ->orderBy('id', 'desc') + ->get(); - // foreach ($bookings as $booking) { - // $booking->id; - // $booking->created_at; - // $booking->marking = $booking->user->marking; - // $booking->rate; - // $booking->amount; - // $booking->bia; - // $booking->admin_status = "(". $booking->admin_status ."/7)";; - // } - // return $bookings; - // } + foreach ($bookings as $booking) { + $booking->id; + $booking->created_at; + $booking->marking = $booking->user->marking; + $booking->rate; + $booking->amount; + $booking->bia; + $booking->admin_status = "(". $booking->admin_status ."/7)";; + } + return $bookings; + } } diff --git a/app/Http/Controllers/BookingSupplierController.php b/app/Http/Controllers/BookingSupplierController.php index 93caaf06..800f6971 100644 --- a/app/Http/Controllers/BookingSupplierController.php +++ b/app/Http/Controllers/BookingSupplierController.php @@ -11,6 +11,8 @@ use App\UserBankSlip; use App\SettingBeneficiary; use App\SupplierBookingItem; use App\SettingSupplier; +use App\SettingTaxRate; +use App\SettingActiveBank; use Illuminate\Http\Request; class BookingSupplierController extends Controller @@ -30,15 +32,66 @@ class BookingSupplierController extends Controller public function show($id) { $booking = Booking::where('id', $id)->first(); + $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; + + $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); } @@ -47,41 +100,59 @@ class BookingSupplierController extends Controller // TODO : Multiple booking public function store(Request $request) { - $transfer_amount = $request->input("transfer_amount"); + //$transfer_amount = $request->input("transfer_amount"); $supplier_id = $request->input("supplier_id"); $booking_id = $request->input("booking_id"); - $rate = $request->input('rate'); + //$rate = $request->input('rate'); $rebate = $request->input('rebate'); - - // Calculation - $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($booking_id); + + + // Calculation (backup) + // $amountInRMB = $transfer_amount * $rate; + // $billing = 0.015 * $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 = round($customerBankInAmount + $rebate, 2); + + // Update: changes in 1.1 according to new supplier booking report + $transfer_amount = $booking->amount; + $rate = $booking->rate; + + $amount_in_myr = round($transfer_amount / $rate, 2); + $amountInRMB = $transfer_amount; + $tax_rate = SettingTaxRate::latest()->first()->tax_rate; + $sales_tax = round($tax_rate * $amount_in_myr - $amount_in_myr, 2); + $amount_after_tax = round($amount_in_myr * $tax_rate,2); + //$billing = 0.015 * $transfer_amount; + // + //$gst = 0 * $transfer_amount; // do we still need this ? + //$customerBankInAmount = round($transfer_amount + $gst + $sales_tax + $billing,2); + //$rmbBankAmount = round($customerBankInAmount + $rebate, 2); + // update existing booking supplier if exist $bookingsupplier = SupplierBooking::where('booking_id', $booking_id)->first(); if (!$bookingsupplier){ $bookingsupplier = new SupplierBooking(); - } $bookingsupplier->supplier_id = $supplier->id; - $bookingsupplier->payment_method = $request->input('payment_method'); - $bookingsupplier->transfer_amount = $transfer_amount; + $bookingsupplier->amountInRMB = $amountInRMB; // TODO : rename to underscore + $bookingsupplier->amount_in_myr = $amount_in_myr; + $bookingsupplier->tax_rate = $tax_rate; + $bookingsupplier->amount_after_tax = $amount_after_tax; $bookingsupplier->rate = $rate; - $bookingsupplier->billing_amount = $billing; - $bookingsupplier->salestax_amount = $sales_tax; - $bookingsupplier->rebate = $rebate; - $bookingsupplier->amountInRMB = $amountInRMB; - $bookingsupplier->rmbBankAmount = $rmbBankAmount; + $bookingsupplier->rebate = $rebate; + $bookingsupplier->salestax_amount = $sales_tax; + //$bookingsupplier->payment_method = $request->input('payment_method'); // TODO : remove from db + //$bookingsupplier->transfer_amount = $transfer_amount; // TODO : remove from db + //$bookingsupplier->billing_amount = $billing; // TODO : remove from db + + //$bookingsupplier->rmbBankAmount = $rmbBankAmount; // TODO : remove from db $bookingsupplier->booking_id = $booking->id; $bookingsupplier->save(); @@ -89,47 +160,12 @@ class BookingSupplierController extends Controller $booking->status = 4; $booking->admin_status = 4; $booking->save(); + + return response()->json($bookingsupplier, 201); } - - public function update(Request $request, $id) - { - $bookingsupplier = SupplierBooking::find($id); - $bookingsupplier->payment_method = $request->input('payment_method'); - $bookingsupplier->transfer_amount = $request->input('transfer_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(); - - /* For multiple booking */ - // $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(); diff --git a/app/Http/Controllers/SettingBeneficiaryController.php b/app/Http/Controllers/SettingBeneficiaryController.php index fdec75f7..eef947b1 100644 --- a/app/Http/Controllers/SettingBeneficiaryController.php +++ b/app/Http/Controllers/SettingBeneficiaryController.php @@ -12,8 +12,12 @@ class SettingBeneficiaryController extends Controller return SettingBeneficiary::all(); } - public function show(SettingBeneficiary $beneficiary) + public function show($beneficiary) { + if ($beneficiary == 0){ + response()->json(["company_name"=>"123", "account_number"=>"123"] , 201); + } + $beneficiary = SettingBeneficiary::find($beneficiary); return $beneficiary; } diff --git a/database/migrations/2018_07_20_145804_make_china_beneficiary_acc_nulabble_in_beneficiarysetting_table.php b/database/migrations/2018_07_20_145804_make_china_beneficiary_acc_nulabble_in_beneficiarysetting_table.php new file mode 100644 index 00000000..9fbde388 --- /dev/null +++ b/database/migrations/2018_07_20_145804_make_china_beneficiary_acc_nulabble_in_beneficiarysetting_table.php @@ -0,0 +1,33 @@ +dropForeign('setting_active_banks_beneficiary_id_foreign'); + $table->integer('beneficiary_id')->nullable()->unsigned()->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('beneficiarysetting', function (Blueprint $table) { + // + }); + } +} diff --git a/database/migrations/2018_07_20_175339_add_orderno_n_paymentfor_field_to_bookings_table.php b/database/migrations/2018_07_20_175339_add_orderno_n_paymentfor_field_to_bookings_table.php new file mode 100644 index 00000000..18a24a7e --- /dev/null +++ b/database/migrations/2018_07_20_175339_add_orderno_n_paymentfor_field_to_bookings_table.php @@ -0,0 +1,33 @@ +string('order_no')->nullable(); + $table->string('payment_for'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('bookings', function (Blueprint $table) { + // + }); + } +} diff --git a/database/migrations/2018_07_26_094305_add_fields_into_supplier_bookings_table.php b/database/migrations/2018_07_26_094305_add_fields_into_supplier_bookings_table.php new file mode 100644 index 00000000..c7320caa --- /dev/null +++ b/database/migrations/2018_07_26_094305_add_fields_into_supplier_bookings_table.php @@ -0,0 +1,32 @@ +string('amount_in_myr')->nullable(); + $table->string('tax_rate')->nullable(); + $table->string('amount_after_tax')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/database/seeds/BookTableSeeder.php b/database/seeds/BookTableSeeder.php index 5dfc3fd9..9bbc0d9a 100644 --- a/database/seeds/BookTableSeeder.php +++ b/database/seeds/BookTableSeeder.php @@ -18,8 +18,8 @@ class BookTableSeeder extends Seeder $rate = Rate::all()->last(); DB::table('bookings')->insert([ - 'account_name' => 'milah', - 'account_num' => '99898', + 'account_name' => 'EXCHANGE SDN BHD', + 'account_num' => '99898239298123', 'bank_name' => 'maybank', 'bank_branch' => 'rembau', 'company_name' => 'ICEF', @@ -36,6 +36,8 @@ class BookTableSeeder extends Seeder 'user_id' => $user->id, 'status' => 2, 'admin_status' => 2, + 'order_no' => '001', + 'payment_for' => 'FULL PAYMENT', 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'), ]); diff --git a/database/seeds/SettingActiveBankSeeder.php b/database/seeds/SettingActiveBankSeeder.php index 59ed5afd..953de4f3 100644 --- a/database/seeds/SettingActiveBankSeeder.php +++ b/database/seeds/SettingActiveBankSeeder.php @@ -13,8 +13,8 @@ class SettingActiveBankSeeder extends Seeder */ public function run() { - $bankx1 = SettingMalaysiaBank::where('acc_no', "=" ,'malaysiaacc01')->first(); - $bankx2 = SettingMalaysiaBank::where('acc_no', "=",'malaysiaacc02')->first(); + $bankx1 = SettingMalaysiaBank::find(1); + $bankx2 = SettingMalaysiaBank::find(2); $chinabank = SettingBeneficiary::where('acc_no', "=" ,'123456789')->first(); DB::table('setting_active_banks')->truncate(); diff --git a/database/seeds/SettingMalaysiaBankSeeder.php b/database/seeds/SettingMalaysiaBankSeeder.php index 21cc374a..7fed97fe 100644 --- a/database/seeds/SettingMalaysiaBankSeeder.php +++ b/database/seeds/SettingMalaysiaBankSeeder.php @@ -15,8 +15,8 @@ class SettingMalaysiaBankSeeder extends Seeder DB::table('setting_malaysia_banks')->truncate(); DB::table('setting_malaysia_banks')->insert([ 'company_name' => 'CIEF', - 'bank_name' => 'Maybank', - 'acc_no' => 'malaysiaacc01', + 'bank_name' => 'MAYBANK', + 'acc_no' => '75930284783', 'bank_address' => 'Jalan putrajaya', 'swift' => 'ABC123', 'cnap' => 'CED234', @@ -24,8 +24,8 @@ class SettingMalaysiaBankSeeder extends Seeder ]); DB::table('setting_malaysia_banks')->insert([ 'company_name' => 'CIEF', - 'bank_name' => 'Maybank', - 'acc_no' => 'malaysiaacc02', + 'bank_name' => 'MAYBANK', + 'acc_no' => '85839298348', 'bank_address' => 'Jalan putrajaya', 'swift' => 'ABC123', 'cnap' => 'CED234', diff --git a/package.json b/package.json index 5b860ffb..33534d51 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@fortawesome/fontawesome-free-brands": "^5.0.8", "@fortawesome/fontawesome-free-regular": "^5.0.8", "@fortawesome/fontawesome-free-solid": "^5.0.8", - "@fortawesome/vue-fontawesome": "^0.0.22", + "@fortawesome/vue-fontawesome": "0.0.22", "@xkeshi/vue-countdown": "^0.6.0", "axios": "^0.18.0", "bootstrap": "^4.0.0", @@ -27,7 +27,6 @@ "npm": "^6.0.1", "popper.js": "^1.14.1", "sweetalert2": "^7.15.1", - "vee-validate": "^2.1.0-beta.5", "vform": "^1.0.0", "vue": "^2.5.16", "vue-axios": "^2.1.1", diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 5b2beb01..e0e5bcc2 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -10,7 +10,6 @@ import locale from 'element-ui/lib/locale/lang/en' import '~/plugins' import '~/components' -import VeeValidate from 'vee-validate'; const config = { errorBagName: 'errors', // change if property conflicts. fieldsBagName: 'fields', @@ -29,7 +28,6 @@ const config = { events: 'blur', inject: true }; -Vue.use(VeeValidate, config); Vue.config.productionTip = false diff --git a/resources/assets/js/components/LocaleDropdown.vue b/resources/assets/js/components/LocaleDropdown.vue index 5f6efaba..b4a2e143 100644 --- a/resources/assets/js/components/LocaleDropdown.vue +++ b/resources/assets/js/components/LocaleDropdown.vue @@ -43,13 +43,13 @@ - X1:    Cash : - Cheque : - BA : + X1:    Cash : + Cheque : + BA :
- X2:    Cash : - Cheque : - BA : + X2:    Cash : + Cheque : + BA :

@@ -139,7 +139,7 @@ export default { this.rate = response.data }) }, - createRate: function () { + createRate: function () { // TODO : we do not have create rate, only update rate. Delete this ? this.loading = true, this.dialogFormVisible1 = true let newRate = { diff --git a/resources/assets/js/components/Navbar.vue b/resources/assets/js/components/Navbar.vue index 8cdc5c99..e01004de 100644 --- a/resources/assets/js/components/Navbar.vue +++ b/resources/assets/js/components/Navbar.vue @@ -61,7 +61,6 @@
-