app/models/statement.rb in artfully_ose-1.2.0.pre.23 vs app/models/statement.rb in artfully_ose-1.2.0.pre.24

- old
+ new

@@ -24,11 +24,12 @@ :cc_net, :settled, :payment_method_rows, :order_location_rows, :ticket_type_rows, - :discount_rows + :discount_rows, + :pass_rows def self.for_show(show, imported=false) if show.nil? return new end @@ -79,10 +80,11 @@ items.each {|item| row << item} statement.order_location_rows[order_location] = row end statement.build_discount_rows(show.items) + statement.build_pass_rows(show.items) statement.build_ticket_type_rows(show, show.items) end end # @@ -90,17 +92,17 @@ # def build_ticket_type_rows(show, items) self.ticket_type_rows = {} show.chart.ticket_types.each do |ticket_type| - self.ticket_type_rows[ticket_type.name] = TicketTypeRow.new(ticket_type.name) + self.ticket_type_rows[ticket_type.name] = TicketTypeRow.new(ticket_type) end items.each do |item| #refunded items now have nil ticket types unless item.product.ticket_type.nil? - row = self.ticket_type_rows[item.product.ticket_type.name] || TicketTypeRow.new(item.product.ticket_type.name) + row = self.ticket_type_rows[item.product.ticket_type.name] || TicketTypeRow.new(item.product.ticket_type) row << item self.ticket_type_rows[item.product.ticket_type.name] = row end end end @@ -114,10 +116,21 @@ row.discount += (item.original_price - item.price) self.discount_rows[item.discount.code] = row end end end + + def build_pass_rows(items) + self.pass_rows = {} + items.each do |item| + unless item.pass.nil? + row = self.pass_rows[item.pass.pass_type.name] || PassRow.new(item.pass.pass_type.name) + row << item + self.pass_rows[item.pass.pass_type.name] = row + end + end + end module Row attr_accessor :tickets, :gross, :processing, @@ -138,14 +151,15 @@ end end class TicketTypeRow include Row - attr_accessor :ticket_type + attr_accessor :ticket_type, :member_ticket def initialize(ticket_type) - self.ticket_type = ticket_type + self.ticket_type = ticket_type.name + self.member_ticket = ticket_type.member_ticket self.tickets = 0 self.gross = 0 self.processing = 0 self.net = 0 end @@ -161,9 +175,22 @@ self.tickets = 0 self.gross = 0 self.processing = 0 self.net = 0 self.discount = 0 + end + end + + class PassRow + include Row + attr_accessor :pass_type_name + + def initialize(pass_type_name) + self.pass_type_name = pass_type_name + self.tickets = 0 + self.gross = 0 + self.processing = 0 + self.net = 0 end end class OrderLocationRow include Row \ No newline at end of file