From 770f0763f40557d1f9d7b001850a377c54123bc1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 19 Jan 2020 11:19:10 +1000 Subject: [PATCH] OpenAPI documentation for Payments. (#3223) * Working on API docs for payments * Fixes for OpenAPI documentation * Fix for conditionals in invoice calculator --- app/Helpers/Invoice/InvoiceItemSum.php | 2 +- .../Invoice/InvoiceItemSumInclusive.php | 2 +- .../OpenAPI/CreditPaymentableSchema.php | 10 ++++++ .../OpenAPI/InvoicePaymentableSchema.php | 10 ++++++ .../Controllers/OpenAPI/PaymentSchema.php | 18 +++++++++++ .../Controllers/OpenAPI/PaymentableSchema.php | 14 +++++++++ app/Http/Controllers/PaymentController.php | 31 +------------------ app/Transformers/PaymentableTransformer.php | 1 + 8 files changed, 56 insertions(+), 32 deletions(-) create mode 100644 app/Http/Controllers/OpenAPI/CreditPaymentableSchema.php create mode 100644 app/Http/Controllers/OpenAPI/InvoicePaymentableSchema.php create mode 100644 app/Http/Controllers/OpenAPI/PaymentableSchema.php diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index df8e3358fb36..693cc4b4d722 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -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; } diff --git a/app/Helpers/Invoice/InvoiceItemSumInclusive.php b/app/Helpers/Invoice/InvoiceItemSumInclusive.php index 8adc3a9a2470..2621387cd058 100644 --- a/app/Helpers/Invoice/InvoiceItemSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceItemSumInclusive.php @@ -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; } diff --git a/app/Http/Controllers/OpenAPI/CreditPaymentableSchema.php b/app/Http/Controllers/OpenAPI/CreditPaymentableSchema.php new file mode 100644 index 000000000000..2b8519d377f3 --- /dev/null +++ b/app/Http/Controllers/OpenAPI/CreditPaymentableSchema.php @@ -0,0 +1,10 @@ + $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, ];