spree_np_atobarai 1.0.0

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.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/Gemfile +3 -0
  4. data/LICENSE +673 -0
  5. data/README.md +71 -0
  6. data/app/controllers/spree/admin/np_orders_controller.rb +36 -0
  7. data/app/controllers/spree_np_atobarai/checkout_controller_decorator.rb +26 -0
  8. data/app/models/spree/payment_method/np_atobarai.rb +94 -0
  9. data/app/models/spree_np_atobarai/order_decorator.rb +114 -0
  10. data/app/models/spree_np_atobarai/payment_decorator.rb +23 -0
  11. data/app/overrides/add_invoice_sending_method_to_account_orders.rb +27 -0
  12. data/app/overrides/add_invoice_sending_method_to_checkout_summary.rb +13 -0
  13. data/app/overrides/add_invoice_sending_method_to_payment.rb +11 -0
  14. data/app/overrides/add_invoice_sending_method_to_purchased_items_table.rb +22 -0
  15. data/app/overrides/hide_preference_fields_for_payment_method_np_atobarai.rb +10 -0
  16. data/app/overrides/set_orders_active_for_np_orders.rb +10 -0
  17. data/app/services/spree_np_atobarai/order_csv_service.rb +123 -0
  18. data/app/views/spree/admin/np_orders/index.html.erb +29 -0
  19. data/app/views/spree/admin/payment_methods/custom_form_fields/_np_atobarai_form_fields.html.erb +32 -0
  20. data/app/views/spree/checkout/payment/_npatobarai.html.erb +12 -0
  21. data/app/views/spree_np_atobarai/_np_atobarai_invoice_options.html.erb +24 -0
  22. data/app/views/spree_np_atobarai/admin/_orders_nav_item.html.erb +4 -0
  23. data/app/views/spree_np_atobarai/admin/np_orders/_list.html.erb +29 -0
  24. data/app/views/spree_np_atobarai/admin/np_orders/_order.html.erb +31 -0
  25. data/bin/rails +8 -0
  26. data/config/initializers/admin_navigation.rb +20 -0
  27. data/config/locales/activerecord.en.yml +9 -0
  28. data/config/locales/activerecord.ja.yml +9 -0
  29. data/config/locales/en.yml +21 -0
  30. data/config/locales/ja.yml +25 -0
  31. data/config/routes.rb +9 -0
  32. data/db/migrate/20250401033922_add_column_invoice_sending_to_payment.rb +5 -0
  33. data/lib/generators/spree_np_atobarai/install_generator.rb +19 -0
  34. data/lib/spree_np_atobarai/engine.rb +34 -0
  35. data/lib/spree_np_atobarai/version.rb +7 -0
  36. data/lib/spree_np_atobarai.rb +5 -0
  37. data/spree_np_atobarai.gemspec +29 -0
  38. metadata +151 -0
