Adds ability to link across entities more.
This commit is contained in:
@@ -231,6 +231,7 @@
|
|||||||
{:fields {:id {:type :id}
|
{:fields {:id {:type :id}
|
||||||
:source {:type 'String}
|
:source {:type 'String}
|
||||||
:external_id {:type 'String}
|
:external_id {:type 'String}
|
||||||
|
:original_entity {:type :id}
|
||||||
:amount {:type 'String}
|
:amount {:type 'String}
|
||||||
:note {:type 'String}
|
:note {:type 'String}
|
||||||
:cleared_against {:type 'String}
|
:cleared_against {:type 'String}
|
||||||
|
|||||||
@@ -22,21 +22,21 @@
|
|||||||
|
|
||||||
(defn get-ledger-page [context args value]
|
(defn get-ledger-page [context args value]
|
||||||
(let [args (assoc args :id (:id context))
|
(let [args (assoc args :id (:id context))
|
||||||
[journal-entries journal-entries-count] (l/get-graphql (assoc (<-graphql (:filters args)
|
[journal-entries journal-entries-count] (l/get-graphql (assoc (<-graphql (:filters args))
|
||||||
)
|
|
||||||
:id (:id context)))
|
:id (:id context)))
|
||||||
|
|
||||||
journal-entries (mapv
|
journal-entries (mapv
|
||||||
(fn [je]
|
(fn [je]
|
||||||
(update je :journal-entry/line-items
|
(-> je
|
||||||
(fn [jels]
|
(update :journal-entry/original-entity :db/id)
|
||||||
(mapv
|
(update :journal-entry/line-items
|
||||||
(fn [jel]
|
(fn [jels]
|
||||||
(assoc jel :running-balance (get-in @running-balance-cache [(:db/id (:journal-entry/client je))
|
(mapv
|
||||||
(:db/id jel)])))
|
(fn [jel]
|
||||||
|
(assoc jel :running-balance (get-in @running-balance-cache [(:db/id (:journal-entry/client je))
|
||||||
|
(:db/id jel)])))
|
||||||
|
|
||||||
jels)
|
jels)))))
|
||||||
))
|
|
||||||
)
|
|
||||||
journal-entries)]
|
journal-entries)]
|
||||||
(result->page journal-entries journal-entries-count :journal_entries (:filters args))))
|
(result->page journal-entries journal-entries-count :journal_entries (:filters args))))
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
{:filters (data-params->query-params params)}
|
{:filters (data-params->query-params params)}
|
||||||
[[:journal-entries [:id
|
[[:journal-entries [:id
|
||||||
:source
|
:source
|
||||||
|
:original-entity
|
||||||
:amount
|
:amount
|
||||||
:note
|
:note
|
||||||
:cleared-against
|
:cleared-against
|
||||||
|
|||||||
@@ -247,6 +247,7 @@
|
|||||||
{:filters (data-params->query-params ledger-params)}
|
{:filters (data-params->query-params ledger-params)}
|
||||||
[[:journal-entries [:id
|
[[:journal-entries [:id
|
||||||
:source
|
:source
|
||||||
|
:original-entity
|
||||||
:amount
|
:amount
|
||||||
:alternate-description
|
:alternate-description
|
||||||
[:vendor
|
[:vendor
|
||||||
|
|||||||
@@ -1,15 +1,21 @@
|
|||||||
(ns auto-ap.views.pages.ledger.table
|
(ns auto-ap.views.pages.ledger.table
|
||||||
(:require [auto-ap.subs :as subs]
|
(:require [auto-ap.events :as events]
|
||||||
[auto-ap.views.components.paginator :refer [paginator]]
|
[auto-ap.routes :as routes]
|
||||||
[auto-ap.views.components.sorter :refer [sorted-column]]
|
[auto-ap.subs :as subs]
|
||||||
[auto-ap.views.components.sort-by-list :refer [sort-by-list]]
|
[auto-ap.views.components.buttons :as buttons]
|
||||||
[auto-ap.views.utils :refer [date->str dispatch-event nf]]
|
[auto-ap.views.components.dropdown
|
||||||
[goog.string :as gstring]
|
:refer
|
||||||
[re-frame.core :as re-frame]
|
[drop-down drop-down-contents]]
|
||||||
[auto-ap.views.components.grid :as grid]
|
[auto-ap.views.components.grid :as grid]
|
||||||
[auto-ap.views.pages.data-page :as data-page]))
|
[auto-ap.views.pages.data-page :as data-page]
|
||||||
|
[auto-ap.views.utils
|
||||||
|
:refer
|
||||||
|
[date->str dispatch-event-with-propagation nf action-cell-width]]
|
||||||
|
[bidi.bidi :as bidi]
|
||||||
|
[cemerick.url :as url]
|
||||||
|
[re-frame.core :as re-frame]))
|
||||||
|
|
||||||
(defn ledger-row [{{:keys [client vendor alternate-description status date amount id line-items] :as i} :row
|
(defn ledger-row [{{:keys [client vendor alternate-description status date amount id line-items source original-entity] :as i} :row
|
||||||
:keys [selected-client accounts-by-id bank-accounts-by-id]}]
|
:keys [selected-client accounts-by-id bank-accounts-by-id]}]
|
||||||
[:<>
|
[:<>
|
||||||
[grid/row {:class (:class i) :id id}
|
[grid/row {:class (:class i) :id id}
|
||||||
@@ -22,7 +28,42 @@
|
|||||||
[grid/cell {} (date->str date) ]
|
[grid/cell {} (date->str date) ]
|
||||||
[grid/cell {} ]
|
[grid/cell {} ]
|
||||||
[grid/cell {:class "has-text-right"} (nf amount )]
|
[grid/cell {:class "has-text-right"} (nf amount )]
|
||||||
[grid/cell {:class "has-text-right"} (nf amount )]]
|
[grid/cell {:class "has-text-right"} (nf amount )]
|
||||||
|
[grid/button-cell {}
|
||||||
|
(when (#{"invoice" "transaction"} source)
|
||||||
|
[drop-down {:id [::links id]
|
||||||
|
:is-right? true
|
||||||
|
:header [buttons/fa-icon {:class "badge"
|
||||||
|
:on-click (dispatch-event-with-propagation [::events/toggle-menu [::links id]])
|
||||||
|
:data-badge (str 1)
|
||||||
|
:icon "fa-paperclip"}]}
|
||||||
|
[drop-down-contents
|
||||||
|
[:div.dropdown-item
|
||||||
|
[:table.table.grid.compact
|
||||||
|
[:tbody
|
||||||
|
(cond
|
||||||
|
(= "invoice" source)
|
||||||
|
[:tr
|
||||||
|
[:td
|
||||||
|
"Invoice"]
|
||||||
|
[:td
|
||||||
|
[buttons/fa-icon {:icon "fa-external-link"
|
||||||
|
:href (str (bidi/path-for routes/routes :invoices )
|
||||||
|
"?"
|
||||||
|
(url/map->query {:exact-match-id original-entity}))}]]]
|
||||||
|
(= "transaction" source)
|
||||||
|
[:tr
|
||||||
|
[:td
|
||||||
|
"Transaction"]
|
||||||
|
[:td
|
||||||
|
[buttons/fa-icon {:icon "fa-external-link"
|
||||||
|
:href (str (bidi/path-for routes/routes :transactions )
|
||||||
|
"?"
|
||||||
|
(url/map->query {:exact-match-id original-entity}))}]]]
|
||||||
|
|
||||||
|
:else
|
||||||
|
nil
|
||||||
|
)]]]]])]]
|
||||||
[:<>
|
[:<>
|
||||||
(for [{:keys [debit credit location account id running-balance]} line-items
|
(for [{:keys [debit credit location account id running-balance]} line-items
|
||||||
:let [account (or (accounts-by-id (:id account))
|
:let [account (or (accounts-by-id (:id account))
|
||||||
@@ -39,6 +80,9 @@
|
|||||||
[:i "unknown"])]
|
[:i "unknown"])]
|
||||||
[grid/cell {:class "has-text-right"} (when debit (nf debit ))]
|
[grid/cell {:class "has-text-right"} (when debit (nf debit ))]
|
||||||
[grid/cell {:class "has-text-right"} (when credit (nf credit ))]
|
[grid/cell {:class "has-text-right"} (when credit (nf credit ))]
|
||||||
|
[grid/button-cell {}
|
||||||
|
]
|
||||||
|
|
||||||
#_[grid/cell {:class "has-text-right"} (when running-balance (nf running-balance ))]])]])
|
#_[grid/cell {:class "has-text-right"} (when running-balance (nf running-balance ))]])]])
|
||||||
|
|
||||||
(defn table [{:keys [id data-page status vendors on-check-changed expense-event]}]
|
(defn table [{:keys [id data-page status vendors on-check-changed expense-event]}]
|
||||||
@@ -59,6 +103,7 @@
|
|||||||
[grid/header-cell {} "Account"]
|
[grid/header-cell {} "Account"]
|
||||||
[grid/sortable-header-cell {:sort-key "amount" :sort-name "Amount" :class "has-text-right" :style {:width "7em"}} "Debit"]
|
[grid/sortable-header-cell {:sort-key "amount" :sort-name "Amount" :class "has-text-right" :style {:width "7em"}} "Debit"]
|
||||||
[grid/sortable-header-cell {:sort-key "amount" :sort-name "Amount" :class "has-text-right" :style {:width "7em"}} "Credit"]
|
[grid/sortable-header-cell {:sort-key "amount" :sort-name "Amount" :class "has-text-right" :style {:width "7em"}} "Credit"]
|
||||||
|
[grid/header-cell {:style {:width (action-cell-width 1)}}]
|
||||||
#_[grid/header-cell {:class "has-text-right" :style {:width "10em"}} "Running Balance"]]]
|
#_[grid/header-cell {:class "has-text-right" :style {:width "10em"}} "Running Balance"]]]
|
||||||
[grid/body
|
[grid/body
|
||||||
(for [{:keys [client vendor status date amount id line-items] :as i} (:data data)]
|
(for [{:keys [client vendor status date amount id line-items] :as i} (:data data)]
|
||||||
|
|||||||
Reference in New Issue
Block a user