diff --git a/resources/sushi-confidential.jpg b/resources/sushi-confidential.jpg new file mode 100644 index 00000000..bfd80851 Binary files /dev/null and b/resources/sushi-confidential.jpg differ diff --git a/src/clj/auto_ap/datomic/ledger.clj b/src/clj/auto_ap/datomic/ledger.clj index 7064ec35..fe483f68 100644 --- a/src/clj/auto_ap/datomic/ledger.clj +++ b/src/clj/auto_ap/datomic/ledger.clj @@ -96,6 +96,13 @@ {:bank-account/type [*]}]}]}] ids) (map #(update % :journal-entry/date c/from-date)) + (filter (fn [je] + (every? + (fn [jel] + (let [include-in-reports (-> jel :journal-entry-line/account :bank-account/include-in-reports)] + (or (nil? include-in-reports) + (true? include-in-reports)))) + (:journal-entry/line-items je)))) (group-by :db/id))] (->> ids (map results) diff --git a/src/clj/auto_ap/datomic/migrate.clj b/src/clj/auto_ap/datomic/migrate.clj index ee85eeab..65697c84 100644 --- a/src/clj/auto_ap/datomic/migrate.clj +++ b/src/clj/auto_ap/datomic/migrate.clj @@ -71,6 +71,21 @@ (seq vs) (conj {:db/id e a vs})))})}]]) +(defn add-include-in-reports [conn] + (let [existing-accounts (->> (d/query {:query {:find ['?e] + :in ['$] + :where ['[?e :bank-account/name]]} + :args [(d/db conn)]}) + + (transduce + (comp + (map first) + (map (fn [bank-account] + {:db/id bank-account :bank-account/include-in-reports true}))) + conj + []))] + [existing-accounts])) + (defn -main [& args] (println "Creating database ..." uri) (doto (d/create-database uri) println) @@ -257,7 +272,13 @@ :db/doc "An identifier for this forcasted transaction, e.g., 'RENT'" :db/valueType :db.type/string :db/cardinality :db.cardinality/one}]]} - :auto-ap/add-manager-schema {:txes [[{:db/ident :user-role/manager}]]}} + :auto-ap/add-manager-schema {:txes [[{:db/ident :user-role/manager}]]} + :auto-ap/add-include-in-reports1 {:txes [[{:db/ident :bank-account/include-in-reports + :db/doc "Whether to include this bank account in balance sheet, etc." + :db/valueType :db.type/boolean + :db/cardinality :db.cardinality/one}]] + :depends-on [:auto-ap/add-manager-schema]} + :auto-ap/migrate-include-in-reports {:txes-fn `add-include-in-reports :depends-on [:auto-ap/add-include-in-reports1] }} ] (println "Conforming database...") (c/ensure-conforms conn norms-map) diff --git a/src/clj/auto_ap/graphql.clj b/src/clj/auto_ap/graphql.clj index a89e85af..ad5b8bff 100644 --- a/src/clj/auto_ap/graphql.clj +++ b/src/clj/auto_ap/graphql.clj @@ -85,6 +85,7 @@ :number {:type 'String} :sort_order {:type 'Int} :visible {:type 'Boolean} + :include_in_reports {:type 'Boolean} :routing {:type 'String} :code {:type 'String} :check_number {:type 'Int} @@ -531,6 +532,7 @@ :number {:type 'String} :check_number {:type 'Int} :visible {:type 'Boolean} + :include_in_reports {:type 'Boolean} :sort_order {:type 'Int} :name {:type 'String} :bank_code {:type 'String} diff --git a/src/clj/auto_ap/graphql/clients.clj b/src/clj/auto_ap/graphql/clients.clj index 7e4366b2..6e53ec0e 100644 --- a/src/clj/auto_ap/graphql/clients.clj +++ b/src/clj/auto_ap/graphql/clients.clj @@ -51,6 +51,7 @@ :bank-account/bank-name (:bank_name %) :bank-account/bank-code (:bank_code %) :bank-account/routing (:routing %) + :bank-account/include-in-reports (:include_in_reports %) :bank-account/name (:name %) :bank-account/visible (:visible %) diff --git a/src/clj/auto_ap/graphql/ledger.clj b/src/clj/auto_ap/graphql/ledger.clj index 0d7c3aed..1949d3f3 100644 --- a/src/clj/auto_ap/graphql/ledger.clj +++ b/src/clj/auto_ap/graphql/ledger.clj @@ -68,9 +68,9 @@ :id (str (:db/id account) "-" location) :numeric-code (or (:account/numeric-code account) (and (#{:bank-account-type/check} (:db/ident (:bank-account/type account))) - 1100) + 11100) (and (#{:bank-account-type/credit} (:db/ident (:bank-account/type account))) - 2800)) + 28000)) :account-type (or (:db/ident (:account/type account)) ({:bank-account-type/check :asset :bank-account-type/credit :liability} diff --git a/src/clj/auto_ap/graphql/transactions.clj b/src/clj/auto_ap/graphql/transactions.clj index 18f8d498..aded1ddd 100644 --- a/src/clj/auto_ap/graphql/transactions.clj +++ b/src/clj/auto_ap/graphql/transactions.clj @@ -131,7 +131,7 @@ (->> (g-tr/run-transaction-rule context {:transaction_rule_id transaction_rule_id :count Integer/MAX_VALUE} nil) - (filter #(not (:transaction/payment %))) + (filter #(not (:payment %))) (map :id )) diff --git a/src/cljs/auto_ap/events.cljs b/src/cljs/auto_ap/events.cljs index 7235050b..b85e0a3b 100644 --- a/src/cljs/auto_ap/events.cljs +++ b/src/cljs/auto_ap/events.cljs @@ -44,7 +44,7 @@ :graphql {:token token :query-obj {:venia/queries [[:client - [:id :name :code :email :matches :locations [:location-matches [:location :match]] [:bank-accounts [:id :code :number :bank-name :bank-code :check-number :name :routing :type :sort-order :visible :yodlee-account-id :locations] ] + [:id :name :code :email :matches :locations [:location-matches [:location :match]] [:bank-accounts [:id :code :number :bank-name :bank-code :check-number :name :routing :type :sort-order :visible :yodlee-account-id :locations :include-in-reports] ] [:address [:street1 :street2 :city :state :zip]]]] [:vendor [:id :name :hidden [:default-account [:name :id :location]] [:primary-contact [:name :phone :email :id]] [:secondary-contact [:id :name :phone :email]] :print-as :invoice-reminder-schedule :code @@ -71,7 +71,7 @@ (fn [{:keys [db]} [_ token user]] {:graphql {:token token :query-obj {:venia/queries [[:client - [:id :name :code :matches :locations [:location-matches [:location :match]] [:address [:street1 :street2 :city :state :zip]] [:bank-accounts [:id :code :number :bank-name :bank-code :check-number :name :routing :type :sort-order :visible :yodlee-account-id :locations] ]]] + [:id :name :code :matches :locations [:location-matches [:location :match]] [:address [:street1 :street2 :city :state :zip]] [:bank-accounts [:id :code :number :bank-name :bank-code :check-number :name :routing :type :sort-order :visible :yodlee-account-id :locations :include-in-reports] ]]] [:vendor [:id :name :hidden [:default-account [:name :id :location]] [:primary-contact [:name :phone :email :id]] [:secondary-contact [:id :name :phone :email]] :print-as :invoice-reminder-schedule :code]] [:accounts [:numeric-code :name :location :type :account_set :applicability :id [:client-overrides [:name [:client [:name :id]]]]]]]} diff --git a/src/cljs/auto_ap/views/components/layouts.cljs b/src/cljs/auto_ap/views/components/layouts.cljs index eff197c2..e4c88b25 100644 --- a/src/cljs/auto_ap/views/components/layouts.cljs +++ b/src/cljs/auto_ap/views/components/layouts.cljs @@ -75,10 +75,9 @@ [:a.navbar-item {:class [(active-when ap = :payments)] :href (bidi/path-for routes/routes :payments)} "Payments" ] - (when (not= "manager" (:user/role @user)) - [:a.navbar-item {:class [(active-when ap = :transactions)] - :href (bidi/path-for routes/routes :transactions)} - "Transactions" ]) + [:a.navbar-item {:class [(active-when ap = :transactions)] + :href (bidi/path-for routes/routes :transactions)} + "Transactions" ] (when (not= "manager" (:user/role @user)) [:a.navbar-item {:class [(active-when ap = :ledger)] diff --git a/src/cljs/auto_ap/views/pages/admin/clients.cljs b/src/cljs/auto_ap/views/pages/admin/clients.cljs index 3d32df45..fae3ac11 100644 --- a/src/cljs/auto_ap/views/pages/admin/clients.cljs +++ b/src/cljs/auto_ap/views/pages/admin/clients.cljs @@ -50,10 +50,11 @@ :city (:city (:address new-client-data)) :state (:state (:address new-client-data)) :zip (:zip (:address new-client-data))} - :bank-accounts (map (fn [{:keys [number name check-number type id code bank-name routing bank-code new? sort-order visible yodlee-account-id locations]}] + :bank-accounts (map (fn [{:keys [number name check-number include-in-reports type id code bank-name routing bank-code new? sort-order visible yodlee-account-id locations]}] {:number number :name name :check-number check-number + :include-in-reports include-in-reports :type type :id id :sort-order sort-order @@ -415,7 +416,16 @@ [:ul (for [location locations] ^{:key location} [:li location ])] - [:i "This account applies to all locations"])]]) + [:i "This account applies to all locations"])] + [:div.field + [:label.checkbox + [bind-field + [:input {:type "checkbox" + :field [:bank-accounts sort-order :include-in-reports] + :event change-event + :subscription new-client}]] + " Include in reports"] + ]]) (when active? [:footer.card-footer diff --git a/src/cljs/auto_ap/views/pages/transactions.cljs b/src/cljs/auto_ap/views/pages/transactions.cljs index e5ba2215..b2395540 100644 --- a/src/cljs/auto_ap/views/pages/transactions.cljs +++ b/src/cljs/auto_ap/views/pages/transactions.cljs @@ -162,15 +162,13 @@ params @(re-frame/subscribe [::params]) ;; Keep to make sure it doens'nt get disposed ap @(re-frame/subscribe [::subs/active-page]) user (re-frame/subscribe [::subs/user])] - (if (not= "manager" (:user/role @user)) - [side-bar-layout - {:side-bar [side-bar/side-bar] - :main [:div ^{:key approval-status} - [content]] - :bottom [:div - [manual/modal {:import-completed [::manual-import-completed ]}]] - :right-side-bar [appearing-side-bar - {:visible? transaction-bar-active?} - [edit/form {:edit-completed [::edit-completed]}]]}] - [:div "Not authorized"])))})) + [side-bar-layout + {:side-bar [side-bar/side-bar] + :main [:div ^{:key approval-status} + [content]] + :bottom [:div + [manual/modal {:import-completed [::manual-import-completed ]}]] + :right-side-bar [appearing-side-bar + {:visible? transaction-bar-active?} + [edit/form {:edit-completed [::edit-completed]}]]}]))}))