due date exists.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
(defn <-datomic [x]
|
||||
(-> x
|
||||
(update :invoice/date c/from-date)
|
||||
(update :invoice/due c/from-date)
|
||||
(update :invoice/status :db/ident)
|
||||
(rename-keys {:invoice-payment/_invoice :invoice/payments})))
|
||||
|
||||
@@ -33,6 +34,7 @@
|
||||
'[?v :vendor/name ?sorter]]
|
||||
"description-original" ['[?e :transaction/description-original ?sorter]]
|
||||
"date" ['[?e :invoice/date ?sorter]]
|
||||
"due" ['[?e :invoice/due ?sorter]]
|
||||
"invoice-number" ['[?e :invoice/invoice-number ?sorter]]
|
||||
"total" ['[?e :invoice/total ?sorter]]
|
||||
"outstanding" ['[?e :invoice/outstanding-balance ?sorter]]}
|
||||
|
||||
@@ -143,6 +143,10 @@
|
||||
:auto-ap/add-terms {:txes [[{:db/ident :vendor/terms
|
||||
:db/doc "How many days till you pay"
|
||||
:db/valueType :db.type/long
|
||||
:db/cardinality :db.cardinality/one}]]}
|
||||
:auto-ap/add-due {:txes [[{:db/ident :invoice/due
|
||||
:db/doc "When you gotta pay"
|
||||
:db/valueType :db.type/instant
|
||||
:db/cardinality :db.cardinality/one}]]}}]
|
||||
(println "Conforming database...")
|
||||
(c/ensure-conforms conn norms-map)
|
||||
|
||||
@@ -262,6 +262,7 @@
|
||||
:status {:type 'String}
|
||||
:expense_accounts {:type '(list :invoices_expense_accounts)}
|
||||
:date {:type 'String}
|
||||
:due {:type 'String}
|
||||
:client_id {:type 'Int}
|
||||
:payments {:type '(list :invoice_payment)}
|
||||
:vendor {:type :vendor}
|
||||
@@ -541,7 +542,7 @@
|
||||
:invoice_number {:type 'String}
|
||||
:expense_accounts {:type '(list :edit_expense_account)}
|
||||
:location {:type 'String}
|
||||
:date {:type 'String}
|
||||
:date {:type :iso_date}
|
||||
:client_id {:type :id}
|
||||
:vendor_id {:type :id}
|
||||
:vendor_name {:type 'String}
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
[datomic.api :as d]
|
||||
[auto-ap.datomic :refer [uri remove-nils]]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clj-time.core :as time]
|
||||
[clojure.set :as set]))
|
||||
|
||||
(defn get-invoice-page [context args value]
|
||||
(println "HI")
|
||||
|
||||
(let [args (assoc args :id (:id context))
|
||||
[invoices invoice-count] (d-invoices/get-graphql (<-graphql (assoc args :id (:id context))))]
|
||||
(println "HELLO" (take 1 invoices ) invoice-count)
|
||||
[{:invoices (map ->graphql invoices)
|
||||
:total invoice-count
|
||||
:count (count invoices)
|
||||
@@ -57,21 +57,25 @@
|
||||
:location location}))
|
||||
|
||||
(defn add-invoice-transaction [{:keys [total invoice_number location client_id vendor_id vendor_name date expense_accounts] :as in}]
|
||||
(println date)
|
||||
(let [vendor (d-vendors/get-by-id vendor_id)
|
||||
account (:vendor/default-account vendor)
|
||||
_ (when-not (:db/id account)
|
||||
(throw (ex-info (str "Vendor '" (:vendor/name vendor) "' does not have a default expense acount.") {:vendor-id vendor_id} )))]
|
||||
{:db/id "invoice"
|
||||
:invoice/invoice-number invoice_number
|
||||
:invoice/client client_id
|
||||
:invoice/vendor vendor_id
|
||||
:invoice/import-status :import-status/imported
|
||||
:invoice/total total
|
||||
:invoice/outstanding-balance total
|
||||
:invoice/status :invoice-status/unpaid
|
||||
:invoice/date (coerce/to-date date)
|
||||
:invoice/expense-accounts (map expense-account->entity
|
||||
expense_accounts)}))
|
||||
(cond->
|
||||
{:db/id "invoice"
|
||||
:invoice/invoice-number invoice_number
|
||||
:invoice/client client_id
|
||||
:invoice/vendor vendor_id
|
||||
:invoice/import-status :import-status/imported
|
||||
:invoice/total total
|
||||
:invoice/outstanding-balance total
|
||||
:invoice/status :invoice-status/unpaid
|
||||
:invoice/date (coerce/to-date date)
|
||||
:invoice/expense-accounts (map expense-account->entity
|
||||
expense_accounts)}
|
||||
(:vendor/terms vendor) (assoc :invoice/due (coerce/to-date
|
||||
(time/plus date (time/days (:vendor/terms vendor))))))))
|
||||
|
||||
|
||||
(defn deleted-expense-accounts [invoice expense-accounts]
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
{:venia/queries [[:invoice_page
|
||||
(assoc params
|
||||
:client-id (:id @(re-frame/subscribe [::subs/client])))
|
||||
[[:invoices [:id :total :outstanding-balance :invoice-number :date :status :client-identifier
|
||||
[[:invoices [:id :total :outstanding-balance :invoice-number :date :due :status :client-identifier
|
||||
[:vendor [:name :id]]
|
||||
[:expense_accounts [:amount :id :location
|
||||
[:account [:id :name :numeric-code :location ]]]]
|
||||
@@ -108,6 +108,12 @@
|
||||
:sort-by sort-by
|
||||
:asc asc}
|
||||
"Date"]
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width "8em" :cursor "pointer"}
|
||||
:sort-key "due"
|
||||
:sort-by sort-by
|
||||
:asc asc}
|
||||
"Due"]
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width "5em" :cursor "pointer"}
|
||||
:sort-key "location"
|
||||
@@ -143,7 +149,7 @@
|
||||
[:td {:col-span 5}
|
||||
[:i.fa.fa-spin.fa-spinner]]]
|
||||
|
||||
(for [{:keys [client payments expense-accounts invoice-number date total outstanding-balance id vendor] :as i} (:invoices @invoice-page)]
|
||||
(for [{:keys [client payments expense-accounts invoice-number date due total outstanding-balance id vendor] :as i} (:invoices @invoice-page)]
|
||||
^{:key id}
|
||||
[:tr {:class (:class i)}
|
||||
(when check-boxes
|
||||
@@ -161,6 +167,7 @@
|
||||
[:td (:name vendor)]
|
||||
[:td invoice-number]
|
||||
[:td (date->str date) ]
|
||||
[:td (date->str due) ]
|
||||
[:td (str/join ", " (set (map :location expense-accounts)))]
|
||||
|
||||
[:td.has-text-right (nf total )]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(ns auto-ap.views.pages.invoices.common)
|
||||
|
||||
(def invoice-read [:id :total :outstanding-balance :date :invoice-number :status
|
||||
(def invoice-read [:id :total :outstanding-balance :date :due :invoice-number :status
|
||||
[:client [:id :name :locations]]
|
||||
[:payments [:amount [:payment [:amount :s3_url :check_number ]]]]
|
||||
[:vendor [:id :name]]
|
||||
|
||||
@@ -80,7 +80,6 @@
|
||||
(re-frame/reg-event-db
|
||||
::invoice-updated
|
||||
(fn [db [_ invoice]]
|
||||
(println "HERE")
|
||||
(update-in db
|
||||
[::invoice-page :invoices]
|
||||
replace-by :id (assoc invoice :class "live-added"))))
|
||||
@@ -699,10 +698,6 @@
|
||||
:on-check-changed (fn [which invoice]
|
||||
(re-frame/dispatch [::toggle-check which invoice]))
|
||||
:expense-event [::expense-accounts-dialog/change-expense-accounts]}]
|
||||
|
||||
|
||||
|
||||
|
||||
]))
|
||||
:component-will-mount #(re-frame/dispatch-sync [::params-change params]) }))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user