PaymentAmount.vue 4.8 KB

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