1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #6127 from turbo124/v5-develop

Fixes for WePay ACH
This commit is contained in:
David Bomba 2021-06-25 14:47:53 +10:00 committed by GitHub
commit 55838ede51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 32 additions and 20 deletions

View File

@ -77,7 +77,7 @@ class Handler extends ExceptionHandler
return;
}
if(Ninja::isHosted()){
if(Ninja::isHosted() && !($exception instanceof ValidationException)){
app('sentry')->configureScope(function (Scope $scope): void {

View File

@ -155,7 +155,7 @@ class PreviewController extends BaseController
$t = app('translator');
$t->replace(Ninja::transformTranslations(auth()->user()->company()->settings));
DB::beginTransaction();
DB::connection(config('database.default'))->beginTransaction();
$client = Client::factory()->create([
'user_id' => auth()->user()->id,
@ -230,7 +230,7 @@ class PreviewController extends BaseController
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company());
DB::rollBack();
DB::connection(config('database.default'))->rollBack();
$response = Response::make($file_path, 200);
$response->header('Content-Type', 'application/pdf');

View File

@ -45,6 +45,7 @@ class RecurringInvoicesCron
if (! config('ninja.db.multi_db_enabled')) {
$recurring_invoices = RecurringInvoice::where('next_send_date', '<=', now()->toDateTimeString())
->whereNotNull('next_send_date')
->whereNull('deleted_at')
->where('status_id', RecurringInvoice::STATUS_ACTIVE)
->where('remaining_cycles', '!=', '0')
->with('company')
@ -66,6 +67,7 @@ class RecurringInvoicesCron
$recurring_invoices = RecurringInvoice::where('next_send_date', '<=', now()->toDateTimeString())
->whereNotNull('next_send_date')
->whereNull('deleted_at')
->where('status_id', RecurringInvoice::STATUS_ACTIVE)
->where('remaining_cycles', '!=', '0')
->with('company')

View File

@ -224,6 +224,13 @@ class RecurringInvoice extends BaseModel
$offset = $this->client->timezone_offset();
/*
As we are firing at UTC+0 if our offset is negative it is technically firing the day before so we always need
to add ON a day - a day = 86400 seconds
*/
if($offset < 0)
$offset += 86400;
switch ($this->frequency_id) {
case self::FREQUENCY_DAILY:
return Carbon::parse($this->next_send_date)->startOfDay()->addDay()->addSeconds($offset);
@ -428,17 +435,14 @@ class RecurringInvoice extends BaseModel
'due_date' => $next_due_date_string
];
$next_send_date = $this->nextDateByFrequency($next_send_date->format('Y-m-d'));
/* Fixes the timeshift in case the offset is negative which cause a infinite loop due to UTC +0*/
if($this->client->timezone_offset() < 0){
$next_send_date = $this->nextDateByFrequency($next_send_date->addDay()->format('Y-m-d'));
}
else
$next_send_date = $this->nextDateByFrequency($next_send_date->format('Y-m-d'));
}
/*If no due date is set - unset the due_date value */
// if(!$this->due_date_days || $this->due_date_days == 0){
// foreach($data as $key => $value)
// $data[$key]['due_date'] = '';
// }
return $data;
}

View File

@ -189,7 +189,7 @@ class ACH
public function paymentResponse($request)
{
nlog($request->all());
// nlog($request->all());
$token = ClientGatewayToken::find($this->decodePrimaryKey($request->input('source')));
$token_meta = $token->meta;

View File

@ -24,8 +24,13 @@ trait WePayCommon
private function processSuccessfulPayment($response, $payment_status, $gateway_type)
{
if($gateway_type == GatewayType::BANK_TRANSFER)
$payment_type = PaymentType::ACH;
else
$payment_type = PaymentType::CREDIT_CARD_OTHER;
$data = [
'payment_type' => PaymentType::CREDIT_CARD_OTHER,
'payment_type' => $payment_type,
'amount' => $response->amount,
'transaction_reference' => $response->checkout_id,
'gateway_type_id' => $gateway_type,

View File

@ -45,8 +45,8 @@ class SubscriptionRepository extends BaseRepository
private function calculatePrice($subscription) :array
{
DB::beginTransaction();
// DB::beginTransaction();
DB::connection(config('database.default'))->beginTransaction();
$data = [];
$client = Client::factory()->create([
@ -90,8 +90,9 @@ class SubscriptionRepository extends BaseRepository
$data['promo_price'] = $invoice->calc()->getTotal();
DB::rollBack();
// DB::rollBack();
DB::connection(config('database.default'))->rollBack();
return $data;
}

View File

@ -239,7 +239,7 @@ class TemplateEngine
private function mockEntity()
{
DB::beginTransaction();
DB::connection(config('database.default'))->beginTransaction();
$client = Client::factory()->create([
'user_id' => auth()->user()->id,
@ -277,6 +277,6 @@ class TemplateEngine
private function tearDown()
{
DB::rollBack();
DB::connection(config('database.default'))->rollBack();
}
}