Fixes for pdf regeneration

This commit is contained in:
David Bomba 2022-01-10 12:47:16 +11:00
parent 386131f618
commit 239b180a21
10 changed files with 70 additions and 21 deletions

View File

@ -401,7 +401,7 @@ class InvoiceController extends BaseController
$invoice = $this->invoice_repo->save($request->all(), $invoice);
$invoice->service()->triggeredActions($request)->deletePdf();
$invoice->service()->triggeredActions($request)->deletePdf()->touchPdf();
event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
@ -708,7 +708,7 @@ class InvoiceController extends BaseController
}
break;
case 'cancel':
$invoice = $invoice->service()->handleCancellation()->deletePdf()->save();
$invoice = $invoice->service()->handleCancellation()->deletePdf()->touchPdf()->save();
if (! $bulk) {
$this->itemResponse($invoice);

View File

@ -95,7 +95,7 @@ class SendRecurring implements ShouldQueue
$invoice = $this->createRecurringInvitations($invoice);
/* 09-01-2022 ensure we create the PDFs at this point in time! */
$invoice->service()->touchPdf();
$invoice->service()->touchPdf(true);
nlog("updating recurring invoice dates");
/* Set next date here to prevent a recurring loop forming */

View File

@ -80,6 +80,8 @@ class ReminderJob implements ShouldQueue
$invoice->service()->touchReminder($reminder_template)->save();
$invoice = $this->calcLateFee($invoice, $reminder_template);
$invoice->service()->touchPdf();
//check if this reminder needs to be emailed
if(in_array($reminder_template, ['reminder1','reminder2','reminder3','reminder_endless']) && $invoice->client->getSetting("enable_".$reminder_template))
{

View File

@ -43,7 +43,7 @@ class InvoiceArchivedActivity implements ShouldQueue
{
MultiDB::setDb($event->company->db);
$event->invoice->service()->deletePdf();
// $event->invoice->service()->deletePdf();
$fields = new stdClass;

View File

@ -442,7 +442,7 @@ class BaseDriver extends AbstractPaymentDriver
$invoices->each(function ($invoice) {
$invoice->service()->deletePdf();
$invoice->service()->touchPdf();
});
@ -494,7 +494,7 @@ class BaseDriver extends AbstractPaymentDriver
$invoices->each(function ($invoice){
$invoice->service()->deletePdf();
$invoice->service()->touchPdf();
});

View File

@ -194,13 +194,18 @@ class BrowserPay implements MethodInterface
return;
}
$domain = config('ninja.app_url');
// $domain = config('ninja.app_url');
if (Ninja::isHosted()) {
$domain = isset($this->stripe->company_gateway->company->portal_domain)
? $this->stripe->company_gateway->company->portal_domain
: $this->stripe->company_gateway->company->domain();
}
// if (Ninja::isHosted()) {
// $domain = isset($this->stripe->company_gateway->company->portal_domain)
// ? $this->stripe->company_gateway->company->portal_domain
// : $this->stripe->company_gateway->company->domain();
// }
$domain = $this->getAppleDomain();
if(!$domain)
throw new PaymentFailed('Unable to register Domain with Apple Pay', 500);
$response = ApplePayDomain::create([
'domain_name' => $domain,
@ -212,4 +217,36 @@ class BrowserPay implements MethodInterface
$this->stripe->company_gateway->save();
}
private function getAppleDomain()
{
$domain = '';
if(Ninja::isHosted())
{
if($this->company_gateway->company->portal_mode == 'domain'){
$domain = $this->company_gateway->company->portal_domain;
}
else{
$domain = $this->company_gateway->company->subdomain . '.' . config('ninja.app_domain');
}
}
else {
$domain = config('ninja.app_url');
}
$parsed_url = parse_url($domain);
if(array_key_exists('host', $parsed_url))
return $parsed_url['host'];
return false;
}
}

View File

@ -390,6 +390,8 @@ class InvoiceService
*/
public function touchPdf($force = false)
{
try {
if($force){
$this->invoice->invitations->each(function ($invitation) {
@ -403,6 +405,13 @@ class InvoiceService
CreateEntityPdf::dispatch($invitation);
});
}
catch(\Exception $e){
nlog("failed creating invoices in Touch PDF");
}
return $this;
}

View File

@ -89,6 +89,7 @@ class MarkPaid extends AbstractService
->service()
->applyNumber()
->deletePdf()
->touchPdf()
->save();
$payment->ledger()

View File

@ -87,7 +87,7 @@ class UpdateInvoicePayment
$invoice->refresh();
$invoice->service()
->deletePdf()
->touchPdf()
->workFlow()
->save();

View File

@ -94,7 +94,7 @@ trait SettingsSaver
case 'double':
return is_float($value) || is_numeric(strval($value));
case 'string':
return ( is_string( $value ) && method_exists($value, '__toString') ) || is_null($value) || is_string($value);
return !is_int($value) || ( is_string( $value ) && method_exists($value, '__toString') ) || is_null($value) || is_string($value);
case 'bool':
case 'boolean':
return is_bool($value) || (int) filter_var($value, FILTER_VALIDATE_BOOLEAN);