Adjustments for shipping / delivery location
This commit is contained in:
parent
87b50024e4
commit
f2fa2b1e13
|
|
@ -53,7 +53,7 @@ class UpdateLocationTaxData implements ShouldQueue
|
|||
{
|
||||
MultiDB::setDb($this->company->db);
|
||||
|
||||
if ($this->company->account->isFreeHostedClient() || (isset($this->location->client) && $this->location->client->country_id != 840)) {
|
||||
if ($this->company->account->isFreeHostedClient() || $this->location->vendor || $this->location->country_id != 840) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -70,11 +70,11 @@ class UpdateLocationTaxData implements ShouldQueue
|
|||
$tax_provider = new \App\Services\Tax\Providers\TaxProvider($this->company, $this->location->client);
|
||||
|
||||
$location_address = [
|
||||
'address2' => $this->location->address2,
|
||||
'address1' => $this->location->address1,
|
||||
'city' => $this->location->city,
|
||||
'state' => $this->location->state,
|
||||
'postal_code' => $this->location->postal_code,
|
||||
'address2' => $this->location->address2 ?? '',
|
||||
'address1' => $this->location->address1 ?? '',
|
||||
'city' => $this->location->city ?? '',
|
||||
'state' => $this->location->state ?? '',
|
||||
'postal_code' => $this->location->postal_code ?? '',
|
||||
'country' => $this->location->country()->exists() ? $this->location->country->name : $this->company->country()->name,
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @property int|null $deleted_at
|
||||
* @property-read mixed $hashed_id
|
||||
* @property-read \App\Models\User $user
|
||||
* @property-read \App\Models\Client $client
|
||||
* @property-read \App\Models\Vendor $vendor
|
||||
* @property-read \App\Models\Client|null $client
|
||||
* @property-read \App\Models\Vendor|null $vendor
|
||||
* @property-read \App\Models\Company $company
|
||||
* @property-read \App\Models\Country|null $country
|
||||
*
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ class LocationObserver
|
|||
*/
|
||||
public function created(Location $location)
|
||||
{
|
||||
|
||||
if ($location->country_id == 840 && $location->company->calculate_taxes && !$location->company->account->isFreeHostedClient()) {
|
||||
UpdateLocationTaxData::dispatch($location, $location->company);
|
||||
}
|
||||
|
|
@ -40,7 +39,7 @@ class LocationObserver
|
|||
{
|
||||
|
||||
if ($location->getOriginal('postal_code') != $location->postal_code && $location->country_id == 840 && $location->company->calculate_taxes && !$location->company->account->isFreeHostedClient()) {
|
||||
UpdateLocationTaxData::dispatch($location, $location->company);
|
||||
UpdateLocationTaxData::dispatch($location, $location->company);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,10 +144,12 @@ class TaxProvider
|
|||
|
||||
public function updateLocationTaxData(Location $location): self
|
||||
{
|
||||
$this->configureProvider($this->provider, $location->country->iso_3166_2); //hard coded for now to one provider, but we'll be able to swap these out later
|
||||
$this->configureProvider($this->provider, $location->country->iso_3166_2);
|
||||
|
||||
$tax_provider = new $this->provider($this->getBillingAddress());
|
||||
|
||||
$tax_provider->setApiCredentials($this->api_credentials);
|
||||
|
||||
$tax_data = $tax_provider->run();
|
||||
|
||||
if ($tax_data) {
|
||||
|
|
|
|||
|
|
@ -5510,6 +5510,9 @@ $lang = array(
|
|||
'disable_emails' => 'Disable Emails',
|
||||
'disable_emails_error' => 'You are not authorized to send emails',
|
||||
'disable_emails_help' => 'Prevents a user from sending emails from the system',
|
||||
'add_location' => 'Add Location',
|
||||
'updated_location' => 'Updated Location',
|
||||
'created_location' => 'Created Location',
|
||||
);
|
||||
|
||||
return $lang;
|
||||
|
|
|
|||
Loading…
Reference in New Issue