Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Andrey/adnan/solidus 4.0 #3

Open
wants to merge 65 commits into
base: adnan/solidus-4.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
55c3696
Allow feature specs to run without `--headless` mode
forkata Apr 5, 2023
f0bf55a
Add failing feature spec for retrying failed transaction syncs
forkata Apr 5, 2023
5927d99
Introduce a reportable concern to encapsulate reporting criteria
forkata Apr 5, 2023
67bd181
Move order pre-conditions into `with_reportable`
forkata Apr 14, 2023
5d0ec7c
Move `transaction_replaceable?` to module
forkata Apr 14, 2023
6691c22
Extract `with_replaceable` method to shared module
forkata May 3, 2023
5642d2c
Fire `shipment_shipped` after running `after_ship`
forkata May 3, 2023
c8e29af
Fix formatting in spec
forkata Jun 9, 2023
680edde
Stub event system on Omnes implementation
forkata Jun 9, 2023
df8ce52
Update Changelog
Noah-Silvera Jul 17, 2023
bb4940a
Switch to `File.exist?` API
forkata Jul 12, 2023
4f9c335
Rename current subscriber to Legacy and add Omnes version
forkata Jun 9, 2023
6c90c05
Drop support for load reporting subscriber prior to 2.11
forkata Jul 12, 2023
61f2460
Bump Ruby to 3.0 on CI for older versions of Solidus
forkata Jul 14, 2023
f6de719
Update CHANGELOG
forkata Jul 14, 2023
6c56129
Temporarily pend refund feature spec
forkata Jul 19, 2023
58cfde3
Sort order transactions by created_at
nvandoorn Jul 11, 2023
235314c
Update CHANGELOG.md
nvandoorn Jul 14, 2023
1f21cca
Move checkout feature spec out of admin folder
nvandoorn May 23, 2023
7fdaa48
Exclude line items that have been returned
nvandoorn Jul 13, 2023
0edb459
Don't report cancelled or returned items to TaxJar
nvandoorn Jul 14, 2023
b01e0d1
Move inventory unit query into private method
nvandoorn Aug 10, 2023
c1d0a54
Update CHANGELOG.md
nvandoorn Aug 10, 2023
18526b8
Associate refund transactions with sync logs
Noah-Silvera Mar 20, 2023
d95f5fb
Create sync log when replacing transactions
Noah-Silvera Mar 20, 2023
74b8feb
Add error handling to replace transaction job
Noah-Silvera Mar 20, 2023
9eee4ea
Show refund transaction in sync log table
Noah-Silvera Mar 20, 2023
8ff371b
Let Selenium Manager download Chrome for Testing
benjaminwil Aug 25, 2023
10b19f0
Update CHANGELOG.md
nvandoorn Aug 25, 2023
666dcbd
Extract `#with_events_disabled` helper for reuse
benjaminwil Aug 25, 2023
de0b70c
Let admins retry a TaxJar transaction sync
benjaminwil Aug 25, 2023
4cd0b84
Add CHANGELOG entry
benjaminwil Oct 13, 2023
a1e9686
Load factories in line with new Solidus conventions
forkata May 10, 2023
ed05ae6
Add Changelog entry
forkata Oct 17, 2023
77540f4
Don't depend on the `webdrivers` gem
benjaminwil Nov 21, 2023
566e59f
Improve error handling in `ReportTransactionJob`
benjaminwil Nov 21, 2023
cbead07
Add specs for existing behavior of reportable
Noah-Silvera Oct 27, 2023
d342969
Add failing feature spec for reporting instead of replacing
forkata Sep 26, 2023
d952c31
Prevent order from being reported if it is not paid
Noah-Silvera Oct 31, 2023
3adb3cc
Refactor checks in reportable module
Noah-Silvera Oct 31, 2023
ea18079
Combine the replace and report event handlers
Noah-Silvera Oct 31, 2023
7f57bd5
Remove shipment_shipped event
Noah-Silvera Dec 11, 2023
9e9a696
Update Changelog
Noah-Silvera Jan 3, 2024
2e257b1
Update CHANGELOG format to Keep a Changelog
forkata Jan 28, 2023
80b471a
Add a delay before reporting transactions
benjaminwil Jan 20, 2024
378f112
Do not include solidus_admin in sandbox app
forkata Jan 19, 2024
ab64a7b
Move admin configuration override to Deface DSL
forkata Jan 19, 2024
63cafbb
Run `bundle exec solidus extension .` to update binstubs
forkata Jan 19, 2024
cd8dda1
Add back the legacy frontend to sandbox app
forkata Jan 20, 2024
03086fe
Update CHANGELOG
benjaminwil Jan 30, 2024
43d901b
Create shared context for checkout-related specs
benjaminwil Jan 16, 2024
dc6a80f
Refactor skipped refund feature spec
benjaminwil Jan 16, 2024
0acd5d1
Fix tax calculation for orders with returned items
benjaminwil Jan 16, 2024
648b2bc
Pend spec failing on CI
Noah-Silvera Jan 30, 2024
c439fbe
Update CHANGELOG.md
Noah-Silvera Jan 31, 2024
292a825
Make README capitalization consistent
benjaminwil Jan 31, 2024
501a0d4
Tweak feature documentation in README
benjaminwil Jan 31, 2024
f2e23e5
Bump version to v1.0.0
benjaminwil Jan 31, 2024
ef698c7
Add Gem version badge to README
forkata Feb 2, 2024
3f21cae
Merge branch 'master' into andrey/adnan/solidus-4.0
ashgaliyev Jun 18, 2024
b09bc5e
Remove reporting subscriber
ashgaliyev Jun 18, 2024
db89002
subscribe to reporting subscriber
AdnanTheExcellent Sep 30, 2024
99bfe75
trigger reporting on shipment_shipped as well. update reportable crit…
AdnanTheExcellent Oct 3, 2024
2b93ed8
fix namespace issue
AdnanTheExcellent Oct 4, 2024
2b5f530
update enum syntax for rails 8.0
AdnanTheExcellent Feb 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
run-specs-solidus-older:
executor:
name: solidusio_extensions/postgres
ruby_version: "2.7"
ruby_version: "3.0"
steps:
- checkout
- browser-tools/install-browser-tools
Expand Down
69 changes: 55 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# Changelog
All notable changes to this project will be documented in this file.

