you can add vendors while creating.
This commit is contained in:
24
migrator/package-lock.json
generated
24
migrator/package-lock.json
generated
@@ -19,8 +19,8 @@
|
||||
"resolved": "https://registry.npmjs.org/db-migrator/-/db-migrator-2.2.0.tgz",
|
||||
"integrity": "sha512-7A5sSNJwZv0/2dslOOJyccwS7wN99+Xq+ifNXUHEfxlWuVeQ9wGds3s1HYRcmtZl+oV2wq1ZEOXfyPb/GvQpMA==",
|
||||
"requires": {
|
||||
"colors": "1.1.2",
|
||||
"lodash": "4.17.4"
|
||||
"colors": "1.x",
|
||||
"lodash": "^4.17.4"
|
||||
}
|
||||
},
|
||||
"js-string-escape": {
|
||||
@@ -47,9 +47,9 @@
|
||||
"js-string-escape": "1.0.1",
|
||||
"packet-reader": "0.3.1",
|
||||
"pg-connection-string": "0.1.3",
|
||||
"pg-pool": "2.0.3",
|
||||
"pg-types": "1.12.1",
|
||||
"pgpass": "1.0.2",
|
||||
"pg-pool": "~2.0.3",
|
||||
"pg-types": "~1.12.1",
|
||||
"pgpass": "1.x",
|
||||
"semver": "4.3.2"
|
||||
}
|
||||
},
|
||||
@@ -68,10 +68,10 @@
|
||||
"resolved": "https://registry.npmjs.org/pg-types/-/pg-types-1.12.1.tgz",
|
||||
"integrity": "sha1-1kCH45A7WP+q0nnnWVxSIIoUw9I=",
|
||||
"requires": {
|
||||
"postgres-array": "1.0.2",
|
||||
"postgres-bytea": "1.0.0",
|
||||
"postgres-date": "1.0.3",
|
||||
"postgres-interval": "1.1.1"
|
||||
"postgres-array": "~1.0.0",
|
||||
"postgres-bytea": "~1.0.0",
|
||||
"postgres-date": "~1.0.0",
|
||||
"postgres-interval": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"pgpass": {
|
||||
@@ -79,7 +79,7 @@
|
||||
"resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.2.tgz",
|
||||
"integrity": "sha1-Knu0G2BltnkH6R2hsHwYR8h3swY=",
|
||||
"requires": {
|
||||
"split": "1.0.1"
|
||||
"split": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"postgres-array": {
|
||||
@@ -102,7 +102,7 @@
|
||||
"resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.1.1.tgz",
|
||||
"integrity": "sha512-OkuCi9t/3CZmeQreutGgx/OVNv9MKHGIT5jH8KldQ4NLYXkvmT9nDVxEuCENlNwhlGPE374oA/xMqn05G49pHA==",
|
||||
"requires": {
|
||||
"xtend": "4.0.1"
|
||||
"xtend": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"semver": {
|
||||
@@ -115,7 +115,7 @@
|
||||
"resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz",
|
||||
"integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==",
|
||||
"requires": {
|
||||
"through": "2.3.8"
|
||||
"through": "2"
|
||||
}
|
||||
},
|
||||
"through": {
|
||||
|
||||
168
package-lock.json
generated
168
package-lock.json
generated
@@ -7,25 +7,25 @@
|
||||
"resolved": "https://registry.npmjs.org/@cljs-oss/module-deps/-/module-deps-1.1.1.tgz",
|
||||
"integrity": "sha1-YmZ/KCFk8/EParnxJLpBb9EkOfo=",
|
||||
"requires": {
|
||||
"JSONStream": "1.3.3",
|
||||
"babel-traverse": "6.26.0",
|
||||
"babylon": "6.18.0",
|
||||
"browser-resolve": "1.11.2",
|
||||
"cached-path-relative": "1.0.1",
|
||||
"concat-stream": "1.5.2",
|
||||
"defined": "1.0.0",
|
||||
"detective": "4.7.1",
|
||||
"duplexer2": "0.1.4",
|
||||
"JSONStream": "^1.0.3",
|
||||
"babel-traverse": "^6.23.1",
|
||||
"babylon": "^6.15.0",
|
||||
"browser-resolve": "^1.7.0",
|
||||
"cached-path-relative": "^1.0.0",
|
||||
"concat-stream": "~1.5.0",
|
||||
"defined": "^1.0.0",
|
||||
"detective": "^4.0.0",
|
||||
"duplexer2": "^0.1.2",
|
||||
"enhanced-resolve": "3.4.1",
|
||||
"inherits": "2.0.3",
|
||||
"inherits": "^2.0.1",
|
||||
"konan": "1.1.0",
|
||||
"parents": "1.0.1",
|
||||
"readable-stream": "2.3.6",
|
||||
"resolve": "1.7.1",
|
||||
"stream-combiner2": "1.1.1",
|
||||
"subarg": "1.0.0",
|
||||
"through2": "2.0.3",
|
||||
"xtend": "4.0.1"
|
||||
"parents": "^1.0.0",
|
||||
"readable-stream": "^2.0.2",
|
||||
"resolve": "^1.1.3",
|
||||
"stream-combiner2": "^1.1.1",
|
||||
"subarg": "^1.0.0",
|
||||
"through2": "^2.0.0",
|
||||
"xtend": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"JSONStream": {
|
||||
@@ -33,8 +33,8 @@
|
||||
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.3.tgz",
|
||||
"integrity": "sha512-3Sp6WZZ/lXl+nTDoGpGWHEpTnnC6X5fnkolYZR6nwIfzbxxvA8utPWe1gCt7i0m9uVGsSz2IS8K8mJ7HmlduMg==",
|
||||
"requires": {
|
||||
"jsonparse": "1.3.1",
|
||||
"through": "2.3.8"
|
||||
"jsonparse": "^1.2.0",
|
||||
"through": ">=2.2.7 <3"
|
||||
}
|
||||
},
|
||||
"acorn": {
|
||||
@@ -57,9 +57,9 @@
|
||||
"resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
|
||||
"integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=",
|
||||
"requires": {
|
||||
"chalk": "1.1.3",
|
||||
"esutils": "2.0.2",
|
||||
"js-tokens": "3.0.2"
|
||||
"chalk": "^1.1.3",
|
||||
"esutils": "^2.0.2",
|
||||
"js-tokens": "^3.0.2"
|
||||
}
|
||||
},
|
||||
"babel-messages": {
|
||||
@@ -67,7 +67,7 @@
|
||||
"resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.23.0.tgz",
|
||||
"integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=",
|
||||
"requires": {
|
||||
"babel-runtime": "6.26.0"
|
||||
"babel-runtime": "^6.22.0"
|
||||
}
|
||||
},
|
||||
"babel-runtime": {
|
||||
@@ -75,8 +75,8 @@
|
||||
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
|
||||
"integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=",
|
||||
"requires": {
|
||||
"core-js": "2.5.7",
|
||||
"regenerator-runtime": "0.11.1"
|
||||
"core-js": "^2.4.0",
|
||||
"regenerator-runtime": "^0.11.0"
|
||||
}
|
||||
},
|
||||
"babel-traverse": {
|
||||
@@ -84,15 +84,15 @@
|
||||
"resolved": "https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.26.0.tgz",
|
||||
"integrity": "sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=",
|
||||
"requires": {
|
||||
"babel-code-frame": "6.26.0",
|
||||
"babel-messages": "6.23.0",
|
||||
"babel-runtime": "6.26.0",
|
||||
"babel-types": "6.26.0",
|
||||
"babylon": "6.18.0",
|
||||
"debug": "2.6.9",
|
||||
"globals": "9.18.0",
|
||||
"invariant": "2.2.4",
|
||||
"lodash": "4.17.10"
|
||||
"babel-code-frame": "^6.26.0",
|
||||
"babel-messages": "^6.23.0",
|
||||
"babel-runtime": "^6.26.0",
|
||||
"babel-types": "^6.26.0",
|
||||
"babylon": "^6.18.0",
|
||||
"debug": "^2.6.8",
|
||||
"globals": "^9.18.0",
|
||||
"invariant": "^2.2.2",
|
||||
"lodash": "^4.17.4"
|
||||
}
|
||||
},
|
||||
"babel-types": {
|
||||
@@ -100,10 +100,10 @@
|
||||
"resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz",
|
||||
"integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=",
|
||||
"requires": {
|
||||
"babel-runtime": "6.26.0",
|
||||
"esutils": "2.0.2",
|
||||
"lodash": "4.17.10",
|
||||
"to-fast-properties": "1.0.3"
|
||||
"babel-runtime": "^6.26.0",
|
||||
"esutils": "^2.0.2",
|
||||
"lodash": "^4.17.4",
|
||||
"to-fast-properties": "^1.0.3"
|
||||
}
|
||||
},
|
||||
"babylon": {
|
||||
@@ -131,7 +131,7 @@
|
||||
"resolved": "https://registry.npmjs.org/bulma-calendar/-/bulma-calendar-1.3.0.tgz",
|
||||
"integrity": "sha1-yqz7AWeSxV2t8O3BGq5vtkwlYEE=",
|
||||
"requires": {
|
||||
"camelcase": "4.1.0"
|
||||
"camelcase": "^4.1.0"
|
||||
}
|
||||
},
|
||||
"cached-path-relative": {
|
||||
@@ -149,11 +149,11 @@
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
||||
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
|
||||
"requires": {
|
||||
"ansi-styles": "2.2.1",
|
||||
"escape-string-regexp": "1.0.5",
|
||||
"has-ansi": "2.0.0",
|
||||
"strip-ansi": "3.0.1",
|
||||
"supports-color": "2.0.0"
|
||||
"ansi-styles": "^2.2.1",
|
||||
"escape-string-regexp": "^1.0.2",
|
||||
"has-ansi": "^2.0.0",
|
||||
"strip-ansi": "^3.0.0",
|
||||
"supports-color": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"concat-stream": {
|
||||
@@ -161,9 +161,9 @@
|
||||
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.2.tgz",
|
||||
"integrity": "sha1-cIl4Yk2FavQaWnQd790mHadSwmY=",
|
||||
"requires": {
|
||||
"inherits": "2.0.3",
|
||||
"readable-stream": "2.0.6",
|
||||
"typedarray": "0.0.6"
|
||||
"inherits": "~2.0.1",
|
||||
"readable-stream": "~2.0.0",
|
||||
"typedarray": "~0.0.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"readable-stream": {
|
||||
@@ -171,12 +171,12 @@
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz",
|
||||
"integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=",
|
||||
"requires": {
|
||||
"core-util-is": "1.0.2",
|
||||
"inherits": "2.0.3",
|
||||
"isarray": "1.0.0",
|
||||
"process-nextick-args": "1.0.7",
|
||||
"string_decoder": "0.10.31",
|
||||
"util-deprecate": "1.0.2"
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.1",
|
||||
"isarray": "~1.0.0",
|
||||
"process-nextick-args": "~1.0.6",
|
||||
"string_decoder": "~0.10.x",
|
||||
"util-deprecate": "~1.0.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,8 +209,8 @@
|
||||
"resolved": "https://registry.npmjs.org/detective/-/detective-4.7.1.tgz",
|
||||
"integrity": "sha512-H6PmeeUcZloWtdt4DAkFyzFL94arpHr3NOwwmVILFiy+9Qd4JTxxXrzfyGk/lmct2qVGBwTSwSXagqu2BxmWig==",
|
||||
"requires": {
|
||||
"acorn": "5.5.3",
|
||||
"defined": "1.0.0"
|
||||
"acorn": "^5.2.1",
|
||||
"defined": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"duplexer2": {
|
||||
@@ -218,7 +218,7 @@
|
||||
"resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz",
|
||||
"integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=",
|
||||
"requires": {
|
||||
"readable-stream": "2.3.6"
|
||||
"readable-stream": "^2.0.2"
|
||||
}
|
||||
},
|
||||
"enhanced-resolve": {
|
||||
@@ -226,10 +226,10 @@
|
||||
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-3.4.1.tgz",
|
||||
"integrity": "sha1-BCHjOf1xQZs9oT0Smzl5BAIwR24=",
|
||||
"requires": {
|
||||
"graceful-fs": "4.1.11",
|
||||
"memory-fs": "0.4.1",
|
||||
"object-assign": "4.1.1",
|
||||
"tapable": "0.2.8"
|
||||
"graceful-fs": "^4.1.2",
|
||||
"memory-fs": "^0.4.0",
|
||||
"object-assign": "^4.0.1",
|
||||
"tapable": "^0.2.7"
|
||||
}
|
||||
},
|
||||
"errno": {
|
||||
@@ -237,7 +237,7 @@
|
||||
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz",
|
||||
"integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==",
|
||||
"requires": {
|
||||
"prr": "1.0.1"
|
||||
"prr": "~1.0.1"
|
||||
}
|
||||
},
|
||||
"escape-string-regexp": {
|
||||
@@ -265,7 +265,7 @@
|
||||
"resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
|
||||
"integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=",
|
||||
"requires": {
|
||||
"ansi-regex": "2.1.1"
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"inherits": {
|
||||
@@ -278,7 +278,7 @@
|
||||
"resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz",
|
||||
"integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==",
|
||||
"requires": {
|
||||
"loose-envify": "1.3.1"
|
||||
"loose-envify": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"isarray": {
|
||||
@@ -301,8 +301,8 @@
|
||||
"resolved": "https://registry.npmjs.org/konan/-/konan-1.1.0.tgz",
|
||||
"integrity": "sha1-M3dDxLl7S9Hvi2KiSzFeuLxLIJQ=",
|
||||
"requires": {
|
||||
"babel-traverse": "6.26.0",
|
||||
"babylon": "6.18.0"
|
||||
"babel-traverse": "^6.23.1",
|
||||
"babylon": "^6.15.0"
|
||||
}
|
||||
},
|
||||
"lodash": {
|
||||
@@ -315,7 +315,7 @@
|
||||
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz",
|
||||
"integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=",
|
||||
"requires": {
|
||||
"js-tokens": "3.0.2"
|
||||
"js-tokens": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"memory-fs": {
|
||||
@@ -323,8 +323,8 @@
|
||||
"resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz",
|
||||
"integrity": "sha1-OpoguEYlI+RHz7x+i7gO1me/xVI=",
|
||||
"requires": {
|
||||
"errno": "0.1.7",
|
||||
"readable-stream": "2.3.6"
|
||||
"errno": "^0.1.3",
|
||||
"readable-stream": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
@@ -347,7 +347,7 @@
|
||||
"resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz",
|
||||
"integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=",
|
||||
"requires": {
|
||||
"path-platform": "0.11.15"
|
||||
"path-platform": "~0.11.15"
|
||||
}
|
||||
},
|
||||
"path-parse": {
|
||||
@@ -375,13 +375,13 @@
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
||||
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
|
||||
"requires": {
|
||||
"core-util-is": "1.0.2",
|
||||
"inherits": "2.0.3",
|
||||
"isarray": "1.0.0",
|
||||
"process-nextick-args": "2.0.0",
|
||||
"safe-buffer": "5.1.2",
|
||||
"string_decoder": "1.1.1",
|
||||
"util-deprecate": "1.0.2"
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.3",
|
||||
"isarray": "~1.0.0",
|
||||
"process-nextick-args": "~2.0.0",
|
||||
"safe-buffer": "~5.1.1",
|
||||
"string_decoder": "~1.1.1",
|
||||
"util-deprecate": "~1.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"process-nextick-args": {
|
||||
@@ -394,7 +394,7 @@
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"requires": {
|
||||
"safe-buffer": "5.1.2"
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -409,7 +409,7 @@
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz",
|
||||
"integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==",
|
||||
"requires": {
|
||||
"path-parse": "1.0.5"
|
||||
"path-parse": "^1.0.5"
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
@@ -422,8 +422,8 @@
|
||||
"resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz",
|
||||
"integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=",
|
||||
"requires": {
|
||||
"duplexer2": "0.1.4",
|
||||
"readable-stream": "2.3.6"
|
||||
"duplexer2": "~0.1.0",
|
||||
"readable-stream": "^2.0.2"
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
@@ -436,7 +436,7 @@
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
|
||||
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
|
||||
"requires": {
|
||||
"ansi-regex": "2.1.1"
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"subarg": {
|
||||
@@ -444,7 +444,7 @@
|
||||
"resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz",
|
||||
"integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=",
|
||||
"requires": {
|
||||
"minimist": "1.2.0"
|
||||
"minimist": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"supports-color": {
|
||||
@@ -467,8 +467,8 @@
|
||||
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz",
|
||||
"integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=",
|
||||
"requires": {
|
||||
"readable-stream": "2.3.6",
|
||||
"xtend": "4.0.1"
|
||||
"readable-stream": "^2.1.5",
|
||||
"xtend": "~4.0.1"
|
||||
}
|
||||
},
|
||||
"to-fast-properties": {
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
:plugins [[lein-figwheel "0.5.13"]
|
||||
[lein-pdo "0.1.1"]
|
||||
[cider/cider-nrepl "0.16.0"]]
|
||||
:jvm-opts ["-Dconfig=config/dev.edn"]}
|
||||
:jvm-opts ["-Dconfig=config/dev.edn" "--add-modules" "java.xml.bind"]}
|
||||
:uberjar {:prep-tasks [["cljsbuild" "once" "min"] "compile"]}
|
||||
:provided {:dependencies [[org.clojure/clojurescript "1.10.238"]
|
||||
[reagent "0.7.0"]
|
||||
|
||||
@@ -53,15 +53,14 @@
|
||||
:where [:= :id (if (int? id)
|
||||
id
|
||||
(Integer/parseInt id))])
|
||||
execute!)
|
||||
execute!)
|
||||
(get-by-id (if (int? id)
|
||||
id
|
||||
(Integer/parseInt id))))
|
||||
|
||||
(defn insert [data]
|
||||
(let [[id] (-> (sql/build :insert-into :vendors
|
||||
:values [(unparse data)])
|
||||
execute!)]
|
||||
|
||||
(let [[{:keys [id]}] (j/insert! (get-conn) :vendors (unparse data))]
|
||||
(println "inserted vendor: " data ", id " id)
|
||||
(get-by-id id)))
|
||||
|
||||
|
||||
@@ -192,6 +192,7 @@
|
||||
:date {:type 'String}
|
||||
:company_id {:type 'Int}
|
||||
:vendor_id {:type 'Int}
|
||||
:vendor_name {:type 'String}
|
||||
:total {:type 'Float}}}}
|
||||
|
||||
:mutations
|
||||
|
||||
@@ -1,21 +1,27 @@
|
||||
(ns auto-ap.graphql.invoices
|
||||
(:require [auto-ap.graphql.utils :refer [->graphql]]
|
||||
[auto-ap.db.invoices :as invoices]
|
||||
[auto-ap.db.vendors :as vendors]
|
||||
[auto-ap.db.invoices-expense-accounts :as invoices-expense-accounts]
|
||||
[auto-ap.time :refer [parse normal-date]]))
|
||||
|
||||
(defn add-invoice [context {{:keys [total invoice_number company_id vendor_id date] :as in} :invoice} value]
|
||||
(defn -create-vendor-if-necessary [vendor-id vendor-name]
|
||||
(if vendor-id
|
||||
vendor-id
|
||||
(:id (doto (vendors/insert {:name vendor-name :default-expense-account 0}) println))))
|
||||
|
||||
(-> (invoices/insert-multi! [{:invoice-number invoice_number
|
||||
:company-id company_id
|
||||
:vendor-id vendor_id
|
||||
:total total
|
||||
:outstanding-balance total
|
||||
:status "unpaid"
|
||||
:imported true
|
||||
:date (parse date normal-date)}])
|
||||
(first)
|
||||
(->graphql)))
|
||||
(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)]
|
||||
(-> (invoices/insert-multi! [{:invoice-number invoice_number
|
||||
:company-id company_id
|
||||
:vendor-id vendor_id
|
||||
:total total
|
||||
:outstanding-balance total
|
||||
:status "unpaid"
|
||||
:imported true
|
||||
:date (parse date normal-date)}])
|
||||
(first)
|
||||
(->graphql))))
|
||||
|
||||
|
||||
(defn get-invoices-expense-accounts [context args value]
|
||||
|
||||
@@ -3,14 +3,15 @@
|
||||
[auto-ap.entities.shared :as shared]))
|
||||
|
||||
(s/def ::vendor-id int?)
|
||||
(s/def ::vendor-name string?)
|
||||
(s/def ::company-id int?)
|
||||
(s/def ::invoice-number ::shared/required-identifier)
|
||||
(s/def ::date ::shared/date)
|
||||
(s/def ::total ::shared/money)
|
||||
|
||||
(s/def ::invoice (s/keys :req-un [::vendor-id
|
||||
::company-id
|
||||
(s/def ::invoice (s/keys :req-un [::company-id
|
||||
::invoice-number
|
||||
::date
|
||||
::total
|
||||
]))
|
||||
::total]
|
||||
:opt-un [::vendor-id
|
||||
::vendor-name]))
|
||||
|
||||
@@ -74,8 +74,9 @@
|
||||
(re-frame/reg-event-db
|
||||
::change-form
|
||||
(fn [db [_ location field value]]
|
||||
(println field value)
|
||||
(assoc-in db (into location field) value)))
|
||||
(if value
|
||||
(assoc-in db (into location field) value)
|
||||
(update-in db location dissoc field))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::modal-status
|
||||
|
||||
@@ -2,31 +2,38 @@
|
||||
(:require [reagent.core :as r]
|
||||
[clojure.string :as str]))
|
||||
|
||||
(defn typeahead [{:keys [matches on-change field value class]}]
|
||||
(defn typeahead [{:keys [matches on-change field text-field value class not-found-description
|
||||
not-found-value]}]
|
||||
(let [text (r/atom (or (second (first (filter #(= (first %) value) matches))) ""))
|
||||
highlighted (r/atom 0)
|
||||
selected (r/atom (first (first (filter #(= (first %) value) matches))))
|
||||
select (fn [[id t]]
|
||||
(reset! selected id)
|
||||
(reset! text t)
|
||||
(println [id t])
|
||||
select (fn [[id text-description text-value]]
|
||||
(reset! selected id)
|
||||
(reset! text text-description)
|
||||
(println (= :not-found id))
|
||||
(when on-change
|
||||
(on-change id)))]
|
||||
(fn [{:keys [matches on-change field value class]}]
|
||||
(if (= :not-found id)
|
||||
(on-change nil text-description text-value)
|
||||
(on-change id text-description (or text-value text-description)))))]
|
||||
(fn [{:keys [matches on-change field text-field value class not-found-description]}]
|
||||
(let [valid-matches (take 5 (for [[[id t :as match] i] (map vector matches (range))
|
||||
:when (str/includes? (.toLowerCase t) (.toLowerCase @text))]
|
||||
match))]
|
||||
match))
|
||||
valid-matches (if (and not-found-description @text)
|
||||
(concat valid-matches [[:not-found (not-found-description @text) (not-found-value @text)]])
|
||||
|
||||
valid-matches)]
|
||||
[:div.typeahead
|
||||
(if @selected
|
||||
[:div.input {:class class}
|
||||
[:div.control
|
||||
[:div.tags.has-addons
|
||||
[:span.tag @text]
|
||||
[:a.tag.is-delete {:on-click (fn [] (select [nil ""]))}]]]]
|
||||
[:a.tag.is-delete {:on-click (fn [] (select [nil "" nil]))}]]]]
|
||||
|
||||
[:input.input {:type "text"
|
||||
:class class
|
||||
:field [:vendor]
|
||||
:field field
|
||||
:value @text
|
||||
:on-blur (fn [e]
|
||||
(cond @selected
|
||||
@@ -52,13 +59,19 @@
|
||||
(reset! highlighted (ffirst valid-matches))
|
||||
(select [nil (.. e -target -value)]))}
|
||||
])
|
||||
(when (and (seq @text)
|
||||
(not @selected)
|
||||
(seq valid-matches))
|
||||
(cond
|
||||
(and (seq @text)
|
||||
(not @selected)
|
||||
(seq valid-matches))
|
||||
[:div.typeahead-menu
|
||||
[:ul
|
||||
(for [[id t :as match] valid-matches]
|
||||
|
||||
[:li.typeahead-suggestion {:class (if (= id @highlighted)
|
||||
"typeahead-highlighted")
|
||||
:on-mouse-down #(do (println "MATCH" match) (select match))} t])]])]))))
|
||||
:on-mouse-down #(do (select match))} t])]]
|
||||
|
||||
|
||||
|
||||
:else
|
||||
nil)]))))
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
(re-frame/reg-sub
|
||||
::invoice
|
||||
(fn [db id]
|
||||
(println id)
|
||||
(get (by :id (-> db ::invoice-page :invoices )) id)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
@@ -207,18 +206,20 @@
|
||||
(re-frame/reg-event-fx
|
||||
::create-invoice
|
||||
(fn [{:keys [db]} _]
|
||||
{:graphql
|
||||
{:token (-> db :user)
|
||||
:query-obj {:venia/operation {:operation/type :mutation
|
||||
:operation/name "AddInvoice"}
|
||||
|
||||
:venia/queries [{:query/data [:add-invoice
|
||||
{:invoice @(re-frame/subscribe [::new-invoice])}
|
||||
[:id :total :outstanding-balance :date :invoice-number
|
||||
[:company [:id :name]]
|
||||
[:vendor [:id :name]]
|
||||
]]}]}
|
||||
:on-success [::invoice-created]}}))
|
||||
(let [new-invoice @(re-frame/subscribe [::new-invoice])]
|
||||
(println new-invoice)
|
||||
{:graphql
|
||||
{:token (-> db :user)
|
||||
:query-obj {:venia/operation {:operation/type :mutation
|
||||
:operation/name "AddInvoice"}
|
||||
|
||||
:venia/queries [{:query/data [:add-invoice
|
||||
{:invoice new-invoice}
|
||||
[:id :total :outstanding-balance :date :invoice-number
|
||||
[:company [:id :name]]
|
||||
[:vendor [:id :name]]
|
||||
]]}]}
|
||||
:on-success [::invoice-created]}})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::invoice-created
|
||||
@@ -270,7 +271,7 @@
|
||||
(update-in [::invoice-page :invoices]
|
||||
|
||||
(fn [is]
|
||||
(println "UPDATE" updated is)
|
||||
|
||||
(replace-if #(= (:id %1) (:id %2)) updated is)))
|
||||
(dissoc ::change-expense-accounts))})))
|
||||
|
||||
@@ -336,7 +337,7 @@
|
||||
:field [:invoice :expense-accounts index :amount]
|
||||
:event change-event
|
||||
:subscription data
|
||||
:value (doto (get-in data [:invoice :expense-accounts index :amount]) println)
|
||||
:value (get-in data [:invoice :expense-accounts index :amount])
|
||||
|
||||
:max (:total data)
|
||||
:step "0.01"}]]]]]]
|
||||
@@ -421,8 +422,11 @@
|
||||
[typeahead {:matches (map (fn [x] [(:id x) (:name x)]) @(re-frame/subscribe [::subs/vendors]))
|
||||
:type "typeahead"
|
||||
:field [:vendor-id]
|
||||
:text-field [:vendor-name]
|
||||
:not-found-description #(str "Create vendor '" % "'")
|
||||
:not-found-value #(str %)
|
||||
:event change-event
|
||||
:spec ::invoice/vendor-id
|
||||
:spec (s/nilable ::invoice/vendor-id)
|
||||
:subscription data}]]]
|
||||
[horizontal-field
|
||||
[:label.label "Date"]
|
||||
|
||||
@@ -68,12 +68,15 @@
|
||||
keys (dissoc keys :field :subscription :event :spec)]
|
||||
(into [dom keys] (with-keys rest))))
|
||||
|
||||
(defmethod do-bind "typeahead" [dom {:keys [field event subscription class spec] :as keys} & rest]
|
||||
(defmethod do-bind "typeahead" [dom {:keys [field text-field event subscription class spec] :as keys} & rest]
|
||||
(let [field (if (keyword? field) [field] field)
|
||||
event (if (keyword? event) [event] event)
|
||||
keys (assoc keys
|
||||
:on-change (fn [selected]
|
||||
(re-frame/dispatch (conj (conj event field) selected)))
|
||||
:on-change (fn [selected text-description text-value]
|
||||
(println "HERE " selected text-description text-value)
|
||||
(re-frame/dispatch (conj (conj event field) selected))
|
||||
(when text-field
|
||||
(re-frame/dispatch (conj (conj event text-field) text-value))))
|
||||
:value (get-in subscription field)
|
||||
:class (str class
|
||||
(when (and spec (not (s/valid? spec (get-in subscription field))))
|
||||
|
||||
Reference in New Issue
Block a user