spree_np_atobarai 1.0.1 → 1.0.2
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 65d71b77484c006719fbf12177c6aa65e6ab4ae2c3e9cdcc5188a9dcb8470fde
|
|
4
|
+
data.tar.gz: 76995b177b21785fadbd2002a12bc5319a0e46771b8335b717f53c4ce6763eaa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3d27fff44014a2292c51269d952f3517c7b6cc2c2d2477b9e1478885fdad73bb09d24582115c7426eaef618fac01c6015db616cf472cf3d773ff9ef58f23f74e
|
|
7
|
+
data.tar.gz: c481bdabdc7dcc8c7c97ce03fbbc0cb7435f5903de7609dd006f45cb3c4557ecef7314ca1b150eb0b1fe63ee0b99af4c28c14d3535a4d35c80e4848d9050be49
|
|
@@ -24,10 +24,11 @@ module SpreeNpAtobarai
|
|
|
24
24
|
def adjust_np_atobarai_fee
|
|
25
25
|
return if payments_attributes.blank?
|
|
26
26
|
|
|
27
|
-
destroy_np_atobarai_adjustments
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
destroyed = destroy_np_atobarai_adjustments
|
|
28
|
+
created = create_np_atobarai_fee_adjustment!(find_np_atobarai_payment_method)
|
|
29
|
+
# 支払い金額は直後に注文合計から決まるので、手数料を付け外ししたら合計を更新しておく。
|
|
30
|
+
# 付け外しが無ければ合計は変わらないので、重い再計算を省く(#1390)
|
|
31
|
+
updater.update if destroyed.any? || created
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
def find_np_atobarai_payment_method
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe SpreeNpAtobarai::OrderDecorator, type: :model do
|
|
4
|
+
describe "#update_from_params" do
|
|
5
|
+
subject do
|
|
6
|
+
allow(order.updater).to receive(:update).and_call_original
|
|
7
|
+
order.update_from_params(params, [ payments_attributes: [ :payment_method_id, :amount, :invoice_sending ] ])
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
let!(:store) { create(:store) }
|
|
11
|
+
let(:order) { create(:order_with_line_items, store:, state: 'payment') }
|
|
12
|
+
let!(:np_atobarai) { Spree::PaymentMethod::NpAtobarai.create!(name: 'NP後払い', stores: [ store ]) }
|
|
13
|
+
let(:params) do
|
|
14
|
+
ActionController::Parameters.new(order: { payments_attributes: [ { payment_method_id: np_atobarai.id, invoice_sending: } ] })
|
|
15
|
+
end
|
|
16
|
+
let(:fee_adjustment) { order.adjustments.find_by(label: Spree::PaymentMethod::NpAtobarai.np_atobarai_fee_label) }
|
|
17
|
+
let(:payment_amounts) { order.payments.valid.map(&:amount) }
|
|
18
|
+
|
|
19
|
+
context "請求書を郵送にした" do
|
|
20
|
+
let(:invoice_sending) { 'postal' }
|
|
21
|
+
|
|
22
|
+
it do
|
|
23
|
+
expect(subject).to be true
|
|
24
|
+
expect(fee_adjustment.amount).to eq 330
|
|
25
|
+
expect(payment_amounts).to eq [ order.reload.total ]
|
|
26
|
+
expect(order.updater).to have_received(:update)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context "請求書を郵送からメールに変えた" do
|
|
31
|
+
let(:invoice_sending) { 'email' }
|
|
32
|
+
|
|
33
|
+
before do
|
|
34
|
+
np_atobarai.create_np_atobarai_fee_adjustment!(order)
|
|
35
|
+
order.update_with_updater!
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it do
|
|
39
|
+
expect(subject).to be true
|
|
40
|
+
expect(fee_adjustment).to be_nil
|
|
41
|
+
expect(payment_amounts).to eq [ order.reload.total ]
|
|
42
|
+
expect(order.updater).to have_received(:update)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
context "請求書をメールにした" do
|
|
47
|
+
let(:invoice_sending) { 'email' }
|
|
48
|
+
|
|
49
|
+
# 注文合計が変わらないので、重い再計算をしない
|
|
50
|
+
it do
|
|
51
|
+
expect(subject).to be true
|
|
52
|
+
expect(fee_adjustment).to be_nil
|
|
53
|
+
expect(payment_amounts).to eq [ order.reload.total ]
|
|
54
|
+
expect(order.updater).not_to have_received(:update)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_np_atobarai
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- be agile Co., Ltd.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: spree
|
|
@@ -135,6 +135,7 @@ files:
|
|
|
135
135
|
- lib/spree_np_atobarai.rb
|
|
136
136
|
- lib/spree_np_atobarai/engine.rb
|
|
137
137
|
- lib/spree_np_atobarai/version.rb
|
|
138
|
+
- spec/models/spree_np_atobarai/order_decorator_spec.rb
|
|
138
139
|
- spree_np_atobarai.gemspec
|
|
139
140
|
homepage: https://github.com/be-agile/spree_np_atobarai
|
|
140
141
|
licenses:
|