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

Basic Usage #77

Open
FractalMind opened this issue Mar 11, 2020 · 2 comments
Open

Basic Usage #77

FractalMind opened this issue Mar 11, 2020 · 2 comments

Comments

@FractalMind
Copy link

What am I doing wrong?

            $taxTypeRepository = new TaxTypeRepository();
            $chainTaxTypeResolver = new ChainTaxTypeResolver();
            $chainTaxTypeResolver->addResolver(new CanadaTaxTypeResolver($taxTypeRepository));
            $chainTaxTypeResolver->addResolver(new EuTaxTypeResolver($taxTypeRepository));
            $chainTaxTypeResolver->addResolver(new DefaultTaxTypeResolver($taxTypeRepository));
            $chainTaxRateResolver = new ChainTaxRateResolver();
            $chainTaxRateResolver->addResolver(new DefaultTaxRateResolver());
            $resolver = new TaxResolver($chainTaxTypeResolver, $chainTaxRateResolver);


            $from = new Address();
            $from->countryCode          = 'CA';
            $from->administrativeArea   = 'Quebec';
            $from->locality             = 'Montreal';
            $from->dependentLocality;
            $from->postalCode           = 'H2G1A7';
            $from->sortingCode;
            $from->addressLine1         = '1452 Rue Bélanger, Montréal, QC H2G 1A7';
            $from->addressLine2;
            $from->organization;
            $from->givenName            = 'Espace Plomberium';
            $from->additionalName;
            $from->familyName;
            $from->locale;


            $to = new Address();
            $to->countryCode          = 'CA';
            $to->administrativeArea   = 'British Columbia';
            $to->locality             = 'Vancouver';
            $to->dependentLocality;
            $to->postalCode           = 'V5P3W7';
            $to->sortingCode;
            $to->addressLine1         = '5786 Victoria Dr, Vancouver, BC, V5P3W7';
            $to->addressLine2;
            $to->organization;
            $to->givenName            = 'LifeLabs Medical Laboratory Services';
            $to->additionalName;
            $to->familyName;
            $to->locale;

            $taxable = new Taxable();
            $taxable->isPhysical = true;

            $context = new Context($from, $to);

            $amounts = $resolver->resolveAmounts($taxable, $context);
            // More rarely, if only the types or rates are needed:
            $rates = $resolver->resolveRates($taxable, $context);
            $types = $resolver->resolveTypes($taxable, $context);


            var_dump($amounts); // outputs: [] 
            var_dump($rates);       // outputs: [] 
            var_dump($types);      // outputs: [] 

[$amounts, $rates, $types] return empty arrays!?

Did I miss something?

Thank you for your time 😄

@FractalMind
Copy link
Author

            $from = new \CommerceGuys\Addressing\Address();
            $from->withCountryCode('CA');
            $from->withAdditionalName('Quebec');
            $from->withLocality('Montreal');
            $from->withPostalCode('H2G1A7');
            $from->withAddressLine1('1452 Rue Bélanger, Montréal, QC H2G 1A7');
            $from->withOrganization('Espace Plomberium');

This gives me the same result with the class you provide.

@faustbrian
Copy link

@FractalMind probably too late to be of any help but Address is immutable so you'll have to either reassign the $from and $to variables after setting a value or use method chaining.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants