merge all 03062017
This commit is contained in:
3
app/assets/javascripts/origami/request_bills.coffee
Normal file
3
app/assets/javascripts/origami/request_bills.coffee
Normal 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/
|
||||
3
app/assets/stylesheets/origami/request_bills.scss
Normal file
3
app/assets/stylesheets/origami/request_bills.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the origami/RequestBills controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
@@ -0,0 +1,84 @@
|
||||
body {
|
||||
background-color: #fff;
|
||||
color: #333;
|
||||
margin: 33px;
|
||||
font-family: verdana, arial, helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
p, ol, ul, td {
|
||||
font-family: verdana, arial, helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color: #eee;
|
||||
padding: 10px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #000;
|
||||
|
||||
&:visited {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: #fff;
|
||||
background-color: #000;
|
||||
}
|
||||
}
|
||||
|
||||
th {
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 0 5px 7px;
|
||||
}
|
||||
|
||||
div {
|
||||
&.field, &.actions {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
#notice {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.field_with_errors {
|
||||
padding: 2px;
|
||||
background-color: red;
|
||||
display: table;
|
||||
}
|
||||
|
||||
#error_explanation {
|
||||
width: 450px;
|
||||
border: 2px solid red;
|
||||
padding: 7px 7px 0;
|
||||
margin-bottom: 20px;
|
||||
background-color: #f0f0f0;
|
||||
|
||||
h2 {
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
padding: 5px 5px 5px 15px;
|
||||
font-size: 12px;
|
||||
margin: -7px -7px 0;
|
||||
background-color: #c00;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
ul li {
|
||||
font-size: 12px;
|
||||
list-style: square;
|
||||
}
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
13
app/controllers/origami/request_bills_controller.rb
Normal file
13
app/controllers/origami/request_bills_controller.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class Origami::RequestBillsController < BaseOrigamiController
|
||||
def show
|
||||
@sale = Sale.new
|
||||
check_order = Order.find_by_id(params[:id])
|
||||
if check_order
|
||||
@order_details = OrderItem.get_order_items_details(check_order.id)
|
||||
@order_details = OrderItem.get_order_items_details(check_order.id)
|
||||
@status, @sale_id = @sale.generate_invoice_from_order(check_order.id, nil,current_login_employee.name)
|
||||
@sale_data = Sale.find_by_id(@sale_id)
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
73
app/controllers/settings/accounts_controller.rb
Normal file
73
app/controllers/settings/accounts_controller.rb
Normal file
@@ -0,0 +1,73 @@
|
||||
class Settings::AccountsController < ApplicationController
|
||||
before_action :set_account, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /settings/accounts
|
||||
# GET /settings/accounts.json
|
||||
def index
|
||||
@settings_accounts = Account.all
|
||||
end
|
||||
|
||||
# GET /settings/accounts/1
|
||||
# GET /settings/accounts/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /settings/accounts/new
|
||||
def new
|
||||
@settings_account = Account.new
|
||||
end
|
||||
|
||||
# GET /settings/accounts/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /settings/accounts
|
||||
# POST /settings/accounts.json
|
||||
def create
|
||||
@settings_account = Account.new(account_params)
|
||||
respond_to do |format|
|
||||
if @settings_account.save!
|
||||
format.html { redirect_to settings_accounts_url, notice: 'Account was successfully created.' }
|
||||
format.json { render :index, status: :created, location: @settings_account }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: settings_accounts_url.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /settings/accounts/1
|
||||
# PATCH/PUT /settings/accounts/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @settings_account.update(account_params)
|
||||
format.html { redirect_to settings_accounts_url, notice: 'Account was successfully updated.' }
|
||||
format.json { render :index, status: :ok, location: @settings_account }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: settings_accounts_url.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /settings/accounts/1
|
||||
# DELETE /settings/accounts/1.json
|
||||
def destroy
|
||||
@settings_account.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_accounts_url, notice: 'Account was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_account
|
||||
@settings_account = Account.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def account_params
|
||||
params.require(:account).permit(:title, :account_type)
|
||||
end
|
||||
end
|
||||
2
app/helpers/origami/request_bills_helper.rb
Normal file
2
app/helpers/origami/request_bills_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Origami::RequestBillsHelper
|
||||
end
|
||||
2
app/helpers/settings/accounts_helper.rb
Normal file
2
app/helpers/settings/accounts_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Settings::AccountsHelper
|
||||
end
|
||||
7
app/models/account.rb
Normal file
7
app/models/account.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class Account < ApplicationRecord
|
||||
validates_presence_of :title, :account_type
|
||||
|
||||
has_many :menu_items
|
||||
# belongs_to :lookup , :class_name => "Lookup" ,:foreign_key => :tax_type
|
||||
|
||||
end
|
||||
5
app/models/crm.rb
Normal file
5
app/models/crm.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
module Crm
|
||||
def self.table_name_prefix
|
||||
'crm_'
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,6 @@
|
||||
class Lookup < ApplicationRecord
|
||||
|
||||
has_many :accounts
|
||||
|
||||
def available_types
|
||||
{'Employee Roles' => 'employee_roles',
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
class MenuItem < ApplicationRecord
|
||||
belongs_to :account
|
||||
belongs_to :menu_category, :optional => true
|
||||
has_many :menu_item_instances
|
||||
belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
|
||||
has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
|
||||
|
||||
validates_presence_of :item_code, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item
|
||||
|
||||
default_scope { order('item_code asc') }
|
||||
|
||||
@@ -16,6 +16,7 @@ class Order < ApplicationRecord
|
||||
# option_values : [],
|
||||
# sub_order_items : [],
|
||||
# }
|
||||
|
||||
def generate
|
||||
booking = nil
|
||||
|
||||
@@ -235,13 +236,15 @@ class Order < ApplicationRecord
|
||||
end
|
||||
#Origami: Cashier : to view orders
|
||||
def self.get_orders
|
||||
from = Time.now.beginning_of_day.utc
|
||||
to = Time.now.end_of_day.utc
|
||||
orders = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price,
|
||||
order_items.id as order_items_id,dining_facilities.name as table_or_room_name")
|
||||
.joins("left join booking_orders on booking_orders.order_id = orders.id
|
||||
left join bookings on bookings.id = booking_orders.id
|
||||
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
|
||||
left join order_items on order_items.order_id = orders.id")
|
||||
.where("dining_facilities.is_active=?",true)
|
||||
.where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
|
||||
.group("orders.id")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -188,7 +188,8 @@ class Sale < ApplicationRecord
|
||||
sale_tax.tax_name = tax.name
|
||||
sale_tax.tax_rate = tax.rate
|
||||
#include or execulive
|
||||
sale_tax.tax_payable_amount = total_taxable * tax.rate
|
||||
# sale_tax.tax_payable_amount = total_taxable * tax.rate
|
||||
sale_tax.tax_payable_amount = total_taxable * tax.rate / 100
|
||||
#new taxable amount
|
||||
total_taxable = total_taxable + sale_tax.tax_payable_amount
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="row">
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-8">
|
||||
<!-- Column One -->
|
||||
|
||||
@@ -22,15 +22,15 @@
|
||||
<div class="tab-pane active" id="tables" role="tabpanel">
|
||||
<!--- Booking Items -->
|
||||
<div class="card-columns" style="padding-top:10px">
|
||||
|
||||
<% @order_table.each do |order_table| %>
|
||||
<div class="card" id="table-order-<%=order_table.order_id%>" onclick="callOrderDetails('<%=order_table.order_id%>')">
|
||||
|
||||
<div class="card-block">
|
||||
<h4 class="card-title"><span id="table-name-<%=order_table.order_id%>" class="table-name"><%=order_table.table_name%></span></h4>
|
||||
<p class="card-text"><%=order_table.total_price%></p>
|
||||
<% if @order_table %>
|
||||
<% @order_table.each do |order_table| %>
|
||||
<div class="card" id="table-order-<%=order_table.order_id%>" onclick="callOrderDetails('<%=order_table.order_id%>')">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title"><span id="table-name-<%=order_table.order_id%>" class="table-name"><%=order_table.table_name%></span></h4>
|
||||
<p class="card-text"><%=order_table.total_price%></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%end %>
|
||||
<%end %>
|
||||
</div>
|
||||
|
||||
@@ -136,32 +136,36 @@
|
||||
<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" 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" class="btn btn-primary btn-lg btn-block" disabled>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 = ""
|
||||
function callOrderDetails(order_id){
|
||||
var old_table_name = ""
|
||||
var table_or_order_id = 0
|
||||
|
||||
function callOrderDetails(order_id){
|
||||
table_or_order_id = order_id
|
||||
$("#test").html(order_id)
|
||||
var tbody = ""
|
||||
$("#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
|
||||
|
||||
old_order_id = order_id
|
||||
}
|
||||
|
||||
$("#order-detail-header").html("")
|
||||
$("#order-detail-header").append(document.getElementById("table-name-"+order_id).innerHTML)
|
||||
$("#sub-total").html("")
|
||||
url = "origami/"+order_id
|
||||
url = "origami/"+order_id
|
||||
$.ajax({type: "GET",
|
||||
url: url,
|
||||
data: { order_id: order_id},
|
||||
@@ -190,6 +194,12 @@ function callOrderDetails(order_id){
|
||||
});
|
||||
}
|
||||
|
||||
$( document ).ready(function() {
|
||||
$('#request_bills').click(function() {
|
||||
window.location.href = '/origami/request_bills/'+table_or_order_id;
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style type="text/css">
|
||||
.selected_color{
|
||||
|
||||
69
app/views/origami/request_bills/show.html.erb
Normal file
69
app/views/origami/request_bills/show.html.erb
Normal file
@@ -0,0 +1,69 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-5 col-sm-3">
|
||||
<div class="card" >
|
||||
<div class="card-header">
|
||||
<div id="order-title">
|
||||
<span><strong>Receipt No</strong> <% if @sale_data%>- <%=@sale_data.receipt_no%><% end %></span>
|
||||
<span><strong>Table No</strong> <% if @sale_data%>- <%=@sale_data.receipt_no%><% end %></span>
|
||||
</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>
|
||||
<% sub_total = 0 %>
|
||||
<% if @sale_items %>
|
||||
<% @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 %>
|
||||
<%end %>
|
||||
</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"><%=sub_total%></span></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:80%; text-align:left; border-top:none"><strong>(Discount)</strong></td>
|
||||
<td style="width:20%; text-align:right; border-top:none"><strong><span>(<%=@sale_data.total_discount%>)</span></strong></td>
|
||||
</tr>
|
||||
<td style="width:80%; text-align:left; border-top:none"><strong>Tax</strong></td>
|
||||
<td style="width:20%; text-align:right; border-top:none"><strong><span><%=@sale_data.total_tax%></span></strong></td>
|
||||
</tr>
|
||||
<td style="width:80%; text-align:left; border-top:none"><strong>Grand Total</strong></td>
|
||||
<td style="width:20%; text-align:right; border-top:none"><strong><span><%=@sale_data.grand_total%></span></strong></td>
|
||||
</tr>
|
||||
</tfooter>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
14
app/views/settings/accounts/_form.html.erb
Normal file
14
app/views/settings/accounts/_form.html.erb
Normal file
@@ -0,0 +1,14 @@
|
||||
<%= simple_form_for([:settings,@settings_account]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.input :title %>
|
||||
<%= f.input :account_type, :collection => Lookup.collection_of("account_type") %>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
json.extract! settings_account, :id, :title, :account_type, :created_at, :updated_at
|
||||
json.url settings_account_url(settings_account, format: :json)
|
||||
10
app/views/settings/accounts/edit.html.erb
Normal file
10
app/views/settings/accounts/edit.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= root_path %>">Home</a></li>
|
||||
<li><a href="<%= settings_accounts_path %>">Account</a></li>
|
||||
<li>Edit</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', settings_account: @settings_account %>
|
||||
</div>
|
||||
40
app/views/settings/accounts/index.html.erb
Normal file
40
app/views/settings/accounts/index.html.erb
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
|
||||
<%= link_to 'New Settings Account', new_settings_account_path %>
|
||||
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= %>">Home</a></li>
|
||||
<li>Account</li>
|
||||
<span style="float: right">
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")),new_settings_account_path,:class => 'btn btn-primary btn-sm' %>
|
||||
</span>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<div class="card">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:40%">Title</th>
|
||||
<th style="width:40%">Account Type</th>
|
||||
<th style="width:20%">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @settings_accounts.each do |account| %>
|
||||
<tr>
|
||||
<td><%= account.title %></td>
|
||||
<td><%= account.account_type %></td>
|
||||
<td>
|
||||
<%= link_to 'Edit', edit_settings_account_path(account) %> |
|
||||
<%= link_to 'Destroy', settings_account_path(account), method: :delete, data: { confirm: 'Are you sure?' } %>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
1
app/views/settings/accounts/index.json.jbuilder
Normal file
1
app/views/settings/accounts/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @settings_accounts, partial: 'settings_accounts/settings_account', as: :settings_account
|
||||
11
app/views/settings/accounts/new.html.erb
Normal file
11
app/views/settings/accounts/new.html.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= root_path %>">Home</a></li>
|
||||
<li><a href="<%= settings_accounts_path %>">Account</a></li>
|
||||
<li>New</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', settings_account: @settings_account %>
|
||||
</div>
|
||||
|
||||
49
app/views/settings/accounts/show.html.erb
Normal file
49
app/views/settings/accounts/show.html.erb
Normal file
@@ -0,0 +1,49 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<strong>Title:</strong>
|
||||
<%= @settings_account.title %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Account type:</strong>
|
||||
<%= @settings_account.account_type %>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Edit', %> |
|
||||
<%= link_to 'Back', settings_accounts_path %>
|
||||
|
||||
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= %>">Home</a></li>
|
||||
<li>Account</li>
|
||||
<span style="float: right">
|
||||
</span>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">Account</h4>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Account type</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><%= @settings_account.title %></td>
|
||||
<td><%= @settings_account.account_type %></td>
|
||||
|
||||
<td><%= link_to 'Edit', edit_settings_account_path(@settings_account, @settings_account) %></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
1
app/views/settings/accounts/show.json.jbuilder
Normal file
1
app/views/settings/accounts/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "settings_accounts/settings_account", settings_account: @settings_account
|
||||
Reference in New Issue
Block a user