diff --git a/src/core.clj b/src/core.clj index 4e88923..18649e9 100644 --- a/src/core.clj +++ b/src/core.clj @@ -74,9 +74,8 @@ (def imported (concat (import/payroll "2024-01-31" "January 2024" "rt:19462/685751" grouped-data) (import/individual-taxes "2024-01-31" "January 2024" "rt:19462/685751" "rt:19403/685602" grouped-data) - ;; TODO: Needs fixes for the correct :entity and :memo (import/employer-taxes "2024-01-31" "January 2024" "rt:19462/685751" grouped-data) - #_(import/payroll-fees "2024-01-31" "January 2024" "rt:19459/675387" "rt:19459/674887" 206.50M grouped-data) + (import/payroll-fees "2024-01-31" "January 2024" "rt:19459/675387" "rt:19459/674887" 206.50M grouped-data) (import/retirement "2024-01-31" "January 2024" "rt:19403/685929" "rt:19403/685602" grouped-data))) (dd/pretty-print (dd/diff diff --git a/src/import.clj b/src/import.clj index 07a048d..94756ef 100644 --- a/src/import.clj +++ b/src/import.clj @@ -64,16 +64,10 @@ "NY Re-empl Svc" "US:NY:Reempt" cat)) -(defn employee-entity-meta [name] +(defn assoc-project [name m] (if (= name "Sharp-Sage-A") - {:entity name - :project "Outreachy"} - {:entity name})) - -(defn project [name] - (if (= name "Sharp-Sage-A") - "Outreachy" - "Conservancy")) + (assoc m :project "Outreachy") + m)) (defn split-fee "Share a total fee into n groups allocating the remainder as evenly as possible." @@ -101,7 +95,7 @@ [{:account "Expenses:Payroll:Salary" :amount actual-total-net-pay :currency "USD" - :meta (employee-entity-meta name)} + :meta (assoc-project name {:entity name})} {:account "Assets:FR:Check2721" :amount (- actual-total-net-pay) :currency "USD" @@ -109,11 +103,11 @@ {:account "Expenses:Hosting" :amount total-reimbursement :currency "USD" - :meta (merge (employee-entity-meta name) {:payroll-type "US:Reimbursement"})} + :meta (assoc-project name {:entity name :payroll-type "US:Reimbursement"})} {:account "Assets:FR:Check2721" :amount (- total-reimbursement) :currency "USD" - :meta (merge (employee-entity-meta name) {:tax-implication "Reimbursement"})}]))] + :meta (assoc-project name {:entity name :tax-implication "Reimbursement"})}]))] [{:date date :desc (format "Monthly Payroll - %s - Net Pay" period) :meta {:program "Conservancy:Payroll" :project "Conservancy" @@ -170,11 +164,11 @@ :amount (reduce + (map :amount insurance-lines)) :currency "USD"}]] {:date date :desc (format "Monthly Payroll - %s - TAXES - %s" period name) - :meta {:project (project name) - :program "Conservancy:Payroll" - :entity name - :receipt receipt-no - :approval "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"} + :meta (assoc-project name {:project "Conservancy" + :program "Conservancy:Payroll" + :entity name + :receipt receipt-no + :approval "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"}) :postings (concat super-postings liability-postings @@ -188,18 +182,35 @@ [date period receipt-no groups] (let [liability-postings (apply concat (for [[name records] groups] - (let [liability-lines (filter #(= (:type %) "Liability") records)] + (let [liability-lines (filter #(and (= (:type %) "Liability") + (not (str/includes? (:category %) "Unemploy"))) records)] (for [{:keys [category amount]} liability-lines] {:account "Expenses:Payroll:Tax" :amount amount :currency "USD" - :meta (merge - (employee-entity-meta name) - ;; TODO: Check lack of ":Tax:" with Rosanne. - {:payroll-type (str/replace (cat->acct category) "Tax:" "")})})))) + ;; TODO: Check lack of ":Tax:" with Rosanne. + :meta (assoc-project + name + {:entity name + :payroll-type (str/replace (cat->acct category) "Tax:" "")})})))) total-liabilities (->> liability-postings (map :amount) (reduce +)) + unemploy-postings (apply concat + (for [[name records] groups] + (let [unemploy-lines (filter #(and (= (:type %) "Liability") + (str/includes? (:category %) "Unemploy")) records)] + (for [{:keys [amount category]} unemploy-lines] + {:account "Expenses:Payroll:Tax" + :amount amount + :currency "USD" + :meta (assoc-project + name + {:entity (first (str/split category #" ")) + ;; TODO: Karen doesn't have a memo in January 2024 + :memo name + :payroll-type (str "US:" (cat->acct category))})})))) + total-unemploy (->> unemploy-postings (map :amount) (reduce +)) asset-postings [{:account "Assets:FR:Check2721" - :amount (- total-liabilities) + :amount (- (+ total-liabilities total-unemploy)) :currency "USD" :meta {:entity "Paychex" :tax-implication "Tax-Payment"}}]] @@ -208,7 +219,7 @@ :project "Conservancy" :receipt receipt-no :approval "Financial/Employment-Records/memo-re-board-approval-of-payroll.txt"} - :postings (concat liability-postings asset-postings)}])) + :postings (concat liability-postings unemploy-postings asset-postings)}])) (defn payroll-fees "Return a payroll fees transaction." @@ -220,7 +231,7 @@ {:account "Expenses:Payroll:Fees" :amount fee :currency "USD" - :meta (employee-entity-meta name)}) + :meta (assoc-project name {:entity name})}) asset-postings [{:account "Assets:FR:Check2721" :amount (- total-fees) :currency "USD"}]]