diff --git a/app/assets/javascripts/origami/request_bills.coffee b/app/assets/javascripts/origami/request_bills.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/origami/request_bills.coffee @@ -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/ diff --git a/app/assets/stylesheets/origami/request_bills.scss b/app/assets/stylesheets/origami/request_bills.scss new file mode 100644 index 00000000..20719090 --- /dev/null +++ b/app/assets/stylesheets/origami/request_bills.scss @@ -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/ diff --git a/app/assets/stylesheets/scaffolds.scss b/app/assets/stylesheets/scaffolds.scss index e69de29b..60451880 100644 --- a/app/assets/stylesheets/scaffolds.scss +++ b/app/assets/stylesheets/scaffolds.scss @@ -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; +} diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb new file mode 100644 index 00000000..c202d4dc --- /dev/null +++ b/app/controllers/origami/request_bills_controller.rb @@ -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 diff --git a/app/controllers/settings/accounts_controller.rb b/app/controllers/settings/accounts_controller.rb new file mode 100644 index 00000000..74f27c84 --- /dev/null +++ b/app/controllers/settings/accounts_controller.rb @@ -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 diff --git a/app/helpers/origami/request_bills_helper.rb b/app/helpers/origami/request_bills_helper.rb new file mode 100644 index 00000000..a33f7c3e --- /dev/null +++ b/app/helpers/origami/request_bills_helper.rb @@ -0,0 +1,2 @@ +module Origami::RequestBillsHelper +end diff --git a/app/helpers/settings/accounts_helper.rb b/app/helpers/settings/accounts_helper.rb new file mode 100644 index 00000000..de8b6ad9 --- /dev/null +++ b/app/helpers/settings/accounts_helper.rb @@ -0,0 +1,2 @@ +module Settings::AccountsHelper +end diff --git a/app/models/account.rb b/app/models/account.rb new file mode 100644 index 00000000..4cf5040c --- /dev/null +++ b/app/models/account.rb @@ -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 diff --git a/app/models/crm.rb b/app/models/crm.rb new file mode 100644 index 00000000..3407e215 --- /dev/null +++ b/app/models/crm.rb @@ -0,0 +1,5 @@ +module Crm + def self.table_name_prefix + 'crm_' + end +end diff --git a/app/models/lookup.rb b/app/models/lookup.rb index 1784b7a7..e1b141df 100644 --- a/app/models/lookup.rb +++ b/app/models/lookup.rb @@ -1,4 +1,6 @@ class Lookup < ApplicationRecord + + has_many :accounts def available_types {'Employee Roles' => 'employee_roles', diff --git a/app/models/menu_item.rb b/app/models/menu_item.rb index e84ce61e..e83c2eed 100644 --- a/app/models/menu_item.rb +++ b/app/models/menu_item.rb @@ -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') } diff --git a/app/models/order.rb b/app/models/order.rb index 3f74284f..e489ecbf 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -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 diff --git a/app/models/sale.rb b/app/models/sale.rb index 37819c9b..88f0d846 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -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 diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index e79900ab..7dcc1ba8 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -1,4 +1,4 @@ -
<%=order_table.total_price%>
+ <% if @order_table %> + <% @order_table.each do |order_table| %> +<%=order_table.total_price%>
+