## master
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

- Nothing yet.

## v1.0.0

### Added

- [#193](https://github.com/SuperGoodSoft/solidus_taxjar/pull/193) Bump version requirement for `solidus_support` to ">= 0.9.0", and as a result drop support for Rails 5.2.
- [#190](https://github.com/SuperGoodSoft/solidus_taxjar/pull/190) Add transaction sync batch show page
- [#188](https://github.com/SuperGoodSoft/solidus_taxjar/pull/188) Show transaction sync batches in user interface
- [#185](https://github.com/SuperGoodSoft/solidus_taxjar/pull/185) Backfill transactions in batches
Expand All @@ -12,23 +21,16 @@
- [#158](https://github.com/SuperGoodSoft/solidus_taxjar/pull/158) Update sandbox bin stub for `solidus@3`
- [#88](https://github.com/SuperGoodSoft/solidus_taxjar/pull/88) Fire `shipment_shipped` event when any shipment on an order ships.
- [#81](https://github.com/SuperGoodSoft/solidus_taxjar/pull/81) Add install generator
- [#95](https://github.com/SuperGoodSoft/solidus_taxjar/pull/95) Only require "state" for Canadian and US addresses
- [#98](https://github.com/SuperGoodSoft/solidus_taxjar/pull/98) Add generator for TaxJar transaction IDs
- [#103](https://github.com/SuperGoodSoft/solidus_taxjar/pull/103) Add `reporting_enabled` configuration option
- [#97](https://github.com/SuperGoodSoft/solidus_taxjar/pull/97) Add public API method to request the latest transaction associated with a solidus order.
- [#100](https://github.com/SuperGoodSoft/solidus_taxjar/pull/100) Add public API method to post a taxjar refund transaction for a solidus order.
- [#102](https://github.com/SuperGoodSoft/solidus_taxjar/pull/102) Add description to transaction line item params
- [#107](https://github.com/SuperGoodSoft/solidus_taxjar/pull/107) Fix rails-engine binstub to point to correct engine entry point
- [#108](https://github.com/SuperGoodSoft/solidus_taxjar/pull/108) Add new model associated with a `Spree::Order` to represent taxjar order creation transactions
- [#117](https://github.com/SuperGoodSoft/solidus_taxjar/pull/117) Fix migration install
- [#114](https://github.com/SuperGoodSoft/solidus_taxjar/pull/114) Add new model associated with a `SuperGood::SolidusTaxjar::OrderTransaction` to represent taxjar refund creation transactions
- [#116](https://github.com/SuperGoodSoft/solidus_taxjar/pull/116) Update the `OrderTransaction` model to record the transaction date.
- [#120](https://github.com/SuperGoodSoft/solidus_taxjar/pull/120) Change default `SOLIDUS_BRANCH` and `RAILS_VERSION`
- [#109](https://github.com/SuperGoodSoft/solidus_taxjar/pull/109) Save `OrderTransaction` after API call to TaxJar
- [#119](https://github.com/SuperGoodSoft/solidus_taxjar/pull/119) Move the install generator into the correct path so that it will be installed in the dummy app.
- [#111](https://github.com/SuperGoodSoft/solidus_taxjar/pull/111) Create a new taxjar transaction when a shipment is shipped.
- [#137](https://github.com/SuperGoodSoft/solidus_taxjar/pull/137) Only run tests against solidus 2.11. This also represents the drop of official support for solidus 2.9 and 2.10.
- [#137](https://github.com/SuperGoodSoft/solidus_taxjar/pull/137) Run tests against the most up to date versions of solidus.
- [#141](https://github.com/SuperGoodSoft/solidus_taxjar/pull/141) Handle unimplemented reporting features
- [#129](https://github.com/SuperGoodSoft/solidus_taxjar/pull/129) Report transaction asynchronously when a shipment is shipped.
- [#127](https://github.com/SuperGoodSoft/solidus_taxjar/pull/127) Add acceptance test for calculating taxes with the extension.
Expand All @@ -38,29 +40,68 @@
- [#174](https://github.com/SuperGoodSoft/solidus_taxjar/pull/174) Provide a link to Taxjar state settings
- [#177](https://github.com/SuperGoodSoft/solidus_taxjar/pull/177) Make nexus caching configurable
- [#169](https://github.com/SuperGoodSoft/solidus_taxjar/pull/169) Add basic backfill transaction functionality
- [#181](https://github.com/SuperGoodSoft/solidus_taxjar/pull/181) Take all non-tax adjustment types into account when calculating a line item's discount
- [#182](https://github.com/SuperGoodSoft/solidus_taxjar/pull/182) Automatically create default Tax Rate
- [#176](https://github.com/SuperGoodSoft/solidus_taxjar/pull/176) Create refund transaction database models when reporting refunds.
- [#192](https://github.com/SuperGoodSoft/solidus_taxjar/pull/192) Handle failures that occur in the middle of refunding a transaction.
- [#194](https://github.com/SuperGoodSoft/solidus_taxjar/pull/194) Move the transaction backfill button to it's own unique page
- [#198](https://github.com/SuperGoodSoft/solidus_taxjar/pull/198) Don't create zero dollar transactions when an order is fully refunded.
- [#195](https://github.com/SuperGoodSoft/solidus_taxjar/pull/195) Run transaction backfills asynchronously
- [#200](https://github.com/SuperGoodSoft/solidus_taxjar/pull/200) Expand solidus gem into dependencies to support Solidus 3.2+
- [#200](https://github.com/SuperGoodSoft/solidus_taxjar/pull/200) Expand `solidus` gem into dependencies to support Solidus 3.2+
- [#183](https://github.com/SuperGoodSoft/solidus_taxjar/pull/183) Add ability to fetch tax codes from TaxJar and assign to tax categories in admin
- [#200](https://github.com/SuperGoodSoft/solidus_taxjar/pull/200) Render error message when backfilling transactions fails
- [#203](https://github.com/SuperGoodSoft/solidus_taxjar/pull/203) Remove outdated backfill button
- [#202](https://github.com/SuperGoodSoft/solidus_taxjar/pull/202) Add TaxJar transaction sync status to order show page
- [#204](https://github.com/SuperGoodSoft/solidus_taxjar/pull/204) Add page to render an orders TaxJar transactions
- [#201](https://github.com/SuperGoodSoft/solidus_taxjar/pull/201) Allow transaction backfills to be filtered by date range
- [#244](https://github.com/SuperGoodSoft/solidus_taxjar/pull/244) Let admins manually retry syncing failed TaxJar transactions
- [#255](https://github.com/SuperGoodSoft/solidus_taxjar/pull/255) Add a delay before reporting transactions
- [#253](https://github.com/SuperGoodSoft/solidus_taxjar/pull/253) Fix various bugs with reporting refund transactions

### Changed

- [#95](https://github.com/SuperGoodSoft/solidus_taxjar/pull/95) Only require "state" for Canadian and US addresses
- [#181](https://github.com/SuperGoodSoft/solidus_taxjar/pull/181) Take all non-tax adjustment types into account when calculating a line item's discount
- [#182](https://github.com/SuperGoodSoft/solidus_taxjar/pull/182) Automatically create default Tax Rate
- [#205](https://github.com/SuperGoodSoft/solidus_taxjar/pull/205) Use nexus regions for taxable address checks
- [#218](https://github.com/SuperGoodSoft/solidus_taxjar/pull/218) Removed `order_recalculated` event backport
- [#216](https://github.com/SuperGoodSoft/solidus_taxjar/pull/216) Add `deface` as a dependency.
- [#217](https://github.com/SuperGoodSoft/solidus_taxjar/pull/217) Handle updates to orders that have not been reported
- [#227](https://github.com/SuperGoodSoft/solidus_taxjar/pull/227) Fix reporting for orders with refunds
- [#226](https://github.com/SuperGoodSoft/solidus_taxjar/pull/226) Refactor reporting subscriber logic
- [#238](https://github.com/SuperGoodSoft/solidus_taxjar/pull/238) Drop support for loading of reporting subscriber for Solidus < 2.11
- [#237](https://github.com/SuperGoodSoft/solidus_taxjar/pull/237) Sort order transactions by `created_at`
- [#236](https://github.com/SuperGoodSoft/solidus_taxjar/pull/236) Don't send cancelled or returned line items
- [#225](https://github.com/SuperGoodSoft/solidus_taxjar/pull/225) Create sync logs for replace transaction jobs
- [#231](https://github.com/SuperGoodSoft/solidus_taxjar/pull/231) Load Solidus factories using new conventions
- [#246](https://github.com/SuperGoodSoft/solidus_taxjar/pull/246) Fix bugs with sync retries when reporting or replacing a transaction fails

### Removed

- [#137](https://github.com/SuperGoodSoft/solidus_taxjar/pull/137) Only run tests against Solidus 2.11. This also represents the drop of official support for Solidus 2.9 and 2.10.
- [#193](https://github.com/SuperGoodSoft/solidus_taxjar/pull/193) Bump version requirement for `solidus_support` to ">= 0.9.0", and as a result drop support for Rails 5.2.

### Fixed

- [#107](https://github.com/SuperGoodSoft/solidus_taxjar/pull/107) Fix rails-engine binstub to point to correct engine entry point
- [#117](https://github.com/SuperGoodSoft/solidus_taxjar/pull/117) Fix migration install
- [#119](https://github.com/SuperGoodSoft/solidus_taxjar/pull/119) Move the install generator into the correct path so that it will be installed in the dummy app.
- [#250](https://github.com/SuperGoodSoft/solidus_taxjar/pull/250) Improve error handling for `ReportTransactionJob`
- [#254](https://github.com/SuperGoodSoft/solidus_taxjar/pull/254) Get tests and binstubs working against Solidus `main`

### Development Changes

These changes only affect the development of this extension.

- [#120](https://github.com/SuperGoodSoft/solidus_taxjar/pull/120) Change default `SOLIDUS_BRANCH` and `RAILS_VERSION`
- [#137](https://github.com/SuperGoodSoft/solidus_taxjar/pull/137) Run tests against the most up to date versions of Solidus
- [#249](https://github.com/SuperGoodSoft/solidus_taxjar/pull/249) Don't depend on `webdrivers` gem

## Upgrading Instructions
### Upgrading from 0.18.x to 1.0.0

* If you had previously configured a `Spree::TaxRate` with the name "Sales Tax", it can be deleted after upgrading, as a new `Spree::TaxRate` with the name "Solidus TaxJar Rate" will automatically be created. Alternatively, you can rename your existing `Spree::TaxRate` from "Sales Tax" to "Solidus TaxJar Rate". [#182](https://github.com/SuperGoodSoft/solidus_taxjar/pull/182)
If you had previously configured a `Spree::TaxRate` with the name "Sales Tax",
it can be deleted after upgrading, as a new `Spree::TaxRate` with the name
"Solidus TaxJar Rate" will automatically be created. Alternatively, you can
rename your existing `Spree::TaxRate` from "Sales Tax" to "Solidus TaxJar
Rate". [#182](https://github.com/SuperGoodSoft/solidus_taxjar/pull/182)

## v0.18.2

Expand Down
10 changes: 9 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
source "https://rubygems.org"
# frozen_string_literal: true

source "https://rubygems.org"
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

branch = ENV.fetch("SOLIDUS_BRANCH", "v3.1")
Expand Down Expand Up @@ -35,6 +36,13 @@ group :development, :test do
gem "pry"
gem "pry-stack_explorer"
gem "pry-byebug"

# FIXME:
# Once a new version of `solidus_dev_support` is released to RubyGems, we can
# use that.
gem "solidus_dev_support",
github: "solidusio/solidus_dev_support",
branch: "main"
end

gemspec
Expand Down
41 changes: 23 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# `SuperGood::SolidusTaxjar`

[![Gem Version](https://badge.fury.io/rb/super_good-solidus_taxjar.svg)](https://badge.fury.io/rb/super_good-solidus_taxjar)
[![CircleCI build status](https://circleci.com/gh/SuperGoodSoft/solidus_taxjar/tree/master.svg?style=shield)](https://circleci.com/gh/SuperGoodSoft/solidus_taxjar/tree/master)

`SuperGood::SolidusTaxjar` is a [Solidus](https://github.com/solidusio/solidus)
Expand Down Expand Up @@ -50,7 +50,7 @@ about using the Solidus TaxJar extension after it has been installed.
4. Finally, make sure that the `TAXJAR_API_KEY` environment variable is set to
your TaxJar API key.

### Warning: Installing on production
### Warning: Installing on Production

Before you install this extension in your production environment, **we strongly
recommend that you install and configure a supported ActiveJob backend**.
Expand All @@ -68,20 +68,7 @@ particularly helpful.
[active-job-basics]: https://edgeguides.rubyonrails.org/active_job_basics.html
[active-job-execution]: https://edgeguides.rubyonrails.org/active_job_basics.html#job-execution

## Project Status

<!-- FIXME: Modify the following paragraph for the v1.0 release. -->

This extension is under active development and not yet at a v1.0 release, but
it's currently being used in production by multiple Solidus stores.

Requirements for TaxJar integrations vary as some stores also need reporting,
which isn't provided out of the box by this extension. This is because
individual stores will be using different background job frameworks or runners
(Sidekiq, delayed_job, ActiveJob, etc.) and a reliable integration will rely on
one of these. Because this part of the integration is small, we've chosen to
provide the transaction reporting functionality, but have skipped directly
integrating it.
## Developer Support

If you're having trouble integrating this extension with your store and would
like some assistance, please reach out to Jared via e-mail at [[email protected]](mailto:[email protected])
Expand All @@ -104,9 +91,12 @@ that event to your applicaiton.
This extension also supports:

* syncing orders to TaxJar's reporting dashboard
* syncing nexus regions as configured in the connected TaxJar account
* syncing nexus regions as configured in the connected TaxJar account (including
automatic _and_ manual sync)
* connecting your Solidus store's tax categories to TaxJar's tax categories (U.S. tax codes)

**Note that reporting is turned off by default.**

### TaxCalculator

`SuperGood::SolidusTaxjar::TaxCalculator` allows calculating the full tax
Expand Down Expand Up @@ -240,7 +230,13 @@ Developers can configure the following settings in an initializer:

Default value: `false`

### Exception handling
### Taxable Orders

Note that the configuration setting `taxable_order_check` can be customized if
there is specific criteria that make some orders taxable and other orders not
taxable. By default this extension considers all orders taxable.

### Exception Handling

You can configure your own exception handler in an initializer. using the
`exception_handler` configuration point:
Expand Down Expand Up @@ -310,6 +306,15 @@ and `SOLIDUS_BRANCH` environment variables, respectively. See the
The database vendor can also be changed from the default (`sqlite3`) by setting
the `DB` environment variable.

### Testing the Extension

When testing your application's integration with this extension you may use its factories.
You can load Solidus core factories along with this extension's factories using this statement:

```ruby
SolidusDevSupport::TestingSupport::Factories.load_for(SuperGoodSolidusTaxjar::Engine)
```

## Releasing a New Version

1. Update the `master` header in changelog to the version that you're releasing.
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require 'solidus_dev_support/rake_tasks'
SolidusDevSupport::RakeTasks.install

Expand Down
37 changes: 37 additions & 0 deletions app/controllers/spree/admin/taxjar_transactions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module Spree
module Admin
class TaxjarTransactionsController < Spree::Admin::BaseController
include SuperGood::SolidusTaxjar::Reportable

def retry
order = Spree::Order.find_by number: params[:order_id]

if transaction_replaceable? order
replace_transaction order
flash[:notice] = "Queued transaction sync job"
elsif order_reportable? order
report_transaction order
flash[:notice] = "Queued transaction sync job"
else
flash[:error] = "Could not retry sync successfully"
end

redirect_to taxjar_transactions_admin_order_path(params[:order_id])
end

private

def report_transaction(order)
with_reportable(order) do
SuperGood::SolidusTaxjar::ReportTransactionJob.perform_later(order)
end
end

def replace_transaction(order)
with_replaceable(order) do
SuperGood::SolidusTaxjar::ReplaceTransactionJob.perform_later(order)
end
end
end
end
end
15 changes: 14 additions & 1 deletion app/jobs/super_good/solidus_taxjar/replace_transaction_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@ class ReplaceTransactionJob < ApplicationJob
queue_as { SuperGood::SolidusTaxjar.job_queue }

def perform(order)
SuperGood::SolidusTaxjar.reporting.refund_and_create_new_transaction(order)
order_transaction = SuperGood::SolidusTaxjar.reporting.refund_and_create_new_transaction(order)

SuperGood::SolidusTaxjar::TransactionSyncLog.create!(
order: order,
order_transaction: order_transaction,
status: :success
)

rescue Taxjar::Error => exception
SuperGood::SolidusTaxjar::TransactionSyncLog.create!(
order: order,
status: :error,
error_message: exception.message
)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def perform(order, transaction_sync_batch = nil)
begin
order_transaction = SuperGood::SolidusTaxjar.reporting.show_or_create_transaction(order)
transaction_sync_log.update!(order_transaction: order_transaction, status: :success)
rescue Taxjar::Error => exception
rescue StandardError => exception
transaction_sync_log.update!(status: :error, error_message: exception.message)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/super_good/solidus_taxjar/order_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class OrderTransaction < ActiveRecord::Base
validates_presence_of :transaction_date

def self.latest_for(order)
where(order: order).order(transaction_date: :desc).limit(1).first
where(order: order).order(transaction_date: :desc, created_at: :desc).limit(1).first
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion app/models/super_good/solidus_taxjar/transaction_sync_log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class SuperGood::SolidusTaxjar::TransactionSyncLog < ApplicationRecord
belongs_to :transaction_sync_batch, optional: true
belongs_to :order, class_name: "Spree::Order"
belongs_to :order_transaction, optional: true
delegate :refund_transaction, to: :order_transaction, :allow_nil => true

enum status: [:processing, :success, :error]
enum status [:processing, :success, :error]
end
1 change: 1 addition & 0 deletions app/overrides/spree/admin/orders_controller_override.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Spree
module Admin
module OrdersControllerOverride
# FIXME: Move this to TaxJar transactions controller.
def taxjar_transactions
load_order
end
Expand Down
15 changes: 0 additions & 15 deletions app/overrides/spree/admin/shared/_configuration_menu.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
</style>
<% end %>

<% last_success_sync_log = @order.taxjar_transaction_sync_logs.success.order(:created_at).last %>
<% last_sync_log = @order.taxjar_transaction_sync_logs.order(:created_at).last %>
<dt>Reported to TaxJar at:</dt>
<dd> <%= last_sync_log ? pretty_time(last_sync_log.created_at) : "-" %></dd>
<dd> <%= last_success_sync_log ? pretty_time(last_success_sync_log.created_at) : "-" %></dd>
<dt>TaxJar Sync: </dt>
<dd>
<% last_sync_log_status = if last_sync_log
Expand All @@ -26,3 +27,4 @@
<%= last_sync_log_status.capitalize %>
</span>
</dd>
<dt><%= link_to("TaxJar Sync History", spree.taxjar_transactions_admin_order_path(@order)) %></dt>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- insert_bottom "[data-hook='admin_settings_taxes_tabs']" -->

<%= configurations_sidebar_menu_item "TaxJar Settings", edit_admin_taxjar_settings_path %>

<%= configurations_sidebar_menu_item "TaxJar Backfill", admin_transaction_sync_batches_path %>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def self.prepended(base)
inverse_of: :order

base.has_many :taxjar_transaction_sync_logs,
-> { order(:created_at) },
class_name: "SuperGood::SolidusTaxjar::TransactionSyncLog",
inverse_of: :order
end
Expand Down
Loading