(ns auto-ap.datomic.migrate.vendors
  (:require [datomic.api :as d]
            [auto-ap.datomic :refer [uri]]))

(def norms-map {:add-1099-stuff {:txes [[{:db/ident :vendor/legal-entity-first-name
                                          :db/doc "The first name for the legal entity"
                                          :db/valueType :db.type/string
                                          :db/cardinality :db.cardinality/one}

                                         {:db/ident :vendor/legal-entity-middle-name
                                          :db/doc "The first name for the legal entity"
                                          :db/valueType :db.type/string
                                          :db/cardinality :db.cardinality/one}

                                         {:db/ident :vendor/legal-entity-last-name
                                          :db/doc "The first name for the legal entity"
                                          :db/valueType :db.type/string
                                          :db/cardinality :db.cardinality/one}

                                         {:db/ident :vendor/legal-entity-tin
                                          :db/doc "The ssn or ein for the legal entity"
                                          :db/valueType :db.type/string
                                          :db/cardinality :db.cardinality/one}

                                         {:db/ident :vendor/legal-entity-tin-type
                                          :db/doc "The ssn or ein for the legal entity"
                                          :db/valueType :db.type/ref
                                          :db/cardinality :db.cardinality/one}

                                         {:db/ident :vendor/legal-entity-1099-type
                                          :db/doc "The ssn or ein for the legal entity"
                                          :db/valueType :db.type/ref
                                          :db/cardinality :db.cardinality/one}]]}
                :add-1099-enums {:txes [[{:db/ident :legal-entity-tin-type/ssn}
                                         {:db/ident :legal-entity-tin-type/ein}

                                         {:db/ident :legal-entity-1099-type/none}
                                         {:db/ident :legal-entity-1099-type/misc}
                                         {:db/ident :legal-entity-1099-type/landlord}]]}
                :add-vendor-usages  {:txes [[{:db/ident :vendor-usage/key
                                              :db/doc "A key to find this by, normally vendor (db:/id)-client(:db/id)"
                                              :db/valueType :db.type/string
                                              :db/cardinality :db.cardinality/one
                                              :db/unique :db.unique/identity}
                                             {:db/ident :vendor-usage/vendor
                                              :db/doc "Which vendor this usage is for"
                                              :db/valueType :db.type/ref
                                              :db/cardinality :db.cardinality/one}

                                             {:db/ident :vendor-usage/client
                                              :db/doc "Which client this usage is for"
                                              :db/valueType :db.type/ref
                                              :db/cardinality :db.cardinality/one}
                                             {:db/ident :vendor-usage/count
                                              :db/doc "How many times does this client use this vendor"
                                              :db/valueType :db.type/long
                                              :db/cardinality :db.cardinality/one
                                              :db/noHistory true}]
                                            ]}})





