fixed conflict file

This commit is contained in:
Aung Myo
2017-06-13 10:40:49 +06:30
19 changed files with 196 additions and 120 deletions

View File

@@ -12,7 +12,7 @@ gem 'rails', '~> 5.1.0'
gem 'mysql2', '>= 0.3.18', '< 0.5'
#Use PosgreSQL
# gem 'pg'
gem 'pg'
# redis server for cable
# gem 'redis', '~> 3.0'

View File

@@ -110,6 +110,7 @@ GEM
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
pdf-core (0.7.0)
pg (0.20.0)
prawn (2.2.2)
pdf-core (~> 0.7.0)
ttfunk (~> 1.5)
@@ -246,6 +247,7 @@ DEPENDENCIES
kaminari (~> 0.16.3)
listen (~> 3.0.5)
mysql2 (>= 0.3.18, < 0.5)
pg
prawn
prawn-table
puma (~> 3.0)

View File

@@ -68,11 +68,12 @@ $(document).ready(function(){
// Receipt Header
receipt_no = result[i].receipt_no;
cashier = result[i].cashier_name;
receipt_date = result[i].receipt_date;
receipt_date = new Date(result[i].receipt_date);
show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes()
$("#receipt_no").text(receipt_no);
$("#cashier").text(cashier == null ? "" : cashier);
$("#receipt_date").text(receipt_date);
$("#receipt_date").text(show_date);
//Receipt Charges
@@ -132,7 +133,8 @@ $(document).ready(function(){
});
// Pay Discount for Payment
$("#pay-discount").on('click', function(){
$("#pay-discount").on('click', function(e){
e.preventDefault();
var sale_id = $('#sale-id').text();
var sale_item_id = $('.selected-item').attr('id');
var sub_total = $('#order-sub-total').text();
@@ -140,10 +142,10 @@ $(document).ready(function(){
var discount_type = $('#discount-type').val();
var discount_value = $('#discount-amount').val();
var discount_amount = discount_value;
var ajax_url = "/origami/" + sale_id + "/discount";
if(sale_item_id == null){
alert('Please select item row to discount!');
return;
if(sale_item_id != null){
ajax_url = "/origami/" + sale_item_id + "/discount";
}
// For Percentage Discount
@@ -154,7 +156,7 @@ $(document).ready(function(){
var params = {'sale_id': sale_id, 'sale_item_id': sale_item_id, 'grand_total' : grand_total, 'discount_type':discount_type, 'discount_value':discount_value, 'discount_amount':discount_amount};
$.ajax({
type: "POST",
url: "/origami/" + sale_item_id + "/discount",
url: ajax_url,
data: params,
success:function(result){ }
});

View File

@@ -8,9 +8,15 @@ class Api::BillController < Api::ApiController
#create Bill by Booking ID
if (params[:booking_id])
@sale = Sale.new
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee.name)
booking = Booking.find(params[:booking_id])
if booking
if booking.sale_id.nil?
@sale = Sale.new
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee.name)
else
@status = true
end
end
elsif (params[:order_id])
@sale = Sale.new
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee.name)

View File

@@ -1,8 +1,77 @@
class BaseReportController < ActionController::Base
include LoginVerification
include LoginVerification
layout "application"
#before_action :check_installation
protect_from_forgery with: :exception
#before_action :check_installation
protect_from_forgery with: :exception
PERIOD = {
"today" => 0,
"yesterday" => 1,
"this_week" => 2,
"last_week" => 3,
"last_7" => 4,
"this_month" => 5,
"last_month" => 6,
"last_30" => 7,
"this_year" => 8,
"last_year" => 9
}
def get_date_range_from_params
period_type = params[:period_type]
period = params[:period]
from = params[:from]
to = params[:to]
day_ref = Time.now
if period_type.to_i == 1
if params[:from] && params[:to]
if params[:from] != "" && params[:to] !=""
from = DateTime.strptime(params[:from], "%m/%d/%Y")
to = DateTime.strptime(params[:to], "%m/%d/%Y")
else
from = day_ref.beginning_of_day.utc
to = day_ref.end_of_day.utc
end
end
else
case period.to_i
when PERIOD["today"]
from = day_ref.beginning_of_day.utc
to = day_ref.end_of_day.utc
when PERIOD["yesterday"]
from = (day_ref - 1.day).beginning_of_day.utc
to = (day_ref - 1.day).end_of_day.utc
when PERIOD["this_week"]
from = Time.now.beginning_of_week.utc
to = Time.now.utc
when PERIOD["last_week"]
from = (day_ref - 7.day).beginning_of_week.utc
to = (day_ref - 7.day).end_of_week.utc
when PERIOD["last_7"]
from = (day_ref - 7.day).utc
to = Time.now.utc
when PERIOD["this_month"]
from = Time.now.beginning_of_month.utc
to = Time.now.utc
when PERIOD["last_month"]
from = (day_ref - 1.month).beginning_of_month.utc
to = (day_ref - 1.month).end_of_month.utc
when PERIOD["last_30"]
from = (day_ref - 30.day).utc
to = Time.now.utc
when PERIOD["this_year"]
from = Time.now.beginning_of_year.utc
to = Time.now.utc
when PERIOD["last_year"]
from = (day_ref - 1.year).beginning_of_year.utc
to = (day_ref - 1.year).end_of_year.utc
end
end
return from, to
end
end

View File

@@ -5,7 +5,7 @@ class Crm::CustomersController < BaseCrmController
# GET /crm/customers.json
def index
filter = params[:filter]
if filter.nil?
@crm_customers = Customer.order("customer_id").page(params[:page])
#@products = Product.order("name").page(params[:page]).per(5)
@@ -31,7 +31,7 @@ class Crm::CustomersController < BaseCrmController
# GET /crm/customers/1.json
def show
@orders = Order.where("customer_id=?", params[:id])
if @orders
@order_items = []
@orders.each do |bo|
@@ -57,7 +57,6 @@ class Crm::CustomersController < BaseCrmController
def create
@crm_customers = Customer.new(customer_params)
respond_to do |format|
puts @crm_customers.errors.to_json
if @crm_customers.save
@@ -73,7 +72,9 @@ class Crm::CustomersController < BaseCrmController
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
dob: dob,
member_group_id: member_group_id,merchant_uid:merchant_uid}.to_json,
:headers => {
'Content-Type' => 'application/json',
@@ -82,18 +83,18 @@ class Crm::CustomersController < BaseCrmController
)
if response["status"] == true
customer = Customer.find(@crm_customers.customer_id)
status = customer.update_attributes(membership_id: response["customer_datas"]["id"])
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer', notice: 'Customer was successfully created.' }
else
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'}
end
end
# format.json { render :index, status: :created, location: @crm_customers }
else
@crm_customers.destroy
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'}
@@ -104,7 +105,7 @@ class Crm::CustomersController < BaseCrmController
else
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'}
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'}
else
format.html { redirect_to crm_customers_path}
@@ -133,7 +134,7 @@ end
memberaction = MembershipAction.find_by_membership_type("update_membership_customer")
merchant_uid = memberaction.merchant_account_id.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
dob: dob,
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid}.to_json,

View File

@@ -30,13 +30,15 @@ class Origami::DiscountsController < BaseOrigamiController
sale.save
#save sale item for discount
origin_sale_item = SaleItem.find(sale_item_id)
if sale_item_id != nil
origin_sale_item = SaleItem.find(sale_item_id)
end
sale_item = SaleItem.new
#pull
sale_item.sale_id = sale_id
sale_item.product_code = origin_sale_item.product_code
sale_item.product_name = origin_sale_item.product_name + " Discount"
sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
sale_item.product_name = "Overall Discount"
sale_item.remark = remark
sale_item.qty = 1

View File

@@ -49,8 +49,8 @@ class Origami::PaymentsController < BaseOrigamiController
if spay.payment_method == "cash"
@cash = spay.payment_amount
end
if spay.payment_method == "mpu"
@other = spay.payment_amount
if spay.payment_method == "mpu" || spay.payment_method == "paypar"
@other += spay.payment_amount
end
end
end

View File

@@ -0,0 +1,21 @@
class Reports::DailySaleController < BaseReportController
PERIOD = {
"today" => 0,
"yesterday" => 1,
"this_week" => 2,
"last_week" => 3,
"last_7" => 4,
"this_month" => 5,
"last_month" => 6,
"last_30" => 7,
"this_year" => 8,
"last_year" => 9
}
def index
from, to = get_date_range_from_params
@sale_data = Sale.get_receipt_no_list(from,to)
@sale_data = Kaminari.paginate_array(@sale_data).page(params[:page]).per(50)
end
end

View File

@@ -1,17 +1,4 @@
class Reports::ReceiptNoController < ApplicationController
PERIOD = {
"today" => 0,
"yesterday" => 1,
"this_week" => 2,
"last_week" => 3,
"last_7" => 4,
"this_month" => 5,
"last_month" => 6,
"last_30" => 7,
"this_year" => 8,
"last_year" => 9
}
class Reports::ReceiptNoController < BaseReportController
def index
from, to = get_date_range_from_params
puts "from..."
@@ -25,61 +12,4 @@ class Reports::ReceiptNoController < ApplicationController
def show
end
private
def get_date_range_from_params
period_type = params[:period_type]
period = params[:period]
from = params[:from]
to = params[:to]
day_ref = Time.now
if period_type.to_i == 1
if params[:from] && params[:to]
if params[:from] != "" && params[:to] !=""
from = DateTime.strptime(params[:from], "%m/%d/%Y")
to = DateTime.strptime(params[:to], "%m/%d/%Y")
else
from = day_ref.beginning_of_day.utc
to = day_ref.end_of_day.utc
end
end
else
case period.to_i
when PERIOD["today"]
from = day_ref.beginning_of_day.utc
to = day_ref.end_of_day.utc
when PERIOD["yesterday"]
from = (day_ref - 1.day).beginning_of_day.utc
to = (day_ref - 1.day).end_of_day.utc
when PERIOD["this_week"]
from = Time.now.beginning_of_week.utc
to = Time.now.utc
when PERIOD["last_week"]
from = (day_ref - 7.day).beginning_of_week.utc
to = (day_ref - 7.day).end_of_week.utc
when PERIOD["last_7"]
from = (day_ref - 7.day).utc
to = Time.now.utc
when PERIOD["this_month"]
from = Time.now.beginning_of_month.utc
to = Time.now.utc
when PERIOD["last_month"]
from = (day_ref - 1.month).beginning_of_month.utc
to = (day_ref - 1.month).end_of_month.utc
when PERIOD["last_30"]
from = (day_ref - 30.day).utc
to = Time.now.utc
when PERIOD["this_year"]
from = Time.now.beginning_of_year.utc
to = Time.now.utc
when PERIOD["last_year"]
from = (day_ref - 1.year).beginning_of_year.utc
to = (day_ref - 1.year).end_of_year.utc
end
end
return from, to
end
end

View File

@@ -223,7 +223,7 @@ class Order < ApplicationRecord
#Origami: Cashier : to view booking order Table
def self.get_booking_order_table
booking_orders = Booking.select("sales.receipt_no,orders.status as order_status,
booking_orders = Booking.select("sales.receipt_no,orders.status as order_status, sales.sale_status as sale_status,
orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id,
bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
.joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id")
@@ -232,7 +232,6 @@ class Order < ApplicationRecord
.joins("left join sales on sales.sale_id = bookings.sale_id")
.where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true)
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id")
end
#Origami: Cashier : to view booking order Table
@@ -244,13 +243,12 @@ class Order < ApplicationRecord
.joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join sales on sales.sale_id = bookings.sale_id")
.where("sales.sale_status='completed'")
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status")
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id")
end
#Origami: Cashier : to view order type Room
def self.get_booking_order_rooms
booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status,
booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status, sales.sale_status as sale_status,
orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id,
bookings.booking_id,orders.customer_id as customer_id,
sales.sale_id as sale_id,dining_facilities.name as room_name")
@@ -259,8 +257,8 @@ class Order < ApplicationRecord
.joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join sale_orders on sale_orders.order_id = orders.order_id")
.joins("left join sales on sales.sale_id = sale_orders.sale_id")
.where("sales.sale_status<>'completed' and sales.sale_status<>'complete' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true)
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id")
.where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true)
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id")
end
#Origami: Cashier : to view order type Room
@@ -280,7 +278,7 @@ class Order < ApplicationRecord
def self.get_orders
from = Time.now.beginning_of_day.utc
to = Time.now.end_of_day.utc
orders = Order.select("orders.order_id as order_id,sales.receipt_no,orders.status as order_status,
orders = Order.select("orders.order_id as order_id,sales.receipt_no,orders.status as order_status, sales.sale_status as sale_status,
orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id
,bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
.joins("left join booking_orders on booking_orders.order_id = orders.order_id
@@ -289,7 +287,7 @@ class Order < ApplicationRecord
left join order_items on order_items.order_id = orders.order_id
left join sale_orders on sale_orders.order_id = orders.order_id
left join sales on sales.sale_id = sale_orders.sale_id")
.where("sales.sale_status<>'completed' and dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
.where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
.group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id,orders.customer_id")
end

View File

@@ -60,7 +60,7 @@ class SalePayment < ApplicationRecord
#record an payment in sale-audit
remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
sale_audit = SaleAudit.record_payment(invoice.id, remark,action_by)
return false, "No outstanding Amount"
end
@@ -217,7 +217,7 @@ class SalePayment < ApplicationRecord
self.sale.sale_status = "completed"
self.sale.save!
table_update_status(sObj)
rebat()
rebat(sObj)
end
end
@@ -233,8 +233,37 @@ class SalePayment < ApplicationRecord
end
end
def rebat
def rebat(sObj)
food_prices, beverage_prices = SaleItem.calculate_food_beverage(sObj.sale_items)
generic_customer_id = sObj.customer.membership_id
if generic_customer_id != nil || generic_customer_id != ""
paypar = sObj.sale_payments
payparcost = 0
paypar.each do |pp|
if pp.payment_method == "paypar"
payparcost = payparcost + pp.payment_amount
end
end
total_amount = food_prices - payparcost
puts "aaaa"
puts food_prices
puts payparcost
puts total_amount
receipt_no = sObj.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("rebate")
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
app_token = membership.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,total_amount: total_amount,campaign_type_id: campaign_type_id,
receipt_no: receipt_no}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
})
puts response.to_json
end
end
private

View File

@@ -27,8 +27,8 @@
<li class="navbar-nav mr-auto dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">&nbsp;&nbsp;&nbsp;Transactions</a>
<ul class="dropdown-menu">
<li><%= link_to "Orders ", origami_root_path, :tabindex =>"-1" %></li>
<li><%= link_to "Sales ", crm_root_path, :tabindex =>"-1" %></li>
<li><%= link_to "Orders ", settings_orders_path, :tabindex =>"-1" %></li>
<li><%= link_to "Sales ", settings_sales_path, :tabindex =>"-1" %></li>
</ul>
</li>
<li class="navbar-nav mr-auto dropdown">

View File

@@ -60,7 +60,7 @@
<p class="hidden orders-id"><%= unique_id %></p>
<p class="hidden customer-id"><%= customer_id %></p>
<p class="hidden order-cid"><%= cpo.order_id %></p>
<h4 class="card-title orders-table"><%= cpo.table_name %></h4>
<h4 class="card-title orders-table"><%= cpo.table_name %></h4>
<p class="card-text">
Receipt No :
<span class="orders-receipt-no">
@@ -87,6 +87,11 @@
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@booking_orders.each do |bko|
# No Show completed
if bko.sale_status == 'completed'
next
end
# Assigned Id for new Order? Sale?
unique_id=""
customer_id=""
@@ -96,7 +101,7 @@
unique_id=bko.booking_id
customer_id=bko.order_customer_id
# check selected item and assign
if @selected_item != nil
if !@selected_item.nil?
if bko.order_id == @selected_item.order_id
sale_status = sale_status + " selected-item"
end
@@ -145,6 +150,11 @@
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@booking_rooms.each do |rmo|
# No Show completed
if rmo.sale_status == 'completed'
next
end
# Assigned Id for new Order? Sale?
unique_id=""
customer_id=""
@@ -204,6 +214,10 @@
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@orders.each do |odr|
# No Show completed
if odr.sale_status == 'completed'
next
end
# Assigned Id for new Order? Sale?
unique_id=""
customer_id=""
@@ -302,7 +316,7 @@
sub_total = 0
if @selected_item_type == "Sale"
@selected_item.sale_items.each do |sale_item|
sub_total += sale_item.qty*sale_item.unit_price
sub_total += (sale_item.qty*sale_item.unit_price)
%>
<tr>
<td class='item-name'><%= sale_item.product_name %></td>
@@ -319,7 +333,7 @@
sub_total = 0
if @selected_item_type == "Order"
@selected_item.order_items.each do |order_item|
sub_total += order_item.qty*order_item.unit_price
sub_total += (order_item.qty*order_item.unit_price)
%>
<tr>
<td class='item-name'><%= order_item.item_name %></td>
@@ -337,7 +351,7 @@
<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>
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr>
<!-- <tr>
<td class="charges-name"><strong>Food:</strong></td>

View File

@@ -1,5 +1,6 @@
<%= form_tag report_path, :method => :get, :id=>"frm_report" do %>
<div class="row">
<div class="col-md-12"></div>
<div class="span3">
<% if defined? product_account %>
<%= select_tag "account", options_from_collection_for_select(@accounts,"id","title", :selected => params[:account])%>

View File

@@ -8,6 +8,7 @@
</span>
</ul>
</div>
<div class="card">
<table class="table table-striped">
<thead>

View File

@@ -9,7 +9,7 @@ Rails.application.routes.draw do
mount Sidekiq::Web => '/kiq'
# Action Cable Creation
# mount ActionCable.server => "/cable"
mount ActionCable.server => "/cable"
#--------- SmartSales Installation ------------#
get 'install' => 'install#index'

View File

@@ -157,7 +157,7 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance",
])
payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http//192.168.1.47:3006"})
payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http//192.168.1.47:3006"})
payment_methods = PaymentMethodSetting.create({payment_method:"REDEEMREBATE",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"})