From 98706698d290c4868a66bfadf52d3c65588a969d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 15 Jun 2023 16:23:08 +1000 Subject: [PATCH] Localize payment dates --- app/Http/Requests/Payment/StorePaymentRequest.php | 2 +- app/PaymentDrivers/BaseDriver.php | 2 +- app/Services/Credit/CreditService.php | 2 +- app/Services/Invoice/AutoBillInvoice.php | 2 +- app/Services/Invoice/MarkPaid.php | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Http/Requests/Payment/StorePaymentRequest.php b/app/Http/Requests/Payment/StorePaymentRequest.php index 196c302e57a7..9fd353d39323 100644 --- a/app/Http/Requests/Payment/StorePaymentRequest.php +++ b/app/Http/Requests/Payment/StorePaymentRequest.php @@ -88,7 +88,7 @@ class StorePaymentRequest extends Request // $input['is_manual'] = true; if (! isset($input['date'])) { - $input['date'] = now()->format('Y-m-d'); + $input['date'] = now()->addSeconds(auth()->user()->company->timezone()->utc_offset)->format('Y-m-d'); } $this->replace($input); diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index fcc36d4b698a..4bad13f054a3 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -320,7 +320,7 @@ class BaseDriver extends AbstractPaymentDriver $payment->company_gateway_id = $this->company_gateway->id; $payment->status_id = $status; $payment->currency_id = $this->client->getSetting('currency_id'); - $payment->date = Carbon::now(); + $payment->date = Carbon::now()->addSeconds($this->client->company->timezone()->utc_offset)->format('Y-m-d'); $payment->gateway_type_id = $data['gateway_type_id']; $client_contact = $this->getContact(); diff --git a/app/Services/Credit/CreditService.php b/app/Services/Credit/CreditService.php index 4adc71cd290c..26c9228e3804 100644 --- a/app/Services/Credit/CreditService.php +++ b/app/Services/Credit/CreditService.php @@ -119,7 +119,7 @@ class CreditService $payment->type_id = PaymentType::CREDIT; $payment->is_manual = true; $payment->currency_id = $this->credit->client->getSetting('currency_id'); - $payment->date = now(); + $payment->date = now()->addSeconds($this->credit->company->timezone()->utc_offset)->format('Y-m-d'); $payment->saveQuietly(); $payment->number = $payment->client->getNextPaymentNumber($payment->client, $payment); diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index de76290a75e0..d67b4fa8607f 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -179,7 +179,7 @@ class AutoBillInvoice extends AbstractService $payment->applied = $amount; $payment->client_id = $this->invoice->client_id; $payment->currency_id = $this->invoice->client->getSetting('currency_id'); - $payment->date = now(); + $payment->date = now()->addSeconds($this->invoice->company->timezone()->utc_offset)->format('Y-m-d'); $payment->status_id = Payment::STATUS_COMPLETED; $payment->type_id = PaymentType::CREDIT; $payment->service()->applyNumber()->save(); diff --git a/app/Services/Invoice/MarkPaid.php b/app/Services/Invoice/MarkPaid.php index a056da4b6038..333c84eb1524 100644 --- a/app/Services/Invoice/MarkPaid.php +++ b/app/Services/Invoice/MarkPaid.php @@ -71,6 +71,7 @@ class MarkPaid extends AbstractService $payment->is_manual = true; if ($this->invoice->company->timezone()) { + nlog($this->invoice->company->timezone()->utc_offset); $payment->date = now()->addSeconds($this->invoice->company->timezone()->utc_offset)->format('Y-m-d'); }