Skip to content

Instantly share code, notes, and snippets.

View boxxxie's full-sized avatar
👙
disrupting absurdism

Paul Iannazzo boxxxie

👙
disrupting absurdism
View GitHub Profile
(helper-macro menubuttons :Field :Type :Collation :Attributes :Null :Default :Extra :Action)
;produces
(defstruct menubuttons-fields :Field :Type :Collation :Attributes :Null :Default :Extra :Action )
(def *menubuttons-csv-file* "data/menubuttons.csv")
(defn fetch-menubuttons-data [] (load-data-from-csv *menubuttons-csv-file* inventory-fields))
(defn contains-transaction? [transactions transaction] (contains? transactions (:TransactionID transaction)))
(defmulti conj-transaction contains-transaction?)
(defmethod conj-transaction true [transactions transaction]
(let[id (:TransactionID transaction)
transaction-list (get transactions id)]
(assoc transactions id (conj transaction-list transaction))))
(defmethod conj-transaction false [transactions transaction]
(let [id (:TransactionID transaction)]
(defn contains-transaction? [transactions transaction] (contains? transactions (:TransactionID transaction)))
(defmulti conj-transaction contains-transaction?)
(defmethod conj-transaction true [transactions transaction]
(let[id (:TransactionID transaction)
transaction-list (get transactions id)]
(assoc transactions id (conj transaction-list transaction))))
(defmethod conj-transaction false [transactions transaction]
(let [id (:TransactionID transaction)]
(defn- null-vals []
(set {:CashAmount "0",
:DebitAmount "0",
:VisaAmount "0",
:MastercardAmount "0",
:AmexAmount "0",
:DinersAmount "0",
:DiscoverAmount "0",
:MobileVisaAmount "0",
:MobileMastercardAmount "0",
transaction-migration.import-transaction-details> (pprint (transaction-details))
#{{:tax1 0.4995M,
:tax2 0.7992M,
:transaction_id 326,
:price 9.99M,
:modifiers ({:description "WELL DONE "} {:description "KETCHUP "}),
:description "CAJUN CHICKEN COMBO"}
{:tax1 0.0005M,
:tax2 0.0008M,
:transaction_id 103,
transaction-migration.import-transaction-headers> (->> (transaction-details)
;(select #(= (:transaction_id %) 326) ,,,)
pprint)
#{{:tax1 0.4995M,
:tax2 0.7992M,
:transaction_id 326,
:price 9.99M,
:modifiers ({:description "WELL DONE "} {:description "KETCHUP "}),
:description "CAJUN CHICKEN COMBO"}
{:tax1 0.0005M,
transaction-migration.import-transaction-details> (pprint (pretty-orders+mods))
#{{:tax1 0.4995M,
:tax2 0.7992M,
:transaction_id 326,
:price 9.99M,
:modifiers ({:description "WELL DONE "} {:description "KETCHUP "}),
:description "CAJUN CHICKEN COMBO"}
{:tax1 0.0005M,
:tax2 0.0008M,
:transaction_id 103,
transaction-migration.import-transaction-details> (pprint (pretty-orders+mods))
#{{:transaction_id 122,
:price 7.29M,
:modifiers
({:description "NO HERO SAUCE "} {:description "NO MAYO "}),
:description "HOT DOG COMBO"}
{:transaction_id 309,
:price 11.99M,
:modifiers
({:description "EASY PLEASE "}
transaction-migration.import-transaction-headers> (pprint (transactions))
#{{:order
({:quantity 1,
:price 7.29M,
:modifiers
({:description "HOT SAUCE "}
{:description "TO GO "}
{:description "KETCHUP "}
{:description "LETTUCE "}
{:description "NO TOMATO "}),
(defproject transaction-migration "1.0.0-SNAPSHOT"
:description "This project is to migrate the transaction SQL (CSV) tables to couchdb for the new Point of sale (POS) project"
:dependencies [[org.clojure/clojure "1.2.1"]
[org.clojars.jhowarth/clojure-contrib "1.2.0-RC3"]
[clojure-csv "1.3.0"]
[clj-time "0.3.0"]
[com.ashafa/clutch "0.2.5-SNAPSHOT"]
[clj-http "0.1.3"]]
:dev-dependencies [[swank-clojure "1.4.0-SNAPSHOT"]])