@@ -0,0 +1,24 @@
1
+ <div class="NpAtobarai-invoice-options ml-3 mb-4">
2
+ <div><%= Spree.t('please_select_invoice_sending_method') %></div>
3
+
4
+ <% if order.confirm? && current_payment&.persisted? %>
5
+ <%# confirm画面の場合、既存のPaymentを更新するためにidとpayment_method_idを含める %>
6
+ <%= hidden_field_tag "order[payments_attributes][][id]", current_payment.id %>
7
+ <%= hidden_field_tag "order[payments_attributes][][payment_method_id]", current_payment.payment_method_id %>
8
+ <% end %>
9
+
10
+ <% Spree::PaymentMethod::NpAtobarai.invoice_sending_options.keys.each do |invoice_method| %>
11
+ <% checked = current_payment&.payment_method_id == payment_method.id && current_payment&.invoice_sending == invoice_method %>
12
+ <% next if order.confirm? && !checked %>
13
+ <%= label_tag(nil, class: "custom-control custom-radio flex items-center cursor-pointer w-full mt-2") do %>
14
+ <%= radio_button_tag "order[payments_attributes][][invoice_sending]",
15
+ invoice_method,
16
+ checked,
17
+ class: "invoice-method-radio mr-3",
18
+ data: { payment_method_id: payment_method.id } %>
19
+
20
+ <%= Spree::Payment.human_invoice_sending_name(invoice_method) %>
21
+ <% end %>
22
+
23
+ <% end %>
24
+ </div>
@@ -0,0 +1,4 @@
1
+ <%= nav_item(
2
+ Spree.t('admin.orders.np_atobarai'),
3
+ spree.admin_np_orders_path(q: { payment_state_eq: 'balance_due' })
4
+ ) %>
@@ -0,0 +1,29 @@
1
+ <% if @orders.any? %>
2
+ <div class="table-responsive">
3
+ <table class="table position-relative" id="listing_orders">
4
+ <thead>
5
+ <tr>
6
+ <th><%= I18n.t(:number, scope: 'activerecord.attributes.spree/order') %></th>
7
+ <% if controller_name == 'orders' %>
8
+ <th><%= sort_link @search, :completed_at, Spree.t(:date) %></th>
9
+ <% else %>
10
+ <th><%= sort_link @search, :created_at, Spree.t(:date) %></th>
11
+ <% end %>
12
+ <th class="d-customer"><%= Spree.t(:customer) %></th>
13
+ <th><%= Spree.t(:package_from) %></th>
14
+ <th><%= I18n.t(:invoice_sending, scope: 'activerecord.attributes.spree/payment') %></th>
15
+ <th><%= I18n.t(:payment_state, scope: 'activerecord.attributes.spree/order') %></th>
16
+ <th><%= I18n.t(:shipment_state, scope: 'activerecord.attributes.spree/order') %></th>
17
+ <th class="text-right"><%= sort_link @search, :item_count, I18n.t(:item_count, scope: 'activerecord.attributes.spree/order') %></th>
18
+ <th class="text-right"><%= sort_link @search, :total, I18n.t(:total, scope: 'activerecord.attributes.spree/order') %></th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <%= render collection: @orders, partial: 'spree_np_atobarai/admin/np_orders/order', cached: !(defined?(current_vendor) && current_vendor) ? spree_base_cache_scope : false %>
23
+ </tbody>
24
+ </table>
25
+ </div>
26
+ <% else %>
27
+ <%= render 'spree/admin/shared/no_resource_found', new_object_url: nil, model_class: Spree::Order %>
28
+ <% end %>
29
+ <%= render 'spree/admin/shared/index_table_options', collection: @orders if @orders.any? %>
@@ -0,0 +1,31 @@
1
+ <tr id="<%= dom_id(order) %>" data-controller="row-link">
2
+ <td class="p-0 w-10">
3
+ <%= link_to order.number, spree.edit_admin_order_path(order), class: 'font-bolder block p-2 px-4 no-underline', data: { 'turbo-frame': '_top', row_link_target: :link } %>
4
+ </td>
5
+ <td class="w-15 cursor-pointer" data-action="click->row-link#openLink">
6
+ <%= l((order.completed? ? order.completed_at : order.created_at), format: :middle) %>
7
+ </td>
8
+ <td class="d-customer w-15 cursor-pointer" data-action="click->row-link#openLink">
9
+ <%= render 'spree/admin/orders/customer_summary', order: order %>
10
+ </td>
11
+ <td class="whitespace-normal w-20 cursor-pointer" data-action="click->row-link#openLink">
12
+ <% order.shipments.map(&:stock_location).compact.uniq.each_with_index do |stock_location, index| %>
13
+ <% if index > 0 %>, <% end %><%= stock_location.name %>
14
+ <% end %>
15
+ </td>
16
+ <td class="d-customer w-15 cursor-pointer" data-action="click->row-link#openLink">
17
+ <%= order.human_invoice_sending_name %>
18
+ </td>
19
+ <td class="w-10 cursor-pointer" data-action="click->row-link#openLink">
20
+ <%= order_payment_state(order) %>
21
+ </td>
22
+ <td class="w-10 cursor-pointer" data-action="click->row-link#openLink">
23
+ <%= order_shipment_state(order) %>
24
+ </td>
25
+ <td class="text-end w-10 cursor-pointer" data-action="click->row-link#openLink">
26
+ <%= pluralize(order.item_count, 'item') %>
27
+ </td>
28
+ <td class="text-end w-10 cursor-pointer" data-action="click->row-link#openLink">
29
+ <%= order.display_total.to_html %>
30
+ </td>
31
+ </tr>
data/bin/rails ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" from the root of your extension
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/spree_np_atobarai/engine', __FILE__)
6
+
7
+ require 'rails/all'
8
+ require 'rails/engine/commands'
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Spree 5.2 の新ナビゲーションシステム(legacy_sidebar_navigation=false)に対応。
4
+ # 旧 store_orders_nav_partials(render_admin_partials方式)は新システムで無視されるため、
5
+ # Spree.admin.navigation.sidebar に orders の子メニュー(NP後払い)として登録する。
6
+ #
7
+ # engine.rb の config.after_initialize ではなく config/initializers 配下に置くのは、
8
+ # engine 初期化段階の after_initialize は本家ナビ定義(orders 登録)より早く実行され、
9
+ # orders コンテキストがまだ無いため登録できないことへの対応。
10
+ Rails.application.config.after_initialize do
11
+ next unless Spree.admin.navigation.sidebar.exists?(:orders)
12
+
13
+ Spree.admin.navigation.sidebar.add :np_atobarai,
14
+ parent: :orders,
15
+ label: 'admin.orders.np_atobarai',
16
+ url: -> { spree.admin_np_orders_path(q: { payment_state_eq: 'balance_due' }) },
17
+ position: 50,
18
+ active: -> { controller_name == 'np_orders' },
19
+ if: -> { can?(:admin, Spree::Order) }
20
+ end
@@ -0,0 +1,9 @@
1
+ en:
2
+ activerecord:
3
+ attributes:
4
+ spree/payment:
5
+ invoice_sending: "Invoice sending method"
6
+ invoice_sendings:
7
+ postal: "Postal"
8
+ email: "Email (Convenience store payment unavailable)"
9
+ other: "Other"
@@ -0,0 +1,9 @@
1
+ ja:
2
+ activerecord:
3
+ attributes:
4
+ spree/payment:
5
+ invoice_sending: "請求書送付方法"
6
+ invoice_sendings:
7
+ postal: "郵送"
8
+ email: "メール コンビニ払いはご利用不可"
9
+ other: "その他"
@@ -0,0 +1,21 @@
1
+ en:
2
+ spree:
3
+ np_atobarai_fee_adjustment: "NP Postpay Fee Adjustment"
4
+
5
+ admin:
6
+ orders:
7
+ np_atobarai: "NP Postpay"
8
+ np_atobarai:
9
+ btns:
10
+ btn_export: "CSV Export"
11
+ np_atobarai_fee: "Fee"
12
+ np_atobarai_no_fee_same_month: "No charge if there is already an order in the same month"
13
+ please_select_invoice_sending_method: "Please select the invoice sending method."
14
+
15
+ storefront:
16
+ checkout:
17
+ np_atobarai:
18
+ description: "NP Postpay is a payment method that allows you to pay (via postal transfer, bank transfer, or convenience store payment) after confirming the product."
19
+ concept: "Order Number"
20
+ amount: "Order Amount"
21
+ extra: "NP Postpaid Fee is separately charged as %{extra}."
@@ -0,0 +1,25 @@
1
+ ja:
2
+ spree:
3
+ np_atobarai_fee_adjustment: "NP後払い手数料"
4
+ np_atobarai:
5
+ fee_label: "NP後払い手数料"
6
+ fee_hint: "郵送の際にかかる手数料(税込)の設定です"
7
+ no_fee_same_month_label: "同月の注文がすでにあるなら手数料を徴収しない"
8
+ no_fee_same_month_hint: "同月にNP後払い(郵送)での注文がすでにある場合、手数料を徴収しません"
9
+ admin:
10
+ orders:
11
+ np_atobarai: "NP後払い"
12
+ np_atobarai:
13
+ btns:
14
+ btn_export: "NP後払い用エクスポート"
15
+ np_atobarai_fee: "手数料"
16
+ np_atobarai_no_fee_same_month: "同月の注文がすでにあるなら課金されない"
17
+ please_select_invoice_sending_method: "請求書の送付方法を選択してください。"
18
+
19
+ storefront:
20
+ checkout:
21
+ np_atobarai:
22
+ description: "NP後払いは商品をお届けした後にお支払い(銀行振込・コンビニ払い)ができる決済方法です。"
23
+ concept: "注文番号"
24
+ amount: "注文金額"
25
+ extra: "NP後払いの請求書を郵送にてお受け取りの場合、請求書発行手数料として%{extra}が別途発生します。"
data/config/routes.rb ADDED
@@ -0,0 +1,9 @@
1
+ Spree::Core::Engine.routes.draw do
2
+ namespace :admin, path: Spree.admin_path do
3
+ resources :np_orders, only: [ :index ] do
4
+ collection do
5
+ post :csv_export
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ class AddColumnInvoiceSendingToPayment < ActiveRecord::Migration[8.0]
2
+ def change
3
+ add_column :spree_payments, :invoice_sending, :string, null: true
4
+ end
5
+ end
@@ -0,0 +1,19 @@
1
+ module SpreeNpAtobarai
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ class_option :auto_run_migrations, type: :boolean, default: false
5
+
6
+ def add_migrations
7
+ run 'bundle exec rake railties:install:migrations FROM=spree_np_atobarai'
8
+ end
9
+
10
+ def run_migrations
11
+ if options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
12
+ run 'bundle exec rake db:migrate'
13
+ else
14
+ puts "Skiping rake db:migrate, don't forget to run it!"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,34 @@
1
+ module SpreeNpAtobarai
2
+ class Engine < Rails::Engine
3
+ require 'spree/core'
4
+ isolate_namespace Spree
5
+ engine_name 'spree_np_atobarai'
6
+
7
+ def self.activate
8
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
9
+ Rails.configuration.cache_classes ? require(c) : load(c)
10
+ end
11
+ end
12
+
13
+ config.after_initialize do |app|
14
+ # Add NpAtobarai payment method to Spree's payment methods
15
+ app.config.spree.payment_methods << ::Spree::PaymentMethod::NpAtobarai
16
+
17
+ # 管理画面メニュー(NP後払い)は Spree 5.2 の新ナビゲーションシステムに対応するため
18
+ # config/initializers/admin_navigation.rb に移動した。
19
+ # (engine.rb の config.after_initialize は本家ナビ定義より早く実行され、
20
+ # orders コンテキストがまだ無いため登録できない)
21
+
22
+ # Add invoice_sending attribute to Spree's permitted checkout attributes
23
+ Spree::PermittedAttributes.payment_attributes << :invoice_sending
24
+ end
25
+
26
+ initializer 'spree_np_atobarai.autoloader' do |app|
27
+ if Rails.autoloaders.zeitwerk_enabled?
28
+ Rails.autoloaders.main.ignore("#{root}/app/overrides")
29
+ end
30
+ end
31
+
32
+ config.to_prepare(&method(:activate).to_proc)
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ module SpreeNpAtobarai
2
+ VERSION = '1.0.0'.freeze
3
+
4
+ def gem_version
5
+ Gem::Version.new(VERSION)
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ require 'spree_core'
2
+ require 'spree_extension'
3
+ require 'spree_np_atobarai/engine'
4
+ require 'spree_np_atobarai/version'
5
+ require 'deface'
@@ -0,0 +1,29 @@
1
+ # encoding: UTF-8
2
+
3
+ lib = File.expand_path('../lib/', __FILE__)
4
+ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
5
+
6
+ require 'spree_np_atobarai/version'
7
+
8
+ Gem::Specification.new do |s|
9
+ s.platform = Gem::Platform::RUBY
10
+ s.name = 'spree_np_atobarai'
11
+ s.version = SpreeNpAtobarai::VERSION
12
+ s.summary = "A Spree extension that integrates NP Atobarai as a payment method, provides an order management interface, supports CSV export for NP orders, and allows selecting invoice sending methods."
13
+ s.required_ruby_version = '>= 3.0'
14
+
15
+ s.author = 'be agile Co., Ltd.'
16
+ s.email = 'develop@be-agile.jp'
17
+ s.homepage = 'https://github.com/be-agile/spree_np_atobarai'
18
+ s.licenses = ['AGPL-3.0-or-later']
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.require_path = 'lib'
22
+ s.requirements << 'none'
23
+
24
+ s.add_dependency 'spree', '= 5.3.6'
25
+ s.add_dependency 'spree_admin', '= 5.3.6'
26
+ s.add_dependency 'spree_storefront', '= 5.3.6'
27
+ s.add_dependency 'spree_i18n', '>= 5.3.0'
28
+ s.add_dependency 'deface'
29
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spree_np_atobarai
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - be agile Co., Ltd.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-08-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: spree
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 5.3.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 5.3.6
27
+ - !ruby/object:Gem::Dependency
28
+ name: spree_admin
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 5.3.6
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 5.3.6
41
+ - !ruby/object:Gem::Dependency
42
+ name: spree_storefront
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 5.3.6
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 5.3.6
55
+ - !ruby/object:Gem::Dependency
56
+ name: spree_i18n
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 5.3.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 5.3.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: deface
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email: develop@be-agile.jp
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - ".gitignore"
90
+ - Gemfile
91
+ - LICENSE
92
+ - README.md
93
+ - app/controllers/spree/admin/np_orders_controller.rb
94
+ - app/controllers/spree_np_atobarai/checkout_controller_decorator.rb
95
+ - app/models/spree/payment_method/np_atobarai.rb
96
+ - app/models/spree_np_atobarai/order_decorator.rb
97
+ - app/models/spree_np_atobarai/payment_decorator.rb
98
+ - app/overrides/add_invoice_sending_method_to_account_orders.rb
99
+ - app/overrides/add_invoice_sending_method_to_checkout_summary.rb
100
+ - app/overrides/add_invoice_sending_method_to_payment.rb
101
+ - app/overrides/add_invoice_sending_method_to_purchased_items_table.rb
102
+ - app/overrides/hide_preference_fields_for_payment_method_np_atobarai.rb
103
+ - app/overrides/set_orders_active_for_np_orders.rb
104
+ - app/services/spree_np_atobarai/order_csv_service.rb
105
+ - app/views/spree/admin/np_orders/index.html.erb
106
+ - app/views/spree/admin/payment_methods/custom_form_fields/_np_atobarai_form_fields.html.erb
107
+ - app/views/spree/checkout/payment/_npatobarai.html.erb
108
+ - app/views/spree_np_atobarai/_np_atobarai_invoice_options.html.erb
109
+ - app/views/spree_np_atobarai/admin/_orders_nav_item.html.erb
110
+ - app/views/spree_np_atobarai/admin/np_orders/_list.html.erb
111
+ - app/views/spree_np_atobarai/admin/np_orders/_order.html.erb
112
+ - bin/rails
113
+ - config/initializers/admin_navigation.rb
114
+ - config/locales/activerecord.en.yml
115
+ - config/locales/activerecord.ja.yml
116
+ - config/locales/en.yml
117
+ - config/locales/ja.yml
118
+ - config/routes.rb
119
+ - db/migrate/20250401033922_add_column_invoice_sending_to_payment.rb
120
+ - lib/generators/spree_np_atobarai/install_generator.rb
121
+ - lib/spree_np_atobarai.rb
122
+ - lib/spree_np_atobarai/engine.rb
123
+ - lib/spree_np_atobarai/version.rb
124
+ - spree_np_atobarai.gemspec
125
+ homepage: https://github.com/be-agile/spree_np_atobarai
126
+ licenses:
127
+ - AGPL-3.0-or-later
128
+ metadata: {}
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '3.0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements:
144
+ - none
145
+ rubygems_version: 3.4.9
146
+ signing_key:
147
+ specification_version: 4
148
+ summary: A Spree extension that integrates NP Atobarai as a payment method, provides
149
+ an order management interface, supports CSV export for NP orders, and allows selecting
150
+ invoice sending methods.
151
+ test_files: []