diff --git a/VERSION.txt b/VERSION.txt index a7e0a988ad..12d56fd94b 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.3.81 \ No newline at end of file +5.3.82 \ No newline at end of file diff --git a/app/Services/Invoice/MarkPaid.php b/app/Services/Invoice/MarkPaid.php index 920f72e27a..17cfdf5e14 100644 --- a/app/Services/Invoice/MarkPaid.php +++ b/app/Services/Invoice/MarkPaid.php @@ -18,6 +18,7 @@ use App\Jobs\Invoice\InvoiceWorkflowSettings; use App\Jobs\Ninja\TransactionLog; use App\Jobs\Payment\EmailPayment; use App\Libraries\Currency\Conversion\CurrencyApi; +use App\Models\Client; use App\Models\Invoice; use App\Models\Payment; use App\Models\TransactionEvent; @@ -99,10 +100,15 @@ class MarkPaid extends AbstractService $payment->ledger() ->updatePaymentBalance($payment->amount * -1); - $this->invoice->client->fresh(); - $this->invoice->client->paid_to_date += $payment->amount; - $this->invoice->client->balance += $payment->amount * -1; - $this->invoice->client->push(); + \DB::connection(config('database.default'))->transaction(function () use($payment){ + + /* Get the last record for the client and set the current balance*/ + $client = Client::where('id', $this->invoice->client_id)->lockForUpdate()->first(); + $client->paid_to_date += $payment->amount; + $client->balance += $payment->amount * -1; + $client->save(); + + }, 1); $this->invoice = $this->invoice ->service() diff --git a/app/Services/Invoice/MarkSent.php b/app/Services/Invoice/MarkSent.php index 292521ea5a..886888cd77 100644 --- a/app/Services/Invoice/MarkSent.php +++ b/app/Services/Invoice/MarkSent.php @@ -57,16 +57,21 @@ class MarkSent extends AbstractService ->service() ->applyNumber() ->setDueDate() - // ->deletePdf() //08-01-2022 - ->touchPdf() //08-01-2022 + ->touchPdf() ->setReminder() ->save(); /*Adjust client balance*/ - $this->client->fresh(); - $this->client->balance += $adjustment; - $this->client->save(); + + \DB::connection(config('database.default'))->transaction(function () use($adjustment){ + + /* Get the last record for the client and set the current balance*/ + $client = Client::where('id', $this->client->id)->lockForUpdate()->first(); + $client->balance += $adjustment; + $client->save(); + + }, 1); $this->invoice->markInvitationsSent(); diff --git a/config/ninja.php b/config/ninja.php index 5cd221c403..10f6f4404b 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.3.81', - 'app_tag' => '5.3.81', + 'app_version' => '5.3.82', + 'app_tag' => '5.3.82', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''), diff --git a/database/migrations/2022_04_22_115838_client_settings_parse_for_types.php b/database/migrations/2022_04_22_115838_client_settings_parse_for_types.php new file mode 100644 index 0000000000..6612ff12a9 --- /dev/null +++ b/database/migrations/2022_04_22_115838_client_settings_parse_for_types.php @@ -0,0 +1,47 @@ +each( function ($client) { + $entity_settings = $this->checkSettingType($client->settings); + $entity_settings->md5 = md5(time()); + $client->settings = $entity_settings; + $client->save(); + + }); + + + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/resources/views/index/index.blade.php b/resources/views/index/index.blade.php index c794eddecf..99a10c3303 100644 --- a/resources/views/index/index.blade.php +++ b/resources/views/index/index.blade.php @@ -152,7 +152,6 @@ -