dscf-marketplace 0.13.4 → 0.13.6

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: e713d41fece224efb5187e70f38a81a3bcb951579dbab893eb0602abdca2ded8
4
- data.tar.gz: 1beb16fefbd3e7d674fcf6854063665106d4b8858f015d396f656a23a4d37815
3
+ metadata.gz: 02ad82c5c180b78f7d7e6dd9fa99ad4f9d085fada05a9458d4f808dc4786589c
4
+ data.tar.gz: c2f9f253a2c90b0efd917f1479272bac714761e97a502eaaccc453b1cf57bfb4
5
5
  SHA512:
6
- metadata.gz: c48b573dd70627bc33628e66f304325b52c252cf1001fec0788ffc9266f47b3375772286bd9e0754f9f88ad811a6a5001fe6431c63fbb695f00ddc59eebad45a
7
- data.tar.gz: 8662c81c6b5942193a1b879f107d307666d38328186652d2f10fe6e4028280f86d96fb9b05c54f940c80a1e8af21c783ae033ce349691e8220ccb4f34f78c580
6
+ metadata.gz: fa26ea6d381ac3736aae27cb6cd1664629d39a6683524a5266ca8555cbe7c348c0d2c6c642cb1fe32cdfcb017f031091d8c6a07e146e8f7142ca319c83d5bc02
7
+ data.tar.gz: 5906f2d82f237f21a0038c2c2304a4455faeb46982fc5fb9779675796e75feb5f08f3a0584784b978a0ab159f439722a1c2c506f28d08c43ed9bf6f60096d193
@@ -462,8 +462,19 @@ module Dscf
462
462
  end
463
463
 
464
464
  items_params.map do |item_params|
465
- listing_id = item_params[:listing_id] || model_params[:listing_id]
466
- listing_type = item_params[:listing_type] || model_params[:listing_type]
465
+ # The mobile app names each aggregator-feed line by its polymorphic
466
+ # source (source_id + source_type: "Dscf::Marketplace::AggregatorListing")
467
+ # rather than listing_id/listing_type. Treat that as the listing
468
+ # reference — it identifies WHICH AggregatorListing; the final
469
+ # OrderItem.source is still re-derived per source_kind at build time.
470
+ agg_by_source = item_params[:source_type].to_s == "Dscf::Marketplace::AggregatorListing" &&
471
+ item_params[:source_id].present?
472
+ listing_id = item_params[:listing_id].presence ||
473
+ (agg_by_source ? item_params[:source_id] : nil) ||
474
+ model_params[:listing_id]
475
+ listing_type = item_params[:listing_type].presence ||
476
+ (agg_by_source ? "AggregatorListing" : nil) ||
477
+ model_params[:listing_type]
467
478
  quantity = item_params[:quantity].to_i
468
479
 
469
480
  if quantity <= 0
@@ -572,7 +583,7 @@ module Dscf
572
583
  :quotation_id, :listing_id, :user_id, :ordered_by_id, :ordered_to_id, :delivery_order_id, :dropoff_address_id,
573
584
  :order_type, :status, :fulfillment_type, :payment_method, :received_bank_name, :transaction_reference, :listing_type,
574
585
  :agent_id, :retailer_id,
575
- order_items_attributes: [ :id, :quotation_item_id, :listing_id, :listing_type, :product_id, :unit_id, :quantity, :unit_price, :status, :_destroy ]
586
+ order_items_attributes: [ :id, :quotation_item_id, :listing_id, :listing_type, :source_id, :source_type, :product_id, :unit_id, :quantity, :unit_price, :status, :_destroy ]
576
587
  )
577
588
  @model_params[:payment_method] = normalize_payment_method(@model_params[:payment_method]) if @model_params.key?(:payment_method)
578
589
  @model_params
@@ -15,7 +15,11 @@ module Dscf::Marketplace
15
15
  enum :source_kind, {catalog: 0, supplier: 1, sub_supplier: 2}, default: :catalog
16
16
 
17
17
  validates :price, numericality: {greater_than: 0}, presence: true
18
- validates :quantity, numericality: {greater_than: 0}, presence: true
18
+ # Quantity must be positive while the listing is orderable, but a sold-out
19
+ # listing legitimately holds 0 — that's exactly the state set when the last
20
+ # unit is purchased (order creation decrements to 0 and flips to :sold_out).
21
+ validates :quantity, presence: true, numericality: {greater_than_or_equal_to: 0}
22
+ validates :quantity, numericality: {greater_than: 0}, unless: :sold_out?
19
23
  validates :aggregator, presence: true
20
24
 
21
25
  # Each kind requires (and is unique on) exactly one reference.
@@ -14,7 +14,11 @@ module Dscf::Marketplace
14
14
 
15
15
  # Validations
16
16
  validates :price, numericality: {greater_than: 0}, presence: true
17
- validates :quantity, numericality: {greater_than: 0}, presence: true
17
+ # Quantity must be positive while the listing is orderable, but a sold-out
18
+ # listing legitimately holds 0 — that's exactly the state set when the last
19
+ # unit is purchased (order creation decrements to 0 and flips to :sold_out).
20
+ validates :quantity, presence: true, numericality: {greater_than_or_equal_to: 0}
21
+ validates :quantity, numericality: {greater_than: 0}, unless: :sold_out?
18
22
  validates :business_id, presence: true
19
23
  validates :supplier_product_id, presence: true
20
24
 
@@ -1,5 +1,5 @@
1
1
  module Dscf
2
2
  module Marketplace
3
- VERSION = "0.13.4".freeze
3
+ VERSION = "0.13.6".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dscf-marketplace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.4
4
+ version: 0.13.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Asrat