@archerjessop/utilities 2.1.0 → 2.2.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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"business.js","sources":["../../src/config/business.js"],"sourcesContent":["/**\n * Business logic and fee constants\n */\n\nexport const BUSINESS_CONSTANTS = {\n // Assignment and transaction fees\n ASSIGNMENT_FEE_PERCENTAGE: 0.05, // 5% assignment fee\n NET_TO_BUYER_PERCENTAGE: 0.10, // 10% net to buyer\n CLOSING_COSTS_PERCENTAGE: 0.0125, // 1.25% closing costs\n FINANCING_FEE_PERCENTAGE: 0.03, // 3% financing fee\n REHAB_PERCENTAGE: 0.0, // 0% rehab fee\n \n // Agent commissions\n SELLER_AGENT_COMMISSION: 0.03, // 3% seller agent commission\n BUYER_AGENT_COMMISSION: 0.03, // 3% buyer agent commission\n \n // COCR15 price calculation limits\n MINIMUM_COCR15_PRICE: 10000, // $10,000 minimum\n MAX_COCR15_PRICE_MULTIPLIER: 50, // Maximum price as multiple of NOI\n CONSERVATIVE_COCR15_PRICE_MULTIPLIER: 20, // Conservative price limit\n \n // Algorithm parameters (duplicated for business logic context)\n\n \n // Calculation parameters\n MAX_ITERATIONS: 50, // Maximum iterations for iterative calculations\n CALCULATION_TOLERANCE: 0.001, // Tolerance for convergence\n ADJUSTMENT_FACTOR: 0.5, // Adjustment factor for iterations\n\n\n \n // Export/import constants\n EXPORT_URL_BASE: \"https://app.archerjessop.com/property-dashboard/import\",\n EXCLUDED_EXPORT_VALUES: [\"Loading...\", \"Not found\", \"\", null, undefined],\n};\n\n// Convenience exports for commonly used values\nexport const {\n ASSIGNMENT_FEE_PERCENTAGE,\n NET_TO_BUYER_PERCENTAGE,\n CLOSING_COSTS_PERCENTAGE,\n FINANCING_FEE_PERCENTAGE,\n SELLER_AGENT_COMMISSION,\n BUYER_AGENT_COMMISSION,\n MINIMUM_COCR15_PRICE,\n MAX_COCR15_PRICE_MULTIPLIER,\n CONSERVATIVE_COCR15_PRICE_MULTIPLIER\n} = BUSINESS_CONSTANTS;\n"],"names":["BUSINESS_CONSTANTS","ASSIGNMENT_FEE_PERCENTAGE","NET_TO_BUYER_PERCENTAGE","CLOSING_COSTS_PERCENTAGE","FINANCING_FEE_PERCENTAGE","REHAB_PERCENTAGE","SELLER_AGENT_COMMISSION","BUYER_AGENT_COMMISSION","MINIMUM_COCR15_PRICE","MAX_COCR15_PRICE_MULTIPLIER","CONSERVATIVE_COCR15_PRICE_MULTIPLIER","MAX_ITERATIONS","CALCULATION_TOLERANCE","ADJUSTMENT_FACTOR","EXPORT_URL_BASE","EXCLUDED_EXPORT_VALUES","undefined"],"mappings":"AAIY,MAACA,EAAqB,CAEhCC,0BAA2B,IAC3BC,wBAAyB,GACzBC,yBAA0B,MAC1BC,yBAA0B,IAC1BC,iBAAkB,EAGlBC,wBAAyB,IACzBC,uBAAwB,IAGxBC,qBAAsB,IACtBC,4BAA6B,GAC7BC,qCAAsC,GAMtCC,eAAgB,GAChBC,sBAAuB,KACvBC,kBAAmB,GAKnBC,gBAAiB,yDACjBC,uBAAwB,CAAC,aAAc,YAAa,GAAI,UAAMC,
|
|
1
|
+
{"version":3,"file":"business.js","sources":["../../src/config/business.js"],"sourcesContent":["/**\n * Business logic and fee constants\n */\n\nexport const BUSINESS_CONSTANTS = {\n // Assignment and transaction fees\n ASSIGNMENT_FEE_PERCENTAGE: 0.05, // 5% assignment fee\n NET_TO_BUYER_PERCENTAGE: 0.10, // 10% net to buyer\n CLOSING_COSTS_PERCENTAGE: 0.0125, // 1.25% closing costs\n FINANCING_FEE_PERCENTAGE: 0.03, // 3% financing fee\n REHAB_PERCENTAGE: 0.0, // 0% rehab fee\n \n // Agent commissions\n SELLER_AGENT_COMMISSION: 0.03, // 3% seller agent commission\n BUYER_AGENT_COMMISSION: 0.03, // 3% buyer agent commission\n \n // COCR15 price calculation limits\n MINIMUM_COCR15_PRICE: 10000, // $10,000 minimum\n MAX_COCR15_PRICE_MULTIPLIER: 50, // Maximum price as multiple of NOI\n CONSERVATIVE_COCR15_PRICE_MULTIPLIER: 20, // Conservative price limit\n \n // Algorithm parameters (duplicated for business logic context)\n\n \n // Calculation parameters\n MAX_ITERATIONS: 50, // Maximum iterations for iterative calculations\n CALCULATION_TOLERANCE: 0.001, // Tolerance for convergence\n ADJUSTMENT_FACTOR: 0.5, // Adjustment factor for iterations\n\n\n \n // Export/import constants\n EXPORT_URL_BASE: \"https://app.archerjessop.com/property-dashboard/import\",\n EXCLUDED_EXPORT_VALUES: [\"Loading...\", \"Not found\", \"\", null, undefined],\n \n};\n\n// Convenience exports for commonly used values\nexport const {\n ASSIGNMENT_FEE_PERCENTAGE,\n NET_TO_BUYER_PERCENTAGE,\n CLOSING_COSTS_PERCENTAGE,\n FINANCING_FEE_PERCENTAGE,\n SELLER_AGENT_COMMISSION,\n BUYER_AGENT_COMMISSION,\n MINIMUM_COCR15_PRICE,\n MAX_COCR15_PRICE_MULTIPLIER,\n CONSERVATIVE_COCR15_PRICE_MULTIPLIER\n} = BUSINESS_CONSTANTS;\n"],"names":["BUSINESS_CONSTANTS","ASSIGNMENT_FEE_PERCENTAGE","NET_TO_BUYER_PERCENTAGE","CLOSING_COSTS_PERCENTAGE","FINANCING_FEE_PERCENTAGE","REHAB_PERCENTAGE","SELLER_AGENT_COMMISSION","BUYER_AGENT_COMMISSION","MINIMUM_COCR15_PRICE","MAX_COCR15_PRICE_MULTIPLIER","CONSERVATIVE_COCR15_PRICE_MULTIPLIER","MAX_ITERATIONS","CALCULATION_TOLERANCE","ADJUSTMENT_FACTOR","EXPORT_URL_BASE","EXCLUDED_EXPORT_VALUES","undefined"],"mappings":"AAIY,MAACA,EAAqB,CAEhCC,0BAA2B,IAC3BC,wBAAyB,GACzBC,yBAA0B,MAC1BC,yBAA0B,IAC1BC,iBAAkB,EAGlBC,wBAAyB,IACzBC,uBAAwB,IAGxBC,qBAAsB,IACtBC,4BAA6B,GAC7BC,qCAAsC,GAMtCC,eAAgB,GAChBC,sBAAuB,KACvBC,kBAAmB,GAKnBC,gBAAiB,yDACjBC,uBAAwB,CAAC,aAAc,YAAa,GAAI,UAAMC,KAKnDf,0BACXA,EAAyBC,wBACzBA,EAAuBC,yBACvBA,EAAwBC,yBACxBA,EAAwBE,wBACxBA,EAAuBC,uBACvBA,EAAsBC,qBACtBA,EAAoBC,4BACpBA,EAA2BC,qCAC3BA,GACEV"}
|
|
@@ -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"],"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\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"}
|