Skip to content

Instantly share code, notes, and snippets.

@ayende
Last active February 18, 2019 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayende/b65c08d28ecbafc28c5b5a9d441d9e85 to your computer and use it in GitHub Desktop.
Save ayende/b65c08d28ecbafc28c5b5a9d441d9e85 to your computer and use it in GitHub Desktop.
map("MortgageMonthlyStatuses", status => {
return {
Mortgage: status.Mortgage,
PrincipleRemaining: status.PrincipleRemaining,
InterestRemaining: status.InterestRemaining,
AmountPaid: status.AmountPaid,
PastDue: (status.PrincipleRemaining + status.InterestRemaining) > 0 ? 1 : 0
};
});
map("AmountPaid", amount => {
return {
Amount: amount.Amount,
Mortgage: amount.Mortgage
};
});
groupBy(x=>x.Mortgage)
.aggregate(g => {
return {
Mortgage: g.key,
PastDue: Math.max(0, sum(g, x=>x.PastDue) - 1),
Amount: sum(g, x=>x.Amount),
PrincipleRemaining: sum(g, x=>x.PrincipleRemaining),
InterestRemaining: sum(g, x=>x.InterestRemaining)
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment