Skip to content

Instantly share code, notes, and snippets.

@rafaelcorreiapoli
Created August 1, 2017 05:50
Show Gist options
  • Save rafaelcorreiapoli/1d9299926a11988bf2eb703ab9f48490 to your computer and use it in GitHub Desktop.
Save rafaelcorreiapoli/1d9299926a11988bf2eb703ab9f48490 to your computer and use it in GitHub Desktop.
(ns vbank.controller
(:require [vbank.db :as db]
[vbank.logic.utils :as utils]
[vbank.logic.operations :as l-o]))
(defn create-operation
[account-number type timestamp amount]
(db/insert-operation account-number type timestamp amount)
{:account-number account-number :type type :timestamp timestamp :amount amount}) ; TODO: Refactor
(defn get-operations [] (db/get-operations))
(defn get-balance-by-account-number
[account-number]
(->> (db/get-operations)
(l-o/filter-operations-by-account-number account-number)
(l-o/calculate-balance)))
(defn get-statement-by-account-number
[account-number initial-date final-date]
(->> (db/get-operations)
(l-o/filter-operations-by-account-number account-number initial-date final-date)
(l-o/build-statement)
(l-o/sort-by-day-timestamp)))
(defn get-debt-by-account-number
[account-number]
(->> (db/get-operations)
(l-o/filter-operations-by-account-number account-number)
(l-o/build-statement)
(l-o/sort-by-day-timestamp)
(l-o/build-debt-periods)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment