16. WE* STARTED WITH RESEARCH
*Led by Bojan Zivanovic.
Define the deficiencies in our own software
Existing */money libraries
Sonata / Sylius e-commerce bundles
Non-Symfony PHP applications
Non-PHP applications
17. IDENTIFYING OUR WEAKNESSES
Age old tax management issues
Incomplete price management API
Incomplete currency formatting rules
Address implementation stretched to the limit
Limited ability to collaborate outside of Drupal
18. PROPOSING STANDALONE SOLUTIONS
Internationalization (esp. currency formatting)
Address formatting / validation
Territory grouping (to support taxing)
Tax rate management (at least for VAT)
Price calculation and manipulation
27. PRICING
A price is a value object. Each operation (add, subtract,
multiply, divide, round) produces a new price instance. All
amounts are passed as strings, and manipulated using
bcmath.
32. ADDRESSING
Address formats for 200 countries
Subdivisions (administrative areas, localities, dependent
localities) for 40 countries
Subdivision translations for all of the parent country's (i.e
Canada, Switzerland) official languages.
Validation (via Symfony Validator)
Form generation (via Symfony Form)
Postal formatting
Featured on the Drupal Commerce blog.
36. ADDRESS FORMAT
Which fields are used, and in which order
Which fields are required
Which fields need to be uppercased
Field labels
Regular expression for validating postal codes
38. ZONE
Zones are territorial groupings mostly used for shipping or
tax purposes. For example, a set of shipping rates associated
with a zone where the rates become available only if the
customer's address matches the zone.
A zone can match other zones, countries, subdivisions
(states/provinces/municipalities), postal codes. Postal codes
can also be expressed using ranges or regular expressions.
39. Create the German VAT zone
use CommerceGuysAddressingModelAddress;
use CommerceGuysZoneModelZone;
use CommerceGuysZoneModelZoneMemberCountry;
$zone = new Zone();
$zone>setId('german_vat');
$zone>setName('German VAT');
$zone>setScope('tax');
40. Add Germany to the zone,
$germanyZoneMember = new ZoneMemberCountry();
$germanyZoneMember>setCountryCode('DE');
$zone>addMember($germanyZoneMember);
add the 4 Austrian postal codes that are in Germany for VAT.
$austriaZoneMember = new ZoneMemberCountry();
$austriaZoneMember>setCountryCode('AT');
$austriaZoneMember>setIncludedPostalCodes('6691, 6991:6993');
$zone>addMember($austriaZoneMember);
41. Initialising a zone matcher.
use CommerceGuysAddressingModelAddress;
use CommerceGuysZoneMatcherZoneMatcher;
use CommerceGuysZoneRepositoryZoneRepository;
$repository = new ZoneRepository('resources/zone');
$matcher = new ZoneMatcher($repository);
43. TAX
Smart data model designed for fluctuating tax rate
amounts ("19% -> 21% on January 1st").
Predefined tax rates and zones for EU countries, Iceland,
Norway, South Africa and Switzerland. More to come.
Tax resolvers with logic for all major use cases.