11class DistributionPdf
22 include Prawn ::View
3+ include ItemsHelper
34
45 def initialize ( organization , distribution )
56 @distribution = distribution
@@ -9,11 +10,11 @@ def initialize(organization, distribution)
910 text organization . address , align : :right
1011 text organization . email , align : :right
1112 end
12- data = [ [ "Items Received" , "Quantity" ] ]
13+ data = [ [ "Items Received" , "Value/item" , "Total value" , " Quantity"] ]
1314 data += @distribution . line_items . sorted . map do |c |
14- [ c . item . name , c . quantity ]
15+ [ c . item . name , item_value ( c . item . value ) , item_value ( c . value_per_line_item ) , c . quantity ]
1516 end
16- data += [ [ "" , "" ] , [ "Total Items Received" , @distribution . line_items . total ] ]
17+ data += [ [ "" , "" , "" , "" ] , [ "Total Items Received" , "" , item_value ( @distribution . value_per_itemizable ) , @distribution . line_items . total ] ]
1718
1819 move_down 55
1920
@@ -45,22 +46,23 @@ def initialize(organization, distribution)
4546 row ( 0 ) . borders = [ :bottom ]
4647 row ( 0 ) . border_width = 2
4748 row ( 0 ) . font_style = :bold
48- row ( 0 ) . column ( -1 ) . borders = %i( bottom left )
49+ row ( 0 ) . column ( 1 .. -1 ) . borders = %i( bottom left )
4950
5051 # Total Items footer row
5152 row ( -1 ) . borders = [ :top ]
5253 row ( -1 ) . font_style = :bold
53- row ( -1 ) . column ( -1 ) . borders = %i( top left )
54+ row ( -1 ) . column ( 2 ..-1 ) . borders = %i( top left )
55+ row ( -1 ) . column ( 2 ..-1 ) . border_left_color = "aaaaaa"
5456
5557 # Footer spacing row
5658 row ( -2 ) . borders = [ :top ]
5759 row ( -2 ) . padding = [ 2 , 0 , 2 , 0 ]
5860
59- column ( 0 ) . width = 400
61+ column ( 0 ) . width = 250
6062
6163 # Quantity column
62- column ( 1 ) . row ( 1 ..-3 ) . borders = [ :left ]
63- column ( 1 ) . row ( 1 ..-3 ) . border_left_color = "aaaaaa"
64+ column ( 1 .. 3 ) . row ( 1 ..-3 ) . borders = [ :left ]
65+ column ( 1 .. 3 ) . row ( 1 ..-3 ) . border_left_color = "aaaaaa"
6466 column ( 1 ) . style align : :right
6567 end
6668
0 commit comments