comee_core 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +10 -0
- data/app/controllers/comee/core/access_controller.rb +33 -0
- data/app/controllers/comee/core/application_controller.rb +43 -0
- data/app/controllers/comee/core/currencies_controller.rb +13 -0
- data/app/controllers/comee/core/notifications_controller.rb +38 -0
- data/app/controllers/comee/core/product_types_controller.rb +18 -0
- data/app/controllers/comee/core/products_controller.rb +13 -0
- data/app/controllers/comee/core/suppliers_controller.rb +13 -0
- data/app/controllers/comee/core/units_controller.rb +13 -0
- data/app/controllers/comee/core/users_controller.rb +13 -0
- data/app/controllers/concerns/comee/core/common.rb +73 -0
- data/app/jobs/comee_core/application_job.rb +4 -0
- data/app/mailers/comee/core/application_mailer.rb +8 -0
- data/app/mailers/comee/core/supplier_mailer.rb +18 -0
- data/app/models/comee/core/application_record.rb +7 -0
- data/app/models/comee/core/back_order.rb +33 -0
- data/app/models/comee/core/back_order_item.rb +16 -0
- data/app/models/comee/core/client.rb +10 -0
- data/app/models/comee/core/client_order.rb +23 -0
- data/app/models/comee/core/client_order_item.rb +10 -0
- data/app/models/comee/core/client_price.rb +20 -0
- data/app/models/comee/core/currency.rb +8 -0
- data/app/models/comee/core/invoice.rb +23 -0
- data/app/models/comee/core/invoice_item.rb +18 -0
- data/app/models/comee/core/master_price.rb +35 -0
- data/app/models/comee/core/notification.rb +17 -0
- data/app/models/comee/core/product.rb +47 -0
- data/app/models/comee/core/product_lookup.rb +10 -0
- data/app/models/comee/core/product_type.rb +19 -0
- data/app/models/comee/core/supplier.rb +10 -0
- data/app/models/comee/core/unit.rb +10 -0
- data/app/models/comee/core/user.rb +13 -0
- data/app/notifications/comee/core/new_order_notification.rb +23 -0
- data/app/serializers/comee/core/currency_serializer.rb +7 -0
- data/app/serializers/comee/core/product_serializer.rb +8 -0
- data/app/serializers/comee/core/product_type_serializer.rb +7 -0
- data/app/serializers/comee/core/supplier_serializer.rb +7 -0
- data/app/serializers/comee/core/unit_serializer.rb +7 -0
- data/app/serializers/comee/core/user_serializer.rb +7 -0
- data/app/services/comee/core/product_lookup_service.rb +38 -0
- data/app/services/comee/core/token_service.rb +13 -0
- data/app/utils/comee/core/period.rb +35 -0
- data/app/views/comee/core/supplier_mailer/new_order_notification.html.erb +8 -0
- data/app/views/layouts/comee/core/mailer.html.erb +13 -0
- data/app/views/layouts/comee/core/mailer.text.erb +1 -0
- data/config/locales/de.yml +13 -0
- data/config/locales/en.yml +13 -0
- data/config/routes.rb +21 -0
- data/config/spring.rb +1 -0
- data/db/migrate/20230727153013_create_comee_core_units.rb +12 -0
- data/db/migrate/20230728011037_create_comee_core_currencies.rb +11 -0
- data/db/migrate/20230728012836_create_comee_core_product_types.rb +13 -0
- data/db/migrate/20230728014322_create_comee_core_products.rb +21 -0
- data/db/migrate/20230728014330_create_comee_core_users.rb +14 -0
- data/db/migrate/20230728122618_create_comee_core_suppliers.rb +17 -0
- data/db/migrate/20230728123039_create_comee_core_clients.rb +18 -0
- data/db/migrate/20230728123928_create_comee_core_back_orders.rb +20 -0
- data/db/migrate/20230728125723_create_comee_core_back_order_items.rb +22 -0
- data/db/migrate/20230730061225_create_comee_core_notifications.rb +13 -0
- data/db/migrate/20230812190652_create_comee_core_client_orders.rb +24 -0
- data/db/migrate/20230812212844_create_comee_core_client_order_items.rb +18 -0
- data/db/migrate/20230813235946_create_comee_core_master_prices.rb +26 -0
- data/db/migrate/20230814151601_create_comee_core_client_prices.rb +23 -0
- data/db/migrate/20230914041307_create_comee_core_external_products.rb +18 -0
- data/db/migrate/20230915205522_create_comee_core_invoices.rb +24 -0
- data/db/migrate/20230915205648_create_comee_core_invoice_items.rb +19 -0
- data/lib/comee/core/engine.rb +24 -0
- data/lib/comee/core/version.rb +5 -0
- data/lib/comee/core.rb +4 -0
- data/lib/comee_core.rb +6 -0
- data/lib/tasks/comee_core_tasks.rake +4 -0
- data/spec/factories/comee/core/back_order_items.rb +11 -0
- data/spec/factories/comee/core/back_orders.rb +13 -0
- data/spec/factories/comee/core/client_order_items.rb +8 -0
- data/spec/factories/comee/core/client_orders.rb +13 -0
- data/spec/factories/comee/core/client_prices.rb +12 -0
- data/spec/factories/comee/core/clients.rb +9 -0
- data/spec/factories/comee/core/currencies.rb +6 -0
- data/spec/factories/comee/core/invoice_items.rb +9 -0
- data/spec/factories/comee/core/invoices.rb +16 -0
- data/spec/factories/comee/core/master_prices.rb +15 -0
- data/spec/factories/comee/core/notifications.rb +8 -0
- data/spec/factories/comee/core/product_lookups.rb +7 -0
- data/spec/factories/comee/core/product_types.rb +8 -0
- data/spec/factories/comee/core/products.rb +10 -0
- data/spec/factories/comee/core/suppliers.rb +9 -0
- data/spec/factories/comee/core/units.rb +7 -0
- data/spec/factories/comee/core/users.rb +9 -0
- metadata +346 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Comee
|
|
2
|
+
module Core
|
|
3
|
+
class ProductType < ApplicationRecord
|
|
4
|
+
validates :code, presence: true, uniqueness: true
|
|
5
|
+
validates :name, presence: true
|
|
6
|
+
validate :required_fields_must_be_in_properties
|
|
7
|
+
|
|
8
|
+
def required_fields_must_be_in_properties
|
|
9
|
+
return unless metadata_schema.present?
|
|
10
|
+
|
|
11
|
+
diff = metadata_schema["required"] - metadata_schema["properties"].keys
|
|
12
|
+
return unless diff.count.positive?
|
|
13
|
+
|
|
14
|
+
error = "The following fields are mentioned as required but do not exist in the field list: #{diff}."
|
|
15
|
+
errors.add(:base, error)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Comee
|
|
2
|
+
module Core
|
|
3
|
+
class User < ApplicationRecord
|
|
4
|
+
enum :user_type, {supplier: 0, admin: 1}
|
|
5
|
+
|
|
6
|
+
has_secure_password
|
|
7
|
+
has_many :notifications, as: :recipient, dependent: :destroy
|
|
8
|
+
|
|
9
|
+
validates :name, :email, :user_type, presence: true
|
|
10
|
+
validates :email, uniqueness: true
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Comee
|
|
2
|
+
module Core
|
|
3
|
+
class NewOrderNotification < Noticed::Base
|
|
4
|
+
deliver_by :database
|
|
5
|
+
deliver_by :email, mailer: "Comee::Core::SupplierMailer", method: :new_order_notification
|
|
6
|
+
|
|
7
|
+
param :back_order
|
|
8
|
+
|
|
9
|
+
def message
|
|
10
|
+
back_order = params[:back_order]
|
|
11
|
+
title = "New Order Notification"
|
|
12
|
+
date = Date.current
|
|
13
|
+
content = <<~CONTENT
|
|
14
|
+
A new purchase order with the following details has been sent to you:
|
|
15
|
+
order number: #{back_order.order_number}
|
|
16
|
+
order date: #{back_order.order_date}
|
|
17
|
+
delivery date: #{back_order.delivery_date}
|
|
18
|
+
CONTENT
|
|
19
|
+
{title:, date:, content:}
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Comee
|
|
2
|
+
module Core
|
|
3
|
+
class ProductLookupService
|
|
4
|
+
ORGANIZATION = "ORG".freeze
|
|
5
|
+
##
|
|
6
|
+
# This method returns a translated code for a given +code+. The +code+ can be
|
|
7
|
+
# for a supplier or a client. The source of the +code+ is described using the +from+
|
|
8
|
+
# parameter. The +from+ parameter is a has which specifies the id of the source
|
|
9
|
+
# supplier/client as `itemable_id`, and the data type of the source as itemable_type.
|
|
10
|
+
# We specify the id and type because the ProductLookup model has a polymorphic relationship
|
|
11
|
+
# with supplier and client.
|
|
12
|
+
#
|
|
13
|
+
# The +to+ parameter uses a similar format to specify the target supplier/client we want to
|
|
14
|
+
# conduct the lookup for.
|
|
15
|
+
def lookup_product(code, from, to)
|
|
16
|
+
error = "The 'from' parameter cannot be assigned any string other than '#{ORGANIZATION}'."
|
|
17
|
+
raise(StandardError, error) if from.instance_of?(String) && from != ORGANIZATION
|
|
18
|
+
|
|
19
|
+
error = "The 'to' parameter cannot be assigned any string other than '#{ORGANIZATION}'."
|
|
20
|
+
raise(StandardError, error) if to.instance_of?(String) && to != ORGANIZATION
|
|
21
|
+
|
|
22
|
+
if from == ORGANIZATION
|
|
23
|
+
query = ProductLookup.joins(:product).find_by(product: {code:}, **to)
|
|
24
|
+
return query.code
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
if to == ORGANIZATION
|
|
28
|
+
product = ProductLookup.find_by(code: code, **from).product
|
|
29
|
+
return product.code
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
product = ProductLookup.find_by(code: code, **from).product
|
|
33
|
+
query = ProductLookup.find_by(product: product, **to)
|
|
34
|
+
query.code
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Comee
|
|
2
|
+
module Core
|
|
3
|
+
class TokenService
|
|
4
|
+
def self.issue(payload)
|
|
5
|
+
JWT.encode(payload, ENV["SECRET_KEY"], "HS256")
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def self.decode(token)
|
|
9
|
+
JWT.decode(token, ENV["SECRET_KEY"], true, algorithm: "HS256").first
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Comee
|
|
2
|
+
module Core
|
|
3
|
+
class Period
|
|
4
|
+
attr_accessor :start, :finish
|
|
5
|
+
def initialize(start, finish)
|
|
6
|
+
@start = start
|
|
7
|
+
@finish = finish
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def valid?
|
|
11
|
+
finish > start
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def contains?(period)
|
|
15
|
+
return true if start <= period.start && finish >= period.finish
|
|
16
|
+
|
|
17
|
+
false
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def contained_by?(period)
|
|
21
|
+
return true if start >= period.start && finish <= period.finish
|
|
22
|
+
|
|
23
|
+
false
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def overlaps?(period)
|
|
27
|
+
return true if period.start <= start && start <= period.finish
|
|
28
|
+
|
|
29
|
+
return true if start <= period.start && period.start <= finish
|
|
30
|
+
|
|
31
|
+
false
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<p><%= t(".greeting") %></p>
|
|
2
|
+
<p><%= t(".entry", link: "http://localhost:4200/order-management/confirmation/#{@back_order.id}", order_number: @back_order.order_number) %><p>
|
|
3
|
+
<p><%= t(".feedback", next_day: Date.current.advance(days: 1)) %>
|
|
4
|
+
</p><%= t(".delivery", delivery_address: @back_order.delivery_address) %>
|
|
5
|
+
<p><%= t(".invoice", invoice_address: @back_order.invoice_address) %></p>
|
|
6
|
+
<p><%= t(".telephone") %></p>
|
|
7
|
+
<p><%= t(".thanks") %></p>
|
|
8
|
+
<p><%= t(".closing") %></p>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= yield %>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
de:
|
|
2
|
+
comee:
|
|
3
|
+
core:
|
|
4
|
+
supplier_mailer:
|
|
5
|
+
new_order_notification:
|
|
6
|
+
greeting: "Sehr geehrte Damen und Herren,"
|
|
7
|
+
entry: "Bitte besuchen Sie den %{link}, um unser '%{order_number}' zu finden."
|
|
8
|
+
feedback: "Wir bitten um Rückmeldung bis zum %{next_day} (the next day)."
|
|
9
|
+
delivery: "Die Warenannahme findet an der Adresse %{delivery_address} statt und erfolgt von Montag bis Freitag im Zeitraum von 07:00 – 16:00 Uhr."
|
|
10
|
+
invoice: "Die Büro-/Rechnungsadresse lautet %{invoice_address}."
|
|
11
|
+
telephone: "Unsere neue Telefon-Nr. lautet +49 (0) 40-98256170"
|
|
12
|
+
thanks: "Vielen Dank im Voraus."
|
|
13
|
+
closing: "Beste Grüße"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
en:
|
|
2
|
+
comee:
|
|
3
|
+
core:
|
|
4
|
+
supplier_mailer:
|
|
5
|
+
new_order_notification:
|
|
6
|
+
greeting: "Dear Ladies and Gentlemen,"
|
|
7
|
+
entry: "Please visit %{link} to find our '%{order_number}'."
|
|
8
|
+
feedback: "We kindly ask for feedback by %{next_day} (the next day)."
|
|
9
|
+
delivery: "Please take note that the goods receipt will take place at the address %{delivery_address} from Monday to Friday in the time frame from 07:00 - 16:00 o'clock."
|
|
10
|
+
invoice: "The office billing address is %{invoice_address}."
|
|
11
|
+
telephone: "Our new telephone number is: +49 (0) 40-98256170"
|
|
12
|
+
thanks: "Thank you in advance."
|
|
13
|
+
closing: "Best regards"
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Comee::Core::Engine.routes.draw do
|
|
2
|
+
post "/login", controller: :access, action: :login
|
|
3
|
+
get "/notifications/unread", controller: :notifications, action: :unread
|
|
4
|
+
get "/notifications/read", controller: :notifications, action: :read
|
|
5
|
+
resources :notifications, only: [:index] do
|
|
6
|
+
member do
|
|
7
|
+
post "mark_as_read", controller: :notifications, action: :mark_as_read
|
|
8
|
+
post "mark_as_unread", controller: :notifications, action: :mark_as_unread
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
resources :suppliers
|
|
12
|
+
resources :products
|
|
13
|
+
resources :product_types do
|
|
14
|
+
member do
|
|
15
|
+
get "products", controller: :product_types, action: :products
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
resources :currencies
|
|
19
|
+
resources :units
|
|
20
|
+
resources :users
|
|
21
|
+
end
|
data/config/spring.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Spring.application_root = "spec/dummy"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class CreateComeeCoreUnits < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :comee_core_units do |t|
|
|
4
|
+
t.string :code, null: false
|
|
5
|
+
t.string :name, null: false
|
|
6
|
+
t.integer :unit_type, null: false, default: 0
|
|
7
|
+
|
|
8
|
+
t.timestamps
|
|
9
|
+
end
|
|
10
|
+
add_index :comee_core_units, :code, unique: true
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class CreateComeeCoreCurrencies < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :comee_core_currencies do |t|
|
|
4
|
+
t.string :code, null: false
|
|
5
|
+
t.string :name, null: false
|
|
6
|
+
|
|
7
|
+
t.timestamps
|
|
8
|
+
end
|
|
9
|
+
add_index :comee_core_currencies, :code, unique: true
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class CreateComeeCoreProductTypes < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :comee_core_product_types do |t|
|
|
4
|
+
t.string :code, null: false
|
|
5
|
+
t.string :name, null: false
|
|
6
|
+
t.string :description
|
|
7
|
+
t.jsonb :metadata_schema, default: {}
|
|
8
|
+
|
|
9
|
+
t.timestamps
|
|
10
|
+
end
|
|
11
|
+
add_index :comee_core_product_types, :code, unique: true
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
class CreateComeeCoreProducts < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :comee_core_products do |t|
|
|
4
|
+
t.string :code, null: false
|
|
5
|
+
t.string :name, null: false
|
|
6
|
+
t.string :description
|
|
7
|
+
t.jsonb :metadata
|
|
8
|
+
t.references :product_type,
|
|
9
|
+
null: false,
|
|
10
|
+
index: {name: "ccpt_on_ccp_indx"},
|
|
11
|
+
foreign_key: {to_table: :comee_core_product_types}
|
|
12
|
+
t.references :unit,
|
|
13
|
+
null: false,
|
|
14
|
+
index: {name: "unit_on_ccp_indx"},
|
|
15
|
+
foreign_key: {to_table: :comee_core_units}
|
|
16
|
+
|
|
17
|
+
t.timestamps
|
|
18
|
+
end
|
|
19
|
+
add_index :comee_core_products, :code, unique: true
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class CreateComeeCoreUsers < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :comee_core_users do |t|
|
|
4
|
+
t.string :name, null: false
|
|
5
|
+
t.string :email, null: false
|
|
6
|
+
t.boolean :active, null: false, default: true
|
|
7
|
+
t.string :password_digest
|
|
8
|
+
t.integer :user_type, null: false, default: 0
|
|
9
|
+
|
|
10
|
+
t.timestamps
|
|
11
|
+
end
|
|
12
|
+
add_index :comee_core_users, :email, unique: true
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class CreateComeeCoreSuppliers < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :comee_core_suppliers do |t|
|
|
4
|
+
t.string :code, null: false
|
|
5
|
+
t.string :name, null: false
|
|
6
|
+
t.string :address, null: false
|
|
7
|
+
t.string :locale, null: false, default: "en"
|
|
8
|
+
t.references :user,
|
|
9
|
+
null: true,
|
|
10
|
+
index: {name: "user_on_ccs_indx"},
|
|
11
|
+
foreign_key: {to_table: :comee_core_users}
|
|
12
|
+
|
|
13
|
+
t.timestamps
|
|
14
|
+
end
|
|
15
|
+
add_index :comee_core_suppliers, :code, unique: true
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class CreateComeeCoreClients < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :comee_core_clients do |t|
|
|
4
|
+
t.references :user,
|
|
5
|
+
null: false,
|
|
6
|
+
index: {name: "user_on_ccc_indx"},
|
|
7
|
+
foreign_key: {to_table: :comee_core_users}
|
|
8
|
+
t.string :code, null: false
|
|
9
|
+
t.string :name, null: false
|
|
10
|
+
t.string :address, null: false
|
|
11
|
+
t.string :locale, null: false, default: "en"
|
|
12
|
+
t.string :discount, null: false, default: 0
|
|
13
|
+
|
|
14
|
+
t.timestamps
|
|
15
|
+
end
|
|
16
|
+
add_index :comee_core_clients, :code, unique: true
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class CreateComeeCoreBackOrders < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :comee_core_back_orders do |t|
|
|
4
|
+
t.string :order_number, null: false
|
|
5
|
+
t.date :order_date, null: false, default: -> { "CURRENT_DATE" }
|
|
6
|
+
t.date :delivery_date, null: false
|
|
7
|
+
t.references :supplier,
|
|
8
|
+
null: false,
|
|
9
|
+
index: {name: "supplier_on_ccbo_indx"},
|
|
10
|
+
foreign_key: {to_table: :comee_core_suppliers}
|
|
11
|
+
t.json :terms, null: false, default: {freight_terms: "FOB", currency: "EURO"}
|
|
12
|
+
t.string :delivery_address, null: false
|
|
13
|
+
t.string :invoice_address, null: false
|
|
14
|
+
t.integer :status, null: false, default: 0
|
|
15
|
+
t.string :remark
|
|
16
|
+
|
|
17
|
+
t.timestamps
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class CreateComeeCoreBackOrderItems < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :comee_core_back_order_items do |t|
|
|
4
|
+
t.references :back_order,
|
|
5
|
+
null: false,
|
|
6
|
+
index: {name: "bo_on_ccboi_indx"},
|
|
7
|
+
foreign_key: {to_table: :comee_core_back_orders}
|
|
8
|
+
t.references :product,
|
|
9
|
+
null: false,
|
|
10
|
+
index: {name: "product_on_ccboi_indx"},
|
|
11
|
+
foreign_key: {to_table: :comee_core_products}
|
|
12
|
+
t.float :requested_quantity, null: false
|
|
13
|
+
t.float :requested_unit_price, null: false
|
|
14
|
+
t.float :supplier_quantity, null: false
|
|
15
|
+
t.float :supplier_unit_price, null: false
|
|
16
|
+
t.integer :item_status, null: false, default: 0
|
|
17
|
+
t.string :remark
|
|
18
|
+
|
|
19
|
+
t.timestamps
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class CreateComeeCoreNotifications < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :comee_core_notifications do |t|
|
|
4
|
+
t.references :recipient, polymorphic: true, null: false
|
|
5
|
+
t.string :type
|
|
6
|
+
t.jsonb :params
|
|
7
|
+
t.datetime :read_at
|
|
8
|
+
|
|
9
|
+
t.timestamps
|
|
10
|
+
end
|
|
11
|
+
add_index :comee_core_notifications, :read_at
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class CreateComeeCoreClientOrders < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :comee_core_client_orders do |t|
|
|
4
|
+
t.string :order_number, null: false
|
|
5
|
+
t.date :order_date, null: false, default: -> { "CURRENT_DATE" }
|
|
6
|
+
t.date :delivery_date, null: false
|
|
7
|
+
t.references :client,
|
|
8
|
+
null: false,
|
|
9
|
+
index: {name: "client_on_ccco_indx"},
|
|
10
|
+
foreign_key: {to_table: :comee_core_clients}
|
|
11
|
+
t.json :terms
|
|
12
|
+
t.integer :status, null: false, default: 0
|
|
13
|
+
t.string :delivery_address, null: false
|
|
14
|
+
t.string :invoice_address, null: false
|
|
15
|
+
t.string :remark
|
|
16
|
+
t.float :total_price, null: true, default: 0
|
|
17
|
+
t.float :amount_paid, null: true, default: 0
|
|
18
|
+
t.float :amount_due, null: true, default: 0
|
|
19
|
+
|
|
20
|
+
t.timestamps
|
|
21
|
+
end
|
|
22
|
+
add_index :comee_core_client_orders, :order_number, unique: true
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class CreateComeeCoreClientOrderItems < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :comee_core_client_order_items do |t|
|
|
4
|
+
t.references :client_order,
|
|
5
|
+
null: false,
|
|
6
|
+
index: {name: "co_on_coi_indx"},
|
|
7
|
+
foreign_key: {to_table: :comee_core_client_orders}
|
|
8
|
+
t.references :product,
|
|
9
|
+
null: false,
|
|
10
|
+
index: {name: "po_on_coi_indx"},
|
|
11
|
+
foreign_key: {to_table: :comee_core_products}
|
|
12
|
+
t.integer :quantity, null: false
|
|
13
|
+
t.integer :price, null: false
|
|
14
|
+
|
|
15
|
+
t.timestamps
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class CreateComeeCoreMasterPrices < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :comee_core_master_prices do |t|
|
|
4
|
+
t.date :pp_valid_from, null: false
|
|
5
|
+
t.date :pp_valid_to, null: false
|
|
6
|
+
t.date :sp_valid_from, null: false
|
|
7
|
+
t.date :sp_valid_to, null: false
|
|
8
|
+
t.float :old_pprice, null: true
|
|
9
|
+
t.float :new_pprice, null: false
|
|
10
|
+
t.float :old_sprice, null: true
|
|
11
|
+
t.float :new_sprice, null: false
|
|
12
|
+
t.boolean :primary, null: false
|
|
13
|
+
t.references :product,
|
|
14
|
+
null: false,
|
|
15
|
+
index: {name: "product_on_ccsp_indx"},
|
|
16
|
+
foreign_key: {to_table: :comee_core_products}
|
|
17
|
+
t.references :supplier,
|
|
18
|
+
null: false,
|
|
19
|
+
index: {name: "supplier_on_ccsp_indx"},
|
|
20
|
+
foreign_key: {to_table: :comee_core_suppliers}
|
|
21
|
+
|
|
22
|
+
t.timestamps
|
|
23
|
+
end
|
|
24
|
+
add_index :comee_core_master_prices, [:product_id, :supplier_id], unique: true
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class CreateComeeCoreClientPrices < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :comee_core_client_prices do |t|
|
|
4
|
+
t.date :valid_from, null: false
|
|
5
|
+
t.date :valid_to, null: false
|
|
6
|
+
t.float :old_price, null: true
|
|
7
|
+
t.float :new_price, null: false
|
|
8
|
+
t.float :future_price, null: true
|
|
9
|
+
t.date :future_validity, null: true
|
|
10
|
+
t.references :product,
|
|
11
|
+
null: false,
|
|
12
|
+
index: {name: "product_on_cccp_indx"},
|
|
13
|
+
foreign_key: {to_table: :comee_core_products}
|
|
14
|
+
t.references :client,
|
|
15
|
+
null: false,
|
|
16
|
+
index: {name: "client_on_cccp_indx"},
|
|
17
|
+
foreign_key: {to_table: :comee_core_clients}
|
|
18
|
+
|
|
19
|
+
t.timestamps
|
|
20
|
+
end
|
|
21
|
+
add_index :comee_core_client_prices, [:product_id, :client_id], unique: true
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class CreateComeeCoreExternalProducts < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :comee_core_product_lookups do |t|
|
|
4
|
+
t.string :code, null: false
|
|
5
|
+
t.references :itemable, polymorphic: true, null: false
|
|
6
|
+
t.references :product,
|
|
7
|
+
null: false,
|
|
8
|
+
index: {name: "product_on_ccep_indx"},
|
|
9
|
+
foreign_key: {to_table: :comee_core_products}
|
|
10
|
+
|
|
11
|
+
t.timestamps
|
|
12
|
+
end
|
|
13
|
+
add_index :comee_core_product_lookups,
|
|
14
|
+
[:itemable_id, :itemable_type, :product_id],
|
|
15
|
+
name: "itemable_product_indx_uniq",
|
|
16
|
+
unique: true
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class CreateComeeCoreInvoices < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :comee_core_invoices do |t|
|
|
4
|
+
t.string :invoice_no, null: false
|
|
5
|
+
t.references :client_order,
|
|
6
|
+
null: false,
|
|
7
|
+
index: {name: "co_on_cci_indx"},
|
|
8
|
+
foreign_key: {to_table: :comee_core_client_orders}
|
|
9
|
+
t.date :date_issued, null: false
|
|
10
|
+
t.string :ship_name
|
|
11
|
+
t.date :delivery_date
|
|
12
|
+
t.string :voyage_no
|
|
13
|
+
t.float :additional_charges
|
|
14
|
+
t.float :total_price
|
|
15
|
+
t.string :payment_term, null: false
|
|
16
|
+
t.integer :notifications_sent
|
|
17
|
+
t.integer :status, null: false, default: 0
|
|
18
|
+
t.integer :payment_status, null: false, default: 0
|
|
19
|
+
|
|
20
|
+
t.timestamps
|
|
21
|
+
end
|
|
22
|
+
add_index :comee_core_invoices, :invoice_no, unique: true
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class CreateComeeCoreInvoiceItems < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :comee_core_invoice_items do |t|
|
|
4
|
+
t.references :client_order_item,
|
|
5
|
+
null: false,
|
|
6
|
+
index: {name: "coi_on_ccii_indx"},
|
|
7
|
+
foreign_key: {to_table: :comee_core_client_order_items}
|
|
8
|
+
t.float :quantity, null: false
|
|
9
|
+
t.float :unit_price, null: false
|
|
10
|
+
t.float :total_price, null: false
|
|
11
|
+
t.references :invoice,
|
|
12
|
+
null: false,
|
|
13
|
+
index: {name: "invoice_on_ccii_indx"},
|
|
14
|
+
foreign_key: {to_table: :comee_core_invoices}
|
|
15
|
+
|
|
16
|
+
t.timestamps
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|