Remove redundant info() Change document download route

This commit is contained in:
David Bomba 2020-12-13 20:46:29 +11:00
parent 5a66069833
commit 6f451b8924
8 changed files with 17 additions and 30 deletions

View File

@ -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']);
}

View File

@ -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);
}

View File

@ -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)

View File

@ -170,6 +170,6 @@ class EmailController extends BaseController
$this->entity_transformer = RecurringInvoiceTransformer::class;
}
return $this->itemResponse($entity_obj);
return $this->itemResponse($entity_obj->fresh());
}
}

View File

@ -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}");
}
}

View File

@ -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;
}

View File

@ -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()));

View File

@ -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 () {