spree_cm_commissioner 1.11.0.pre.pre → 1.11.0.pre.pre2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c727894cc45a2d005e5c0254542ce6b8bfc054a30fe9d7b9fa6c7dfea61cfc4
4
- data.tar.gz: 9d99d30cfc27e987bffda2e0462e91a8cbe4d9a88c44c18dc67df02e947f3278
3
+ metadata.gz: 72b30d2dd7e38275035e90f40357f304bf844828ef18cd7076a737b467f2d1ac
4
+ data.tar.gz: 21d98612977148a431c77fd26633c0011cc0be1325b75a0dd9175b3b7bbe11e3
5
5
  SHA512:
6
- metadata.gz: 51065e106d1939327817aa8c54154d1711faee026b771010c9f104083da88aad01aa2f3ced6383c8f3c952e8c8cfba8035324271ee92548dc2e22449da601bf1
7
- data.tar.gz: dbc3410043aea748600477cfdd6724d1916155df35e28b62495a53950475f122eac3bf8b80de97282c82214e60ee880e807629246467ca8872753c519eb4afad
6
+ metadata.gz: fceca341a978f1022e8420f7a5b96e405de662fdb0cb1ea8fb745b4ceca48271aeaf9179e04e7512f3a7ee4049d93fb0b80443bcea1473d89b02b7d709f0f7dd
7
+ data.tar.gz: 3f15f7304214c925f4257cab2eb802211eb0ddde0af8e13bf6378ada2f668af6d509499df2be71eb9cd0aaa923c586b5843757101c4cb16c950fdc1e585d0351
@@ -15,104 +15,6 @@ on:
15
15
  tags:
16
16
  - "*"
17
17
  jobs:
18
- # validate-commits:
19
- # runs-on: ubuntu-latest
20
-
21
- # steps:
22
- # - name: Check PR title format
23
- # uses: actions/github-script@v7
24
- # with:
25
- # script: |
26
- # const title = context.payload.pull_request.title.trim();
27
-
28
- # console.log("PR title: ", title);
29
-
30
- # const pattern = /^Close\s+#\d+\s.+/;
31
-
32
- # if (!pattern.test(title)) {
33
- # core.setFailed(
34
- # `PR title must start with "Close #issue_number message". Example: Close #123 Add login form`
35
- # );
36
- # } else {
37
- # console.log("PR title format is correct.");
38
- # }
39
- # - name: Check commit messages format
40
- # uses: actions/github-script@v7
41
- # with:
42
- # script: |
43
- # const pr = context.payload.pull_request;
44
- # const commits_url = pr.commits_url;
45
-
46
- # const commits = await github.request(commits_url);
47
- # const pattern = /^Close\s+#\d+\s.+/;
48
-
49
- # let invalidCommits = [];
50
-
51
- # for (const commit of commits.data) {
52
- # const msg = commit.commit.message.trim();
53
-
54
- # console.log("commit message: ", msg);
55
-
56
- # if (!pattern.test(msg)) {
57
- # invalidCommits.push(`- ${msg}`);
58
- # }
59
- # }
60
-
61
- # if (invalidCommits.length > 0) {
62
- # core.setFailed(
63
- # `The following commit messages are not in the correct format:\n\n${invalidCommits.join(
64
- # '\n'
65
- # )}\n\nEach commit message must start with "Close #<issue_number> <message>"`
66
- # );
67
- # } else {
68
- # console.log("All commit messages are correctly formatted.");
69
- # }
70
- # - name: Check for unresolved review threads
71
- # uses: actions/github-script@v7
72
- # with:
73
- # script: |
74
- # const prNumber = context.payload.pull_request.number;
75
- # const { owner, repo } = context.repo;
76
-
77
- # const query = `
78
- # query($owner: String!, $repo: String!, $prNumber: Int!) {
79
- # repository(owner: $owner, name: $repo) {
80
- # pullRequest(number: $prNumber) {
81
- # reviewThreads(first: 100) {
82
- # nodes {
83
- # isResolved
84
- # comments(first: 1) {
85
- # nodes {
86
- # body
87
- # author {
88
- # login
89
- # }
90
- # }
91
- # }
92
- # }
93
- # }
94
- # }
95
- # }
96
- # }
97
- # `;
98
- # const variables = { owner, repo, prNumber };
99
- # const result = await github.graphql(query, variables);
100
- # const threads = result.repository.pullRequest.reviewThreads.nodes;
101
-
102
- # const unresolved = threads.filter(t => !t.isResolved);
103
-
104
- # if (unresolved.length > 0) {
105
- # unresolved.forEach(thread => {
106
- # const comments = thread.comments.nodes;
107
- # if (comments.length > 0) {
108
- # console.log(`💬 Comment by ${comments[0].author.login}: ${comments[0].body}`);
109
- # }
110
- # });
111
- # core.setFailed(`❌ There are ${unresolved.length} unresolved review thread(s). Please resolve them before merging.`);
112
- # } else {
113
- # console.log("✅ All review threads are resolved.");
114
- # }
115
-
116
18
  test_and_build_gem:
