Skip to content

Instantly share code, notes, and snippets.

@ericbmerritt
Created December 10, 2010 21:21
Show Gist options
  • Save ericbmerritt/736845 to your computer and use it in GitHub Desktop.
Save ericbmerritt/736845 to your computer and use it in GitHub Desktop.
{ok, RawCDs} = core_cds:find_all(),
FilteredCDs = lists:filter(fun(CD) ->
Now = date(),
case ecdm_cd:maturity_date(CD) of
undefined ->
true;
Value when Value < Now ->
true;
_ ->
false
end
end,
RawCDs),
CDs = lists:map(fun(CD) ->
IssuerKey = ecdm_cd:issuer(CD),
IssuerKey = ecdm_cd:buyer(CD),
{ok, Issuer} = ecdm_accounts:find(IssuerKey),
AccountNum = ecdm_account:account_num(Issuer),
IssuerName = ecdm_account:account_desc(Issuer),
IssuerFDIC = ecdm_issuer_account:fdic(Issuer),
Funded = case ecdm_cd:state(CD) of
opened_and_funded ->
"true";
_ ->
"false"
end,
{OYear, OMonth, ODay} = ecdm_cd:open_by_date(CD),
OpenDate = io_lib:format("~2..0B/~2..0B/~4..0B",
[OMonth, ODay, OYear]),
{MYear, MMonth, MDay} = ecdm_cd:maturity_date(CD),
MaturityDate = io_lib:format("~2..0B/~2..0B/~4..0B",
[MMonth, MDay, MYear]),
{cd, [{key, ecdm_cd:key(CD)},
{ergonomic_id, ecdm_cd:ergonomic_id(CD)},
{size, ecdm_cd:size(CD)},
{apy, ecdm_cd:apy(CD)},
{bank_cd_number, ecdm_cd:bank_cd_number(CD)},
{open_date, OpenDate},
{funded, Funded},
{maturity_date, MaturityDate},
{issuer_fdic, IssuerFDIC},
{issuer_name, IssuerName},
{account_num, AccountNum}]}
end, FilteredCDs).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment