PaymentDetails.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template lang="pug">
  2. form.payment-details
  3. .form-separator
  4. h3 Detalles del Cliente
  5. hr
  6. .form-item
  7. label.form-label Cliente
  8. input.form-input(readonly :value="getCustomerName()")
  9. transition(name="fade")
  10. .form-item(v-if="payment === 'credit'")
  11. label.form-label Crédito
  12. input.form-input(readonly :value="getCustomerCredit()")
  13. .form-separator
  14. h3 Detalles del Pago
  15. hr
  16. .form-item
  17. label.form-label Forma de pago
  18. .form-item-option
  19. input.form-input(type="radio" id="cash" value="cash" v-model="payIn")
  20. label(for="cash") Contado
  21. .form-item-option
  22. input.form-input(type="radio" id="credit" value="credit" v-model="payIn")
  23. label(for="credit") Crédito
  24. transition(name="fade")
  25. .form-item(v-if="payment === 'credit'")
  26. select.form-input.input-only(v-model="term")
  27. option(v-for="term in paymentTerms" :value="term" v-if="term.lines.length > 0 && (term.lines[0].days !== 0 || term.lines[0].value !== 'balance')") {{ term.display_name }}
  28. .form-item(v-else)
  29. label.form-label Método de Pago
  30. select.form-input(v-model="journal")
  31. option(v-for="journal in journals" :value="journal") {{ journal.display_name }}
  32. </template>
  33. <script>
  34. import { mapGetters, mapActions } from 'vuex'
  35. export default {
  36. computed: {
  37. payIn: {
  38. get() {
  39. return this.payment
  40. },
  41. set(value) {
  42. this.togglePayment(value)
  43. }
  44. },
  45. term: {
  46. get() {
  47. return this.selectedPaymentTerm
  48. },
  49. set(value) {
  50. this.selectPaymentTerm(value)
  51. }
  52. },
  53. journal: {
  54. get() {
  55. return this.selectedJournal
  56. },
  57. set(value) {
  58. this.selectJournal(value)
  59. }
  60. },
  61. ...mapGetters([
  62. 'hasSelectedCustomer',
  63. 'selectedCustomer',
  64. 'payment',
  65. 'paymentTerms',
  66. 'journals',
  67. 'selectedJournal',
  68. 'selectedPaymentTerm'
  69. ])
  70. },
  71. methods: {
  72. getCustomerName() {
  73. return this.hasSelectedCustomer ? this.selectedCustomer.display_name : ''
  74. },
  75. getCustomerCredit() {
  76. return this.hasSelectedCustomer && this.selectedCustomer.credit_limit >= this.selectedCustomer.credit ? this.selectedCustomer.credit_limit - this.selectedCustomer.credit : 0
  77. },
  78. ...mapActions([
  79. 'togglePayment',
  80. 'selectJournal',
  81. 'selectPaymentTerm'
  82. ])
  83. }
  84. }
  85. </script>
  86. <style lang="sass">
  87. .payment-details
  88. width: calc(100% - 450px)
  89. height: 100%
  90. margin-right: 50px
  91. padding: 35px
  92. background: #f5f5f5
  93. .form-separator
  94. h3
  95. color: #9e9e9e
  96. font-size: 8pt
  97. hr
  98. margin-top: 5px
  99. .form-item
  100. width: 100%
  101. height: 45px
  102. margin-bottom: 15px
  103. .form-label
  104. width: 250px
  105. height: 45px
  106. font-size: 14pt
  107. .form-input
  108. width: 350px
  109. height: 45px
  110. font-size: 14pt
  111. border-radius: 0
  112. &.input-only
  113. margin-left: 250px
  114. margin-bottom: 15px
  115. .form-item-option
  116. display: inline-block
  117. input
  118. width: 20px
  119. height: 20px
  120. label
  121. font-size: 12pt
  122. margin: 0 45px 15px 5px
  123. </style>