fixed conflict

This commit is contained in:
Nweni
2017-06-09 10:58:40 +06:30
95 changed files with 2525 additions and 598 deletions

View File

@@ -9,8 +9,7 @@ end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.0'
# Use mysql as the database for Active Record
#gem 'mysql2', '>= 0.3.18', '< 0.5'
gem 'mysql2', '>= 0.3.18', '< 0.5'
#Use PosgreSQL
gem 'pg'
@@ -44,9 +43,6 @@ gem 'to_xls-rails'
#Reporting gem
#gem 'compendium'
# Pagination
gem 'kaminari', :git => "git://github.com/amatsuda/kaminari.git", :branch => 'master'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
@@ -61,7 +57,8 @@ gem 'bcrypt', '~> 3.1.7'
gem 'sidekiq'
# Pagination
gem 'kaminari', :git => "git://github.com/amatsuda/kaminari.git", :branch => 'master'
gem 'kaminari', '~> 0.16.3'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

View File

@@ -1,21 +1,3 @@
GIT
remote: git://github.com/amatsuda/kaminari.git
revision: bc52ae73d41386d344b5d1b18e689e5a988f1a03
branch: master
specs:
kaminari (1.0.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.0.1)
kaminari-activerecord (= 1.0.1)
kaminari-core (= 1.0.1)
kaminari-actionview (1.0.1)
actionview
kaminari-core (= 1.0.1)
kaminari-activerecord (1.0.1)
activerecord
kaminari-core (= 1.0.1)
kaminari-core (1.0.1)
GEM
remote: https://rubygems.org/
specs:
@@ -104,6 +86,9 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
kaminari (0.16.3)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
@@ -119,6 +104,7 @@ GEM
minitest (5.10.2)
multi_json (1.12.1)
multi_xml (0.6.0)
mysql2 (0.4.6)
nio4r (2.1.0)
nokogiri (1.7.2)
mini_portile2 (~> 2.1.0)
@@ -256,8 +242,10 @@ DEPENDENCIES
httparty (~> 0.15.5)
jbuilder (~> 2.5)
jquery-rails
kaminari!
kaminari (~> 0.16.3)
listen (~> 3.0.5)
mysql2 (>= 0.3.18, < 0.5)
pg
prawn
prawn-table
@@ -281,4 +269,4 @@ DEPENDENCIES
web-console (>= 3.3.0)
BUNDLED WITH
1.15.0
1.15.1

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -18,3 +18,4 @@
//= require cable
//= require settings/processing_items
//= require bootstrap-datepicker

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -1,102 +0,0 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require bootstrap
//= require jquery_ujs
//= require turbolinks
//= require cable
$(document).ready(function(){
$(".orders").on('click', function(){
var zone_name=$(this).find(".orders-table").text();
var receipt_no=$(this).find(".orders-receipt-no").text();
var unique_id=$(this).find(".orders-id").text();
var cashier="";
var receipt_date="";
var sub_total=0;
var discount_amount=0;
var tax_amount=0;
var grand_total_amount=0;
$("#order-title").text("ORDER DETAILS - " + zone_name);
// clear order items
$("#order-items-table").children("tbody").empty();
// AJAX call for order
$.ajax({
type: "GET",
url: "origami/" + unique_id,
data: { 'id' : unique_id },
success:function(result){
for (i = 0; i < result.length; i++) {
var data = JSON.stringify(result[i]);
var parse_data = JSON.parse(data);
// Receipt Header
receipt_no = result[i].receipt_no;
cashier = result[i].cashier_name;
receipt_date = result[i].receipt_date;
$("#receipt_no").text(receipt_no);
$("#cashier").text(cashier==null?"":cashier);
$("#receipt_date").text(receipt_date);
//Receipt Charges
sub_total += (parse_data.qty*parse_data.price);
discount_amount = parse_data.discount_amount;
tax_amount = parse_data.tax_amount;
grand_total_amount = parse_data.grand_total_amount;
$("#order-sub-total").text(sub_total);
$("#order-food").text('');
$("#order-beverage").text('');
$("#order-discount").text(discount_amount);
$("#order-Tax").text(tax_amount);
$("#order-grand-total").text(grand_total_amount);
// Ordered Items
var order_items_rows = "<tr>" +
"<td class='item-name'>" + parse_data.item_name + "</td>" +
"<td class='item-attr'>" + parse_data.qty + "</td>" +
"<td class='item-attr'>" + parse_data.qty*parse_data.price + "</td>" +
"</tr>";
$("#order-items-table").children("tbody").append(order_items_rows);
}
}
});
// End AJAX Call
$('.orders').removeClass('selected-item');
$(this).addClass('selected-item');
});
// Bill Request
$('#request_bills').click(function() {
var order_id=$(".selected-item").find(".orders-id").text();
window.location.href = '/origami/request_bills/'+ order_id
return false;
});
// Payment for Bill
$('#pay').click(function() {
var sale_id=$(".selected-item").find(".orders-id").text();
window.location.href = '/origami/sale/'+ sale_id + "/payment"
return false;
});
});

View File

@@ -0,0 +1,243 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require bootstrap
//= require jquery_ujs
//= require turbolinks
//= require cable
$(document).ready(function(){
$(".orders").on('click', function(){
var zone_name=$(this).find(".orders-table").text();
var receipt_no=$(this).find(".orders-receipt-no").text();
var unique_id=$(this).find(".orders-id").text();
var order_status=$(this).find(".orders-order-status").text().trim();
// Enable/Disable Button
control_button(order_status);
//for customer button
if(unique_id.charAt(0) == 'S'){
$("#customer").removeAttr('disabled');
}else{
$("#customer").attr('disabled','disabled');
}
var cashier="";
var receipt_date="";
var sub_total=0;
var discount_amount=0;
var tax_amount=0;
var grand_total_amount=0;
$("#order-title").text("ORDER DETAILS - " + zone_name);
// clear order items
$("#order-items-table").children("tbody").empty();
// AJAX call for order
$.ajax({
type: "GET",
url: "origami/" + unique_id,
data: { 'id' : unique_id },
success:function(result){
for (i = 0; i < result.length; i++) {
var data = JSON.stringify(result[i]);
var parse_data = JSON.parse(data);
// Receipt Header
receipt_no = result[i].receipt_no;
cashier = result[i].cashier_name;
receipt_date = result[i].receipt_date;
$("#receipt_no").text(receipt_no);
$("#cashier").text(cashier==null?"":cashier);
$("#receipt_date").text(receipt_date);
//Receipt Charges
sub_total += (parse_data.qty*parse_data.price);
discount_amount = parse_data.discount_amount;
tax_amount = parse_data.tax_amount;
grand_total_amount = parse_data.grand_total_amount;
$("#order-sub-total").text(sub_total);
$("#order-food").text('');
$("#order-beverage").text('');
$("#order-discount").text(discount_amount);
$("#order-Tax").text(tax_amount);
$("#order-grand-total").text(grand_total_amount);
// Ordered Items
var order_items_rows = "<tr>" +
"<td class='item-name'>" + parse_data.item_name + "</td>" +
"<td class='item-attr'>" + parse_data.qty + "</td>" +
"<td class='item-attr'>" + parse_data.qty*parse_data.price + "</td>" +
"</tr>";
$("#order-items-table").children("tbody").append(order_items_rows);
}
}
});
// End AJAX Call
$('.orders').removeClass('selected-item');
$(this).addClass('selected-item');
});
// Bill Request
$('#request_bills').click(function() {
var order_id=$(".selected-item").find(".orders-id").text();
if(order_id!=""){
window.location.href = '/origami/request_bills/'+ order_id
}
else {
alert("Please select an order!");
}
return false;
});
// Discount for Payment
$('#discount').click(function() {
var order_id=$(".selected-item").find(".orders-id").text();
if(order_id!=""){
window.location.href = '/origami/discount/'+ order_id
}
else {
alert("Please select an order!");
}
return false;
});
// Pay Discount for Payment
$("#pay-discount").on('click', function(){
var sale_id = $('#sale-id').text();
var sub_total = $('#order-sub-total').text();
var grand_total = $('#order-grand-total').text();
var discount_type = $('#discount-type').val();
var discount_value = $('#discount-amount').val();
var discount_amount = discount_value;
// For Percentage Discount
if(discount_type == 1){
discount_amount=(sub_total*discount_value)/100;
}
var params = {'sale_id': sale_id, 'grand_total' : grand_total, 'discount_type':discount_type, 'discount_value':discount_value, 'discount_amount':discount_amount};
$.ajax({
type: "POST",
url: "/origami/discount",
data: params,
success:function(result){ }
});
});
// Payment for Bill
$('#pay').click(function() {
var sale_id=$(".selected-item").find(".orders-id").text();
if(sale_id!=""){
window.location.href = '/origami/sale/'+ sale_id + "/payment"
}
else {
alert("Please select an order!");
}
return false;
});
$('#customer').click(function() {
var sale_id=$(".selected-item").find(".orders-id").text();
window.location.href = '/crm/customers/'+ sale_id + "/assign_sale_id"
return false;
});
});
/* For Receipt - Calculate discount or tax */
$(document).on('click', '.cashier_number', function(event){
if(event.handled !== true) {
var original_value=0;
original_value = $('#discount-amount').val();
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
var input_value = $(this).attr("data-value");
if (original_value == "0.0"){
$('#discount-amount').val(input_value);
update_balance();
}
else{
$('#discount-amount').val(original_value + '' + input_value);
update_balance();
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#discount-amount').val(amount);
update_balance();
break;
case 'del' :
var discount_text=$('#discount-amount').val();
$('#discount-amount').val(discount_text.substr(0,discount_text.length-1));
update_balance();
break;
case 'clr':
$('#discount-amount').val("0.0");
update_balance();
break;
}
event.handled = true;
} else {
return false;
}
});
/* Button Control by Status */
function control_button(order_status){
if(order_status=="billed"){
$("#request_bills").prop('disabled', true);
$("#discount").prop('disabled', false);
$("#pay").prop('disabled', false);
}
else if(order_status=="new") {
$("#request_bills").prop('disabled', false);
$("#discount").prop('disabled', true);
$("#pay").prop('disabled', true);
}
}
/* For Receipt - Update Balance */
function update_balance(){
var discount_type = $('#discount-type').val();
var discount_amount = $('#discount-amount').val();
var sub_total = $('#order-sub-total').text();
var tax = $('#order-Tax').text();
// For Percentage Discount
if(discount_type == 1){
discount_amount=(sub_total*discount_amount)/100;
}
var total = (parseFloat(sub_total) + parseFloat(tax)) - discount_amount;
$('#order-discount').text(discount_amount);
$('#order-grand-total').text(total);
}

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the api/origami/paypar controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the membership_actions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -69,3 +69,10 @@
.green{
background-color: #009900
}
/*----- Reset -----*/
select.form-control {
height: inherit !important;
}

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the origami/paypar controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the settings/membership_actions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -1,7 +1,7 @@
class Api::MembershipsController < ActionController::API
before :authenticate_token
#Add Membership to invoice
def create

View File

