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: 799acd02cc226c0ceea7ffb1d1ed099a55692f96
4
- data.tar.gz: 9eef70870ee7a13a9822591d2baba9765f609b1e
3
+ metadata.gz: 4a2643479be4941c3d1c6609d7613c74f0987450
4
+ data.tar.gz: 059b00c474a704ae873480cc4396026414929577
5
5
  SHA512:
6
- metadata.gz: 8c2e7d24b5e14401b902899c70b89c7973f260288ed111231daff8036db00899ba7e1c957c6bd7047aee0ad8fc19ca901d3aed1fdcd80e5a3480da31604ee338
7
- data.tar.gz: 6d78af6d91eb805b080e351b5f3c8b6ccfba55ff611333296801a294e915e4c5b9c5e590c4350f809c2ac67bb35c9defbf8082203d0821686ab4b4ea7f45703b
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
@@ -26,7 +26,7 @@
26
26
  <ul>
27
27
  <% csample.crows.each do |crow| %>
28
28
  <li>
29
- <%= crow.offer_title %> - <%= crow.offer_price_integer %> р.
29
+ <%= crow.offer_title %> - <span class='pric'><%= crow.offer_price_integer %> р.</span>
30
30
  </li>
31
31
  <% end %>
32
32
  </ul>
@@ -1,3 +1,3 @@
1
1
  module C80Catoffers
2
- VERSION = '0.1.0.6'
2
+ VERSION = '0.1.0.7'
3
3
  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.6
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-14 00:00:00.000000000 Z
11
+ date: 2016-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler