payments.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template lang="pug">
  2. .payments-purchase-step
  3. .payments-step
  4. .from-loading-payments(v-show='processingPaymentsPurchases')
  5. .form-overlay-payments
  6. .form-spinner-payments
  7. spinner(type='wave')
  8. voucher-ticket(v-if="paymentsMoveLines.length" :items="paymentsMoveLines" :customer='selectedSupplier' :currencyAmount="paymentsCurrencyAmount")
  9. form.method-payment
  10. .method-form-separator
  11. h3 Detalle del Proveedor
  12. hr
  13. .method-form-item
  14. label.method-form-label Proveedor
  15. input.method-form-input(readonly :value="selectedSupplier && selectedSupplier.displayName")
  16. .method-form-separator
  17. h3 Detalle de pago
  18. hr
  19. .method-form-item
  20. label.method-form-label Método de pago
  21. select.method-form-input(v-model="SelectedJournal")
  22. option(v-for="journal in paymentsJournals" :value="journal") {{ journal.displayName }}
  23. payment-modals(:show="this.typeJournal === 'bank'" @onAccept='methodbutton' @onCancel='methodbutton')
  24. .method-form-item
  25. label.method-form-label Total
  26. input.method-form-input-number(readonly :value="paymentsTotal | currency(...paymentsCurrencyJournal)")
  27. .method-form-item
  28. label.method-form-label Monto a Pagar
  29. input.method-form-input-number(v-model='paid' autofocus)
  30. .method-form-item
  31. label.method-form-label Vuelto
  32. input.method-form-input-number(readonly :value='paymentsReturned | currency(...paymentsCurrencyJournal)')
  33. </template>
  34. <script>
  35. import { mapGetters, mapActions } from 'vuex'
  36. import { SELECT_PAYMENTS_JOURNALS, CHANGE_INITIAL_PAID, RESET_SUPPLIER_PAYMENTS_BANK } from '@/constants/actionTypes'
  37. import VoucherTicket from '@@/payments/VoucherTicket'
  38. import Spinner from '@@/common/Spinner'
  39. import PaymentModals from '@@/modals/PaymentReferenceModals'
  40. export default {
  41. components: {
  42. VoucherTicket,
  43. Spinner,
  44. PaymentModals
  45. },
  46. computed: {
  47. SelectedJournal: {
  48. get() {
  49. this.paymentsReturned = 0
  50. return (this.paymentsSelectedJournal) || -1
  51. },
  52. set(value) {
  53. if (value)
  54. this.selectPaymentsJournals(value)
  55. this.typeJournal = value.type
  56. }
  57. },
  58. paid: {
  59. get() {
  60. let formatted = this.$options.filters.currency(this.paidTotal, {...this.paymentsCurrencyJournal})
  61. return !!this.paidTotal ? formatted : formatted.replace(/\d/, '')
  62. },
  63. set(value) {
  64. value = value.replace(/[\.|,](\d{0,2}$)/, '?$1').split(/\?/)
  65. value[0] = value[0].replace(/[^0-9]/g, '')
  66. value = Number.parseFloat(value.join('.')) || 0
  67. this.changeInitialPaid(value)
  68. this.computePayment(value)
  69. }
  70. },
  71. ...mapGetters([
  72. 'paymentsMoveLines',
  73. 'paymentsCurrencyAmount',
  74. 'selectedSupplier',
  75. 'selectedInvoices',
  76. 'paymentsJournals',
  77. 'paymentsSelectedJournal',
  78. 'paymentsTotal',
  79. 'paidTotal',
  80. 'paymentsReturned',
  81. 'paymentsCurrencyJournal',
  82. 'processingPaymentsPurchases'
  83. ])
  84. },
  85. methods: {
  86. computePayment(value) {
  87. this.paymentsReturned = value < this.paymentsTotal ? 0 : value - this.paymentsTotal
  88. },
  89. methodbutton(value) {
  90. this.typeJournal = ''
  91. if (value === 'Cancel') {
  92. this.resetSupplierPaymentsBank()
  93. }
  94. },
  95. ...mapActions([
  96. CHANGE_INITIAL_PAID,
  97. SELECT_PAYMENTS_JOURNALS,
  98. RESET_SUPPLIER_PAYMENTS_BANK
  99. ])
  100. },
  101. data() {
  102. return {
  103. paymentsReturned: 0,
  104. typeJournal: ''
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="sass">
  110. @import '../../assets/variables'
  111. .payments-purchase-step
  112. .payments-step
  113. width: 100%
  114. height: calc(100% - 50px)
  115. padding-bottom: 50px
  116. display: flex
  117. .method-payment
  118. width: calc(100% - 450px)
  119. height: 100%
  120. margin-right: 50px
  121. padding: 15px 35px
  122. background: $app-light-color
  123. .method-form-separator
  124. h3
  125. color: #9e9e9e
  126. font-size: 8pt
  127. hr
  128. margin-top: 5px
  129. .method-form-item
  130. width: 100%
  131. height: 45px
  132. margin-bottom: 15px
  133. .method-form-label
  134. width: 250px
  135. height: 45px
  136. font-size: 14pt
  137. .method-form-input, .method-form-input-number
  138. width: 350px
  139. height: 45px
  140. font-size: 14pt
  141. border-radius: 0
  142. .method-form-input-number
  143. text-align: right
  144. .from-loading-payments
  145. width: 90%
  146. height: 90%
  147. position: absolute
  148. .form-overlay-payments
  149. width: 100%
  150. height: 100%
  151. background: $app-bg-color
  152. opacity: 0.5
  153. position: absolute
  154. .form-spinner-payments
  155. width: 100%
  156. height: 100%
  157. display: flex
  158. justify-content: center
  159. align-items: center
  160. </style>