merged.
This commit is contained in:
@@ -1056,6 +1056,10 @@
|
|||||||
:args {:invoice_id {:type :id}}
|
:args {:invoice_id {:type :id}}
|
||||||
:resolve :mutation/unvoid-invoice}
|
:resolve :mutation/unvoid-invoice}
|
||||||
|
|
||||||
|
:unautopay_invoice {:type :invoice
|
||||||
|
:args {:invoice_id {:type :id}}
|
||||||
|
:resolve :mutation/unautopay-invoice}
|
||||||
|
|
||||||
:void_payment {:type :payment
|
:void_payment {:type :payment
|
||||||
:args {:payment_id {:type :id}}
|
:args {:payment_id {:type :id}}
|
||||||
:resolve :mutation/void-payment}
|
:resolve :mutation/void-payment}
|
||||||
@@ -1343,6 +1347,7 @@
|
|||||||
:mutation/merge-vendors gq-vendors/merge-vendors
|
:mutation/merge-vendors gq-vendors/merge-vendors
|
||||||
:mutation/void-invoice gq-invoices/void-invoice
|
:mutation/void-invoice gq-invoices/void-invoice
|
||||||
:mutation/unvoid-invoice gq-invoices/unvoid-invoice
|
:mutation/unvoid-invoice gq-invoices/unvoid-invoice
|
||||||
|
:mutation/unautopay-invoice gq-invoices/unautopay-invoice
|
||||||
:mutation/void-payment gq-checks/void-check
|
:mutation/void-payment gq-checks/void-check
|
||||||
:mutation/edit-expense-accounts gq-invoices/edit-expense-accounts
|
:mutation/edit-expense-accounts gq-invoices/edit-expense-accounts
|
||||||
:mutation/import-ledger gq-ledger/import-ledger
|
:mutation/import-ledger gq-ledger/import-ledger
|
||||||
|
|||||||
@@ -239,6 +239,18 @@
|
|||||||
(-> (d-invoices/get-by-id id)
|
(-> (d-invoices/get-by-id id)
|
||||||
(->graphql))))
|
(->graphql))))
|
||||||
|
|
||||||
|
(defn unautopay-invoice [context {id :invoice_id} value]
|
||||||
|
(let [invoice (d/entity (d/db conn) id)
|
||||||
|
_ (assert (:invoice/client invoice))
|
||||||
|
_ (assert-can-see-client (:id context) (:db/id (:invoice/client invoice)))]
|
||||||
|
(audit-transact [[:db/add id :invoice/status :invoice-status/unpaid]
|
||||||
|
[:db/add id :invoice/outstanding-balance (:invoice/total invoice)]
|
||||||
|
[:db/retract id :invoice/scheduled-payment (:invoice/scheduled-payment invoice)]]
|
||||||
|
(:id context))
|
||||||
|
|
||||||
|
(-> (d-invoices/get-by-id id)
|
||||||
|
(->graphql))))
|
||||||
|
|
||||||
(defn edit-expense-accounts [context args value]
|
(defn edit-expense-accounts [context args value]
|
||||||
(assert-can-see-client (:id context) (:db/id (:invoice/client (d-invoices/get-by-id (:invoice_id args)))))
|
(assert-can-see-client (:id context) (:db/id (:invoice/client (d-invoices/get-by-id (:invoice_id args)))))
|
||||||
(let [invoice-id (:invoice_id args)
|
(let [invoice-id (:invoice_id args)
|
||||||
|
|||||||
@@ -128,6 +128,19 @@
|
|||||||
result)))
|
result)))
|
||||||
|
|
||||||
|
|
||||||
|
(defn order
|
||||||
|
|
||||||
|
([o]
|
||||||
|
(log/info "Searching for" o)
|
||||||
|
(let [result (->> (client/get (str "https://connect.squareup.com/v2/orders/" o)
|
||||||
|
{:headers {"Square-Version" "2020-08-12"
|
||||||
|
"Authorization" "Bearer EAAAEO2xSqesDutZz71hz3eulKmrlKTiEqG3uZ4j25x5GYlOluQ2cj2JxNUXqXD7"
|
||||||
|
"Content-Type" "application/json"}
|
||||||
|
:as :json})
|
||||||
|
:body)]
|
||||||
|
|
||||||
|
(log/info "found " (count result))
|
||||||
|
result)))
|
||||||
|
|
||||||
(defn amount->money [amt]
|
(defn amount->money [amt]
|
||||||
(* 0.01 (or (:amount amt) 0.0)))
|
(* 0.01 (or (:amount amt) 0.0)))
|
||||||
@@ -150,7 +163,8 @@
|
|||||||
"LQTHXQY69MYB6" ["NGDG" "DB"]
|
"LQTHXQY69MYB6" ["NGDG" "DB"]
|
||||||
"L7S9MXZBJ00HY" ["NGGG" "LM"]
|
"L7S9MXZBJ00HY" ["NGGG" "LM"]
|
||||||
"LRC7WVD77ZM81" ["NGLK" "SM"]
|
"LRC7WVD77ZM81" ["NGLK" "SM"]
|
||||||
"FZ3ZYC77T3W1T" ["NGA1" "KA"]} location))
|
"FZ3ZYC77T3W1T" ["NGA1" "KA"]
|
||||||
|
"LG5X0MHA4NZDM" ["NGSM" "SM"]} location))
|
||||||
|
|
||||||
;; to get totals:
|
;; to get totals:
|
||||||
(comment
|
(comment
|
||||||
@@ -190,8 +204,8 @@
|
|||||||
:returns (+ (- (-> order :return_amounts :total_money amount->money)
|
:returns (+ (- (-> order :return_amounts :total_money amount->money)
|
||||||
(-> order :return_amounts :tax_money amount->money)
|
(-> order :return_amounts :tax_money amount->money)
|
||||||
(-> order :return_amounts :tip_money amount->money)
|
(-> order :return_amounts :tip_money amount->money)
|
||||||
(-> order :return_amounts :service_charge_money amount->money)
|
(-> order :return_amounts :service_charge_money amount->money))
|
||||||
(-> order :return_amounts :discount_money amount->money)))
|
(-> order :return_amounts :discount_money amount->money))
|
||||||
:charges (->> (:tenders order)
|
:charges (->> (:tenders order)
|
||||||
(map (fn [t]
|
(map (fn [t]
|
||||||
(remove-nils
|
(remove-nils
|
||||||
@@ -217,7 +231,9 @@
|
|||||||
(remove-nils
|
(remove-nils
|
||||||
#:order-line-item
|
#:order-line-item
|
||||||
{:item-name (:name li)
|
{:item-name (:name li)
|
||||||
:category (item-id->category-name (:catalog_object_id li))
|
:category (if (= "GIFT_CARD" (:item_type li))
|
||||||
|
"Gift Card"
|
||||||
|
(item-id->category-name (:catalog_object_id li)))
|
||||||
:total (amount->money (:total_money li))
|
:total (amount->money (:total_money li))
|
||||||
:tax (amount->money (:total_tax_money li))
|
:tax (amount->money (:total_tax_money li))
|
||||||
:discount (amount->money (:total_discount_money li))}))))}))))))
|
:discount (amount->money (:total_discount_money li))}))))}))))))
|
||||||
@@ -263,10 +279,12 @@
|
|||||||
(if (> try-count 4) false true))})))]
|
(if (> try-count 4) false true))})))]
|
||||||
n))))))
|
n))))))
|
||||||
|
|
||||||
(defn daily-settlements []
|
(defn daily-settlements
|
||||||
(->> (locations)
|
([] (daily-settlements (->> (locations)
|
||||||
(map :id)
|
(map :id)
|
||||||
(filter location_id->client-location)
|
(filter location_id->client-location))))
|
||||||
|
([location-ids]
|
||||||
|
(->> location-ids
|
||||||
(mapcat (fn [l]
|
(mapcat (fn [l]
|
||||||
(for [settlement (settlements l)
|
(for [settlement (settlements l)
|
||||||
:let [[client loc] (location_id->client-location l)]]
|
:let [[client loc] (location_id->client-location l)]]
|
||||||
@@ -274,13 +292,15 @@
|
|||||||
:total (amount->money (:total_money settlement))
|
:total (amount->money (:total_money settlement))
|
||||||
:client [:client/code client]
|
:client [:client/code client]
|
||||||
:location loc
|
:location loc
|
||||||
:fee (- (reduce + 0 (map (fn [entry]
|
:fee (- (reduce + 0.0 (map (fn [entry]
|
||||||
(if (= (:type entry) "REFUND")
|
(if (= (:type entry) "REFUND")
|
||||||
(- (amount->money (:fee_money entry)))
|
(- (amount->money (:fee_money entry)))
|
||||||
(amount->money (:fee_money entry))))
|
(amount->money (:fee_money entry))))
|
||||||
(:entries settlement))))
|
(:entries settlement))))
|
||||||
:date (-> (:initiated_at settlement)
|
:date (-> (:initiated_at settlement)
|
||||||
(coerce/to-date))})))))
|
(coerce/to-date))})))
|
||||||
|
(filter :expected-deposit/date)))
|
||||||
|
)
|
||||||
|
|
||||||
(defn refunds [l]
|
(defn refunds [l]
|
||||||
(let [refunds (:refunds (:body (client/get (str "https://connect.squareup.com/v2/refunds?location_id=" l)
|
(let [refunds (:refunds (:body (client/get (str "https://connect.squareup.com/v2/refunds?location_id=" l)
|
||||||
@@ -329,24 +349,28 @@
|
|||||||
(catch Exception e
|
(catch Exception e
|
||||||
(log/error e))))))
|
(log/error e))))))
|
||||||
|
|
||||||
(defn upsert-settlements []
|
(defn upsert-settlements
|
||||||
(lc/with-context {:source "Square settlements loading "}
|
([] (upsert-settlements nil))
|
||||||
(try
|
([location-ids]
|
||||||
(let [existing (->> (d/query {:query {:find ['?external-id]
|
(lc/with-context {:source "Square settlements loading "}
|
||||||
:in ['$]
|
(try
|
||||||
:where ['[_ :expected-deposit/external-id ?external-id]]}
|
(let [existing (->> (d/query {:query {:find ['?external-id]
|
||||||
:args [(d/db conn)]})
|
:in ['$]
|
||||||
(map first)
|
:where ['[_ :expected-deposit/external-id ?external-id]]}
|
||||||
set)
|
:args [(d/db conn)]})
|
||||||
_ (log/info (count existing) "settlements already exist")
|
(map first)
|
||||||
to-create (filter #(not (existing (:expected-deposit/external-id %)))
|
set)
|
||||||
(daily-settlements))]
|
_ (log/info (count existing) "settlements already exist")
|
||||||
(doseq [x (partition-all 20 to-create)]
|
to-create (filter #(not (existing (:expected-deposit/external-id %)))
|
||||||
(log/info "Loading expected deposit" (count x))
|
(if location-ids
|
||||||
@(d/transact conn x)))
|
(daily-settlements location-ids)
|
||||||
(catch Exception e
|
(daily-settlements)))]
|
||||||
(log/error e)))
|
(doseq [x (partition-all 20 to-create)]
|
||||||
(log/info "Done loading settlements")))
|
(log/info "Loading expected deposit" (count x))
|
||||||
|
@(d/transact conn x)))
|
||||||
|
(catch Exception e
|
||||||
|
(log/error e)))
|
||||||
|
(log/info "Done loading settlements"))))
|
||||||
|
|
||||||
(defn upsert-refunds []
|
(defn upsert-refunds []
|
||||||
(doseq [{location :id} (locations)]
|
(doseq [{location :id} (locations)]
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
(:require [auto-ap.events :as events]
|
(:require [auto-ap.events :as events]
|
||||||
[auto-ap.routes :as routes]
|
[auto-ap.routes :as routes]
|
||||||
[auto-ap.subs :as subs]
|
[auto-ap.subs :as subs]
|
||||||
|
[auto-ap.status :as status]
|
||||||
[auto-ap.views.components.buttons :as buttons]
|
[auto-ap.views.components.buttons :as buttons]
|
||||||
[auto-ap.views.components.dropdown
|
[auto-ap.views.components.dropdown
|
||||||
:refer
|
:refer
|
||||||
@@ -90,6 +91,21 @@
|
|||||||
invoice-read]}]}
|
invoice-read]}]}
|
||||||
:on-success (fn [result]
|
:on-success (fn [result]
|
||||||
[::invoice-updated (:unvoid-invoice result)])}}))
|
[::invoice-updated (:unvoid-invoice result)])}}))
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::unautopay
|
||||||
|
(fn [{:keys [db]} [_ {id :id}]]
|
||||||
|
{:graphql
|
||||||
|
{:token (-> db :user)
|
||||||
|
:owns-state {:multi ::unautopay
|
||||||
|
:which id}
|
||||||
|
:query-obj {:venia/operation {:operation/type :mutation
|
||||||
|
:operation/name "UnautopayInvoice"}
|
||||||
|
|
||||||
|
:venia/queries [{:query/data [:unautopay-invoice
|
||||||
|
{:invoice-id id}
|
||||||
|
invoice-read]}]}
|
||||||
|
:on-success (fn [result]
|
||||||
|
[::invoice-updated (:unautopay-invoice result)])}}))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::invoice-updated
|
::invoice-updated
|
||||||
@@ -99,6 +115,7 @@
|
|||||||
(defn row [{:keys [invoice check-boxes selected-client overrides checkable? expense-event actions]}]
|
(defn row [{:keys [invoice check-boxes selected-client overrides checkable? expense-event actions]}]
|
||||||
(let [{:keys [client status payments expense-accounts invoice-number date due total outstanding-balance id vendor] :as i} invoice
|
(let [{:keys [client status payments expense-accounts invoice-number date due total outstanding-balance id vendor] :as i} invoice
|
||||||
accounts-by-id @(re-frame/subscribe [::subs/accounts-by-id client])
|
accounts-by-id @(re-frame/subscribe [::subs/accounts-by-id client])
|
||||||
|
unautopay-states @(re-frame/subscribe [::status/multi ::unautopay])
|
||||||
account->name #(:name (accounts-by-id (:id %)))]
|
account->name #(:name (accounts-by-id (:id %)))]
|
||||||
[grid/row {:class (:class i) :id id :checkable? checkable? :entity invoice}
|
[grid/row {:class (:class i) :id id :checkable? checkable? :entity invoice}
|
||||||
(when-not selected-client
|
(when-not selected-client
|
||||||
@@ -121,7 +138,11 @@
|
|||||||
[grid/cell {} (str/join ", " (set (map :location expense-accounts)))]
|
[grid/cell {} (str/join ", " (set (map :location expense-accounts)))]
|
||||||
|
|
||||||
[grid/cell {:class "has-text-right"} (nf total )]
|
[grid/cell {:class "has-text-right"} (nf total )]
|
||||||
[grid/cell {:class "has-text-right"} (nf outstanding-balance )]
|
[grid/cell {:class "has-text-right"}
|
||||||
|
(if (:scheduled-payment i)
|
||||||
|
[:<> [:div.tag.is-info.is-light "Autopay"] " "]
|
||||||
|
)
|
||||||
|
(nf outstanding-balance )]
|
||||||
[grid/button-cell {}
|
[grid/button-cell {}
|
||||||
[:div.buttons
|
[:div.buttons
|
||||||
(when (seq expense-accounts)
|
(when (seq expense-accounts)
|
||||||
@@ -185,7 +206,13 @@
|
|||||||
(when (and (get actions :void)
|
(when (and (get actions :void)
|
||||||
(= ":voided" (:status i)))
|
(= ":voided" (:status i)))
|
||||||
[buttons/fa-icon {:icon "fa-undo"
|
[buttons/fa-icon {:icon "fa-undo"
|
||||||
:event [::unvoid-invoice i]}])]]]))
|
:event [::unvoid-invoice i]}])
|
||||||
|
(when (and (get actions :void)
|
||||||
|
(= ":paid" (:status i))
|
||||||
|
(:scheduled-payment i))
|
||||||
|
[buttons/fa-icon {:icon "fa-undo"
|
||||||
|
:class (status/class-for (get unautopay-states (:id i)))
|
||||||
|
:event [::unautopay i]}])]]]))
|
||||||
|
|
||||||
(defn invoice-table [{:keys [id check-boxes overrides actions data-page checkable-fn]}]
|
(defn invoice-table [{:keys [id check-boxes overrides actions data-page checkable-fn]}]
|
||||||
(let [selected-client @(re-frame/subscribe [::subs/client])
|
(let [selected-client @(re-frame/subscribe [::subs/client])
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
value
|
value
|
||||||
(expense-accounts-field/can-replace-with-default? (:accounts data)))
|
(expense-accounts-field/can-replace-with-default? (:accounts data)))
|
||||||
[[:accounts] (expense-accounts-field/default-account (:accounts data)
|
[[:accounts] (expense-accounts-field/default-account (:accounts data)
|
||||||
@(re-frame/subscribe [::subs/vendor-default-account value (:client data)])
|
@(re-frame/subscribe [::subs/vendor-default-account (:id value) (:client data)])
|
||||||
(:amount data)
|
(:amount data)
|
||||||
locations)]
|
locations)]
|
||||||
[])))))
|
[])))))
|
||||||
@@ -414,15 +414,20 @@
|
|||||||
:field [:vendor]
|
:field [:vendor]
|
||||||
:disabled (or (boolean (:payment data))
|
:disabled (or (boolean (:payment data))
|
||||||
should-disable-for-client?)}])
|
should-disable-for-client?)}])
|
||||||
(field nil
|
(with-meta
|
||||||
[expense-accounts-field
|
(field nil
|
||||||
{:type "expense-accounts"
|
[expense-accounts-field
|
||||||
:field [:accounts]
|
{:type "expense-accounts"
|
||||||
:max (Math/abs (js/parseFloat (:amount data)))
|
:field [:accounts]
|
||||||
:descriptor "credit account"
|
:max (Math/abs (js/parseFloat (:amount data)))
|
||||||
:disabled (or (boolean (:payment data))
|
:descriptor "credit account"
|
||||||
should-disable-for-client?)
|
:disabled (or (boolean (:payment data))
|
||||||
:locations locations}])
|
should-disable-for-client?)
|
||||||
|
:locations locations}])
|
||||||
|
{:key (str (:id (:vendor data)))})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -92,5 +92,5 @@
|
|||||||
"FARGATE"
|
"FARGATE"
|
||||||
],
|
],
|
||||||
"cpu": "2048",
|
"cpu": "2048",
|
||||||
"memory": "4096"
|
"memory": "8192"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ resource "aws_ecs_task_definition" "integreat_app" {
|
|||||||
|
|
||||||
family = "integreat_app_${var.stage}"
|
family = "integreat_app_${var.stage}"
|
||||||
container_definitions = file("${var.stage}-taskdef.json")
|
container_definitions = file("${var.stage}-taskdef.json")
|
||||||
memory = 4096
|
memory = 8192
|
||||||
cpu = 2048
|
cpu = 2048
|
||||||
network_mode = "awsvpc"
|
network_mode = "awsvpc"
|
||||||
requires_compatibilities = ["FARGATE"]
|
requires_compatibilities = ["FARGATE"]
|
||||||
|
|||||||
Reference in New Issue
Block a user