11class DistributionPdf
22 include Prawn ::View
3+ include ItemsHelper
4+ include ActionView ::Helpers ::NumberHelper
35
46 def initialize ( organization , distribution )
57 @distribution = distribution
@@ -9,11 +11,11 @@ def initialize(organization, distribution)
911 text organization . address , align : :right
1012 text organization . email , align : :right
1113 end
12- data = [ [ "Items Received" , "Quantity" ] ]
14+ data = [ [ "Items Received" , "Price/item" , "Total price" , " Quantity"] ]
1315 data += @distribution . line_items . sorted . map do |c |
14- [ c . item . name , c . quantity ]
16+ [ c . item . name , item_price ( c . item . price ) , item_price ( c . price_per_line_item ) , c . quantity ]
1517 end
16- data += [ [ "" , "" ] , [ "Total Items Received" , @distribution . line_items . total ] ]
18+ data += [ [ "" , "" , "" , "" ] , [ "Total Items Received" , "" , item_price ( @distribution . price_per_itemizable ) , @distribution . line_items . total ] ]
1719
1820 move_down 55
1921
@@ -45,22 +47,23 @@ def initialize(organization, distribution)
4547 row ( 0 ) . borders = [ :bottom ]
4648 row ( 0 ) . border_width = 2
4749 row ( 0 ) . font_style = :bold
48- row ( 0 ) . column ( -1 ) . borders = %i( bottom left )
50+ row ( 0 ) . column ( 1 .. -1 ) . borders = %i( bottom left )
4951
5052 # Total Items footer row
5153 row ( -1 ) . borders = [ :top ]
5254 row ( -1 ) . font_style = :bold
53- row ( -1 ) . column ( -1 ) . borders = %i( top left )
55+ row ( -1 ) . column ( 2 ..-1 ) . borders = %i( top left )
56+ row ( -1 ) . column ( 2 ..-1 ) . border_left_color = "aaaaaa"
5457
5558 # Footer spacing row
5659 row ( -2 ) . borders = [ :top ]
5760 row ( -2 ) . padding = [ 2 , 0 , 2 , 0 ]
5861
59- column ( 0 ) . width = 400
62+ column ( 0 ) . width = 250
6063
6164 # Quantity column
62- column ( 1 ) . row ( 1 ..-3 ) . borders = [ :left ]
63- column ( 1 ) . row ( 1 ..-3 ) . border_left_color = "aaaaaa"
65+ column ( 1 .. 3 ) . row ( 1 ..-3 ) . borders = [ :left ]
66+ column ( 1 .. 3 ) . row ( 1 ..-3 ) . border_left_color = "aaaaaa"
6467 column ( 1 ) . style align : :right
6568 end
6669
0 commit comments