c80_catoffers 0.1.0.6 → 0.1.0.7
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a2643479be4941c3d1c6609d7613c74f0987450
|
4
|
+
data.tar.gz: 059b00c474a704ae873480cc4396026414929577
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 084fdf7c4f60f35c5658017f46f5e491e39c45f6eb973edd8fed0c214b821a4c3fc13b1fd0a66dc77fc356f6f055736b267cb3d65d2322db2b7d85b99018a71c
|
7
|
+
data.tar.gz: f387c2581a2acf9e7fe61b169e93144b9818a10259b40634802df87ecc0dd7760b73096bc24a547a769a1617b3c67a7bd5eecf956a2c2c47194b15a7a595419b
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "babosa"
|
2
2
|
|
3
3
|
module C80Catoffers
|
4
|
+
|
4
5
|
class Offer < ActiveRecord::Base
|
5
6
|
|
6
7
|
has_many :ophotos, :dependent => :destroy
|
@@ -12,9 +13,13 @@ module C80Catoffers
|
|
12
13
|
|
13
14
|
scope :def_order, -> {order(:created_at => :desc)}
|
14
15
|
|
16
|
+
after_update :recalc_parent_sample_price
|
17
|
+
after_create :recalc_parent_sample_price
|
18
|
+
|
15
19
|
has_and_belongs_to_many :categories
|
16
20
|
has_and_belongs_to_many :props
|
17
21
|
|
22
|
+
# один Offer может соответствовать нескольким Строкам
|
18
23
|
has_many :crows, :dependent => :destroy
|
19
24
|
|
20
25
|
extend FriendlyId
|
@@ -75,6 +80,20 @@ module C80Catoffers
|
|
75
80
|
d.present? ? d[0].to_i : 0
|
76
81
|
end
|
77
82
|
|
83
|
+
def recalc_parent_sample_price
|
84
|
+
# если Пример состоит в Строке
|
85
|
+
if crows.count > 0
|
86
|
+
# переберём его Строки
|
87
|
+
crows.each do |crow|
|
88
|
+
Rails.logger.debug "[TRACE] <Offer.recalc_parent_sample_price> Пересчитать стоимость Примера id=#{crow.csample.id}."
|
89
|
+
# добираемся до Примера, в чьём составе находится Строка, которая "содержит" данное Преложение, и просим его пересчитать цену
|
90
|
+
crow.csample.recalc_summ_price
|
91
|
+
end
|
92
|
+
else
|
93
|
+
Rails.logger.debug '[TRACE] <Offer.recalc_parent_sample_price> У Предложения нет Строк.'
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
78
97
|
end
|
79
98
|
|
80
99
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: c80_catoffers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- C80609A
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|