fixed conflict

This commit is contained in:
Nweni
2017-06-06 09:43:16 +06:30
50 changed files with 331 additions and 106 deletions

View File

@@ -1,4 +1,9 @@
class AssignedOrderItem < ApplicationRecord
before_create :generate_custom_id
#primary key - need to be unique
self.primary_key = "assigned_order_item_id"
belongs_to :order
belongs_to :order_queue_station
@@ -11,4 +16,9 @@ class AssignedOrderItem < ApplicationRecord
assigned_order_item.delivery_status = false
assigned_order_item.save
end
private
def generate_custom_id
self.assigned_order_item_id = SeedGenerator.generate_id(self.class.name, "AOI")
end
end

View File

@@ -1,9 +1,17 @@
class Booking < ApplicationRecord
self.primary_key = "booking_id"
#primary key - need to be unique
before_create :generate_custom_id
belongs_to :dining_facility, :optional => true
belongs_to :sale, :optional => true
has_many :booking_orders
has_many :orders, :through => :booking_orders
private
def generate_custom_id
self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI")
end
end

View File

@@ -1,5 +1,5 @@
class BookingOrder < ApplicationRecord
#primary key - need to be unique
#primary key - need to be unique
belongs_to :booking
belongs_to :order

View File

@@ -1,4 +1,11 @@
class CashierLoginLog < ApplicationRecord
before_create :generate_custom_id
belongs_to :cashier_station
belongs_to :employee
private
def generate_custom_id
self.cashier_login_log_id = SeedGenerator.generate_id(self.class.name, "CLO")
end
end

View File

@@ -1,5 +0,0 @@
module Crm
def self.table_name_prefix
'crm_'
end
end

View File

@@ -1,4 +1,7 @@
class Customer < ApplicationRecord
self.primary_key = "customer_id"
before_create :generate_custom_id
has_many :orders
has_many :sales
@@ -8,4 +11,9 @@ class Customer < ApplicationRecord
def lastest_invoices
sales.where(:customer_id => self.id).order("created_at desc").limit(5)
end
private
def generate_custom_id
self.customer_id = SeedGenerator.generate_id(self.class.name, "CUS")
end
end

View File

@@ -1,16 +0,0 @@
class LoginForm
include ActiveModel::Model
include ActiveModel::Validations
attr_accessor :emp_id, :password
validates_presence_of :emp_id, :password
def persisted?
false
end
def initialize(attributes={})
super
end
end

View File

@@ -1,5 +1,5 @@
class MenuItem < ApplicationRecord
belongs_to :account
# 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

View File

@@ -1,6 +1,8 @@
class Order < ApplicationRecord
#primary key - need to be unique
self.primary_key = "order_id"
#primary key - need to be unique
before_create :generate_custom_id
before_create :set_order_date
belongs_to :customer
@@ -40,7 +42,7 @@ class Order < ApplicationRecord
self.adding_line_items
#Add Order Table and Room relation afrer order creation
BookingOrder.create({:booking_id => booking.id, :order => self})
BookingOrder.create({:booking_id => booking.booking_id, :order => self})
#Send order to queue one it done!
process_order_queue
@@ -182,14 +184,6 @@ class Order < ApplicationRecord
return new_items_list
end
private
def validate_api_inputs
end
def set_order_date
self.date = Time.now.utc
end
#Update Items Count and Quantity changes whenever there is changes
def update_products_and_quantity_count
@@ -223,8 +217,10 @@ class Order < ApplicationRecord
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.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,"dine_in",true)
.group("orders.id, order_items.id,dining_facilities.name")
end
#Origami: Cashier : to view order type Room
def self.get_order_rooms
@@ -250,4 +246,14 @@ class Order < ApplicationRecord
.where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
.group("orders.id,order_items.id,dining_facilities.name")
end
private
def generate_custom_id
self.order_id = SeedGenerator.generate_id(self.class.name, "ODR")
end
def set_order_date
self.date = Time.now.utc
end
end

View File

@@ -1,5 +1,8 @@
class OrderItem < ApplicationRecord
self.primary_key = "order_items_id"
#primary key - need to be unique
before_create :generate_custom_id
#Associations
belongs_to :order, autosave: true
@@ -42,4 +45,9 @@ class OrderItem < ApplicationRecord
.where("order_items.order_id=?",order_id)
end
private
def generate_custom_id
self.order_items_id = SeedGenerator.generate_id(self.class.name, "ODI")
end
end

View File

