Payment.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template lang="pug">
  2. .pos-step
  3. ticket(
  4. :companyName='companyName'
  5. :items='cartItems'
  6. :total='amountToPay'
  7. :defaultCurrency='selectedCurrency'
  8. :customerName='selectedCustomerName'
  9. )
  10. form
  11. //- input para forma de pago
  12. .form-item
  13. label.form-label Forma de Pago
  14. switch-button-input.form-input(
  15. primary-value='Contado'
  16. secondary-value='Crédito'
  17. :selected-value="paymentType === 'cash' ? 'Contado' : 'Crédito'"
  18. @onChange="changePaymentType($event ? 'cash' : 'credit')"
  19. )
  20. //- input para condiciones de pago en caso de pago a crédito
  21. .form-item(v-show="paymentType === 'credit'")
  22. select.form-input.input-only(v-model='paymentTermId')
  23. option(
  24. :value='term.id'
  25. v-for='term in paymentTerms'
  26. v-if="term.lines.length > 0 && (term.lines[0].days !== 0 || term.lines[0].value !== 'balance')"
  27. ) {{ term.name }}
  28. //- input para monto de pago
  29. .form-item
  30. label.form-label Monto a Pagar
  31. input-dropdown.form-input(
  32. format='number'
  33. :value='amountToPay'
  34. :editable='false'
  35. :suffix='currencySymbol'
  36. :options='currencySymbols'
  37. @onChangeValue='onChangeValue'
  38. @onClickOption='changeCurrency'
  39. )
  40. .other_exchanges(v-if='settings.viewExchanges')
  41. h2 En otras monedas
  42. ul
  43. li(v-for='value in amountToPayInOtherCurrencies') {{ value.amount | currency(value.currency) }}
  44. //- input para el monto recibido
  45. .form-item
  46. label.form-label Monto Recibido
  47. input-dropdown.form-input(
  48. ref='initialAmount'
  49. format='number'
  50. :value='initialPayment'
  51. :suffix='paymentMethod'
  52. :options='paymentMethods'
  53. :focus='true'
  54. @onClickOption='changePaymentMethod'
  55. @onChangeValue='changeAmountReceived($event)'
  56. )
  57. //- input para el vuelto del pago en caso de pago en efectivo
  58. div(v-show="paymentType === 'cash'")
  59. hr
  60. .form-item
  61. label.form-label Vuelto
  62. input-dropdown.form-input(
  63. format='number'
  64. :value='amountResidual'
  65. :editable='false'
  66. )
  67. //- input para el monto de cuotas calculadas en caso de pago a crédito
  68. .form-item-table(v-show="paymentType === 'credit'")
  69. table
  70. thead
  71. tr
  72. th Monto a Pagar
  73. th Fecha de Pago
  74. tbody
  75. tr(v-for='line in paymentLines')
  76. td {{ line.total | currency(...selectedCurrency) }}
  77. td {{ line.date }}
  78. bank-payment-modal(
  79. :initialAmount='amountToPay'
  80. :journals='bankJournals'
  81. :hasSelectedJournal='hasBankJournalSelected'
  82. :banks='banks'
  83. :bankPaymentTypes='bankPaymentTypes'
  84. :selectedBankPaymentType='selectedBankPaymentType'
  85. :chequeTypes='chequeTypes'
  86. :selectedChequeType='selectedChequeType'
  87. :show='showBankPayment'
  88. @onNotify='notify'
  89. @onChangeBankJournal='changeBankJournal'
  90. @onChangeBankPaymentType='changeBankPaymentType'
  91. @onChangeChequeType='changeChequeType'
  92. @onSelectBank='changeBank'
  93. @onDone='endBankPayment'
  94. @onCancel='cancelBankPayment'
  95. )
  96. </template>
  97. <script>
  98. import { mapGetters, mapActions } from 'vuex'
  99. import { Ticket, SwitchButtonInput, InputDropdown } from '../common'
  100. import BankPaymentModal from '../modals/BankPaymentModal'
  101. export default {
  102. components: {
  103. Ticket,
  104. SwitchButtonInput,
  105. InputDropdown,
  106. BankPaymentModal
  107. },
  108. computed: {
  109. paymentTermId: {
  110. get() {
  111. return (this.paymentTerm && this.paymentTerm.id) || -1
  112. },
  113. set(value) {
  114. this.selectPaymentTerm(value)
  115. if (this.paymentType === 'credit') {
  116. this.computePaymentLines()
  117. }
  118. }
  119. },
  120. ...mapGetters([
  121. 'companyName',
  122. 'amountToPay',
  123. 'amountToPayInOtherCurrencies',
  124. 'initialPayment',
  125. 'amountResidual',
  126. 'paymentLines',
  127. 'cartItems',
  128. 'paymentType',
  129. 'paymentTerm',
  130. 'paymentMethod',
  131. 'currencySymbol',
  132. 'showBankPayment',
  133. 'hasBankJournalSelected',
  134. 'selectedCustomerName',
  135. 'selectedCurrency',
  136. 'selectedJournal',
  137. 'selectedBankPaymentType',
  138. 'selectedChequeType',
  139. 'currencies',
  140. 'currencySymbols',
  141. 'journals',
  142. 'bankJournals',
  143. 'paymentTerms',
  144. 'paymentMethods',
  145. 'banks',
  146. 'bankPaymentTypes',
  147. 'chequeTypes',
  148. 'settings'
  149. ])
  150. },
  151. watch: {
  152. paymentType() {
  153. this.focusInitialPayment()
  154. },
  155. paymentTerm() {
  156. this.focusInitialPayment()
  157. },
  158. selectedCurrency() {
  159. this.focusInitialPayment()
  160. }
  161. },
  162. methods: {
  163. focusInitialPayment() {
  164. this.$nextTick(() => this.$refs.initialAmount.$el.children[0].children[0].focus())
  165. },
  166. endBankPayment(data) {
  167. this.changeBankPaymentData(data)
  168. this.toggleBankPayment()
  169. },
  170. changeBankJournal(journalId) {
  171. this.selectJournal(journalId)
  172. this.changeBankPaymentType()
  173. },
  174. cancelBankPayment() {
  175. this.toggleBankPayment()
  176. this.changePaymentMethod('Efectivo')
  177. this.autoSelectJournal()
  178. },
  179. changeAmountReceived(amount) {
  180. this.changeInitialPayment(amount)
  181. },
  182. ...mapActions([
  183. 'autoSelectJournal',
  184. 'changeCurrency',
  185. 'selectPaymentTerm',
  186. 'selectJournal',
  187. 'changePaymentType',
  188. 'changePaymentMethod',
  189. 'changeBankPaymentType',
  190. 'changeChequeType',
  191. 'changeBank',
  192. 'changeInitialPayment',
  193. 'changeBankPaymentData',
  194. 'computePaymentLines',
  195. 'toggleBankPayment',
  196. 'notify'
  197. ])
  198. }
  199. }
  200. </script>
  201. <style lang="sass">
  202. @import '../../assets/variables'
  203. .pos-step
  204. width: 100%
  205. height: calc(100% - 50px)
  206. padding-bottom: 50px
  207. display: flex
  208. form
  209. width: calc(100% - 450px)
  210. height: 100%
  211. margin-right: 50px
  212. padding: 25px
  213. background: $app-bg-color
  214. .form-item
  215. width: 100%
  216. height: 35px
  217. margin-bottom: 15px
  218. & > .form-label, > .form-input
  219. display: inline-block
  220. vertical-align: top
  221. .form-label
  222. width: 200px
  223. height: 35px
  224. font-size: 12pt
  225. line-height: 30px
  226. color: $app-dark-color
  227. .form-input
  228. width: 400px
  229. height: 35px
  230. font-size: 12pt
  231. border-radius: 0
  232. &.input-only
  233. margin-left: 200px
  234. margin-bottom: 15px
  235. .form-item-option
  236. display: inline-block
  237. input
  238. width: 20px
  239. height: 20px
  240. label
  241. font-size: 12pt
  242. margin: 0 35px 15px 5px
  243. .other_exchanges
  244. width: 145px
  245. height: 150px
  246. border: 1px solid #e0e0e0
  247. display: inline-block
  248. position: relative
  249. bottom: calc(50% + 40px)
  250. margin-left: 25px
  251. &:after
  252. content: ''
  253. position: absolute
  254. left: 0
  255. top: 50%
  256. width: 0
  257. height: 0
  258. border: 16px solid transparent
  259. border-right-color: #e0e0e0
  260. border-left: 0
  261. margin-top: -16px
  262. margin-left: -16px
  263. h2
  264. font-size: 8pt
  265. margin: 10px 0 0
  266. color: #d3d3d3
  267. text-align: center
  268. ul
  269. list-style: none
  270. margin: 0
  271. padding: 10px
  272. font-size: 12pt
  273. text-align: center
  274. li
  275. margin-bottom: 10px
  276. border-bottom: 1px solid #eeeeee
  277. .form-item-table
  278. width: 100%
  279. height: 200px
  280. border: 1px solid #e0e0e0
  281. overflow-y: auto
  282. table
  283. width: 100%
  284. thead
  285. background-color: #7c7bad
  286. color: #fff
  287. th
  288. line-height: 35px
  289. padding-left: 10px
  290. th:nth-child(1)
  291. width: 200px
  292. th:nth-child(2)
  293. width: 200px
  294. tbody
  295. td
  296. height: 35px
  297. padding-left: 10px
  298. line-height: 30px
  299. font-size: 11pt
  300. td:nth-child(1)
  301. width: 200px
  302. td:nth-child(2)
  303. width: 200px
  304. </style>