schema.rb 42 KB

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