2021-03-29 06:54:53 +02:00
|
|
|
(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{335:function(t,e,n){t.exports=n(461)},461:function(t,e,n){"use strict";n.r(e);var i=n(30),s=n(14),a=n(68),r=n(46),o=n(69),c=n(66),d=n(29);function u(t){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function l(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function p(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?l(Object(n),!0).forEach((function(e){h(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function h(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var _=Object(s.b)("transactions/create"),f=(_.mapState,_.mapGetters),m=(_.mapActions,_.mapMutations),y={name:"Create",components:{SplitForm:c.a,Alert:a.a,SplitPills:r.a,TransactionGroupTitle:o.a},created:function(){this.getAllowedOpposingTypes(),this.getAccountToTransaction(),this.getCustomFields(),this.addTransaction()},data:function(){return{errorMessage:"",successMessage:"",customFields:{},enableSubmit:!0,createAnother:!1,resetFormAfter:!1,submittedTransaction:!1,submittedLinks:!1,submittedAttachments:!1,inError:!1,submittedAttCount:{},groupTitleErrors:[],returnedGroupId:0,returnedGroupTitle:"",accountToTransaction:{},allowedOpposingTypes:{},defaultSourceAllowedTypes:["Asset account","Loan","Debt","Mortgage","Revenue account"],defaultDestinationAllowedTypes:["Asset account","Loan","Debt","Mortgage","Expense account"],sourceAllowedTypes:["Asset account","Loan","Debt","Mortgage","Revenue account"],destinationAllowedTypes:["Asset account","Loan","Debt","Mortgage","Expense account"],date:new Date,time:new Date}},computed:p({},f(["transactionType","transactions","groupTitle"])),watch:{submittedTransaction:function(){this.finalizeSubmit()},submittedLinks:function(){this.finalizeSubmit()},submittedAttachments:function(){this.finalizeSubmit()}},methods:p(p({},m(["setGroupTitle","addTransaction","deleteTransaction","setTransactionError","setTransactionType","resetErrors","updateField","resetTransactions"])),{},{removeTransaction:function(t){this.$store.commit("transactions/create/deleteTransaction",t)},finalizeSubmit:function(){var t=this;if(this.submittedTransaction&&this.submittedAttachments&&this.submittedLinks){var e;if(!1===this.createAnother&&!1===this.inError)return void(window.location.href=(null!==(e=window.previousURL)&&void 0!==e?e:"/")+"?transaction_group_id="+this.returnedGroupId+"&message=created");for(var n in!1===this.inError&&(this.errorMessage="",this.successMessage=this.$t("firefly.transaction_stored_link",{ID:this.returnedGroupId,title:this.returnedGroupTitle})),this.enableSubmit=!0,this.submittedTransaction=!1,this.submittedLinks=!1,this.submittedAttachments=!1,this.inError=!1,this.transactions)this.transactions.hasOwnProperty(n)&&/^0$|^[1-9]\d*$/.test(n)&&n<=4294967294&&this.transactions.hasOwnProperty(n)&&this.updateField({index:n,field:"transaction_journal_id",value:0});this.submittedAttCount=[],this.resetFormAfter&&(this.resetTransactions(),setTimeout((function(){return t.addTransaction()}),50))}},submitTransaction:function(){var t=this;this.enableSubmit=!1;var e=this.convertData();axios.post("./api/v1/transactions",e).then((function(n){t.submittedTransaction=!0,t.submitTransactionLinks(e,n),t.submitAttachments(e,n),t.returnedGroupId=parseInt(n.data.data.id),t.returnedGroupTitle=null===n.data.data.attributes.group_title?n.data.data.attributes.transactions[0].description:n.data.data.attributes.group_title})).catch((function(e){t.enableSubmit=!0,t.submittedTransaction=!0,t.submittedAttachments=!0,t.submitt
|