This commit is contained in:
Bryce
2024-03-21 22:33:05 -07:00
parent 9cf81f6d15
commit 5596848cfc
2 changed files with 99 additions and 94 deletions

View File

@@ -2,6 +2,7 @@
(:require [auto-ap.datomic (:require [auto-ap.datomic
:refer [conn pull-attr]] :refer [conn pull-attr]]
[auto-ap.datomic.accounts :as d-accounts] [auto-ap.datomic.accounts :as d-accounts]
[auto-ap.logging :as alog]
[auto-ap.routes.invoice :as route] [auto-ap.routes.invoice :as route]
[auto-ap.routes.utils [auto-ap.routes.utils
:refer [wrap-client-redirect-unauthenticated]] :refer [wrap-client-redirect-unauthenticated]]
@@ -13,10 +14,11 @@
[auto-ap.ssr.hx :as hx] [auto-ap.ssr.hx :as hx]
[auto-ap.ssr.svg :as svg] [auto-ap.ssr.svg :as svg]
[auto-ap.ssr.utils [auto-ap.ssr.utils
:refer [apply-middleware-to-all-handlers entity-id html-response :refer [apply-middleware-to-all-handlers clj-date-schema
money wrap-schema-enforce]] entity-id html-response money wrap-schema-enforce]]
[auto-ap.time :as atime] [auto-ap.time :as atime]
[bidi.bidi :as bidi] [bidi.bidi :as bidi]
[clj-time.core :as time]
[datomic.api :as dc] [datomic.api :as dc]
[malli.core :as mc] [malli.core :as mc]
[malli.util :as mut])) [malli.util :as mut]))
@@ -24,6 +26,7 @@
(def new-form-schema (def new-form-schema
[:map [:map
[:invoice/client entity-id] [:invoice/client entity-id]
[:invoice/date clj-date-schema]
[:invoice/vendor entity-id] [:invoice/vendor entity-id]
[:invoice/expense-accounts [:invoice/expense-accounts
[:vector {:coerce? true} [:vector {:coerce? true}
@@ -43,9 +46,10 @@
[]) [])
(step-schema [_] (step-schema [_]
(mut/select-keys (mm/form-schema linear-wizard) #{:invoice/client :invoice/vendor})) (mut/select-keys (mm/form-schema linear-wizard) #{:invoice/client :invoice/vendor :invoice/date}))
(render-step [this request] (render-step [this request]
(alog/peek ::check (:multi-form-state request))
(mm/default-render-step (mm/default-render-step
linear-wizard this linear-wizard this
:head [:div.p-2 "New invoice"] :head [:div.p-2 "New invoice"]
@@ -86,7 +90,7 @@
{:label "Date" {:label "Date"
:errors (fc/field-errors)} :errors (fc/field-errors)}
[:div {:class "w-24"} [:div {:class "w-24"}
(com/date-input {:value (-> (fc/field-value) (com/date-input {:value (some-> (fc/field-value)
(atime/unparse-local atime/normal-date)) (atime/unparse-local atime/normal-date))
:name (fc/field-name) :name (fc/field-name)
:error? (fc/field-errors) :error? (fc/field-errors)
@@ -96,7 +100,7 @@
{:label "Due (optional)" {:label "Due (optional)"
:errors (fc/field-errors)} :errors (fc/field-errors)}
[:div {:class "w-24"} [:div {:class "w-24"}
(com/date-input {:value (-> (fc/field-value) (com/date-input {:value (some-> (fc/field-value)
(atime/unparse-local atime/normal-date)) (atime/unparse-local atime/normal-date))
:name (fc/field-name) :name (fc/field-name)
:error? (fc/field-errors) :error? (fc/field-errors)
@@ -106,7 +110,7 @@
{:label "Scheduled payment (optional)" {:label "Scheduled payment (optional)"
:errors (fc/field-errors)} :errors (fc/field-errors)}
[:div {:class "w-24"} [:div {:class "w-24"}
(com/date-input {:value (-> (fc/field-value) (com/date-input {:value (some-> (fc/field-value)
(atime/unparse-local atime/normal-date)) (atime/unparse-local atime/normal-date))
:name (fc/field-name) :name (fc/field-name)
:error? (fc/field-errors) :error? (fc/field-errors)
@@ -294,9 +298,10 @@
(defn initial-new-wizard-state [request] (defn initial-new-wizard-state [request]
(mm/->MultiStepFormState {:TODO nil} (mm/->MultiStepFormState {:TODO nil
:invoice/date (time/plus (time/now) (time/days 12))}
[] []
{})) {:invoice/date (time/plus (time/now) (time/days 12))}))
(defn location-select [{{:keys [name account-id client-id value] :as qp} :query-params}] (defn location-select [{{:keys [name account-id client-id value] :as qp} :query-params}]
(html-response (location-select* {:name name (html-response (location-select* {:name name