Merge pull request #7726 from turbo124/v5-develop

Clean up for PHP 8.1
This commit is contained in:
David Bomba 2022-08-09 08:11:26 +10:00 committed by GitHub
commit 0faeb63ba3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 45 additions and 34 deletions

View File

@ -12,8 +12,8 @@ jobs:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: ['ubuntu-18.04', 'ubuntu-20.04']
php-versions: ['7.4','8.0','8.1']
operating-system: ['ubuntu-18.04', 'ubuntu-20.04', 'ubuntu-22.04']
php-versions: ['8.1']
phpunit-versions: ['latest']
env:
@ -107,7 +107,3 @@ jobs:
env:
DB_PORT: ${{ job.services.mysql.ports[3306] }}
PHP_CS_FIXER_IGNORE_ENV: true
- name: Run php-cs-fixer
run: |
PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix

View File

@ -40,7 +40,8 @@ class RecurringInvoicesCron
public function handle() : void
{
/* Get all invoices where the send date is less than NOW + 30 minutes() */
nlog('Sending recurring invoices '.Carbon::now()->format('Y-m-d h:i:s'));
$start = Carbon::now()->format('Y-m-d h:i:s');
nlog('Sending recurring invoices '.$start);
if (! config('ninja.db.multi_db_enabled')) {
$recurring_invoices = RecurringInvoice::where('next_send_date', '<=', now()->toDateTimeString())
@ -119,5 +120,8 @@ class RecurringInvoicesCron
});
}
}
nlog("Recurring invoice send duration " . $start . " - " . Carbon::now()->format('Y-m-d h:i:s'));
}
}

View File