@@ -10,12 +10,12 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
self.print("tmp/receipt.pdf")
end
def print_order_summary(printer_settings,booking_id)
def print_order_summary(printer_settings,order_id)
#Use CUPS service
#Generate PDF
#Print
order=print_query('booking',booking_id)
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
order=print_query('order_summary',order_id)
filename = "tmp/order_summary_#{order_id}" + ".pdf"
pdf = OrderSummaryPdf.new(order,printer_settings)
pdf.render_file filename
@@ -25,21 +25,23 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# Query for OQS with status
def print_query(type, code)
if type == 'order_item'
OrderItem.select("order_items.item_code, order_items.item_name,order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining")
.joins("left join orders ON orders.id = order_items.order_id
OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining")
.joins("left join orders ON orders.order_id = order_items.order_id
left join booking_orders AS bo ON bo.order_id=order_items.order_id
left join bookings AS b ON b.id = bo.booking_id
left join dining_facilities AS df ON df.id = b.dining_facility_id
left join customers as cus ON cus.id = orders.customer_id")
left join bookings AS b ON b.booking_id = bo.booking_id
left join dining_facilities AS df ON df.dining_facility_id = b.dining_facility_id
left join customers as cus ON cus.customer_id = orders.customer_id")
.where("order_items.item_code=" + code)
.group("order_items.item_code")
else
OrderItem.select("order_items.item_code, order_items.item_name, df.name as dining")
.joins("left join orders ON orders.id = order_items.order_id
OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining")
.joins("left join orders ON orders.order_id = order_items.order_id
left join booking_orders AS bo ON bo.order_id=order_items.order_id
left join bookings AS b ON b.id = bo.booking_id
left join dining_facilities AS df ON df.id = b.dining_facility_id")
.where("booking.id=" + code)
left join bookings AS b ON b.booking_id = bo.booking_id
left join dining_facilities AS df ON df.dining_facility_id = b.dining_facility_id
left join customers as cus ON cus.customer_id = orders.customer_id")
.where("orders.order_id=" + code.to_s)
.group("order_items.item_code")
end
end

View File

@@ -1,3 +1,4 @@
class RoomBooking < Booking
has_many :orders
end

View File

@@ -1,6 +1,9 @@
#primary key - need to be unique generated for multiple shops
class Sale < ApplicationRecord
self.primary_key = "sale_id"
#primary key - need to be unique generated for multiple shops
before_create :generate_custom_id
#before_create :generate_receipt_no
belongs_to :cashier, :optional => true
belongs_to :customer, :optional => true
@@ -243,4 +246,8 @@ class Sale < ApplicationRecord
end
end
private
def generate_custom_id
self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL")
end
end

View File

@@ -1,6 +1,9 @@
class SaleAudit < ApplicationRecord
#primary key - need to be unique generated for multiple shops
self.primary_key = "sale_audit_id"
#primary key - need to be unique generated for SaleAudit
before_create :generate_custom_id
belongs_to :sale
def record_audit_void(sale_id, void_by, approved_by, reason)
@@ -50,4 +53,9 @@ class SaleAudit < ApplicationRecord
sale_audit.remark = remark
sale_audit.save!
end
private
def generate_custom_id
self.sale_audit_id = SeedGenerator.generate_id(self.class.name, "SAI")
end
end

View File

@@ -1,9 +1,17 @@
class SaleItem < ApplicationRecord
#primary key - need to be unique generated for multiple shops
self.primary_key = "sale_item_id"
#primary key - need to be unique generated for multiple shops
before_create :generate_custom_id
belongs_to :sale
#compute items - discount, tax, price_change
def compute_item
end
private
def generate_custom_id
self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI")
end
end

View File

@@ -1,6 +1,14 @@
class SaleOrder < ApplicationRecord
#primary key - need to be unique generated for multiple shops
self.primary_key = "sale_order_id"
#primary key - need to be unique generated for multiple shops
before_create :generate_custom_id
belongs_to :sale
belongs_to :order
private
def generate_custom_id
self.sale_order_id = SeedGenerator.generate_id(self.class.name, "SOI")
end
end

View File

@@ -1,5 +1,8 @@
class SalePayment < ApplicationRecord
#primary key - need to be unique generated for multiple shops
self.primary_key = "sale_payment_id"
#primary key - need to be unique generated for multiple shops
before_create :generate_custom_id
belongs_to :sale
@@ -156,4 +159,8 @@ class SalePayment < ApplicationRecord
end
private
def generate_custom_id
self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI")
end
end

View File

@@ -1,5 +1,12 @@
class SaleTax < ApplicationRecord
#primary key - need to be unique generated for multiple shops
self.primary_key = "sale_tax_id"
#primary key - need to be unique generated for multiple shops
before_create :generate_custom_id
belongs_to :sale
private
def generate_custom_id
self.sale_tax_id = SeedGenerator.generate_id(self.class.name, "STI")
end
end

View File

@@ -14,8 +14,9 @@ class SeedGenerator < ApplicationRecord
seed.current = current_no
seed.save
end
padding_len = 15 - prefix.length
return prefix + "-" + seed.current.to_s
return prefix +"-"+ seed.current.to_s.to_s.rjust((14-prefix.length)+1,'0')
end
def self.new_receipt_no

View File

@@ -1,2 +0,0 @@
class Test < ApplicationRecord
end

View File

@@ -1,5 +0,0 @@
module Transactions
def self.table_name_prefix
'transactions_'
end
end