receipt.pdf.erb 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <div class='pdf-body'>
  2. <header class='document-header'>
  3. <h1 class='text-center'>
  4. <% pointsale = sale.get_pointsale %>
  5. <% if pointsale.img_pointsale? %>
  6. <%= wicked_pdf_image_tag_for_public(pointsale.img_pointsale_url, :style => "margin-top:10px") %>
  7. <% elsif @pos_config.ticket_img? %>
  8. <%= wicked_pdf_image_tag_for_public(@pos_config.ticket_img_url, :style => "margin-top:10px") %>
  9. <% end %>
  10. </h1>
  11. <p>
  12. <% if sale.get_pointsale.notes.blank? %>
  13. <%= simple_format(@pos_config.ticket_description, class: 'text-center') %>
  14. <% else %>
  15. <%= simple_format(sale.get_pointsale.notes, class: 'text-center') %>
  16. <% end %>
  17. </p>
  18. </header>
  19. <div class="resume">
  20. <%= l(sale.created_at, :format => '%d/%m/%y %I:%M %p') %> &nbsp; | &nbsp; <%= sale.sale_code %> &nbsp; | &nbsp; <%= sale.seller.name %>
  21. </div>
  22. <div style="margin-top:5px">
  23. <strong>VENTA AL CONTADO</strong><br>
  24. </div>
  25. <div class="products">
  26. <table cellspacing="0">
  27. <thead>
  28. <tr>
  29. <th style="text-align:left;font-weight:normal">Cantidad</th>
  30. <th style="text-align:center;font-weight:normal">Precio</th>
  31. <th style="text-align:center;font-weight:normal">Desc.</th>
  32. <th style="text-align:right;font-weight:normal">Importe</th>
  33. </tr>
  34. </thead>
  35. <tbody style="border-top:1px solid black">
  36. <% sale.sales_details.each_with_index do |detail, key| %>
  37. <tr>
  38. <td colspan="3">
  39. <%= truncate(detail.product.name, :length => 30, :separator => ' ', :omission => '') %> &nbsp; <%= truncate(detail.product.display_attributes_receipt, :length => 20, :separator => ' ', :omission => '') %>
  40. </td>
  41. </tr>
  42. <tr>
  43. <td>
  44. <%= detail.quantity.round %>
  45. </td>
  46. <td style="text-align:center">
  47. <%= number_to_currency(detail.unit_price, precision: 2) %>
  48. </td>
  49. <td style="text-align:center">
  50. <%= number_to_currency(detail.discount, precision: 2) %>
  51. </td>
  52. <% if !detail.haggle.zero? || !detail.haggle_percent.zero? %>
  53. <td style="text-align: right">
  54. <%= number_to_currency(detail.amount, precision: 2) %><br>
  55. <small><%= detail.haggle > 0 ? number_to_currency(detail.haggle, precision: 2) : "#{detail.haggle_percent}%" %> dscto.</small>
  56. </td>
  57. <% else %>
  58. <td style="text-align:right">
  59. <%= number_to_currency(((detail.unit_price * detail.quantity) - detail.discount), precision: 2) %>
  60. </td>
  61. <% end %>
  62. </tr>
  63. <% end %>
  64. </tbody>
  65. </table>
  66. </div>
  67. <div class="totals text-right">
  68. <% margin = 60 %>
  69. <table>
  70. <thead>
  71. <tr>
  72. <th></th>
  73. <th></th>
  74. <th></th>
  75. </tr>
  76. </thead>
  77. <tbody>
  78. <tr>
  79. <td width="30%">Subtotal</td>
  80. <td width="15%" class="text-right">$</td>
  81. <td width="40%"><%= number_to_currency(sale.amount, precision: 2, :unit => "") %></td>
  82. </tr>
  83. <% if sale.tax > 0 %>
  84. <% margin = margin += 20 %>
  85. <tr>
  86. <td width="30%">IVA</td>
  87. <td width="15%" class="text-right">$</td>
  88. <td width="40%"><%= number_to_currency(sale.tax, precision: 2, :unit => "") %></td>
  89. </tr>
  90. <% end %>
  91. <tr>
  92. <td width="30%" style="font-size:15px"><strong>Total</strong></td>
  93. <td width="15%" style="font-size:15px" class="text-right">$</td>
  94. <td width="40%" style="font-size:15px" ><strong><%= number_to_currency(sale.total, precision: 2, :unit => "") %></strong></td>
  95. </tr>
  96. </tbody>
  97. </table>
  98. </div>
  99. <div style="margin-top:<%=margin%>px; border-top:1px dotted black" class="totals text-right">
  100. <table cellspacing="0">
  101. <thead>
  102. <tr>
  103. <th></th>
  104. <th></th>
  105. <th></th>
  106. </tr>
  107. </thead>
  108. <tbody>
  109. <% marginFooter = 20 %>
  110. <% sale.cash_registers_moves.each do |move| %>
  111. <tr class="text-center" style="text-decoration:underline;">
  112. <td><%= move.payment_method.method %> </td>
  113. <td></td>
  114. <td></td>
  115. </tr>
  116. <% if move.payment_method.isCash? %>
  117. <% marginFooter += 80 %>
  118. <tr class="text-left">
  119. <td> </td>
  120. <td> Recibido: </td>
  121. <td> <%= number_to_currency(move.received, precision: 2) %></td>
  122. </tr>
  123. <tr class="text-left">
  124. <td> </td>
  125. <td><strong> Pagó: </strong></td>
  126. <td><strong> <%= number_to_currency(move.quantity, precision: 2) %></strong></td>
  127. </tr>
  128. <tr class="text-left">
  129. <td> </td>
  130. <td> Cambio: </td>
  131. <td> <%= number_to_currency(move.change, precision: 2) %></td>
  132. </tr>
  133. <% else %>
  134. <% marginFooter += 60 %>
  135. <tr class="text-left">
  136. <td> </td>
  137. <td><strong> Pagó: </strong></td>
  138. <td><strong> <%= number_to_currency(move.quantity, precision: 2) %></strong></td>
  139. </tr>
  140. <tr class="text-left">
  141. <td> </td>
  142. <td> tarjeta nº: </td>
  143. <td> <%= move.cardnumber %></td>
  144. </tr>
  145. <% end %>
  146. <% end %>
  147. </tbody>
  148. </table>
  149. </div>
  150. <div style="margin-top:<%=marginFooter%>px">
  151. <% if sale.get_pointsale.ticket_footer.blank? %>
  152. <%= simple_format(@pos_config.ticket_footer) %>
  153. <% else %>
  154. <%= simple_format(sale.get_pointsale.ticket_footer) %>
  155. <% end %>
  156. </div>
  157. </div>