Created
August 1, 2017 05:50
-
-
Save rafaelcorreiapoli/1d9299926a11988bf2eb703ab9f48490 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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