lib/skr/models/sales_order.rb in stockor-0.1.7 vs lib/skr/models/sales_order.rb in stockor-0.1.8
- old
+ new
@@ -60,11 +60,11 @@
compose_query_using_detail_view(view: 'so_allocation_details', join_to: 'sales_order_id')
}
# a open SalesOrder is one who's state is not "complete" or "canceled"
scope :open, lambda { | *args |
- where( arel_table[:state].not_in ['complete', 'canceled'] )
+ where.not(state: [:complete,:canceled])
}, export: true
# a SalesOrder is allocated if it has one or more lines with qty_allocated>0
scope :allocated, lambda { | *unused |
with_allocation_details.where('details.number_of_lines_allocated>0')
@@ -86,9 +86,15 @@
# @return [Array of Array[day_ago,date, order_count,line_count,total]]
def self.sales_history( ndays )
qry = "select * from #{Skr.config.table_prefix}so_dailly_sales_history where days_ago<#{ndays.to_i}"
connection.execute(qry).values
end
+
+ enum state: {
+ open: 1,
+ complete: 5,
+ canceled: 9
+ }
state_machine do
state :open, initial: true
state :complete
state :canceled