diff --git a/app/DataMapper/EmailTemplateDefaults.php b/app/DataMapper/EmailTemplateDefaults.php index d7137ce7f1e7..721114771cff 100644 --- a/app/DataMapper/EmailTemplateDefaults.php +++ b/app/DataMapper/EmailTemplateDefaults.php @@ -173,7 +173,6 @@ class EmailTemplateDefaults public static function emailReminder1Subject() { - info("reminder 1 subject"); return ctrans('texts.reminder_subject', ['invoice'=>'$invoice.number', 'account'=>'$company.name']); } diff --git a/app/Filters/ClientFilters.php b/app/Filters/ClientFilters.php index 9221b5da4fdf..e367708d17f5 100644 --- a/app/Filters/ClientFilters.php +++ b/app/Filters/ClientFilters.php @@ -190,7 +190,6 @@ class ClientFilters extends QueryFilters * limit the user to only the invoices they have created */ if (Gate::denies('view-list', Client::class)) { - info('the gate!'); $query->where('clients.user_id', '=', $user->id); } diff --git a/app/Http/Controllers/ClientPortal/DocumentController.php b/app/Http/Controllers/ClientPortal/DocumentController.php index be7332e4d33d..ee485174bb5a 100644 --- a/app/Http/Controllers/ClientPortal/DocumentController.php +++ b/app/Http/Controllers/ClientPortal/DocumentController.php @@ -54,15 +54,12 @@ class DocumentController extends Controller return Storage::disk($document->disk)->download($document->url, $document->name); } - public function publicDownload(string $contact_key, Document $document) + public function publicDownload(string $document_hash) { - //return failure if the contact is not associated with the document - $contact = ClientContact::where('contact_key', $contact_key)->firstOrFail(); - if($contact->company_id == $document->company_id) + $document = Document::where('hash', $document_hash)->firstOrFail(); + return Storage::disk($document->disk)->download($document->url, $document->name); - - return response()->json(['message' => 'Access denied']); } public function downloadMultiple(DownloadMultipleDocumentsRequest $request) diff --git a/app/Http/Controllers/EmailController.php b/app/Http/Controllers/EmailController.php index e639340df6dd..580fbeb483a4 100644 --- a/app/Http/Controllers/EmailController.php +++ b/app/Http/Controllers/EmailController.php @@ -170,6 +170,6 @@ class EmailController extends BaseController $this->entity_transformer = RecurringInvoiceTransformer::class; } - return $this->itemResponse($entity_obj); + return $this->itemResponse($entity_obj->fresh()); } } diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php index d5ee8ca346b2..1f06e03b64a5 100644 --- a/app/Models/CompanyGateway.php +++ b/app/Models/CompanyGateway.php @@ -280,7 +280,7 @@ class CompanyGateway extends BaseModel if ($fees_and_limits->fee_amount) { $fee += $fees_and_limits->fee_amount; - info("fee after adding fee amount = {$fee}"); + // info("fee after adding fee amount = {$fee}"); } if ($fees_and_limits->fee_percent) { @@ -289,7 +289,7 @@ class CompanyGateway extends BaseModel } else { $fee += round(($amount * $fees_and_limits->fee_percent / 100), 2); } - info("fee after adding fee percent = {$fee}"); + // info("fee after adding fee percent = {$fee}"); } /* Cap fee if we have to here. */ @@ -303,17 +303,17 @@ class CompanyGateway extends BaseModel if ($include_taxes) { if ($fees_and_limits->fee_tax_rate1) { $fee += round(($pre_tax_fee * $fees_and_limits->fee_tax_rate1 / 100), 2); - info("fee after adding fee tax 1 = {$fee}"); + // info("fee after adding fee tax 1 = {$fee}"); } if ($fees_and_limits->fee_tax_rate2) { $fee += round(($pre_tax_fee * $fees_and_limits->fee_tax_rate2 / 100), 2); - info("fee after adding fee tax 2 = {$fee}"); + // info("fee after adding fee tax 2 = {$fee}"); } if ($fees_and_limits->fee_tax_rate3) { $fee += round(($pre_tax_fee * $fees_and_limits->fee_tax_rate3 / 100), 2); - info("fee after adding fee tax 3 = {$fee}"); + // info("fee after adding fee tax 3 = {$fee}"); } } diff --git a/app/Services/Invoice/ApplyPayment.php b/app/Services/Invoice/ApplyPayment.php index ead9cd9b4135..0a67d4070b8f 100644 --- a/app/Services/Invoice/ApplyPayment.php +++ b/app/Services/Invoice/ApplyPayment.php @@ -36,14 +36,13 @@ class ApplyPayment extends AbstractService ->ledger() ->updatePaymentBalance($this->payment_amount * -1); - info("apply payment method - current client balance = {$this->payment->client->balance}"); + // info("apply payment method - current client balance = {$this->payment->client->balance}"); - info("reducing client balance by payment amount {$this->payment_amount}"); + // info("reducing client balance by payment amount {$this->payment_amount}"); $this->invoice->client->service()->updateBalance($this->payment_amount * -1)->save(); -// $this->invoice->client->service()->updateBalance($this->payment_amount*-1)->updatePaidToDate($this->payment_amount)->save(); - info("post client balance = {$this->invoice->client->balance}"); + // info("post client balance = {$this->invoice->client->balance}"); /* Update Pivot Record amount */ $this->payment->invoices->each(function ($inv) { @@ -55,8 +54,8 @@ class ApplyPayment extends AbstractService $this->invoice->fresh('client'); - info("1 end of apply payment method the client balance = {$this->invoice->client->balance}"); - + // info("1 end of apply payment method the client balance = {$this->invoice->client->balance}"); + if ($this->invoice->hasPartial()) { //is partial and amount is exactly the partial amount if ($this->invoice->partial == $this->payment_amount) { @@ -71,11 +70,11 @@ class ApplyPayment extends AbstractService } elseif ($this->payment_amount < $this->invoice->balance) { //partial invoice payment made $this->invoice->service()->clearPartial()->setStatus(Invoice::STATUS_PARTIAL)->updateBalance($this->payment_amount * -1); } - info("2 end of apply payment method the client balnace = {$this->invoice->client->balance}"); + // info("2 end of apply payment method the client balnace = {$this->invoice->client->balance}"); $this->invoice->service()->applyNumber()->save(); - info("3 end of apply payment method the client balnace = {$this->invoice->client->balance}"); + // info("3 end of apply payment method the client balnace = {$this->invoice->client->balance}"); return $this->invoice; } diff --git a/app/Services/Invoice/MarkSent.php b/app/Services/Invoice/MarkSent.php index 839f484f0dc6..ed8c8daaa7f1 100644 --- a/app/Services/Invoice/MarkSent.php +++ b/app/Services/Invoice/MarkSent.php @@ -37,9 +37,6 @@ class MarkSent extends AbstractService return $this->invoice; } -info("in mark sent"); -info($this->invoice->balance); - $this->invoice->markInvitationsSent(); $this->invoice->setReminder(); @@ -52,12 +49,8 @@ info($this->invoice->balance); ->updateBalance($this->invoice->amount) ->save(); -info($this->invoice->balance); - $this->client->service()->updateBalance($this->invoice->balance)->save(); -info($this->client->balance); - $this->invoice->ledger()->updateInvoiceBalance($this->invoice->balance); event(new InvoiceWasUpdated($this->invoice, $this->invoice->company, Ninja::eventVars())); diff --git a/routes/client.php b/routes/client.php index b78370876d23..e66659765fc9 100644 --- a/routes/client.php +++ b/routes/client.php @@ -22,7 +22,7 @@ Route::post('view/{entity_type}/{invitation_key}/password', 'ClientPortal\Entity Route::get('tmp_pdf/{hash}', 'ClientPortal\TempRouteController@index')->name('tmp_pdf'); Route::get('client/key_login/{contact_key}', 'ClientPortal\ContactHashLoginController@login')->name('client.contact_login')->middleware(['contact_key_login']); -Route::get('documents/{contact_key}/{document}/download', 'ClientPortal\DocumentController@publicDownload')->name('documents.public_download'); +Route::get('documents/{document_hash}', 'ClientPortal\DocumentController@publicDownload')->name('documents.public_download'); //todo implement domain DB Route::group(['middleware' => ['auth:contact', 'locale', 'check_client_existence'], 'prefix' => 'client', 'as' => 'client.'], function () {