Skip to content

Commit

Permalink
Add Proforma Invoices & Items resources, Bump to 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaultier Laperche committed Jun 17, 2019
1 parent c60bc6b commit c15765e
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,4 +1,8 @@
# Changelog

## 2.0.1 - 2019-06-17
* Add basic support for proforma invoices and proforma invoice items
* Add the possibility to transform a draft invoice into a proforma

## 2.0.0 - 2018-04-19
* Initial commit
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2010-2015 Stripe
Copyright (c) 2016-2019 Octobat

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -67,8 +67,7 @@ end up there instead of `error_log`:

### Per-request Configuration

For apps that need to use multiple keys during the lifetime of a process, like
one that uses [Stripe Connect][connect], it's also possible to set a
For apps that need to use multiple keys during the lifetime of a process, it's also possible to set a
per-request key and/or account:

```php
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
2.0.0
2.0.1
2 changes: 2 additions & 0 deletions init.php
Expand Up @@ -64,6 +64,8 @@
require(dirname(__FILE__) . '/lib/PaymentRecipientReference.php');
require(dirname(__FILE__) . '/lib/PaymentSource.php');
require(dirname(__FILE__) . '/lib/Payout.php');
require(dirname(__FILE__) . '/lib/ProformaInvoice.php');
require(dirname(__FILE__) . '/lib/ProformaInvoiceItem.php');
require(dirname(__FILE__) . '/lib/TaxEvidence.php');
require(dirname(__FILE__) . '/lib/TaxEvidenceRequest.php');
require(dirname(__FILE__) . '/lib/TaxRegionSetting.php');
Expand Down
1 change: 1 addition & 0 deletions lib/CreditNote.php
Expand Up @@ -29,6 +29,7 @@
* @property int $unrefunded_amount_cents
* @property string $notes
* @property string $language
* @property string $customer_locale
* @property string $currency
* @property string $customer_name
* @property string $customer_address_line_1
Expand Down
18 changes: 18 additions & 0 deletions lib/Invoice.php
Expand Up @@ -28,6 +28,7 @@
* @property int $unpaid_amount_cents
* @property string $notes
* @property string $language
* @property string $customer_locale
* @property string $currency
* @property string $customer_name
* @property string $customer_address_line_1
Expand All @@ -50,6 +51,7 @@
* @property string $replaced_by
* @property OctobatObject $legal_fields
* @property OctobatObject $sources
* @property OctobatObject $metadata
* @property int $items_count
* @property Collection $items
*
Expand Down Expand Up @@ -176,4 +178,20 @@ public function transactions($params = null)
$transactions = Transaction::all($params, $this->_opts);
return $transactions;
}


/**
* @param array|string|null $options
*
* @return Invoice The confirmed Invoice.
*/
public function createProformaInvoice()
{
$params = [];
$params['invoice'] = $this->id;

$proforma = ProformaInvoice::create($params, $this->_opts);
return $proforma;
}

}
2 changes: 1 addition & 1 deletion lib/Octobat.php
Expand Up @@ -40,7 +40,7 @@ class Octobat
// @var float Initial delay between retries, in seconds
private static $initialNetworkRetryDelay = 0.5;

const VERSION = '2.0.0';
const VERSION = '2.0.1';

/**
* @return string The API key used for requests.
Expand Down
68 changes: 68 additions & 0 deletions lib/ProformaInvoice.php
@@ -0,0 +1,68 @@
<?php

namespace Octobat;

/**
* Class ProformaInvoice
*
* @property string $id
* @property string $object
* @property bool $livemode
* @property string $customer
* @property string $invoice
* @property string $document_template
* @property string $pdf_file_url
* @property string $proforma_invoice_number
* @property string $proforma_invoice_date
* @property string $description
* @property int $total_extratax_amount
* @property int $total_tax_amount
* @property int $total_gross_amount
* @property string $notes
* @property string $language
* @property string $customer_locale
* @property string $currency
* @property string $customer_name
* @property string $customer_address_line_1
* @property string $customer_address_line_2
* @property string $customer_address_city
* @property string $customer_address_state
* @property string $customer_address_zip
* @property string $customer_address_country
* @property string $customer_country_code
* @property string $customer_tax_number
* @property string $customer_business_type
* @property string $supplier_address_line_1
* @property string $supplier_address_line_2
* @property string $supplier_address_city
* @property string $supplier_address_state
* @property string $supplier_address_zip
* @property string $supplier_address_country
* @property string $supplier_tax_number
* @property OctobatObject $legal_fields
* @property OctobatObject $metadata
* @property int $proforma_invoice_items_count
* @property Collection $proforma_invoice_items
*
* @package Octobat
*/
class ProformaInvoice extends ApiResource
{
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\NestedResource;

public static function getSavedNestedResources()
{
static $savedNestedResources = null;
if ($savedNestedResources === null) {
$savedNestedResources = new Util\Set([
'proforma_invoice_item',
]);
}
return $savedNestedResources;
}

const PATH_PROFORMA_INVOICE_ITEMS = '/proforma_invoice_items';

}
34 changes: 34 additions & 0 deletions lib/ProformaInvoiceItem.php
@@ -0,0 +1,34 @@
<?php

namespace Octobat;


/**
* Class ProformaInvoiceItem
*
* @property string $id
* @property string $object
* @property string $customer
* @property string $proforma_invoice
* @property string $product_type
* @property string $sale_mode
* @property string $description
* @property int $quantity
* @property int $unit_extratax_amount
* @property int $extratax_amount
* @property int $tax_amount
* @property int $gross_amount
* @property string $currency
* @property float $tax_rate
* @property string $tax
* @property OctobatObject $period
* @property OctobatObject $tax_evidence
* @property OctobatObject $product
*
* @package Octobat
*/
class ProformaInvoiceItem extends ApiResource
{


}
2 changes: 2 additions & 0 deletions lib/Util/Util.php
Expand Up @@ -88,6 +88,8 @@ public static function convertToOctobatObject($resp, $opts)
'payment_recipient_reference' => 'Octobat\\PaymentRecipientReference',
'payment_source' => 'Octobat\\PaymentSource',
'payout' => 'Octobat\\Payout',
'proforma_invoice' => 'Octobat\\ProformaInvoice',
'proforma_invoice_item' => 'Octobat\\ProformaInvoiceItem',
'tax_evidence' => 'Octobat\\TaxEvidence',
'tax_evidence_request' => 'Octobat\\TaxEvidenceRequest',
'tax_region_setting' => 'Octobat\\TaxRegionSetting',
Expand Down

0 comments on commit c15765e

Please sign in to comment.