update edit with remark
This commit is contained in:
@@ -41,7 +41,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
sale_item.product_name = di["name"]
|
||||
sale_item.item_instance_code = origin_sale_item.item_instance_code
|
||||
sale_item.product_alt_name = ""
|
||||
sale_item.remark = "Discount"
|
||||
sale_item.status = "Discount"
|
||||
|
||||
sale_item.qty = -1
|
||||
sale_item.unit_price = di["price"].to_f * (-1)
|
||||
@@ -123,7 +123,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
discount_items = []
|
||||
#destroy all discount sale item
|
||||
sale.sale_items.each do |si|
|
||||
if si.remark == "Discount" && si.price < 0
|
||||
if si.status == "Discount" && si.price < 0
|
||||
sale.total_amount = (sale.total_amount + si.price.abs)
|
||||
discount_items.push(si)
|
||||
end
|
||||
@@ -277,7 +277,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
# sale_item.sale_id = sale_id
|
||||
# sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
|
||||
# sale_item.product_name = product_name
|
||||
# sale_item.remark = remark
|
||||
# sale_item.status = remark
|
||||
|
||||
# sale_item.qty = 1
|
||||
# sale_item.unit_price = (0-discount_amount.to_f)
|
||||
|
||||
@@ -32,7 +32,7 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
sale_item.product_code = "Other Charges"
|
||||
sale_item.product_name = "*" + di["name"]
|
||||
sale_item.product_alt_name = ""
|
||||
sale_item.remark = "Other Charges"
|
||||
sale_item.status = "Other Charges"
|
||||
|
||||
sale_item.qty = 1
|
||||
sale_item.unit_price = di["price"]
|
||||
|
||||
@@ -307,12 +307,14 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
|
||||
|
||||
if saleObj.discount_type == "member_discount"
|
||||
saleObj.update_attributes(rounding_adjustment: 0)
|
||||
saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0)
|
||||
end
|
||||
|
||||
saleObj.update_attributes(rounding_adjustment: 0)
|
||||
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_payment(saleObj, current_user.name, cash, "foc" ,remark)
|
||||
|
||||
|
||||
@@ -10,8 +10,10 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
# create item void. make duplicate old record and update qty and price
|
||||
def item_void
|
||||
saleitemId = params[:sale_item_id]
|
||||
remark = params[:remark]
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
saleitemObj.remark = 'void'
|
||||
saleitemObj.status = 'void'
|
||||
saleitemObj.remark = remark
|
||||
saleitemObj.save
|
||||
@newsaleitem = SaleItem.new
|
||||
@newsaleitem = saleitemObj.dup
|
||||
@@ -21,6 +23,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
@newsaleitem.is_taxable = 1
|
||||
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
|
||||
@newsaleitem.product_name = saleitemObj.product_name + ' (VOID)'
|
||||
@newsaleitem.remark = remark
|
||||
@newsaleitem.save
|
||||
|
||||
# re-calc tax
|
||||
@@ -36,8 +39,10 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
|
||||
def item_foc
|
||||
saleitemId = params[:sale_item_id]
|
||||
remark = params[:remark]
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
saleitemObj.remark = 'foc'
|
||||
saleitemObj.status = 'foc'
|
||||
saleitemObj.remark = remark
|
||||
saleitemObj.save
|
||||
@newsaleitem = SaleItem.new
|
||||
@newsaleitem = saleitemObj.dup
|
||||
@@ -47,6 +52,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
|
||||
@newsaleitem.price = saleitemObj.price * -1
|
||||
@newsaleitem.product_name = saleitemObj.product_name + ' (FOC)'
|
||||
@newsaleitem.remark = remark
|
||||
@newsaleitem.save
|
||||
|
||||
# re-calc tax
|
||||
@@ -65,7 +71,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
# update_qty = params[:update_qty]
|
||||
# update_price = params[:update_price]
|
||||
# saleitemObj = SaleItem.find(saleitemId)
|
||||
# saleitemObj.remark = 'void'
|
||||
# saleitemObj.status = 'void'
|
||||
# saleitemObj.save
|
||||
# @newsaleitem = SaleItem.new
|
||||
# @newsaleitem = saleitemObj.dup
|
||||
@@ -117,7 +123,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
both = SaleItem.where('product_code=?', saleitemObj.product_code)
|
||||
both.each do |item|
|
||||
if item.qty.to_i > 0
|
||||
item.remark = nil
|
||||
item.status = nil
|
||||
item.save
|
||||
end
|
||||
end
|
||||
@@ -142,7 +148,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
if item.qty.to_i < 0
|
||||
item.destroy
|
||||
else
|
||||
item.remark = nil
|
||||
item.status = nil
|
||||
end
|
||||
item.save
|
||||
ProductCommission.remove_product_commission(item)
|
||||
|
||||
@@ -92,7 +92,7 @@ class Sale < ApplicationRecord
|
||||
self.cashier_id = open_cashier[0].id
|
||||
self.cashier_name = open_cashier[0].name
|
||||
shift_id = ShiftSale.current_open_shift(open_cashier[0].id)
|
||||
self.shift_sale_id = shift_id.id
|
||||
self.shift_sale_id = current_shift.id
|
||||
else
|
||||
self.cashier_id = current_shift.employee_id
|
||||
self.cashier_name = Employee.find(current_shift.employee_id).name
|
||||
@@ -227,7 +227,7 @@ class Sale < ApplicationRecord
|
||||
sale_item.product_name = item.item_name
|
||||
sale_item.product_alt_name = item.alt_name
|
||||
sale_item.account_id = item.account_id
|
||||
sale_item.remark = item.remark
|
||||
sale_item.status = item.remark
|
||||
|
||||
sale_item.qty = item.qty
|
||||
sale_item.unit_price = item.price
|
||||
@@ -255,7 +255,7 @@ class Sale < ApplicationRecord
|
||||
sale_item.product_name = instance.item_instance_name
|
||||
sale_item.product_alt_name = menu_item.alt_name
|
||||
sale_item.account_id = menu_item.account_id
|
||||
sale_item.remark = nil
|
||||
sale_item.status = nil
|
||||
|
||||
sale_item.qty = item["quantity"]
|
||||
sale_item.unit_price = item["price"]
|
||||
@@ -381,7 +381,7 @@ class Sale < ApplicationRecord
|
||||
rounding_adjustment = 0
|
||||
|
||||
sales_items.each do |item|
|
||||
if item.remark != 'void' && item.remark != 'foc'
|
||||
if item.status != 'void' && item.status != 'foc'
|
||||
#compute each item and added to total
|
||||
subtotal_price = subtotal_price + item.price
|
||||
|
||||
@@ -417,35 +417,36 @@ class Sale < ApplicationRecord
|
||||
tax_profiles = TaxProfile.all.order("order_by asc")
|
||||
customer = Customer.find(sale.customer_id)
|
||||
# #Creat new tax records
|
||||
tax_profiles.each do |tax|
|
||||
customer.tax_profiles.each do |cus_tax|
|
||||
if cus_tax.to_i == tax.id
|
||||
sale_tax = SaleTax.new(:sale => sale)
|
||||
sale_tax.tax_name = tax.name
|
||||
sale_tax.tax_rate = tax.rate
|
||||
if sale.payment_status != 'foc'
|
||||
tax_profiles.each do |tax|
|
||||
customer.tax_profiles.each do |cus_tax|
|
||||
if cus_tax.to_i == tax.id
|
||||
sale_tax = SaleTax.new(:sale => sale)
|
||||
sale_tax.tax_name = tax.name
|
||||
sale_tax.tax_rate = tax.rate
|
||||
|
||||
# substract , to give after discount
|
||||
total_tax = total_taxable - total_discount
|
||||
#include or execulive
|
||||
if tax.inclusive
|
||||
rate = tax.rate
|
||||
divided_value = (100 + rate)/rate
|
||||
sale_tax.tax_payable_amount = total_tax / divided_value
|
||||
else
|
||||
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
||||
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
|
||||
end
|
||||
#new taxable amount is standard rule for step by step
|
||||
if shop.calc_tax_order
|
||||
total_taxable = total_taxable + sale_tax.tax_payable_amount
|
||||
end
|
||||
# substract , to give after discount
|
||||
total_tax = total_taxable - total_discount
|
||||
#include or execulive
|
||||
if tax.inclusive
|
||||
rate = tax.rate
|
||||
divided_value = (100 + rate)/rate
|
||||
sale_tax.tax_payable_amount = total_tax / divided_value
|
||||
else
|
||||
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
||||
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
|
||||
end
|
||||
#new taxable amount is standard rule for step by step
|
||||
if shop.calc_tax_order
|
||||
total_taxable = total_taxable + sale_tax.tax_payable_amount
|
||||
end
|
||||
|
||||
sale_tax.inclusive = tax.inclusive
|
||||
sale_tax.save
|
||||
sale_tax.inclusive = tax.inclusive
|
||||
sale_tax.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
sale.total_tax = total_tax_amount
|
||||
end
|
||||
|
||||
@@ -757,7 +758,7 @@ end
|
||||
def self.get_item_query()
|
||||
query = Sale.select("acc.title as account_name,mi.account_id, i.item_instance_code as item_code,i.account_id as account_id, " +
|
||||
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item,i.qty as qty," +
|
||||
"i.remark as status_type,"+
|
||||
"i.status as status_type,"+
|
||||
" i.unit_price,i.price as price,i.product_name as product_name, mc.name as" +
|
||||
" menu_category_name,mc.id as menu_category_id ")
|
||||
|
||||
@@ -776,7 +777,7 @@ end
|
||||
def self.get_other_charges()
|
||||
query = Sale.select("i.account_id as account_id, " +
|
||||
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item," +
|
||||
"i.remark as status_type,"+
|
||||
"i.status as status_type,"+
|
||||
" i.unit_price as unit_price,i.product_name as product_name")
|
||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id")
|
||||
query = query.where("i.item_instance_code IS NULL AND i.product_code = 'Other Charges'")
|
||||
@@ -1227,7 +1228,7 @@ end
|
||||
|
||||
def self.total_foc_items(today)
|
||||
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||
.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||
.where("sales.sale_status = 'completed' and a.status='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||
.sum("a.qty")
|
||||
end
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class SaleItem < ApplicationRecord
|
||||
|
||||
def self.update_existing_item(qty, item, sale_id, type, item_price, price)
|
||||
# Original Item to add remark
|
||||
item.remark = type
|
||||
item.status = type
|
||||
item.save
|
||||
|
||||
sale_item = SaleItem.new
|
||||
@@ -37,7 +37,7 @@ class SaleItem < ApplicationRecord
|
||||
sale_item.product_name = item.product_name + " (#{type.upcase})"
|
||||
sale_item.product_alt_name = item.product_alt_name
|
||||
sale_item.account_id = item.account_id
|
||||
sale_item.remark = type
|
||||
sale_item.status = type
|
||||
if type == "foc" || type == "promotion" || type == "void"
|
||||
sale_item.qty = qty * (-1)
|
||||
else
|
||||
@@ -99,7 +99,7 @@ class SaleItem < ApplicationRecord
|
||||
discount_account = {:name => a.title, :price => 0}
|
||||
|
||||
# Check for actual sale items
|
||||
sale_items.where("remark = 'Discount'").find_each do |si|
|
||||
sale_items.where("status = 'Discount'").find_each do |si|
|
||||
if si.account_id == a.id
|
||||
discount_account[:price] = (discount_account[:price].abs + si.price.abs) * (1)
|
||||
end
|
||||
|
||||
@@ -194,7 +194,7 @@ class SalePayment < ApplicationRecord
|
||||
payment_status = false
|
||||
|
||||
# add to sale item with foc
|
||||
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }' and remark is null")
|
||||
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }' and status is null")
|
||||
|
||||
sale_items.each do|item|
|
||||
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<% @sale_data.sale_items.each do |sale_item| %>
|
||||
<%
|
||||
sub_total += sale_item.qty*sale_item.unit_price
|
||||
if sale_item.price != 0 && sale_item.remark != "void" && sale_item.remark != "foc"
|
||||
if sale_item.price != 0 && sale_item.status != "void" && sale_item.status != "foc"
|
||||
%>
|
||||
<tr class="item-row" id=<%= sale_item.sale_item_id %> >
|
||||
<td style="width:60%; text-align:left">
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<td class="p-2" width="20%">
|
||||
<%= sale_item.product_name %>
|
||||
</td>
|
||||
<% if sale_item.remark != 'void' && sale_item.remark != 'edit' && sale_item.remark != 'foc' %>
|
||||
<% if sale_item.status != 'void' && sale_item.status != 'edit' && sale_item.status != 'foc' %>
|
||||
<td class="p-1" width="5%">
|
||||
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control "/>
|
||||
</td>
|
||||
@@ -69,11 +69,12 @@
|
||||
</td> -->
|
||||
<td class="p-1" width="25%">
|
||||
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-blue waves-effect update'>Update</button>
|
||||
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-danger waves-effect void'>Void</button>
|
||||
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-red waves-effect foc'>FOC</button>
|
||||
<button data-id="<%= sale_item.id %>" data-type="void" class='editModal btn btn-lg bg-danger waves-effect' data-toggle="modal" data-target="#editModal">Void</button>
|
||||
|
||||
<button data-id="<%= sale_item.id %>" data-type="foc" class='editModal btn btn-lg bg-danger waves-effect' data-toggle="modal" data-target="#editModal">FOC</button>
|
||||
</td>
|
||||
|
||||
<% elsif sale_item.qty.to_i < 0 || sale_item.remark == 'edit' %>
|
||||
<% elsif sale_item.qty.to_i < 0 || sale_item.status == 'edit' %>
|
||||
<td class="p-1" width="5%">
|
||||
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
|
||||
</td>
|
||||
@@ -148,18 +149,48 @@
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<!-- Waiter Buttons -->
|
||||
<button type="button" class="btn btn-block btn-lg bg-default waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
|
||||
<button type="button" class="btn btn-danger btn- action-btn" id='cancel_all_void'>Cancel All Void</button>
|
||||
<button type="button" class="btn btn-block btn-lg bg-blue waves-effect" id='apply'>Apply</button>
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<!-- Waiter Buttons -->
|
||||
<button type="button" class="btn btn-block btn-lg bg-default waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
|
||||
<button type="button" class="btn btn-danger btn- action-btn" id='cancel_all_void'>Cancel All Void</button>
|
||||
<button type="button" class="btn btn-block btn-lg bg-blue waves-effect" id='apply'>Apply</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal fade" id="editModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="editModalLabel">Please Enter Remark</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="textarea" name="remark" class="form-control col-md-12 remark" id="remark">
|
||||
</div>
|
||||
<div class="modal-footer ">
|
||||
<div class="row p-r-20">
|
||||
<div class="col-md-5">
|
||||
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-red waves-effect" id="action">VOID</button>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// Bill Request
|
||||
$(document).ready(function () {
|
||||
$('.editModal').on('click', function () {
|
||||
$("#action").attr('data-type', $(this).attr('data-type'));
|
||||
$("#action").attr('data-id', $(this).attr('data-id'));
|
||||
$("#action").text($(this).attr('data-type'))
|
||||
})
|
||||
|
||||
$(".update").on('click', function () {
|
||||
var sale_item_id = $(this).attr('data-id');
|
||||
@@ -182,13 +213,14 @@
|
||||
});
|
||||
});
|
||||
|
||||
$('.void').on('click', function () {
|
||||
/*$('.void').on('click', function () {
|
||||
var sale_item_id = $(this).attr('data-id');
|
||||
var remark = $("#remark").val();
|
||||
var ajax_url = "/origami/item_void";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id,
|
||||
data: 'sale_item_id=' + sale_item_id + "&remark=" + remark,
|
||||
success: function (result) {
|
||||
location.reload();
|
||||
}
|
||||
@@ -201,7 +233,27 @@
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id,
|
||||
data: 'sale_item_id=' + sale_item_id + "&remark=" + remark,
|
||||
success: function (result) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
})*/
|
||||
|
||||
$('#action').on('click', function () {
|
||||
var sale_item_id = $(this).attr('data-id');
|
||||
var type = $(this).attr('data-type');
|
||||
var remark = $("#remark").val();
|
||||
if (type=='foc') {
|
||||
var ajax_url = "/origami/item_foc";
|
||||
}else{
|
||||
var ajax_url = "/origami/item_void";
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id + "&remark=" + remark,
|
||||
success: function (result) {
|
||||
location.reload();
|
||||
}
|
||||
@@ -224,6 +276,7 @@
|
||||
|
||||
})
|
||||
|
||||
|
||||
$('#back').on('click', function () {
|
||||
var table_id = '<%= @table_id %>'
|
||||
window.location.href = '/origami/table/' + table_id;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
development:
|
||||
secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61
|
||||
sx_provision_url: 192.168.1.125:3002/api #connect.smartsales.dev/api #connect.smartsales.asia/api #provision.zsai.ws/api
|
||||
server_mode: cloud
|
||||
server_mode: application
|
||||
cipher_type: AES-256-CBC
|
||||
sx_key: Wh@t1$C2L
|
||||
|
||||
@@ -25,7 +25,7 @@ test:
|
||||
production:
|
||||
secret_key_base: c4bc81065013f9a3506d385bcbd49586c42e586488144b0de90c7da36867de9fa880f46b5c4f86f0ce9b7c783bb5a73bdb0e5605a47716567294390e726d3e22
|
||||
sx_provision_url: connect.smartsales.asia/api #192.168.1.147:3002/api
|
||||
server_mode: application
|
||||
server_mode: cloud
|
||||
cipher_type: AES-256-CBC
|
||||
sx_key: Wh@t1$C2L
|
||||
|
||||
|
||||
Reference in New Issue
Block a user