readiness for ntg automatic invoice importation
This commit is contained in:
@@ -43,14 +43,16 @@
|
||||
:key k}))
|
||||
|
||||
(defn is-csv-file? [x]
|
||||
(= "csv" (last (str/split x #"[\\.]"))))
|
||||
(= "dat" (last (str/split x #"[\\.]"))))
|
||||
|
||||
(defn decipher-source [k]
|
||||
(cond
|
||||
(str/includes? k "Cintas")
|
||||
(and (str/includes? k "Cintas")
|
||||
(str/includes? k "zcic"))
|
||||
:cintas
|
||||
|
||||
(and (str/includes? k "GeneralProduce")
|
||||
(str/includes? k "FRANCHISEE")
|
||||
(is-csv-file? k))
|
||||
:general-produce
|
||||
|
||||
@@ -70,6 +72,9 @@
|
||||
(map (fn [[vendor location-hint invoice-number ship-date invoice-total ]]
|
||||
(let [matching-client (and location-hint
|
||||
(parse/exact-match clients location-hint))]
|
||||
(when-not matching-client
|
||||
(log/warn ::missing-client
|
||||
:client-hint location-hint))
|
||||
{:invoice/vendor vendor
|
||||
:invoice/location (parse/best-location-match matching-client location-hint location-hint )
|
||||
:invoice/date (coerce/to-date (atime/parse ship-date atime/normal-date))
|
||||
@@ -115,9 +120,7 @@
|
||||
first
|
||||
:content
|
||||
first)
|
||||
matching-client (and location-hint (parse/exact-match clients location-hint))
|
||||
|
||||
]
|
||||
matching-client (and location-hint (parse/exact-match clients location-hint))]
|
||||
(if matching-client
|
||||
(let [invoice-date (->> node-seq
|
||||
(map zip/node)
|
||||
@@ -180,7 +183,7 @@
|
||||
:invoice invoice)
|
||||
[invoice])
|
||||
(do
|
||||
(log/info ::missing-client
|
||||
(log/warn ::missing-client
|
||||
:client-hint location-hint)
|
||||
[]))))
|
||||
|
||||
@@ -202,7 +205,12 @@
|
||||
:destination-key invoice-key })
|
||||
invoice-key))
|
||||
|
||||
(defn import-ntg-invoices []
|
||||
(defn import-ntg-invoices
|
||||
([] (import-ntg-invoices (->> (s3/list-objects-v2 {:bucket-name bucket-name
|
||||
:prefix "ntg-invoices/pending"})
|
||||
:object-summaries
|
||||
(map :key))))
|
||||
([keys ]
|
||||
(let [clients (map first (d/q '[:find (pull ?c [:client/code
|
||||
:db/id
|
||||
:client/feature-flags
|
||||
@@ -211,16 +219,9 @@
|
||||
:client/matches
|
||||
:client/locations])
|
||||
:where [?c :client/code]]
|
||||
(d/db conn)))
|
||||
keys (->> (s3/list-objects-v2 {:bucket-name bucket-name
|
||||
:prefix "ntg-invoices/pending"})
|
||||
:object-summaries
|
||||
(map :key))]
|
||||
|
||||
|
||||
(d/db conn)))]
|
||||
(log/info ::found-invoice-keys
|
||||
:keys keys )
|
||||
|
||||
(let [transaction (->> keys
|
||||
(mapcat (fn [k]
|
||||
(try
|
||||
@@ -252,8 +253,8 @@
|
||||
:count (count transaction)
|
||||
:sample (take 3 transaction)))
|
||||
(doseq [k keys]
|
||||
(mark-key k))))
|
||||
(mark-key k)))))
|
||||
|
||||
|
||||
(defn -main [& _]
|
||||
(execute "ntg-invoices" import-ntg-invoices))
|
||||
(execute "ntg" import-ntg-invoices))
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
[auto-ap.jobs.ezcater-upsert :as job-ezcater-upsert]
|
||||
[auto-ap.jobs.import-uploaded-invoices :as job-import-uploaded-invoices]
|
||||
[auto-ap.jobs.intuit :as job-intuit]
|
||||
[auto-ap.jobs.ntg :as job-ntg]
|
||||
[auto-ap.backup :as backup]
|
||||
[auto-ap.jobs.ledger-reconcile :as job-reconcile-ledger]
|
||||
[auto-ap.jobs.load-historical-sales :as job-load-historical-sales]
|
||||
@@ -141,6 +142,9 @@
|
||||
(= job "export-backup")
|
||||
(backup/-main)
|
||||
|
||||
(= job "ntg")
|
||||
(job-ntg/-main)
|
||||
|
||||
:else
|
||||
|
||||
(do
|
||||
|
||||
@@ -481,3 +481,15 @@ module "export_backup_job" {
|
||||
memory = 8192
|
||||
cpu = 4096
|
||||
}
|
||||
|
||||
module "ntg_job" {
|
||||
source = "./background-job/"
|
||||
ecs_cluster = var.ecs_cluster
|
||||
task_role_arn = var.task_role_arn
|
||||
stage = var.stage
|
||||
job_name = "ntg"
|
||||
execution_role_arn = var.execution_role_arn
|
||||
use_schedule = false
|
||||
memory = 4096
|
||||
cpu = 1024
|
||||
}
|
||||
Reference in New Issue
Block a user