schema.rb 42 KB

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