diff --git a/app/Jobs/RecurringInvoice/SendRecurring.php b/app/Jobs/RecurringInvoice/SendRecurring.php index a6f3aece17..99a9d97b25 100644 --- a/app/Jobs/RecurringInvoice/SendRecurring.php +++ b/app/Jobs/RecurringInvoice/SendRecurring.php @@ -62,8 +62,7 @@ class SendRecurring implements ShouldQueue // Generate Standard Invoice $invoice = RecurringInvoiceToInvoiceFactory::create($this->recurring_invoice, $this->recurring_invoice->client); - $date = now()->addSeconds($this->recurring_invoice->client->timezone_offset())->format('Y-m-d'); - // $date = date('Y-m-d'); + $date = date('Y-m-d'); //@todo this will always pull UTC date. $invoice->date = $date; nlog("Recurring Invoice Date Set on Invoice = {$invoice->date} - ". now()->format('Y-m-d')); @@ -85,7 +84,6 @@ class SendRecurring implements ShouldQueue ->save(); } - //12-01-2023 i moved this block after fillDefaults to handle if standard invoice auto bill config has been enabled, recurring invoice should override. if ($this->recurring_invoice->auto_bill == 'always') { $invoice->auto_bill_enabled = true; $invoice->saveQuietly(); diff --git a/app/Models/RecurringInvoice.php b/app/Models/RecurringInvoice.php index 3211161174..ee56c3755f 100644 --- a/app/Models/RecurringInvoice.php +++ b/app/Models/RecurringInvoice.php @@ -679,6 +679,8 @@ class RecurringInvoice extends BaseModel return Carbon::parse($date)->copy(); default: + + $date = now()->addSeconds($this->client->timezone_offset()); return $this->setDayOfMonth($date, $this->due_date_days); } } diff --git a/openapi/api-docs.yaml b/openapi/api-docs.yaml index c996104a18..5b7b68d1cd 100644 --- a/openapi/api-docs.yaml +++ b/openapi/api-docs.yaml @@ -169,16 +169,11 @@ paths: /api/v1/login: post: + x-codeSamples: tags: - - login - summary: "Attempts authentication" + - auth + summary: "Login" description: | - After authenticating with the API, the returned object is a CompanyUser object which is a bridge linking the user to the company. - - The company user object itself contains the users permissions (admin/owner or fine grained permissions) You will most likely want to - also include in the response of this object both the company and the user object, this can be done by using the include parameter. - - /api/v1/login?include=company,user operationId: postLogin parameters: @@ -14651,7 +14646,6 @@ components: required: true schema: type: string - readOnly: true example: XMLHttpRequest X-API-TOKEN: name: X-API-TOKEN @@ -14753,7 +14747,11 @@ components: login_include: name: include in: query - description: Include child relations of the CompanyUser object, format is comma separated. **Note** it is possible to chain multiple includes together, ie. include=account,token + description: | + Include child relations of the CompanyUser object, format is comma separated. + + > ### **Note**: it is possible to chain multiple includes together, ie. include=account,token + required: false schema: type: string @@ -14798,7 +14796,7 @@ components: name: include_static in: query description: | - Static variables include: + This include will also return the full set of static variables used in the application including: - Currencies - Countries - Languages @@ -22157,10 +22155,18 @@ components: readOnly: true type: object tags: - - name: login - # description: | - # Attempts to authenticate with the API using a email/password combination. + - name: auth + description: | + Attempts to authenticate with the API using a email/password combination. + After authenticating with the API, the returned object is a CompanyUser object which is a bridge linking the user to the company. + + The company user object contains the users permissions (admin/owner or fine grained permissions) You will most likely want to + also include in the response of this object both the company and the user object, this can be done by using the include parameter. + + ```html + /api/v1/login?include=company,user + ``` - name: clients x-tag-expanded: false # description: | diff --git a/openapi/components/parameters.yaml b/openapi/components/parameters.yaml index ece96fa8a7..b351f82d0d 100644 --- a/openapi/components/parameters.yaml +++ b/openapi/components/parameters.yaml @@ -14,7 +14,6 @@ required: true schema: type: string - readOnly: true example: XMLHttpRequest X-API-TOKEN: name: X-API-TOKEN @@ -116,7 +115,11 @@ login_include: name: include in: query - description: Include child relations of the CompanyUser object, format is comma separated. **Note** it is possible to chain multiple includes together, ie. include=account,token + description: | + Include child relations of the CompanyUser object, format is comma separated. + + > ### **Note**: it is possible to chain multiple includes together, ie. include=account,token + required: false schema: type: string @@ -161,7 +164,7 @@ name: include_static in: query description: | - Static variables include: + This include will also return the full set of static variables used in the application including: - Currencies - Countries - Languages diff --git a/openapi/misc/misc.yaml b/openapi/misc/misc.yaml index 43a10765e4..1054028a93 100644 --- a/openapi/misc/misc.yaml +++ b/openapi/misc/misc.yaml @@ -1,8 +1,16 @@ tags: - - name: login - # description: | - # Attempts to authenticate with the API using a email/password combination. + - name: auth + description: | + Attempts to authenticate with the API using a email/password combination. + After authenticating with the API, the returned object is a CompanyUser object which is a bridge linking the user to the company. + + The company user object contains the users permissions (admin/owner or fine grained permissions) You will most likely want to + also include in the response of this object both the company and the user object, this can be done by using the include parameter. + + ```html + /api/v1/login?include=company,user + ``` - name: clients x-tag-expanded: false # description: | diff --git a/openapi/paths.yaml b/openapi/paths.yaml index 64e5e2e549..4a8d68913e 100644 --- a/openapi/paths.yaml +++ b/openapi/paths.yaml @@ -86,16 +86,11 @@ paths: /api/v1/login: post: + x-codeSamples: tags: - - login - summary: "Attempts authentication" + - auth + summary: "Login" description: | - After authenticating with the API, the returned object is a CompanyUser object which is a bridge linking the user to the company. - - The company user object itself contains the users permissions (admin/owner or fine grained permissions) You will most likely want to - also include in the response of this object both the company and the user object, this can be done by using the include parameter. - - /api/v1/login?include=company,user operationId: postLogin parameters: diff --git a/tests/Unit/RecurringDatesTest.php b/tests/Unit/RecurringDatesTest.php index 7d41f8161a..63eb0e04df 100644 --- a/tests/Unit/RecurringDatesTest.php +++ b/tests/Unit/RecurringDatesTest.php @@ -45,11 +45,25 @@ class RecurringDatesTest extends TestCase public function testDueDateDaysCalculationsTZ2() { + + $settings = CompanySettings::defaults(); + $settings->timezone_id = '15'; // New York + + $company = Company::factory()->create([ + 'account_id'=>$this->account->id, + 'settings' => $settings, + ]); + + $client = Client::factory()->create([ + 'company_id' =>$company->id, + 'user_id' => $this->user->id, + ]); + $this->travelTo(\Carbon\Carbon::create(2024, 12, 1, 17, 0, 0)); - $recurring_invoice = RecurringInvoiceFactory::create($this->company->id, $this->user->id); + $recurring_invoice = RecurringInvoiceFactory::create($company->id, $this->user->id); $recurring_invoice->line_items = $this->buildLineItems(); - $recurring_invoice->client_id = $this->client->id; + $recurring_invoice->client_id = $client->id; $recurring_invoice->status_id = RecurringInvoice::STATUS_DRAFT; $recurring_invoice->frequency_id = RecurringInvoice::FREQUENCY_MONTHLY; $recurring_invoice->remaining_cycles = 5; diff --git a/tests/Unit/RecurringDueDatesTest.php b/tests/Unit/RecurringDueDatesTest.php index 918d566c8d..54cfbeb116 100644 --- a/tests/Unit/RecurringDueDatesTest.php +++ b/tests/Unit/RecurringDueDatesTest.php @@ -15,10 +15,6 @@ use App\Utils\Traits\Recurring\HasRecurrence; use Illuminate\Support\Carbon; use Tests\TestCase; -/** - * - * App\Utils\Traits\Recurring\HasRecurrence - */ class RecurringDueDatesTest extends TestCase { use HasRecurrence;