This commit is contained in:
2021-11-05 16:51:42 -07:00
parent f20751a9b4
commit 32eded1f9c

View File

@@ -336,117 +336,119 @@
should-disable-for-client? (and (not (or is-admin? is-power-user?)) should-disable-for-client? (and (not (or is-admin? is-power-user?))
(not= :requires-feedback (:original-status data))) (not= :requires-feedback (:original-status data)))
is-already-matched? (:payment data)] is-already-matched? (:payment data)]
(form-inline {:title "Transaction"} (with-meta
[:<> (form-inline {:title "Transaction"}
[:<>
(when (and @(re-frame/subscribe [::subs/is-admin?]) (when (and @(re-frame/subscribe [::subs/is-admin?])
(get-in data [:yodlee-merchant])) (get-in data [:yodlee-merchant]))
[:div.control [:div.control
[:p.help "Merchant"] [:p.help "Merchant"]
[:input.input {:type "text" [:input.input {:type "text"
:disabled true :disabled true
:value (str (get-in data [:yodlee-merchant :name]) :value (str (get-in data [:yodlee-merchant :name])
" - " " - "
(get-in data [:yodlee-merchant :yodlee-id]))}]]) (get-in data [:yodlee-merchant :yodlee-id]))}]])
(when is-admin? (when is-admin?
(field "Matched Rule" (field "Matched Rule"
[:input.input {:type "text" [:input.input {:type "text"
:field [:matched-rule :note] :field [:matched-rule :note]
:disabled "disabled"}])) :disabled "disabled"}]))
(field "Amount" (field "Amount"
[:input.input {:type "text" [:input.input {:type "text"
:field [:amount] :field [:amount]
:disabled "disabled"}]) :disabled "disabled"}])
(field "Description" (field "Description"
[:input.input {:type "text" [:input.input {:type "text"
:field [:description-original] :field [:description-original]
:disabled "disabled"}]) :disabled "disabled"}])
(field "Date" (field "Date"
[:input.input {:type "text" [:input.input {:type "text"
:field [:date] :field [:date]
:disabled "disabled"}]) :disabled "disabled"}])
(when (and (:payment data) (when (and (:payment data)
(or is-admin? is-power-user?)) (or is-admin? is-power-user?))
[:p.notification.is-info.is-light>div.level>div.level-left [:p.notification.is-info.is-light>div.level>div.level-left
[:div.level-item "This transaction is linked to a payment "] [:div.level-item "This transaction is linked to a payment "]
[:div.level-item [:button.button.is-warning {:on-click (dispatch-event [::unlink])} "Unlink"]]]) [:div.level-item [:button.button.is-warning {:on-click (dispatch-event [::unlink])} "Unlink"]]])
[tabs {:default-tab :details} [tabs {:default-tab :details}
(when (when
(and (seq (:potential-transaction-rule-matches data)) (and (seq (:potential-transaction-rule-matches data))
(not (:matched-rule data)) (not (:matched-rule data))
is-admin?) is-admin?)
[tab {:title "Transaction Rule" :key :transaction-rule} [tab {:title "Transaction Rule" :key :transaction-rule}
[potential-transaction-rule-matches-box {:potential-transaction-rule-matches (:potential-transaction-rule-matches data)}]]) [potential-transaction-rule-matches-box {:potential-transaction-rule-matches (:potential-transaction-rule-matches data)}]])
(when (when
(and (seq (:potential-autopay-invoices-matches data)) (and (seq (:potential-autopay-invoices-matches data))
(not is-already-matched?) (not is-already-matched?)
(or is-admin? is-power-user?)) (or is-admin? is-power-user?))
[tab {:title "Autopay Invoices" :key :autopay-invoices} [tab {:title "Autopay Invoices" :key :autopay-invoices}
[potential-autopay-invoices-matches-box {:potential-autopay-invoices-matches (:potential-autopay-invoices-matches data)}]]) [potential-autopay-invoices-matches-box {:potential-autopay-invoices-matches (:potential-autopay-invoices-matches data)}]])
(when (when
(and (seq (:potential-unpaid-invoices-matches data)) (and (seq (:potential-unpaid-invoices-matches data))
(not is-already-matched?) (not is-already-matched?)
(or is-admin? is-power-user?)) (or is-admin? is-power-user?))
[tab {:title "Unpaid Invoices" :key :unpaid-invoices} [tab {:title "Unpaid Invoices" :key :unpaid-invoices}
[potential-unpaid-invoices-matches-box {:potential-unpaid-invoices-matches (:potential-unpaid-invoices-matches data)}]]) [potential-unpaid-invoices-matches-box {:potential-unpaid-invoices-matches (:potential-unpaid-invoices-matches data)}]])
(when (when
(and (seq (:potential-payment-matches data)) (and (seq (:potential-payment-matches data))
(not is-already-matched?) (not is-already-matched?)
(or is-admin? is-power-user?)) (or is-admin? is-power-user?))
[tab {:title "Payment" :key :payment} [tab {:title "Payment" :key :payment}
[potential-payment-matches-box {:potential-payment-matches (:potential-payment-matches data)}]]) [potential-payment-matches-box {:potential-payment-matches (:potential-payment-matches data)}]])
[tab {:title "Details" :key :details} [tab {:title "Details" :key :details}
[:div [:div
(field "Vendor" (field "Vendor"
[typeahead-v3 {:entities-by-id @(re-frame/subscribe [::subs/vendors-by-id]) [typeahead-v3 {:entities-by-id @(re-frame/subscribe [::subs/vendors-by-id])
:entity-index @(re-frame/subscribe [::subs/searchable-vendors-index]) :entity-index @(re-frame/subscribe [::subs/searchable-vendors-index])
:entity->text :name :entity->text :name
:type "typeahead-v3" :type "typeahead-v3"
:auto-focus true :auto-focus true
:field [:vendor] :field [:vendor]
:disabled (or (boolean (:payment data)) :disabled (or (boolean (:payment data))
should-disable-for-client?)}]) should-disable-for-client?)}])
(with-meta (with-meta
(field nil (field nil
[expense-accounts-field [expense-accounts-field
{:type "expense-accounts" {:type "expense-accounts"
:field [:accounts] :field [:accounts]
:max (Math/abs (js/parseFloat (:amount data))) :max (Math/abs (js/parseFloat (:amount data)))
:descriptor "credit account" :descriptor "credit account"
:disabled (or (boolean (:payment data)) :disabled (or (boolean (:payment data))
should-disable-for-client?) should-disable-for-client?)
:locations locations}]) :locations locations}])
{:key (str (:id (:vendor data)))}) {:key (str (:id (:vendor data)))})
(field "Approval Status" (field "Approval Status"
[button-radio [button-radio
{:type "button-radio" {:type "button-radio"
:field [:approval-status] :field [:approval-status]
:options [[:unapproved "Unapproved"] :options [[:unapproved "Unapproved"]
[:requires-feedback "Client Review"] [:requires-feedback "Client Review"]
[:approved "Approved"] [:approved "Approved"]
[:excluded "Excluded from Ledger"]] [:excluded "Excluded from Ledger"]]
:disabled should-disable-for-client?}]) :disabled should-disable-for-client?}])
(field "Forecasted-transaction" (field "Forecasted-transaction"
[typeahead-v3 {:entities @(re-frame/subscribe [::subs/forecasted-transactions-for-client (:id (:client data))]) [typeahead-v3 {:entities @(re-frame/subscribe [::subs/forecasted-transactions-for-client (:id (:client data))])
:entity->text :identifier :entity->text :identifier
:type "typeahead-v3" :type "typeahead-v3"
:field [:forecast-match]}]) :field [:forecast-match]}])
(error-notification) (error-notification)
(when-not should-disable-for-client? (when-not should-disable-for-client?
(submit-button "Save"))]]]]))]) (submit-button "Save"))]]]])
{:key (:id data)}))])