fixed dates.
This commit is contained in:
14
package-lock.json
generated
14
package-lock.json
generated
@@ -127,23 +127,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"bulma-calendar": {
|
"bulma-calendar": {
|
||||||
"version": "1.3.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/bulma-calendar/-/bulma-calendar-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/bulma-calendar/-/bulma-calendar-3.0.0.tgz",
|
||||||
"integrity": "sha1-yqz7AWeSxV2t8O3BGq5vtkwlYEE=",
|
"integrity": "sha512-qHnFvuR++824s36c9F2n9U2El/lPGJVhXUzfylH8TQK9+8he/fZThJZH3wE+m8/gaOWWIhrNVzUTm7f1AQz9Vg=="
|
||||||
"requires": {
|
|
||||||
"camelcase": "^4.1.0"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"cached-path-relative": {
|
"cached-path-relative": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.1.tgz",
|
||||||
"integrity": "sha1-0JxLUoAKpMB44t2BqGmqyQ0uVOc="
|
"integrity": "sha1-0JxLUoAKpMB44t2BqGmqyQ0uVOc="
|
||||||
},
|
},
|
||||||
"camelcase": {
|
|
||||||
"version": "4.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz",
|
|
||||||
"integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0="
|
|
||||||
},
|
|
||||||
"chalk": {
|
"chalk": {
|
||||||
"version": "1.1.3",
|
"version": "1.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cljs-oss/module-deps": "^1.1.1",
|
"@cljs-oss/module-deps": "^1.1.1",
|
||||||
"bulma-calendar": "^1.3.0"
|
"bulma-calendar": "^3.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,9 +87,7 @@
|
|||||||
:source-map-timestamp true
|
:source-map-timestamp true
|
||||||
:preloads [devtools.preload]
|
:preloads [devtools.preload]
|
||||||
:external-config {:devtools/config {:features-to-install :all}}
|
:external-config {:devtools/config {:features-to-install :all}}
|
||||||
:foreign-libs [{ :file "node_modules/bulma-calendar/dist/bulma-calendar.js"
|
|
||||||
:provides ["bulma-calendar.core"]
|
|
||||||
:module-type :commonjs}]
|
|
||||||
:install-deps true
|
:install-deps true
|
||||||
:infer-externs true
|
:infer-externs true
|
||||||
}}
|
}}
|
||||||
@@ -99,9 +97,7 @@
|
|||||||
:jar true
|
:jar true
|
||||||
:compiler {:main auto-ap.core
|
:compiler {:main auto-ap.core
|
||||||
:output-to "resources/public/js/compiled/app.js"
|
:output-to "resources/public/js/compiled/app.js"
|
||||||
:foreign-libs [{ :file "node_modules/bulma-calendar/dist/bulma-calendar.js"
|
|
||||||
:provides ["bulma-calendar.core"]
|
|
||||||
:module-type :commonjs}]
|
|
||||||
:optimizations :advanced
|
:optimizations :advanced
|
||||||
:closure-defines {goog.DEBUG false}
|
:closure-defines {goog.DEBUG false}
|
||||||
:pretty-print false}}
|
:pretty-print false}}
|
||||||
|
|||||||
@@ -270,6 +270,7 @@
|
|||||||
background-color:#F5F5F5;
|
background-color:#F5F5F5;
|
||||||
}
|
}
|
||||||
.table { table-layout: fixed }
|
.table { table-layout: fixed }
|
||||||
|
.table td {text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
|
||||||
|
|
||||||
.typeahead {
|
.typeahead {
|
||||||
position:relative;
|
position:relative;
|
||||||
|
|||||||
@@ -59,7 +59,6 @@
|
|||||||
(Integer/parseInt id))))
|
(Integer/parseInt id))))
|
||||||
|
|
||||||
(defn insert [data]
|
(defn insert [data]
|
||||||
|
|
||||||
(let [[{:keys [id]}] (j/insert! (get-conn) :vendors (unparse data))]
|
(let [[{:keys [id]}] (j/insert! (get-conn) :vendors (unparse data))]
|
||||||
(println "inserted vendor: " data ", id " id)
|
(println "inserted vendor: " data ", id " id)
|
||||||
(get-by-id id)))
|
(get-by-id id)))
|
||||||
|
|||||||
@@ -3,24 +3,29 @@
|
|||||||
[auto-ap.db.invoices :as invoices]
|
[auto-ap.db.invoices :as invoices]
|
||||||
[auto-ap.db.vendors :as vendors]
|
[auto-ap.db.vendors :as vendors]
|
||||||
[auto-ap.db.invoices-expense-accounts :as invoices-expense-accounts]
|
[auto-ap.db.invoices-expense-accounts :as invoices-expense-accounts]
|
||||||
[auto-ap.time :refer [parse normal-date]]))
|
[auto-ap.time :refer [parse iso-date]]))
|
||||||
|
|
||||||
(defn -create-vendor-if-necessary [vendor-id vendor-name]
|
(defn -create-or-get-vendor [vendor-id vendor-name]
|
||||||
(if vendor-id
|
(if vendor-id
|
||||||
vendor-id
|
(vendors/get-by-id vendor-id)
|
||||||
(:id (vendors/insert {:name vendor-name :default-expense-account 0}))))
|
(vendors/insert {:name vendor-name :default-expense-account 0})))
|
||||||
|
|
||||||
(defn add-invoice [context {{:keys [total invoice_number company_id vendor_id vendor_name date] :as in} :invoice} value]
|
(defn add-invoice [context {{:keys [total invoice_number company_id vendor_id vendor_name date] :as in} :invoice} value]
|
||||||
(let [vendor_id (-create-vendor-if-necessary vendor_id vendor_name)]
|
(let [vendor (-create-or-get-vendor vendor_id vendor_name)
|
||||||
(-> (invoices/insert-multi! [{:invoice-number invoice_number
|
|
||||||
:company-id company_id
|
[invoice] (invoices/insert-multi! [{:invoice-number invoice_number
|
||||||
:vendor-id vendor_id
|
:company-id company_id
|
||||||
:total total
|
:vendor-id (:id vendor)
|
||||||
:outstanding-balance total
|
:total total
|
||||||
:status "unpaid"
|
:outstanding-balance total
|
||||||
:imported true
|
:status "unpaid"
|
||||||
:date (parse date normal-date)}])
|
:imported true
|
||||||
(first)
|
:date (parse date iso-date)}]
|
||||||
|
)]
|
||||||
|
(invoices-expense-accounts/replace-for-invoice
|
||||||
|
(:id invoice) [{:expense-account-id (:default-expense-account vendor)
|
||||||
|
:amount total}] )
|
||||||
|
(-> invoice
|
||||||
(->graphql))))
|
(->graphql))))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
(time/to-time-zone (time/now) (time/time-zone-for-id "America/Los_Angeles")))
|
(time/to-time-zone (time/now) (time/time-zone-for-id "America/Los_Angeles")))
|
||||||
|
|
||||||
(def normal-date "MM/dd/yyyy")
|
(def normal-date "MM/dd/yyyy")
|
||||||
|
(def iso-date "yyyy-MM-dd")
|
||||||
|
|
||||||
(defn parse [v format]
|
(defn parse [v format]
|
||||||
(try
|
(try
|
||||||
|
|||||||
@@ -38,8 +38,7 @@
|
|||||||
status :status}
|
status :status}
|
||||||
transaction
|
transaction
|
||||||
company-id (account->company-id account-id)
|
company-id (account->company-id account-id)
|
||||||
vendor-id (transaction->vendor-id transaction)]
|
vendor-id (transaction->vendor-id transaction)]]
|
||||||
]
|
|
||||||
|
|
||||||
(try
|
(try
|
||||||
(transactions/upsert!
|
(transactions/upsert!
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
(:require [clojure.spec.alpha :as s]
|
(:require [clojure.spec.alpha :as s]
|
||||||
[clojure.string :as str]))
|
[clojure.string :as str]))
|
||||||
|
|
||||||
(def date-regex #"[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}")
|
(def date-regex #"[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}")
|
||||||
(def money-regex #"[0-9]+(\.[0-9]{1,2})?$")
|
(def money-regex #"[0-9]+(\.[0-9]{1,2})?$")
|
||||||
|
|
||||||
(s/def ::identifier (s/nilable string?))
|
(s/def ::identifier (s/nilable string?))
|
||||||
|
|||||||
@@ -74,6 +74,7 @@
|
|||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::change-form
|
::change-form
|
||||||
(fn [db [_ location field value]]
|
(fn [db [_ location field value]]
|
||||||
|
(println location field value)
|
||||||
(if value
|
(if value
|
||||||
(assoc-in db (into location field) value)
|
(assoc-in db (into location field) value)
|
||||||
(update-in db location dissoc field))))
|
(update-in db location dissoc field))))
|
||||||
|
|||||||
@@ -180,7 +180,7 @@
|
|||||||
[:li.menu-item
|
[:li.menu-item
|
||||||
[:a {:href (bidi/path-for routes/routes :unpaid-invoices), :class (str "item" (active-when= ap :unpaid-invoices))}
|
[:a {:href (bidi/path-for routes/routes :unpaid-invoices), :class (str "item" (active-when= ap :unpaid-invoices))}
|
||||||
[:span {:class "icon"}
|
[:span {:class "icon"}
|
||||||
[:i {:class "fa fa-envelope-o"}]]
|
[:i {:class "fa fa-envelope-open-o"}]]
|
||||||
[:span {:class "name"} "Unpaid Invoices"]]
|
[:span {:class "name"} "Unpaid Invoices"]]
|
||||||
]
|
]
|
||||||
[:li.menu-item
|
[:li.menu-item
|
||||||
|
|||||||
@@ -8,15 +8,14 @@
|
|||||||
[auto-ap.entities.invoice :as invoice]
|
[auto-ap.entities.invoice :as invoice]
|
||||||
[auto-ap.entities.vendors :as vendor]
|
[auto-ap.entities.vendors :as vendor]
|
||||||
[auto-ap.entities.invoices-expense-accounts :as invoices-expense-accounts]
|
[auto-ap.entities.invoices-expense-accounts :as invoices-expense-accounts]
|
||||||
[auto-ap.views.utils :refer [dispatch-event bind-field horizontal-field]]
|
[auto-ap.views.utils :refer [dispatch-event bind-field horizontal-field date->str str->date pretty standard]]
|
||||||
[auto-ap.utils :refer [by replace-if]]
|
[auto-ap.utils :refer [by replace-if]]
|
||||||
[auto-ap.views.pages.check :as check]
|
[auto-ap.views.pages.check :as check]
|
||||||
[auto-ap.views.components.invoice-table :refer [invoice-table] :as invoice-table]
|
[auto-ap.views.components.invoice-table :refer [invoice-table] :as invoice-table]
|
||||||
[auto-ap.views.components.modal :refer [modal action-modal]]
|
[auto-ap.views.components.modal :refer [modal action-modal]]
|
||||||
[auto-ap.views.components.typeahead :refer [typeahead]]
|
[auto-ap.views.components.typeahead :refer [typeahead]]
|
||||||
[auto-ap.subs :as subs]
|
[auto-ap.subs :as subs]
|
||||||
[auto-ap.events :as events]
|
[auto-ap.events :as events]))
|
||||||
[bulma-calendar.core :as bc]))
|
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::invoice-page
|
::invoice-page
|
||||||
@@ -217,6 +216,8 @@
|
|||||||
[:id :total :outstanding-balance :date :invoice-number
|
[:id :total :outstanding-balance :date :invoice-number
|
||||||
[:company [:id :name]]
|
[:company [:id :name]]
|
||||||
[:vendor [:id :name]]
|
[:vendor [:id :name]]
|
||||||
|
[:expense_accounts [:amount :id :expense_account_id
|
||||||
|
[:expense_account [:id :name [:parent [:id :name]]]]]]
|
||||||
]]}]}
|
]]}]}
|
||||||
:on-success [::invoice-created]}})))
|
:on-success [::invoice-created]}})))
|
||||||
|
|
||||||
@@ -395,30 +396,6 @@
|
|||||||
:max outstanding-balance
|
:max outstanding-balance
|
||||||
:step "0.01"}]]]]]])]]])))
|
:step "0.01"}]]]]]])]]])))
|
||||||
|
|
||||||
#_(defn date-picker []
|
|
||||||
(let [cal (r/atom nil)]
|
|
||||||
(r/create-class
|
|
||||||
{:component-did-mount (fn [this]
|
|
||||||
|
|
||||||
(reset! cal (new bc (r/dom-node this) (clj->js {:overlay false :dateFormat "mm/dd/yyyy"} )))
|
|
||||||
nil)
|
|
||||||
|
|
||||||
:component-will-unmount (fn [this]
|
|
||||||
(.hide @cal)
|
|
||||||
nil)
|
|
||||||
:reagent-render (fn [props]
|
|
||||||
[:input ])})))
|
|
||||||
(defn my-date [props]
|
|
||||||
(let [cal (r/atom nil)]
|
|
||||||
(r/create-class
|
|
||||||
{:component-did-mount (fn [this]
|
|
||||||
(reset! cal (new bc (r/dom-node this) (clj->js {:overlay false :dateFormat "yyyy-mm-dd"} )))
|
|
||||||
|
|
||||||
nil)
|
|
||||||
:reagent-render (fn [props]
|
|
||||||
[:input.input (merge props {:on-blur (fn [] (js/setTimeout 100 #(.hide @cal)) )}) ])})))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn new-invoice-modal []
|
(defn new-invoice-modal []
|
||||||
(let [data @(re-frame/subscribe [::new-invoice])
|
(let [data @(re-frame/subscribe [::new-invoice])
|
||||||
@@ -446,11 +423,12 @@
|
|||||||
|
|
||||||
|
|
||||||
[bind-field
|
[bind-field
|
||||||
[my-date {:type "date"
|
[:input.input {:type "date"
|
||||||
:field [:date]
|
:field [:date]
|
||||||
:event change-event
|
:event change-event
|
||||||
:spec ::invoice/date
|
:spec ::invoice/date
|
||||||
:subscription data}]]]
|
:subscription data}]]]
|
||||||
|
|
||||||
[horizontal-field
|
[horizontal-field
|
||||||
[:label.label "Company"]
|
[:label.label "Company"]
|
||||||
[bind-field
|
[bind-field
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
(ns auto-ap.views.utils
|
(ns auto-ap.views.utils
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
|
[cljs-time.coerce :as c]
|
||||||
|
[cljs-time.core :as time]
|
||||||
[auto-ap.events :as events]
|
[auto-ap.events :as events]
|
||||||
[auto-ap.subs :as subs]
|
[auto-ap.subs :as subs]
|
||||||
[cljs-time.format :as format]))
|
[cljs-time.format :as format]))
|
||||||
@@ -27,15 +29,22 @@
|
|||||||
|
|
||||||
(def pretty-long (format/formatter "MM/dd/yyyy HH:mm:ss"))
|
(def pretty-long (format/formatter "MM/dd/yyyy HH:mm:ss"))
|
||||||
(def pretty (format/formatter "MM/dd/yyyy"))
|
(def pretty (format/formatter "MM/dd/yyyy"))
|
||||||
|
(def standard (format/formatter "yyyy-MM-MM"))
|
||||||
|
|
||||||
(defn date->str [d]
|
(defn date->str
|
||||||
(when d
|
([d] (date->str d pretty))
|
||||||
(format/unparse pretty d)))
|
([d format]
|
||||||
|
(when d
|
||||||
|
(format/unparse format d))))
|
||||||
|
|
||||||
(defn date-time->str [d]
|
(defn date-time->str [d]
|
||||||
(when d
|
(when d
|
||||||
(format/unparse pretty-long d)))
|
(format/unparse pretty-long d)))
|
||||||
|
|
||||||
|
(defn str->date [d f]
|
||||||
|
(when d
|
||||||
|
(format/parse f d)))
|
||||||
|
|
||||||
(defmulti do-bind (fn [a {:keys [type] :as x}]
|
(defmulti do-bind (fn [a {:keys [type] :as x}]
|
||||||
type))
|
type))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user