@@ -4,10 +4,13 @@ class Crm::CustomersController < ApplicationController
# GET /crm/customers
# GET /crm/customers.json
def index
@crm_customers = Customer.all
@customers = Customer.new
@sale_id = 0
@crm_customers = Customer.all
@crm_customer = Customer.new
@membership = Customer.get_member_group
if @membership["status"] == true
@member_group = @membership["data"]
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @crm_customers }
@@ -33,15 +36,68 @@ class Crm::CustomersController < ApplicationController
# POST /crm/customers
# POST /crm/customers.json
def create
@crm_customer = Customer.new(customer_params)
@crm_customers = Customer.new(customer_params)
respond_to do |format|
if @crm_customer.save
format.html { redirect_to @crm_customer, notice: 'Customer was successfully created.' }
format.json { render :show, status: :created, location: @crm_customer }
if @crm_customers.save
name = customer_params[:name]
phone = customer_params[:contact_no]
email = customer_params[:email]
date_of_birth = customer_params[:date_of_birth]
membership_id = params[:membership_id]
membership = MembershipSetting.find_by_membership_type("paypar_url")
app_token = membership.auth_token.to_s
url = membership.gateway_url.to_s + "/api/create_membership_customer".to_s
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
date_of_birth: date_of_birth,
membership_id: membership_id}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
)
if response["status"] == true
puts "hhhhhhhhhhhhhhhhhh"
puts params[:sale_id]
customer = Customer.find(@crm_customers.customer_id)
status = customer.update_attributes(membership_id: response["customer_datas"]["id"])
if params[:sale_id] != 0
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' }
else
format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: 'Customer was successfully created.' }
end
# format.json { render :index, status: :created, location: @crm_customers }
else
@crm_customers.destroy
if params[:sale_id] != 0
format.html { redirect_to crm_customers_path, notice: response["message"] }
else
format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: response["message"] }
end
end
# format.json { render :index, status: :created, location: @crm_customers }
else
format.html { render :new }
format.json { render json: @crm_customer.errors, status: :unprocessable_entity }
if params[:sale_id] != 0
format.html { redirect_to crm_customers_path}
format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
else
format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: response["message"] }
end
end
end
end
@@ -49,14 +105,38 @@ class Crm::CustomersController < ApplicationController
# PATCH/PUT /crm/customers/1
# PATCH/PUT /crm/customers/1.json
def update
respond_to do |format|
if @crm_customer.update(customer_params)
format.html { redirect_to @crm_customer, notice: 'Customer was successfully updated.' }
name = customer_params[:name]
phone = customer_params[:contact_no]
email = customer_params[:email]
date_of_birth = customer_params[:date_of_birth]
id = customer_params[:membership_id]
membership = MembershipSetting.find_by_membership_type("paypar_url")
app_token = membership.auth_token.to_s
url = membership.gateway_url.to_s + "/api/update_membership_customer".to_s
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
date_of_birth: date_of_birth,
id: id}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
)
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' }
format.json { render :show, status: :ok, location: @crm_customer }
else
format.html { render :edit }
format.json { render json: @crm_customer.errors, status: :unprocessable_entity }
end
end
end
@@ -70,6 +150,23 @@ class Crm::CustomersController < ApplicationController
end
end
# DELETE /crm/customers/1
# DELETE /crm/customers/1.json
def get_sale_id
@sale_id = params[:sale_id]
@crm_customers = Customer.all
@crm_customer = Customer.new
@membership = Customer.get_member_group
if @membership["status"] == true
@member_group = @membership["data"]
end
respond_to do |format|
format.html { render action: "index"}
format.json { render json: @crm_customers }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_crm_customer
@@ -78,6 +175,9 @@ class Crm::CustomersController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def customer_params
params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth, :membership_id, :membership_type, :membership_authentication_code)
params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth, :membership_type, :membership_authentication_code)
end
end

View File

@@ -3,22 +3,53 @@ class Crm::HomeController < BaseCrmController
@booking = Booking.all
@customer = Customer.all
#@booking = Booking.select("bookings.id as booking_id,
# bookings.checkin_at,
# bookings.checkin_by,
# bookings.dining_facility_id,
# od.customer_id as customer,
# od.id as order_id,
# od.item_count as count,
# odt.id as order_item_id,
# odt.item_name as item_name")
# .joins("join booking_orders as bko ON bko.booking_id = bookings.id")
# .joins("right join orders as od ON od.id = bko.order_id")
# .joins("right join order_items as odt ON odt.order_id=od.id")
# .order("bookings.id DESC")
end
def show
end
#print for crm
def print_order
@booking = Booking.find(params[:id])
@total_amount = 0.00
@total_tax = 0.00
if @booking.booking_orders
order_items = []
@booking.booking_orders.each do |bo|
order = Order.find(bo.order_id)
#if (order.status == "new")
order_items = order_items + order.order_items
#end
end
end
unique_code="CrmOrderPdf"
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_crm_order(@booking,order_items,print_settings)
end
def update_sale_by_customer
sale = Sale.find(params[:sale_id])
status = sale.update_attributes(customer_id: params[:customer_id])
if status == true
render json: JSON.generate({:status => true})
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})
end
end
end

View File

@@ -0,0 +1,29 @@
class Origami::CardPaymentsController < BaseOrigamiController
def index
@membership_rebate_balance = 0
@membership_id = 0
if !@membership_id.nil?
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_data = SalePayment.get_paypar_account(membership_setting.gateway_url,membership_setting.auth_token,@membership_id)
if membership_data["status"]==true
membership_account_data = membership_data["data"];
membership_account_data.each do |acc_data|
if acc_data["accountable_type"] == "REBATEACCOUNT"
@membership_rebate_balance=acc_data["balance"]
else
@membership_rebate_balance = 0
end
end
else
@membership_rebate_balance = 0
end
end
end
def create
end
end

View File

@@ -1,6 +1,51 @@
class Origami::DiscountsController < BaseOrigamiController
#discount page show from origami index with selected order
def index
sale_id = params[:id]
if Sale.exists?(sale_id)
@sale_data = Sale.find(sale_id)
end
end
#discount for selected order
def create
sale_id = params[:sale_id]
discount_type = params[:discount_type]
discount_value = params[:discount_value]
discount_amount = params[:discount_amount]
grand_total = params[:grand_total]
if discount_type == 0
remark="Discount " + discount_amount + " as net"
else
remark="Discount " + discount_amount + " as percentage"
end
#update discount for sale
sale = Sale.find(sale_id)
sale.total_discount = discount_amount
sale.grand_total = grand_total
sale.save
#save sale item for discount
sale_item = SaleItem.new
#pull
sale_item.sale_id = sale_id
sale_item.product_code = 0
sale_item.product_name = "Discount"
sale_item.remark = remark
sale_item.qty = 1
sale_item.unit_price = (0-discount_amount.to_f)
sale_item.taxable_price = discount_amount
sale_item.is_taxable = 0
sale_item.price = sale_item.qty * sale_item.unit_price
sale_item.save
redirect_to origami_root_path
end
end

View File

@@ -2,6 +2,34 @@ class Origami::OthersPaymentsController < BaseOrigamiController
def index
@membership_rebate_balance = 0
@sale_id = params[:sale_id]
@payment_method_setting = PaymentMethodSetting.all
# @sale_id = params[:sale_id]
# sale_data = Sale.find_by_sale_id(@sale_id)
# if sale_data.customer_id
# customer_data= Customer.find_by_customer_id(sale_data.customer_id)
# @membership_id = customer_data.membership_id
# if !@membership_id.nil?
# membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
# membership_data = SalePayment.get_paypar_account(membership_setting.gateway_url,membership_setting.auth_token,@membership_id)
# if membership_data["status"]==true
# membership_account_data = membership_data["data"];
# membership_account_data.each do |acc_data|
# if acc_data["accountable_type"] == "REBATEACCOUNT"
# @membership_rebate_balance=acc_data["balance"]
# else
# @membership_rebate_balance = 0
# end
# end
# else
# @membership_rebate_balance = 0
# end
# end
# else
# end
end
def create

View File

@@ -0,0 +1,22 @@
class Origami::PayparPaymentsController < BaseOrigamiController
def create
sale_id = params[:sale_id]
redeem_amount = params[:redeem_amount]
membership_id = params[:membership_id]
payment_method = "paypar"
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
status,msg =sale_payment.process_payment(saleObj, @user, redeem_amount,payment_method)
if status == true
@out = true, "Success!"
else
@out =false, "Please try again payment!"
end
else
@out = false, "There has no sale record!"
end
end
end

View File

@@ -1,5 +1,6 @@
class Origami::RequestBillsController < BaseOrigamiController
def print
@sale = Sale.new
sale_order=SaleOrder.new
@@ -26,3 +27,5 @@ class Origami::RequestBillsController < BaseOrigamiController
redirect_to origami_root_path
end
end

View File

