Payment.vue 12 KB

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