@archerjessop/utilities 2.2.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function calculatePMT(t,c
|
|
1
|
+
import{FINANCIAL_CONSTANTS as t}from"../config/financial.js";import{BUSINESS_CONSTANTS as e}from"../config/business.js";import{PROPERTY_TYPES as c,PROPERTY_TYPE_CONSTANTS as r}from"../config/property-types.js";function calculatePMT(t,e,c){if(0===e)return t/(12*c);const r=e/12,E=12*c;return t*(r*Math.pow(1+r,E))/(Math.pow(1+r,E)-1)}function calculateCOCR30(t,e){try{const c=.3*t,r=12*calculatePMT(.7*t,.075,30);return(e-r)/c*100}catch(t){return 0}}function calculateCashFlowYield(t,e){if(!e||e<=0)return 0;return 12*t/e*100}function calculatePriceForCOCR(c,r=.15,E={}){const{downPercent:a=100*t.DEFAULT_DOWN_PAYMENT,dscrLtvPercent:n=100*t.DEFAULT_DSCR_PERCENTAGE,dscrRate:T=t.DSCR_INTEREST_RATE,dscrTerm:l=t.DSCR_AMORTIZATION,maxIterations:C=e.MAX_ITERATIONS,tolerance:R=e.CALCULATION_TOLERANCE}=E;try{let t=c/.08,E=0;for(;E<C;){const C=t*(a/100),o=12*calculatePMT(t*(n/100),T,l),s=(c-o)/C;if(Math.abs(s-r)<R)break;const _=s-r,u=_*e.ADJUSTMENT_FACTOR;t*=_>0?1+Math.abs(u):1-Math.abs(u),t<1e3&&(t=1e3),t>c*e.MAX_COCR15_PRICE_MULTIPLIER&&(t=c*e.CONSERVATIVE_COCR15_PRICE_MULTIPLIER),E++}return t<e.MINIMUM_COCR15_PRICE&&(t=e.MINIMUM_COCR15_PRICE),t}catch(t){return 0}}function calculateCOCRAtPercent(e,c,r,E={}){const{dscrLtvPercent:a=100*t.DEFAULT_DSCR_PERCENTAGE,sellerFiPercent:n=0,dscrRate:T=t.DSCR_INTEREST_RATE,dscrTerm:l=t.DSCR_AMORTIZATION,sellerFiTerm:C=t.SELLER_FI_AMORTIZATION}=E;try{const E=e*(r/100),R=e*(n/100),o=Math.max(0,a-n),s=12*calculatePMT(e*(o/100),T,l),_=12*calculatePMT(R,t.SELLER_FI_INTEREST_RATE,C);return(c-s-_)/E*100}catch(t){return 0}}function calculateNOIByType(t,e,E=c.MULTIFAMILY,a={}){const{strGrossIncomeMultiplier:n=r.STR.ESTIMATED_GROSS_RATE,strNoiPercentage:T=r.STR.NOI_PERCENTAGE,assistedIncomePerBedroom:l=r.ASSISTED_LIVING.INCOME_PER_BEDROOM_MONTHLY,bedroomCount:C=r.ASSISTED_LIVING.DEFAULT_BEDROOM_COUNT}=a;try{switch(E.toLowerCase()){case c.STR:return t*n*T;case c.ASSISTED_LIVING:return C*l*12;case c.MULTIFAMILY:default:return t*e}}catch(t){return 0}}function calculateAssignmentFee(t,c=100*e.ASSIGNMENT_FEE_PERCENTAGE){try{return t*(c/100)}catch(t){return 0}}function calculateNetToBuyer(c,r={}){const{buyerCostPercent:E=100*e.NET_TO_BUYER_PERCENTAGE,sellerCostAssignment:a=100*e.ASSIGNMENT_FEE_PERCENTAGE,sellerCostClosing:n=100*e.CLOSING_COSTS_PERCENTAGE,additionalCostRehab:T=100*e.REHAB_PERCENTAGE,additionalCostFinancing:l=100*e.FINANCING_FEE_PERCENTAGE,dscrLtvPercent:C=100*t.DEFAULT_DSCR_PERCENTAGE}=r;try{return c*(E/100)-c*((a+n)/100)-c*(T/100)-l/100*(c-c*(C/100))}catch(t){return 0}}export{calculateAssignmentFee,calculateCOCR30,calculateCOCRAtPercent,calculateCashFlowYield,calculateNOIByType,calculateNetToBuyer,calculatePMT,calculatePriceForCOCR};
|
|
2
2
|
//# sourceMappingURL=calculations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculations.js","sources":["../../src/financial/calculations.js"],"sourcesContent":["// src/financial/calculations.js\n\n/**\n * PMT function for loan payment calculation\n * @param {number} principal - Loan principal amount \n * @param {number} annualRate - Annual interest rate (as decimal, e.g., 0.075 for 7.5%)\n * @param {number} years - Loan term in years\n * @returns {number} Monthly payment amount\n */\nexport function calculatePMT(principal, annualRate, years) {\n if (annualRate === 0) {\n return principal / (years * 12);\n }\n \n const monthlyRate = annualRate / 12;\n const numPayments = years * 12;\n const pmt = principal * (monthlyRate * Math.pow(1 + monthlyRate, numPayments)) / \n (Math.pow(1 + monthlyRate, numPayments) - 1);\n return pmt;\n}\n\nexport function calculateCOCR30(askingPrice, noi) {\n try {\n const cashInvested = askingPrice * 0.30; // 30% down payment\n const dscrLoanAmount = askingPrice * 0.70; // Fixed 70% DSCR loan\n const dscrPayment = calculatePMT(dscrLoanAmount, 0.075, 30) * 12; // Annual DSCR payment\n const annualCashFlow = noi - dscrPayment;\n const cocr = (annualCashFlow / cashInvested) * 100;\n \n return cocr;\n } catch (error) {\n return 0;\n }\n}\n\nexport function calculateCashFlowYield(monthlyCashFlow, purchasePrice) {\n if (!purchasePrice || purchasePrice <= 0) return 0;\n const annualCashFlow = monthlyCashFlow * 12;\n return (annualCashFlow / purchasePrice) * 100;\n}\n\n/**\n * Calculate the property price that yields a target COCR percentage\n * @param {number} noi - Net Operating Income (annual)\n * @param {number} targetCOCR - Target COCR as decimal (e.g., 0.15 for 15%)\n * @param {Object} options - Configuration options\n * @param {number} options.downPercent - Down payment percentage (default: 30)\n * @param {number} options.dscrLtvPercent - DSCR loan LTV percentage (default: 70)\n * @param {number} options.dscrRate - DSCR interest rate as decimal (default: 0.075)\n * @param {number} options.dscrTerm - DSCR loan term in years (default: 30)\n * @param {number} options.maxIterations - Maximum iterations for convergence (default: 50)\n * @param {number} options.tolerance - Convergence tolerance (default: 0.001)\n * @returns {number} Calculated property price\n */\nexport function calculatePriceForCOCR(noi, targetCOCR = 0.15, options = {}) {\n const {\n downPercent = 30,\n dscrLtvPercent = 70,\n dscrRate = 0.075,\n dscrTerm = 30,\n maxIterations = 50,\n tolerance = 0.001\n } = options;\n\n try {\n // Initial estimate: NOI / 8% cap rate\n let targetPrice = noi / 0.08;\n let iterations = 0;\n \n while (iterations < maxIterations) {\n const cashInvested = targetPrice * (downPercent / 100);\n const dscrLoanAmount = targetPrice * (dscrLtvPercent / 100);\n const dscrPayment = calculatePMT(dscrLoanAmount, dscrRate, dscrTerm) * 12;\n const annualCashFlow = noi - dscrPayment;\n const currentCOCR = annualCashFlow / cashInvested;\n \n if (Math.abs(currentCOCR - targetCOCR) < tolerance) {\n return targetPrice;\n }\n \n const error = currentCOCR - targetCOCR;\n const adjustment = error * 0.5;\n \n if (error > 0) {\n targetPrice = targetPrice * (1 + Math.abs(adjustment));\n } else {\n targetPrice = targetPrice * (1 - Math.abs(adjustment));\n }\n \n // Reasonable bounds\n if (targetPrice < 10000) targetPrice = 10000;\n if (targetPrice > noi * 50) targetPrice = noi * 20;\n \n iterations++;\n }\n \n return targetPrice;\n } catch (error) {\n return 0;\n }\n}\n\n/**\n * Calculate COCR at a specific down payment percentage\n * @param {number} askingPrice - Property asking price\n * @param {number} noi - Net Operating Income (annual)\n * @param {number} downPercent - Down payment percentage\n * @param {Object} options - Configuration options\n * @param {number} options.dscrLtvPercent - DSCR loan LTV percentage (default: 70)\n * @param {number} options.sellerFiPercent - Seller financing percentage (default: 0)\n * @param {number} options.dscrRate - DSCR interest rate as decimal (default: 0.075)\n * @param {number} options.dscrTerm - DSCR loan term in years (default: 30)\n * @param {number} options.sellerFiTerm - Seller financing term in years (default: 30)\n * @returns {number} COCR percentage\n */\nexport function calculateCOCRAtPercent(askingPrice, noi, downPercent, options = {}) {\n const {\n dscrLtvPercent = 70,\n sellerFiPercent = 0,\n dscrRate = 0.075,\n dscrTerm = 30,\n sellerFiTerm = 30\n } = options;\n\n try {\n const downDecimal = downPercent / 100;\n const cashInvested = askingPrice * downDecimal;\n \n const dscrLoanAmount = askingPrice * (dscrLtvPercent / 100);\n const dscrPayment = calculatePMT(dscrLoanAmount, dscrRate, dscrTerm) * 12;\n \n const sellerFiAmount = askingPrice * (sellerFiPercent / 100);\n const jvPayment = calculatePMT(sellerFiAmount, 0, sellerFiTerm) * 12;\n \n const annualCashFlow = noi - dscrPayment - jvPayment;\n const cocr = (annualCashFlow / cashInvested) * 100;\n \n return cocr;\n } catch (error) {\n return 0;\n }\n}\n\n/**\n * Calculate NOI based on property type\n * @param {number} askingPrice - Property asking price\n * @param {number} capRate - Cap rate as decimal (e.g., 0.08 for 8%)\n * @param {string} propertyType - Property type: \"multifamily\", \"str\", \"assisted\"\n * @param {Object} options - Configuration options\n * @param {number} options.strGrossIncomeMultiplier - STR gross income multiplier (default: 0.10)\n * @param {number} options.strExpenseRatio - STR expense ratio (default: 0.45)\n * @param {number} options.assistedIncomePerBedroom - Monthly income per bedroom for assisted living (default: 1500)\n * @param {number} options.bedroomCount - Number of bedrooms for assisted living (default: 4)\n * @returns {number} Calculated NOI\n */\nexport function calculateNOIByType(askingPrice, capRate, propertyType = \"multifamily\", options = {}) {\n const {\n strGrossIncomeMultiplier = 0.10,\n strExpenseRatio = 0.45,\n assistedIncomePerBedroom = 1500,\n bedroomCount = 4\n } = options;\n\n try {\n switch (propertyType.toLowerCase()) {\n case \"str\":\n // STR calculation: price * 10% gross income * 55% net ratio\n const estimatedGrossIncome = askingPrice * strGrossIncomeMultiplier;\n return estimatedGrossIncome * (1 - strExpenseRatio);\n \n case \"assisted\":\n // Assisted living: bedrooms * $1500/month * 12 months\n return bedroomCount * assistedIncomePerBedroom * 12;\n \n case \"multifamily\":\n default:\n // Standard multifamily: asking price * cap rate\n return askingPrice * capRate;\n }\n } catch (error) {\n return 0;\n }\n}\n\n/**\n * Calculate assignment fee\n * @param {number} askingPrice - Property asking price\n * @param {number} assignmentPercent - Assignment fee percentage (default: 5)\n * @returns {number} Assignment fee amount\n */\nexport function calculateAssignmentFee(askingPrice, assignmentPercent = 5) {\n try {\n return askingPrice * (assignmentPercent / 100);\n } catch (error) {\n return 0;\n }\n}\n\n/**\n * Calculate net to buyer\n * @param {number} askingPrice - Property asking price\n * @param {Object} options - Configuration options\n * @param {number} options.buyerCostPercent - Buyer cost percentage (default: 10)\n * @param {number} options.sellerCostPercent - Seller cost percentage (default: 6.25)\n * @param {number} options.additionalCostPercent - Additional cost percentage (default: 3)\n * @param {number} options.dscrLtvPercent - DSCR loan LTV percentage for calculation (default: 70)\n * @returns {number} Net to buyer amount\n */\nexport function calculateNetToBuyer(askingPrice, options = {}) {\n const {\n buyerCostPercent = 10,\n sellerCostPercent = 6.25,\n additionalCostPercent = 3,\n dscrLtvPercent = 70\n } = options;\n\n try {\n const dscrLoanAmount = askingPrice * (dscrLtvPercent / 100);\n \n return askingPrice * (buyerCostPercent / 100) - \n askingPrice * (sellerCostPercent / 100) - \n (additionalCostPercent / 100) * (askingPrice - dscrLoanAmount);\n } catch (error) {\n return 0;\n }\n}"],"names":["calculatePMT","principal","annualRate","years","monthlyRate","numPayments","Math","pow","calculateCOCR30","askingPrice","noi","cashInvested","dscrPayment","error","calculateCashFlowYield","monthlyCashFlow","purchasePrice"],"mappings":"AASO,SAASA,aAAaC,EAAWC,EAAYC,GAClD,GAAmB,IAAfD,EACF,OAAOD,GAAqB,GAARE,GAGtB,MAAMC,EAAcF,EAAa,GAC3BG,EAAsB,GAARF,EAGpB,OAFYF,GAAaG,EAAcE,KAAKC,IAAI,EAAIH,EAAaC,KACpDC,KAAKC,IAAI,EAAIH,EAAaC,GAAe,EAExD,CAEO,SAASG,gBAAgBC,EAAaC,GAC3C,IACE,MAAMC,EAA6B,GAAdF,EAEfG,EAAwD,GAA1CZ,aADiB,GAAdS,EAC0B,KAAO,IAIxD,OAHuBC,EAAME,GACED,EAAgB,GAGjD,CAAE,MAAOE,GACP,OAAO,CACT,CACF,CAEO,SAASC,uBAAuBC,EAAiBC,GACtD,IAAKA,GAAiBA,GAAiB,EAAG,OAAO,EAEjD,OADyC,GAAlBD,EACEC,EAAiB,GAC5C"}
|
|
1
|
+
{"version":3,"file":"calculations.js","sources":["../../src/financial/calculations.js"],"sourcesContent":["// src/financial/calculations.js\r\n\r\nimport { FINANCIAL_CONSTANTS } from '../config/financial.js';\r\nimport { BUSINESS_CONSTANTS } from '../config/business.js';\r\nimport { PROPERTY_TYPE_CONSTANTS, PROPERTY_TYPES } from '../config/property-types.js';\r\n\r\n\r\n/**\r\n * PMT function for loan payment calculation\r\n * @param {number} principal - Loan principal amount \r\n * @param {number} annualRate - Annual interest rate (as decimal, e.g., 0.075 for 7.5%)\r\n * @param {number} years - Loan term in years\r\n * @returns {number} Monthly payment amount\r\n */\r\nexport function calculatePMT(principal, annualRate, years) {\r\n if (annualRate === 0) {\r\n return principal / (years * 12);\r\n }\r\n \r\n const monthlyRate = annualRate / 12;\r\n const numPayments = years * 12;\r\n const pmt = principal * (monthlyRate * Math.pow(1 + monthlyRate, numPayments)) / \r\n (Math.pow(1 + monthlyRate, numPayments) - 1);\r\n return pmt;\r\n}\r\n\r\nexport function calculateCOCR30(askingPrice, noi) {\r\n try {\r\n const cashInvested = askingPrice * 0.30; // 30% down payment\r\n const dscrLoanAmount = askingPrice * 0.70; // Fixed 70% DSCR loan\r\n const dscrPayment = calculatePMT(dscrLoanAmount, 0.075, 30) * 12; // Annual DSCR payment\r\n const annualCashFlow = noi - dscrPayment;\r\n const cocr = (annualCashFlow / cashInvested) * 100;\r\n \r\n return cocr;\r\n } catch (error) {\r\n return 0;\r\n }\r\n}\r\n\r\nexport function calculateCashFlowYield(monthlyCashFlow, purchasePrice) {\r\n if (!purchasePrice || purchasePrice <= 0) return 0;\r\n const annualCashFlow = monthlyCashFlow * 12;\r\n return (annualCashFlow / purchasePrice) * 100;\r\n}\r\n\r\n\r\n/**\r\n * Calculate the property price that yields a target COCR percentage\r\n * @param {number} noi - Net Operating Income (annual)\r\n * @param {number} targetCOCR - Target COCR as decimal (default: 0.15 for 15%)\r\n * @param {Object} options - Configuration options (uses config constants as defaults)\r\n * @returns {number} Calculated property price\r\n */\r\nexport function calculatePriceForCOCR(noi, targetCOCR = 0.15, options = {}) {\r\n const {\r\n downPercent = FINANCIAL_CONSTANTS.DEFAULT_DOWN_PAYMENT * 100,\r\n dscrLtvPercent = FINANCIAL_CONSTANTS.DEFAULT_DSCR_PERCENTAGE * 100,\r\n dscrRate = FINANCIAL_CONSTANTS.DSCR_INTEREST_RATE,\r\n dscrTerm = FINANCIAL_CONSTANTS.DSCR_AMORTIZATION,\r\n maxIterations = BUSINESS_CONSTANTS.MAX_ITERATIONS,\r\n tolerance = BUSINESS_CONSTANTS.CALCULATION_TOLERANCE\r\n } = options;\r\n\r\n try {\r\n let targetPrice = noi / 0.08; // Initial estimate: NOI / 8% cap rate\r\n let iterations = 0;\r\n \r\n while (iterations < maxIterations) {\r\n const cashInvested = targetPrice * (downPercent / 100);\r\n const dscrLoanAmount = targetPrice * (dscrLtvPercent / 100);\r\n const dscrPayment = calculatePMT(dscrLoanAmount, dscrRate, dscrTerm) * 12;\r\n const annualCashFlow = noi - dscrPayment;\r\n const currentCOCR = annualCashFlow / cashInvested;\r\n \r\n if (Math.abs(currentCOCR - targetCOCR) < tolerance) {\r\n break;\r\n }\r\n \r\n const error = currentCOCR - targetCOCR;\r\n const adjustment = error * BUSINESS_CONSTANTS.ADJUSTMENT_FACTOR;\r\n \r\n if (error > 0) {\r\n targetPrice = targetPrice * (1 + Math.abs(adjustment));\r\n } else {\r\n targetPrice = targetPrice * (1 - Math.abs(adjustment));\r\n }\r\n \r\n // Reasonable bounds during iteration (prevent extreme values)\r\n if (targetPrice < 1000) targetPrice = 1000;\r\n if (targetPrice > noi * BUSINESS_CONSTANTS.MAX_COCR15_PRICE_MULTIPLIER) {\r\n targetPrice = noi * BUSINESS_CONSTANTS.CONSERVATIVE_COCR15_PRICE_MULTIPLIER;\r\n }\r\n \r\n iterations++;\r\n }\r\n \r\n // Apply final bounds check AFTER iteration\r\n if (targetPrice < BUSINESS_CONSTANTS.MINIMUM_COCR15_PRICE) {\r\n targetPrice = BUSINESS_CONSTANTS.MINIMUM_COCR15_PRICE;\r\n }\r\n \r\n return targetPrice;\r\n } catch (error) {\r\n return 0;\r\n }\r\n}\r\n\r\n/**\r\n * Calculate COCR at a specific down payment percentage\r\n * @param {number} askingPrice - Property asking price\r\n * @param {number} noi - Net Operating Income (annual)\r\n * @param {number} downPercent - Down payment percentage\r\n * @param {Object} options - Configuration options (uses config constants as defaults)\r\n * @returns {number} COCR percentage\r\n */\r\nexport function calculateCOCRAtPercent(askingPrice, noi, downPercent, options = {}) {\r\n const {\r\n dscrLtvPercent = FINANCIAL_CONSTANTS.DEFAULT_DSCR_PERCENTAGE * 100,\r\n sellerFiPercent = 0,\r\n dscrRate = FINANCIAL_CONSTANTS.DSCR_INTEREST_RATE,\r\n dscrTerm = FINANCIAL_CONSTANTS.DSCR_AMORTIZATION,\r\n sellerFiTerm = FINANCIAL_CONSTANTS.SELLER_FI_AMORTIZATION\r\n } = options;\r\n\r\n try {\r\n const downDecimal = downPercent / 100;\r\n const cashInvested = askingPrice * downDecimal;\r\n \r\n // Fix financing structure: seller financing reduces available DSCR loan\r\n const sellerFiAmount = askingPrice * (sellerFiPercent / 100);\r\n const availableDscrPercent = Math.max(0, dscrLtvPercent - sellerFiPercent);\r\n const dscrLoanAmount = askingPrice * (availableDscrPercent / 100);\r\n \r\n const dscrPayment = calculatePMT(dscrLoanAmount, dscrRate, dscrTerm) * 12;\r\n const jvPayment = calculatePMT(sellerFiAmount, FINANCIAL_CONSTANTS.SELLER_FI_INTEREST_RATE, sellerFiTerm) * 12;\r\n \r\n const annualCashFlow = noi - dscrPayment - jvPayment;\r\n const cocr = (annualCashFlow / cashInvested) * 100;\r\n \r\n return cocr;\r\n } catch (error) {\r\n return 0;\r\n }\r\n}\r\n\r\n/**\r\n * Calculate NOI based on property type\r\n * @param {number} askingPrice - Property asking price\r\n * @param {number} capRate - Cap rate as decimal (e.g., 0.08 for 8%)\r\n * @param {string} propertyType - Property type from PROPERTY_TYPES\r\n * @param {Object} options - Configuration options (uses config constants as defaults)\r\n * @returns {number} Calculated NOI\r\n */\r\nexport function calculateNOIByType(askingPrice, capRate, propertyType = PROPERTY_TYPES.MULTIFAMILY, options = {}) {\r\n const {\r\n strGrossIncomeMultiplier = PROPERTY_TYPE_CONSTANTS.STR.ESTIMATED_GROSS_RATE,\r\n strNoiPercentage = PROPERTY_TYPE_CONSTANTS.STR.NOI_PERCENTAGE,\r\n assistedIncomePerBedroom = PROPERTY_TYPE_CONSTANTS.ASSISTED_LIVING.INCOME_PER_BEDROOM_MONTHLY,\r\n bedroomCount = PROPERTY_TYPE_CONSTANTS.ASSISTED_LIVING.DEFAULT_BEDROOM_COUNT\r\n } = options;\r\n\r\n try {\r\n switch (propertyType.toLowerCase()) {\r\n case PROPERTY_TYPES.STR:\r\n const estimatedGrossIncome = askingPrice * strGrossIncomeMultiplier;\r\n return estimatedGrossIncome * strNoiPercentage;\r\n \r\n case PROPERTY_TYPES.ASSISTED_LIVING:\r\n return bedroomCount * assistedIncomePerBedroom * 12;\r\n \r\n case PROPERTY_TYPES.MULTIFAMILY:\r\n default:\r\n return askingPrice * capRate;\r\n }\r\n } catch (error) {\r\n return 0;\r\n }\r\n}\r\n\r\n/**\r\n * Calculate assignment fee\r\n * @param {number} askingPrice - Property asking price\r\n * @param {number} assignmentPercent - Assignment fee percentage (uses config default)\r\n * @returns {number} Assignment fee amount\r\n */\r\nexport function calculateAssignmentFee(askingPrice, assignmentPercent = BUSINESS_CONSTANTS.ASSIGNMENT_FEE_PERCENTAGE * 100) {\r\n try {\r\n return askingPrice * (assignmentPercent / 100);\r\n } catch (error) {\r\n return 0;\r\n }\r\n}\r\n\r\n/**\r\n * Calculate net to buyer\r\n * @param {number} askingPrice - Property asking price\r\n * @param {Object} options - Configuration options (uses config constants as defaults)\r\n * @returns {number} Net to buyer amount\r\n */\r\nexport function calculateNetToBuyer(askingPrice, options = {}) {\r\n const {\r\n buyerCostPercent = BUSINESS_CONSTANTS.NET_TO_BUYER_PERCENTAGE * 100,\r\n sellerCostAssignment = BUSINESS_CONSTANTS.ASSIGNMENT_FEE_PERCENTAGE * 100,\r\n sellerCostClosing = BUSINESS_CONSTANTS.CLOSING_COSTS_PERCENTAGE * 100,\r\n additionalCostRehab = BUSINESS_CONSTANTS.REHAB_PERCENTAGE * 100,\r\n additionalCostFinancing = BUSINESS_CONSTANTS.FINANCING_FEE_PERCENTAGE * 100,\r\n dscrLtvPercent = FINANCIAL_CONSTANTS.DEFAULT_DSCR_PERCENTAGE * 100\r\n } = options;\r\n\r\n try {\r\n const dscrLoanAmount = askingPrice * (dscrLtvPercent / 100);\r\n \r\n return askingPrice * (buyerCostPercent / 100) - \r\n askingPrice * ((sellerCostAssignment + sellerCostClosing) / 100) - \r\n askingPrice * (additionalCostRehab / 100) - \r\n (additionalCostFinancing / 100) * (askingPrice - dscrLoanAmount);\r\n } catch (error) {\r\n return 0;\r\n }\r\n}"],"names":["calculatePMT","principal","annualRate","years","monthlyRate","numPayments","Math","pow","calculateCOCR30","askingPrice","noi","cashInvested","dscrPayment","error","calculateCashFlowYield","monthlyCashFlow","purchasePrice","calculatePriceForCOCR","targetCOCR","options","downPercent","FINANCIAL_CONSTANTS","DEFAULT_DOWN_PAYMENT","dscrLtvPercent","DEFAULT_DSCR_PERCENTAGE","dscrRate","DSCR_INTEREST_RATE","dscrTerm","DSCR_AMORTIZATION","maxIterations","BUSINESS_CONSTANTS","MAX_ITERATIONS","tolerance","CALCULATION_TOLERANCE","targetPrice","iterations","currentCOCR","abs","adjustment","ADJUSTMENT_FACTOR","MAX_COCR15_PRICE_MULTIPLIER","CONSERVATIVE_COCR15_PRICE_MULTIPLIER","MINIMUM_COCR15_PRICE","calculateCOCRAtPercent","sellerFiPercent","sellerFiTerm","SELLER_FI_AMORTIZATION","sellerFiAmount","availableDscrPercent","max","jvPayment","SELLER_FI_INTEREST_RATE","calculateNOIByType","capRate","propertyType","PROPERTY_TYPES","MULTIFAMILY","strGrossIncomeMultiplier","PROPERTY_TYPE_CONSTANTS","STR","ESTIMATED_GROSS_RATE","strNoiPercentage","NOI_PERCENTAGE","assistedIncomePerBedroom","ASSISTED_LIVING","INCOME_PER_BEDROOM_MONTHLY","bedroomCount","DEFAULT_BEDROOM_COUNT","toLowerCase","calculateAssignmentFee","assignmentPercent","ASSIGNMENT_FEE_PERCENTAGE","calculateNetToBuyer","buyerCostPercent","NET_TO_BUYER_PERCENTAGE","sellerCostAssignment","sellerCostClosing","CLOSING_COSTS_PERCENTAGE","additionalCostRehab","REHAB_PERCENTAGE","additionalCostFinancing","FINANCING_FEE_PERCENTAGE"],"mappings":"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"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{calculateCOCR30,calculateCashFlowYield,calculatePMT}from"./financial/calculations.js";export{formatCurrency,formatPercentage,formatPriceValue}from"./financial/formatters.js";export{extractBedrooms,extractPhoneNumber}from"./data/extractors.js";export{calculateDOM}from"./date/utilities.js";export{CALCULATION_TOLERANCE,DEFAULT_CAP_RATE,DEFAULT_DOWN_PAYMENT,DEFAULT_DSCR_PERCENTAGE,DSCR_AMORTIZATION,DSCR_INTEREST_RATE,FINANCIAL_CONSTANTS,MAX_ITERATIONS,SELLER_FI_AMORTIZATION,SELLER_FI_CARRY,SELLER_FI_DOWN_PAYMENT,SELLER_FI_INTEREST_RATE}from"./config/financial.js";export{ASSISTED_LIVING,MULTIFAMILY,PROPERTY_TYPES,PROPERTY_TYPE_CONSTANTS,STR}from"./config/property-types.js";export{ASSIGNMENT_FEE_PERCENTAGE,BUSINESS_CONSTANTS,BUYER_AGENT_COMMISSION,CLOSING_COSTS_PERCENTAGE,CONSERVATIVE_COCR15_PRICE_MULTIPLIER,FINANCING_FEE_PERCENTAGE,MAX_COCR15_PRICE_MULTIPLIER,MINIMUM_COCR15_PRICE,NET_TO_BUYER_PERCENTAGE,SELLER_AGENT_COMMISSION}from"./config/business.js";
|
|
1
|
+
export{calculateAssignmentFee,calculateCOCR30,calculateCOCRAtPercent,calculateCashFlowYield,calculateNOIByType,calculateNetToBuyer,calculatePMT,calculatePriceForCOCR}from"./financial/calculations.js";export{formatCurrency,formatPercentage,formatPriceValue}from"./financial/formatters.js";export{extractBedrooms,extractPhoneNumber}from"./data/extractors.js";export{calculateDOM}from"./date/utilities.js";export{CALCULATION_TOLERANCE,DEFAULT_CAP_RATE,DEFAULT_DOWN_PAYMENT,DEFAULT_DSCR_PERCENTAGE,DSCR_AMORTIZATION,DSCR_INTEREST_RATE,FINANCIAL_CONSTANTS,MAX_ITERATIONS,SELLER_FI_AMORTIZATION,SELLER_FI_CARRY,SELLER_FI_DOWN_PAYMENT,SELLER_FI_INTEREST_RATE}from"./config/financial.js";export{ASSISTED_LIVING,MULTIFAMILY,PROPERTY_TYPES,PROPERTY_TYPE_CONSTANTS,STR}from"./config/property-types.js";export{ASSIGNMENT_FEE_PERCENTAGE,BUSINESS_CONSTANTS,BUYER_AGENT_COMMISSION,CLOSING_COSTS_PERCENTAGE,CONSERVATIVE_COCR15_PRICE_MULTIPLIER,FINANCING_FEE_PERCENTAGE,MAX_COCR15_PRICE_MULTIPLIER,MINIMUM_COCR15_PRICE,NET_TO_BUYER_PERCENTAGE,SELLER_AGENT_COMMISSION}from"./config/business.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|