update db index

This commit is contained in:
Aung Myo
2018-07-04 18:08:15 +06:30
parent bdd20f727e
commit 4f9a4e2984
7 changed files with 49 additions and 47 deletions

View File

@@ -190,16 +190,18 @@ class Order < ApplicationRecord
def update_items_status_to_billed(items)
if (items.nil?)
OrderItem.where({ order_items_id: '#{self.order_items.pluck(:order_items_id)}'}).update_all(order_item_status: "billed")
##Update the order status to ensure that reflect the stage
self.order_items.each do |item|
item.order_item_status = "billed"
item.save
end
# self.order_items.each do |item|
# item.order_item_status = "billed"
# item.save
# end
else
items.each do |item|
item.order_item_status = "billed"
item.save
end
OrderItem.where({ order_items_id: '#{items.pluck(:order_items_id)}'}).update_all(order_item_status: "billed")
# items.each do |item|
# item.order_item_status = "billed"
# item.save
# end
end
end

View File

@@ -412,7 +412,7 @@ class Sale < ApplicationRecord
# Tax Re-Calculte
def compute_tax(sale, total_taxable, total_discount = 0, order_source = nil, tax_type=nil)
shop = Shop.first();
shop = Shop.first
#if tax is not apply create new record
SaleTax.where("sale_id='#{sale.sale_id}'").find_each do |existing_tax|
@@ -495,7 +495,7 @@ class Sale < ApplicationRecord
# Tax Calculate
def apply_tax(total_taxable, order_source = nil)
shop = Shop.first();
shop = Shop.first
#if tax is not apply create new record
SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax|

View File

@@ -71,10 +71,12 @@ class SalePayment < ApplicationRecord
# update complete order items in oqs
booking = Booking.find_by_sale_id(sale_id)
booking.booking_orders.each do |sodr|
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
aoi.delivery_status = 1
aoi.save
end
assigned =AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").pluck(:assigned_order_item_id)
AssignedOrderItem.where({ order_id: '#{assigned}'}).update_all(print_status: true)
# AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
# aoi.delivery_status = 1
# aoi.save
# end
end
return true, self.save,membership_data
@@ -616,8 +618,9 @@ class SalePayment < ApplicationRecord
end
end
if status && sale_count == 0
table.status = "available"
table.save
table.update_attributes(status: "available")
# table.status = "available"
# table.save
end
# type = 'payment'