@ -100,7 +100,7 @@ class NinjaMailerJob implements ShouldQueue
$this->nmo->mailable->replyTo($this->company->owner()->email, $this->company->owner()->present()->name());
}
// $this->nmo->mailable->tag($this->company->company_key);
$this->nmo->mailable->tag($this->company->company_key);
//send email
try {

View File

@ -41,7 +41,7 @@ class PaymentFailedMailer implements ShouldQueue
public ?PaymentHash $payment_hash;
public string $error;
public $error;
public Company $company;
@ -55,7 +55,7 @@ class PaymentFailedMailer implements ShouldQueue
* @param $company
* @param $amount
*/
public function __construct(?PaymentHash $payment_hash, Company $company, Client $client, string $error)
public function __construct(?PaymentHash $payment_hash, Company $company, Client $client, $error)
{
$this->payment_hash = $payment_hash;
$this->client = $client;
@ -70,6 +70,10 @@ class PaymentFailedMailer implements ShouldQueue
*/
public function handle()
{
if(!is_string($this->error)){
$this->error = "Payment failed, no reason given.";
}
//Set DB
MultiDB::setDb($this->company->db);
App::setLocale($this->client->locale());

View File

@ -127,7 +127,7 @@ class SendRecurring implements ShouldQueue
$invoice->invitations->each(function ($invitation) use ($invoice) {
if ($invitation->contact && ! $invitation->contact->trashed() && strlen($invitation->contact->email) >= 1 && $invoice->client->getSetting('auto_email_invoice')) {
try {
EmailEntity::dispatch($invitation, $invoice->company)->delay(10);
EmailEntity::dispatch($invitation, $invoice->company)->delay(rand(10,20));
} catch (\Exception $e) {
nlog($e->getMessage());
}
@ -140,13 +140,13 @@ class SendRecurring implements ShouldQueue
if ($invoice->client->getSetting('auto_bill_date') == 'on_send_date' && $invoice->auto_bill_enabled) {
nlog("attempting to autobill {$invoice->number}");
// $invoice->service()->autoBill();
AutoBill::dispatch($invoice, $this->db)->delay(20);
AutoBill::dispatch($invoice, $this->db)->delay(rand(30,40));
} elseif ($invoice->client->getSetting('auto_bill_date') == 'on_due_date' && $invoice->auto_bill_enabled) {
if ($invoice->due_date && Carbon::parse($invoice->due_date)->startOfDay()->lte(now()->startOfDay())) {
nlog("attempting to autobill {$invoice->number}");
// $invoice->service()->autoBill();
AutoBill::dispatch($invoice, $this->db)->delay(20);
AutoBill::dispatch($invoice, $this->db)->delay(rand(30,40));
}
}
}

View File

@ -96,12 +96,9 @@ class InvoiceEmailEngine extends BaseEmailEngine
if (is_array($this->template_data) && array_key_exists('subject', $this->template_data) && strlen($this->template_data['subject']) > 0) {
$subject_template = $this->template_data['subject'];
nlog('subject = template data');
} elseif (strlen($this->client->getSetting('email_subject_'.$this->reminder_template)) > 0) {
$subject_template = $this->client->getSetting('email_subject_'.$this->reminder_template);
nlog('subject = settings var');
} else {
nlog('subject = default template '.'email_subject_'.$this->reminder_template);
$subject_template = EmailTemplateDefaults::getDefaultTemplate('email_subject_'.$this->reminder_template, $this->client->locale());
// $subject_template = $this->client->getSetting('email_subject_'.$this->reminder_template);
}

View File

@ -115,12 +115,12 @@ class TemplateEmail extends Mailable
'company' => $company,
'whitelabel' => $this->client->user->account->isPaid() ? true : false,
'logo' => $this->company->present()->logo($settings),
])
->withSymfonyMessage(function ($message) use ($company) {
$message->getHeaders()->addTextHeader('Tag', $company->company_key);
$message->invitation = $this->invitation;
})
->tag($company->company_key);
]);
// ->withSymfonyMessage(function ($message) use ($company) {
// $message->getHeaders()->addTextHeader('Tag', $company->company_key);
// $message->invitation = $this->invitation;
//});
// ->tag($company->company_key);
/*In the hosted platform we need to slow things down a little for Storage to catch up.*/

View File

@ -109,12 +109,12 @@ class VendorTemplateEmail extends Mailable
'company' => $this->company,
'whitelabel' => $this->vendor->user->account->isPaid() ? true : false,
'logo' => $this->company->present()->logo($settings),
])
->withSymfonyMessage(function ($message) {
$message->getHeaders()->addTextHeader('Tag', $this->company->company_key);
$message->invitation = $this->invitation;
})
->tag($this->company->company_key);
]);
//->withSymfonyMessage(function ($message) {
// $message->getHeaders()->addTextHeader('Tag', $this->company->company_key);
// $message->invitation = $this->invitation;
//});
// ->tag($this->company->company_key);
if(Ninja::isHosted() && $this->invitation){

View File

@ -431,6 +431,10 @@ class BaseDriver extends AbstractPaymentDriver
public function sendFailureMail($error)
{
if(is_object($error)){
$error = 'Payment Aborted';
}
if (! is_null($this->payment_hash)) {
$this->unWindGatewayFees($this->payment_hash);
}

View File

@ -156,7 +156,6 @@ class CreditCard
'zip' => $this->paytrace->client->postal_code,
];
nlog($data);
}
public function paymentView($data)

View File

@ -89,15 +89,11 @@ class PaytracePaymentDriver extends BaseDriver
public function refund(Payment $payment, $amount, $return_client_response = false)
{
// $cgt = ClientGatewayToken::where('company_gateway_id', $payment->company_gateway_id)
// ->where('gateway_type_id', $payment->gateway_type_id)
// ->first();
$data = [
'amount' => $amount,
//'customer_id' => $cgt->token,
'transaction_id' => $payment->transaction_reference,
'integrator_id' => '959195xd1CuC',
'integrator_id' => $this->company_gateway->getConfigField('integratorId'),
];
$response = $this->gatewayRequest('/v1/transactions/refund/for_transaction', $data);

View File

@ -167,6 +167,17 @@ class CreditCard
$this->stripe->client->company,
);
//If the user has come from a subscription double check here if we need to redirect.
//08-08-2022
if($payment->invoices()->whereHas('subscription')->exists()){
$subscription = $payment->invoices()->first()->subscription;
if($subscription && array_key_exists('return_url', $subscription->webhook_configuration) && strlen($subscription->webhook_configuration['return_url']) >=1)
return redirect($subscription->webhook_configuration['return_url']);
}
//08-08-2022
return redirect()->route('client.payments.show', ['payment' => $this->stripe->encodePrimaryKey($payment->id)]);
}