schema.rb 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  1. # encoding: UTF-8
  2. # This file is auto-generated from the current state of the database. Instead
  3. # of editing this file, please use the migrations feature of Active Record to
  4. # incrementally modify your database, and then regenerate this schema definition.
  5. #
  6. # Note that this schema.rb definition is the authoritative source for your
  7. # database schema. If you need to create the application database on another
  8. # system, you should be using db:schema:load, not running all the migrations
  9. # from scratch. The latter is a flawed and unsustainable approach (the more migrations
  10. # you'll amass, the slower it'll run and the greater likelihood for issues).
  11. #
  12. # It's strongly recommended that you check this file into your version control system.
  13. ActiveRecord::Schema.define(version: 20180905183025) do
  14. # These are extensions that must be enabled in order to support this database
  15. enable_extension "plpgsql"
  16. create_table "audits", force: :cascade do |t|
  17. t.integer "auditable_id"
  18. t.string "auditable_type"
  19. t.integer "associated_id"
  20. t.string "associated_type"
  21. t.integer "user_id"
  22. t.string "user_type"
  23. t.string "username"
  24. t.string "action"
  25. t.text "audited_changes"
  26. t.integer "version", default: 0
  27. t.string "comment"
  28. t.string "remote_address"
  29. t.string "request_uuid"
  30. t.datetime "created_at"
  31. end
  32. add_index "audits", ["associated_id", "associated_type"], name: "associated_index", using: :btree
  33. add_index "audits", ["auditable_id", "auditable_type"], name: "auditable_index", using: :btree
  34. add_index "audits", ["created_at"], name: "index_audits_on_created_at", using: :btree
  35. add_index "audits", ["request_uuid"], name: "index_audits_on_request_uuid", using: :btree
  36. add_index "audits", ["user_id", "user_type"], name: "user_index", using: :btree
  37. create_table "available_products", force: :cascade do |t|
  38. t.integer "product_id"
  39. t.integer "pointsale_id"
  40. t.decimal "stock_min", default: 0.0
  41. t.decimal "stock_max", default: 0.0
  42. t.decimal "stock", default: 0.0
  43. t.datetime "created_at", null: false
  44. t.datetime "updated_at", null: false
  45. t.decimal "price_sale", precision: 10, scale: 2
  46. t.integer "products_variant_id"
  47. end
  48. add_index "available_products", ["pointsale_id"], name: "index_available_products_on_pointsale_id", using: :btree
  49. add_index "available_products", ["product_id"], name: "index_available_products_on_product_id", using: :btree
  50. create_table "billing_informations", force: :cascade do |t|
  51. t.integer "customer_id", default: 0, null: false
  52. t.string "name", limit: 255, default: "", null: false
  53. t.string "rfc", limit: 13, default: "", null: false
  54. t.string "address", limit: 255, default: "", null: false
  55. t.integer "zipcode", default: 0, null: false
  56. t.string "num_ext", default: "", null: false
  57. t.string "num_int", default: "", null: false
  58. t.integer "state_id", default: 0, null: false
  59. t.integer "county_id", default: 0, null: false
  60. t.string "city", default: "", null: false
  61. t.string "suburb", default: "", null: false
  62. t.integer "status", default: 1, null: false
  63. t.datetime "created_at", null: false
  64. t.datetime "updated_at", null: false
  65. t.integer "supplier_id", default: 0, null: false
  66. end
  67. add_index "billing_informations", ["county_id"], name: "index_billing_informations_on_county_id", using: :btree
  68. add_index "billing_informations", ["customer_id"], name: "index_billing_informations_on_customer_id", using: :btree
  69. add_index "billing_informations", ["state_id"], name: "index_billing_informations_on_state_id", using: :btree
  70. create_table "cash_out_details", force: :cascade do |t|
  71. t.integer "cash_out_id"
  72. t.integer "payment_method_id"
  73. t.datetime "created_at", null: false
  74. t.datetime "updated_at", null: false
  75. t.decimal "incoming", precision: 10, scale: 2, default: 0.0, null: false
  76. t.decimal "total", precision: 10, scale: 2, default: 0.0, null: false
  77. t.decimal "adjustment", precision: 10, scale: 2, default: 0.0, null: false
  78. t.text "observations"
  79. t.decimal "outgoing", precision: 10, scale: 2, default: 0.0, null: false
  80. end
  81. add_index "cash_out_details", ["cash_out_id"], name: "index_cash_out_details_on_cash_out_id", using: :btree
  82. add_index "cash_out_details", ["payment_method_id"], name: "index_cash_out_details_on_payment_method_id", using: :btree
  83. create_table "cash_outs", force: :cascade do |t|
  84. t.integer "open_cash_register_id"
  85. t.integer "user_id"
  86. t.decimal "amount_in", null: false
  87. t.decimal "amount_out", null: false
  88. t.datetime "created_at", null: false
  89. t.datetime "updated_at", null: false
  90. t.integer "received_by_id"
  91. t.decimal "received_cash", precision: 10, scale: 2, default: 0.0
  92. t.decimal "cash_fund", precision: 10, scale: 2, default: 0.0
  93. t.decimal "physical_cash", precision: 10, scale: 2, default: 0.0, null: false
  94. t.string "observations"
  95. end
  96. add_index "cash_outs", ["open_cash_register_id"], name: "index_cash_outs_on_open_cash_register_id", using: :btree
  97. add_index "cash_outs", ["user_id"], name: "index_cash_outs_on_user_id", using: :btree
  98. create_table "cash_registers", force: :cascade do |t|
  99. t.string "name"
  100. t.text "description"
  101. t.integer "pointsale_id"
  102. t.datetime "created_at", null: false
  103. t.datetime "updated_at", null: false
  104. t.integer "main", default: 0, null: false
  105. t.integer "status", default: 1, null: false
  106. end
  107. create_table "cash_registers_moves", force: :cascade do |t|
  108. t.integer "open_cash_register_id"
  109. t.integer "payment_method_id"
  110. t.decimal "quantity", default: 0.0, null: false
  111. t.string "move_type", limit: 1, null: false
  112. t.datetime "created_at", null: false
  113. t.datetime "updated_at", null: false
  114. t.integer "sale_id"
  115. t.integer "cardnumber"
  116. t.integer "purchase_id"
  117. t.integer "expense_id"
  118. t.integer "concept"
  119. t.string "ticket"
  120. t.integer "status", default: 1, null: false
  121. t.decimal "received", precision: 10, scale: 2
  122. t.decimal "change", precision: 10, scale: 2
  123. t.integer "products_return_id"
  124. t.integer "credit_payment_id"
  125. end
  126. add_index "cash_registers_moves", ["open_cash_register_id"], name: "index_cash_registers_moves_on_open_cash_register_id", using: :btree
  127. add_index "cash_registers_moves", ["payment_method_id"], name: "index_cash_registers_moves_on_payment_method_id", using: :btree
  128. create_table "categories", force: :cascade do |t|
  129. t.string "category"
  130. t.text "description"
  131. t.integer "status", default: 1
  132. t.datetime "created_at", null: false
  133. t.datetime "updated_at", null: false
  134. t.integer "parent_id", default: 0, null: false
  135. end
  136. create_table "categories_products", id: false, force: :cascade do |t|
  137. t.integer "product_id"
  138. t.integer "category_id"
  139. end
  140. add_index "categories_products", ["category_id"], name: "index_categories_products_on_category_id", using: :btree
  141. add_index "categories_products", ["product_id"], name: "index_categories_products_on_product_id", using: :btree
  142. create_table "commissions", force: :cascade do |t|
  143. t.decimal "commission_total"
  144. t.datetime "created_at", null: false
  145. t.datetime "updated_at", null: false
  146. t.integer "pointsale_id"
  147. t.integer "user_id"
  148. t.datetime "initial_date", null: false
  149. t.datetime "final_date", null: false
  150. end
  151. add_index "commissions", ["pointsale_id"], name: "index_commissions_on_pointsale_id", using: :btree
  152. create_table "contacts", force: :cascade do |t|
  153. t.string "name", limit: 255, default: "", null: false
  154. t.string "last_name", limit: 255, default: "", null: false
  155. t.string "phone", limit: 30, default: "", null: false
  156. t.string "email", limit: 255, default: "", null: false
  157. t.text "notes", default: "", null: false
  158. t.integer "status", default: 1, null: false
  159. t.datetime "created_at", null: false
  160. t.datetime "updated_at", null: false
  161. end
  162. create_table "credit_payments", force: :cascade do |t|
  163. t.integer "customer_id"
  164. t.integer "credit_id"
  165. t.integer "pointsale_id"
  166. t.decimal "quantity", precision: 10, scale: 2, default: 0.0, null: false
  167. t.integer "status", default: 0, null: false
  168. t.date "date_payment", null: false
  169. t.datetime "created_at", null: false
  170. t.datetime "updated_at", null: false
  171. t.integer "user_id"
  172. end
  173. add_index "credit_payments", ["credit_id"], name: "index_credit_payments_on_credit_id", using: :btree
  174. add_index "credit_payments", ["customer_id"], name: "index_credit_payments_on_customer_id", using: :btree
  175. add_index "credit_payments", ["pointsale_id"], name: "index_credit_payments_on_pointsale_id", using: :btree
  176. create_table "credits", force: :cascade do |t|
  177. t.integer "customer_id"
  178. t.integer "pointsale_id"
  179. t.integer "sale_id"
  180. t.decimal "total", precision: 10, scale: 2, default: 0.0, null: false
  181. t.decimal "rest", precision: 10, scale: 2, default: 0.0, null: false
  182. t.integer "status", default: 0, null: false
  183. t.datetime "created_at", null: false
  184. t.datetime "updated_at", null: false
  185. t.string "credit_note"
  186. end
  187. add_index "credits", ["customer_id"], name: "index_credits_on_customer_id", using: :btree
  188. add_index "credits", ["pointsale_id"], name: "index_credits_on_pointsale_id", using: :btree
  189. add_index "credits", ["sale_id"], name: "index_credits_on_sale_id", using: :btree
  190. create_table "customers", force: :cascade do |t|
  191. t.string "nick_name", limit: 255, default: "", null: false
  192. t.string "phone", limit: 30, default: "", null: false
  193. t.string "email", limit: 255, default: "", null: false
  194. t.boolean "credit", default: true, null: false
  195. t.decimal "credit_limit", precision: 10, scale: 2, default: 0.0, null: false
  196. t.integer "time_limit", default: 0, null: false
  197. t.text "notes", default: "", null: false
  198. t.integer "status", default: 1, null: false
  199. t.datetime "created_at", null: false
  200. t.datetime "updated_at", null: false
  201. t.integer "contact_id"
  202. t.integer "is_public", default: 0
  203. end
  204. create_table "expenses", force: :cascade do |t|
  205. t.integer "expensesconcept_id"
  206. t.integer "open_cash_register_id"
  207. t.decimal "quantity", default: 0.0, null: false
  208. t.integer "status", default: 1, null: false
  209. t.datetime "created_at", null: false
  210. t.datetime "updated_at", null: false
  211. t.text "observations"
  212. t.date "expense_date"
  213. t.string "expense_code"
  214. end
  215. add_index "expenses", ["expensesconcept_id"], name: "index_expenses_on_expensesconcept_id", using: :btree
  216. add_index "expenses", ["open_cash_register_id"], name: "index_expenses_on_open_cash_register_id", using: :btree
  217. create_table "expensesconcepts", force: :cascade do |t|
  218. t.string "name"
  219. t.string "description"
  220. t.boolean "allpoints"
  221. t.integer "status", default: 1
  222. t.datetime "created_at", null: false
  223. t.datetime "updated_at", null: false
  224. t.integer "expense_from_purchase", default: 0, null: false
  225. end
  226. create_table "expensesconcepts_pointsales", id: false, force: :cascade do |t|
  227. t.integer "expensesconcept_id"
  228. t.integer "pointsale_id"
  229. end
  230. create_table "inventories", force: :cascade do |t|
  231. t.integer "pointsale_id"
  232. t.integer "user_id"
  233. t.date "inventory_date"
  234. t.text "notes"
  235. t.datetime "created_at", null: false
  236. t.datetime "updated_at", null: false
  237. end
  238. add_index "inventories", ["pointsale_id"], name: "index_inventories_on_pointsale_id", using: :btree
  239. add_index "inventories", ["user_id"], name: "index_inventories_on_user_id", using: :btree
  240. create_table "inventories_moves", force: :cascade do |t|
  241. t.integer "inventory_id"
  242. t.integer "product_id"
  243. t.integer "purchase_id"
  244. t.integer "sale_id"
  245. t.decimal "quantity", default: 0.0, null: false
  246. t.string "move_type", limit: 1, null: false
  247. t.datetime "created_at", null: false
  248. t.datetime "updated_at", null: false
  249. t.integer "reason"
  250. t.integer "transfer_id"
  251. end
  252. add_index "inventories_moves", ["inventory_id"], name: "index_inventories_moves_on_inventory_id", using: :btree
  253. add_index "inventories_moves", ["product_id"], name: "index_inventories_moves_on_product_id", using: :btree
  254. add_index "inventories_moves", ["purchase_id"], name: "index_inventories_moves_on_purchase_id", using: :btree
  255. add_index "inventories_moves", ["sale_id"], name: "index_inventories_moves_on_sale_id", using: :btree
  256. create_table "open_cash_registers", force: :cascade do |t|
  257. t.integer "cash_register_id"
  258. t.integer "user_id"
  259. t.decimal "initial_cash", precision: 10, scale: 2, default: 0.0
  260. t.decimal "final_cash", precision: 10, scale: 2, default: 0.0
  261. t.integer "status", default: 0
  262. t.datetime "created_at", null: false
  263. t.datetime "updated_at", null: false
  264. end
  265. add_index "open_cash_registers", ["cash_register_id"], name: "index_open_cash_registers_on_cash_register_id", using: :btree
  266. add_index "open_cash_registers", ["user_id"], name: "index_open_cash_registers_on_user_id", using: :btree
  267. create_table "payment_methods", force: :cascade do |t|
  268. t.string "method", null: false
  269. t.integer "status", default: 1, null: false
  270. t.datetime "created_at", null: false
  271. t.datetime "updated_at", null: false
  272. t.integer "reference"
  273. t.integer "isCash", default: 0, null: false
  274. end
  275. create_table "pointsales", force: :cascade do |t|
  276. t.string "name"
  277. t.string "address"
  278. t.text "notes"
  279. t.integer "status", default: 1
  280. t.datetime "created_at", null: false
  281. t.datetime "updated_at", null: false
  282. t.text "prefix"
  283. t.string "img_pointsale_file_name"
  284. t.string "img_pointsale_content_type"
  285. t.integer "img_pointsale_file_size"
  286. t.datetime "img_pointsale_updated_at"
  287. t.string "ticket_footer"
  288. t.string "img_pointsale"
  289. t.decimal "haggle_percent", precision: 10, scale: 2, default: 0.0
  290. end
  291. create_table "pos_configs", force: :cascade do |t|
  292. t.integer "cancel_partial_payment"
  293. t.integer "refund_sale"
  294. t.integer "days_cancel_sale"
  295. t.integer "days_cancel_purchase"
  296. t.decimal "tax_percent"
  297. t.string "time_zone", limit: 255, default: "", null: false
  298. t.decimal "gain_margin"
  299. t.datetime "created_at", null: false
  300. t.datetime "updated_at", null: false
  301. t.text "ticket_description"
  302. t.integer "days_cancel_reserved"
  303. t.decimal "reserve_sale_percent", precision: 10, scale: 2
  304. t.integer "commission_percent"
  305. t.string "ticket_footer"
  306. t.string "ticket_img_file_name"
  307. t.string "ticket_img_content_type"
  308. t.integer "ticket_img_file_size"
  309. t.datetime "ticket_img_updated_at"
  310. t.integer "haggle_in_sale_percent"
  311. t.string "ticket_img"
  312. t.boolean "enable_haggle", default: true
  313. end
  314. create_table "pre_purchases", force: :cascade do |t|
  315. t.integer "supplier_id"
  316. t.integer "user_id"
  317. t.integer "pointsale_id"
  318. t.integer "product_id"
  319. t.datetime "created_at", null: false
  320. t.datetime "updated_at", null: false
  321. t.decimal "amount", default: 0.0, null: false
  322. t.decimal "tax", default: 0.0, null: false
  323. t.decimal "total", default: 0.0, null: false
  324. t.integer "quantity", default: 0, null: false
  325. t.integer "warehouse_id"
  326. t.decimal "price_base", precision: 10, scale: 2
  327. t.decimal "exchange", precision: 10, scale: 2
  328. end
  329. create_table "pre_sales", force: :cascade do |t|
  330. t.integer "customer_id"
  331. t.integer "user_id"
  332. t.integer "open_cash_register_id"
  333. t.integer "product_id"
  334. t.datetime "created_at", null: false
  335. t.datetime "updated_at", null: false
  336. t.integer "sale_type", limit: 2
  337. t.decimal "amount", default: 0.0, null: false
  338. t.decimal "tax", default: 0.0, null: false
  339. t.decimal "discount", default: 0.0, null: false
  340. t.decimal "total", default: 0.0, null: false
  341. t.integer "quantity", default: 0, null: false
  342. t.integer "special_price_id"
  343. t.decimal "unit_price", precision: 10, scale: 2
  344. t.decimal "haggle", precision: 10, scale: 2, default: 0.0
  345. t.integer "promotion_id"
  346. t.decimal "unit_price_w_discount", precision: 10, scale: 2
  347. t.integer "haggle_percent", default: 0
  348. end
  349. create_table "pre_transfers", force: :cascade do |t|
  350. t.integer "origin_id"
  351. t.integer "destiny_id"
  352. t.integer "user_id"
  353. t.integer "product_id"
  354. t.integer "quantity", null: false
  355. t.datetime "created_at", null: false
  356. t.datetime "updated_at", null: false
  357. t.integer "origin_is_pointsale", null: false
  358. t.integer "destiny_is_pointsale", null: false
  359. end
  360. add_index "pre_transfers", ["destiny_id"], name: "index_pre_transfers_on_destiny_id", using: :btree
  361. add_index "pre_transfers", ["origin_id"], name: "index_pre_transfers_on_origin_id", using: :btree
  362. add_index "pre_transfers", ["product_id"], name: "index_pre_transfers_on_product_id", using: :btree
  363. add_index "pre_transfers", ["user_id"], name: "index_pre_transfers_on_user_id", using: :btree
  364. create_table "product_wastes", force: :cascade do |t|
  365. t.integer "product_id"
  366. t.decimal "quantity", precision: 10, scale: 2, default: 0.0, null: false
  367. t.string "reason", default: "", null: false
  368. t.integer "status", default: 0, null: false
  369. t.datetime "created_at", null: false
  370. t.datetime "updated_at", null: false
  371. t.integer "user_id"
  372. t.integer "pointsale_id"
  373. t.integer "warehouse_id"
  374. t.integer "products_return_in_id"
  375. end
  376. add_index "product_wastes", ["product_id"], name: "index_product_wastes_on_product_id", using: :btree
  377. create_table "products", force: :cascade do |t|
  378. t.string "sku", limit: 30, default: "", null: false
  379. t.string "name", limit: 255, default: "", null: false
  380. t.text "description", default: "", null: false
  381. t.decimal "price_base", precision: 10, scale: 2, default: 0.0
  382. t.decimal "price_sale", precision: 10, scale: 2, default: 0.0
  383. t.string "img_product_file_name"
  384. t.string "img_product_content_type"
  385. t.integer "img_product_file_size"
  386. t.datetime "img_product_updated_at"
  387. t.boolean "presentation", default: false, null: false
  388. t.boolean "inventory", default: true, null: false
  389. t.decimal "content"
  390. t.integer "status", default: 1, null: false
  391. t.datetime "created_at", null: false
  392. t.datetime "updated_at", null: false
  393. t.integer "unit_id"
  394. t.integer "include_purchase_tax", default: 0, null: false
  395. t.integer "include_sale_tax", default: 0, null: false
  396. t.string "barcode"
  397. t.integer "parent_id"
  398. t.text "attributes_json"
  399. t.boolean "is_parent", default: false
  400. t.boolean "is_in_dollars", default: false
  401. t.decimal "price_base_dollars", precision: 10, scale: 2
  402. t.string "img_product"
  403. end
  404. add_index "products", ["unit_id"], name: "index_products_on_unit_id", using: :btree
  405. create_table "products_return_ins", force: :cascade do |t|
  406. t.integer "products_return_id"
  407. t.integer "product_id", null: false
  408. t.decimal "quantity", null: false
  409. t.string "reason"
  410. t.boolean "is_wasted", default: false
  411. t.decimal "amount", default: 0.0
  412. t.datetime "created_at", null: false
  413. t.datetime "updated_at", null: false
  414. end
  415. add_index "products_return_ins", ["product_id"], name: "index_products_return_ins_on_product_id", using: :btree
  416. add_index "products_return_ins", ["products_return_id"], name: "index_products_return_ins_on_products_return_id", using: :btree
  417. create_table "products_return_outs", force: :cascade do |t|
  418. t.integer "products_return_id"
  419. t.integer "product_id", null: false
  420. t.decimal "quantity", null: false
  421. t.decimal "amount", default: 0.0
  422. t.datetime "created_at", null: false
  423. t.datetime "updated_at", null: false
  424. end
  425. add_index "products_return_outs", ["product_id"], name: "index_products_return_outs_on_product_id", using: :btree
  426. add_index "products_return_outs", ["products_return_id"], name: "index_products_return_outs_on_products_return_id", using: :btree
  427. create_table "products_returns", force: :cascade do |t|
  428. t.integer "sale_id"
  429. t.integer "user_id"
  430. t.string "return_code", null: false
  431. t.datetime "created_at", null: false
  432. t.datetime "updated_at", null: false
  433. t.integer "pointsale_id", null: false
  434. t.decimal "new_amount", precision: 10, scale: 2, default: 0.0
  435. t.decimal "returned_amount", precision: 10, scale: 2, default: 0.0
  436. t.decimal "difference_amount", precision: 10, scale: 2, default: 0.0
  437. t.boolean "is_money_returned", default: false
  438. end
  439. add_index "products_returns", ["sale_id"], name: "index_products_returns_on_sale_id", using: :btree
  440. add_index "products_returns", ["user_id"], name: "index_products_returns_on_user_id", using: :btree
  441. create_table "products_variants", force: :cascade do |t|
  442. t.integer "product_id"
  443. t.text "attributes_json", null: false
  444. t.string "sku", limit: 30, default: "", null: false
  445. t.string "barcode"
  446. t.decimal "price_sale", precision: 10, scale: 2
  447. t.integer "status"
  448. t.datetime "created_at", null: false
  449. t.datetime "updated_at", null: false
  450. end
  451. add_index "products_variants", ["product_id"], name: "index_products_variants_on_product_id", using: :btree
  452. create_table "promotions", force: :cascade do |t|
  453. t.date "start_date", null: false
  454. t.date "end_date", null: false
  455. t.decimal "percent", default: 0.0
  456. t.integer "product_id"
  457. t.integer "category_id"
  458. t.integer "user_id"
  459. t.integer "status", default: 1, null: false
  460. t.datetime "created_at", null: false
  461. t.datetime "updated_at", null: false
  462. t.integer "subcategory_id"
  463. end
  464. add_index "promotions", ["category_id"], name: "index_promotions_on_category_id", using: :btree
  465. add_index "promotions", ["product_id"], name: "index_promotions_on_product_id", using: :btree
  466. add_index "promotions", ["user_id"], name: "index_promotions_on_user_id", using: :btree
  467. create_table "purchase_details", force: :cascade do |t|
  468. t.integer "purchase_id"
  469. t.integer "product_id"
  470. t.integer "quantity"
  471. t.decimal "price", precision: 10, scale: 2, default: 0.0, null: false
  472. t.decimal "amount", precision: 10, scale: 2, default: 0.0, null: false
  473. t.datetime "created_at", null: false
  474. t.datetime "updated_at", null: false
  475. t.integer "status", default: 1, null: false
  476. t.decimal "tax", null: false
  477. end
  478. add_index "purchase_details", ["product_id"], name: "index_purchase_details_on_product_id", using: :btree
  479. add_index "purchase_details", ["purchase_id"], name: "index_purchase_details_on_purchase_id", using: :btree
  480. create_table "purchases", force: :cascade do |t|
  481. t.integer "supplier_id"
  482. t.integer "pointsale_id"
  483. t.string "purchase_code"
  484. t.decimal "amount", precision: 10, scale: 2, default: 0.0
  485. t.decimal "tax", precision: 10, scale: 2, default: 0.0
  486. t.decimal "total", precision: 10, scale: 2, default: 0.0
  487. t.text "observations"
  488. t.date "purchase_date"
  489. t.string "user_id"
  490. t.datetime "created_at", null: false
  491. t.datetime "updated_at", null: false
  492. t.integer "status", default: 0, null: false
  493. t.integer "warehouse_id"
  494. t.boolean "is_in_dollars", default: false
  495. t.decimal "exchange", precision: 10, scale: 2
  496. end
  497. create_table "sales", force: :cascade do |t|
  498. t.integer "customer_id"
  499. t.integer "user_id"
  500. t.integer "open_cash_register_id"
  501. t.decimal "amount", precision: 10, scale: 2, default: 0.0, null: false
  502. t.decimal "tax", precision: 10, scale: 2, default: 0.0, null: false
  503. t.decimal "discount", precision: 10, scale: 2, default: 0.0, null: false
  504. t.decimal "total", precision: 10, scale: 2, default: 0.0, null: false
  505. t.integer "status", default: 1, null: false
  506. t.date "date_sale", null: false
  507. t.datetime "created_at", null: false
  508. t.datetime "updated_at", null: false
  509. t.integer "saletype", limit: 2
  510. t.integer "seller_id"
  511. t.string "sale_code"
  512. t.date "expiration_date"
  513. t.string "credit_note"
  514. end
  515. add_index "sales", ["customer_id"], name: "index_sales_on_customer_id", using: :btree
  516. add_index "sales", ["open_cash_register_id"], name: "index_sales_on_open_cash_register_id", using: :btree
  517. add_index "sales", ["user_id"], name: "index_sales_on_user_id", using: :btree
  518. create_table "sales_details", force: :cascade do |t|
  519. t.integer "sale_id"
  520. t.integer "product_id"
  521. t.decimal "quantity", null: false
  522. t.decimal "amount", precision: 10, scale: 2, default: 0.0, null: false
  523. t.decimal "tax", precision: 10, scale: 2, default: 0.0, null: false
  524. t.decimal "discount", precision: 10, scale: 2, default: 0.0, null: false
  525. t.decimal "total", precision: 10, scale: 2, default: 0.0, null: false
  526. t.integer "status", default: 1, null: false
  527. t.datetime "created_at", null: false
  528. t.datetime "updated_at", null: false
  529. t.integer "special_price_id"
  530. t.decimal "unit_price", precision: 10, scale: 2
  531. t.decimal "unit_price_w_discount", precision: 10, scale: 2
  532. t.decimal "haggle", precision: 10, scale: 2, default: 0.0
  533. t.decimal "haggle_percent", precision: 10, scale: 2, default: 0.0
  534. end
  535. add_index "sales_details", ["product_id"], name: "index_sales_details_on_product_id", using: :btree
  536. add_index "sales_details", ["sale_id"], name: "index_sales_details_on_sale_id", using: :btree
  537. create_table "sales_sellercommissions", force: :cascade do |t|
  538. t.integer "sellerscommission_id"
  539. t.integer "sale_id"
  540. t.datetime "created_at", null: false
  541. t.datetime "updated_at", null: false
  542. end
  543. add_index "sales_sellercommissions", ["sale_id"], name: "index_sales_sellercommissions_on_sale_id", using: :btree
  544. add_index "sales_sellercommissions", ["sellerscommission_id"], name: "index_sales_sellercommissions_on_sellerscommission_id", using: :btree
  545. create_table "sellers", force: :cascade do |t|
  546. t.integer "pointsale_id"
  547. t.string "name", null: false
  548. t.string "last_name", null: false
  549. t.integer "status", default: 1, null: false
  550. t.datetime "created_at", null: false
  551. t.datetime "updated_at", null: false
  552. end
  553. add_index "sellers", ["pointsale_id"], name: "index_sellers_on_pointsale_id", using: :btree
  554. create_table "sellerscommissions", force: :cascade do |t|
  555. t.integer "commission_id"
  556. t.integer "seller_id"
  557. t.integer "num_sales"
  558. t.decimal "sales_total"
  559. t.decimal "commission_calculated"
  560. t.decimal "commission_paid"
  561. t.datetime "created_at", null: false
  562. t.datetime "updated_at", null: false
  563. t.integer "commission_percent"
  564. t.decimal "total_sold_cash", precision: 10, scale: 2, default: 0.0
  565. t.decimal "total_sold_credits_apartments", precision: 10, scale: 2, default: 0.0
  566. t.decimal "income_by_cash", precision: 10, scale: 2, default: 0.0
  567. t.decimal "income_by_reserved_and_credits", precision: 10, scale: 2, default: 0.0
  568. end
  569. add_index "sellerscommissions", ["commission_id"], name: "index_sellerscommissions_on_commission_id", using: :btree
  570. add_index "sellerscommissions", ["seller_id"], name: "index_sellerscommissions_on_seller_id", using: :btree
  571. create_table "special_prices", force: :cascade do |t|
  572. t.integer "product_id"
  573. t.integer "customer_id"
  574. t.decimal "price", precision: 10, scale: 2
  575. t.decimal "percent"
  576. t.integer "status", default: 1, null: false
  577. t.datetime "created_at", null: false
  578. t.datetime "updated_at", null: false
  579. t.integer "user_id"
  580. end
  581. add_index "special_prices", ["customer_id"], name: "index_special_prices_on_customer_id", using: :btree
  582. add_index "special_prices", ["product_id"], name: "index_special_prices_on_product_id", using: :btree
  583. create_table "spmx_counties", force: :cascade do |t|
  584. t.integer "id_", null: false
  585. t.integer "state_id"
  586. t.string "name", null: false
  587. end
  588. add_index "spmx_counties", ["state_id"], name: "index_spmx_counties_on_state_id", using: :btree
  589. create_table "spmx_states", force: :cascade do |t|
  590. t.string "name", null: false
  591. end
  592. create_table "storers", force: :cascade do |t|
  593. t.integer "user_id"
  594. t.integer "warehouse_id"
  595. t.string "name", null: false
  596. t.string "last_name", null: false
  597. t.integer "status", default: 1, null: false
  598. t.datetime "created_at", null: false
  599. t.datetime "updated_at", null: false
  600. end
  601. add_index "storers", ["user_id"], name: "index_storers_on_user_id", using: :btree
  602. add_index "storers", ["warehouse_id"], name: "index_storers_on_warehouse_id", using: :btree
  603. create_table "suppliers", force: :cascade do |t|
  604. t.string "nick_name", limit: 255, default: "", null: false
  605. t.string "phone", limit: 30, default: "", null: false
  606. t.string "email", limit: 255, default: "", null: false
  607. t.text "notes", default: "", null: false
  608. t.integer "contact_id"
  609. t.integer "status", default: 1, null: false
  610. t.datetime "created_at", null: false
  611. t.datetime "updated_at", null: false
  612. end
  613. add_index "suppliers", ["contact_id"], name: "index_suppliers_on_contact_id", using: :btree
  614. create_table "taggings", force: :cascade do |t|
  615. t.integer "tag_id"
  616. t.integer "taggable_id"
  617. t.string "taggable_type"
  618. t.integer "tagger_id"
  619. t.string "tagger_type"
  620. t.string "context", limit: 128
  621. t.datetime "created_at"
  622. end
  623. add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true, using: :btree
  624. add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree
  625. create_table "tags", force: :cascade do |t|
  626. t.string "name"
  627. t.integer "taggings_count", default: 0
  628. end
  629. add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree
  630. create_table "transfer_details", force: :cascade do |t|
  631. t.integer "transfer_id"
  632. t.integer "product_id"
  633. t.decimal "quantity", precision: 10, scale: 2, default: 0.0, null: false
  634. t.integer "status", default: 1, null: false
  635. t.datetime "created_at", null: false
  636. t.datetime "updated_at", null: false
  637. t.integer "adjustment"
  638. t.integer "has_looses", default: 0
  639. t.integer "has_surplus", default: 0
  640. end
  641. add_index "transfer_details", ["product_id"], name: "index_transfer_details_on_product_id", using: :btree
  642. add_index "transfer_details", ["transfer_id"], name: "index_transfer_details_on_transfer_id", using: :btree
  643. create_table "transfers", force: :cascade do |t|
  644. t.integer "origin_id"
  645. t.integer "destiny_id"
  646. t.date "transfer_date", null: false
  647. t.integer "user_id"
  648. t.integer "status", default: 1, null: false
  649. t.integer "received_by_id"
  650. t.datetime "created_at", null: false
  651. t.datetime "updated_at", null: false
  652. t.text "observations"
  653. t.date "reception_date"
  654. t.integer "origin_is_pointsale", null: false
  655. t.integer "destiny_is_pointsale", null: false
  656. end
  657. add_index "transfers", ["destiny_id"], name: "index_transfers_on_destiny_id", using: :btree
  658. add_index "transfers", ["origin_id"], name: "index_transfers_on_origin_id", using: :btree
  659. add_index "transfers", ["received_by_id"], name: "index_transfers_on_received_by_id", using: :btree
  660. add_index "transfers", ["user_id"], name: "index_transfers_on_user_id", using: :btree
  661. create_table "units", force: :cascade do |t|
  662. t.string "unit"
  663. t.integer "status"
  664. t.datetime "created_at", null: false
  665. t.datetime "updated_at", null: false
  666. end
  667. create_table "users", force: :cascade do |t|
  668. t.string "userid", default: "", null: false
  669. t.string "first_name", default: "", null: false
  670. t.string "last_name", default: "", null: false
  671. t.string "usertype", default: "", null: false
  672. t.string "email", default: "", null: false
  673. t.string "encrypted_password", default: "", null: false
  674. t.string "reset_password_token"
  675. t.datetime "reset_password_sent_at"
  676. t.datetime "remember_created_at"
  677. t.integer "sign_in_count", default: 0, null: false
  678. t.datetime "current_sign_in_at"
  679. t.datetime "last_sign_in_at"
  680. t.inet "current_sign_in_ip"
  681. t.inet "last_sign_in_ip"
  682. t.datetime "created_at", null: false
  683. t.datetime "updated_at", null: false
  684. t.integer "pointsale_id"
  685. t.string "unique_session_id", limit: 20
  686. t.integer "status", default: 1, null: false
  687. t.integer "warehouse_id"
  688. end
  689. add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
  690. add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
  691. add_index "users", ["userid"], name: "index_users_on_userid", unique: true, using: :btree
  692. create_table "warehouse_stocks", force: :cascade do |t|
  693. t.integer "warehouse_id"
  694. t.integer "product_id"
  695. t.decimal "stock_min", default: 0.0
  696. t.decimal "stock_max", default: 0.0
  697. t.decimal "stock", default: 0.0
  698. t.datetime "created_at", null: false
  699. t.datetime "updated_at", null: false
  700. end
  701. add_index "warehouse_stocks", ["product_id"], name: "index_warehouse_stocks_on_product_id", using: :btree
  702. add_index "warehouse_stocks", ["warehouse_id"], name: "index_warehouse_stocks_on_warehouse_id", using: :btree
  703. create_table "warehouses", force: :cascade do |t|
  704. t.datetime "created_at", null: false
  705. t.datetime "updated_at", null: false
  706. t.string "name"
  707. t.integer "status", default: 1, null: false
  708. t.string "prefix", null: false
  709. end
  710. add_foreign_key "suppliers", "contacts"
  711. end