Skip to content

Commit 1ae14b3

Browse files
committed
adding code parameter to line item
1 parent 2e76403 commit 1ae14b3

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

lib/afip_bill/line_item.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
module AfipBill
22
class LineItem
3-
attr_reader :name, :quantity, :imp_unitario, :iva
3+
attr_reader :name, :quantity, :imp_unitario, :iva, :code
44

5-
def initialize(name, quantity, imp_unitario, iva=21)
5+
def initialize(name, quantity, imp_unitario, iva=21, code=nil)
66
@name = name
77
@quantity = quantity
88
@imp_unitario = imp_unitario
99
@iva = iva
10+
@code = code
1011
end
1112

1213
def imp_total_unitario

lib/afip_bill/views/bills/factura_a.html.erb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
<div style="left:492.17px;top:267.68px" class="cls_011"><span class="cls_011">IVA</span></div>
1313

1414
<% top = 283 %>
15-
<% @line_items.each_with_index do |line_item, index| %>
16-
<div style="left:18.00px;top:<%= top %>px" class="cls_008"><span class="cls_008"><%= (index + 1).to_s.rjust(3, "0") %></span></div>
15+
<% @line_items.each_with_index do |line_item, index|
16+
item_code = line_item.code || index + 1
17+
%>
18+
<div style="left:18.00px;top:<%= top %>px" class="cls_008"><span class="cls_008"><%= item_code.to_s.rjust(3, "0") %></span></div>
1719
<div style="left:57.00px;top:<%= top %>px" class="cls_008"><span class="cls_008"><%= line_item.name %></span></div>
1820
<div style="width:60px;left:290.30px;top:<%= top %>px" class="cls_008"><span style="position:absolute;right:0" class="cls_008"><%= line_item.quantity.to_s.tr(".", ",") %> </span></div>
1921
<!--<div style="left:288.30px;top:<%= top %>px" class="cls_012"><span class="cls_012">unidades</span></div>-->

lib/afip_bill/views/bills/factura_b.html.erb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
<div style="left:520.50px;top:270.66px" class="cls_011"><span class="cls_011">Subtotal</span></div>
1111

1212
<% top = 293 %>
13-
<% @line_items.each_with_index do |line_item, index| %>
14-
<div style="left:18.00px;top:<%= top %>px" class="cls_008"><span class="cls_008"><%= (index + 1).to_s.rjust(3, "0") %></span></div>
13+
<% @line_items.each_with_index do |line_item, index|
14+
item_code = line_item.code || index + 1
15+
%>
16+
<div style="left:18.00px;top:<%= top %>px" class="cls_008"><span class="cls_008"><%= item_code.to_s.rjust(3, "0") %></span></div>
1517
<div style="left:57.00px;top:<%= top %>px" class="cls_008"><span class="cls_008"><%= line_item.name %></span></div>
1618
<div style="width:60px;left:392px;top:<%= top %>px" class="cls_008"><span class="cls_008"><%= line_item.quantity.round(2).to_s.tr(".", ",") %></span></div>
1719
<!-- <div style="left:268.30px;top:<%= top %>px" class="cls_012"><span class="cls_012">unidades</span></div> -->

0 commit comments

Comments
 (0)