117
19
  # if: github.head_ref != '2572-enforce-pr-workflow' || github.base_ref != 'develop'
118
20
  runs-on: ubuntu-latest
@@ -164,48 +66,6 @@ jobs:
164
66
  gem install bundler
165
67
  bundle install --jobs 4 --retry 3
166
68
 
167
- # - name: Quality
168
- # env:
169
- # DATABASE_URL: postgres://myuser:mypassword@localhost:5432/test_db
170
- # run: |
171
- # bundle exec rubocop
172
-
173
- # - name: Security
174
- # env:
175
- # DATABASE_URL: postgres://myuser:mypassword@localhost:5432/test_db
176
- # run: |
177
- # bundle exec brakeman
178
-
179
- # - name: Run test
180
- # env:
181
- # DATABASE_URL: postgres://myuser:mypassword@localhost:5432/test_db
182
- # REDIS_URL: redis://localhost:6379/0
183
-
184
- # if: github.event_name == 'pull_request'
185
- # run: |
186
- # bundle exec rake
187
-
188
- # 2405-build-and-publish-gem
189
- # - name: Rename long migration files
190
- # env:
191
- # DATABASE_URL: postgres://myuser:mypassword@localhost:5432/test_db
192
- # # if: startsWith(github.ref, 'refs/tags/') # Only on tag pushes
193
- # if: github.ref == 'refs/heads/2405-build-and-publish-gem'
194
-
195
- # run: |
196
- # cd db/migrate
197
- # for file in *.rb; do
198
- # if [ ${#file} -gt 60 ]; then # Adjust threshold if needed
199
- # # Extract timestamp (first 14 chars) and shorten the rest
200
- # timestamp=${file:0:14}
201
- # suffix=$(echo "$file" | sed 's/^[0-9]\{14\}_//' | sed 's/\.rb$//')
202
- # short_suffix=$(echo "$suffix" | cut -c1-40) # Limit suffix to 40 chars
203
- # new_name="${timestamp}_${short_suffix}.rb"
204
- # mv "$file" "$new_name"
205
- # echo "Renamed $file to $new_name"
206
- # fi
207
- # done
208
-
209
69
  # Build the gem
210
70
  - name: Build gem
211
71
  env:
data/Gemfile.lock CHANGED
@@ -34,7 +34,7 @@ GIT
34
34
  PATH
35
35
  remote: .
36
36
  specs:
37
- spree_cm_commissioner (1.11.0.pre.pre)
37
+ spree_cm_commissioner (1.11.0.pre.pre2)
38
38
  activerecord-multi-tenant
39
39
  activerecord_json_validator (~> 2.1, >= 2.1.3)
40
40
  aws-sdk-cloudfront
@@ -77,6 +77,12 @@ module Spree
77
77
  Spree::StockItem
78
78
  end
79
79
 
80
+ # This method processes the parameters for stock movement creation.
81
+ # Expected attributes for `stock_movement` include:
82
+ # - :quantity (Integer): The quantity of stock to move.
83
+ # - :action (String): The type of stock movement (e.g., "add" or "remove").
84
+ # - :originator_id, :originator_ty (String, optional): The ID and type of the entity creating the stock movement.
85
+ # Ensure that `permitted_stock_movement_attributes` is updated to reflect any changes.
80
86
  def stock_movement_params
81
87
  params.require(:stock_movement).permit(permitted_stock_movement_attributes)
82
88
  end
@@ -10,9 +10,9 @@ module Spree
10
10
  @collection ||= SpreeCmCommissioner::Accommodations::Find.new(
11
11
  from_date: params[:from_date]&.to_date,
12
12
  to_date: params[:to_date]&.to_date,
13
- state_id: params[:state_id],
14
- number_of_adults: params[:number_of_adults].to_i,
15
- number_of_kids: params[:number_of_kids].to_i
13
+ state_id: params[:province_id],
14
+ number_of_adults: params[:adult].to_i,
15
+ number_of_kids: params[:children].to_i
16
16
  ).execute
17
17
  end
18
18
 
