diff --git a/VERSION.txt b/VERSION.txt index 1c26b6f22f62..e230c8396d19 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.2.19 \ No newline at end of file +5.3.0 \ No newline at end of file diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index 79a072f8b7cd..664c09afa9b1 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -403,11 +403,18 @@ class Import implements ShouldQueue $company_repository->save($data, $this->company); if (isset($data['settings']->company_logo) && strlen($data['settings']->company_logo) > 0) { + try { $tempImage = tempnam(sys_get_temp_dir(), basename($data['settings']->company_logo)); copy($data['settings']->company_logo, $tempImage); $this->uploadLogo($tempImage, $this->company, $this->company); } catch (\Exception $e) { + + $settings = $this->company->settings; + $settings->company_logo = ''; + $this->company->settings = $settings; + $this->company->save(); + } } @@ -705,6 +712,7 @@ class Import implements ShouldQueue $modified = $resource; $modified['company_id'] = $this->company->id; $modified['user_id'] = $this->processUserId($resource); + $modified['number'] = $this->checkUniqueConstraint(Vendor::class, 'number', $modified['number']); unset($modified['id']); unset($modified['contacts']); diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index e4240b49ac82..b468fb097c48 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -184,8 +184,12 @@ class ReminderJob implements ShouldQueue $invoice->fresh(); $invoice->service()->deletePdf(); + /* Refresh the client here to ensure the balance is fresh */ + $client = $invoice->client; + $client = $client->fresh(); + nlog("adjusting client balance and invoice balance by ". ($invoice->balance - $temp_invoice_balance)); - $invoice->client->service()->updateBalance($invoice->balance - $temp_invoice_balance)->save(); + $client->service()->updateBalance($invoice->balance - $temp_invoice_balance)->save(); $invoice->ledger()->updateInvoiceBalance($invoice->balance - $temp_invoice_balance, "Late Fee Adjustment for invoice {$invoice->number}"); return $invoice; diff --git a/app/PaymentDrivers/Stripe/ACH.php b/app/PaymentDrivers/Stripe/ACH.php index a17725225b08..5af1cbf05ab2 100644 --- a/app/PaymentDrivers/Stripe/ACH.php +++ b/app/PaymentDrivers/Stripe/ACH.php @@ -61,7 +61,7 @@ class ACH try { $source = Customer::createSource($customer->id, ['source' => $stripe_response->token->id], $this->stripe->stripe_connect_auth); - // $source = $this->stripe->stripe->customers->createSource($customer->id, ['source' => $stripe_response->token->id]); + } catch (InvalidRequestException $e) { throw new PaymentFailed($e->getMessage(), $e->getCode()); } diff --git a/app/PaymentDrivers/Stripe/ImportCustomers.php b/app/PaymentDrivers/Stripe/ImportCustomers.php index 1fae465da08d..2baf26d5bbd5 100644 --- a/app/PaymentDrivers/Stripe/ImportCustomers.php +++ b/app/PaymentDrivers/Stripe/ImportCustomers.php @@ -142,6 +142,32 @@ class ImportCustomers $this->update_payment_methods->updateMethods($customer, $client); } + public function importCustomer($customer_id) + { + + $this->stripe->init(); + + $this->update_payment_methods = new UpdatePaymentMethods($this->stripe); + + if(strlen($this->stripe->company_gateway->getConfigField('account_id')) < 1) + throw new StripeConnectFailure('Stripe Connect has not been configured'); + + $customer = Customer::retrieve($customer_id, $this->stripe_connect_auth); + + if(!$customer) + return; + + foreach($this->stripe->company_gateway->company->clients as $client) + { + if($client->present()->email() == $customer->email) { + + $this->update_payment_methods->updateMethods($customer, $client); + + } + } + + } + public function match() { $this->stripe->init(); diff --git a/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php b/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php index 596356a83148..74d09d4abe26 100644 --- a/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php +++ b/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php @@ -93,6 +93,12 @@ class UpdatePaymentMethods $this->addOrUpdateCard($method, $customer->id, $client, GatewayType::SOFORT); } + //$this->importBankAccounts($customer, $client); + } + + private function importBankAccounts($customer, $client) + { + } // private function addOrUpdateBankAccount($bank_account, $customer_reference, Client $client) diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index 0dce16d84d16..7231cebbffc4 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -550,6 +550,11 @@ class StripePaymentDriver extends BaseDriver return (new ImportCustomers($this))->match(); } + public function importCustomer($customer_id) + { + return (new ImportCustomers($this))->importCustomer($customer_id); + } + public function verifyConnect() { return (new Verify($this))->run(); diff --git a/app/Utils/Traits/Uploadable.php b/app/Utils/Traits/Uploadable.php index f17cce270cd9..604bab5f5b1b 100644 --- a/app/Utils/Traits/Uploadable.php +++ b/app/Utils/Traits/Uploadable.php @@ -40,5 +40,6 @@ trait Uploadable $entity->save(); } } + } } diff --git a/config/ninja.php b/config/ninja.php index 3533b1a7b2f7..e893d61c3b11 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.2.19', - 'app_tag' => '5.2.19', + 'app_version' => '5.3.0', + 'app_tag' => '5.3.0', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''), diff --git a/tests/MockAccountData.php b/tests/MockAccountData.php index fa078e1146ef..0e566900ad80 100644 --- a/tests/MockAccountData.php +++ b/tests/MockAccountData.php @@ -156,7 +156,6 @@ trait MockAccountData } } - $this->account = Account::factory()->create(); $this->company = Company::factory()->create([ 'account_id' => $this->account->id,