PaymentAmount.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template lang="pug">
  2. .pos-step
  3. ticket(:customerName='selectedCustomer && selectedCustomer.name' :companyName='user && user.company.name' :total='cartTotal' :items='cartItems' :defaultCurrency='selectedCurrency')
  4. form.payment-amount
  5. .form-loading(v-show='processing')
  6. .form-overlay
  7. .form-spinner
  8. spinner(type='wave')
  9. .form-separator
  10. h3 Detalles del Pago
  11. hr
  12. .form-item
  13. label.form-label Monto a Pagar
  14. input.form-input(:value='cartTotal | currency(...selectedCurrency)' readonly)
  15. .form-item
  16. label.form-label Monto Recibido
  17. input.form-input(v-model='amountReceived' autofocus)
  18. .form-item(v-show="paymentType === 'cash'")
  19. hr
  20. label.form-label Monto a Devolver
  21. input.form-input(:value='paymentResidual | currency(...selectedCurrency)' readonly)
  22. .form-item-table(v-show="paymentType === 'credit'")
  23. table
  24. thead
  25. tr
  26. th Monto a Pagar
  27. th Fecha de Pago
  28. tbody
  29. tr(v-for='line in paymentLines')
  30. td {{ line.total | currency(...selectedCurrency) }}
  31. td {{ line.date }}
  32. document-selector(:show='askForPrint' @onPrint='processPrint' @onCancel='processPrint')
  33. </template>
  34. <script>
  35. import { mapGetters, mapActions } from 'vuex'
  36. import Ticket from '@@/common/Ticket'
  37. import Spinner from '@/components/common/Spinner'
  38. import DocumentSelector from '@/components/modals/DocumentSelector'
  39. import { CHANGE_INITIAL_PAYMENT, COMPUTE_PAYMENT_LINES, PROCESS_PRINT } from '@/constants/actionTypes'
  40. export default {
  41. components: {
  42. Ticket,
  43. Spinner,
  44. DocumentSelector
  45. },
  46. computed: {
  47. amountReceived: {
  48. get() {
  49. let formatted = this.$options.filters.currency(this.initialPayment, {...this.selectedCurrency})
  50. return !!this.initialPayment ? formatted : formatted.replace(/\d/, '')
  51. },
  52. set(value) {
  53. value = value.replace(/[\.|,](\d{0,2}$)/, '?$1').split(/\?/)
  54. value[0] = value[0].replace(/[^0-9]/g, '')
  55. value = Number.parseFloat(value.join('.')) || 0
  56. this.changeInitialPayment(value)
  57. this.computePaymentResidual(value)
  58. if (this.paymentType === 'credit') {
  59. this.computePaymentLines()
  60. }
  61. }
  62. },
  63. ...mapGetters([
  64. 'user',
  65. 'selectedCustomer',
  66. 'cartItems',
  67. 'cartTotal',
  68. 'paymentTerms',
  69. 'paymentType',
  70. 'paymentLines',
  71. 'initialPayment',
  72. 'paymentResidual',
  73. 'selectedCurrency',
  74. 'processing',
  75. 'askForPrint'
  76. ])
  77. },
  78. methods: {
  79. computePaymentResidual(value) {
  80. this.paymentResidual = value < this.cartTotal ? 0 : value - this.cartTotal
  81. },
  82. ...mapActions([
  83. CHANGE_INITIAL_PAYMENT,
  84. COMPUTE_PAYMENT_LINES,
  85. PROCESS_PRINT
  86. ])
  87. },
  88. data() {
  89. return {
  90. paymentResidual: 0
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="sass">
  96. @import '../../assets/variables'
  97. .pos-step
  98. width: 100%
  99. height: calc(100% - 50px)
  100. padding-bottom: 50px
  101. display: flex
  102. .payment-amount
  103. width: calc(100% - 450px)
  104. height: 100%
  105. margin-right: 50px
  106. padding: 35px
  107. background: $app-light-color
  108. position: relative
  109. .form-loading
  110. width: 90%
  111. height: 90%
  112. position: absolute
  113. .form-overlay
  114. width: 100%
  115. height: 100%
  116. background: $app-bg-color
  117. opacity: 0.5
  118. position: absolute
  119. .form-spinner
  120. width: 100%
  121. height: 100%
  122. display: flex
  123. justify-content: center
  124. align-items: center
  125. .form-separator
  126. h3
  127. color: $app-separator-color
  128. font-size: 8pt
  129. margin: 0
  130. hr
  131. margin-top: 15px
  132. .form-item
  133. width: 100%px
  134. height: 45px
  135. margin-bottom: 15px
  136. .form-label
  137. width: 250px
  138. height: 45px
  139. font-size: 14pt
  140. .form-input
  141. width: 350px
  142. height: 45px
  143. font-size: 14pt
  144. border-radius: 0
  145. &.input-only
  146. margin-left: 250px
  147. margin-bottom: 15px
  148. .form-item-table
  149. width: 100%
  150. height: 200px
  151. border: 1px solid $app-border-color
  152. overflow-y: auto
  153. table
  154. width: 100%
  155. thead
  156. th
  157. line-height: 35px
  158. padding-left: 10px
  159. th:nth-child(1)
  160. width: 200px
  161. th:nth-child(2)
  162. width: 200px
  163. tbody
  164. td
  165. height: 35px
  166. padding-left: 10px
  167. td:nth-child(1)
  168. width: 200px
  169. td:nth-child(2)
  170. width: 200px
  171. </style>