diff --git a/pricing_catalog_rails_app/.dockerignore b/pricing_catalog_rails_app/.dockerignore deleted file mode 100644 index 96123753a..000000000 --- a/pricing_catalog_rails_app/.dockerignore +++ /dev/null @@ -1,37 +0,0 @@ -# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files. - -# Ignore git directory. -/.git/ - -# Ignore bundler config. -/.bundle - -# Ignore all environment files (except templates). -/.env* -!/.env*.erb - -# Ignore all default key files. -/config/master.key -/config/credentials/*.key - -# Ignore all logfiles and tempfiles. -/log/* -/tmp/* -!/log/.keep -!/tmp/.keep - -# Ignore pidfiles, but keep the directory. -/tmp/pids/* -!/tmp/pids/.keep - -# Ignore storage (uploaded files in development and any SQLite databases). -/storage/* -!/storage/.keep -/tmp/storage/* -!/tmp/storage/.keep - -# Ignore assets. -/node_modules/ -/app/assets/builds/* -!/app/assets/builds/.keep -/public/assets diff --git a/pricing_catalog_rails_app/.gitignore b/pricing_catalog_rails_app/.gitignore deleted file mode 100644 index 802489bb8..000000000 --- a/pricing_catalog_rails_app/.gitignore +++ /dev/null @@ -1,37 +0,0 @@ -!/log/.keep -!/storage/.keep -!/tmp/.keep -.byebug_history -.yarn-integrity -/.bundle -/config/master.key -/db/*.sqlite3* -/db/*.sqlite3-journal -/elm-stuff -/log/* -/node_modules -/public/assets -/public/packs -/public/packs-test -/storage/* -/tmp/* -/yarn-error.log -coverage -yarn-debug.log* - -/public/packs -/public/packs-test -/node_modules -/yarn-error.log -yarn-debug.log* -.yarn-integrity -.env*.local - -.idea -.ruby-version -/app/assets/builds/* -!/app/assets/builds/.keep - -# Event to handlers and handler to events mappings generated by big_picture.rb script -/lib/event_to_handlers.rb -/lib/handler_to_events.rb \ No newline at end of file diff --git a/pricing_catalog_rails_app/Dockerfile b/pricing_catalog_rails_app/Dockerfile deleted file mode 100644 index 0ffa0232b..000000000 --- a/pricing_catalog_rails_app/Dockerfile +++ /dev/null @@ -1,62 +0,0 @@ -# syntax = docker/dockerfile:1 - -# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile -ARG RUBY_VERSION=3.2.0 -FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base - -# Rails app lives here -WORKDIR /rails - -# Set production environment -ENV RAILS_ENV="production" \ - BUNDLE_DEPLOYMENT="1" \ - BUNDLE_PATH="/usr/local/bundle" \ - BUNDLE_WITHOUT="development" - - -# Throw-away build stage to reduce size of final image -FROM base as build - -# Install packages needed to build gems -RUN apt-get update -qq && \ - apt-get install --no-install-recommends -y build-essential git pkg-config - -# Install application gems -COPY Gemfile Gemfile.lock ./ -RUN bundle install && \ - rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \ - bundle exec bootsnap precompile --gemfile - -# Copy application code -COPY . . - -# Precompile bootsnap code for faster boot times -RUN bundle exec bootsnap precompile app/ lib/ - -# Precompiling assets for production without requiring secret RAILS_MASTER_KEY -RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile - - -# Final stage for app image -FROM base - -# Install packages needed for deployment -RUN apt-get update -qq && \ - apt-get install --no-install-recommends -y curl libsqlite3-0 && \ - rm -rf /var/lib/apt/lists /var/cache/apt/archives - -# Copy built artifacts: gems, application -COPY --from=build /usr/local/bundle /usr/local/bundle -COPY --from=build /rails /rails - -# Run and own only the runtime files as a non-root user for security -RUN useradd rails --create-home --shell /bin/bash && \ - chown -R rails:rails db log storage tmp -USER rails:rails - -# Entrypoint prepares the database. -ENTRYPOINT ["/rails/bin/docker-entrypoint"] - -# Start the server by default, this can be overwritten at runtime -EXPOSE 3000 -CMD ["./bin/rails", "server"] diff --git a/pricing_catalog_rails_app/Gemfile b/pricing_catalog_rails_app/Gemfile deleted file mode 100644 index 124d5f633..000000000 --- a/pricing_catalog_rails_app/Gemfile +++ /dev/null @@ -1,50 +0,0 @@ -source "https://rubygems.org" - -ruby "3.2.0" -gem "rails", "~> 7.1.3" -gem "sqlite3", "~> 1.4" - -# Use the Puma web server [https://github.com/puma/puma] -gem "puma", ">= 5.0" - -# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] -gem "importmap-rails" - -# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] -gem "turbo-rails" - -# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] -gem "stimulus-rails" - -# Use Redis adapter to run Action Cable in production -gem "redis", ">= 4.0.1" - -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem "tzinfo-data", platforms: %i[ windows jruby ] - -# Reduces boot times through caching; required in config/boot.rb -gem "bootsnap", require: false - -group :development, :test do - # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem - gem "debug", platforms: %i[ mri windows ] -end - -group :development do - # Use console on exceptions pages [https://github.com/rails/web-console] - gem "web-console" - - # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] - # gem "rack-mini-profiler" - - # Speed up commands on slow machines / big apps [https://github.com/rails/spring] - # gem "spring" -end - -group :test do - # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] - gem "capybara" - gem "selenium-webdriver" -end -gem "rails_event_store", "~> 2.14.0" -gem "infra", path: "../infra" \ No newline at end of file diff --git a/pricing_catalog_rails_app/Gemfile.lock b/pricing_catalog_rails_app/Gemfile.lock deleted file mode 100644 index 0ddc0d01e..000000000 --- a/pricing_catalog_rails_app/Gemfile.lock +++ /dev/null @@ -1,337 +0,0 @@ -PATH - remote: ../infra - specs: - infra (1.0.0) - aggregate_root (~> 2.13) - arkency-command_bus - dry-struct - dry-types - rake - ruby_event_store (~> 2.13) - ruby_event_store-transformations - sidekiq - -GEM - remote: https://rubygems.org/ - specs: - actioncable (7.1.3) - actionpack (= 7.1.3) - activesupport (= 7.1.3) - nio4r (~> 2.0) - websocket-driver (>= 0.6.1) - zeitwerk (~> 2.6) - actionmailbox (7.1.3) - actionpack (= 7.1.3) - activejob (= 7.1.3) - activerecord (= 7.1.3) - activestorage (= 7.1.3) - activesupport (= 7.1.3) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.1.3) - actionpack (= 7.1.3) - actionview (= 7.1.3) - activejob (= 7.1.3) - activesupport (= 7.1.3) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp - rails-dom-testing (~> 2.2) - actionpack (7.1.3) - actionview (= 7.1.3) - activesupport (= 7.1.3) - nokogiri (>= 1.8.5) - racc - rack (>= 2.2.4) - rack-session (>= 1.0.1) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - actiontext (7.1.3) - actionpack (= 7.1.3) - activerecord (= 7.1.3) - activestorage (= 7.1.3) - activesupport (= 7.1.3) - globalid (>= 0.6.0) - nokogiri (>= 1.8.5) - actionview (7.1.3) - activesupport (= 7.1.3) - builder (~> 3.1) - erubi (~> 1.11) - rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - activejob (7.1.3) - activesupport (= 7.1.3) - globalid (>= 0.3.6) - activemodel (7.1.3) - activesupport (= 7.1.3) - activerecord (7.1.3) - activemodel (= 7.1.3) - activesupport (= 7.1.3) - timeout (>= 0.4.0) - activestorage (7.1.3) - actionpack (= 7.1.3) - activejob (= 7.1.3) - activerecord (= 7.1.3) - activesupport (= 7.1.3) - marcel (~> 1.0) - activesupport (7.1.3) - base64 - bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) - connection_pool (>= 2.2.5) - drb - i18n (>= 1.6, < 2) - minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) - addressable (2.8.6) - public_suffix (>= 2.0.2, < 6.0) - aggregate_root (2.14.0) - base64 - ruby_event_store (= 2.14.0) - arkency-command_bus (0.4.1) - concurrent-ruby - base64 (0.2.0) - bigdecimal (3.1.6) - bindex (0.8.1) - bootsnap (1.17.1) - msgpack (~> 1.2) - builder (3.2.4) - capybara (3.40.0) - addressable - matrix - mini_mime (>= 0.1.3) - nokogiri (~> 1.11) - rack (>= 1.6.0) - rack-test (>= 0.6.3) - regexp_parser (>= 1.5, < 3.0) - xpath (~> 3.2) - concurrent-ruby (1.2.3) - connection_pool (2.4.1) - crass (1.0.6) - date (3.3.4) - debug (1.9.1) - irb (~> 1.10) - reline (>= 0.3.8) - drb (2.2.0) - ruby2_keywords - dry-core (1.0.1) - concurrent-ruby (~> 1.0) - zeitwerk (~> 2.6) - dry-inflector (1.0.0) - dry-logic (1.5.0) - concurrent-ruby (~> 1.0) - dry-core (~> 1.0, < 2) - zeitwerk (~> 2.6) - dry-struct (1.6.0) - dry-core (~> 1.0, < 2) - dry-types (>= 1.7, < 2) - ice_nine (~> 0.11) - zeitwerk (~> 2.6) - dry-types (1.7.2) - bigdecimal (~> 3.0) - concurrent-ruby (~> 1.0) - dry-core (~> 1.0) - dry-inflector (~> 1.0) - dry-logic (~> 1.4) - zeitwerk (~> 2.6) - erubi (1.12.0) - globalid (1.2.1) - activesupport (>= 6.1) - i18n (1.14.1) - concurrent-ruby (~> 1.0) - ice_nine (0.11.2) - importmap-rails (2.0.1) - actionpack (>= 6.0.0) - activesupport (>= 6.0.0) - railties (>= 6.0.0) - io-console (0.7.2) - irb (1.11.1) - rdoc - reline (>= 0.4.2) - loofah (2.22.0) - crass (~> 1.0.2) - nokogiri (>= 1.12.0) - mail (2.8.1) - mini_mime (>= 0.1.1) - net-imap - net-pop - net-smtp - marcel (1.0.2) - matrix (0.4.2) - mini_mime (1.1.5) - minitest (5.21.2) - msgpack (1.7.2) - mutex_m (0.2.0) - net-imap (0.4.9.1) - date - net-protocol - net-pop (0.1.2) - net-protocol - net-protocol (0.2.2) - timeout - net-smtp (0.4.0.1) - net-protocol - nio4r (2.7.0) - nokogiri (1.16.0-aarch64-linux) - racc (~> 1.4) - nokogiri (1.16.0-arm-linux) - racc (~> 1.4) - nokogiri (1.16.0-arm64-darwin) - racc (~> 1.4) - nokogiri (1.16.0-x86-linux) - racc (~> 1.4) - nokogiri (1.16.0-x86_64-darwin) - racc (~> 1.4) - nokogiri (1.16.0-x86_64-linux) - racc (~> 1.4) - psych (5.1.2) - stringio - public_suffix (5.0.4) - puma (6.4.2) - nio4r (~> 2.0) - racc (1.7.3) - rack (3.0.8) - rack-session (2.0.0) - rack (>= 3.0.0) - rack-test (2.1.0) - rack (>= 1.3) - rackup (2.1.0) - rack (>= 3) - webrick (~> 1.8) - rails (7.1.3) - actioncable (= 7.1.3) - actionmailbox (= 7.1.3) - actionmailer (= 7.1.3) - actionpack (= 7.1.3) - actiontext (= 7.1.3) - actionview (= 7.1.3) - activejob (= 7.1.3) - activemodel (= 7.1.3) - activerecord (= 7.1.3) - activestorage (= 7.1.3) - activesupport (= 7.1.3) - bundler (>= 1.15.0) - railties (= 7.1.3) - rails-dom-testing (2.2.0) - activesupport (>= 5.0.0) - minitest - nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) - loofah (~> 2.21) - nokogiri (~> 1.14) - rails_event_store (2.14.0) - activejob (>= 6.0) - activemodel (>= 6.0) - activesupport (>= 6.0) - aggregate_root (= 2.14.0) - arkency-command_bus (>= 0.4) - rails_event_store_active_record (= 2.14.0) - ruby_event_store (= 2.14.0) - ruby_event_store-browser (= 2.14.0) - rails_event_store_active_record (2.14.0) - ruby_event_store-active_record (= 2.14.0) - railties (7.1.3) - actionpack (= 7.1.3) - activesupport (= 7.1.3) - irb - rackup (>= 1.0.0) - rake (>= 12.2) - thor (~> 1.0, >= 1.2.2) - zeitwerk (~> 2.6) - rake (13.1.0) - rdoc (6.6.2) - psych (>= 4.0.0) - redis (5.0.8) - redis-client (>= 0.17.0) - redis-client (0.19.1) - connection_pool - regexp_parser (2.9.0) - reline (0.4.2) - io-console (~> 0.5) - rexml (3.2.6) - ruby2_keywords (0.0.5) - ruby_event_store (2.14.0) - concurrent-ruby (~> 1.0, >= 1.1.6) - ruby_event_store-active_record (2.14.0) - activerecord (>= 6.0) - ruby_event_store (= 2.14.0) - ruby_event_store-browser (2.14.0) - rack - ruby_event_store (= 2.14.0) - ruby_event_store-transformations (0.1.0) - activesupport (>= 5.0) - ruby_event_store (>= 2.0.0, < 3.0.0) - rubyzip (2.3.2) - selenium-webdriver (4.17.0) - base64 (~> 0.2) - rexml (~> 3.2, >= 3.2.5) - rubyzip (>= 1.2.2, < 3.0) - websocket (~> 1.0) - sidekiq (7.2.1) - concurrent-ruby (< 2) - connection_pool (>= 2.3.0) - rack (>= 2.2.4) - redis-client (>= 0.19.0) - sqlite3 (1.7.1-aarch64-linux) - sqlite3 (1.7.1-arm-linux) - sqlite3 (1.7.1-arm64-darwin) - sqlite3 (1.7.1-x86-linux) - sqlite3 (1.7.1-x86_64-darwin) - sqlite3 (1.7.1-x86_64-linux) - stimulus-rails (1.3.3) - railties (>= 6.0.0) - stringio (3.1.0) - thor (1.3.0) - timeout (0.4.1) - turbo-rails (1.5.0) - actionpack (>= 6.0.0) - activejob (>= 6.0.0) - railties (>= 6.0.0) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - web-console (4.2.1) - actionview (>= 6.0.0) - activemodel (>= 6.0.0) - bindex (>= 0.4.0) - railties (>= 6.0.0) - webrick (1.8.1) - websocket (1.2.10) - websocket-driver (0.7.6) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) - xpath (3.2.0) - nokogiri (~> 1.8) - zeitwerk (2.6.12) - -PLATFORMS - aarch64-linux - arm-linux - arm64-darwin - x86-linux - x86_64-darwin - x86_64-linux - -DEPENDENCIES - bootsnap - capybara - debug - importmap-rails - infra! - puma (>= 5.0) - rails (~> 7.1.3) - rails_event_store (~> 2.14.0) - redis (>= 4.0.1) - selenium-webdriver - sqlite3 (~> 1.4) - stimulus-rails - turbo-rails - tzinfo-data - web-console - -BUNDLED WITH - 2.5.9 diff --git a/pricing_catalog_rails_app/README.md b/pricing_catalog_rails_app/README.md deleted file mode 100644 index 7db80e4ca..000000000 --- a/pricing_catalog_rails_app/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# README - -This README would normally document whatever steps are necessary to get the -application up and running. - -Things you may want to cover: - -* Ruby version - -* System dependencies - -* Configuration - -* Database creation - -* Database initialization - -* How to run the test suite - -* Services (job queues, cache servers, search engines, etc.) - -* Deployment instructions - -* ... diff --git a/pricing_catalog_rails_app/Rakefile b/pricing_catalog_rails_app/Rakefile deleted file mode 100644 index 9a5ea7383..000000000 --- a/pricing_catalog_rails_app/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -# Add your own tasks in files placed in lib/tasks ending in .rake, -# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. - -require_relative "config/application" - -Rails.application.load_tasks diff --git a/pricing_catalog_rails_app/app/admin/read_models/admin_catalog/admin_catalog.rb b/pricing_catalog_rails_app/app/admin/read_models/admin_catalog/admin_catalog.rb deleted file mode 100644 index d7cc7575f..000000000 --- a/pricing_catalog_rails_app/app/admin/read_models/admin_catalog/admin_catalog.rb +++ /dev/null @@ -1,36 +0,0 @@ -module AdminCatalog - - class Migration - def change - ActiveRecord::Base.connection.create_table :admin_catalog_products do |t| - t.string :product_id - t.string :name - t.decimal :price - - t.timestamps - end - end - end - - class Product < ActiveRecord::Base - self.table_name = 'admin_catalog_products' - end - - class Configuration - def call(event_store) - event_store.subscribe( - -> (event) {Product.create(product_id: event.data[:product_id])}, - to: [ProductCatalog::ProductRegistered]) - event_store.subscribe( - -> (event) {Product.find_by(product_id: event.data[:product_id]).update(name: event.data[:name])}, - to: [ProductCatalog::ProductNamed]) - event_store.subscribe( - -> (event) {Product.find_by(product_id: event.data[:product_id]).update(price: event.data[:price])}, - to: [Pricing::PriceSet]) - end - - private - - end - -end \ No newline at end of file diff --git a/pricing_catalog_rails_app/app/admin/read_models/admin_catalog/index.html.erb b/pricing_catalog_rails_app/app/admin/read_models/admin_catalog/index.html.erb deleted file mode 100644 index 67a6aa093..000000000 --- a/pricing_catalog_rails_app/app/admin/read_models/admin_catalog/index.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -Admin Catalog - -<%= form_for new_product, url: {controller: "admin/catalog", action: "create"} do |f| %> -

