Adjustments for shipping / delivery location

This commit is contained in:
David Bomba 2025-03-01 10:03:30 +11:00
parent 87b50024e4
commit f2fa2b1e13
5 changed files with 15 additions and 11 deletions

View File

@ -53,7 +53,7 @@ class UpdateLocationTaxData implements ShouldQueue
{ {
MultiDB::setDb($this->company->db); 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; return;
} }
@ -70,11 +70,11 @@ class UpdateLocationTaxData implements ShouldQueue
$tax_provider = new \App\Services\Tax\Providers\TaxProvider($this->company, $this->location->client); $tax_provider = new \App\Services\Tax\Providers\TaxProvider($this->company, $this->location->client);
$location_address = [ $location_address = [
'address2' => $this->location->address2, 'address2' => $this->location->address2 ?? '',
'address1' => $this->location->address1, 'address1' => $this->location->address1 ?? '',
'city' => $this->location->city, 'city' => $this->location->city ?? '',
'state' => $this->location->state, 'state' => $this->location->state ?? '',
'postal_code' => $this->location->postal_code, 'postal_code' => $this->location->postal_code ?? '',
'country' => $this->location->country()->exists() ? $this->location->country->name : $this->company->country()->name, 'country' => $this->location->country()->exists() ? $this->location->country->name : $this->company->country()->name,
]; ];

View File

@ -56,8 +56,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property int|null $deleted_at * @property int|null $deleted_at
* @property-read mixed $hashed_id * @property-read mixed $hashed_id
* @property-read \App\Models\User $user * @property-read \App\Models\User $user
* @property-read \App\Models\Client $client * @property-read \App\Models\Client|null $client
* @property-read \App\Models\Vendor $vendor * @property-read \App\Models\Vendor|null $vendor
* @property-read \App\Models\Company $company * @property-read \App\Models\Company $company
* @property-read \App\Models\Country|null $country * @property-read \App\Models\Country|null $country
* *

View File

@ -23,7 +23,6 @@ class LocationObserver
*/ */
public function created(Location $location) public function created(Location $location)
{ {
if ($location->country_id == 840 && $location->company->calculate_taxes && !$location->company->account->isFreeHostedClient()) { if ($location->country_id == 840 && $location->company->calculate_taxes && !$location->company->account->isFreeHostedClient()) {
UpdateLocationTaxData::dispatch($location, $location->company); UpdateLocationTaxData::dispatch($location, $location->company);
} }

View File

@ -144,10 +144,12 @@ class TaxProvider
public function updateLocationTaxData(Location $location): self 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 = new $this->provider($this->getBillingAddress());
$tax_provider->setApiCredentials($this->api_credentials);
$tax_data = $tax_provider->run(); $tax_data = $tax_provider->run();
if ($tax_data) { if ($tax_data) {

View File

@ -5510,6 +5510,9 @@ $lang = array(
'disable_emails' => 'Disable Emails', 'disable_emails' => 'Disable Emails',
'disable_emails_error' => 'You are not authorized to send emails', 'disable_emails_error' => 'You are not authorized to send emails',
'disable_emails_help' => 'Prevents a user from sending emails from the system', '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; return $lang;