@@ -0,0 +1,15 @@
1
+ module SpreeCmCommissioner
2
+ module Stock
3
+ class InventoryItemsGenerator < BaseInteractor
4
+ delegate :variant, to: :context
5
+
6
+ def call
7
+ if variant.permanent_stock?
8
+ SpreeCmCommissioner::Stock::PermanentInventoryItemsGenerator.call(variant_ids: [variant.id])
9
+ else
10
+ variant.create_default_non_permanent_inventory_item! unless variant.default_inventory_item_exist?
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ module SpreeCmCommissioner
2
+ module Stock
3
+ class InventoryItemsGeneratorJob < ApplicationUniqueJob
4
+ def perform(variant_id:)
5
+ variant = Spree::Variant.find(variant_id)
6
+
7
+ SpreeCmCommissioner::Stock::InventoryItemsGenerator.call(variant: variant)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -16,6 +16,7 @@ module SpreeCmCommissioner
16
16
 
17
17
  before_save -> { self.product_type = variant.product_type }, if: -> { product_type.nil? }
18
18
 
19
+ # This method is only used when admin update stock
19
20
  def adjust_quantity!(quantity)
20
21
  with_lock do
21
22
  self.max_capacity = max_capacity + quantity
@@ -15,11 +15,7 @@ module SpreeCmCommissioner
15
15
  private
16
16
 
17
17
  def create_inventory_items
18
- if variant.permanent_stock?
19
- SpreeCmCommissioner::Stock::PermanentInventoryItemsGeneratorJob.perform_later(variant_ids: [variant.id])
20
- else
21
- variant.create_default_non_permanent_inventory_item! unless variant.default_inventory_item_exist?
22
- end
18
+ SpreeCmCommissioner::Stock::InventoryItemsGeneratorJob.perform_later(variant_id: variant.id)
23
19
  end
24
20
 
25
21
  # When admin delete stock item, it will deduct stock from inventory item
@@ -14,12 +14,14 @@ FactoryBot.define do
14
14
  variant.stock_items.first.adjust_count_on_hand(evaluator.total_inventory)
15
15
  variant.stock_items.update_all(backorderable: evaluator.backorderable)
16
16
 
17
+ # stock_items is created then enqueue create inventory items job
18
+ # but we want to create inventory items directly in this factory without waiting for job
17
19
  if evaluator.pregenerate_inventory_items
18
- variant.inventory_items.each { |item| item.adjust_quantity!(evaluator.total_inventory) }
19
- SpreeCmCommissioner::Stock::PermanentInventoryItemsGenerator.call(pre_inventory_days: evaluator.pre_inventory_days || 3) if variant.permanent_stock?
20
- else
21
- # make sure all inventory items are remove if exist.
22
- variant.inventory_items.destroy_all
20
+ if variant.permanent_stock?
21
+ SpreeCmCommissioner::Stock::PermanentInventoryItemsGenerator.call(variant_ids: [variant.id], pre_inventory_days: evaluator.pre_inventory_days || 3)
22
+ else
23
+ variant.create_default_non_permanent_inventory_item! unless variant.default_inventory_item_exist?
24
+ end
23
25
  end
24
26
  end
25
27
  end
@@ -1,5 +1,5 @@
1
1
  module SpreeCmCommissioner
2
- VERSION = '1.11.0-pre'.freeze
2
+ VERSION = '1.11.0-pre2'.freeze
3
3
 
4
4
  module_function
5
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_cm_commissioner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0.pre.pre
4
+ version: 1.11.0.pre.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - You
@@ -1092,6 +1092,7 @@ files:
1092
1092
  - app/interactors/spree_cm_commissioner/sqs/media_convert_job_status.rb
1093
1093
  - app/interactors/spree_cm_commissioner/state_updater.rb
1094
1094
  - app/interactors/spree_cm_commissioner/stock/inventory_items_adjuster.rb
1095
+ - app/interactors/spree_cm_commissioner/stock/inventory_items_generator.rb
1095
1096
  - app/interactors/spree_cm_commissioner/stock/permanent_inventory_items_generator.rb
1096
1097
  - app/interactors/spree_cm_commissioner/stock/stock_movement_creator.rb
1097
1098
  - app/interactors/spree_cm_commissioner/subscriptions_order_creator.rb
@@ -1156,6 +1157,7 @@ files:
1156
1157
  - app/jobs/spree_cm_commissioner/sms_pin_code_job.rb
1157
1158
  - app/jobs/spree_cm_commissioner/state_job.rb
1158
1159
  - app/jobs/spree_cm_commissioner/stock/inventory_items_adjuster_job.rb
1160
+ - app/jobs/spree_cm_commissioner/stock/inventory_items_generator_job.rb
1159
1161
  - app/jobs/spree_cm_commissioner/stock/permanent_inventory_items_generator_job.rb
1160
1162
  - app/jobs/spree_cm_commissioner/subscription_order_executor_job.rb
1161
1163
  - app/jobs/spree_cm_commissioner/telegram_debug_pin_code_sender_job.rb