-
Notifications
You must be signed in to change notification settings - Fork 0
/
moore-marsden.js
82 lines (70 loc) · 4.49 KB
/
moore-marsden.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Calculation functions
function subtractLine1FromLine4(purchasePrice, fairMarketAtMarriage) {
return fairMarketAtMarriage - purchasePrice;
}
function subtractLine4FromLine6(fairMarketAtMarriage, fairMarketAtDivision) {
return fairMarketAtDivision - fairMarketAtMarriage;
}
function divideLine5ByLine1(paymentsWithCommunityFunds, purchasePrice) {
return paymentsWithCommunityFunds / purchasePrice;
}
function multiplyLine8ByLine9(line8Result, line9Result) {
return line8Result * line9Result;
}
function subtractLine10FromLine8(line8Result, line10Result) {
return line8Result - line10Result;
}
function calculateSPInterest(downPayment, paymentsWithSeparateFunds, line7Result, line11Result) {
return downPayment + paymentsWithSeparateFunds + line7Result + line11Result;
}
function calculateCPInterest(communityPayments, line10Result) {
return communityPayments + line10Result;
}
// Main calculation function with logging
function calculateMooreMarsden(purchasePrice, downPayment, paymentsWithSeparateFunds, fairMarketAtMarriage, paymentsWithCommunityFunds, fairMarketAtDivision) {
const line7Result = subtractLine1FromLine4(purchasePrice, fairMarketAtMarriage); // Line 7 appreciation before marriage.
const line8Result = subtractLine4FromLine6(fairMarketAtMarriage, fairMarketAtDivision); // Line 8 appreciation during the marriage.
const line9Result = divideLine5ByLine1(paymentsWithCommunityFunds, purchasePrice); // Line 9 proportion of community payments
const line10Result = multiplyLine8ByLine9(line8Result, line9Result); // Line 10 community share of appreciation.
const line11Result = subtractLine10FromLine8(line8Result, line10Result); // Line 11 separate property share of appreciation
const spInterest = calculateSPInterest(downPayment, paymentsWithSeparateFunds, line7Result, line11Result); // SP Interest
const cpInterest = calculateCPInterest(paymentsWithCommunityFunds, line10Result); // CP Interest
// Formatting functions
const currencyFormatter = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' });
const percentageFormatter = new Intl.NumberFormat('en-US', { style: 'percent', minimumFractionDigits: 2 });
// Logging results with formatting
console.log(`1. Purchase price: ${currencyFormatter.format(purchasePrice)}`);
console.log(`2. Down payment: ${currencyFormatter.format(downPayment)}`);
console.log(`3. Principal payments made with separate funds: ${currencyFormatter.format(paymentsWithSeparateFunds)}`);
console.log(`4. Fair Market Value at Date of Marriage : ${currencyFormatter.format(fairMarketAtMarriage)}`);
console.log(`5. Principal payments with community funds: ${currencyFormatter.format(paymentsWithCommunityFunds)}`);
console.log(`6. Fair Market Value at Date of Division: ${currencyFormatter.format(fairMarketAtDivision)}`);
console.log(`---------------------------------------------------------------`);
console.log(`7. Appreciation before marriage: ${currencyFormatter.format(line7Result)}`);
console.log(`8. Appreciation during marriage: ${currencyFormatter.format(line8Result)}`);
console.log(`9. Proportion of community payments: ${percentageFormatter.format(line9Result)}`);
console.log(`10. Community share of appreciation: ${currencyFormatter.format(line10Result)}`);
console.log(`11. Separate property share of appreciation: ${currencyFormatter.format(line11Result)}`);
console.log(`---------------------------------------------------------------`);
console.log(`12. Separate Property Interest (SP Interest): ${currencyFormatter.format(spInterest)}`);
console.log(`13. Community Property Interest (CP Interest): ${currencyFormatter.format(cpInterest)}
`);
}
// Sharon Street Condo
calculateMooreMarsden(
435000, // Purchase price
132179.18, // Down payment
20645.55, // Principal payments made with separate funds
665000, // Fair Market Value at Date of Marriage
10274.73, // Principal payments with community funds
750225.81 // Fair Market Value at Date of Division
);
// // Gilbert Street House
// calculateMooreMarsden(
// 770000, // Purchase price
// 560000, // Down payment
// 441000, // Principal payments made with separate funds
// 770000, // Fair Market Value at Date of Marriage
// 210000, // Principal payments with community funds
// 1050000 // Fair Market Value at Date of Division
// );