- <%= f.label :name %> - <%= f.text_field :name %> -

-

- <%= f.label :price %> - <%= f.text_field :price %> -

- <%= f.submit %> -<% end %> - - \ No newline at end of file diff --git a/pricing_catalog_rails_app/app/admin/register_product.rb b/pricing_catalog_rails_app/app/admin/register_product.rb deleted file mode 100644 index 4ca05e618..000000000 --- a/pricing_catalog_rails_app/app/admin/register_product.rb +++ /dev/null @@ -1,14 +0,0 @@ -class RegisterProduct - def call(name, price) - product_id = SecureRandom.uuid - command_bus.(ProductCatalog::RegisterProduct.new(product_id: product_id)) - command_bus.(ProductCatalog::NameProduct.new(product_id: product_id, name: name)) - command_bus.(Pricing::SetPrice.new(product_id: product_id, price: price)) - end - - private - - def command_bus - Rails.configuration.command_bus - end -end \ No newline at end of file diff --git a/pricing_catalog_rails_app/app/assets/config/manifest.js b/pricing_catalog_rails_app/app/assets/config/manifest.js deleted file mode 100644 index ddd546a0b..000000000 --- a/pricing_catalog_rails_app/app/assets/config/manifest.js +++ /dev/null @@ -1,4 +0,0 @@ -//= link_tree ../images -//= link_directory ../stylesheets .css -//= link_tree ../../javascript .js -//= link_tree ../../../vendor/javascript .js diff --git a/pricing_catalog_rails_app/app/assets/images/.keep b/pricing_catalog_rails_app/app/assets/images/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/app/assets/stylesheets/application.css b/pricing_catalog_rails_app/app/assets/stylesheets/application.css deleted file mode 100644 index 288b9ab71..000000000 --- a/pricing_catalog_rails_app/app/assets/stylesheets/application.css +++ /dev/null @@ -1,15 +0,0 @@ -/* - * This is a manifest file that'll be compiled into application.css, which will include all the files - * listed below. - * - * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's - * vendor/assets/stylesheets directory can be referenced here using a relative path. - * - * You're free to add application-wide styles to this file and they'll appear at the bottom of the - * compiled file so the styles you add here take precedence over styles defined in any other CSS - * files in this directory. Styles in this file should be added after the last require_* statement. - * It is generally better to create a new file per style scope. - * - *= require_tree . - *= require_self - */ diff --git a/pricing_catalog_rails_app/app/channels/application_cable/channel.rb b/pricing_catalog_rails_app/app/channels/application_cable/channel.rb deleted file mode 100644 index d67269728..000000000 --- a/pricing_catalog_rails_app/app/channels/application_cable/channel.rb +++ /dev/null @@ -1,4 +0,0 @@ -module ApplicationCable - class Channel < ActionCable::Channel::Base - end -end diff --git a/pricing_catalog_rails_app/app/channels/application_cable/connection.rb b/pricing_catalog_rails_app/app/channels/application_cable/connection.rb deleted file mode 100644 index 0ff5442f4..000000000 --- a/pricing_catalog_rails_app/app/channels/application_cable/connection.rb +++ /dev/null @@ -1,4 +0,0 @@ -module ApplicationCable - class Connection < ActionCable::Connection::Base - end -end diff --git a/pricing_catalog_rails_app/app/controllers/admin/catalog_controller.rb b/pricing_catalog_rails_app/app/controllers/admin/catalog_controller.rb deleted file mode 100644 index a7a368379..000000000 --- a/pricing_catalog_rails_app/app/controllers/admin/catalog_controller.rb +++ /dev/null @@ -1,16 +0,0 @@ -class Admin::CatalogController < ApplicationController - def index - products = AdminCatalog::Product.all - prepend_view_path Rails.root.join("app", "admin", "read_models") - render template: "admin_catalog/index", - locals: { products: products, new_product: AdminCatalog::Product.new } - end - - def create - RegisterProduct.new.call( - params[:admin_catalog_product][:name], - params[:admin_catalog_product][:price] - ) - redirect_to admin_root_path - end -end \ No newline at end of file diff --git a/pricing_catalog_rails_app/app/controllers/application_controller.rb b/pricing_catalog_rails_app/app/controllers/application_controller.rb deleted file mode 100644 index 09705d12a..000000000 --- a/pricing_catalog_rails_app/app/controllers/application_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class ApplicationController < ActionController::Base -end diff --git a/pricing_catalog_rails_app/app/controllers/catalog_controller.rb b/pricing_catalog_rails_app/app/controllers/catalog_controller.rb deleted file mode 100644 index caa1185f0..000000000 --- a/pricing_catalog_rails_app/app/controllers/catalog_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -class CatalogController < ApplicationController - def index - products = PublicCatalog::Product.all - prepend_view_path Rails.root.join("app", "public", "read_models") - render template: "public_catalog/index", locals: { products: products } - end -end \ No newline at end of file diff --git a/pricing_catalog_rails_app/app/controllers/concerns/.keep b/pricing_catalog_rails_app/app/controllers/concerns/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/app/helpers/application_helper.rb b/pricing_catalog_rails_app/app/helpers/application_helper.rb deleted file mode 100644 index de6be7945..000000000 --- a/pricing_catalog_rails_app/app/helpers/application_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ApplicationHelper -end diff --git a/pricing_catalog_rails_app/app/javascript/application.js b/pricing_catalog_rails_app/app/javascript/application.js deleted file mode 100644 index 0d7b49404..000000000 --- a/pricing_catalog_rails_app/app/javascript/application.js +++ /dev/null @@ -1,3 +0,0 @@ -// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails -import "@hotwired/turbo-rails" -import "controllers" diff --git a/pricing_catalog_rails_app/app/javascript/controllers/application.js b/pricing_catalog_rails_app/app/javascript/controllers/application.js deleted file mode 100644 index 1213e85c7..000000000 --- a/pricing_catalog_rails_app/app/javascript/controllers/application.js +++ /dev/null @@ -1,9 +0,0 @@ -import { Application } from "@hotwired/stimulus" - -const application = Application.start() - -// Configure Stimulus development experience -application.debug = false -window.Stimulus = application - -export { application } diff --git a/pricing_catalog_rails_app/app/javascript/controllers/hello_controller.js b/pricing_catalog_rails_app/app/javascript/controllers/hello_controller.js deleted file mode 100644 index 5975c0789..000000000 --- a/pricing_catalog_rails_app/app/javascript/controllers/hello_controller.js +++ /dev/null @@ -1,7 +0,0 @@ -import { Controller } from "@hotwired/stimulus" - -export default class extends Controller { - connect() { - this.element.textContent = "Hello World!" - } -} diff --git a/pricing_catalog_rails_app/app/javascript/controllers/index.js b/pricing_catalog_rails_app/app/javascript/controllers/index.js deleted file mode 100644 index 54ad4cad4..000000000 --- a/pricing_catalog_rails_app/app/javascript/controllers/index.js +++ /dev/null @@ -1,11 +0,0 @@ -// Import and register all your controllers from the importmap under controllers/* - -import { application } from "controllers/application" - -// Eager load all controllers defined in the import map under controllers/**/*_controller -import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading" -eagerLoadControllersFrom("controllers", application) - -// Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!) -// import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading" -// lazyLoadControllersFrom("controllers", application) diff --git a/pricing_catalog_rails_app/app/jobs/application_job.rb b/pricing_catalog_rails_app/app/jobs/application_job.rb deleted file mode 100644 index d394c3d10..000000000 --- a/pricing_catalog_rails_app/app/jobs/application_job.rb +++ /dev/null @@ -1,7 +0,0 @@ -class ApplicationJob < ActiveJob::Base - # Automatically retry jobs that encountered a deadlock - # retry_on ActiveRecord::Deadlocked - - # Most jobs are safe to ignore if the underlying records are no longer available - # discard_on ActiveJob::DeserializationError -end diff --git a/pricing_catalog_rails_app/app/models/application_record.rb b/pricing_catalog_rails_app/app/models/application_record.rb deleted file mode 100644 index b63caeb8a..000000000 --- a/pricing_catalog_rails_app/app/models/application_record.rb +++ /dev/null @@ -1,3 +0,0 @@ -class ApplicationRecord < ActiveRecord::Base - primary_abstract_class -end diff --git a/pricing_catalog_rails_app/app/models/concerns/.keep b/pricing_catalog_rails_app/app/models/concerns/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/app/public/read_models/public_catalog/index.html.erb b/pricing_catalog_rails_app/app/public/read_models/public_catalog/index.html.erb deleted file mode 100644 index a29fdc81c..000000000 --- a/pricing_catalog_rails_app/app/public/read_models/public_catalog/index.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -Catalog - - \ No newline at end of file diff --git a/pricing_catalog_rails_app/app/public/read_models/public_catalog/public_catalog.rb b/pricing_catalog_rails_app/app/public/read_models/public_catalog/public_catalog.rb deleted file mode 100644 index 39276906a..000000000 --- a/pricing_catalog_rails_app/app/public/read_models/public_catalog/public_catalog.rb +++ /dev/null @@ -1,36 +0,0 @@ -module PublicCatalog - - class Migration - def change - ActiveRecord::Base.connection.create_table :public_catalog_products do |t| - t.string :product_id - t.string :name - t.decimal :price - - t.timestamps - end - end - end - - class Product < ActiveRecord::Base - self.table_name = 'public_catalog_products' - end - - class Configuration - def call(event_store) - event_store.subscribe( - -> (event) {Product.create(product_id: event.data[:product_id])}, - to: [ProductCatalog::ProductRegistered]) - event_store.subscribe( - -> (event) {Product.find_by(product_id: event.data[:product_id]).update(name: event.data[:name])}, - to: [ProductCatalog::ProductNamed]) - event_store.subscribe( - -> (event) {Product.find_by(product_id: event.data[:product_id]).update(price: event.data[:price])}, - to: [Pricing::PriceSet]) - end - - private - - end - -end \ No newline at end of file diff --git a/pricing_catalog_rails_app/app/views/layouts/application.html.erb b/pricing_catalog_rails_app/app/views/layouts/application.html.erb deleted file mode 100644 index 453940f01..000000000 --- a/pricing_catalog_rails_app/app/views/layouts/application.html.erb +++ /dev/null @@ -1,16 +0,0 @@ - - - - PricingCatalogRailsApp - - <%= csrf_meta_tags %> - <%= csp_meta_tag %> - - <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> - <%= javascript_importmap_tags %> - - - - <%= yield %> - - diff --git a/pricing_catalog_rails_app/bin/bundle b/pricing_catalog_rails_app/bin/bundle deleted file mode 100755 index 50da5fdf9..000000000 --- a/pricing_catalog_rails_app/bin/bundle +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -# -# This file was generated by Bundler. -# -# The application 'bundle' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require "rubygems" - -m = Module.new do - module_function - - def invoked_as_script? - File.expand_path($0) == File.expand_path(__FILE__) - end - - def env_var_version - ENV["BUNDLER_VERSION"] - end - - def cli_arg_version - return unless invoked_as_script? # don't want to hijack other binstubs - return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` - bundler_version = nil - update_index = nil - ARGV.each_with_index do |a, i| - if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN) - bundler_version = a - end - next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ - bundler_version = $1 - update_index = i - end - bundler_version - end - - def gemfile - gemfile = ENV["BUNDLE_GEMFILE"] - return gemfile if gemfile && !gemfile.empty? - - File.expand_path("../Gemfile", __dir__) - end - - def lockfile - lockfile = - case File.basename(gemfile) - when "gems.rb" then gemfile.sub(/\.rb$/, ".locked") - else "#{gemfile}.lock" - end - File.expand_path(lockfile) - end - - def lockfile_version - return unless File.file?(lockfile) - lockfile_contents = File.read(lockfile) - return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ - Regexp.last_match(1) - end - - def bundler_requirement - @bundler_requirement ||= - env_var_version || - cli_arg_version || - bundler_requirement_for(lockfile_version) - end - - def bundler_requirement_for(version) - return "#{Gem::Requirement.default}.a" unless version - - bundler_gem_version = Gem::Version.new(version) - - bundler_gem_version.approximate_recommendation - end - - def load_bundler! - ENV["BUNDLE_GEMFILE"] ||= gemfile - - activate_bundler - end - - def activate_bundler - gem_error = activation_error_handling do - gem "bundler", bundler_requirement - end - return if gem_error.nil? - require_error = activation_error_handling do - require "bundler/version" - end - return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) - warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" - exit 42 - end - - def activation_error_handling - yield - nil - rescue StandardError, LoadError => e - e - end -end - -m.load_bundler! - -if m.invoked_as_script? - load Gem.bin_path("bundler", "bundle") -end diff --git a/pricing_catalog_rails_app/bin/docker-entrypoint b/pricing_catalog_rails_app/bin/docker-entrypoint deleted file mode 100755 index 67ef49314..000000000 --- a/pricing_catalog_rails_app/bin/docker-entrypoint +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -e - -# If running the rails server then create or migrate existing database -if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then - ./bin/rails db:prepare -fi - -exec "${@}" diff --git a/pricing_catalog_rails_app/bin/importmap b/pricing_catalog_rails_app/bin/importmap deleted file mode 100755 index 36502ab16..000000000 --- a/pricing_catalog_rails_app/bin/importmap +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby - -require_relative "../config/application" -require "importmap/commands" diff --git a/pricing_catalog_rails_app/bin/rails b/pricing_catalog_rails_app/bin/rails deleted file mode 100755 index efc037749..000000000 --- a/pricing_catalog_rails_app/bin/rails +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby -APP_PATH = File.expand_path("../config/application", __dir__) -require_relative "../config/boot" -require "rails/commands" diff --git a/pricing_catalog_rails_app/bin/rake b/pricing_catalog_rails_app/bin/rake deleted file mode 100755 index 4fbf10b96..000000000 --- a/pricing_catalog_rails_app/bin/rake +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby -require_relative "../config/boot" -require "rake" -Rake.application.run diff --git a/pricing_catalog_rails_app/bin/setup b/pricing_catalog_rails_app/bin/setup deleted file mode 100755 index 3cd5a9d78..000000000 --- a/pricing_catalog_rails_app/bin/setup +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env ruby -require "fileutils" - -# path to your application root. -APP_ROOT = File.expand_path("..", __dir__) - -def system!(*args) - system(*args, exception: true) -end - -FileUtils.chdir APP_ROOT do - # This script is a way to set up or update your development environment automatically. - # This script is idempotent, so that you can run it at any time and get an expectable outcome. - # Add necessary setup steps to this file. - - puts "== Installing dependencies ==" - system! "gem install bundler --conservative" - system("bundle check") || system!("bundle install") - - # puts "\n== Copying sample files ==" - # unless File.exist?("config/database.yml") - # FileUtils.cp "config/database.yml.sample", "config/database.yml" - # end - - puts "\n== Preparing database ==" - system! "bin/rails db:prepare" - - puts "\n== Removing old logs and tempfiles ==" - system! "bin/rails log:clear tmp:clear" - - puts "\n== Restarting application server ==" - system! "bin/rails restart" -end diff --git a/pricing_catalog_rails_app/config.ru b/pricing_catalog_rails_app/config.ru deleted file mode 100644 index 4a3c09a68..000000000 --- a/pricing_catalog_rails_app/config.ru +++ /dev/null @@ -1,6 +0,0 @@ -# This file is used by Rack-based servers to start the application. - -require_relative "config/environment" - -run Rails.application -Rails.application.load_server diff --git a/pricing_catalog_rails_app/config/application.rb b/pricing_catalog_rails_app/config/application.rb deleted file mode 100644 index 780a71cca..000000000 --- a/pricing_catalog_rails_app/config/application.rb +++ /dev/null @@ -1,39 +0,0 @@ -require_relative "boot" - -require "rails" -# Pick the frameworks you want: -require "active_model/railtie" -require "active_job/railtie" -require "active_record/railtie" -# require "active_storage/engine" -require "action_controller/railtie" -# require "action_mailer/railtie" -# require "action_mailbox/engine" -# require "action_text/engine" -require "action_view/railtie" -require "action_cable/engine" -require "rails/test_unit/railtie" - -# Require the gems listed in Gemfile, including any gems -# you've limited to :test, :development, or :production. -Bundler.require(*Rails.groups) - -module PricingCatalogRailsApp - class Application < Rails::Application - # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.1 - - # Please, add to the `ignore` list any other `lib` subdirectories that do - # not contain `.rb` files, or that should not be reloaded or eager loaded. - # Common ones are `templates`, `generators`, or `middleware`, for example. - config.autoload_lib(ignore: %w(assets tasks)) - - # Configuration for the application, engines, and railties goes here. - # - # These settings can be overridden in specific environments using the files - # in config/environments, which are processed later. - # - # config.time_zone = "Central Time (US & Canada)" - # config.eager_load_paths << Rails.root.join("extras") - end -end diff --git a/pricing_catalog_rails_app/config/boot.rb b/pricing_catalog_rails_app/config/boot.rb deleted file mode 100644 index 988a5ddc4..000000000 --- a/pricing_catalog_rails_app/config/boot.rb +++ /dev/null @@ -1,4 +0,0 @@ -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) - -require "bundler/setup" # Set up gems listed in the Gemfile. -require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/pricing_catalog_rails_app/config/cable.yml b/pricing_catalog_rails_app/config/cable.yml deleted file mode 100644 index 2d44db85c..000000000 --- a/pricing_catalog_rails_app/config/cable.yml +++ /dev/null @@ -1,11 +0,0 @@ -development: - adapter: redis - url: redis://localhost:6379/1 - -test: - adapter: test - -production: - adapter: redis - url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> - channel_prefix: pricing_catalog_rails_app_production diff --git a/pricing_catalog_rails_app/config/credentials.yml.enc b/pricing_catalog_rails_app/config/credentials.yml.enc deleted file mode 100644 index 0f0dfd275..000000000 --- a/pricing_catalog_rails_app/config/credentials.yml.enc +++ /dev/null @@ -1 +0,0 @@ -1bVsLr2aTAhLscEGzm9z9M6tAEvNNqGbM+wJgoEaQFkaXELdbldo0WLR2WfGRmKICorkE4reE6N47g30nr0XIHRly9lfRb0/pSXxZY06X37RF+C/amRJJ4G0bqxJTwjcE1GBQ0x3Xv7WZnj0YvIVAfZX1pa3OS4piVDHCgvf/03a5PGcSJxcfF8xbYbHb5NLWIJtJ//mjPpOZiFnJh0W7PKsP0N2KeqjPIvyb97EcOw2l6UKf9pV1ZhkOWUf6RWc3MzfvPVQkvW7qPe6CUVNWp34w5/8eZCFAtNHw9v57A/GF148I3C8p6xuF3/B74xL3yuw/xE//RdwT2Tw0BwtOOFePK+iuxEBZDhZxwDCmB8VuWr0Fai0tI4jx7DUIPC1f2inoDLb+3zrd8Yjc2I8xC0UHDDB--mwsUJW1WffHciEwk--Ih++i+PuMS7pOk1yjdDf9Q== \ No newline at end of file diff --git a/pricing_catalog_rails_app/config/database.yml b/pricing_catalog_rails_app/config/database.yml deleted file mode 100644 index 796466ba2..000000000 --- a/pricing_catalog_rails_app/config/database.yml +++ /dev/null @@ -1,25 +0,0 @@ -# SQLite. Versions 3.8.0 and up are supported. -# gem install sqlite3 -# -# Ensure the SQLite 3 gem is defined in your Gemfile -# gem "sqlite3" -# -default: &default - adapter: sqlite3 - pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - timeout: 5000 - -development: - <<: *default - database: storage/development.sqlite3 - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - <<: *default - database: storage/test.sqlite3 - -production: - <<: *default - database: storage/production.sqlite3 diff --git a/pricing_catalog_rails_app/config/environment.rb b/pricing_catalog_rails_app/config/environment.rb deleted file mode 100644 index cac531577..000000000 --- a/pricing_catalog_rails_app/config/environment.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Load the Rails application. -require_relative "application" - -# Initialize the Rails application. -Rails.application.initialize! diff --git a/pricing_catalog_rails_app/config/environments/development.rb b/pricing_catalog_rails_app/config/environments/development.rb deleted file mode 100644 index 94c3ba6ab..000000000 --- a/pricing_catalog_rails_app/config/environments/development.rb +++ /dev/null @@ -1,65 +0,0 @@ -require "active_support/core_ext/integer/time" - -Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # In the development environment your application's code is reloaded any time - # it changes. This slows down response time but is perfect for development - # since you don't have to restart the web server when you make code changes. - config.enable_reloading = true - - # Do not eager load code on boot. - config.eager_load = false - - # Show full error reports. - config.consider_all_requests_local = true - - # Enable server timing - config.server_timing = true - - # Enable/disable caching. By default caching is disabled. - # Run rails dev:cache to toggle caching. - if Rails.root.join("tmp/caching-dev.txt").exist? - config.action_controller.perform_caching = true - config.action_controller.enable_fragment_cache_logging = true - - config.cache_store = :memory_store - config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{2.days.to_i}" - } - else - config.action_controller.perform_caching = false - - config.cache_store = :null_store - end - - # Print deprecation notices to the Rails logger. - config.active_support.deprecation = :log - - # Raise exceptions for disallowed deprecations. - config.active_support.disallowed_deprecation = :raise - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - - # Raise an error on page load if there are pending migrations. - config.active_record.migration_error = :page_load - - # Highlight code that triggered database queries in logs. - config.active_record.verbose_query_logs = true - - # Highlight code that enqueued background job in logs. - config.active_job.verbose_enqueue_logs = true - - # Raises error for missing translations. - # config.i18n.raise_on_missing_translations = true - - # Annotate rendered view with file names. - # config.action_view.annotate_rendered_view_with_filenames = true - - # Uncomment if you wish to allow Action Cable access from any origin. - # config.action_cable.disable_request_forgery_protection = true - - # Raise error when a before_action's only/except options reference missing actions - config.action_controller.raise_on_missing_callback_actions = true -end diff --git a/pricing_catalog_rails_app/config/environments/production.rb b/pricing_catalog_rails_app/config/environments/production.rb deleted file mode 100644 index 5f66ca6ab..000000000 --- a/pricing_catalog_rails_app/config/environments/production.rb +++ /dev/null @@ -1,88 +0,0 @@ -require "active_support/core_ext/integer/time" - -Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # Code is not reloaded between requests. - config.enable_reloading = false - - # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both threaded web servers - # and those relying on copy on write to perform better. - # Rake tasks automatically ignore this option for performance. - config.eager_load = true - - # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false - config.action_controller.perform_caching = true - - # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment - # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files). - # config.require_master_key = true - - # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. - # config.public_file_server.enabled = false - - # Compress CSS using a preprocessor. - # config.assets.css_compressor = :sass - - # Do not fall back to assets pipeline if a precompiled asset is missed. - config.assets.compile = false - - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.asset_host = "http://assets.example.com" - - # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache - # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX - - # Mount Action Cable outside main process or domain. - # config.action_cable.mount_path = nil - # config.action_cable.url = "wss://example.com/cable" - # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] - - # Assume all access to the app is happening through a SSL-terminating reverse proxy. - # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. - # config.assume_ssl = true - - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - config.force_ssl = true - - # Log to STDOUT by default - config.logger = ActiveSupport::Logger.new(STDOUT) - .tap { |logger| logger.formatter = ::Logger::Formatter.new } - .then { |logger| ActiveSupport::TaggedLogging.new(logger) } - - # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] - - # "info" includes generic and useful information about system operation, but avoids logging too much - # information to avoid inadvertent exposure of personally identifiable information (PII). If you - # want to log everything, set the level to "debug". - config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") - - # Use a different cache store in production. - # config.cache_store = :mem_cache_store - - # Use a real queuing backend for Active Job (and separate queues per environment). - # config.active_job.queue_adapter = :resque - # config.active_job.queue_name_prefix = "pricing_catalog_rails_app_production" - - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation cannot be found). - config.i18n.fallbacks = true - - # Don't log any deprecations. - config.active_support.report_deprecations = false - - # Do not dump schema after migrations. - config.active_record.dump_schema_after_migration = false - - # Enable DNS rebinding protection and other `Host` header attacks. - # config.hosts = [ - # "example.com", # Allow requests from example.com - # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` - # ] - # Skip DNS rebinding protection for the default health check endpoint. - # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } -end diff --git a/pricing_catalog_rails_app/config/environments/test.rb b/pricing_catalog_rails_app/config/environments/test.rb deleted file mode 100644 index d349c3556..000000000 --- a/pricing_catalog_rails_app/config/environments/test.rb +++ /dev/null @@ -1,54 +0,0 @@ -require "active_support/core_ext/integer/time" - -# The test environment is used exclusively to run your application's -# test suite. You never need to work with it otherwise. Remember that -# your test database is "scratch space" for the test suite and is wiped -# and recreated between test runs. Don't rely on the data there! - -Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # While tests run files are not watched, reloading is not necessary. - config.enable_reloading = false - - # Eager loading loads your entire application. When running a single test locally, - # this is usually not necessary, and can slow down your test suite. However, it's - # recommended that you enable it in continuous integration systems to ensure eager - # loading is working properly before deploying your code. - config.eager_load = ENV["CI"].present? - - # Configure public file server for tests with Cache-Control for performance. - config.public_file_server.enabled = true - config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{1.hour.to_i}" - } - - # Show full error reports and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false - config.cache_store = :null_store - - # Render exception templates for rescuable exceptions and raise for other exceptions. - config.action_dispatch.show_exceptions = :rescuable - - # Disable request forgery protection in test environment. - config.action_controller.allow_forgery_protection = false - - # Print deprecation notices to the stderr. - config.active_support.deprecation = :stderr - - # Raise exceptions for disallowed deprecations. - config.active_support.disallowed_deprecation = :raise - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - - # Raises error for missing translations. - # config.i18n.raise_on_missing_translations = true - - # Annotate rendered view with file names. - # config.action_view.annotate_rendered_view_with_filenames = true - - # Raise error when a before_action's only/except options reference missing actions - config.action_controller.raise_on_missing_callback_actions = true -end diff --git a/pricing_catalog_rails_app/config/importmap.rb b/pricing_catalog_rails_app/config/importmap.rb deleted file mode 100644 index bc060edb7..000000000 --- a/pricing_catalog_rails_app/config/importmap.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Pin npm packages by running ./bin/importmap - -pin "application" -pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true -pin "@hotwired/stimulus", to: "stimulus.min.js" -pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" -pin_all_from "app/javascript/controllers", under: "controllers" diff --git a/pricing_catalog_rails_app/config/initializers/content_security_policy.rb b/pricing_catalog_rails_app/config/initializers/content_security_policy.rb deleted file mode 100644 index b3076b38f..000000000 --- a/pricing_catalog_rails_app/config/initializers/content_security_policy.rb +++ /dev/null @@ -1,25 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Define an application-wide content security policy. -# See the Securing Rails Applications Guide for more information: -# https://guides.rubyonrails.org/security.html#content-security-policy-header - -# Rails.application.configure do -# config.content_security_policy do |policy| -# policy.default_src :self, :https -# policy.font_src :self, :https, :data -# policy.img_src :self, :https, :data -# policy.object_src :none -# policy.script_src :self, :https -# policy.style_src :self, :https -# # Specify URI for violation reports -# # policy.report_uri "/csp-violation-report-endpoint" -# end -# -# # Generate session nonces for permitted importmap, inline scripts, and inline styles. -# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } -# config.content_security_policy_nonce_directives = %w(script-src style-src) -# -# # Report violations without enforcing the policy. -# # config.content_security_policy_report_only = true -# end diff --git a/pricing_catalog_rails_app/config/initializers/filter_parameter_logging.rb b/pricing_catalog_rails_app/config/initializers/filter_parameter_logging.rb deleted file mode 100644 index c2d89e28a..000000000 --- a/pricing_catalog_rails_app/config/initializers/filter_parameter_logging.rb +++ /dev/null @@ -1,8 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. -# Use this to limit dissemination of sensitive information. -# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. -Rails.application.config.filter_parameters += [ - :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn -] diff --git a/pricing_catalog_rails_app/config/initializers/inflections.rb b/pricing_catalog_rails_app/config/initializers/inflections.rb deleted file mode 100644 index 3860f659e..000000000 --- a/pricing_catalog_rails_app/config/initializers/inflections.rb +++ /dev/null @@ -1,16 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Add new inflection rules using the following format. Inflections -# are locale specific, and you may define rules for as many different -# locales as you wish. All of these examples are active by default: -# ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.plural /^(ox)$/i, "\\1en" -# inflect.singular /^(ox)en/i, "\\1" -# inflect.irregular "person", "people" -# inflect.uncountable %w( fish sheep ) -# end - -# These inflection rules are supported but not enabled by default: -# ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.acronym "RESTful" -# end diff --git a/pricing_catalog_rails_app/config/initializers/permissions_policy.rb b/pricing_catalog_rails_app/config/initializers/permissions_policy.rb deleted file mode 100644 index 7db3b9577..000000000 --- a/pricing_catalog_rails_app/config/initializers/permissions_policy.rb +++ /dev/null @@ -1,13 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Define an application-wide HTTP permissions policy. For further -# information see: https://developers.google.com/web/updates/2018/06/feature-policy - -# Rails.application.config.permissions_policy do |policy| -# policy.camera :none -# policy.gyroscope :none -# policy.microphone :none -# policy.usb :none -# policy.fullscreen :self -# policy.payment :self, "https://secure.example.com" -# end diff --git a/pricing_catalog_rails_app/config/initializers/rails_event_store.rb b/pricing_catalog_rails_app/config/initializers/rails_event_store.rb deleted file mode 100644 index 78bde65ea..000000000 --- a/pricing_catalog_rails_app/config/initializers/rails_event_store.rb +++ /dev/null @@ -1,38 +0,0 @@ -require_relative "../../../ecommerce/pricing/lib/pricing" -require_relative "../../../ecommerce/product_catalog//lib/product_catalog" -require_relative "../../../infra/lib/infra" -require "rails_event_store" -require "arkency/command_bus" -require_relative "../../app/public/read_models/public_catalog/public_catalog" -require_relative "../../app/admin/read_models/admin_catalog/admin_catalog" - -Rails.configuration.to_prepare do - Rails.configuration.event_store = Infra::EventStore.main - Rails.configuration.command_bus = Arkency::CommandBus.new - Configuration.new.call(Rails.configuration.event_store, Rails.configuration.command_bus) -end - -class Configuration - def call(event_store, command_bus) - enable_res_infra_event_linking(event_store) - [ - Pricing::Configuration.new, - ProductCatalog::Configuration.new, - ].each { |c| c.call(event_store, command_bus) } - PublicCatalog::Configuration.new.call(event_store) - AdminCatalog::Configuration.new.call(event_store) - - end - - private - - def enable_res_infra_event_linking(event_store) - [ - RailsEventStore::LinkByEventType.new, - RailsEventStore::LinkByCorrelationId.new, - RailsEventStore::LinkByCausationId.new - ].each { |h| event_store.subscribe_to_all_events(h) } - end - -end - diff --git a/pricing_catalog_rails_app/config/locales/en.yml b/pricing_catalog_rails_app/config/locales/en.yml deleted file mode 100644 index 6c349ae5e..000000000 --- a/pricing_catalog_rails_app/config/locales/en.yml +++ /dev/null @@ -1,31 +0,0 @@ -# Files in the config/locales directory are used for internationalization and -# are automatically loaded by Rails. If you want to use locales other than -# English, add the necessary files in this directory. -# -# To use the locales, use `I18n.t`: -# -# I18n.t "hello" -# -# In views, this is aliased to just `t`: -# -# <%= t("hello") %> -# -# To use a different locale, set it with `I18n.locale`: -# -# I18n.locale = :es -# -# This would use the information in config/locales/es.yml. -# -# To learn more about the API, please read the Rails Internationalization guide -# at https://guides.rubyonrails.org/i18n.html. -# -# Be aware that YAML interprets the following case-insensitive strings as -# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings -# must be quoted to be interpreted as strings. For example: -# -# en: -# "yes": yup -# enabled: "ON" - -en: - hello: "Hello world" diff --git a/pricing_catalog_rails_app/config/master.key b/pricing_catalog_rails_app/config/master.key deleted file mode 100644 index 9bcdf7473..000000000 --- a/pricing_catalog_rails_app/config/master.key +++ /dev/null @@ -1 +0,0 @@ -c2400f761b119d3f092a64d00bad9fdc \ No newline at end of file diff --git a/pricing_catalog_rails_app/config/puma.rb b/pricing_catalog_rails_app/config/puma.rb deleted file mode 100644 index afa809b43..000000000 --- a/pricing_catalog_rails_app/config/puma.rb +++ /dev/null @@ -1,35 +0,0 @@ -# This configuration file will be evaluated by Puma. The top-level methods that -# are invoked here are part of Puma's configuration DSL. For more information -# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. - -# Puma can serve each request in a thread from an internal thread pool. -# The `threads` method setting takes two numbers: a minimum and maximum. -# Any libraries that use thread pools should be configured to match -# the maximum value specified for Puma. Default is set to 5 threads for minimum -# and maximum; this matches the default thread size of Active Record. -max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } -min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } -threads min_threads_count, max_threads_count - -# Specifies that the worker count should equal the number of processors in production. -if ENV["RAILS_ENV"] == "production" - require "concurrent-ruby" - worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count }) - workers worker_count if worker_count > 1 -end - -# Specifies the `worker_timeout` threshold that Puma will use to wait before -# terminating a worker in development environments. -worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" - -# Specifies the `port` that Puma will listen on to receive requests; default is 3000. -port ENV.fetch("PORT") { 3000 } - -# Specifies the `environment` that Puma will run in. -environment ENV.fetch("RAILS_ENV") { "development" } - -# Specifies the `pidfile` that Puma will use. -pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } - -# Allow puma to be restarted by `bin/rails restart` command. -plugin :tmp_restart diff --git a/pricing_catalog_rails_app/config/routes.rb b/pricing_catalog_rails_app/config/routes.rb deleted file mode 100644 index e77d0686b..000000000 --- a/pricing_catalog_rails_app/config/routes.rb +++ /dev/null @@ -1,16 +0,0 @@ -Rails.application.routes.draw do - mount RailsEventStore::Browser => '/res' if Rails.env.development? - # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html - - # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. - # Can be used by load balancers and uptime monitors to verify that the app is live. - get "up" => "rails/health#show", as: :rails_health_check - - # Defines the root path route ("/") - root "catalog#index" - - namespace :admin do - root "catalog#index" - post "catalog", to: "catalog#create" - end -end diff --git a/pricing_catalog_rails_app/db/migrate/20240130110320_create_event_store_events.rb b/pricing_catalog_rails_app/db/migrate/20240130110320_create_event_store_events.rb deleted file mode 100644 index 70389537c..000000000 --- a/pricing_catalog_rails_app/db/migrate/20240130110320_create_event_store_events.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -class CreateEventStoreEvents < ActiveRecord::Migration[7.1] - def change - create_table(:event_store_events_in_streams, force: false) do |t| - t.string :stream, null: false - t.integer :position, null: true - t.references :event, null: false, type: :string, limit: 36, index: false - t.datetime :created_at, null: false, precision: 6, index: true - end - add_index :event_store_events_in_streams, [:stream, :position], unique: true - add_index :event_store_events_in_streams, [:stream, :event_id], unique: true - add_index :event_store_events_in_streams, [:event_id] - - create_table(:event_store_events, force: false) do |t| - t.references :event, null: false, type: :string, limit: 36, index: { unique: true } - t.string :event_type, null: false, index: true - t.binary :metadata - t.binary :data, null: false - t.datetime :created_at, null: false, precision: 6, index: true - t.datetime :valid_at, null: true, precision: 6, index: true - end - - add_foreign_key "event_store_events_in_streams", "event_store_events", column: "event_id", primary_key: "event_id" - end -end diff --git a/pricing_catalog_rails_app/db/migrate/20240201132941_enable_pg_crypto.rb b/pricing_catalog_rails_app/db/migrate/20240201132941_enable_pg_crypto.rb deleted file mode 100644 index aa1d05d93..000000000 --- a/pricing_catalog_rails_app/db/migrate/20240201132941_enable_pg_crypto.rb +++ /dev/null @@ -1,5 +0,0 @@ -class EnablePgCrypto < ActiveRecord::Migration[7.1] - def change - enable_extension "pgcrypto" - end -end diff --git a/pricing_catalog_rails_app/db/migrate/20240201133038_create_products_table.rb b/pricing_catalog_rails_app/db/migrate/20240201133038_create_products_table.rb deleted file mode 100644 index 035f3be94..000000000 --- a/pricing_catalog_rails_app/db/migrate/20240201133038_create_products_table.rb +++ /dev/null @@ -1,5 +0,0 @@ -class CreateProductsTable < ActiveRecord::Migration[7.1] - def change - PublicCatalog::Migration.new.change - end -end diff --git a/pricing_catalog_rails_app/db/migrate/20240201154705_create_admin_products.rb b/pricing_catalog_rails_app/db/migrate/20240201154705_create_admin_products.rb deleted file mode 100644 index dd7f3b56a..000000000 --- a/pricing_catalog_rails_app/db/migrate/20240201154705_create_admin_products.rb +++ /dev/null @@ -1,5 +0,0 @@ -class CreateAdminProducts < ActiveRecord::Migration[7.1] - def change - AdminCatalog::Migration.new.change - end -end diff --git a/pricing_catalog_rails_app/db/schema.rb b/pricing_catalog_rails_app/db/schema.rb deleted file mode 100644 index f73ac726f..000000000 --- a/pricing_catalog_rails_app/db/schema.rb +++ /dev/null @@ -1,55 +0,0 @@ -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# This file is the source Rails uses to define your schema when running `bin/rails -# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to -# be faster and is potentially less error prone than running all of your -# migrations from scratch. Old migrations may fail to apply correctly if those -# migrations use external dependencies or application code. -# -# It's strongly recommended that you check this file into your version control system. - -ActiveRecord::Schema[7.1].define(version: 2024_02_01_154705) do - create_table "admin_catalog_products", force: :cascade do |t| - t.string "product_id" - t.string "name" - t.decimal "price" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - create_table "event_store_events", force: :cascade do |t| - t.string "event_id", limit: 36, null: false - t.string "event_type", null: false - t.binary "metadata" - t.binary "data", null: false - t.datetime "created_at", null: false - t.datetime "valid_at" - t.index ["created_at"], name: "index_event_store_events_on_created_at" - t.index ["event_id"], name: "index_event_store_events_on_event_id", unique: true - t.index ["event_type"], name: "index_event_store_events_on_event_type" - t.index ["valid_at"], name: "index_event_store_events_on_valid_at" - end - - create_table "event_store_events_in_streams", force: :cascade do |t| - t.string "stream", null: false - t.integer "position" - t.string "event_id", limit: 36, null: false - t.datetime "created_at", null: false - t.index ["created_at"], name: "index_event_store_events_in_streams_on_created_at" - t.index ["event_id"], name: "index_event_store_events_in_streams_on_event_id" - t.index ["stream", "event_id"], name: "index_event_store_events_in_streams_on_stream_and_event_id", unique: true - t.index ["stream", "position"], name: "index_event_store_events_in_streams_on_stream_and_position", unique: true - end - - create_table "public_catalog_products", force: :cascade do |t| - t.string "product_id" - t.string "name" - t.decimal "price" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - add_foreign_key "event_store_events_in_streams", "event_store_events", column: "event_id", primary_key: "event_id" -end diff --git a/pricing_catalog_rails_app/db/seeds.rb b/pricing_catalog_rails_app/db/seeds.rb deleted file mode 100644 index 4fbd6ed97..000000000 --- a/pricing_catalog_rails_app/db/seeds.rb +++ /dev/null @@ -1,9 +0,0 @@ -# This file should ensure the existence of records required to run the application in every environment (production, -# development, test). The code here should be idempotent so that it can be executed at any point in every environment. -# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). -# -# Example: -# -# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name| -# MovieGenre.find_or_create_by!(name: genre_name) -# end diff --git a/pricing_catalog_rails_app/lib/assets/.keep b/pricing_catalog_rails_app/lib/assets/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/lib/tasks/.keep b/pricing_catalog_rails_app/lib/tasks/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/log/.keep b/pricing_catalog_rails_app/log/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/public/404.html b/pricing_catalog_rails_app/public/404.html deleted file mode 100644 index 2be3af26f..000000000 --- a/pricing_catalog_rails_app/public/404.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - The page you were looking for doesn't exist (404) - - - - - - -
-
-

