PaymentAmount.vue 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template lang="pug">
  2. form.payment-amount-form
  3. .payment-form-separator
  4. h3 Detalles del Pago
  5. hr
  6. .payment-amount-item
  7. label.payment-label Monto a pagar
  8. input.payment-input(readonly :value="formatTotal()")
  9. .payment-amount-item
  10. label.payment-label Monto recibido
  11. input.payment-input(:value="paid" v-model="paid" autofocus)
  12. hr.result-separator
  13. .payment-amount-item
  14. label.payment-label Monto a devolver
  15. input.payment-input(readonly :value="formatResidual()")
  16. </template>
  17. <script>
  18. import { mapGetters, mapActions } from 'vuex'
  19. export default {
  20. computed: {
  21. paid: {
  22. get() {
  23. return accounting.formatMoney(this.amountPaid, this.currencySymbol, 0, '.', ',')
  24. },
  25. set(value) {
  26. value = accounting.unformat(value, ',')
  27. this.changeAmountPaid(value)
  28. this.calculateResidual()
  29. }
  30. },
  31. ...mapGetters([
  32. 'total',
  33. 'currencySymbol',
  34. 'amountPaid'
  35. ])
  36. },
  37. methods: {
  38. formatTotal() {
  39. return accounting.formatMoney(this.total, this.currencySymbol, 0, '.', ',')
  40. },
  41. formatResidual() {
  42. return accounting.formatMoney(this.residual, this.currencySymbol, 0, '.', ',')
  43. },
  44. calculateResidual() {
  45. this.residual = this.amountPaid >= this.total ? this.amountPaid - this.total : 0
  46. },
  47. ...mapActions([
  48. 'changeAmountPaid'
  49. ])
  50. },
  51. data() {
  52. return {
  53. residual: 0
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="sass">
  59. .payment-amount-form
  60. width: calc(100% - 450px)
  61. height: 100%
  62. margin-right: 50px
  63. padding: 35px
  64. background: #f5f5f5
  65. .payment-amount-item
  66. width: 100%
  67. height: 45px
  68. margin-bottom: 15px
  69. .payment-label
  70. width: 250px
  71. height: 45px
  72. font-size: 14pt
  73. .payment-input
  74. width: 350px
  75. height: 45px
  76. font-size: 24pt
  77. border-radius: 0
  78. text-align: right
  79. .payment-form-separator
  80. h3
  81. color: #9e9e9e
  82. font-size: 8pt
  83. hr
  84. margin-top: 5px
  85. .result-separator
  86. margin: 30px 165px 30px 250px
  87. border-top: 1px solid #bdbdbd
  88. </style>