diff --git a/iol_ion/src/iol_ion/query.clj b/iol_ion/src/iol_ion/query.clj index 6e19e127..586a76a1 100644 --- a/iol_ion/src/iol_ion/query.clj +++ b/iol_ion/src/iol_ion/query.clj @@ -201,15 +201,40 @@ (defn account-snapshot [db client-id ^java.util.Date end] (for [running-balance-set (account-sets db client-id) - :let [{id :e [client-id account-id location date _ _ current-balance] :v} + :let [z (->> running-balance-set (take-while (fn until-date [^Line l] (let [^java.util.Date d (.-date l)] (<= (.compareTo ^java.util.Date d end) 0)))) - last)] - :when id] - [client-id account-id location date current-balance])) + last) ] + :when (and z (.-id z))] + [(.-client-id z) (.-account-id z) (.-location z) (.-date z) (.-running-balance z)])) +#_(doseq [[ n] (dc/q '[:find ?cd :where [?c :client/code ?cd] [?c :client/groups "NTG"]] (dc/db auto-ap.datomic/conn))] + (println n) + (dc/q '[:find ?code ?name ?afc ?an ?l ?d2 ?balance + :in $ ?end ?group + :where + [(clj-time.coerce/to-date-time ?end) ?end2] + [(iol-ion.query/localize ?end2) ?end3] + [(clj-time.coerce/to-date ?end3) ?end4] + (or + [?c :client/groups ?group] + [?c :client/code ?group]) + [?c :client/name ?name] + [?c :client/code ?code] + [?c :client/bank-accounts ?b] + [(iol-ion.query/account-snapshot $ ?c ?end4) [?x ...]] + [(untuple ?x) [_ ?a ?l ?date ?balance]] + [(not= nil ?a)] + [(iol-ion.query/excel-date ?date) ?d2] + (or-join [?a ?afc ?an] + (and [?a :account/name ?an] + [?a :account/numeric-code ?afc]) + (and [?a :bank-account/name ?an] + [?a :bank-account/numeric-code ?afc]))] + (dc/db auto-ap.datomic/conn) + #inst "2024-10-10" n)) (defn detailed-account-snapshot [db client-id ^java.util.Date end] (for [running-balance-set (account-sets db client-id) diff --git a/src/clj/auto_ap/parse.clj b/src/clj/auto_ap/parse.clj index f2435f5e..3e7d0f78 100644 --- a/src/clj/auto_ap/parse.clj +++ b/src/clj/auto_ap/parse.clj @@ -64,12 +64,13 @@ (defmulti parse-file (fn [_ filename] (.toLowerCase (last (str/split filename #"\." ))))) (defn invoke-glimpse2 [f] - (-> (lambda/invoke {:function-name "glimpse2" :payload - (json/write-str - (alog/peek ::x {"url" (str "https://" "data.prod.app.integreatconsult.com" "/" f ) }))}) - :payload - slurp - json/read-str)) + (let [result (slurp (:payload (lambda/invoke {:function-name "glimpse2" :payload + (json/write-str + (alog/peek ::x {"url" (str "https://" "data.prod.app.integreatconsult.com" "/" f ) }))})))] + + (alog/info ::glimpse2-payload :payload result) + (-> result + json/read-str))) (defn glimpse2 [file] (try diff --git a/src/clj/auto_ap/parse/templates.clj b/src/clj/auto_ap/parse/templates.clj index d8f4ee10..75b22f7a 100644 --- a/src/clj/auto_ap/parse/templates.clj +++ b/src/clj/auto_ap/parse/templates.clj @@ -170,10 +170,10 @@ ;; GOLDEN BRANDS {:vendor "Bigoli Fresh Pasta" :keywords [#"bigolifreshpasta.com"] - :extract {:date #"INVOICE #.*?\n.*?([0-9]+/[0-9]+/[0-9]+)" ;; HOW TO GO TO SPCIFIC LINE - :customer-identifier #"BILL TO.*\n\s+(.*?)\s{2,}" - :invoice-number #"INVOICE #.*?\n(\d+)" - :total #" TOTAL\s+([0-9,]+\.[0-9]{2})"} + :extract {:date #"Invoice Date.*?([0-9]+/[0-9]+/[0-9]+)" ;; HOW TO GO TO SPCIFIC LINE + :customer-identifier #"BILL TO.*\n\s*(.*?)\s{2,}" + :invoice-number #"Invoice #.*?(\d+)" + :total #" BALANCE DUE\s+(?:\$)?([0-9,]+\.[0-9]{2})"} :parser {:date [:clj-time "MM/dd/yyyy"] :total [:trim-commas nil]}}