(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;e0&&(t.group_title=this.groupTitle),this.transactions)this.transactions.hasOwnProperty(e)&&/^0$|^[1-9]\d*$/.test(e)&&e<=4294967294&&t.transactions.push(this.convertSplit(e,this.transactions[e]));return t.transactions.length>1&&""!==t.transactions[0].description&&(t.group_title=t.transactions[0].description),t.transactions.length>1&&(t=this.synchronizeAccounts(t)),t},synchronizeAccounts:function(t){for(var e in t.transactions)t.transactions.hasOwnProperty(e)&&/^0$|^[1-9]\d*$/.test(e)&&e<=4294967294&&("Transfer"===this.transactionType&&(t.transactions[e].source_name=null,t.transactions[e].destination_name=null,e>0&&(t.transactions[e].source_id=t.transactions[0].source_id,t.transactions[e].destination_id=t.transactions[0].destination_id)),"Deposit"===this.transactionType&&(t.transactions[e].destination_name=null,e>0&&(t.transactions[e].destination_id=t.transactions[0].destination_id)),"Withdrawal"===this.transactionType&&(t.transactions[e].source_name=null,e>0&&(t.transactions[e].source_id=t.transactions[0].source_id)));return t},switchAccounts:function(t){var e=this.transactions[t].source_account_id,n=this.transactions[t].source_account_name,i=this.transactions[t].source_account_type,s=this.transactions[t].destination_account_id,a=this.transactions[t].destination_account_name,r=this.transactions[t].destination_account_type;this.updateField({index:0,field:"source_account_id",value:s}),this.updateField({index:0,field:"source_account_name",value:a}),this.updateField({index:0,field:"source_account_type",value:r}),this.updateField({index:0,field:"destination_account_id",value:e}),this.updateField({index:0,field:"destination_account_name",value:n}),this.updateField({index:0,field:"destination_account_type",value:i}),this.calculateTransactionType(0)},convertSplit:function(t,e){var n,i,s,a,r="invalid";if(this.time instanceof Date&&!isNaN(this.time)&&this.date instanceof Date&&!isNaN(this.date)){var o=new Date(this.date);o.setHours(this.time.getHours()),o.setMinutes(this.time.getMinutes()),o.setSeconds(this.time.getSeconds()),r=Object(d.c)(o)}var c,l,p,h={description:e.description,date:r,type:this.transactionType,source_id:null!==(n=e.source_account_id)&&void 0!==n?n:null,source_name:null!==(i=e.source_account_name)&&void 0!==i?i:null,destination_id:null!==(s=e.destination_account_id)&&void 0!==s?s:null,destination_name:null!==(a=e.destination_account_name)&&void 0!==a?a:null,currency_id:e.currency_id,amount:e.amount,budget_id:e.budget_id,category_name:e.category,interest_date:e.interest_date,book_date:e.book_date,process_date:e.process_date,due_date:e.due_date,payment_date:e.payment_date,invoice_date:e.invoice_date,internal_reference:e.internal_reference,external_url:e.external_url,notes:e.notes,external_id:e.external_id,zoom_level:e.zoom_level,longitude:e.longitude,latitude:e.latitude,tags:[],order:0,reconciled:!1};if(0!==e.tags.length)for(var _ in e.tags)if(e.tags.hasOwnProperty(_)&&/^0$|^[1-9]\d*$/.test(_)&&_<=4294967294){var f=e.tags[_];"object"===u(f)&&null!==f&&h.tags.push(f.text),"string"==typeof f&&h.tags.push(f)}0!==e.piggy_bank_id&&(h.piggy_bank_id=e.piggy_bank_id),0!==e.bill_id&&(h.bill_id=e.bill_id),0!==e.foreign_currency_id&&""!==e.foreign_amount&&(h.foreign_currency_id=e.foreign_currency_id),""!==e.foreign_amount&&(h.foreign_amount=e.foreign_amount),c=this.transactionType?this.transactionType.toLowerCase():"any",l=this.transactions[0].source_account_type,p=this.transactions[0].destination_account_type,h.currency_id=e.source_account_currency_id,"any"===c&&["asset","Asset account","Loan","Debt","Mortgage"].includes(l)&&(c="withdrawal"),"any"===c&&["asset","Asset account","Loan","Debt","Mortgage"].includes(p)&&(c="deposit",h.currency_id=e.destination_account_currency_id),h.type=c;var m=[];for(var y in e.links)if(e.links.hasOwnProperty(y)&&/^0$|^[1-9]\d*$/.test(y)&&y<=4294967294){var v=e.links[y],b=v.link_type_id.split("-"),g="outward"===b[1]?0:parseInt(v.transaction_journal_id),T="inward"===b[1]?0:parseInt(v.transaction_journal_id),A={link_type_id:parseInt(b[0]),inward_id:g,outward_id:T};m.push(A)}return h.links=m,h},getAllowedOpposingTypes:function(){var t=this;axios.get("./api/v1/configuration/firefly.allowed_opposing_types").then((function(e){t.allowedOpposingTypes=e.data.data.value}))},getAccountToTransaction:function(){var t=this;axios.get("./api/v1/configuration/firefly.account_to_transaction").then((function(e){t.accountToTransaction=e.data.data.value}))},getCustomFields:function(){var t=this;axios.get("./api/v1/preferences/transaction_journal_optional_fields").then((function(e){t.customFields=e.data.data.attributes.data}))},setDestinationAllowedTypes:function(t){0!==t.length?this.destinationAllowedTypes=t:this.destinationAllowedTypes=this.defaultDestinationAllowedTypes},setSourceAllowedTypes:function(t){0!==t.length?this.sourceAllowedTypes=t:this.sourceAllowedTypes=this.defaultSourceAllowedTypes}})},v=n(4),b=Object(v.a)(y,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",[n("alert",{attrs:{message:t.errorMessage,type:"danger"}}),t._v(" "),n("alert",{attrs:{message:t.successMessage,type:"success"}}),t._v(" "),n("SplitPills",{attrs:{transactions:t.transactions}}),t._v(" "),n("div",{staticClass:"tab-content"},t._l(this.transactions,(function(e,i){return n("SplitForm",{key:i,attrs:{"allowed-opposing-types":t.allowedOpposingTypes,count:t.transactions.length,"custom-fields":t.customFields,date:t.date,"destination-allowed-types":t.destinationAllowedTypes,index:i,"source-allowed-types":t.sourceAllowedTypes,"submitted-transaction":t.submittedTransaction,time:t.time,transaction:e,"transaction-type":t.transactionType},on:{"uploaded-attachments":function(e){return t.uploadedAttachment(e)},"set-marker-location":function(e){return t.storeLocation(e)},"set-account":function(e){return t.storeAccountValue(e)},"switch-accounts":function(e){return t.switchAccounts(e)},"set-date":function(e){return t.storeDate(e)},"set-time":function(e){return t.storeTime(e)},"set-field":function(e){return t.storeField(e)},"remove-transaction":function(e){return t.removeTransaction(e)},"set-dest-types":function(e){return t.setDestinationAllowedTypes(e)},"set-src-types":function(e){return t.setSourceAllowedTypes(e)}}})})),1),t._v(" "),n("div",{staticClass:"row"},[n("div",{staticClass:"col-xl-6 col-lg-6 col-md-12 col-sm-12 col-xs-12"},[t.transactions.length>1?n("div",{staticClass:"card"},[n("div",{staticClass:"card-body"},[n("div",{staticClass:"row"},[n("div",{staticClass:"col"},[n("TransactionGroupTitle",{attrs:{errors:this.groupTitleErrors},on:{"set-group-title":function(e){return t.storeGroupTitle(e)}},model:{value:this.groupTitle,callback:function(e){t.$set(this,"groupTitle",e)},expression:"this.groupTitle"}})],1)])])]):t._e()]),t._v(" "),n("div",{staticClass:"col-xl-6 col-lg-6 col-md-12 col-sm-12 col-xs-12"},[n("div",{staticClass:"card card-primary"},[n("div",{staticClass:"card-body"},[n("div",{staticClass:"row"},[n("div",{staticClass:"col"},[n("div",{staticClass:"text-xs d-none d-lg-block d-xl-block"},[t._v("\n  \n ")]),t._v(" "),n("button",{staticClass:"btn btn-outline-primary btn-block",on:{click:t.addTransaction}},[n("i",{staticClass:"far fa-clone"}),t._v(" "+t._s(t.$t("firefly.add_another_split"))+"\n ")])]),t._v(" "),n("div",{staticClass:"col"},[n("div",{staticClass:"text-xs d-none d-lg-block d-xl-block"},[t._v("\n  \n ")]),t._v(" "),n("button",{staticClass:"btn btn-success btn-block",attrs:{disabled:!t.enableSubmit},on:{click:t.submitTransaction}},[t.enableSubmit?n("span",[n("i",{staticClass:"far fa-save"}),t._v(" "+t._s(t.$t("firefly.store_transaction")))]):t._e(),t._v(" "),t.enableSubmit?t._e():n("span",[n("i",{staticClass:"fas fa-spinner fa-spin"})])])])]),t._v(" "),n("div",{staticClass:"row"},[n("div",{staticClass:"col"},[t._v("\n  \n ")]),t._v(" "),n("div",{staticClass:"col"},[n("div",{staticClass:"form-check"},[n("input",{directives:[{name:"model",rawName:"v-model",value:t.createAnother,expression:"createAnother"}],staticClass:"form-check-input",attrs:{id:"createAnother",type:"checkbox"},domProps:{checked:Array.isArray(t.createAnother)?t._i(t.createAnother,null)>-1:t.createAnother},on:{change:function(e){var n=t.createAnother,i=e.target,s=!!i.checked;if(Array.isArray(n)){var a=t._i(n,null);i.checked?a<0&&(t.createAnother=n.concat([null])):a>-1&&(t.createAnother=n.slice(0,a).concat(n.slice(a+1)))}else t.createAnother=s}}}),t._v(" "),n("label",{staticClass:"form-check-label",attrs:{for:"createAnother"}},[n("span",{staticClass:"small"},[t._v(t._s(t.$t("firefly.create_another")))])])]),t._v(" "),n("div",{staticClass:"form-check"},[n("input",{directives:[{name:"model",rawName:"v-model",value:t.resetFormAfter,expression:"resetFormAfter"}],staticClass:"form-check-input",attrs:{id:"resetFormAfter",disabled:!t.createAnother,type:"checkbox"},domProps:{checked:Array.isArray(t.resetFormAfter)?t._i(t.resetFormAfter,null)>-1:t.resetFormAfter},on:{change:function(e){var n=t.resetFormAfter,i=e.target,s=!!i.checked;if(Array.isArray(n)){var a=t._i(n,null);i.checked?a<0&&(t.resetFormAfter=n.concat([null])):a>-1&&(t.resetFormAfter=n.slice(0,a).concat(n.slice(a+1)))}else t.resetFormAfter=s}}}),t._v(" "),n("label",{staticClass:"form-check-label",attrs:{for:"resetFormAfter"}},[n("span",{staticClass:"small"},[t._v(t._s(t.$t("firefly.reset_after")))])])])])])])])])])],1)}),[],!1,null,"6df98ad4",null).exports,g=n(8),T=n.n(g);n(41),T.a.config.productionTip=!1;var A=n(43),w={};new T.a({i18n:A,store:i.a,render:function(t){return t(b,{props:w})},beforeCreate:function(){this.$store.commit("initialiseStore"),this.$store.dispatch("updateCurrencyPreference")}}).$mount("#transactions_create")}},[[335,0,1]]]); //# sourceMappingURL=create.js.map