commit for sales
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/
|
||||
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
|
||||
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
|
||||
@@ -226,13 +226,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,38 @@
|
||||
<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" class="btn btn-primary btn-lg btn-block" disabled>
|
||||
Req.Bill
|
||||
<form method="get" onclick="test()">
|
||||
<button type="button" id="request_bills" class="btn btn-primary btn-lg btn-block" >Continue</button>
|
||||
</form>
|
||||
<!-- 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 +196,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>
|
||||
@@ -2,6 +2,10 @@ require 'sidekiq/web'
|
||||
|
||||
Rails.application.routes.draw do
|
||||
|
||||
namespace :origami do
|
||||
get 'request_bills/show'
|
||||
end
|
||||
|
||||
root 'home#index'
|
||||
mount Sidekiq::Web => '/kiq'
|
||||
|
||||
@@ -65,6 +69,7 @@ Rails.application.routes.draw do
|
||||
resources :discounts, only: [:index,:new, :create ] #add discount type
|
||||
resources :customers, only: [:index,:new, :create ] #add customer type
|
||||
end
|
||||
resources :request_bills, only: [:show]
|
||||
end
|
||||
|
||||
|
||||
|
||||
5
spec/views/origami/request_bills/show.html.erb_spec.rb
Normal file
5
spec/views/origami/request_bills/show.html.erb_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "request_bills/show.html.erb", type: :view do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
Reference in New Issue
Block a user