The page you were looking for doesn't exist.

-

You may have mistyped the address or the page may have moved.

-
-

If you are the application owner check the logs for more information.

-
- - diff --git a/pricing_catalog_rails_app/public/422.html b/pricing_catalog_rails_app/public/422.html deleted file mode 100644 index c08eac0d1..000000000 --- a/pricing_catalog_rails_app/public/422.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - The change you wanted was rejected (422) - - - - - - -
-
-

The change you wanted was rejected.

-

Maybe you tried to change something you didn't have access to.

-
-

If you are the application owner check the logs for more information.

-
- - diff --git a/pricing_catalog_rails_app/public/500.html b/pricing_catalog_rails_app/public/500.html deleted file mode 100644 index 78a030af2..000000000 --- a/pricing_catalog_rails_app/public/500.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - We're sorry, but something went wrong (500) - - - - - - -
-
-

We're sorry, but something went wrong.

-
-

If you are the application owner check the logs for more information.

-
- - diff --git a/pricing_catalog_rails_app/public/apple-touch-icon-precomposed.png b/pricing_catalog_rails_app/public/apple-touch-icon-precomposed.png deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/public/apple-touch-icon.png b/pricing_catalog_rails_app/public/apple-touch-icon.png deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/public/favicon.ico b/pricing_catalog_rails_app/public/favicon.ico deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/public/robots.txt b/pricing_catalog_rails_app/public/robots.txt deleted file mode 100644 index c19f78ab6..000000000 --- a/pricing_catalog_rails_app/public/robots.txt +++ /dev/null @@ -1 +0,0 @@ -# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/pricing_catalog_rails_app/storage/.keep b/pricing_catalog_rails_app/storage/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/test/application_system_test_case.rb b/pricing_catalog_rails_app/test/application_system_test_case.rb deleted file mode 100644 index d19212abd..000000000 --- a/pricing_catalog_rails_app/test/application_system_test_case.rb +++ /dev/null @@ -1,5 +0,0 @@ -require "test_helper" - -class ApplicationSystemTestCase < ActionDispatch::SystemTestCase - driven_by :selenium, using: :chrome, screen_size: [1400, 1400] -end diff --git a/pricing_catalog_rails_app/test/channels/application_cable/connection_test.rb b/pricing_catalog_rails_app/test/channels/application_cable/connection_test.rb deleted file mode 100644 index 6340bf9c0..000000000 --- a/pricing_catalog_rails_app/test/channels/application_cable/connection_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -require "test_helper" - -module ApplicationCable - class ConnectionTest < ActionCable::Connection::TestCase - # test "connects with cookies" do - # cookies.signed[:user_id] = 42 - # - # connect - # - # assert_equal connection.user_id, "42" - # end - end -end diff --git a/pricing_catalog_rails_app/test/controllers/.keep b/pricing_catalog_rails_app/test/controllers/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/test/fixtures/files/.keep b/pricing_catalog_rails_app/test/fixtures/files/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/test/helpers/.keep b/pricing_catalog_rails_app/test/helpers/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/test/integration/.keep b/pricing_catalog_rails_app/test/integration/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/test/models/.keep b/pricing_catalog_rails_app/test/models/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/test/system/.keep b/pricing_catalog_rails_app/test/system/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/test/test_helper.rb b/pricing_catalog_rails_app/test/test_helper.rb deleted file mode 100644 index 0c22470ec..000000000 --- a/pricing_catalog_rails_app/test/test_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -ENV["RAILS_ENV"] ||= "test" -require_relative "../config/environment" -require "rails/test_help" - -module ActiveSupport - class TestCase - # Run tests in parallel with specified workers - parallelize(workers: :number_of_processors) - - # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. - fixtures :all - - # Add more helper methods to be used by all tests here... - end -end diff --git a/pricing_catalog_rails_app/tmp/.keep b/pricing_catalog_rails_app/tmp/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/tmp/local_secret.txt b/pricing_catalog_rails_app/tmp/local_secret.txt deleted file mode 100644 index 56a4593b2..000000000 --- a/pricing_catalog_rails_app/tmp/local_secret.txt +++ /dev/null @@ -1 +0,0 @@ -4b650a883751aa8985f1c1e9bc291ec5dd22575339d1415cb6ca116e77fc00e6f30ae882aae0a55cc22a7611693563e3e6e3eb07b07726a4628a5665e47b54a3 \ No newline at end of file diff --git a/pricing_catalog_rails_app/tmp/pids/.keep b/pricing_catalog_rails_app/tmp/pids/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/tmp/storage/.keep b/pricing_catalog_rails_app/tmp/storage/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/vendor/.keep b/pricing_catalog_rails_app/vendor/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/pricing_catalog_rails_app/vendor/javascript/.keep b/pricing_catalog_rails_app/vendor/javascript/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/rails_application/app/controllers/billing_addresses_controller.rb b/rails_application/app/controllers/billing_addresses_controller.rb index 1240d7544..297054ff7 100644 --- a/rails_application/app/controllers/billing_addresses_controller.rb +++ b/rails_application/app/controllers/billing_addresses_controller.rb @@ -2,23 +2,13 @@ class BillingAddressesController < ApplicationController def edit @invoice = Invoices::Invoice.find_or_initialize_by(order_uid: params[:order_id]) - @order = Shipments::Order.find_or_initialize_by(uid: params[:order_id]) + @order = Order.find(params[:order_id]) end def update - cmd = - Invoicing::SetBillingAddress.new( - invoice_id: params[:order_id], - tax_id_number: address_params[:tax_id_number], - postal_address: { - line_1: address_params[:address_line_1], - line_2: address_params[:address_line_2], - line_3: address_params[:address_line_3], - line_4: address_params[:address_line_4] - } - ) - command_bus.(cmd) - @order = Shipments::Order.find_or_initialize_by(uid: params[:order_id]) + @order = Order.find(params[:order_id]) + @order.update!(address_params) + redirect_to @order.submitted? ? order_path(params[:order_id]) : edit_order_path(params[:order_id]), notice: "Billing Address was successfully updated" end @@ -26,12 +16,12 @@ def update private def address_params - params.require(:invoices_invoice).permit( - :tax_id_number, - :address_line_1, - :address_line_2, - :address_line_3, - :address_line_4 + params.require(:order).permit( + :invoice_tax_id_number, + :invoice_addressed_to, + :invoice_address, + :invoice_city, + :invoice_country ) end end diff --git a/rails_application/app/controllers/customers_controller.rb b/rails_application/app/controllers/customers_controller.rb index 6cf55475f..9fc7b97d2 100644 --- a/rails_application/app/controllers/customers_controller.rb +++ b/rails_application/app/controllers/customers_controller.rb @@ -1,18 +1,14 @@ class CustomersController < ApplicationController def index - @customers = Customers::Customer.all + @customers = Customer.all end def new - @customer_id = SecureRandom.uuid + @customer = Customer.new end def create - create_customer(params[:customer_id], params[:name]) - rescue Crm::Customer::AlreadyRegistered - flash[:notice] = "Customer was already registered" - render "new" - else + Customer.create!(customer_params) redirect_to customers_path, notice: "Customer was successfully created" end @@ -25,27 +21,18 @@ def update end def show - @customer = Customers::Customer.find(params[:id]) - @customer_orders = ClientOrders::Order.where(client_uid: params[:id]) - .order(created_at: :desc) - .page(params[:page]).per(10) + @customer = Customer.find(params[:id]) + @customer_orders = @customer.orders.order(created_at: :desc) + .page(params[:page]).per(10) end private - def create_customer(customer_id, name) - command_bus.(create_customer_cmd(customer_id, name)) + def customer_params + params.require(:customer).permit(:first_name, :last_name, :email) end def promote_to_vip(customer_id) - command_bus.(promote_to_vip_cmd(customer_id)) - end - - def create_customer_cmd(customer_id, name) - Crm::RegisterCustomer.new(customer_id: customer_id, name: name) - end - - def promote_to_vip_cmd(customer_id) - Crm::PromoteCustomerToVip.new(customer_id: customer_id) + Customer.find(customer_id).promote_to_vip end end diff --git a/rails_application/app/controllers/events_catalog_controller.rb b/rails_application/app/controllers/events_catalog_controller.rb deleted file mode 100644 index d90d6e889..000000000 --- a/rails_application/app/controllers/events_catalog_controller.rb +++ /dev/null @@ -1,5 +0,0 @@ -class EventsCatalogController < ApplicationController - def index - render file: ENV["EVENTS_CATALOG_PATH"] || "../events_catalog/out/index.html" - end -end diff --git a/rails_application/app/controllers/invoices_controller.rb b/rails_application/app/controllers/invoices_controller.rb index bae493b21..6e1dbe079 100644 --- a/rails_application/app/controllers/invoices_controller.rb +++ b/rails_application/app/controllers/invoices_controller.rb @@ -1,20 +1,22 @@ class InvoicesController < ApplicationController def show - @invoice = Invoices::Invoice.find_by_order_uid(params[:id]) + @invoice = Order.find(params[:id]) end def create - begin - ActiveRecord::Base.transaction do - command_bus.(Invoicing::IssueInvoice.new(invoice_id: params[:order_id], issue_date: Time.zone.now.to_date)) - end - rescue Invoicing::Invoice::BillingAddressNotSpecified + @order = Order.find(params[:order_id]) + + if !@order.billing_address_specified? flash[:alert] = "Billing address is missing" - rescue Invoicing::Invoice::InvoiceAlreadyIssued + elsif @order.invoice_issued? flash[:alert] = "Invoice was already issued" - rescue Invoicing::Invoice::InvoiceNumberInUse - retry + else + @order.invoice_issued = true + @order.invoice_issue_date = Time.current + @order.invoice_total_value = @order.total - ((@order.total * @order.discount) / 100) + @order.save! end + redirect_to(invoice_path(params[:order_id])) end end \ No newline at end of file diff --git a/rails_application/app/controllers/orders_controller.rb b/rails_application/app/controllers/orders_controller.rb index 005355a63..2cf9b173c 100644 --- a/rails_application/app/controllers/orders_controller.rb +++ b/rails_application/app/controllers/orders_controller.rb @@ -1,35 +1,41 @@ class OrdersController < ApplicationController def index - @orders = Orders::Order.order("id DESC").page(params[:page]).per(10) + @orders = Order.order("id DESC").page(params[:page]).per(10) end def show - @order = Orders::Order.find_by_uid(params[:id]) + @order = Order.find(params[:id]) return not_found unless @order - @order_lines = Orders::OrderLine.where(order_uid: @order.uid) - @shipment = Shipments::Shipment.find_by(order_uid: @order.uid) - @invoice = Invoices::Invoice.find_or_initialize_by(order_uid: @order.uid) + @total = @order.total - ((@order.total * @order.discount) / 100) + @order_lines = @order.order_items end def new - redirect_to edit_order_path(SecureRandom.uuid) + @order = Order.new + @order.status = "Draft" + @order.total = 0 + @order.discount = 0 + @order.save! + @order_id = @order.id + @products = Product.all + @customers = Customer.all + @time_promotions = TimePromotions::TimePromotion.current end def edit @order_id = params[:id] - @order = Orders::Order.find_by_uid(params[:id]) - @order_lines = Orders::OrderLine.where(order_uid: params[:id]) - @products = Products::Product.all - @customers = Customers::Customer.all + @order = Order.find(params[:id]) + @products = Product.all + @customers = Customer.all @time_promotions = TimePromotions::TimePromotion.current render :edit, locals: { - discounted_value: @order&.discounted_value || 0, - total_value: @order&.total_value || 0, - percentage_discount: @order&.percentage_discount + discounted_value: @order.total - ((@order.total * @order.discount) / 100), + total_value: @order.total, + percentage_discount: @order.discount } end @@ -38,98 +44,124 @@ def edit_discount end def update_discount - @order_id = params[:id] - order = Orders::Order.find_or_create_by!(uid: params[:id]) - if order.percentage_discount - command_bus.(Pricing::ChangePercentageDiscount.new(order_id: @order_id, amount: params[:amount])) - else - command_bus.(Pricing::SetPercentageDiscount.new(order_id: @order_id, amount: params[:amount])) - end + order = Order.find(params[:id]) + order.discount = params[:amount] + order.discount_updated_at = Time.current + order.save! - redirect_to edit_order_path(@order_id) + redirect_to edit_order_path(order) end def reset_discount - @order_id = params[:id] - command_bus.(Pricing::ResetPercentageDiscount.new(order_id: @order_id)) + order = Order.find(params[:id]) + order.discount = 0 + order.discount_updated_at = Time.current + order.save! - redirect_to edit_order_path(@order_id) + redirect_to edit_order_path(order) end def add_item - read_model = Orders::OrderLine.where(order_uid: params[:id], product_id: params[:product_id]).first - unless Availability.approximately_available?(params[:product_id], (read_model&.quantity || 0) + 1) + product = Product.find(params[:product_id]) + if product.stock_level < 1 redirect_to edit_order_path(params[:id]), alert: "Product not available in requested quantity!" and return end - ActiveRecord::Base.transaction do - command_bus.(Ordering::AddItemToBasket.new(order_id: params[:id], product_id: params[:product_id])) + + @order = Order.find(params[:id]) + if @order.order_items.any? { |order_item| order_item.product_id == params[:product_id].to_i } + @order.order_items.find_by(product_id: params[:product_id]).increment!(:quantity) + @order.total = @order.total + product.price + else + @order.order_items.create!(product_id: params[:product_id], quantity: 1) + @order.total = @order.total + product.price end - head :ok + product.decrement!(:stock_level) + @order.save! + + redirect_to edit_order_path(params[:id]) end def remove_item - command_bus.(Ordering::RemoveItemFromBasket.new(order_id: params[:id], product_id: params[:product_id])) - head :ok + product = Product.find(params[:product_id]) + @order = Order.find(params[:id]) + order_item = @order.order_items.find_by(product_id: params[:product_id]) + if order_item && order_item.quantity > 0 + @order.order_items.find_by(product_id: params[:product_id]).decrement!(:quantity) + product.increment!(:stock_level) + @order.total = @order.total - product.price + @order.save! + end + + redirect_to edit_order_path(params[:id]) end def create - ApplicationRecord.transaction { submit_order(params[:order_id], params[:customer_id]) } + order = Order.find(params[:order_id]) + if order.order_items.empty? + redirect_to order_path(order.id), alert: "Order cannot be submitted because it is empty" + return + end + customer = Customer.find_by(id: params[:customer_id]) + unless customer + redirect_to order_path(order.id), alert: "Order can not be submitted! Customer does not exist." + return + end + ApplicationRecord.transaction { submit_order(order, params[:customer_id]) } redirect_to order_path(params[:order_id]), notice: "Your order is being submitted" - rescue Crm::Customer::NotExists - redirect_to order_path(params[:order_id]), alert: "Order can not be submitted! Customer does not exist." end def expire - Orders::Order - .where(state: "Draft") - .find_each { |order| command_bus.(Ordering::SetOrderAsExpired.new(order_id: order.uid)) } + Order + .where(status: "Draft") + .find_each { |order| order.status = "Expired"; order.save! } redirect_to root_path end def pay - ActiveRecord::Base.transaction do - authorize_payment(params[:id]) - capture_payment(params[:id]) - flash[:notice] = "Order paid successfully" - rescue Payments::Payment::AlreadyAuthorized + order = Order.find(params[:id]) + + if order.invoice_payment_status == "Authorized" flash[:alert] = "Payment was already authorized" - rescue Payments::Payment::AlreadyCaptured + elsif order.invoice_payment_status == "Captured" flash[:alert] = "Payment was already captured" - rescue Payments::Payment::NotAuthorized - flash[:alert] = "Payment wasn't yet authorized" - rescue Ordering::Order::NotPlaced - flash[:alert] = "You can't pay for an order which is not submitted" + + else + ActiveRecord::Base.transaction do + order.invoice_payment_status = "Authorized" + order.save! + + order.invoice_payment_status = "Captured" + order.invoice_payment_date = Time.current + order.status = "Paid" + customer = order.customer + customer.paid_orders_summary += order.total + order.save! + customer.save! + + flash[:notice] = "Order paid successfully" + end end + redirect_to orders_path end def cancel - command_bus.(Fulfillment::CancelOrder.new(order_id: params[:id])) + order = Order.find(params[:id]) + order.status = "Cancelled" + order.save! redirect_to root_path, notice: "Order cancelled" end private - def submit_order(order_id, customer_id) - command_bus.(Ordering::SubmitOrder.new(order_id: order_id)) - command_bus.(Crm::AssignCustomerToOrder.new(order_id: order_id, customer_id: customer_id)) - end - - def authorize_payment(order_id) - command_bus.call(authorize_payment_cmd(order_id)) - end - - def capture_payment(order_id) - command_bus.call(capture_payment_cmd(order_id)) - end - - def authorize_payment_cmd(order_id) - Payments::AuthorizePayment.new(order_id: order_id) - end - - def capture_payment_cmd(order_id) - Payments::CapturePayment.new(order_id: order_id) + def submit_order(order, customer_id) + if order.status == "Draft" + order.status = "Submitted" + order.number = Time.now.strftime("%Y/%m/#{SecureRandom.random_number(100)}") + order.customer_id = customer_id.to_i + order.save! + end end def not_found diff --git a/rails_application/app/controllers/product/future_price_controller.rb b/rails_application/app/controllers/product/future_price_controller.rb deleted file mode 100644 index 6e4b5e8ab..000000000 --- a/rails_application/app/controllers/product/future_price_controller.rb +++ /dev/null @@ -1,20 +0,0 @@ -module Product - class FuturePriceController < ApplicationController - def add_future_price - respond_to do |format| - format.turbo_stream do - render turbo_stream: - turbo_stream.append( - "future_prices", - partial: "/products/future_price", - locals: { - disabled: false, - valid_since: nil, - price: nil - } - ) - end - end - end - end -end diff --git a/rails_application/app/controllers/products_controller.rb b/rails_application/app/controllers/products_controller.rb index 87b0e14ca..e9ba45faf 100644 --- a/rails_application/app/controllers/products_controller.rb +++ b/rails_application/app/controllers/products_controller.rb @@ -1,130 +1,57 @@ class ProductsController < ApplicationController - class ProductForm - include ActiveModel::Model - include ActiveModel::Attributes - include ActiveModel::Validations - - attribute :name, :string - attribute :price, :decimal - attribute :vat_rate, :string - attribute :product_id, :string - - validates :name, presence: true - validates :price, presence: true, numericality: { greater_than: 0 } - validates :vat_rate, presence: true, numericality: { greater_than: 0 } - validates :product_id, presence: true - end - def index - @products = Products::Product.all + @products = Product.all end def show - @product = Products::Product.find(params[:id]) + @product = Product.find(params[:id]) end def new - @product_id = SecureRandom.uuid + @product = Product.new end def edit - @product = Products::Product.find(params[:id]) + @product = Product.find(params[:id]) end def create - product_form = ProductForm.new(**product_params) + Product.create!(product_params) + redirect_to products_path, notice: "Product was successfully created" + end - unless product_form.valid? - return render "new", locals: { errors: product_form.errors }, status: :unprocessable_entity - end + def update + @product = Product.find(params[:id]) - ActiveRecord::Base.transaction do - create_product(product_form.product_id, product_form.name) - if product_form.price.present? - set_product_price(product_form.product_id, product_form.price) - end - if product_form.vat_rate.present? - set_product_vat_rate(product_form.product_id, product_form.vat_rate) - end - rescue ProductCatalog::AlreadyRegistered - flash[:notice] = "Product was already registered" - render "new" - rescue Taxes::Product::VatRateNotApplicable - flash[:notice] = "Selected VAT rate not applicable" - render "new" - else - redirect_to products_path, notice: "Product was successfully created" + if params["future_price"].present? + @product.future_price = params["future_price"]["price"] + @product.future_price_start_time = params["future_price"]["start_time"] + @product.save! end + @product.update!(product_params) + redirect_to products_path, notice: "Product was successfully updated" end - def update - if params[:name].present? - set_product_name(params[:product_id], params[:name]) - end - if params[:price].present? - set_product_price(params[:product_id], params[:price]) - end - if params[:future_prices].present? - params[:future_prices].each do |future_price| - set_future_product_price( - params[:product_id], - future_price["price"], - Time.zone.parse(future_price["start_time"]).utc - ) + def add_future_price + respond_to do |format| + format.turbo_stream do + render turbo_stream: + turbo_stream.update( + "future_prices", + partial: "/products/future_price", + locals: { + disabled: false, + valid_since: nil, + price: nil + } + ) end end - redirect_to products_path, notice: "Product was successfully updated" end private - def create_product(product_id, name) - command_bus.(create_product_cmd(product_id)) - command_bus.(name_product_cmd(product_id, name)) - end - - def set_product_price(product_id, price) - command_bus.(set_product_price_cmd(product_id, price)) - end - - def set_future_product_price(product_id, price, valid_since) - command_bus.(set_product_future_price_cmd(product_id, price, valid_since)) - end - - def set_product_vat_rate(product_id, vat_rate_code) - vat_rate = Taxes::Configuration.available_vat_rates.find{|rate| rate.code == vat_rate_code} - command_bus.(set_product_vat_rate_cmd(product_id, vat_rate)) - end - - def set_product_name(product_id, name) - command_bus.(name_product_cmd(product_id, name)) - end - - def create_product_cmd(product_id) - ProductCatalog::RegisterProduct.new(product_id: product_id) - end - - def name_product_cmd(product_id, name) - ProductCatalog::NameProduct.new(product_id: product_id, name: name) - end - - def set_product_price_cmd(product_id, price) - Pricing::SetPrice.new(product_id: product_id, price: price) - end - - def set_product_vat_rate_cmd(product_id, vat_rate) - Taxes::SetVatRate.new(product_id: product_id, vat_rate: vat_rate) - end - - def set_product_future_price_cmd(product_id, price, valid_since) - Pricing::SetFuturePrice.new( - product_id: product_id, - price: price, - valid_since: valid_since - ) - end - def product_params - params.permit(:name, :price, :vat_rate, :product_id).to_h.symbolize_keys.slice(:price, :vat_rate, :product_id, :name) + params.require(:product).permit(:name, :price, :vat_rate).to_h.symbolize_keys.slice(:price, :vat_rate, :name) end end diff --git a/rails_application/app/controllers/shipments_controller.rb b/rails_application/app/controllers/shipments_controller.rb index 297a55cba..e7abb91a8 100644 --- a/rails_application/app/controllers/shipments_controller.rb +++ b/rails_application/app/controllers/shipments_controller.rb @@ -1,10 +1,5 @@ class ShipmentsController < ApplicationController def index - @shipments = - Shipments::Shipment - .includes(:order) - .order("id DESC") - .page(params[:page]) - .per(10) + @orders = Order.order("id DESC").page(params[:page]).per(10) end end diff --git a/rails_application/app/controllers/shipping_addresses_controller.rb b/rails_application/app/controllers/shipping_addresses_controller.rb index c166844b1..42dbd2607 100644 --- a/rails_application/app/controllers/shipping_addresses_controller.rb +++ b/rails_application/app/controllers/shipping_addresses_controller.rb @@ -1,23 +1,14 @@ class ShippingAddressesController < ApplicationController def edit - @shipment = Shipments::Shipment.find_or_initialize_by(order_uid: params[:order_id]) - @order = Shipments::Order.find_or_initialize_by(uid: params[:order_id]) + @order = Order.find(params[:order_id]) end def update - cmd = - Shipping::AddShippingAddressToShipment.new( - order_id: params[:order_id], - postal_address: { - line_1: address_params[:address_line_1], - line_2: address_params[:address_line_2], - line_3: address_params[:address_line_3], - line_4: address_params[:address_line_4] - } - ) - command_bus.(cmd) - @order = Shipments::Order.find_or_initialize_by(uid: params[:order_id]) + @order = Order.find(params[:order_id]) + + @order.update!(address_params) + redirect_to @order.submitted? ? order_path(params[:order_id]) : edit_order_path(params[:order_id]), notice: "Shippping Address was successfully updated" end @@ -25,11 +16,11 @@ def update private def address_params - params.require(:shipments_shipment).permit( - :address_line_1, - :address_line_2, - :address_line_3, - :address_line_4 + params.require(:order).permit( + :addressed_to, + :address, + :city, + :country ) end end diff --git a/rails_application/app/controllers/supplies_controller.rb b/rails_application/app/controllers/supplies_controller.rb index 471ce29a4..38ad8cc4a 100644 --- a/rails_application/app/controllers/supplies_controller.rb +++ b/rails_application/app/controllers/supplies_controller.rb @@ -4,15 +4,9 @@ def new end def create - supply(params[:product_id], params[:quantity]) + product = Product.find(params[:product_id]) + product.stock_level == nil ? product.stock_level = params[:quantity].to_i : product.stock_level += params[:quantity].to_i + product.save! redirect_to products_path, notice: "Stock level changed" end - - private - - def supply(product_id, quantity) - command_bus.( - Inventory::Supply.new(product_id: product_id, quantity: quantity) - ) - end end diff --git a/rails_application/app/models/customer.rb b/rails_application/app/models/customer.rb new file mode 100644 index 000000000..818048015 --- /dev/null +++ b/rails_application/app/models/customer.rb @@ -0,0 +1,12 @@ +class Customer < ApplicationRecord + has_many :orders + + def full_name + "#{first_name} #{last_name}" + end + + def promote_to_vip + raise AlreadyVip if vip + update!(vip: true) + end +end diff --git a/rails_application/app/models/invoice.rb b/rails_application/app/models/invoice.rb new file mode 100644 index 000000000..51e318981 --- /dev/null +++ b/rails_application/app/models/invoice.rb @@ -0,0 +1,13 @@ +class Invoice < ApplicationRecord + self.table_name = "invoices_tbl" + + belongs_to :order, class_name: "Order", foreign_key: "order_id" + + def issued? + issued_at.present? + end + + def address_present? + address.present? + end +end diff --git a/rails_application/app/models/order.rb b/rails_application/app/models/order.rb new file mode 100644 index 000000000..b0e03a602 --- /dev/null +++ b/rails_application/app/models/order.rb @@ -0,0 +1,33 @@ +class Order < ApplicationRecord + has_many :order_items + has_one :invoice + + def state + self.status + end + + def customer + Customer.find(customer_id) if customer_id + end + + def submitted? + status == "Submitted" + end + + def invoice_issued? + invoice_issued + end + + def shipment_full_address + "#{address}, #{city}, #{country} #{addressed_to}" + end + + def billing_address_specified? + invoice_tax_id_number.present? && + invoice_country.present? && + invoice_address.present? && + invoice_city.present? && + invoice_addressed_to.present? && + invoice_address.present? + end +end diff --git a/rails_application/app/models/order_item.rb b/rails_application/app/models/order_item.rb new file mode 100644 index 000000000..1376198f2 --- /dev/null +++ b/rails_application/app/models/order_item.rb @@ -0,0 +1,5 @@ +class OrderItem < ApplicationRecord + def product + Product.find(product_id) + end +end diff --git a/rails_application/app/models/product.rb b/rails_application/app/models/product.rb new file mode 100644 index 000000000..ee38eb4aa --- /dev/null +++ b/rails_application/app/models/product.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class Product < ApplicationRecord + before_create :set_stock_level + + def set_stock_level + self.stock_level = 0 + end +end diff --git a/rails_application/app/read_models/client_orders/orders_list.rb b/rails_application/app/read_models/client_orders/orders_list.rb index c73cd0fa9..621056ef6 100644 --- a/rails_application/app/read_models/client_orders/orders_list.rb +++ b/rails_application/app/read_models/client_orders/orders_list.rb @@ -70,7 +70,7 @@ def orders_rows(client_orders) client_order.state end td class: "py-2 text-right" do - number_to_currency(client_order.discounted_value) + number_to_currency(client_order.discount) end end end diff --git a/rails_application/app/read_models/client_orders/reset_discount.rb b/rails_application/app/read_models/client_orders/reset_discount.rb index 8af8d72d7..537f2dccf 100644 --- a/rails_application/app/read_models/client_orders/reset_discount.rb +++ b/rails_application/app/read_models/client_orders/reset_discount.rb @@ -2,7 +2,7 @@ module ClientOrders class ResetDiscount def call(event) order = Order.find_by(order_uid: event.data.fetch(:order_id)) - order.percentage_discount = nil + order.discount = nil order.save! end end diff --git a/rails_application/app/read_models/client_orders/show_order.rb b/rails_application/app/read_models/client_orders/show_order.rb index c764b43d7..b8cc5d0ef 100644 --- a/rails_application/app/read_models/client_orders/show_order.rb +++ b/rails_application/app/read_models/client_orders/show_order.rb @@ -72,8 +72,8 @@ def item_row(item) def footer_rows(order) tfoot class: "border-t-4" do - before_discounts_row(order) if order.discounted_value != order.total_value - general_discount_row(order) if order.percentage_discount + before_discounts_row(order) if order.discount != order.total + general_discount_row(order) if order.discount total_row(order) end end @@ -81,21 +81,21 @@ def footer_rows(order) def before_discounts_row(order) tr class: "border-t" do td(class: "py-2", colspan: 3) { "Before discounts" } - td(class: "py-2 text-right", id: "before-discounts-value") { number_to_currency(order.total_value) } + td(class: "py-2 text-right", id: "before-discounts-value") { number_to_currency(order.total) } end end def general_discount_row(order) tr class: "border-t" do td(class: "py-2", colspan: 3) { "General discount" } - td(class: "py-2 text-right") { "#{order.percentage_discount}%" } + td(class: "py-2 text-right") { "#{order.discount}%" } end end def total_row(order) tr class: "border-t" do td(class: "py-2", colspan: 3) { "Total" } - td(class: "py-2 text-right font-bold") { number_to_currency(order.discounted_value) } + td(class: "py-2 text-right font-bold") { number_to_currency(order.discount) } end end end diff --git a/rails_application/app/read_models/client_orders/update_discount.rb b/rails_application/app/read_models/client_orders/update_discount.rb index ca393197c..3ea51a797 100644 --- a/rails_application/app/read_models/client_orders/update_discount.rb +++ b/rails_application/app/read_models/client_orders/update_discount.rb @@ -2,7 +2,7 @@ module ClientOrders class UpdateDiscount def call(event) order = Order.find_or_create_by!(order_uid: event.data.fetch(:order_id)) - order.percentage_discount = event.data.fetch(:amount) + order.discount = event.data.fetch(:amount) order.save! end end diff --git a/rails_application/app/read_models/client_orders/update_order_total_value.rb b/rails_application/app/read_models/client_orders/update_order_total_value.rb index 87a879b48..9100cb6dd 100644 --- a/rails_application/app/read_models/client_orders/update_order_total_value.rb +++ b/rails_application/app/read_models/client_orders/update_order_total_value.rb @@ -2,8 +2,8 @@ module ClientOrders class UpdateOrderTotalValue def call(event) order = Order.find_or_create_by!(order_uid: event.data.fetch(:order_id)) { |order| order.state = "Draft" } - order.discounted_value = event.data.fetch(:discounted_amount) - order.total_value = event.data.fetch(:total_amount) + order.discount = event.data.fetch(:discounted_amount) + order.total = event.data.fetch(:total_amount) order.save! end end diff --git a/rails_application/app/read_models/client_orders/update_paid_orders_summary.rb b/rails_application/app/read_models/client_orders/update_paid_orders_summary.rb index 20f73be80..0306b4465 100644 --- a/rails_application/app/read_models/client_orders/update_paid_orders_summary.rb +++ b/rails_application/app/read_models/client_orders/update_paid_orders_summary.rb @@ -3,7 +3,7 @@ class UpdatePaidOrdersSummary def call(event) order = Order.find_by(order_uid: event.data.fetch(:order_id)) client = Client.where(uid: order.client_uid).first - client.update(paid_orders_summary: client.paid_orders_summary + order.discounted_value) + client.update(paid_orders_summary: client.paid_orders_summary + order.discount) end end end diff --git a/rails_application/app/read_models/customers/update_paid_orders_summary.rb b/rails_application/app/read_models/customers/update_paid_orders_summary.rb index 9c9d29659..e8203fc66 100644 --- a/rails_application/app/read_models/customers/update_paid_orders_summary.rb +++ b/rails_application/app/read_models/customers/update_paid_orders_summary.rb @@ -3,7 +3,7 @@ class UpdatePaidOrdersSummary def call(event) order = ClientOrders::Order.find_by(order_uid: event.data.fetch(:order_id)) customer = Customer.find(order.client_uid) - customer.update(paid_orders_summary: customer.paid_orders_summary + order.discounted_value) + customer.update(paid_orders_summary: customer.paid_orders_summary + order.discount) end end end diff --git a/rails_application/app/read_models/products/configuration.rb b/rails_application/app/read_models/products/configuration.rb deleted file mode 100644 index e8174f0af..000000000 --- a/rails_application/app/read_models/products/configuration.rb +++ /dev/null @@ -1,55 +0,0 @@ -module Products - class Product < ApplicationRecord - self.table_name = "products" - serialize :current_prices_calendar, Array - - def current_prices_calendar - return [] unless super - super.map(&method(:parse_calendar_entry)) - end - - def price(time = Time.current) - last_price_before(time) - end - - def future_prices_calendar - current_prices_calendar.select { |entry| entry[:valid_since] > Time.current } - end - - private - - def last_price_before(time) - (prices_before(time).last || {})[:price] - end - - def prices_before(time) - current_prices_calendar.partition { |entry| entry[:valid_since] < time }.first - end - - def parse_calendar_entry(entry) - { - valid_since: Time.zone.parse(time_of(entry)).in_time_zone(Time.current.zone), - price: BigDecimal(entry[:price]) - } - end - - def time_of(entry) - entry[:valid_since] - end - end - - class Configuration - def initialize(event_store) - @read_model = SingleTableReadModel.new(event_store, Product, :product_id) - @event_store = event_store - end - - def call - @read_model.subscribe_create(ProductCatalog::ProductRegistered) - @read_model.subscribe_copy(ProductCatalog::ProductNamed, :name) - @read_model.subscribe_copy(Inventory::StockLevelChanged, :stock_level) - @read_model.subscribe_copy(Taxes::VatRateSet, [:vat_rate, :code]) - @event_store.subscribe(RefreshFuturePricesCalendar, to: [Pricing::PriceSet]) - end - end -end diff --git a/rails_application/app/read_models/products/refresh_future_prices_calendar.rb b/rails_application/app/read_models/products/refresh_future_prices_calendar.rb deleted file mode 100644 index 276a8982f..000000000 --- a/rails_application/app/read_models/products/refresh_future_prices_calendar.rb +++ /dev/null @@ -1,23 +0,0 @@ -module Products - class RefreshFuturePricesCalendar - def call(event) - product_id = event.data.fetch(:product_id) - product = Product.find_or_create_by(id: product_id) - product.update!(current_prices_calendar: updated_prices_calendar(event, product)) - end - - private - - def updated_prices_calendar(event, product) - (product.read_attribute(:current_prices_calendar) << new_entry_from_event(event)) - .sort_by { |entry| Time.parse(entry[:valid_since]) } - end - - def new_entry_from_event(event) - { - price: event.data.fetch(:price).to_s, - valid_since: event.metadata.fetch(:valid_at).to_s - } - end - end -end diff --git a/rails_application/app/views/billing_addresses/edit.erb b/rails_application/app/views/billing_addresses/edit.erb index 5d61da338..7db7db63a 100644 --- a/rails_application/app/views/billing_addresses/edit.erb +++ b/rails_application/app/views/billing_addresses/edit.erb @@ -5,9 +5,9 @@ <% content_for(:actions) do %> <%= secondary_action_button do %> <% if @order.submitted? %> - <%= link_to 'Back', order_path(@order.uid) %> + <%= link_to 'Back', order_path(@order.id) %> <% else %> - <%= link_to 'Back', edit_order_path(@order.uid) %> + <%= link_to 'Back', edit_order_path(@order.id) %> <% end %> <% end %> @@ -16,35 +16,35 @@ <% end %> <% end %> -<%= form_with(model: @invoice, url: order_billing_address_path(@invoice.order_uid), method: "patch", id: "form") do |form| %> +<%= form_with(model: @order, url: order_billing_address_path(@order.id), method: "patch", id: "form") do |form| %>
- <%= form.text_field :tax_id_number, required: false, class: "mt-1 focus:ring-blue-500 focus:border-blue-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" %> + <%= form.text_field :invoice_tax_id_number, required: false, class: "mt-1 focus:ring-blue-500 focus:border-blue-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" %>
- <%= form.text_field :address_line_1, required: true, class: "mt-1 focus:ring-blue-500 focus:border-blue-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" %> + <%= form.text_field :invoice_addressed_to, required: true, class: "mt-1 focus:ring-blue-500 focus:border-blue-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" %>
- <%= form.text_field :address_line_2, required: true, class: "mt-1 focus:ring-blue-500 focus:border-blue-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" %> + <%= form.text_field :invoice_address, required: true, class: "mt-1 focus:ring-blue-500 focus:border-blue-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" %>
- <%= form.text_field :address_line_3, required: true, class: "mt-1 focus:ring-blue-500 focus:border-blue-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" %> + <%= form.text_field :invoice_city, required: true, class: "mt-1 focus:ring-blue-500 focus:border-blue-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" %>
- <%= form.text_field :address_line_4, required: true, class: "mt-1 focus:ring-blue-500 focus:border-blue-500 block shadow-sm sm:text-sm border-gray-300 rounded-md" %> + <%= form.text_field :invoice_country, required: true, class: "mt-1 focus:ring-blue-500 focus:border-blue-500 block shadow-sm sm:text-sm border-gray-300 rounded-md" %>
<% end %> diff --git a/rails_application/app/views/customers/index.html.erb b/rails_application/app/views/customers/index.html.erb index 2200db920..ae69bb94a 100644 --- a/rails_application/app/views/customers/index.html.erb +++ b/rails_application/app/views/customers/index.html.erb @@ -20,7 +20,7 @@ <% @customers.each do |customer| %> - <%= link_to customer.name, customer_path(customer), class: "text-blue-500 hover:underline" %> + <%= link_to customer.email, customer_path(customer), class: "text-blue-500 hover:underline" %> <%- if customer.vip %> Already a VIP diff --git a/rails_application/app/views/customers/new.html.erb b/rails_application/app/views/customers/new.html.erb index 97733f124..a3d4cd400 100644 --- a/rails_application/app/views/customers/new.html.erb +++ b/rails_application/app/views/customers/new.html.erb @@ -12,11 +12,17 @@ <% end %> <% end %> -<%= form_tag({controller: "customers", action: "create"}, method: "post", id: "form") do %> - <%= hidden_field_tag(:customer_id, @customer_id) %> - -