UNPKG

patrimoniumjs

Version:

Patrimonium.js is a JavaScript library providing a set of tools to modelize the real estate operations of an individual and their impact on the financial situation of the same individual.

1 lines 7.09 kB
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){var t,r;this.amount=e.amount,this.period=e.period,this.interestRate=e.interestRate,this.insuranceRate=e.insuranceRate,this.bankingFees=null!==(t=e.bankingFees)&&void 0!==t?t:0,this.elapsedMonths=null!==(r=e.elapsedMonths)&&void 0!==r?r:0}return Object.defineProperty(e.prototype,"monthlyPayment",{get:function(){var e,t,r=this.amount,n=(t=((e=this).interestRate+e.insuranceRate)/100,Math.pow(1+t,1/12)-1),o=this.period;return r*n*Math.pow(1+n,o)/(Math.pow(1+n,o)-1)},enumerable:!0,configurable:!0}),e.prototype.getAmountStillToBeRepaid=function(){return this.amount-function(e){for(var t,r=e.period,n=(e.interestRate+e.insuranceRate)/100,o=e.amount,i=0,u=null!==(t=e.elapsedMonths)&&void 0!==t?t:0,p=0;p<u;p++)i+=o*n*Math.pow(1+n/12,p)/(12*(Math.pow(1+n/12,r)-1));return i}(this)},e}();t.Loan=n},,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(3);t.BuyPropertyAction=n.BuyPropertyAction;var o=r(4);t.SignLoanAction=o.SignLoanAction;var i=r(5);t.SellPropertyAction=i.SellPropertyAction;var u=r(6);t.RentPropertyAction=u.RentPropertyAction;var p=r(7);t.LeaveRentalPropertyAction=p.LeaveRentalPropertyAction;var s=r(8);t.MoveInAction=s.MoveInAction;var c=r(9);t.MakePropertyImprovementAction=c.MakePropertyImprovementAction;var a=r(10);t.RentOutPropertyAction=a.RentOutPropertyAction},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){this.date=e,this.purchase=function(e){var t,r,n,o,i,u,p,s,c,a;return{price:null!==(t=null==e?void 0:e.price)&&void 0!==t?t:0,notaryFees:null!==(r=null==e?void 0:e.notaryFees)&&void 0!==r?r:0,recurrentExpenses:{residenceTax:null!==(o=null===(n=null==e?void 0:e.recurrentExpenses)||void 0===n?void 0:n.residenceTax)&&void 0!==o?o:0,propertyTax:null!==(u=null===(i=null==e?void 0:e.recurrentExpenses)||void 0===i?void 0:i.propertyTax)&&void 0!==u?u:0,maintenanceFees:null!==(s=null===(p=null==e?void 0:e.recurrentExpenses)||void 0===p?void 0:p.maintenanceFees)&&void 0!==s?s:0},rent:null!==(c=null==e?void 0:e.rent)&&void 0!==c?c:0,growthRate:null!==(a=null==e?void 0:e.growthRate)&&void 0!==a?a:0}}(t)}return e.prototype.execute=function(e){var t,r,n,o,i,u,p,s,c;e.currentAccount-=this.purchase.price+this.purchase.notaryFees,e.properties.push({purchasePrice:(t=this.purchase).price,currentWorth:t.price,recurrentExpenses:{residenceTax:null!==(n=null===(r=t.recurrentExpenses)||void 0===r?void 0:r.residenceTax)&&void 0!==n?n:0,propertyTax:null!==(i=null===(o=t.recurrentExpenses)||void 0===o?void 0:o.propertyTax)&&void 0!==i?i:0,maintenanceFees:null!==(p=null===(u=t.recurrentExpenses)||void 0===u?void 0:u.maintenanceFees)&&void 0!==p?p:0},rent:null!==(s=t.rent)&&void 0!==s?s:0,state:"empty",growthRate:null!==(c=t.growthRate)&&void 0!==c?c:0})},e}();t.BuyPropertyAction=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=function(){function e(e,t){this.date=e,this.options=t,this.date=e}return e.prototype.execute=function(e){var t=new n.Loan(this.options);e.currentAccount+=t.amount-t.bankingFees,e.loans.push(t)},e}();t.SignLoanAction=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){void 0===t&&(t=0),this.date=e,this.propertyIdx=t,this.date=e}return e.prototype.execute=function(e){if(e.properties.length<=this.propertyIdx)throw new Error("Property not found with index '"+this.propertyIdx+".'");var t=e.properties[this.propertyIdx].currentWorth;e.currentAccount+=t,e.properties.splice(this.propertyIdx,1)},e}();t.SellPropertyAction=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){this.date=e,this.rental=t,this.date=e}return e.prototype.execute=function(e){var t,r,n;e.rental=(t=this.rental,{price:null!==(r=t.price)&&void 0!==r?r:0,residenceTax:null!==(n=t.residenceTax)&&void 0!==n?n:0})},e}();t.RentPropertyAction=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.date=e,this.date=e}return e.prototype.execute=function(e){e.rental=null},e}();t.LeaveRentalPropertyAction=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){void 0===t&&(t=0),this.date=e,this.propertyIdx=t,this.date=e}return e.prototype.execute=function(e){if(e.properties.length<=this.propertyIdx)throw new Error("Invalid operation: no property with index '"+this.propertyIdx+"'");!function(e){var t=e.properties.findIndex((function(e){return"usedAsPrincipalResidence"===e.state}));t>-1&&(e.properties[t].state="empty")}(e),function(e,t){e.properties[t].state="usedAsPrincipalResidence"}(e,this.propertyIdx)},e}();t.MoveInAction=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t,r,n){void 0===n&&(n=0),this.date=e,this.cost=t,this.addedValue=r,this.propertyIdx=n,this.date=e}return e.prototype.execute=function(e){if(e.properties.length<=this.propertyIdx)throw new Error("Invalid operation: no property with index '"+this.propertyIdx+"'");e.properties[this.propertyIdx].currentWorth+=this.addedValue,e.currentAccount-=this.cost},e}();t.MakePropertyImprovementAction=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){void 0===t&&(t=0),this.date=e,this.propertyIdx=t}return e.prototype.execute=function(e){if(e.properties.length<=this.propertyIdx)throw new Error("Property not found with index '"+this.propertyIdx+".'");if(!e.properties[this.propertyIdx].rent)throw new Error("Unable to rent out property with index '"+this.propertyIdx+"': the rent of the property has not been defined.");e.properties[this.propertyIdx].state="rented"},e}();t.RentOutPropertyAction=n}])}));