shift sale
This commit is contained in:
@@ -4,7 +4,6 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def show
|
||||
puts current_user.id
|
||||
@shift = ShiftSale.current_open_shift(current_user.id)
|
||||
end
|
||||
|
||||
@@ -15,8 +14,9 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
|
||||
def create
|
||||
opening_balance = params[:opening_balance]
|
||||
cashier_terminal = params[:cashier_terminal]
|
||||
@shift = ShiftSale.new
|
||||
@shift.create(opening_balance,current_user)
|
||||
@shift.create(opening_balance,cashier_terminal, current_user)
|
||||
end
|
||||
|
||||
def update_shift
|
||||
@@ -30,7 +30,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -345,8 +345,8 @@ class Sale < ApplicationRecord
|
||||
else
|
||||
## up to 100
|
||||
value = 100 - get_last_no.to_f
|
||||
num += value
|
||||
puts 'up to 100'
|
||||
num += value
|
||||
puts 'up to 100'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -479,11 +479,12 @@ end
|
||||
|
||||
def get_commerical_tax
|
||||
tax = 0.0
|
||||
self.sale_taxes.each do |tax|
|
||||
if tax.tax_name == "Commerical Tax"
|
||||
tax += tax.tax_payable_amount
|
||||
self.sale_taxes.each do |taxobj|
|
||||
if taxobj.tax_name == "Commerical Tax"
|
||||
tax += taxobj.tax_payable_amount
|
||||
end
|
||||
end
|
||||
return tax
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -266,6 +266,8 @@ class SalePayment < ApplicationRecord
|
||||
shift = ShiftSale.current_open_shift(self.sale.cashier_id)
|
||||
if !shift.nil?
|
||||
shift.update(self.sale)
|
||||
self.sale.shift_sale_id = shift.id
|
||||
self.sale.save
|
||||
end
|
||||
end
|
||||
|
||||
@@ -324,7 +326,7 @@ class SalePayment < ApplicationRecord
|
||||
}, :timeout => 10)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ class ShiftSale < ApplicationRecord
|
||||
#end
|
||||
end
|
||||
|
||||
def create(opening_balance,current_user)
|
||||
self.cashier_terminal_id = CashierTerminal.first.id
|
||||
def create(opening_balance,cashier_terminal, current_user)
|
||||
self.cashier_terminal_id = cashier_terminal
|
||||
self.shift_started_at = DateTime.now
|
||||
self.employee_id = current_user.id
|
||||
self.opening_balance = opening_balance
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
<h1>Open Cashier</h1>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<table class='table table-striped'>
|
||||
<tr>
|
||||
<th>Cashier Terminal</th>
|
||||
<th>
|
||||
<select class='form-control' id='cashier_terminal'>
|
||||
<% @terminal.each do |ter| %>
|
||||
<option value="<%= ter.id %>"><%= ter.name %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
</th>
|
||||
</tr>
|
||||
<% @float.each do |float| %>
|
||||
<tr>
|
||||
<th><%= float.name %></th>
|
||||
@@ -69,10 +76,12 @@ $(document).on('focusout', '.float-value', function(event){
|
||||
|
||||
})
|
||||
$('#open_cashier').on('click',function(){
|
||||
var cashier_terminal = $('#cashier_terminal').val();
|
||||
alert(cashier_terminal)
|
||||
var amount = $('#total').text();
|
||||
$.ajax({type: "POST",
|
||||
url: "<%= origami_shifts_path %>",
|
||||
data: "opening_balance=" + amount,
|
||||
data: "opening_balance=" + amount + "&cashier_terminal="+ cashier_terminal,
|
||||
success:function(result){
|
||||
if(result){
|
||||
window.location.href = '/origami';
|
||||
|
||||
@@ -20,7 +20,7 @@ class CreateSales < ActiveRecord::Migration[5.1]
|
||||
t.decimal :rounding_adjustment, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.decimal :amount_received, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.decimal :amount_changed, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||
t.integer :shift_sale_id, :null => false
|
||||
t.integer :shift_sale_id
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user