shop_setup branch
This commit is contained in:
7
app/forms/shop_form.rb
Normal file
7
app/forms/shop_form.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#Form object to use during the installation process - will handle creation of shop model into db after verification from the cloud
|
||||||
|
#provising service through license verification
|
||||||
|
|
||||||
|
class ShopForm < ActiveModel
|
||||||
|
:attr_accessor :logo, :name, :address, :township, :city, :state, :country, :license, :base_currency, :password, :password_confirmation
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
class Booking < ApplicationRecord
|
class Booking < ApplicationRecord
|
||||||
|
#primary key - need to be unique
|
||||||
|
|
||||||
belongs_to :dining_facility, :optional => true
|
belongs_to :dining_facility, :optional => true
|
||||||
belongs_to :sale, :optional => true
|
belongs_to :sale, :optional => true
|
||||||
has_many :booking_orders
|
has_many :booking_orders
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
class BookingOrder < ApplicationRecord
|
class BookingOrder < ApplicationRecord
|
||||||
|
#primary key - need to be unique
|
||||||
|
|
||||||
belongs_to :booking
|
belongs_to :booking
|
||||||
belongs_to :order
|
belongs_to :order
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
class Order < ApplicationRecord
|
class Order < ApplicationRecord
|
||||||
|
#primary key - need to be unique
|
||||||
|
|
||||||
before_create :set_order_date
|
before_create :set_order_date
|
||||||
|
|
||||||
belongs_to :customer
|
belongs_to :customer
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
class OrderItem < ApplicationRecord
|
class OrderItem < ApplicationRecord
|
||||||
|
#primary key - need to be unique
|
||||||
|
|
||||||
#Associations
|
#Associations
|
||||||
belongs_to :order, autosave: true
|
belongs_to :order, autosave: true
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#primary key - need to be unique generated for multiple shops
|
||||||
|
|
||||||
class Sale < ApplicationRecord
|
class Sale < ApplicationRecord
|
||||||
#before_create :generate_receipt_no
|
#before_create :generate_receipt_no
|
||||||
belongs_to :cashier, :optional => true
|
belongs_to :cashier, :optional => true
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
class SaleAudit < ApplicationRecord
|
class SaleAudit < ApplicationRecord
|
||||||
|
#primary key - need to be unique generated for multiple shops
|
||||||
|
|
||||||
belongs_to :sale
|
belongs_to :sale
|
||||||
|
|
||||||
def record_audit_void(sale_id, void_by, approved_by, reason)
|
def record_audit_void(sale_id, void_by, approved_by, reason)
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
class SaleItem < ApplicationRecord
|
class SaleItem < ApplicationRecord
|
||||||
|
#primary key - need to be unique generated for multiple shops
|
||||||
|
|
||||||
belongs_to :sale
|
belongs_to :sale
|
||||||
|
|
||||||
#compute items - discount, tax, price_change
|
#compute items - discount, tax, price_change
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
class SaleOrder < ApplicationRecord
|
class SaleOrder < ApplicationRecord
|
||||||
|
#primary key - need to be unique generated for multiple shops
|
||||||
|
|
||||||
belongs_to :sale
|
belongs_to :sale
|
||||||
belongs_to :order
|
belongs_to :order
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
class SalePayment < ApplicationRecord
|
class SalePayment < ApplicationRecord
|
||||||
|
#primary key - need to be unique generated for multiple shops
|
||||||
|
|
||||||
belongs_to :sale
|
belongs_to :sale
|
||||||
|
|
||||||
:attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status
|
:attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
class SaleTax < ApplicationRecord
|
class SaleTax < ApplicationRecord
|
||||||
|
#primary key - need to be unique generated for multiple shops
|
||||||
|
|
||||||
belongs_to :sale
|
belongs_to :sale
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,23 @@
|
|||||||
class SeedGenerator < ApplicationRecord
|
class SeedGenerator < ApplicationRecord
|
||||||
|
def self.generate_id(model, prefix)
|
||||||
|
seed = SeedGenerator.find_by_model(model)
|
||||||
|
new_receipt_no = 0
|
||||||
|
if (seed.nil?)
|
||||||
|
seed = SeedGenerator.new()
|
||||||
|
seed.model = model
|
||||||
|
new_receipt_no = seed.next
|
||||||
|
seed.save
|
||||||
|
|
||||||
|
else
|
||||||
|
current_no = seed.next
|
||||||
|
seed.next = seed.next + seed.increase_by
|
||||||
|
seed.current = current_no
|
||||||
|
seed.save
|
||||||
|
end
|
||||||
|
|
||||||
|
return prefix + "-" + seed.current.to_s
|
||||||
|
end
|
||||||
|
|
||||||
def self.new_receipt_no
|
def self.new_receipt_no
|
||||||
seed = SeedGenerator.find_by_model("sale")
|
seed = SeedGenerator.find_by_model("sale")
|
||||||
new_receipt_no = 0
|
new_receipt_no = 0
|
||||||
|
|||||||
2
app/models/shop.rb
Normal file
2
app/models/shop.rb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
class Shop < ApplicationRecord
|
||||||
|
end
|
||||||
@@ -7,7 +7,7 @@ class CreateSalePayments < ActiveRecord::Migration[5.0]
|
|||||||
t.decimal :outstanding_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
t.decimal :outstanding_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00
|
||||||
t.string :payment_reference
|
t.string :payment_reference
|
||||||
t.string :payment_status, :null => false, :default => "new"
|
t.string :payment_status, :null => false, :default => "new"
|
||||||
|
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ class CreateSeedGenerators < ActiveRecord::Migration[5.0]
|
|||||||
t.integer :increase_by, :null => false, :default => 1
|
t.integer :increase_by, :null => false, :default => 1
|
||||||
t.bigint :current, :null => false ,:default => 1
|
t.bigint :current, :null => false ,:default => 1
|
||||||
t.bigint :next, :null => false, :default => 2
|
t.bigint :next, :null => false, :default => 2
|
||||||
|
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
25
db/migrate/20170530072247_create_shops.rb
Normal file
25
db/migrate/20170530072247_create_shops.rb
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
class CreateShops < ActiveRecord::Migration[5.1]
|
||||||
|
def change
|
||||||
|
create_table :shops do |t|
|
||||||
|
t.string :logo
|
||||||
|
t.string :name, :null => false
|
||||||
|
t.string :address, :null => false
|
||||||
|
t.string :township, :null => false
|
||||||
|
t.string :city, :null => false
|
||||||
|
t.string :state, :null => false
|
||||||
|
t.string :country, :null => false
|
||||||
|
t.string :phone_no, :null => false
|
||||||
|
t.string :reserviation_no, :null => false
|
||||||
|
t.string :license, :null => false
|
||||||
|
t.datetime :activated_at, :null => false
|
||||||
|
t.text :license_data, :null => false
|
||||||
|
t.string :base_currency, :null => false, :limit => 3
|
||||||
|
t.string :cloud_url
|
||||||
|
t.string :cloud_token
|
||||||
|
t.string :owner_token
|
||||||
|
t.string :id_prefix, :null => false, :limit => 3
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
5
spec/models/shop_spec.rb
Normal file
5
spec/models/shop_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Shop, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user