seed(CountriesTableSeeder::class); $this->seed(CurrenciesTableSeeder::class); $this->seed(CompaniesTableSeeder::class); // create currency rate DB::table('currency_rates')->insert(array ( 0 => array ( 'id' => 1, 'currency_id' => 2, 'selling' => $this->curr_rate_std_cash, 'payment_method_type' => 1, 'service_id' => 1, ), 1 => array ( 'id' => 2, 'currency_id' => 2, 'selling' => $this->curr_rate_std_cheque, 'payment_method_type' => 2, 'service_id' => 1, ), 2 => array ( 'id' => 3, 'currency_id' => 2, 'selling' => $this->curr_rate_std_wallet, 'payment_method_type' => 4, 'service_id' => 1, ), 3 => array ( 'id' => 4, 'currency_id' => 2, 'selling' => $this->curr_rate_std_online, 'payment_method_type' => 5, 'service_id' => 1, ) )); // create service DB::table('service_types')->insert([ 'id' => 1, 'name' => 'X1 Transfer', 'status' => 2, ]); // create standard segment DB::table('segments')->insert([ 'id' => 1, 'name' => 'Standard Segment', 'type' => SegmentConstants::STANDARD_SEGMENT, 'status' => 2 ]); // create platinum segment DB::table('segments')->insert([ 'id' => 2, 'name' => 'platinum member', 'type' => SegmentConstants::CUSTOM_SEGMENT, 'status' => 2, ]); // create standard segment constant DB::table('segment_constants')->insert([ 'id' => 1, 'segment_id' => 1, 'name' => 'Service Type', 'reference' => 'SERVICE_TYPE', 'detail' => '{"id":1,"bank_id":1,"service_charge":{"type":"percentage","value":2},"minimum_charge":{"type":"fixed_amount","value":10},"tax":{"type":"percentage","value":0},"po_limit":{"type":"fixed_amount","value":3},"is_active":true,"is_billable":true,"currencies":[{"id":2,"max_limit":{"type":"fixed_amount","value":500000},"min_limit":{"type":"fixed_amount","value":100},"rates":[]}]}', ]); // create platinum segment constant DB::table('segment_constants')->insert([ 'id' => 2, 'segment_id' => 2, 'name' => 'Custom Service Type', 'reference' => 'CUSTOM_SERVICE_TYPE', 'detail' => '{"id":1,"minimum_charge":{"type":"fixed_amount","value":0},"is_active":true,"is_billable":true,"currencies":[{"id":2,"max_limit":{"type":"fixed_amount","value":500000},"min_limit":{"type":"fixed_amount","value":0.01},"rates":[{"payment_type":1,"payment_method":"cash","selling":{"type":"rate","value":"1.54100"}},{"payment_type":2,"payment_method":"cheque","selling":{"type":"rate","value":"1.53100"}},{"payment_type":4,"payment_method":"wallet","selling":{"type":"rate","value":"1.54700"}},{"payment_type":5,"payment_method":"payment_gateway","selling":{"type":"rate","value":"1.54400"}}]}]}', ]); // create a user $this->postJson(route('api.account.registration.register', [ "company_name" => "", "name" => "user one", "email" => "user1@mail.com", "password" => "password", "password_confirmation" => "password", "phone" => "0123456789", "type" => 0 ])); $response = $this->postJson(route('api.account.authentication.authenticate.attempt', [ 'email' => 'user1@mail.com', 'password' => 'password' ])); $company = Company::where('name', 'user one')->first(); // create recipient bank DB::table('banks')->insert([ 'company_id' => $company->id, 'bank_name' => 'Maybank', 'holder_name' => 'user one recipient', 'account_no' => '123456789', 'country_id' => 2, 'status' => 2, 'type' => 2, ]); $token = json_decode($response->getContent(), true)['payload']['access_token']; $this->withHeaders([ 'Accept' => 'application/json', 'Authorization' => "Bearer $token", 'Captcha-Token' => "test" ]); $recipient_bank = $company->banks->where('type', BankAccountType::EXTERNAL)->first(); // create booking $this->postJson(route('api.booking.create', ['company_id' => $company->id]), [ 'convertible_currency_id' => 2, 'fix_amount' => 1000, 'service_id' => 1, 'transferable_bank_id' => $recipient_bank->id, 'type' => 1, ]); } public function test_standard_customer_fetch_booking_payment_quotation_cash() { $booking = Booking::first(); $foreign_total = 1000; $local_total = 1000 / $this->curr_rate_std_cash; $conversion_amount = $local_total; $service_charge = $conversion_amount * 0.02; $sub_total = $local_total + $service_charge; $response = $this->postJson(route('api.booking.payment.quotation', [ 'id' => $booking->id, 'amount' => 1000, 'payment_method' => 'cash', 'voucherCode' => '' ])); $response->assertStatus(200)->assertJsonStructure([ "title", "message", "payload" => [ "data" => [ "conversion_amount", "foreign_total", "local_total", "rate", "service_charge", "sub_total", "tax", "tax_total", "total", "voucher_code", "voucher_discount_amount" ] ] ]); $data = json_decode($response->getContent(), true)['payload']['data']; $this->assertEqualsWithDelta($conversion_amount, $data['conversion_amount'], 0.0000001); $this->assertEqualsWithDelta($foreign_total, $data['foreign_total'], 0.0000001); $this->assertEqualsWithDelta($local_total, $data['local_total'], 0.0000001); $this->assertEqualsWithDelta($this->curr_rate_std_cash, $data['rate'], 0.0000001); $this->assertEqualsWithDelta($service_charge, $data['service_charge'], 0.0000001); $this->assertEqualsWithDelta($sub_total, $data['sub_total'], 0.0000001); $this->assertEquals(0, $data['tax']); $this->assertEquals(0, $data['tax_total']); $this->assertEqualsWithDelta($sub_total, $data['total'], 0.0000001); $this->assertEquals("", $data['voucher_code']); $this->assertEquals(0, $data['voucher_discount_amount']); } public function test_standard_customer_fetch_booking_payment_quotation_cheque() { $booking = Booking::first(); $foreign_total = 1000; $local_total = 1000 / $this->curr_rate_std_cheque; $conversion_amount = $local_total; $service_charge = $conversion_amount * 0.02; $sub_total = $local_total + $service_charge; $response = $this->postJson(route('api.booking.payment.quotation', ['id' => $booking->id]), [ 'amount' => 1000, 'payment_method' => 'cheque', 'voucherCode' => '' ]); $response->assertStatus(200)->assertJsonStructure([ "title", "message", "payload" => [ "data" => [ "conversion_amount", "foreign_total", "local_total", "rate", "service_charge", "sub_total", "tax", "tax_total", "total", "voucher_code", "voucher_discount_amount" ] ] ]); $data = json_decode($response->getContent(), true)['payload']['data']; $this->assertEqualsWithDelta($conversion_amount, $data['conversion_amount'], 0.0000001); $this->assertEqualsWithDelta($foreign_total, $data['foreign_total'], 0.0000001); $this->assertEqualsWithDelta($local_total, $data['local_total'], 0.0000001); $this->assertEqualsWithDelta($this->curr_rate_std_cheque, $data['rate'], 0.0000001); $this->assertEqualsWithDelta($service_charge, $data['service_charge'], 0.0000001); $this->assertEqualsWithDelta($sub_total, $data['sub_total'], 0.0000001); $this->assertEquals(0, $data['tax']); $this->assertEquals(0, $data['tax_total']); $this->assertEqualsWithDelta($sub_total, $data['total'], 0.0000001); $this->assertEquals("", $data['voucher_code']); $this->assertEquals(0, $data['voucher_discount_amount']); } public function test_standard_customer_fetch_booking_payment_quotation_wallet() { $booking = Booking::first(); $foreign_total = 1000; $local_total = 1000 / $this->curr_rate_std_wallet; $conversion_amount = $local_total; $service_charge = $conversion_amount * 0.02; $sub_total = $local_total + $service_charge; $response = $this->postJson(route('api.booking.payment.quotation', ['id' => $booking->id]), [ 'amount' => 1000, 'payment_method' => 'wallet', 'voucherCode' => '' ]); $response->assertStatus(200)->assertJsonStructure([ "title", "message", "payload" => [ "data" => [ "conversion_amount", "foreign_total", "local_total", "rate", "service_charge", "sub_total", "tax", "tax_total", "total", "voucher_code", "voucher_discount_amount" ] ] ]); $data = json_decode($response->getContent(), true)['payload']['data']; $this->assertEqualsWithDelta($conversion_amount, $data['conversion_amount'], 0.0000001); $this->assertEqualsWithDelta($foreign_total, $data['foreign_total'], 0.0000001); $this->assertEqualsWithDelta($local_total, $data['local_total'], 0.0000001); $this->assertEqualsWithDelta($this->curr_rate_std_wallet, $data['rate'], 0.0000001); $this->assertEqualsWithDelta($service_charge, $data['service_charge'], 0.0000001); $this->assertEqualsWithDelta($sub_total, $data['sub_total'], 0.0000001); $this->assertEquals(0, $data['tax']); $this->assertEquals(0, $data['tax_total']); $this->assertEqualsWithDelta($sub_total, $data['total'], 0.0000001); $this->assertEquals("", $data['voucher_code']); $this->assertEquals(0, $data['voucher_discount_amount']); } public function test_standard_customer_fetch_booking_payment_quotation_online() { $booking = Booking::first(); $foreign_total = 1000; $local_total = 1000 / $this->curr_rate_std_online; $conversion_amount = $local_total; $service_charge = $conversion_amount * 0.02; $sub_total = $local_total + $service_charge; $response = $this->postJson(route('api.booking.payment.quotation', ['id' => $booking->id]), [ 'amount' => 1000, 'payment_method' => 'payment_gateway', 'voucherCode' => '' ]); $response->assertStatus(200)->assertJsonStructure([ "title", "message", "payload" => [ "data" => [ "conversion_amount", "foreign_total", "local_total", "rate", "service_charge", "sub_total", "tax", "tax_total", "total", "voucher_code", "voucher_discount_amount" ] ] ]); $data = json_decode($response->getContent(), true)['payload']['data']; $this->assertEqualsWithDelta($conversion_amount, $data['conversion_amount'], 0.0000001); $this->assertEqualsWithDelta($foreign_total, $data['foreign_total'], 0.0000001); $this->assertEqualsWithDelta($local_total, $data['local_total'], 0.0000001); $this->assertEqualsWithDelta($this->curr_rate_std_online, $data['rate'], 0.0000001); $this->assertEqualsWithDelta($service_charge, $data['service_charge'], 0.0000001); $this->assertEqualsWithDelta($sub_total, $data['sub_total'], 0.0000001); $this->assertEquals(0, $data['tax']); $this->assertEquals(0, $data['tax_total']); $this->assertEqualsWithDelta($sub_total, $data['total'], 0.0000001); $this->assertEquals("", $data['voucher_code']); $this->assertEquals(0, $data['voucher_discount_amount']); } public function test_platinum_customer_fetch_booking_payment_quotation_cash() { $company = Company::where('name', 'user one')->first(); DB::table('segment_companies')->insert([ 'segment_id' => 2, 'company_id' => $company->id, ]); $booking = Booking::first(); $foreign_total = 1000; $local_total = 1000 / $this->curr_rate_plat_cash; $conversion_amount = $local_total; $service_charge = $conversion_amount * 0.02; $sub_total = $local_total + $service_charge; $response = $this->postJson(route('api.booking.payment.quotation', [ 'id' => $booking->id, 'amount' => 1000, 'payment_method' => 'cash', 'voucherCode' => '' ])); $response->assertStatus(200)->assertJsonStructure([ "title", "message", "payload" => [ "data" => [ "conversion_amount", "foreign_total", "local_total", "rate", "service_charge", "sub_total", "tax", "tax_total", "total", "voucher_code", "voucher_discount_amount" ] ] ]); $data = json_decode($response->getContent(), true)['payload']['data']; $this->assertEqualsWithDelta($conversion_amount, $data['conversion_amount'], 0.0000001); $this->assertEqualsWithDelta($foreign_total, $data['foreign_total'], 0.0000001); $this->assertEqualsWithDelta($local_total, $data['local_total'], 0.0000001); $this->assertEqualsWithDelta($this->curr_rate_plat_cash, $data['rate'], 0.0000001); $this->assertEqualsWithDelta($service_charge, $data['service_charge'], 0.0000001); $this->assertEqualsWithDelta($sub_total, $data['sub_total'], 0.0000001); $this->assertEquals(0, $data['tax']); $this->assertEquals(0, $data['tax_total']); $this->assertEqualsWithDelta($sub_total, $data['total'], 0.0000001); $this->assertEquals("", $data['voucher_code']); $this->assertEquals(0, $data['voucher_discount_amount']); } public function test_platinum_customer_fetch_booking_payment_quotation_cheque() { $company = Company::where('name', 'user one')->first(); DB::table('segment_companies')->insert([ 'segment_id' => 2, 'company_id' => $company->id, ]); $booking = Booking::first(); $foreign_total = 1000; $local_total = 1000 / $this->curr_rate_plat_cheque; $conversion_amount = $local_total; $service_charge = $conversion_amount * 0.02; $sub_total = $local_total + $service_charge; $response = $this->postJson(route('api.booking.payment.quotation', ['id' => $booking->id]), [ 'amount' => 1000, 'payment_method' => 'cheque', 'voucherCode' => '' ]); $response->assertStatus(200)->assertJsonStructure([ "title", "message", "payload" => [ "data" => [ "conversion_amount", "foreign_total", "local_total", "rate", "service_charge", "sub_total", "tax", "tax_total", "total", "voucher_code", "voucher_discount_amount" ] ] ]); $data = json_decode($response->getContent(), true)['payload']['data']; $this->assertEqualsWithDelta($conversion_amount, $data['conversion_amount'], 0.0000001); $this->assertEqualsWithDelta($foreign_total, $data['foreign_total'], 0.0000001); $this->assertEqualsWithDelta($local_total, $data['local_total'], 0.0000001); $this->assertEqualsWithDelta($this->curr_rate_plat_cheque, $data['rate'], 0.0000001); $this->assertEqualsWithDelta($service_charge, $data['service_charge'], 0.0000001); $this->assertEqualsWithDelta($sub_total, $data['sub_total'], 0.0000001); $this->assertEquals(0, $data['tax']); $this->assertEquals(0, $data['tax_total']); $this->assertEqualsWithDelta($sub_total, $data['total'], 0.0000001); $this->assertEquals("", $data['voucher_code']); $this->assertEquals(0, $data['voucher_discount_amount']); } public function test_platinum_customer_fetch_booking_payment_quotation_wallet() { $company = Company::where('name', 'user one')->first(); DB::table('segment_companies')->insert([ 'segment_id' => 2, 'company_id' => $company->id, ]); $booking = Booking::first(); $foreign_total = 1000; $local_total = 1000 / $this->curr_rate_plat_wallet; $conversion_amount = $local_total; $service_charge = $conversion_amount * 0.02; $sub_total = $local_total + $service_charge; $response = $this->postJson(route('api.booking.payment.quotation', ['id' => $booking->id]), [ 'amount' => 1000, 'payment_method' => 'wallet', 'voucherCode' => '' ]); $response->assertStatus(200)->assertJsonStructure([ "title", "message", "payload" => [ "data" => [ "conversion_amount", "foreign_total", "local_total", "rate", "service_charge", "sub_total", "tax", "tax_total", "total", "voucher_code", "voucher_discount_amount" ] ] ]); $data = json_decode($response->getContent(), true)['payload']['data']; $this->assertEqualsWithDelta($conversion_amount, $data['conversion_amount'], 0.0000001); $this->assertEqualsWithDelta($foreign_total, $data['foreign_total'], 0.0000001); $this->assertEqualsWithDelta($local_total, $data['local_total'], 0.0000001); $this->assertEqualsWithDelta($this->curr_rate_plat_wallet, $data['rate'], 0.0000001); $this->assertEqualsWithDelta($service_charge, $data['service_charge'], 0.0000001); $this->assertEqualsWithDelta($sub_total, $data['sub_total'], 0.0000001); $this->assertEquals(0, $data['tax']); $this->assertEquals(0, $data['tax_total']); $this->assertEqualsWithDelta($sub_total, $data['total'], 0.0000001); $this->assertEquals("", $data['voucher_code']); $this->assertEquals(0, $data['voucher_discount_amount']); } public function test_platinum_customer_fetch_booking_payment_quotation_online() { $company = Company::where('name', 'user one')->first(); DB::table('segment_companies')->insert([ 'segment_id' => 2, 'company_id' => $company->id, ]); $booking = Booking::first(); $foreign_total = 1000; $local_total = 1000 / $this->curr_rate_plat_online; $conversion_amount = $local_total; $service_charge = $conversion_amount * 0.02; $sub_total = $local_total + $service_charge; $response = $this->postJson(route('api.booking.payment.quotation', ['id' => $booking->id]), [ 'amount' => 1000, 'payment_method' => 'payment_gateway', 'voucherCode' => '' ]); $response->assertStatus(200)->assertJsonStructure([ "title", "message", "payload" => [ "data" => [ "conversion_amount", "foreign_total", "local_total", "rate", "service_charge", "sub_total", "tax", "tax_total", "total", "voucher_code", "voucher_discount_amount" ] ] ]); $data = json_decode($response->getContent(), true)['payload']['data']; $this->assertEqualsWithDelta($conversion_amount, $data['conversion_amount'], 0.0000001); $this->assertEqualsWithDelta($foreign_total, $data['foreign_total'], 0.0000001); $this->assertEqualsWithDelta($local_total, $data['local_total'], 0.0000001); $this->assertEqualsWithDelta($this->curr_rate_plat_online, $data['rate'], 0.0000001); $this->assertEqualsWithDelta($service_charge, $data['service_charge'], 0.0000001); $this->assertEqualsWithDelta($sub_total, $data['sub_total'], 0.0000001); $this->assertEquals(0, $data['tax']); $this->assertEquals(0, $data['tax_total']); $this->assertEqualsWithDelta($sub_total, $data['total'], 0.0000001); $this->assertEquals("", $data['voucher_code']); $this->assertEquals(0, $data['voucher_discount_amount']); } }