{"version":3,"sources":["webpack:///./src/components/Reservations/ModalAddPayment.vue","webpack:///src/components/Reservations/ModalAddPayment.vue","webpack:///./src/components/Reservations/ModalAddPayment.vue?a6e1","webpack:///./src/components/Reservations/ModalAddPayment.vue?5561"],"names":["render","_vm","this","_c","_self","attrs","$t","isSaving","isSavingError","onClickCancel","saveReservationPayment","showModal","on","scopedSlots","_u","key","fn","staticClass","domProps","_s","value","paymentDate","model","callback","$$v","expression","_l","paymentTypes","pt","index","id","class","directives","name","rawName","paymentType","_defineProperty","Number","_q","$event","_v","concat","reservation","CurrencySymbol","amount","proxy","slot","staticRenderFns","components","InputNumeric","props","type","Boolean","default","Function","required","data","Date","computed","_objectSpread","mapState","created","TotalOpen","push","methods","mapMutations","_this","self","paymentProvider","addReservationPayment","Id","$options","filters","dateObjectIsoDateString","then","response","status","$emit","roundToTwo","TotalPaid","setReservation","EventBus","message","catch","error","finally","num","Math","round","component"],"mappings":"uIAAIA,G,UAAS,WAAkB,IAAIC,EAAIC,KAAKC,EAAGF,EAAIG,MAAMD,GAAG,OAAOA,EAAG,qBAAqB,CAACE,MAAM,CAAC,WAAaJ,EAAIK,GAAG,uDAAuD,SAAWL,EAAIM,SAAS,cAAgBN,EAAIO,cAAc,kBAAoBP,EAAIO,cAAc,cAAgBP,EAAIQ,cAAc,YAAcR,EAAIS,uBAAuB,UAAYT,EAAIU,WAAWC,GAAG,CAAC,WAAaX,EAAIQ,eAAeI,YAAYZ,EAAIa,GAAG,CAAC,CAACC,IAAI,UAAUC,GAAG,WAAW,MAAO,CAACb,EAAG,QAAQ,CAACc,YAAY,0DAA0D,CAACd,EAAG,QAAQ,CAACA,EAAG,KAAK,CAACA,EAAG,KAAK,CAACe,SAAS,CAAC,YAAcjB,EAAIkB,GAAGlB,EAAIK,GAAG,0DAA0DH,EAAG,KAAK,CAACA,EAAG,qBAAqB,CAACE,MAAM,CAAC,qBAAsB,GAAMO,GAAG,CAAC,YAAc,SAACQ,GACxuBnB,EAAIoB,YAAc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E,SAAA,WACAlB,EAAA5D,UAAA,MAIAuE,WAAA,SAAAQ,GACA,QAAAC,KAAAC,MAAAF,EAAA,mBCvKuW,I,YCOnWG,EAAY,eACd,EACA,EACA1C,GACA,EACA,KACA,KACA,MAIa,aAAA0C,E","file":"js/chunk-2d2304ed.js?id=2e01422fd83820ef66cc","sourcesContent":["var render = function render(){var _vm=this,_c=_vm._self._c;return _c('ui-component-modal',{attrs:{\"modalTitle\":_vm.$t('Components.Reservations.ModalAddPayment.Modal_Title'),\"isSaving\":_vm.isSaving,\"isSavingError\":_vm.isSavingError,\"hideFooterButtons\":_vm.isSavingError,\"onClickCancel\":_vm.onClickCancel,\"onClickSave\":_vm.saveReservationPayment,\"showModal\":_vm.showModal},on:{\"closeModal\":_vm.onClickCancel},scopedSlots:_vm._u([{key:\"content\",fn:function(){return [_c('table',{staticClass:\"table is-fullwidth is-striped has-text-vertical-middle\"},[_c('tbody',[_c('tr',[_c('td',{domProps:{\"textContent\":_vm._s(_vm.$t('Components.Reservations.ModalAddPayment.Label_Date'))}}),_c('td',[_c('ui-base-date-field',{attrs:{\"openCalendarInModal\":true},on:{\"updateDates\":(value) => {\n                  _vm.paymentDate = value\n                }},model:{value:(_vm.paymentDate),callback:function ($$v) {_vm.paymentDate=$$v},expression:\"paymentDate\"}})],1)]),_c('tr',[_c('td',{domProps:{\"textContent\":_vm._s(_vm.$t('Components.Reservations.ModalAddPayment.Label_Type'))}}),_c('td',_vm._l((_vm.paymentTypes),function(pt,index){return _c('label',{key:pt.id,staticClass:\"radio\",class:{ 'ml-4' : index !== 0 }},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.paymentType),expression:\"paymentType\"}],attrs:{\"type\":\"radio\",\"name\":\"paymentType\"},domProps:{\"value\":Number(pt.id),\"checked\":_vm.paymentType === pt.id,\"checked\":_vm._q(_vm.paymentType,Number(pt.id))},on:{\"change\":function($event){_vm.paymentType=Number(pt.id)}}}),_vm._v(\" \"+_vm._s(_vm.$t(`General.PaymentType_${pt.id}`))+\" \")])}),0)]),_c('tr',[_c('td',{domProps:{\"textContent\":_vm._s(_vm.$t('Components.Reservations.ModalAddPayment.Label_Amount'))}}),_c('td',[_c('div',{staticClass:\"field has-addons\"},[_c('p',{staticClass:\"control\"},[_c('a',{staticClass:\"button is-static\",domProps:{\"innerHTML\":_vm._s(_vm.reservation.CurrencySymbol)}})]),_c('p',{staticClass:\"control\"},[_c('InputNumeric',{model:{value:(_vm.amount),callback:function ($$v) {_vm.amount=$$v},expression:\"amount\"}})],1)])])])])])]},proxy:true}])},[_c('template',{slot:\"modalTitle\"})],2)\n}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","<template>\n  <ui-component-modal\n    :modalTitle=\"$t('Components.Reservations.ModalAddPayment.Modal_Title')\"\n    :isSaving=\"isSaving\"\n    :isSavingError=\"isSavingError\"\n    :hideFooterButtons=\"isSavingError\"\n    :onClickCancel=\"onClickCancel\"\n    :onClickSave=\"saveReservationPayment\"\n    :showModal=\"showModal\"\n    @closeModal=\"onClickCancel\"\n  >\n    <template slot=\"modalTitle\"></template>\n    <template v-slot:content>\n      <table class=\"table is-fullwidth is-striped has-text-vertical-middle\">\n        <tbody>\n          <tr>\n            <td v-text=\"$t('Components.Reservations.ModalAddPayment.Label_Date')\"></td>\n            <td>\n              <ui-base-date-field\n                v-model=\"paymentDate\"\n                :openCalendarInModal=\"true\"\n                @updateDates=\"\n                  (value) => {\n                    paymentDate = value\n                  }\n                \"\n              />\n            </td>\n          </tr>\n          <tr>\n            <td v-text=\"$t('Components.Reservations.ModalAddPayment.Label_Type')\"></td>\n            <td>\n              <label\n                v-for=\"(pt, index) in paymentTypes\"\n                :key=\"pt.id\"\n                class=\"radio\"\n                :class=\"{ 'ml-4' : index !== 0 }\"\n              >\n                <input\n                  type=\"radio\"\n                  name=\"paymentType\"\n                  v-model=\"paymentType\"\n                  :value=\"Number(pt.id)\"\n                  :checked=\"paymentType === pt.id\"\n                />\n                {{ $t(`General.PaymentType_${pt.id}`) }}\n              </label>\n            </td>\n          </tr>\n          <tr>\n            <td v-text=\"$t('Components.Reservations.ModalAddPayment.Label_Amount')\"></td>\n            <td>\n              <div class=\"field has-addons\">\n                <p class=\"control\">\n                  <a\n                    class=\"button is-static\"\n                    v-html=\"reservation.CurrencySymbol\"\n                  ></a>\n                </p>\n                <p class=\"control\">\n                  <InputNumeric\n                    v-model=\"amount\"\n                  />\n                </p>\n              </div>\n            </td>\n          </tr>\n        </tbody>\n      </table>\n    </template>\n  </ui-component-modal>\n</template>\n\n<script>\nimport { mapState, mapMutations } from 'vuex'\nimport { EventBus } from '@/eventbus/event-bus'\nimport paymentProvider from '@/providers/payment'\nimport InputNumeric from '../UI/Form/InputNumeric'\n\nexport default {\n  components: {\n    InputNumeric: () => import('@/components/UI/Form/InputNumeric')\n  },\n\n  props: {\n    showModal: {\n      type: Boolean,\n      default: false,\n    },\n\n    onClickCancel: {\n      type: Function,\n      required: true,\n    },\n  },\n\n  data() {\n    return {\n      isSaving: false,\n      isSavingError: false,\n      amount: 0,\n      paymentType: 2,\n      paymentTypes: [],\n      paymentDate: new Date(),\n    }\n  },\n\n  computed: {\n    ...mapState('reservationStore', ['reservation']),\n  },\n\n  created() {\n    this.amount = this.reservation.TotalOpen\n\n    this.paymentTypes.push({ id: 1, name: 'Cash' })\n    this.paymentTypes.push({ id: 2, name: 'Transfer' })\n    this.paymentTypes.push({ id: 6, name: 'Pin' })\n  },\n\n  methods: {\n    ...mapMutations('reservationStore', ['setReservation']),\n\n    saveReservationPayment() {\n      let self = this\n      self.isSaving = true\n\n      paymentProvider.methods\n        .addReservationPayment(\n          self.reservation.Id,\n          self.paymentType,\n          self.amount,\n          this.$options.filters.dateObjectIsoDateString(this.paymentDate)\n        )\n        .then((response) => {\n          if (response.status === 201) {\n            self.$emit('paymentAdd', response.data)\n\n            self.reservation.TotalOpen = self.roundToTwo(\n              self.reservation.TotalOpen - self.amount\n            )\n            self.reservation.TotalPaid = self.roundToTwo(\n              self.reservation.TotalPaid + self.amount\n            )\n\n            // Update reservation store\n            self.setReservation(self.reservation)\n\n            // Send message to display toast on screen\n            EventBus.$emit('showToast', {\n              type: 'info',\n              message: this.$t(\n                'Components.Reservations.ModalAddPayment.Toast_PaymentAdded'\n              ),\n            })\n\n            this.onClickCancel()\n          }\n        })\n        .catch((error) => {\n          self.isSavingError = true\n        })\n        .finally(() => {\n          self.isSaving = false\n        })\n    },\n\n    roundToTwo(num) {\n      return +(Math.round(num + 'e+2') + 'e-2')\n    },\n  },\n}\n</script>\n","import mod from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./ModalAddPayment.vue?vue&type=script&lang=js\"; export default mod; export * from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--13-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./ModalAddPayment.vue?vue&type=script&lang=js\"","import { render, staticRenderFns } from \"./ModalAddPayment.vue?vue&type=template&id=2b9ad1d1\"\nimport script from \"./ModalAddPayment.vue?vue&type=script&lang=js\"\nexport * from \"./ModalAddPayment.vue?vue&type=script&lang=js\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n  script,\n  render,\n  staticRenderFns,\n  false,\n  null,\n  null,\n  null\n  \n)\n\nexport default component.exports"],"sourceRoot":""}