Skip to content

Commit

Permalink
adding code parameter to line item
Browse files Browse the repository at this point in the history
  • Loading branch information
nan-apps committed Jan 21, 2019
1 parent 2e76403 commit 1ae14b3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/afip_bill/line_item.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
module AfipBill
class LineItem
attr_reader :name, :quantity, :imp_unitario, :iva
attr_reader :name, :quantity, :imp_unitario, :iva, :code

def initialize(name, quantity, imp_unitario, iva=21)
def initialize(name, quantity, imp_unitario, iva=21, code=nil)
@name = name
@quantity = quantity
@imp_unitario = imp_unitario
@iva = iva
@code = code
end

def imp_total_unitario
Expand Down
6 changes: 4 additions & 2 deletions lib/afip_bill/views/bills/factura_a.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
<div style="left:492.17px;top:267.68px" class="cls_011"><span class="cls_011">IVA</span></div>

<% top = 283 %>
<% @line_items.each_with_index do |line_item, index| %>
<div style="left:18.00px;top:<%= top %>px" class="cls_008"><span class="cls_008"><%= (index + 1).to_s.rjust(3, "0") %></span></div>
<% @line_items.each_with_index do |line_item, index|
item_code = line_item.code || index + 1
%>
<div style="left:18.00px;top:<%= top %>px" class="cls_008"><span class="cls_008"><%= item_code.to_s.rjust(3, "0") %></span></div>

This comment has been minimized.

Copy link
@ceneon

ceneon Jan 22, 2019

Member

Me da dudas esto. Si line_item.code, no debería hacérsele el rjust, porque la app puede querer códigos específicos que haya pasado a la gema.
Habría que mover ese llamado a rjust a la segunda parte del || de la línea 16. @nan-apps

This comment has been minimized.

Copy link
@nan-apps

nan-apps Jan 23, 2019

Author Collaborator

si! tenes razon

<div style="left:57.00px;top:<%= top %>px" class="cls_008"><span class="cls_008"><%= line_item.name %></span></div>
<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>
<!--<div style="left:288.30px;top:<%= top %>px" class="cls_012"><span class="cls_012">unidades</span></div>-->
Expand Down
6 changes: 4 additions & 2 deletions lib/afip_bill/views/bills/factura_b.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
<div style="left:520.50px;top:270.66px" class="cls_011"><span class="cls_011">Subtotal</span></div>

<% top = 293 %>
<% @line_items.each_with_index do |line_item, index| %>
<div style="left:18.00px;top:<%= top %>px" class="cls_008"><span class="cls_008"><%= (index + 1).to_s.rjust(3, "0") %></span></div>
<% @line_items.each_with_index do |line_item, index|
item_code = line_item.code || index + 1
%>
<div style="left:18.00px;top:<%= top %>px" class="cls_008"><span class="cls_008"><%= item_code.to_s.rjust(3, "0") %></span></div>
<div style="left:57.00px;top:<%= top %>px" class="cls_008"><span class="cls_008"><%= line_item.name %></span></div>
<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>
<!-- <div style="left:268.30px;top:<%= top %>px" class="cls_012"><span class="cls_012">unidades</span></div> -->
Expand Down

0 comments on commit 1ae14b3

Please sign in to comment.