mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
OpenAPI documentation for Payments. (#3223)
* Working on API docs for payments * Fixes for OpenAPI documentation * Fix for conditionals in invoice calculator
This commit is contained in:
parent
67c485c1b8
commit
770f0763f4
@ -58,7 +58,7 @@ class InvoiceItemSum
|
||||
|
||||
public function process()
|
||||
{
|
||||
if (!$this->invoice->line_items || !isset($this->invoice->line_items) || count($this->invoice->line_items) == 0) {
|
||||
if (!$this->invoice->line_items || !isset($this->invoice->line_items) || !is_array($this->invoice->line_items) || count($this->invoice->line_items) == 0) {
|
||||
$this->items = [];
|
||||
return $this;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class InvoiceItemSumInclusive
|
||||
|
||||
public function process()
|
||||
{
|
||||
if (!$this->invoice->line_items || count($this->invoice->line_items) == 0) {
|
||||
if (!$this->invoice->line_items || !is_array($this->invoice->line_items) || count($this->invoice->line_items) == 0) {
|
||||
$this->items = [];
|
||||
return $this;
|
||||
}
|
||||
|
10
app/Http/Controllers/OpenAPI/CreditPaymentableSchema.php
Normal file
10
app/Http/Controllers/OpenAPI/CreditPaymentableSchema.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* @OA\Schema(
|
||||
* schema="CreditPaymentable",
|
||||
* type="object",
|
||||
* @OA\Property(property="credit_id", type="string", example="Opnel5aKBz", description="______"),
|
||||
* @OA\Property(property="amount", type="string", example="2", description="______"),
|
||||
*
|
||||
* )
|
||||
*/
|
10
app/Http/Controllers/OpenAPI/InvoicePaymentableSchema.php
Normal file
10
app/Http/Controllers/OpenAPI/InvoicePaymentableSchema.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* @OA\Schema(
|
||||
* schema="InvoicePaymentable",
|
||||
* type="object",
|
||||
* @OA\Property(property="invoice_id", type="string", example="Opnel5aKBz", description="______"),
|
||||
* @OA\Property(property="amount", type="string", example="2", description="______"),
|
||||
*
|
||||
* )
|
||||
*/
|
@ -19,5 +19,23 @@
|
||||
* @OA\Property(property="updated_at", type="number", format="integer", example="1434342123", description="Timestamp"),
|
||||
* @OA\Property(property="archived_at", type="number", format="integer", example="1434342123", description="Timestamp"),
|
||||
* @OA\Property(property="company_gateway_id", type="string", example="3", description="The company gateway id"),
|
||||
* @OA\Property(property="paymentables",ref="#/components/schemas/Paymentable"),
|
||||
* @OA\Property(
|
||||
* property="invoices",
|
||||
* type="array",
|
||||
* description="",
|
||||
* @OA\Items(
|
||||
* ref="#/components/schemas/InvoicePaymentable",
|
||||
* ),
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="credits",
|
||||
* type="array",
|
||||
* description="",
|
||||
* @OA\Items(
|
||||
* ref="#/components/schemas/CreditPaymentable",
|
||||
* ),
|
||||
* ),
|
||||
*
|
||||
* )
|
||||
*/
|
||||
|
14
app/Http/Controllers/OpenAPI/PaymentableSchema.php
Normal file
14
app/Http/Controllers/OpenAPI/PaymentableSchema.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* @OA\Schema(
|
||||
* schema="Paymentable",
|
||||
* type="object",
|
||||
* @OA\Property(property="id", type="string", example="AS3df3A", description="The paymentable hashed id"),
|
||||
* @OA\Property(property="invoice_id", type="string", example="AS3df3A", description="The invoice hashed id"),
|
||||
* @OA\Property(property="credit_id", type="string", example="AS3df3A", description="The credit hashed id"),
|
||||
* @OA\Property(property="refunded", type="number", format="float", example="10.00", description="______"),
|
||||
* @OA\Property(property="amount", type="number", format="float", example="10.00", description="______"),
|
||||
* @OA\Property(property="updated_at", type="number", format="integer", example="1434342123", description="Timestamp"),
|
||||
* @OA\Property(property="created_at", type="number", format="integer", example="1434342123", description="Timestamp"),*
|
||||
* )
|
||||
*/
|
@ -181,36 +181,7 @@ class PaymentController extends BaseController
|
||||
* @OA\RequestBody(
|
||||
* description="The payment request",
|
||||
* required=true,
|
||||
* @OA\MediaType(
|
||||
* mediaType="application/json",
|
||||
* @OA\Schema(
|
||||
* type="object",
|
||||
* @OA\Property(
|
||||
* property="amount",
|
||||
* description="The payment amount",
|
||||
* type="number",
|
||||
* format="float",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="date",
|
||||
* example="2019/12/1",
|
||||
* description="The payment date",
|
||||
* type="string",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="transation_reference",
|
||||
* example="sdfasdfs98776d6kbkfd",
|
||||
* description="The transaction reference for the payment",
|
||||
* type="string",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="invoices",
|
||||
* example="j7s76d,s8765afk,D8fj3Sfdj",
|
||||
* description="A comma separated list of invoice hashed ids that this payment relates to",
|
||||
* type="string",
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* @OA\JsonContent(ref="#/components/schemas/Payment"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
|
@ -42,6 +42,7 @@ class PaymentableTransformer extends EntityTransformer
|
||||
'id' => $this->encodePrimaryKey($paymentable->id),
|
||||
$entity_key => $this->encodePrimaryKey($paymentable->paymentable_id),
|
||||
'amount' => (float)$paymentable->amount,
|
||||
'refunded' => (float)$paymentable->refunded,
|
||||
'created_at' => (int) $paymentable->created_at,
|
||||
'updated_at' => (int) $paymentable->updated_at,
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user