@@ -0,0 +1,111 @@
class Settings::MembershipActionsController < ApplicationController
before_action :set_settings_membership_action, only: [:show, :edit, :update, :destroy]
# GET /settings/membership_actions
# GET /settings/membership_actions.json
def index
type = params[:type]
@sale_id = params[:sale_id]
if type.nil?
@settings_membership_actions = Settings::MembershipAction.all
else
membership_actions_data=Settings::MembershipAction.find_by_membership_type(type)
if !membership_actions_data.nil?
url = params[:gateway_url].to_s + membership_actions_data.gateway_url.to_s
puts url.to_json
sale_data = Sale.find_by_sale_id(@sale_id)
if sale_data.customer_id
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
@membership_id = customer_data.membership_id
@campaign_type_id =1
if !@membership_id.nil?
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id)
if membership_data["status"]==true
@membership_rebate_balance=membership_data["balance"]
@out = true, @membership_rebate_balance
else
@out = false, 0
end
else
@out = false, 0
end
else
@out =false, 0
end
# campaign_type_id=1
# get_account_data = MembershipAction.get_account_data(url)
else
@out = false, 0
end
render :json => @out.to_json
end
end
# GET /settings/membership_actions/1
# GET /settings/membership_actions/1.json
def show
end
# GET /settings/membership_actions/new
def new
@settings_membership_action = Settings::MembershipAction.new
end
# GET /settings/membership_actions/1/edit
def edit
end
# POST /settings/membership_actions
# POST /settings/membership_actions.json
def create
@settings_membership_action = Settings::MembershipAction.new(settings_membership_action_params)
respond_to do |format|
if @settings_membership_action.save
format.html { redirect_to @settings_membership_action, notice: 'Membership action was successfully created.' }
format.json { render :show, status: :created, location: @settings_membership_action }
else
format.html { render :new }
format.json { render json: @settings_membership_action.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /settings/membership_actions/1
# PATCH/PUT /settings/membership_actions/1.json
def update
respond_to do |format|
if @settings_membership_action.update(settings_membership_action_params)
format.html { redirect_to @settings_membership_action, notice: 'Membership action was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_membership_action }
else
format.html { render :edit }
format.json { render json: @settings_membership_action.errors, status: :unprocessable_entity }
end
end
end
# DELETE /settings/membership_actions/1
# DELETE /settings/membership_actions/1.json
def destroy
@settings_membership_action.destroy
respond_to do |format|
format.html { redirect_to settings_membership_actions_url, notice: 'Membership action was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_settings_membership_action
@settings_membership_action = Settings::MembershipAction.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def settings_membership_action_params
params.require(:settings_membership_action).permit(:membership_type, :is_active, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id, :created_by, :additional_parameter)
end
end

View File

@@ -69,6 +69,6 @@ class Settings::PaymentMethodSettingsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_payment_method_setting_params
params.require(:payment_method_setting).permit(:payment_method, :is_active, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id)
params.require(:payment_method_setting).permit(:payment_method, :is_active, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id, :additional_parameters)
end
end

View File

@@ -0,0 +1,2 @@
module Api::Origami::PayparHelper
end

View File

@@ -0,0 +1,2 @@
module Origami::PayparHelper
end

View File

@@ -0,0 +1,2 @@
module Settings::MembershipActionsHelper
end

View File

@@ -1,5 +1,5 @@
class OrderQueueProcessorJob < ApplicationJob
queue_as :oqs
queue_as :default
def perform(order_id)
# Do something later

View File

@@ -2,7 +2,7 @@ class Account < ApplicationRecord
validates_presence_of :title, :account_type
has_many :menu_items
# belongs_to :lookup , :class_name => "Lookup"
def self.collection
Account.select("id, title").map { |e| [e.title, e.id] }
end

View File

@@ -10,21 +10,26 @@ class Customer < ApplicationRecord
validates :contact_no, uniqueness: true
validates :email, uniqueness: true
def self.get_member_group
gateway_url = MembershipSetting.find_by_membership_type("smartpay_url")
url = gateway_url.gateway_url.to_s + "/api/get_all_member_group".to_s
response = HTTParty.get(url)
membership = MembershipSetting.find_by_membership_type("paypar_url")
app_token = membership.auth_token.to_s
url = membership.gateway_url.to_s + "/api/get_all_member_group".to_s
response = HTTParty.get(url,
:body => { app_token: app_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
)
puts response.body, response.code, response.message, response.headers.inspect
return response;
end
# http://192.168.1.47:3006/api/create_membership_customer
#get_all_member_group
def lastest_invoices
sales.where(:customer_id => self.id).order("created_at desc").limit(5)
end

View File

@@ -48,7 +48,7 @@ class Order < ApplicationRecord
process_order_queue
#send order to broadcast job
send_order_broadcast
#send_order_broadcast
return true, booking

View File

@@ -72,4 +72,14 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
pdf.render_file "tmp/receipt_bill.pdf"
self.print("tmp/receipt_bill.pdf")
end
#Bill Receipt Print
def print_crm_order(booking,order_items,setting)
#Use CUPS service
#Generate PDF
#Print
pdf = CrmOrderPdf.new(booking,order_items,setting)
pdf.render_file "tmp/print_crm_order.pdf"
self.print("tmp/print_crm_order.pdf")
end
end

View File

@@ -55,8 +55,8 @@ class Sale < ApplicationRecord
generate_receipt_no
order = Order.find(order_id)
#Default - Values
self.tax_type = "execlusive"
#Default Tax - Values
self.tax_type = "exclusive"
self.requested_by = requested_by
self.requested_at = DateTime.now.utc

View File

@@ -12,7 +12,7 @@ class SaleItem < ApplicationRecord
def self.get_order_items_details(sale_id)
order_details = SaleItem.select("sales.total_discount as discount_amount,DATE_FORMAT(sales.receipt_date,'%Y-%m-%d %h:%m') as receipt_date,
order_details = SaleItem.select("sales.total_tax as tax_amount, sales.grand_total as grand_total_amount , sales.total_discount as discount_amount,DATE_FORMAT(sales.receipt_date,'%Y-%m-%d %h:%m') as receipt_date,
sales.cashier_name,sales.receipt_no,sale_items.product_name as item_name,sale_items.qty,sale_items.price,sale_items.unit_price as total_price")
.joins("left join sales on sales.sale_id = sale_items.sale_id")
.where("sale_items.sale_id=?",sale_id)

View File

@@ -8,12 +8,10 @@ class SalePayment < ApplicationRecord
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status
def process_payment(invoice, action_by, cash_amount)
def process_payment(invoice, action_by, cash_amount,payment_method)
self.sale = invoice
self.received_amount = cash_amount
payment_method = "cash"
amount_due = invoice.grand_total
#get all payment for this invoices
@@ -54,7 +52,7 @@ class SalePayment < ApplicationRecord
end
#record an payment in sale-audit
remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{amount} | Payment Status ->#{payment_status}"
remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{cash_amount} | Payment Status ->#{payment_status}"
sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by)
return true, self.sale
@@ -66,6 +64,38 @@ class SalePayment < ApplicationRecord
return false, "No outstanding Amount"
end
end
def self.get_paypar_account(url,token,membership_id,campaign_type_id)
response = HTTParty.get(url,
:body => { app_token: token,membership_id:membership_id,campaign_type_id:campaign_type_id}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
)
return response;
end
def self.redeem(paypar_url,token,membership_id,received_amount,sale_id,campaign_type_id)
membership_actions_data = Settings::MembershipAction.find_by_membership_type("redeem_url");
if !membership_actions_data.nil?
url = paypar_url.to_s + membership_actions_data.gateway_url.to_s
campaign_type_id = 1
response = HTTParty.post(url,
:body => { generic_customer_id:membership_id,total_amount:received_amount,receipet_no:sale_id,campaign_type_id:campaign_type_id,account_no:""}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
)
else
response =false;
end
return response;
end
private
@@ -148,15 +178,37 @@ class SalePayment < ApplicationRecord
end
def paypar_payment
##TODO - Integration with Paypar (SmartPay)
payment_status = false
#Next time - validate if the vochure number is valid - within
self.payment_method = "paypar"
self.payment_amount = self.received_amount
self.payment_reference = self.voucher_no
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
self.payment_status = "pending"
payment_method = self.save!
campaign_type_id =1;
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id,campaign_type_id)
if membership_data["status"]==true
SalePayment.where(:sale_payment_id => self.sale_payment_id).update_all(:payment_status => 'paid')
sale_update_payment_status(self.received_amount.to_f)
else
sale_update_payment_status(0)
end
return payment_status
end
def sale_update_payment_status(paid_amount)
puts "paid_amount"
puts paid_amount
#update amount_outstanding
self.sale.amount_received = self.sale.amount_received + paid_amount
self.sale.amount_changed = amount - self.sale.amount_received
self.sale.amount_changed = paid_amount - self.sale.amount_received
if (self.sale.grand_total <= self.sale.amount_received && self.sale.amount_changed > 0)
self.sale.payment_status = "paid"
self.sale.sale_status = "completed"

View File

@@ -0,0 +1,2 @@
class Settings::MembershipAction < ApplicationRecord
end

106
app/pdf/crm_order_pdf.rb Normal file
View File

@@ -0,0 +1,106 @@
class CrmOrderPdf < Prawn::Document
attr_accessor :receipt_width,:price_column_width,:p_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_column_width,:item_description_width
def initialize(booking,order_items,print_settings)
self.p_width = 200
self.page_height = 1450
self.margin = 10
# self.price_width = self.p_width / 2
self.price_width=80
self.item_width = self.p_width - self.price_width
self.item_height = self.item_height
self.qty_column_width = self.p_width / 2
self.item_description_width=self.p_width - self.price_width
self.receipt_width=130
@item_width = self.p_width.to_i / 2
@qty_width = @item_width.to_i / 3
@double = @qty_width * 1.3
@half_qty = @qty_width / 2
#setting page margin and width
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.p_width, self.page_height])
self.header_font_size = 7
self.item_font_size = 9
header( booking.type, booking.dining_facility.name)
stroke_horizontal_rule
order_detail(booking.checkin_by,booking.checkin_at,booking.dining_facility.name)
line_items(order_items)
#all_total(order_items)
end
def header (type, name)
text "#{type}", :size => self.header_font_size,:align => :center
move_down 5
text "#{name}", :size => self.header_font_size,:align => :center
# move_down self.item_height
move_down 5
stroke_horizontal_rule
end
def order_detail(order_by,order_at,customer)
move_down 5
move_down 2
y_position = cursor
qty_column_width = self.p_width * 0.2
item_description_width = self.p_width * 0.5
price_column_width = self.p_width * 0.3
stroke_horizontal_rule
move_down 5
y_position = cursor
pad_top(15) {
# @item_width.to_i + @half_qty.to_i
text_box "Order By", :at =>[0,y_position], :width => @item_width.to_i - @half_qty.to_i , :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size
text_box "Order At", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
text_box "Customer", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
}
move_down 5
stroke_horizontal_rule
y_position = cursor
pad_top(15) {
text_box "#{order_by}", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
text_box "#{order_at.to_i}", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
text_box "#{customer}", :at =>[@item_width.to_i + @half_qty.to_i,y_position], :width => @double, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
}
end
def line_items(order_items)
y_position = cursor
qty_column_width = self.p_width * 0.2
item_description_width = self.p_width * 0.5
price_column_width = self.p_width * 0.3
stroke_horizontal_rule
move_down 5
y_position = cursor
pad_top(15) {
# @item_width.to_i + @half_qty.to_i
text_box "Items", :at =>[0,y_position], :width => @item_width.to_i - @half_qty.to_i , :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size
text_box "Price", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
text_box "Qty", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
text_box "Total", :at =>[@item_width.to_i + @half_qty.to_i,y_position], :width => @double, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
}
move_down 5
stroke_horizontal_rule
end
end

View File

@@ -8,7 +8,6 @@
<%= f.input :contact_no %>
<%= f.input :email %>
<%= f.input :date_of_birth %>
<%= f.input :membership_id, :collection => @membership %>
<%= f.input :membership_type %>
<%= f.input :membership_authentication_code %>
</div>
@@ -17,3 +16,5 @@
<%= f.button :submit %>
</div>
<% end %>
<!-- -->

View File

@@ -1,20 +1,20 @@
<div class="row">
<div class="col-lg-12">
<ol class="breadcrumb">
<li><a href="<%= dashboard_path %>">Home</a></li>
<li><a href="<%= crm_root_path %>">Home</a></li>
<li class="active">
<a href="<%= crm_customers_path %>">Customer</a>
</li>
<a href="<%= new_crm_customer_path%>" class="btn btn-primary pull-right">
<!-- <a href="<%= new_crm_customer_path%>" class="btn btn-primary pull-right">
<i class="fa fa-plus-circle fa-lg"></i> Add Customer
</a>
</a> -->
</ol>
</div>
</div>
<br/>
<div class="row">
<div class="col-lg-7">
<div class="col-lg-8">
<div class="main-box-body clearfix">
<div class="table-responsive">
@@ -22,6 +22,7 @@
<thead>
<tr>
<th>Select</th>
<th>Name</th>
<th>Company</th>
<th>Contact no</th>
@@ -32,10 +33,16 @@
<tbody>
<% @crm_customers.each do |crm_customer| %>
<tr>
<td>
<input type="radio" style="width:20px;" value="<%= crm_customer.customer_id %>" name="checkbox" class="checkbox_check" ></td>
<td><%= crm_customer.name %></td>
<td><%= crm_customer.company %></td>
<td><%= crm_customer.contact_no %></td>
<td><%= crm_customer.email %></td>
<td>
<%= link_to 'Destroy', crm_customer_path(crm_customer), method: :delete, data: { confirm: 'Are you sure?' } %>
</td>
</tr>
<% end %>
@@ -46,55 +53,61 @@
</div>
<div class="col-lg-5">
<%= simple_form_for crm_customers_path, :html => { :class => 'form-horizontal' } do |f| %>
<div class="col-lg-4">
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
<span class="patch_method"></span>
<input type="hidden" id="sale_id" name="sale_id" value="<%= @sale_id %>" />
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group">
<%= f.input :name, :class => "form-control col-md-6" %>
</div>
<div class="form-group">
<%= f.input :company, :class => "form-control col-md-6" %>
</div>
<div class="form-group">
<%= f.input :contact_no, :class => "form-control col-md-6" %>
</div>
<div class="form-group">
<%= f.input :email, :class => "form-control col-md-6" %>
</div>
<%= f.input :name, :class => "form-control col-md-6 name" %>
</div>
<div class="form-group">
<label for="date_of_birth" class="col-md-6 control-label">Date Of Birth</label>
<%= f.text_field :date_of_birth,:class=>"form-control datepicker",:readonly =>true, :value => @date_of_birth%>
<%= f.input :company, :class => "form-control col-md-6 company" %>
</div>
<div class="form-group">
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
</div>
<div class="form-group">
<%= f.input :email, :class => "form-control col-md-6 email" %>
</div>
<div class="form-group">
<label>Date Of Birth</label>
<%= f.text_field :date_of_birth,:class=>"form-control datepicker date_of_birth",:readonly =>true, :value => @date_of_birth%>
</div>
<div class="form-group">
<%= f.select :membership_id, options_for_select(@membership.collect { |member|
[member["id"].name.titleize, member["id"].id] }, 1), {}, { id: 'countries_select' } %>
<select class="selectpicker form-control col-md-6" name="membership_id">
<select class="selectpicker form-control col-md-12" name="membership_id">
<option>Select Member Group</option>
<% @membership.each do |member| %>
<% @member_group.each do |member| %>
<option value="<%= member["id"] %>">
<%= member["name"] %></option>
<%end %>
</select>
</select>
</div>
<div class="form-group">
<%= f.input :membership_type, :class => "form-control col-md-6" %>
<%= f.input :membership_type, :class => "form-control col-md-6 membership_type" %>
</div>
<div class="form-group">
<%= f.input :membership_authentication_code, :class => "form-control col-md-6" %>
<%= f.input :membership_authentication_code, :class => "form-control col-md-6 membership_authentication_code" %>
</div>
<div class="form-group">
<%= f.button :submit, "Submit", :class => 'btn btn-primary' , :id => 'submit_account' %>
<%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %>
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %>
</div>
<%end%>
</div>
</div>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.js"></script>
<script type="text/javascript">
$(function () {
if (jQuery().datepicker) {
@@ -107,4 +120,112 @@
}
});
$(document).on('click',".checkbox_check",function(){
if(this.checked){
var sale_id = $("#sale_id").val() || 0;
var customer_id = $(this).val();
if(sale_id != 0){
var url = "../"+customer_id;
update_sale(customer_id,sale_id);
}else{
var url = "customers/"+customer_id;
}
$.ajax({
type: "GET",
url: url,
data: {},
dataType: "json",
success: function(data) {
$('#customer_id').val(data.id);
$('#customer_name').val(data.name);
$('#customer_company').val(data.company);
$('#customer_contact_no').val(data.contact_no);
$('#customer_email').val(data.email);
$('#customer_date_of_birth').val(data.date_of_birth);
$('#customer_membership_type').val(data.membership_type);
$('.select > option[value="'+data.membership_id+'"]').attr('selected','selected');
$('.membership_authentication_code').val(data.membership_authentication_code);
$('#update_customer').removeAttr('disabled').val('');
$('#update_customer').attr('value', 'Update');
$('#submit_customer').attr('disabled','disabled');
$("#new_customer").attr('class', 'simple_form edit_customer');
var id = "edit_customer_"+$('#customer_id').val();
$("#new_customer").attr('id', id);
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".patch_method").append('<input type="hidden" name="_method" value="patch">');
//$(".edit_customer").attr('method', 'PATCH');
}
});
}else{
}
})
function update_sale(customer_id,sale_id) {
$.confirm({
title: 'Confirm!',
content: 'Are You Sure to assign this customer!',
buttons: {
cancel: function () {
},
confirm: {
text: 'Confirm',
btnClass: 'btn-green',
keys: ['enter', 'shift'],
action: function(){
$.ajax({
type: "POST",
url: "../../update_sale/" ,
data: {customer_id:customer_id,sale_id:sale_id},
dataType: "json",
success: function(data) {
if(data.status == true)
{
alert('Customer has assigned');
window.location.href = '/origami'
}else{
alert('Record not found!');
location.reload();
}
}
});
}
}
}
});
}
/*function changeMethod() {
$("#update_customer").attr('method', 'put');
}*/
/* $("#update_customer").click(function() {
$("#new_customer").attr('class', 'edit_customer');
var id = "edit_customer_"+$('#customer_id').val();alert(id);
$("#new_customer").attr('id', id);
alert(";;")
//$('#new_customer').removeClass('new_customer');
//$('#new_customer').addClass('edit_customer')
}); */
</script>

View File

@@ -25,10 +25,6 @@
<%= @crm_customer.date_of_birth %>
</p>
<p>
<strong>Membership:</strong>
<%= @crm_customer.membership %>
</p>
<p>
<strong>Membership type:</strong>

View File

@@ -1 +1,2 @@
json.partial! "crm_customers/crm_customer", crm_customer: @crm_customer
json.extract! @crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth, :membership_id, :membership_type, :membership_authentication_code, :created_at, :updated_at
json.url crm_customer_url(@crm_customer, format: :json)

View File

@@ -4,9 +4,10 @@
<% @i = 0 %>
<% @booking.each do |booking| %>
<% if booking.booking_status == "assign" %>
<% if booking.booking_status == "new" %>
<div class="card">
<div class="card-block booking_click" data-ref="<%= api_booking_path booking.id%>" id="card-block booking_block" style="width:100%;">
<div class="card-block booking_click" data-id="sfddf" data-ref="<%= api_booking_path booking.id%>" id="card-block booking_block" >
<p class="hidden booking-id"><%= booking.id %></p>
<h4 class="card-title">
<%= @i += 1 %> . <%= booking.dining_facility.name %>
- <%= booking.id %>
@@ -36,29 +37,50 @@
<script type="text/javascript">
$(function(){
$(".booking_click").on("click", function(){
$(".booking_click").on("click", function(){
$(".summary-items tbody tr").remove();
$("#cancel").removeAttr("disabled");
$("#assign").removeAttr("disabled");
var booking_id = $(this).find(".booking-id").text();
$("#crm_print").val(booking_id);
$("#crm_print").removeAttr("disabled");
var url = $(this).attr('data-ref');
show_details(url);
});
$('.assign').click(function(e){
});
$('.crm_print').click(function() {
var booking_id = $('#crm_print').val();
$.ajax({
type: "GET",
url: "crm/print/"+booking_id,
data: {},
dataType: "json",
success: function(data) {
}
});
});
$('.assign').click(function(e){
var booking_id = $(this).val()
var type = $(this).attr("data-type")
update_booking(booking_id,type)
});
});
$('.cancel').click(function(e){
$('.cancel').click(function(e){
var booking_id = $(this).val()
var type = $(this).attr("data-type")
update_booking(booking_id,type)
});
});
});
});
function show_details(url_item){
$.ajax({
@@ -97,7 +119,7 @@ function show_details(url_item){
function update_booking(booking_id,type) {
$.ajax({
type: "POST",
url: "crm/update_booking/" ,
url: "update_booking/" ,
data: {booking_id:booking_id,type:type},
dataType: "json",
success: function(data) {

View File

@@ -5,6 +5,7 @@
<% if booking.booking_status == "assign" %>
<div class="card booking_click" data-ref="<%= api_booking_path booking.id%>" id="booking_block">
<div class="card-block" id="card-block" style="width:100%;">
<p class="hidden booking-id"><%= booking.id %></p>
<h4 class="card-title">
<%= @i += 1 %> . <%= booking.dining_facility.name %>
- <%= booking.id %>

View File

@@ -92,10 +92,15 @@
<!-- Column Three--->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- OQS Buttons -->
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Print</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Print <br/>Order<br/>Summary</button>
<button id="crm_print" value="" disabled="disabled" data-type="assign" class="btn crm_print btn-primary btn-lg btn-block" >
Print
</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Print <br/>Order<br/>Summary</button>
<button id="assign" value="" disabled="disabled" data-type="assign" class="btn assign btn-primary btn-lg btn-block">ASSIGN</button>
<button id="cancel" value="" disabled="disabled" data-type="cancel" class="btn btn-danger cancel btn-lg btn-block">CANCLE</button>
</div>
</div>
</script>

View File

@@ -17,7 +17,7 @@
<%= render 'layouts/header_crm' %>
<div class="container-fluid">
<% flash.each do |type, message| %>
<div class="alert fade in">
<div class="alert-danger fade in">
<button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button>
<%= message %>
</div>

View File

@@ -4,7 +4,7 @@
<strong>CRM</strong>
</div>
<div style="float:left;margin-top:3px;text-align:left; width:600px">
Queue | Bookings | Online Orders | Customers
Queue | Bookings | Online Orders | <%= link_to 'Customer', crm_customers_path, :html=>":color:white" %>
</div>
<div style="float:right; margin-top:3px; text-align:right;width:200px;color:#ffffff">

View File

@@ -9,8 +9,8 @@
<title>SmartSales : Restaurant</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'orgiami', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'orgiami', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag 'origami', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'origami', 'data-turbolinks-track': 'reload' %>
</head>
<body>

View File

@@ -0,0 +1,178 @@
<div class="row">
<!-- Column One -->
<div class="col-lg-6 col-md-6 col-sm-6">
<!-- Order Details -->
<div class="card" >
<div class="card-header">
<p id="sale-id" class="hidden"><%=@sale_data.sale_id %></p>
<div><strong id="order-title">ORDER DETAILS</strong></div>
</div>
<div class="card-block">
<div class="card-title row">
<div class="col-lg-6 col-md-6 col-sm-6">
<p>Receipt No: <span id="receipt_no"><%=@sale_data.receipt_no rescue ' '%></span></p>
<p>Cashier: <span id="cashier"><%=@sale_data.cashier_name rescue ' '%></span></p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"> <%=@sale_data.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div>
</div>
<div class="card-text">
<table class="table table-striped" id="order-items-table">
<thead>
<tr>
<th class="item-name">Items</th>
<th class="item-attr">QTY</td>
<th class="item-attr">Price</td>
</tr>
</thead>
<tbody>
<% sub_total = 0 %>
<% @sale_data.sale_items.each do |sale_item| %>
<% sub_total += sale_item.qty*sale_item.unit_price%>
<tr>
<td style="width:60%; text-align:left">
<span id="item-name-price"><%=sale_item.product_name%>@<%=sale_item.unit_price%></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-qty"><%=sale_item.qty%></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-total-price"><%=(sale_item.qty*sale_item.unit_price)%></span>
</td>
</tr>
<%end %>
</tbody>
</table>
</div>
<div class="card-footer">
<table class="table" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="order-sub-total"><%=sub_total%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Food:</strong></td>
<td class="item-attr"><strong id="order-food"></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Beverage:</strong></td>
<td class="item-attr"><strong id="order-beverage"></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Discount:</strong></td>
<td class="item-attr"><strong id="order-discount">(<%=@sale_data.total_discount rescue 0%>)</strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Tax:</strong></td>
<td class="item-attr"><strong id="order-Tax"><%=@sale_data.total_tax rescue 0%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Grand Total:</strong></td>
<td class="item-attr"><strong id="order-grand-total"><%=@sale_data.grand_total rescue 0%></strong></td>
</tr>
</table>
</div>
</div>
</div>
</div>
<!-- Column One -->
<!-- Column Two -->
<div class="col-lg-6 col-md-6 col-sm-6">
<!-- Discount Amount -->
<div class="card row">
<div class="card-header">
<div><strong id="order-title">Pay Discount</strong></div>
</div>
<div class="card-block">
<div class="card-title">
<div class="form-horizontal">
<div class="form-group">
<div class="col-md-3">
<select name="discount_type" id="discount-type" class="form-control">
<option value=0 >Net</option>
<option value=1 >Percentage</option>
</select>
</div>
<div class="col-md-9">
<input type="text" id="discount-amount" name="discount-amount" value="<%= @sale_data.total_discount rescue 0 %>" class="form-control" />
</div>
</div>
<button id="pay-discount" class="btn btn-primary long">Discount</button>
</div>
</div>
<hr />
<div class="col-md-12">
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="col-md-3 cashier_number" data-value="1" data-type="num">1</div>
<div class="col-md-3 cashier_number" data-value="2" data-type="num">2</div>
<div class="col-md-3 cashier_number" data-value="3" data-type="num">3</div>
</div>
</div>
<div class="col-md-5">
<div class="col-md-12 cashier_number long" data-value="500" data-type="add">500</div>
</div>
</div>
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="col-md-3 cashier_number" data-value="4" data-type="num">4</div>
<div class="col-md-3 cashier_number" data-value="5" data-type="num">5</div>
<div class="col-md-3 cashier_number" data-value="6" data-type="num">6</div>
</div>
</div>
<div class="col-md-5">
<div class="col-md-12 cashier_number long" data-value="1000" data-type="add">1000</div>
</div>
</div>
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="col-md-3 cashier_number" data-value="7" data-type="num">7</div>
<div class="col-md-3 cashier_number" data-value="8" data-type="num">8</div>
<div class="col-md-3 cashier_number" data-value="9" data-type="num">9</div>
</div>
</div>
<div class="col-md-5">
<div class="col-md-12 cashier_number long" data-value="5000" data-type="add">5000</div>
</div>
</div>
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="col-md-3 cashier_number" data-value="0" data-type="num">0</div>
<div class="col-md-3 cashier_number" data-value="." data-type="num">.</div>
<div class="col-md-3 cashier_number" data-value="00" data-type="num">00</div>
</div>
</div>
<div class="col-md-5">
<div class="col-md-12 cashier_number long" data-value="10000" data-type="add">10000</div>
</div>
</div>
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="col-md-3 cashier_number"></div>
<div class="col-md-3 cashier_number red" data-type="del">DEL</div>
<div class="col-md-3 cashier_number green" data-type="clr">CLR</div>
</div>
</div>
<div class="col-md-5">
<div class="col-md-12 cashier_number long" data-value="50000" data-type="add">50000</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -1,6 +1,6 @@
<div class="row">
<!-- Column One -->
<div class="col-lg-6 col-md-6 col-sm-8">
<div class="col-lg-6 col-md-6 col-sm-6">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
@@ -214,11 +214,13 @@
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Add Order</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Edit</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Move</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Customer</button>
<button type="button" id="request_bills" class="btn btn-primary btn-lg btn-block">Req.Bill</button>
<!-- Cashier Buttons -->
<button type="button" class="btn btn-primary btn-lg btn-block">Discount</button>
<button type="button" class="btn btn-primary btn-lg btn-block">Tax</button>
<button type="button" id="discount" class="btn btn-primary btn-lg btn-block">Discount</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Tax</button>
<button type="button" id="pay" class="btn btn-primary btn-lg btn-block" >Pay</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Re.Print</button>
</div>

View File

@@ -1,328 +0,0 @@
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-8">
<!-- Column One -->
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#tables" role="tab">Tables</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#rooms" role="tab">Rooms</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#orders" role="tab">Orders</a>
</li>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content" style="min-height:670px; max-height:670px; overflow-y:scroll">
<!-- Panel 1 - Tables -->
<div class="tab-pane active" id="tables" role="tabpanel">
<!--- Booking Items -->
<div class="card-columns" style="padding-top:10px">
<% if @booking_orders %>
<% @booking_orders.each do |booking_order| %>
<% if booking_order.order_status != "new" %>
<div style="background-color: red;color: white;" class="card" id="table-order-<%=booking_order.sale_id%>" onclick="callOrderDetails('sale_<%=booking_order.sale_id%>')">
<div class="card-block">
<h4 class="card-title">
<span id="table-name-<%=booking_order.sale_id%>" class="table-name"><%=booking_order.table_name%></span></h4>
<span>Receipt No : <%=booking_order.receipt_no%></span><br/>
<span>Order Status : <%=booking_order.order_status %></span>
</div>
</div>
<% else %>
<div class="card" id="table-order-<%=booking_order.id%>" onclick="callOrderDetails('order_<%=booking_order.id%>')">
<div class="card-block">
<h4 class="card-title"><span id="table-name-<%=booking_order.id%>" class="table-name"><%=booking_order.table_name%></span></h4>
<span>Order Status : <%=booking_order.order_status %></span>
</div>
</div>
<% end %>
<%end %>
<%end %>
</div>
</div>
<!-- Panel 1 - Tables - End -->
<!-- Panel 2 - Rooms -->
<div class="tab-pane" id="rooms" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:scroll">
<!--- Booking Items -->
<div class="card-columns" style="padding-top:10px">
<% if @booking_rooms %>
<% @booking_rooms.each do |booking_room| %>
<% if !booking_room.order_status = 'new'%>
<div style="background-color: red;color: white;" class="card" id="table-order-<%=booking_room.id%>" onclick="callOrderDetails('sale_<%=booking_room.id%>')">
<div class="card-block">
<h4 class="card-title">
<span id="table-name-<%=booking_room.id%>" class="table-name"><%=booking_room.room_name%></span></h4>
<span>Receipt No : <%=booking_room.receipt_no%></span><br/>
<span>Order Status : <%=booking_room.order_status %></span>
</div>
</div>
<% else %>
<div class="card" id="table-order-<%=booking_room.id%>" onclick="callOrderDetails('order_<%=booking_room.id%>')">
<div class="card-block">
<h4 class="card-title"><span id="table-name-<%=booking_room.id%>" class="table-name"><%=booking_room.room_name%>ddd</span></h4> \
<span>Order Status : <%=booking_room.order_status %></span>
</div>
</div>
<% end %>
<%end %>
<%end %>
</div>
</div>
<!-- Panel 2 - Rooms - End -->
<!-- Panel 3 - Orders -->
<div class="tab-pane" id="orders" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:scroll">
<!--- Booking Items -->
<div class="card-columns" style="padding-top:10px">
<% if @orders %>
<% @orders.each do |order| %>
<% if !order.order_status = 'new'%>
<div style="background-color: green;color: white;" class="card" id="table-order-<%=order.order_id%>" onclick="callOrderDetails('sale_<%=order.order_id%>')">
<div class="card-block">
<h4 class="card-title">
<span id="table-name-<%=order.order_id%>" class="table-name">Order No:<%=order.order_id%></span></h4>
<span>Receipt No : <%=order.receipt_no%></span><br/>
<span>Order Status : <%=order.order_status %></span>
</div>
</div>
<% else %>
<div class="card" id="table-order-<%=order.order_id%>" onclick="callOrderDetails('order_<%=order.order_id%>')">
<div class="card-block">
<h4 class="card-title"><span id="table-name-<%=order.order_id%>" class="table-name">Order No:<%=order.order_id%></span></h4>
<span>Order Status : <%=order.order_status %></span>
</div>
</div>
<% end %>
<%end %>
<%end %>
</div>
</div>
<!-- Panel 3 - Orders - End -->
</div>
</div>
<!-- Column Two -->
<div class="col-lg-5 col-md-5 col-sm-3">
<div class="card" >
<div class="card-header">
<div id="order-title"><strong><span id="receipt-no">ORDER DETAILS</span></strong>
<strong><span id ="receipt-date" style="margin-left: 30%"></span></strong></div><br/>
<div ><strong><span id="cashier-name"></span></strong><strong><span style="margin-left: 36%" id="order-detail-header"></span></strong></div>
</div>
<div class="card-block">
<div class="card-title">
<table class="table">
<thead>
<tr>
<th style="width:60%; text-align:left">Items</th>
<th style="width:20%; text-align:right">QTY</td>
<th style="width:20%; text-align:right">Price</td>
</tr>
</thead>
</table>
</div>
<div id="table-details" class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll">
<table class="table" id="append-table">
<tbody>
<tr>
<td style="width:60%; text-align:left">
<span id="item-name-price"></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-qty"></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-total-price"></span>
</td>
</tr>
</tbody>
</table>
</div>
<div class="card-footer">
<table class="table" style="margin-bottom:0px">
<tfooter>
<tr>
<td style="width:80%; text-align:left; border-top:none"><strong>Sub Total</strong></td>
<td style="width:20%; text-align:right; border-top:none"><strong><span id="sub-total"></span></strong></td>
</tr>
<tr>
<td style="width:80%; text-align:left; border-top:none"><strong><span id="discount-header"></strong></td>
<td style="width:20%; text-align:right; border-top:none"><strong><span id="discount_amount"></span></strong></td>
</tr>
<tr>
<td style="width:80%; text-align:left; border-top:none"><strong><span id="tax-header"></strong></td>
<td style="width:20%; text-align:right; border-top:none"><strong><span id="tax_amount"></span></strong></td>
</tr>
<tr>
<td style="width:80%; text-align:left; border-top:none"><strong><span id="grand-total-header"></strong></td>
<td style="width:20%; text-align:right; border-top:none"><strong><span id="grand_total_amount"></span></strong></td>
</tr>
</tfooter>
</table>
</div>
</div>
</div>
</div>
<!-- Column Three--->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- Waiter Buttons -->
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Add Order</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Edit</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Move</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Customer</button>
<!-- <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Req.Bill</button> -->
<button type="button" id="request_bills" class="btn btn-primary btn-lg btn-block">
Req.Bill
</button>
<!-- Cashier Buttons -->
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Discount</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Tax</button>
<button type="button" id="pay" class="btn btn-primary btn-lg btn-block" >Pay</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Re.Print</button>
</div>
</div>
<script>
var old_order_id = 0
var old_table_name = ""
var table_or_order_id = 0
var pay_sale_id = 0
function callOrderDetails(sale_order_id){
var order_id = 0
var sale_id = 0
var data_val = ""
sale_order = sale_order_id.split("_")[0]
if (sale_order == 'sale') {
sale_id = sale_order_id.split("_")[1]
url = "origami/"+sale_id
data_val = { sale_id: sale_id }
sale_or_order_id=sale_id
}else{
order_id = sale_order_id.split("_")[1]
url = "origami/"+order_id
data_val = { order_id: sale_order_id.split("_")[1]}
sale_or_order_id=order_id
}
table_or_order_id = order_id
pay_sale_id = sale_id
var tbody = ""
// clear data in table
$("#append-table").html("")
if (old_order_id != order_id){
$("#table-order-"+old_order_id).removeClass("selected_color")
$("#table-order-"+order_id).addClass("selected_color")
old_order_id = order_id
}
$("#order-detail-header").html("")
$("#order-detail-header").append("Table Name : "+document.getElementById("table-name-" + sale_or_order_id).innerHTML)
$("#sub-total").html("")
$.ajax({type: "GET",
url: url,
data: data_val,
success:function(result){
var sub_total = 0
var discount_amount = 0
var receipt_no = ""
var cashier_name = ""
var receipt_date = ""
var tax_amount = 0
var grand_total_amount = 0
row = "<tbody>"
for (i = 0; i < result.length; i++) {
var data = JSON.stringify(result[i]);
var parse_data = JSON.parse(data)
sub_total += (parse_data.qty*parse_data.price)
row = '<tr><td style="width:60%; text-align:left"><span id="item-name-price">'+parse_data.item_name+"@"+(parse_data.price*1)+'</span></td>'
+'<td style="width:20%; text-align:right"><span id="item-qty">'+(parse_data.qty*1)+'</span></td>s'
+'<td style="width:20%; text-align:right"><span id="item-total-price">'+(parse_data.qty*parse_data.price)+'</span></td>'
+'</tr>>'
tbody += row
discount_amount = result[i].discount_amount;
tax_amount = result[i].tax_amount;
grand_total_amount = result[i].grand_total_amount;
receipt_no = result[i].receipt_no;
cashier_name = result[i].cashier_name;
receipt_date = result[i].receipt_date;
}
row = "</tbody>";
$("#append-table").append(tbody);
$("#sub-total").append((sub_total)+"<br/>");
if (discount_amount > 0 ) {
$("#discount-header").html("(Discount)");
$("#discount_amount").html("("+discount_amount+")");
}
if (tax_amount > 0 ) {
$("#tax-header").html("Tax");
$("#tax_amount").html(tax_amount);
}
if (grand_total_amount > 0 ) {
$("#grand-total-header").html("Grand Total")
$("#grand_total_amount").html(grand_total_amount);
}
if (cashier_name == null){
cashier_name = "";
}
if(receipt_no != null){
$("#receipt-no").html("Receipt No : " + receipt_no);
}
if (receipt_date != null) {
$("#receipt-date").html("Receipt Date : "+receipt_date);
}
if (cashier_name != null) {
$("#cashier-name").html("Cashier Name : "+cashier_name);
}
},
error:function(result){
// alert('error');
}
});
}
$( document ).ready(function() {
$('#request_bills').click(function() {
console.log(table_or_order_id);
window.location.href = '/origami/request_bills/'+ table_or_order_id
return false;
});
$('#pay').click(function() {
window.location.href = '/origami/sale/'+ pay_sale_id + "/payment"
return false;
});
});
</script>
<style type="text/css">
.selected_color{
color:white;
background-color: blue;
}
</style>

View File

@@ -1 +1,177 @@
Hello Card Payment
<div class="row">
<div class="col-lg-5 col-md-5 col-sm-3">
<div class="card">
<% @payment_method_setting.each do |payment_method|%>
<div class="col-md-5">
<div class="col-md-12 long purple " id="<%= payment_method.payment_method%>" data-url="<%=payment_method.gateway_url%>" data-sale-id="<%= @sale_id%>"><%= payment_method.payment_method %></div>
</div>
<% end %>
</div>
</div>
<div class="col-lg-7 col-md-7 col-sm-7">
<div class="rebate-form" hidden="true">
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Valid Amount</label>
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="">
</div>
<hr>
</div>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Used Amount</label>
<div id="used_amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
</div>
<hr>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="col-md-3 cashier_number" data-value="1" data-type="num">1</div>
<div class="col-md-3 cashier_number" data-value="2" data-type="num">2</div>
<div class="col-md-3 cashier_number" data-value="3" data-type="num">3</div>
</div>
</div>
<div class="col-md-5">
<div class="col-md-12 cashier_number long" data-value="1000" data-type="add">1000</div>
</div>
</div>
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="col-md-3 cashier_number" data-value="4" data-type="num">4</div>
<div class="col-md-3 cashier_number" data-value="5" data-type="num">5</div>
<div class="col-md-3 cashier_number" data-value="6" data-type="num">6</div>
</div>
</div>
<div class="col-md-5">
<div class="col-md-12 cashier_number long" data-value="5000" data-type="add">5000</div>
</div>
</div>
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="col-md-3 cashier_number" data-value="7" data-type="num">7</div>
<div class="col-md-3 cashier_number" data-value="8" data-type="num">8</div>
<div class="col-md-3 cashier_number" data-value="9" data-type="num">9</div>
</div>
</div>
<div class="col-md-5">
<div class="col-md-12 cashier_number long" data-value="10000" data-type="add">10000</div>
</div>
</div>
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="col-md-3 cashier_number" data-value="0" data-type="num">0</div>
<div class="col-md-3 cashier_number" data-value="." data-type="num">.</div>
<div class="col-md-3 cashier_number" data-value="00" data-type="num">00</div>
</div>
</div>
<div class="col-md-5">
<div class="col-md-12 cashier_number long" data-value="50000" data-type="add">50000</div>
</div>
</div>
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="col-md-3 cashier_number"></div>
<div class="col-md-3 cashier_number">DEL</div>
<div class="col-md-3 cashier_number">CLR</div>
</div>
</div>
<div class="col-md-5">
<div class="col-md-12 cashier_number long purple" id="redeem" data-value="<%=@sale_id %>" data-member-value = "<%= @membership_id %>">PAY</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
</div>
<script type="text/javascript">
$(document).on('click', '.cashier_number', function(event){
// event.stopPropagation();
// event.preventDefault();
// if(event.handled !== true) {
var original_value;
original_value = $('#used_amount').text();
var input_value = $(this).attr("data-value");
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
if (original_value == "0.0"){
$('#used_amount').text(input_value);
}else{
$('#used_amount').append(input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#used_amount').html(amount);
break;
case 'clr':
$('#used_amount').html("0.0");
break;
}
// event.handled = true;
// } else {
// return false;
// }
});
$("#REDIMREBATE").click(function(){
$('.rebate-form').removeAttr("hidden");
gateway_url = $(this).attr("data-url");
sale_id = $(this).attr("data-sale-id");
$.ajax({
type: "GET",
url: "../../../../settings/membership_actions",
data: {type:"get_account_balance_url",gateway_url:gateway_url,sale_id:sale_id},
success: function(result){
$("#valid_amount").val(result[1]);
}
})
});
$("#redeem").click(function(){
valid_amount = $("#valid_amount").val();
sale_id = $("#REDIMREBATE").attr("data-sale-id");
membership_id = $(this).attr("data-member-value");
redeem_amount = parseInt($("#used_amount").text());
if(redeem_amount<=0){
alert(" Insufficient Amount!")
}else if(valid_amount< redeem_amount){
alert("Please type valid amount");
}else{
$.ajax({
type: "POST",
url: "<%=origami_paypar_payment_process_path%>",
data: {redeem_amount:redeem_amount,membership_id:membership_id,sale_id:sale_id},
success: function(result){
if(result.status == true){
window.location.href = '/origami/sale/'+ sale_id + "/payment"
}else{
alert(result.message);
}
}
})
}
});
</script>

View File

@@ -165,7 +165,7 @@
<script>
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
//event.stopPropagation();
event.preventDefault();
if(event.handled !== true) {
var original_value;
@@ -218,21 +218,21 @@ $( document ).ready(function() {
$('#pay').click(function() {
if($('#balance').text() > 0){
alert(" Insufficient Amount!")
}else{
if($('#balance').text() > 0){
alert(" Insufficient Amount!")
}else{
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
var sale_id = $('#sale_id').text();
$.ajax({type: "POST",
url: "<%= origami_payment_process_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id,
success:function(result){
alert("THANK YOU")
}
});
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
var sale_id = $('#sale_id').text();
$.ajax({type: "POST",
url: "<%= origami_payment_process_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id,
success:function(result){
alert("THANK YOU")
}
});
}
});

View File

@@ -0,0 +1,2 @@
json.set! :status, @out[0]
json.set! :message, @out[1]

View File

@@ -0,0 +1,137 @@
<div class="row">
<div class="col-lg-5 col-md-5 col-sm-3">
<div class="card">
<% if @membership_id!=0 %>
<div class="col-md-5">
<div class="col-md-12 long purple " id="redim">Redim Amount</div>
</div>
<% end %>
</div>
</div>
<div class="col-lg-7 col-md-7 col-sm-7">
<div class="rebate-form" hidden="true">
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Valid Amount</label>
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%= @membership_rebate_balance %>">
</div>
<hr>
</div>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Used Amount</label>
<div id="used_amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
</div>
<hr>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="col-md-3 cashier_number" data-value="1" data-type="num">1</div>
<div class="col-md-3 cashier_number" data-value="2" data-type="num">2</div>
<div class="col-md-3 cashier_number" data-value="3" data-type="num">3</div>
</div>
</div>
<div class="col-md-5">
<div class="col-md-12 cashier_number long" data-value="1000" data-type="add">1000</div>
</div>
</div>
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="col-md-3 cashier_number" data-value="4" data-type="num">4</div>
<div class="col-md-3 cashier_number" data-value="5" data-type="num">5</div>
<div class="col-md-3 cashier_number" data-value="6" data-type="num">6</div>
</div>
</div>
<div class="col-md-5">
<div class="col-md-12 cashier_number long" data-value="5000" data-type="add">5000</div>
</div>
</div>
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="col-md-3 cashier_number" data-value="7" data-type="num">7</div>
<div class="col-md-3 cashier_number" data-value="8" data-type="num">8</div>
<div class="col-md-3 cashier_number" data-value="9" data-type="num">9</div>
</div>
</div>
<div class="col-md-5">
<div class="col-md-12 cashier_number long" data-value="10000" data-type="add">10000</div>
</div>
</div>
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="col-md-3 cashier_number" data-value="0" data-type="num">0</div>
<div class="col-md-3 cashier_number" data-value="." data-type="num">.</div>
<div class="col-md-3 cashier_number" data-value="00" data-type="num">00</div>
</div>
</div>
<div class="col-md-5">
<div class="col-md-12 cashier_number long" data-value="50000" data-type="add">50000</div>
</div>
</div>
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="col-md-3 cashier_number"></div>
<div class="col-md-3 cashier_number">DEL</div>
<div class="col-md-3 cashier_number">CLR</div>
</div>
</div>
<div class="col-md-5">
<div class="col-md-12 cashier_number long purple " id="pay">PAY</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
</div>
<script type="text/javascript">
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
event.preventDefault();
if(event.handled !== true) {
var original_value;
original_value = $('#used_amount').text();
var input_value = $(this).attr("data-value");
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
if (original_value == "0.0"){
$('#used_amount').text(input_value);
}else{
$('#used_amount').append(input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#used_amount').html(amount);
break;
}
event.handled = true;
} else {
return false;
}
});
$("#redim").click(function(){
$('.rebate-form').removeAttr("hidden");
})
</script>

View File

@@ -0,0 +1,18 @@
<%= simple_form_for(@settings_membership_action) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :membership_type %>
<%= f.input :is_active %>
<%= f.input :gateway_communication_type %>
<%= f.input :gateway_url %>
<%= f.input :auth_token %>
<%= f.input :merchant_account_id %>
<%= f.input :created_by %>
<%= f.input :additional_parameter %>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %>

View File

@@ -0,0 +1,2 @@
json.extract! settings_membership_action, :id, :membership_type, :is_active, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id, :created_by, :additional_parameter, :created_at, :updated_at
json.url settings_membership_action_url(settings_membership_action, format: :json)

View File

@@ -0,0 +1,6 @@
<h1>Editing Settings Membership Action</h1>
<%= render 'form', settings_membership_action: @settings_membership_action %>
<%= link_to 'Show', @settings_membership_action %> |
<%= link_to 'Back', settings_membership_actions_path %>

View File

@@ -0,0 +1,41 @@
<p id="notice"><%= notice %></p>
<h1>Settings Membership Actions</h1>
<table>
<thead>
<tr>
<th>Membership type</th>
<th>Is active</th>
<th>Gateway communication type</th>
<th>Gateway url</th>
<th>Auth token</th>
<th>Merchant account</th>
<th>Created by</th>
<th>Additional parameter</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @settings_membership_actions.each do |settings_membership_action| %>
<tr>
<td><%= settings_membership_action.membership_type %></td>
<td><%= settings_membership_action.is_active %></td>
<td><%= settings_membership_action.gateway_communication_type %></td>
<td><%= settings_membership_action.gateway_url %></td>
<td><%= settings_membership_action.auth_token %></td>
<td><%= settings_membership_action.merchant_account_id %></td>
<td><%= settings_membership_action.created_by %></td>
<td><%= settings_membership_action.additional_parameter %></td>
<td><%= link_to 'Show', settings_membership_action %></td>
<td><%= link_to 'Edit', edit_settings_membership_action_path(settings_membership_action) %></td>
<td><%= link_to 'Destroy', settings_membership_action, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New Settings Membership Action', new_settings_membership_action_path %>

View File

@@ -0,0 +1 @@
json.array! @settings_membership_actions, partial: 'settings_membership_actions/settings_membership_action', as: :settings_membership_action

View File

@@ -0,0 +1,5 @@
<h1>New Settings Membership Action</h1>
<%= render 'form', settings_membership_action: @settings_membership_action %>
<%= link_to 'Back', settings_membership_actions_path %>

View File

@@ -0,0 +1,44 @@
<p id="notice"><%= notice %></p>
<p>
<strong>Membership type:</strong>
<%= @settings_membership_action.membership_type %>
</p>
<p>
<strong>Is active:</strong>
<%= @settings_membership_action.is_active %>
</p>
<p>
<strong>Gateway communication type:</strong>
<%= @settings_membership_action.gateway_communication_type %>
</p>
<p>
<strong>Gateway url:</strong>
<%= @settings_membership_action.gateway_url %>
</p>
<p>
<strong>Auth token:</strong>
<%= @settings_membership_action.auth_token %>
</p>
<p>
<strong>Merchant account:</strong>
<%= @settings_membership_action.merchant_account_id %>
</p>
<p>
<strong>Created by:</strong>
<%= @settings_membership_action.created_by %>
</p>
<p>
<strong>Additional parameter:</strong>
<%= @settings_membership_action.additional_parameter %>
</p>
<%= link_to 'Edit', edit_settings_membership_action_path(@settings_membership_action) %> |
<%= link_to 'Back', settings_membership_actions_path %>

View File

@@ -0,0 +1 @@
json.partial! "settings_membership_actions/settings_membership_action", settings_membership_action: @settings_membership_action

View File

@@ -8,6 +8,7 @@
<%= f.input :gateway_url %>
<%= f.input :auth_token %>
<%= f.input :merchant_account_id %>
<%= f.input :additional_parameters %>
</div>
<div class="form-actions">

View File

@@ -1,7 +1,10 @@
require 'sidekiq/web'
Rails.application.routes.draw do
namespace :settings do
resources :membership_actions
end
root 'home#index'
mount Sidekiq::Web => '/kiq'
@@ -72,12 +75,14 @@ Rails.application.routes.draw do
resources :customers, only: [:index,:new, :create ] #add customer type
end
get "/request_bills/:id" => "request_bills#print"
get "/discount/:id" => "discounts#index"
post "/discount" => "discounts#create"
#--------- Payment ------------#
get 'sale/:sale_id/payment' => 'payments#show'
post 'payment_process' => 'payments#create'
post 'paypar_payment_process' => 'paypar_payments#create'
get 'sale/:sale_id/payment/credit_payment' => "credit_payments#index"
get 'sale/:sale_id/payment/others_payment' => "others_payments#index"
@@ -93,12 +98,12 @@ Rails.application.routes.draw do
#--------- Customer Relationship Management ------------#
namespace :crm do
root "home#index" #queue number
#customers
get 'customers/:sale_id/assign_sale_id', to: "customers#get_sale_id", :as => "assign_sale"#get sale id with customer for crm
resources :customers
#membership
#bookings
post "update_booking" , to: "bookings#update_booking", as: "update_booking"
#queue
post "update_booking" , to: "bookings#update_booking", as: "update_booking"#assign and cancel
post "update_sale" , to: "home#update_sale_by_customer"#update customer id in sale table
get '/print/:id', to: "home#print_order"#print order for crm
end
#--------- Order Queue Station ------------#

View File

@@ -1,4 +1,5 @@
class AddCompanyAddressEmail < ActiveRecord::Migration[5.1]
def change
add_column :order_items, :completed_by, :string
end
end

View File

@@ -1,6 +0,0 @@
class OrderItemsCompletedBy < ActiveRecord::Migration[5.1]
def change
add_column :order_items, :completed_by, :string
add_column :order_items, :completed_at, :datetime
end
end

View File

@@ -3,10 +3,10 @@ class CreatePrintSettings < ActiveRecord::Migration[5.1]
create_table :print_settings do |t|
t.string :name, :null => false
t.string :unique_code, :null => false
t.string :template, :null => false
t.string :db_name, :null => false
t.string :db_type, :null => false
t.string :db_username, :null => false
t.string :template
t.string :db_name
t.string :db_type
t.string :db_username
t.string :db_password
t.string :printer_name, :null => false
t.string :api_settings

View File

@@ -0,0 +1,16 @@
class CreateSettingsMembershipActions < ActiveRecord::Migration[5.1]
def change
create_table :settings_membership_actions do |t|
t.string :membership_type
t.boolean :is_active
t.string :gateway_communication_type
t.string :gateway_url
t.string :auth_token
t.string :merchant_account_id
t.string :created_by
t.string :additional_parameter
t.timestamps
end
end
end

View File

@@ -0,0 +1,5 @@
class Additionparametertopaymentsettings < ActiveRecord::Migration[5.1]
def change
add_column :payment_method_settings, :additional_parameters, :string
end
end

View File

@@ -140,9 +140,13 @@ admin_employee = Employee.create({name: "Administrator", role: "Administrator",
food = Account.create({title: "Food", account_type: "0"})
beverage = Account.create({title: "Beverage", account_type: "1"})
shop = Shop.create(
{name: "Beauty In The Pot", address: "address", township: "Yangon", city: "Yangon", state: "Yangon",
country: "Myanmar", phone_no: "09123456789", reservation_no: "bip000001", license: "license",
activated_at: "2017-06-06", license_data: "license_data", base_currency: "Ks", id_prefix: "abc"}
)
order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "EPSON-TM-T82-S-A"})
order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "EPSON-TM-T82-S-A"})
request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "EPSON-TM-T82-S-A"})
# shop = Shop.create(
# {name: "Beauty In The Pot", address: "address", township: "Yangon", city: "Yangon", state: "Yangon",
# country: "Myanmar", phone_no: "09123456789", reservation_no: "bip000001", license: "license",
# activated_at: "2017-06-06", license_data: "license_data", base_currency: "Ks", id_prefix: "abc"}
# )

BIN
dump.rdb

Binary file not shown.

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Api::Origami::PayparController, type: :controller do
end

View File

@@ -0,0 +1,141 @@
require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator. If you are using any extension libraries to generate different
# controller code, this generated spec may or may not pass.
#
# It only uses APIs available in rails and/or rspec-rails. There are a number
# of tools you can use to make these specs even more expressive, but we're
# sticking to rails and rspec-rails APIs to keep things simple and stable.
#
# Compared to earlier versions of this generator, there is very limited use of
# stubs and message expectations in this spec. Stubs are only used when there
# is no simpler way to get a handle on the object needed for the example.
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.
#
# Also compared to earlier versions of this generator, there are no longer any
# expectations of assigns and templates rendered. These features have been
# removed from Rails core in Rails 5, but can be added back in via the
# `rails-controller-testing` gem.
RSpec.describe MembershipActionsController, type: :controller do
# This should return the minimal set of attributes required to create a valid
# MembershipAction. As you add validations to MembershipAction, be sure to
# adjust the attributes here as well.
let(:valid_attributes) {
skip("Add a hash of attributes valid for your model")
}
let(:invalid_attributes) {
skip("Add a hash of attributes invalid for your model")
}
# This should return the minimal set of values that should be in the session
# in order to pass any filters (e.g. authentication) defined in
# MembershipActionsController. Be sure to keep this updated too.
let(:valid_session) { {} }
describe "GET #index" do
it "returns a success response" do
membership_action = MembershipAction.create! valid_attributes
get :index, params: {}, session: valid_session
expect(response).to be_success
end
end
describe "GET #show" do
it "returns a success response" do
membership_action = MembershipAction.create! valid_attributes
get :show, params: {id: membership_action.to_param}, session: valid_session
expect(response).to be_success
end
end
describe "GET #new" do
it "returns a success response" do
get :new, params: {}, session: valid_session
expect(response).to be_success
end
end
describe "GET #edit" do
it "returns a success response" do
membership_action = MembershipAction.create! valid_attributes
get :edit, params: {id: membership_action.to_param}, session: valid_session
expect(response).to be_success
end
end
describe "POST #create" do
context "with valid params" do
it "creates a new MembershipAction" do
expect {
post :create, params: {membership_action: valid_attributes}, session: valid_session
}.to change(MembershipAction, :count).by(1)
end
it "redirects to the created membership_action" do
post :create, params: {membership_action: valid_attributes}, session: valid_session
expect(response).to redirect_to(MembershipAction.last)
end
end
context "with invalid params" do
it "returns a success response (i.e. to display the 'new' template)" do
post :create, params: {membership_action: invalid_attributes}, session: valid_session
expect(response).to be_success
end
end
end
describe "PUT #update" do
context "with valid params" do
let(:new_attributes) {
skip("Add a hash of attributes valid for your model")
}
it "updates the requested membership_action" do
membership_action = MembershipAction.create! valid_attributes
put :update, params: {id: membership_action.to_param, membership_action: new_attributes}, session: valid_session
membership_action.reload
skip("Add assertions for updated state")
end
it "redirects to the membership_action" do
membership_action = MembershipAction.create! valid_attributes
put :update, params: {id: membership_action.to_param, membership_action: valid_attributes}, session: valid_session
expect(response).to redirect_to(membership_action)
end
end
context "with invalid params" do
it "returns a success response (i.e. to display the 'edit' template)" do
membership_action = MembershipAction.create! valid_attributes
put :update, params: {id: membership_action.to_param, membership_action: invalid_attributes}, session: valid_session
expect(response).to be_success
end
end
end
describe "DELETE #destroy" do
it "destroys the requested membership_action" do
membership_action = MembershipAction.create! valid_attributes
expect {
delete :destroy, params: {id: membership_action.to_param}, session: valid_session
}.to change(MembershipAction, :count).by(-1)
end
it "redirects to the membership_actions list" do
membership_action = MembershipAction.create! valid_attributes
delete :destroy, params: {id: membership_action.to_param}, session: valid_session
expect(response).to redirect_to(membership_actions_url)
end
end
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Origami::PayparController, type: :controller do
end

View File

@@ -0,0 +1,141 @@
require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator. If you are using any extension libraries to generate different
# controller code, this generated spec may or may not pass.
#
# It only uses APIs available in rails and/or rspec-rails. There are a number
# of tools you can use to make these specs even more expressive, but we're
# sticking to rails and rspec-rails APIs to keep things simple and stable.
#
# Compared to earlier versions of this generator, there is very limited use of
# stubs and message expectations in this spec. Stubs are only used when there
# is no simpler way to get a handle on the object needed for the example.
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.
#
# Also compared to earlier versions of this generator, there are no longer any
# expectations of assigns and templates rendered. These features have been
# removed from Rails core in Rails 5, but can be added back in via the
# `rails-controller-testing` gem.
RSpec.describe Settings::MembershipActionsController, type: :controller do
# This should return the minimal set of attributes required to create a valid
# Settings::MembershipAction. As you add validations to Settings::MembershipAction, be sure to
# adjust the attributes here as well.
let(:valid_attributes) {
skip("Add a hash of attributes valid for your model")
}
let(:invalid_attributes) {
skip("Add a hash of attributes invalid for your model")
}
# This should return the minimal set of values that should be in the session
# in order to pass any filters (e.g. authentication) defined in
# Settings::MembershipActionsController. Be sure to keep this updated too.
let(:valid_session) { {} }
describe "GET #index" do
it "returns a success response" do
membership_action = Settings::MembershipAction.create! valid_attributes
get :index, params: {}, session: valid_session
expect(response).to be_success
end
end
describe "GET #show" do
it "returns a success response" do
membership_action = Settings::MembershipAction.create! valid_attributes
get :show, params: {id: membership_action.to_param}, session: valid_session
expect(response).to be_success
end
end
describe "GET #new" do
it "returns a success response" do
get :new, params: {}, session: valid_session
expect(response).to be_success
end
end
describe "GET #edit" do
it "returns a success response" do
membership_action = Settings::MembershipAction.create! valid_attributes
get :edit, params: {id: membership_action.to_param}, session: valid_session
expect(response).to be_success
end
end
describe "POST #create" do
context "with valid params" do
it "creates a new Settings::MembershipAction" do
expect {
post :create, params: {settings_membership_action: valid_attributes}, session: valid_session
}.to change(Settings::MembershipAction, :count).by(1)
end
it "redirects to the created settings_membership_action" do
post :create, params: {settings_membership_action: valid_attributes}, session: valid_session
expect(response).to redirect_to(Settings::MembershipAction.last)
end
end
context "with invalid params" do
it "returns a success response (i.e. to display the 'new' template)" do
post :create, params: {settings_membership_action: invalid_attributes}, session: valid_session
expect(response).to be_success
end
end
end
describe "PUT #update" do
context "with valid params" do
let(:new_attributes) {
skip("Add a hash of attributes valid for your model")
}
it "updates the requested settings_membership_action" do
membership_action = Settings::MembershipAction.create! valid_attributes
put :update, params: {id: membership_action.to_param, settings_membership_action: new_attributes}, session: valid_session
membership_action.reload
skip("Add assertions for updated state")
end
it "redirects to the settings_membership_action" do
membership_action = Settings::MembershipAction.create! valid_attributes
put :update, params: {id: membership_action.to_param, settings_membership_action: valid_attributes}, session: valid_session
expect(response).to redirect_to(membership_action)
end
end
context "with invalid params" do
it "returns a success response (i.e. to display the 'edit' template)" do
membership_action = Settings::MembershipAction.create! valid_attributes
put :update, params: {id: membership_action.to_param, settings_membership_action: invalid_attributes}, session: valid_session
expect(response).to be_success
end
end
end
describe "DELETE #destroy" do
it "destroys the requested settings_membership_action" do
membership_action = Settings::MembershipAction.create! valid_attributes
expect {
delete :destroy, params: {id: membership_action.to_param}, session: valid_session
}.to change(Settings::MembershipAction, :count).by(-1)
end
it "redirects to the settings_membership_actions list" do
membership_action = Settings::MembershipAction.create! valid_attributes
delete :destroy, params: {id: membership_action.to_param}, session: valid_session
expect(response).to redirect_to(settings_membership_actions_url)
end
end
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the Api::Origami::PayparHelper. For example:
#
# describe Api::Origami::PayparHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe Api::Origami::PayparHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the MembershipActionsHelper. For example:
#
# describe MembershipActionsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe MembershipActionsHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the Origami::PayparHelper. For example:
#
# describe Origami::PayparHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe Origami::PayparHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the Settings::MembershipActionsHelper. For example:
#
# describe Settings::MembershipActionsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe Settings::MembershipActionsHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe MembershipAction, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Settings::MembershipAction, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,10 @@
require 'rails_helper'
RSpec.describe "MembershipActions", type: :request do
describe "GET /membership_actions" do
it "works! (now write some real specs)" do
get membership_actions_path
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,10 @@
require 'rails_helper'
RSpec.describe "Settings::MembershipActions", type: :request do
describe "GET /settings_membership_actions" do
it "works! (now write some real specs)" do
get settings_membership_actions_path
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,39 @@
require "rails_helper"
RSpec.describe MembershipActionsController, type: :routing do
describe "routing" do
it "routes to #index" do
expect(:get => "/membership_actions").to route_to("membership_actions#index")
end
it "routes to #new" do
expect(:get => "/membership_actions/new").to route_to("membership_actions#new")
end
it "routes to #show" do
expect(:get => "/membership_actions/1").to route_to("membership_actions#show", :id => "1")
end
it "routes to #edit" do
expect(:get => "/membership_actions/1/edit").to route_to("membership_actions#edit", :id => "1")
end
it "routes to #create" do
expect(:post => "/membership_actions").to route_to("membership_actions#create")
end
it "routes to #update via PUT" do
expect(:put => "/membership_actions/1").to route_to("membership_actions#update", :id => "1")
end
it "routes to #update via PATCH" do
expect(:patch => "/membership_actions/1").to route_to("membership_actions#update", :id => "1")
end
it "routes to #destroy" do
expect(:delete => "/membership_actions/1").to route_to("membership_actions#destroy", :id => "1")
end
end
end

View File

@@ -0,0 +1,39 @@
require "rails_helper"
RSpec.describe Settings::MembershipActionsController, type: :routing do
describe "routing" do
it "routes to #index" do
expect(:get => "/settings/membership_actions").to route_to("settings/membership_actions#index")
end
it "routes to #new" do
expect(:get => "/settings/membership_actions/new").to route_to("settings/membership_actions#new")
end
it "routes to #show" do
expect(:get => "/settings/membership_actions/1").to route_to("settings/membership_actions#show", :id => "1")
end
it "routes to #edit" do
expect(:get => "/settings/membership_actions/1/edit").to route_to("settings/membership_actions#edit", :id => "1")
end
it "routes to #create" do
expect(:post => "/settings/membership_actions").to route_to("settings/membership_actions#create")
end
it "routes to #update via PUT" do
expect(:put => "/settings/membership_actions/1").to route_to("settings/membership_actions#update", :id => "1")
end
it "routes to #update via PATCH" do
expect(:patch => "/settings/membership_actions/1").to route_to("settings/membership_actions#update", :id => "1")
end
it "routes to #destroy" do
expect(:delete => "/settings/membership_actions/1").to route_to("settings/membership_actions#destroy", :id => "1")
end
end
end

View File

@@ -0,0 +1,39 @@
require 'rails_helper'
RSpec.describe "membership_actions/edit", type: :view do
before(:each) do
@membership_action = assign(:membership_action, MembershipAction.create!(
:membership_type => "MyString",
:is_active => false,
:gateway_communication_type => "MyString",
:gateway_url => "MyString",
:auth_token => "MyString",
:merchant_account_id => "MyString",
:created_by => "MyString",
:additional_parameter => ""
))
end
it "renders the edit membership_action form" do
render
assert_select "form[action=?][method=?]", membership_action_path(@membership_action), "post" do
assert_select "input[name=?]", "membership_action[membership_type]"
assert_select "input[name=?]", "membership_action[is_active]"
assert_select "input[name=?]", "membership_action[gateway_communication_type]"
assert_select "input[name=?]", "membership_action[gateway_url]"
assert_select "input[name=?]", "membership_action[auth_token]"
assert_select "input[name=?]", "membership_action[merchant_account_id]"
assert_select "input[name=?]", "membership_action[created_by]"
assert_select "input[name=?]", "membership_action[additional_parameter]"
end
end
end

View File

@@ -0,0 +1,40 @@
require 'rails_helper'
RSpec.describe "membership_actions/index", type: :view do
before(:each) do
assign(:membership_actions, [
MembershipAction.create!(
:membership_type => "Membership Type",
:is_active => false,
:gateway_communication_type => "Gateway Communication Type",
:gateway_url => "Gateway Url",
:auth_token => "Auth Token",
:merchant_account_id => "Merchant Account",
:created_by => "Created By",
:additional_parameter => ""
),
MembershipAction.create!(
:membership_type => "Membership Type",
:is_active => false,
:gateway_communication_type => "Gateway Communication Type",
:gateway_url => "Gateway Url",
:auth_token => "Auth Token",
:merchant_account_id => "Merchant Account",
:created_by => "Created By",
:additional_parameter => ""
)
])
end
it "renders a list of membership_actions" do
render
assert_select "tr>td", :text => "Membership Type".to_s, :count => 2
assert_select "tr>td", :text => false.to_s, :count => 2
assert_select "tr>td", :text => "Gateway Communication Type".to_s, :count => 2
assert_select "tr>td", :text => "Gateway Url".to_s, :count => 2
assert_select "tr>td", :text => "Auth Token".to_s, :count => 2
assert_select "tr>td", :text => "Merchant Account".to_s, :count => 2
assert_select "tr>td", :text => "Created By".to_s, :count => 2
assert_select "tr>td", :text => "".to_s, :count => 2
end
end

View File

@@ -0,0 +1,39 @@
require 'rails_helper'
RSpec.describe "membership_actions/new", type: :view do
before(:each) do
assign(:membership_action, MembershipAction.new(
:membership_type => "MyString",
:is_active => false,
:gateway_communication_type => "MyString",
:gateway_url => "MyString",
:auth_token => "MyString",
:merchant_account_id => "MyString",
:created_by => "MyString",
:additional_parameter => ""
))
end
it "renders new membership_action form" do
render
assert_select "form[action=?][method=?]", membership_actions_path, "post" do
assert_select "input[name=?]", "membership_action[membership_type]"
assert_select "input[name=?]", "membership_action[is_active]"
assert_select "input[name=?]", "membership_action[gateway_communication_type]"
assert_select "input[name=?]", "membership_action[gateway_url]"
assert_select "input[name=?]", "membership_action[auth_token]"
assert_select "input[name=?]", "membership_action[merchant_account_id]"
assert_select "input[name=?]", "membership_action[created_by]"
assert_select "input[name=?]", "membership_action[additional_parameter]"
end
end
end

View File

@@ -0,0 +1,28 @@
require 'rails_helper'
RSpec.describe "membership_actions/show", type: :view do
before(:each) do
@membership_action = assign(:membership_action, MembershipAction.create!(
:membership_type => "Membership Type",
:is_active => false,
:gateway_communication_type => "Gateway Communication Type",
:gateway_url => "Gateway Url",
:auth_token => "Auth Token",
:merchant_account_id => "Merchant Account",
:created_by => "Created By",
:additional_parameter => ""
))
end
it "renders attributes in <p>" do
render
expect(rendered).to match(/Membership Type/)
expect(rendered).to match(/false/)
expect(rendered).to match(/Gateway Communication Type/)
expect(rendered).to match(/Gateway Url/)
expect(rendered).to match(/Auth Token/)
expect(rendered).to match(/Merchant Account/)
expect(rendered).to match(/Created By/)
expect(rendered).to match(//)
end
end

View File

@@ -0,0 +1,39 @@
require 'rails_helper'
RSpec.describe "settings/membership_actions/edit", type: :view do
before(:each) do
@settings_membership_action = assign(:settings_membership_action, Settings::MembershipAction.create!(
:membership_type => "MyString",
:is_active => false,
:gateway_communication_type => "MyString",
:gateway_url => "MyString",
:auth_token => "MyString",
:merchant_account_id => "MyString",
:created_by => "MyString",
:additional_parameter => "MyString"
))
end
it "renders the edit settings_membership_action form" do
render
assert_select "form[action=?][method=?]", settings_membership_action_path(@settings_membership_action), "post" do
assert_select "input[name=?]", "settings_membership_action[membership_type]"
assert_select "input[name=?]", "settings_membership_action[is_active]"
assert_select "input[name=?]", "settings_membership_action[gateway_communication_type]"
assert_select "input[name=?]", "settings_membership_action[gateway_url]"
assert_select "input[name=?]", "settings_membership_action[auth_token]"
assert_select "input[name=?]", "settings_membership_action[merchant_account_id]"
assert_select "input[name=?]", "settings_membership_action[created_by]"
assert_select "input[name=?]", "settings_membership_action[additional_parameter]"
end
end
end

View File

@@ -0,0 +1,40 @@
require 'rails_helper'
RSpec.describe "settings/membership_actions/index", type: :view do
before(:each) do
assign(:settings_membership_actions, [
Settings::MembershipAction.create!(
:membership_type => "Membership Type",
:is_active => false,
:gateway_communication_type => "Gateway Communication Type",
:gateway_url => "Gateway Url",
:auth_token => "Auth Token",
:merchant_account_id => "Merchant Account",
:created_by => "Created By",
:additional_parameter => "Additional Parameter"
),
Settings::MembershipAction.create!(
:membership_type => "Membership Type",
:is_active => false,
:gateway_communication_type => "Gateway Communication Type",
:gateway_url => "Gateway Url",
:auth_token => "Auth Token",
:merchant_account_id => "Merchant Account",
:created_by => "Created By",
:additional_parameter => "Additional Parameter"
)
])
end
it "renders a list of settings/membership_actions" do
render
assert_select "tr>td", :text => "Membership Type".to_s, :count => 2
assert_select "tr>td", :text => false.to_s, :count => 2
assert_select "tr>td", :text => "Gateway Communication Type".to_s, :count => 2
assert_select "tr>td", :text => "Gateway Url".to_s, :count => 2
assert_select "tr>td", :text => "Auth Token".to_s, :count => 2
assert_select "tr>td", :text => "Merchant Account".to_s, :count => 2
assert_select "tr>td", :text => "Created By".to_s, :count => 2
assert_select "tr>td", :text => "Additional Parameter".to_s, :count => 2
end
end

View File

@@ -0,0 +1,39 @@
require 'rails_helper'
RSpec.describe "settings/membership_actions/new", type: :view do
before(:each) do
assign(:settings_membership_action, Settings::MembershipAction.new(
:membership_type => "MyString",
:is_active => false,
:gateway_communication_type => "MyString",
:gateway_url => "MyString",
:auth_token => "MyString",
:merchant_account_id => "MyString",
:created_by => "MyString",
:additional_parameter => "MyString"
))
end
it "renders new settings_membership_action form" do
render
assert_select "form[action=?][method=?]", settings_membership_actions_path, "post" do
assert_select "input[name=?]", "settings_membership_action[membership_type]"
assert_select "input[name=?]", "settings_membership_action[is_active]"
assert_select "input[name=?]", "settings_membership_action[gateway_communication_type]"
assert_select "input[name=?]", "settings_membership_action[gateway_url]"
assert_select "input[name=?]", "settings_membership_action[auth_token]"
assert_select "input[name=?]", "settings_membership_action[merchant_account_id]"
assert_select "input[name=?]", "settings_membership_action[created_by]"
assert_select "input[name=?]", "settings_membership_action[additional_parameter]"
end
end
end

View File

@@ -0,0 +1,28 @@
require 'rails_helper'
RSpec.describe "settings/membership_actions/show", type: :view do
before(:each) do
@settings_membership_action = assign(:settings_membership_action, Settings::MembershipAction.create!(
:membership_type => "Membership Type",
:is_active => false,
:gateway_communication_type => "Gateway Communication Type",
:gateway_url => "Gateway Url",
:auth_token => "Auth Token",
:merchant_account_id => "Merchant Account",
:created_by => "Created By",
:additional_parameter => "Additional Parameter"
))
end
it "renders attributes in <p>" do
render
expect(rendered).to match(/Membership Type/)
expect(rendered).to match(/false/)
expect(rendered).to match(/Gateway Communication Type/)
expect(rendered).to match(/Gateway Url/)
expect(rendered).to match(/Auth Token/)
expect(rendered).to match(/Merchant Account/)
expect(rendered).to match(/Created By/)
expect(rendered).to match(/Additional Parameter/)
end
end

View File

@@ -0,0 +1,9 @@
require "application_system_test_case"
class Settings::MembershipActionsTest < ApplicationSystemTestCase
# test "visiting the index" do
# visit settings_membership_actions_url
#
# assert_selector "h1", text: "Settings::MembershipAction"
# end
end