Class: SpreeSquare::TaxMapping

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree_square/tax_mapping.rb

Overview

Mirrors one Square CatalogTax object — a plain flat percentage + an inclusion type, category-agnostic. Square's Catalog API has no concept of jurisdiction/zone at all, so this row never points at a Spree::TaxRate directly: which Spree::TaxCategory (and therefore which Spree::TaxRate) a given Square tax participates in depends on which combination of Square taxes each item carries — see TaxCategoryMapping and CatalogObjectMapper#resolve_tax_category.

square_version is Square's optimistic-concurrency token — same stale-check pattern as CatalogMapping, guards against out-of-order or duplicate webhook delivery re-processing older data over newer.

Instance Method Summary collapse

Instance Method Details

#stale?(incoming_version) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/models/spree_square/tax_mapping.rb', line 20

def stale?(incoming_version)
  square_version.present? && incoming_version.present? && incoming_version <= square_version
end