Skip to content

Commit

Permalink
Add Invoice#invoice_number_prefix and Invoice#invoice_number_with_prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
cbarton committed Jan 9, 2015
1 parent 3df9c84 commit b0da280
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<a name="unreleased"></a>
## Unreleased
* Add `vat_location_valid` to `Account` [PR](https://github.com/recurly/recurly-client-ruby/pull/171)
* Add `Invoice#invoice_number_prefix` and `Invoice#invoice_number_with_prefix` to make use of the new
Country Invoice Sequencing feature [PR](https://github.com/recurly/recurly-client-ruby/pull/173)

<a name="v2.4.0"></a>
## v2.4.0 (2015-1-7)
Expand Down
7 changes: 6 additions & 1 deletion lib/recurly/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ class Invoice < Resource
# @return [Redemption]
has_one :redemption

def invoice_number_with_prefix
"#{invoice_number_prefix}#{invoice_number}"
end

define_attribute_methods %w(
uuid
state
invoice_number
invoice_number_prefix
po_number
vat_number
subtotal_in_cents
Expand All @@ -45,7 +50,7 @@ class Invoice < Resource
customer_notes
address
)
alias to_param invoice_number
alias to_param invoice_number_with_prefix

def self.to_xml(attrs)
invoice = new attrs
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/invoices/create-201.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Location: https://api.recurly.com/v2/invoices/created-invoice
<uuid>created-invoice</uuid>
<state>open</state>
<invoice_number type="integer">1000</invoice_number>
<invoice_number_prefix></invoice_number_prefix>
<po_number nil="nil"></po_number>
<vat_number nil="nil"></vat_number>
<subtotal_in_cents type="integer">300</subtotal_in_cents>
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/invoices/create-with-optionals-201.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Location: https://api.recurly.com/v2/invoices/created-invoice
<uuid>created-invoice</uuid>
<state>open</state>
<invoice_number type="integer">1000</invoice_number>
<invoice_number_prefix></invoice_number_prefix>
<po_number nil="nil"></po_number>
<vat_number nil="nil"></vat_number>
<subtotal_in_cents type="integer">300</subtotal_in_cents>
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/invoices/preview-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Content-Type: application/xml; charset=utf-8
<uuid>previewed-invoice</uuid>
<state>open</state>
<invoice_number type="integer">1000</invoice_number>
<invoice_number_prefix></invoice_number_prefix>
<po_number nil="nil"></po_number>
<vat_number nil="nil"></vat_number>
<subtotal_in_cents type="integer">300</subtotal_in_cents>
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/invoices/refund-201.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Location: https://api.recurly.com/v2/invoices/refund-invoice
<uuid>refund-invoice</uuid>
<state>open</state>
<invoice_number type="integer">1001</invoice_number>
<invoice_number_prefix></invoice_number_prefix>
<po_number nil="nil"></po_number>
<vat_number nil="nil"></vat_number>
<subtotal_in_cents type="integer">-550</subtotal_in_cents>
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/invoices/refund_amount-201.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Location: https://api.recurly.com/v2/invoices/refund-invoice
<uuid>refund-invoice</uuid>
<state>open</state>
<invoice_number type="integer">1001</invoice_number>
<invoice_number_prefix></invoice_number_prefix>
<po_number nil="nil"></po_number>
<vat_number nil="nil"></vat_number>
<subtotal_in_cents type="integer">-1000</subtotal_in_cents>
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/invoices/show-200-nosub.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Content-Type: application/xml; charset=utf-8
<uuid>created-invoice</uuid>
<state>open</state>
<invoice_number type="integer">1000</invoice_number>
<invoice_number_prefix></invoice_number_prefix>
<po_number nil="nil"></po_number>
<vat_number nil="nil"></vat_number>
<subtotal_in_cents type="integer">300</subtotal_in_cents>
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/invoices/show-200-refundable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Content-Type: application/xml; charset=utf-8
<uuid>refundable-invoice</uuid>
<state>open</state>
<invoice_number type="integer">1000</invoice_number>
<invoice_number_prefix></invoice_number_prefix>
<po_number nil="nil"></po_number>
<vat_number nil="nil"></vat_number>
<subtotal_in_cents type="integer">1100</subtotal_in_cents>
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/invoices/show-200-taxed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Content-Type: application/xml; charset=utf-8
<uuid>created-invoice</uuid>
<state>open</state>
<invoice_number type="integer">1000</invoice_number>
<invoice_number_prefix></invoice_number_prefix>
<po_number nil="nil"></po_number>
<vat_number nil="nil"></vat_number>
<subtotal_in_cents type="integer">300</subtotal_in_cents>
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/invoices/show-200-with-notes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Content-Type: application/xml; charset=utf-8
<uuid>created-invoice</uuid>
<state>open</state>
<invoice_number type="integer">1000</invoice_number>
<invoice_number_prefix></invoice_number_prefix>
<po_number nil="nil"></po_number>
<vat_number nil="nil"></vat_number>
<subtotal_in_cents type="integer">300</subtotal_in_cents>
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/subscriptions/preview-200-change.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Content-Type: application/xml; charset=utf-8
<uuid>abcdefg123</uuid>
<state>open</state>
<invoice_number nil="nil"></invoice_number>
<invoice_number_prefix></invoice_number_prefix>
<po_number nil="nil"></po_number>
<vat_number></vat_number>
<subtotal_in_cents type="integer">5000</subtotal_in_cents>
Expand Down
9 changes: 9 additions & 0 deletions spec/recurly/invoice_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
end

describe 'attributes' do
it 'includes the invoice number prefix' do
stub_api_request :get, 'invoices/invoice-with-prefix', 'invoices/create-201-prefix'

invoice = Invoice.find('invoice-with-prefix')
invoice.invoice_number.must_equal 1001
invoice.invoice_number_prefix.must_equal 'GB'
invoice.invoice_number_with_prefix.must_equal 'GB1001'
end

it 'has a tax type if taxed' do
stub_api_request :get, 'invoices/taxed-invoice', 'invoices/show-200-taxed'

Expand Down

0 comments on commit b0da280

Please sign in to comment.