vatsense 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.ignore +2 -0
- data/CHANGELOG.md +14 -0
- data/README.md +235 -0
- data/SECURITY.md +27 -0
- data/lib/vatsense/client.rb +129 -0
- data/lib/vatsense/errors.rb +228 -0
- data/lib/vatsense/file_part.rb +58 -0
- data/lib/vatsense/internal/transport/base_client.rb +595 -0
- data/lib/vatsense/internal/transport/pooled_net_requester.rb +210 -0
- data/lib/vatsense/internal/type/array_of.rb +168 -0
- data/lib/vatsense/internal/type/base_model.rb +531 -0
- data/lib/vatsense/internal/type/base_page.rb +55 -0
- data/lib/vatsense/internal/type/boolean.rb +77 -0
- data/lib/vatsense/internal/type/converter.rb +327 -0
- data/lib/vatsense/internal/type/enum.rb +131 -0
- data/lib/vatsense/internal/type/file_input.rb +111 -0
- data/lib/vatsense/internal/type/hash_of.rb +188 -0
- data/lib/vatsense/internal/type/request_parameters.rb +42 -0
- data/lib/vatsense/internal/type/union.rb +237 -0
- data/lib/vatsense/internal/type/unknown.rb +81 -0
- data/lib/vatsense/internal/util.rb +951 -0
- data/lib/vatsense/internal.rb +20 -0
- data/lib/vatsense/models/country.rb +70 -0
- data/lib/vatsense/models/country_list_params.rb +34 -0
- data/lib/vatsense/models/country_list_provinces_params.rb +22 -0
- data/lib/vatsense/models/country_list_provinces_response.rb +67 -0
- data/lib/vatsense/models/country_list_response.rb +28 -0
- data/lib/vatsense/models/create_invoice.rb +171 -0
- data/lib/vatsense/models/currency_calculate_vat_price_params.rb +53 -0
- data/lib/vatsense/models/currency_calculate_vat_price_response.rb +28 -0
- data/lib/vatsense/models/currency_convert_params.rb +53 -0
- data/lib/vatsense/models/currency_convert_response.rb +87 -0
- data/lib/vatsense/models/currency_list_params.rb +45 -0
- data/lib/vatsense/models/currency_list_response.rb +72 -0
- data/lib/vatsense/models/find_rate.rb +28 -0
- data/lib/vatsense/models/invoice/invoice_item.rb +71 -0
- data/lib/vatsense/models/invoice/invoice_item_input.rb +52 -0
- data/lib/vatsense/models/invoice/item_add_params.rb +28 -0
- data/lib/vatsense/models/invoice/item_delete_params.rb +28 -0
- data/lib/vatsense/models/invoice/item_retrieve_params.rb +28 -0
- data/lib/vatsense/models/invoice/item_retrieve_response.rb +30 -0
- data/lib/vatsense/models/invoice/item_update_params.rb +28 -0
- data/lib/vatsense/models/invoice.rb +301 -0
- data/lib/vatsense/models/invoice_business_input.rb +80 -0
- data/lib/vatsense/models/invoice_conversion_input.rb +24 -0
- data/lib/vatsense/models/invoice_create_params.rb +14 -0
- data/lib/vatsense/models/invoice_customer_input.rb +59 -0
- data/lib/vatsense/models/invoice_delete_params.rb +20 -0
- data/lib/vatsense/models/invoice_delete_response.rb +22 -0
- data/lib/vatsense/models/invoice_list_params.rb +38 -0
- data/lib/vatsense/models/invoice_list_response.rb +28 -0
- data/lib/vatsense/models/invoice_response.rb +28 -0
- data/lib/vatsense/models/invoice_retrieve_params.rb +20 -0
- data/lib/vatsense/models/invoice_update_params.rb +20 -0
- data/lib/vatsense/models/rate.rb +74 -0
- data/lib/vatsense/models/rate_calculate_price_params.rb +88 -0
- data/lib/vatsense/models/rate_calculate_price_response.rb +79 -0
- data/lib/vatsense/models/rate_details_params.rb +69 -0
- data/lib/vatsense/models/rate_find_params.rb +69 -0
- data/lib/vatsense/models/rate_list_params.rb +51 -0
- data/lib/vatsense/models/rate_list_response.rb +28 -0
- data/lib/vatsense/models/rate_list_types_params.rb +14 -0
- data/lib/vatsense/models/rate_list_types_response.rb +28 -0
- data/lib/vatsense/models/rate_with_tax_rate.rb +49 -0
- data/lib/vatsense/models/sandbox_generate_key_params.rb +14 -0
- data/lib/vatsense/models/sandbox_generate_key_response.rb +68 -0
- data/lib/vatsense/models/tax_rate.rb +76 -0
- data/lib/vatsense/models/usage_retrieve_params.rb +14 -0
- data/lib/vatsense/models/usage_retrieve_response.rb +67 -0
- data/lib/vatsense/models/validate_check_params.rb +48 -0
- data/lib/vatsense/models/validate_check_response.rb +135 -0
- data/lib/vatsense/models/vat_price.rb +86 -0
- data/lib/vatsense/models.rb +103 -0
- data/lib/vatsense/request_options.rb +77 -0
- data/lib/vatsense/resources/countries.rb +70 -0
- data/lib/vatsense/resources/currency.rb +111 -0
- data/lib/vatsense/resources/invoice/item.rb +133 -0
- data/lib/vatsense/resources/invoice.rb +206 -0
- data/lib/vatsense/resources/rates.rb +190 -0
- data/lib/vatsense/resources/sandbox.rb +36 -0
- data/lib/vatsense/resources/usage.rb +33 -0
- data/lib/vatsense/resources/validate.rb +56 -0
- data/lib/vatsense/version.rb +5 -0
- data/lib/vatsense.rb +113 -0
- data/manifest.yaml +17 -0
- data/rbi/vatsense/client.rbi +93 -0
- data/rbi/vatsense/errors.rbi +205 -0
- data/rbi/vatsense/file_part.rbi +37 -0
- data/rbi/vatsense/internal/transport/base_client.rbi +300 -0
- data/rbi/vatsense/internal/transport/pooled_net_requester.rbi +83 -0
- data/rbi/vatsense/internal/type/array_of.rbi +104 -0
- data/rbi/vatsense/internal/type/base_model.rbi +306 -0
- data/rbi/vatsense/internal/type/base_page.rbi +42 -0
- data/rbi/vatsense/internal/type/boolean.rbi +58 -0
- data/rbi/vatsense/internal/type/converter.rbi +216 -0
- data/rbi/vatsense/internal/type/enum.rbi +82 -0
- data/rbi/vatsense/internal/type/file_input.rbi +59 -0
- data/rbi/vatsense/internal/type/hash_of.rbi +104 -0
- data/rbi/vatsense/internal/type/request_parameters.rbi +29 -0
- data/rbi/vatsense/internal/type/union.rbi +128 -0
- data/rbi/vatsense/internal/type/unknown.rbi +58 -0
- data/rbi/vatsense/internal/util.rbi +507 -0
- data/rbi/vatsense/internal.rbi +16 -0
- data/rbi/vatsense/models/country.rbi +111 -0
- data/rbi/vatsense/models/country_list_params.rbi +59 -0
- data/rbi/vatsense/models/country_list_provinces_params.rbi +43 -0
- data/rbi/vatsense/models/country_list_provinces_response.rbi +177 -0
- data/rbi/vatsense/models/country_list_response.rbi +55 -0
- data/rbi/vatsense/models/create_invoice.rbi +240 -0
- data/rbi/vatsense/models/currency_calculate_vat_price_params.rbi +100 -0
- data/rbi/vatsense/models/currency_calculate_vat_price_response.rbi +51 -0
- data/rbi/vatsense/models/currency_convert_params.rbi +81 -0
- data/rbi/vatsense/models/currency_convert_response.rbi +190 -0
- data/rbi/vatsense/models/currency_list_params.rbi +79 -0
- data/rbi/vatsense/models/currency_list_response.rbi +174 -0
- data/rbi/vatsense/models/find_rate.rbi +50 -0
- data/rbi/vatsense/models/invoice/invoice_item.rbi +129 -0
- data/rbi/vatsense/models/invoice/invoice_item_input.rbi +79 -0
- data/rbi/vatsense/models/invoice/item_add_params.rbi +45 -0
- data/rbi/vatsense/models/invoice/item_delete_params.rbi +48 -0
- data/rbi/vatsense/models/invoice/item_retrieve_params.rbi +48 -0
- data/rbi/vatsense/models/invoice/item_retrieve_response.rbi +57 -0
- data/rbi/vatsense/models/invoice/item_update_params.rbi +48 -0
- data/rbi/vatsense/models/invoice.rbi +481 -0
- data/rbi/vatsense/models/invoice_business_input.rbi +113 -0
- data/rbi/vatsense/models/invoice_conversion_input.rbi +35 -0
- data/rbi/vatsense/models/invoice_create_params.rbi +27 -0
- data/rbi/vatsense/models/invoice_customer_input.rbi +93 -0
- data/rbi/vatsense/models/invoice_delete_params.rbi +35 -0
- data/rbi/vatsense/models/invoice_delete_response.rbi +31 -0
- data/rbi/vatsense/models/invoice_list_params.rbi +68 -0
- data/rbi/vatsense/models/invoice_list_response.rbi +55 -0
- data/rbi/vatsense/models/invoice_response.rbi +48 -0
- data/rbi/vatsense/models/invoice_retrieve_params.rbi +35 -0
- data/rbi/vatsense/models/invoice_update_params.rbi +35 -0
- data/rbi/vatsense/models/rate.rbi +119 -0
- data/rbi/vatsense/models/rate_calculate_price_params.rbi +144 -0
- data/rbi/vatsense/models/rate_calculate_price_response.rbi +184 -0
- data/rbi/vatsense/models/rate_details_params.rbi +109 -0
- data/rbi/vatsense/models/rate_find_params.rbi +109 -0
- data/rbi/vatsense/models/rate_list_params.rbi +83 -0
- data/rbi/vatsense/models/rate_list_response.rbi +48 -0
- data/rbi/vatsense/models/rate_list_types_params.rbi +27 -0
- data/rbi/vatsense/models/rate_list_types_response.rbi +51 -0
- data/rbi/vatsense/models/rate_with_tax_rate.rbi +94 -0
- data/rbi/vatsense/models/sandbox_generate_key_params.rbi +27 -0
- data/rbi/vatsense/models/sandbox_generate_key_response.rbi +135 -0
- data/rbi/vatsense/models/tax_rate.rbi +109 -0
- data/rbi/vatsense/models/usage_retrieve_params.rbi +27 -0
- data/rbi/vatsense/models/usage_retrieve_response.rbi +155 -0
- data/rbi/vatsense/models/validate_check_params.rbi +82 -0
- data/rbi/vatsense/models/validate_check_response.rbi +285 -0
- data/rbi/vatsense/models/vat_price.rbi +136 -0
- data/rbi/vatsense/models.rbi +66 -0
- data/rbi/vatsense/request_options.rbi +59 -0
- data/rbi/vatsense/resources/countries.rbi +49 -0
- data/rbi/vatsense/resources/currency.rbi +82 -0
- data/rbi/vatsense/resources/invoice/item.rbi +97 -0
- data/rbi/vatsense/resources/invoice.rbi +191 -0
- data/rbi/vatsense/resources/rates.rbi +164 -0
- data/rbi/vatsense/resources/sandbox.rbi +24 -0
- data/rbi/vatsense/resources/usage.rbi +22 -0
- data/rbi/vatsense/resources/validate.rbi +51 -0
- data/rbi/vatsense/version.rbi +5 -0
- data/sig/vatsense/client.rbs +45 -0
- data/sig/vatsense/errors.rbs +117 -0
- data/sig/vatsense/file_part.rbs +21 -0
- data/sig/vatsense/internal/transport/base_client.rbs +135 -0
- data/sig/vatsense/internal/transport/pooled_net_requester.rbs +48 -0
- data/sig/vatsense/internal/type/array_of.rbs +48 -0
- data/sig/vatsense/internal/type/base_model.rbs +102 -0
- data/sig/vatsense/internal/type/base_page.rbs +24 -0
- data/sig/vatsense/internal/type/boolean.rbs +26 -0
- data/sig/vatsense/internal/type/converter.rbs +79 -0
- data/sig/vatsense/internal/type/enum.rbs +32 -0
- data/sig/vatsense/internal/type/file_input.rbs +25 -0
- data/sig/vatsense/internal/type/hash_of.rbs +48 -0
- data/sig/vatsense/internal/type/request_parameters.rbs +17 -0
- data/sig/vatsense/internal/type/union.rbs +52 -0
- data/sig/vatsense/internal/type/unknown.rbs +26 -0
- data/sig/vatsense/internal/util.rbs +195 -0
- data/sig/vatsense/internal.rbs +9 -0
- data/sig/vatsense/models/country.rbs +76 -0
- data/sig/vatsense/models/country_list_params.rbs +32 -0
- data/sig/vatsense/models/country_list_provinces_params.rbs +23 -0
- data/sig/vatsense/models/country_list_provinces_response.rbs +90 -0
- data/sig/vatsense/models/country_list_response.rbs +32 -0
- data/sig/vatsense/models/create_invoice.rbs +154 -0
- data/sig/vatsense/models/currency_calculate_vat_price_params.rbs +47 -0
- data/sig/vatsense/models/currency_calculate_vat_price_response.rbs +28 -0
- data/sig/vatsense/models/currency_convert_params.rbs +47 -0
- data/sig/vatsense/models/currency_convert_response.rbs +104 -0
- data/sig/vatsense/models/currency_list_params.rbs +45 -0
- data/sig/vatsense/models/currency_list_response.rbs +90 -0
- data/sig/vatsense/models/find_rate.rbs +32 -0
- data/sig/vatsense/models/invoice/invoice_item.rbs +85 -0
- data/sig/vatsense/models/invoice/invoice_item_input.rbs +46 -0
- data/sig/vatsense/models/invoice/item_add_params.rbs +33 -0
- data/sig/vatsense/models/invoice/item_delete_params.rbs +30 -0
- data/sig/vatsense/models/invoice/item_retrieve_params.rbs +30 -0
- data/sig/vatsense/models/invoice/item_retrieve_response.rbs +36 -0
- data/sig/vatsense/models/invoice/item_update_params.rbs +34 -0
- data/sig/vatsense/models/invoice.rbs +332 -0
- data/sig/vatsense/models/invoice_business_input.rbs +72 -0
- data/sig/vatsense/models/invoice_conversion_input.rbs +15 -0
- data/sig/vatsense/models/invoice_create_params.rbs +15 -0
- data/sig/vatsense/models/invoice_customer_input.rbs +62 -0
- data/sig/vatsense/models/invoice_delete_params.rbs +23 -0
- data/sig/vatsense/models/invoice_delete_response.rbs +15 -0
- data/sig/vatsense/models/invoice_list_params.rbs +38 -0
- data/sig/vatsense/models/invoice_list_response.rbs +34 -0
- data/sig/vatsense/models/invoice_response.rbs +32 -0
- data/sig/vatsense/models/invoice_retrieve_params.rbs +23 -0
- data/sig/vatsense/models/invoice_update_params.rbs +25 -0
- data/sig/vatsense/models/rate.rbs +79 -0
- data/sig/vatsense/models/rate_calculate_price_params.rbs +77 -0
- data/sig/vatsense/models/rate_calculate_price_response.rbs +104 -0
- data/sig/vatsense/models/rate_details_params.rbs +63 -0
- data/sig/vatsense/models/rate_find_params.rbs +63 -0
- data/sig/vatsense/models/rate_list_params.rbs +44 -0
- data/sig/vatsense/models/rate_list_response.rbs +32 -0
- data/sig/vatsense/models/rate_list_types_params.rbs +15 -0
- data/sig/vatsense/models/rate_list_types_response.rbs +28 -0
- data/sig/vatsense/models/rate_with_tax_rate.rbs +62 -0
- data/sig/vatsense/models/sandbox_generate_key_params.rbs +15 -0
- data/sig/vatsense/models/sandbox_generate_key_response.rbs +85 -0
- data/sig/vatsense/models/tax_rate.rbs +72 -0
- data/sig/vatsense/models/usage_retrieve_params.rbs +15 -0
- data/sig/vatsense/models/usage_retrieve_response.rbs +81 -0
- data/sig/vatsense/models/validate_check_params.rbs +38 -0
- data/sig/vatsense/models/validate_check_response.rbs +161 -0
- data/sig/vatsense/models/vat_price.rbs +89 -0
- data/sig/vatsense/models.rbs +63 -0
- data/sig/vatsense/request_options.rbs +34 -0
- data/sig/vatsense/resources/countries.rbs +18 -0
- data/sig/vatsense/resources/currency.rbs +27 -0
- data/sig/vatsense/resources/invoice/item.rbs +38 -0
- data/sig/vatsense/resources/invoice.rbs +69 -0
- data/sig/vatsense/resources/rates.rbs +50 -0
- data/sig/vatsense/resources/sandbox.rbs +11 -0
- data/sig/vatsense/resources/usage.rbs +11 -0
- data/sig/vatsense/resources/validate.rbs +14 -0
- data/sig/vatsense/version.rbs +3 -0
- metadata +316 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module Vatsense
|
|
4
|
+
module Resources
|
|
5
|
+
class Invoice
|
|
6
|
+
# VAT-compliant invoice management
|
|
7
|
+
class Item
|
|
8
|
+
# Retrieve a specific line item from an invoice.
|
|
9
|
+
sig do
|
|
10
|
+
params(
|
|
11
|
+
item_id: String,
|
|
12
|
+
invoice_id: String,
|
|
13
|
+
request_options: Vatsense::RequestOptions::OrHash
|
|
14
|
+
).returns(Vatsense::Models::Invoice::ItemRetrieveResponse)
|
|
15
|
+
end
|
|
16
|
+
def retrieve(
|
|
17
|
+
# The unique identifier of the invoice item.
|
|
18
|
+
item_id,
|
|
19
|
+
# The unique identifier of the invoice.
|
|
20
|
+
invoice_id:,
|
|
21
|
+
request_options: {}
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Update a specific line item on an invoice.
|
|
26
|
+
sig do
|
|
27
|
+
params(
|
|
28
|
+
item_id: String,
|
|
29
|
+
invoice_id: String,
|
|
30
|
+
item: String,
|
|
31
|
+
price_each: Float,
|
|
32
|
+
quantity: Float,
|
|
33
|
+
vat_rate: Float,
|
|
34
|
+
discount_rate: Float,
|
|
35
|
+
request_options: Vatsense::RequestOptions::OrHash
|
|
36
|
+
).returns(Vatsense::InvoiceResponse)
|
|
37
|
+
end
|
|
38
|
+
def update(
|
|
39
|
+
# Path param: The unique identifier of the invoice item.
|
|
40
|
+
item_id,
|
|
41
|
+
# Path param: The unique identifier of the invoice.
|
|
42
|
+
invoice_id:,
|
|
43
|
+
# Body param: The description of the line item.
|
|
44
|
+
item:,
|
|
45
|
+
# Body param: The price per item. Must be a decimal with 2 decimal places.
|
|
46
|
+
price_each:,
|
|
47
|
+
# Body param: The quantity of the item.
|
|
48
|
+
quantity:,
|
|
49
|
+
# Body param: A percentage VAT rate for this item.
|
|
50
|
+
vat_rate:,
|
|
51
|
+
# Body param: A percentage discount to apply to the price.
|
|
52
|
+
discount_rate: nil,
|
|
53
|
+
request_options: {}
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Remove a specific line item from an invoice.
|
|
58
|
+
sig do
|
|
59
|
+
params(
|
|
60
|
+
item_id: String,
|
|
61
|
+
invoice_id: String,
|
|
62
|
+
request_options: Vatsense::RequestOptions::OrHash
|
|
63
|
+
).returns(Vatsense::InvoiceResponse)
|
|
64
|
+
end
|
|
65
|
+
def delete(
|
|
66
|
+
# The unique identifier of the invoice item.
|
|
67
|
+
item_id,
|
|
68
|
+
# The unique identifier of the invoice.
|
|
69
|
+
invoice_id:,
|
|
70
|
+
request_options: {}
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Add one or more line items to an existing invoice.
|
|
75
|
+
sig do
|
|
76
|
+
params(
|
|
77
|
+
invoice_id: String,
|
|
78
|
+
items: T::Array[Vatsense::Invoice::InvoiceItemInput::OrHash],
|
|
79
|
+
request_options: Vatsense::RequestOptions::OrHash
|
|
80
|
+
).returns(Vatsense::InvoiceResponse)
|
|
81
|
+
end
|
|
82
|
+
def add(
|
|
83
|
+
# The unique identifier of the invoice.
|
|
84
|
+
invoice_id,
|
|
85
|
+
items:,
|
|
86
|
+
request_options: {}
|
|
87
|
+
)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# @api private
|
|
91
|
+
sig { params(client: Vatsense::Client).returns(T.attached_class) }
|
|
92
|
+
def self.new(client:)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module Vatsense
|
|
4
|
+
module Resources
|
|
5
|
+
# VAT-compliant invoice management
|
|
6
|
+
class Invoice
|
|
7
|
+
# VAT-compliant invoice management
|
|
8
|
+
sig { returns(Vatsense::Resources::Invoice::Item) }
|
|
9
|
+
attr_reader :item
|
|
10
|
+
|
|
11
|
+
# Create a new VAT-compliant invoice. VAT Sense will automatically calculate the
|
|
12
|
+
# totals based on the items provided.
|
|
13
|
+
#
|
|
14
|
+
# Not available with sandbox API keys.
|
|
15
|
+
sig do
|
|
16
|
+
params(
|
|
17
|
+
business: Vatsense::InvoiceBusinessInput::OrHash,
|
|
18
|
+
currency_code: String,
|
|
19
|
+
date: String,
|
|
20
|
+
items: T::Array[Vatsense::Invoice::InvoiceItemInput::OrHash],
|
|
21
|
+
tax_point: String,
|
|
22
|
+
conversion: Vatsense::InvoiceConversionInput::OrHash,
|
|
23
|
+
customer: Vatsense::InvoiceCustomerInput::OrHash,
|
|
24
|
+
has_vat: T::Boolean,
|
|
25
|
+
invoice_number: String,
|
|
26
|
+
is_copy: T::Boolean,
|
|
27
|
+
is_reverse_charge: T::Boolean,
|
|
28
|
+
notes: String,
|
|
29
|
+
pad_invoice_number: Integer,
|
|
30
|
+
serial: String,
|
|
31
|
+
tax_type: Vatsense::CreateInvoice::TaxType::OrSymbol,
|
|
32
|
+
type: Vatsense::CreateInvoice::Type::OrSymbol,
|
|
33
|
+
zero_rated: T::Boolean,
|
|
34
|
+
request_options: Vatsense::RequestOptions::OrHash
|
|
35
|
+
).returns(Vatsense::InvoiceResponse)
|
|
36
|
+
end
|
|
37
|
+
def create(
|
|
38
|
+
business:,
|
|
39
|
+
# The 3-character currency code the invoice is billed in.
|
|
40
|
+
currency_code:,
|
|
41
|
+
# The date the invoice was issued (YYYY-MM-DD or YYYY-MM-DD HH:MM:SS).
|
|
42
|
+
date:,
|
|
43
|
+
items:,
|
|
44
|
+
# The tax point or "time of supply" (YYYY-MM-DD or YYYY-MM-DD HH:MM:SS).
|
|
45
|
+
tax_point:,
|
|
46
|
+
conversion: nil,
|
|
47
|
+
customer: nil,
|
|
48
|
+
# Whether the invoice is subject to VAT.
|
|
49
|
+
has_vat: nil,
|
|
50
|
+
# A unique invoice number. If not provided, defaults to an auto-incremented
|
|
51
|
+
# number.
|
|
52
|
+
invoice_number: nil,
|
|
53
|
+
# Whether the invoice is a copy of a primary invoice.
|
|
54
|
+
is_copy: nil,
|
|
55
|
+
# Whether the invoice is zero-rated due to reverse charge.
|
|
56
|
+
is_reverse_charge: nil,
|
|
57
|
+
# Any additional notes for the invoice.
|
|
58
|
+
notes: nil,
|
|
59
|
+
# Pad the auto-generated invoice number with leading zeros to this length.
|
|
60
|
+
pad_invoice_number: nil,
|
|
61
|
+
# A serial prepended to the auto-generated invoice number. Each unique serial has
|
|
62
|
+
# its own auto-increment range.
|
|
63
|
+
serial: nil,
|
|
64
|
+
# Whether item prices include or exclude VAT.
|
|
65
|
+
tax_type: nil,
|
|
66
|
+
# The type of invoice.
|
|
67
|
+
type: nil,
|
|
68
|
+
# Whether the invoice has been zero-rated.
|
|
69
|
+
zero_rated: nil,
|
|
70
|
+
request_options: {}
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Retrieve a specific invoice by its ID.
|
|
75
|
+
sig do
|
|
76
|
+
params(
|
|
77
|
+
invoice_id: String,
|
|
78
|
+
request_options: Vatsense::RequestOptions::OrHash
|
|
79
|
+
).returns(Vatsense::InvoiceResponse)
|
|
80
|
+
end
|
|
81
|
+
def retrieve(
|
|
82
|
+
# The unique identifier of the invoice.
|
|
83
|
+
invoice_id,
|
|
84
|
+
request_options: {}
|
|
85
|
+
)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Update an existing invoice. Only the fields provided will be updated.
|
|
89
|
+
sig do
|
|
90
|
+
params(
|
|
91
|
+
invoice_id: String,
|
|
92
|
+
business: Vatsense::InvoiceBusinessInput::OrHash,
|
|
93
|
+
currency_code: String,
|
|
94
|
+
date: String,
|
|
95
|
+
items: T::Array[Vatsense::Invoice::InvoiceItemInput::OrHash],
|
|
96
|
+
tax_point: String,
|
|
97
|
+
conversion: Vatsense::InvoiceConversionInput::OrHash,
|
|
98
|
+
customer: Vatsense::InvoiceCustomerInput::OrHash,
|
|
99
|
+
has_vat: T::Boolean,
|
|
100
|
+
invoice_number: String,
|
|
101
|
+
is_copy: T::Boolean,
|
|
102
|
+
is_reverse_charge: T::Boolean,
|
|
103
|
+
notes: String,
|
|
104
|
+
pad_invoice_number: Integer,
|
|
105
|
+
serial: String,
|
|
106
|
+
tax_type: Vatsense::CreateInvoice::TaxType::OrSymbol,
|
|
107
|
+
type: Vatsense::CreateInvoice::Type::OrSymbol,
|
|
108
|
+
zero_rated: T::Boolean,
|
|
109
|
+
request_options: Vatsense::RequestOptions::OrHash
|
|
110
|
+
).returns(Vatsense::InvoiceResponse)
|
|
111
|
+
end
|
|
112
|
+
def update(
|
|
113
|
+
# The unique identifier of the invoice.
|
|
114
|
+
invoice_id,
|
|
115
|
+
business:,
|
|
116
|
+
# The 3-character currency code the invoice is billed in.
|
|
117
|
+
currency_code:,
|
|
118
|
+
# The date the invoice was issued (YYYY-MM-DD or YYYY-MM-DD HH:MM:SS).
|
|
119
|
+
date:,
|
|
120
|
+
items:,
|
|
121
|
+
# The tax point or "time of supply" (YYYY-MM-DD or YYYY-MM-DD HH:MM:SS).
|
|
122
|
+
tax_point:,
|
|
123
|
+
conversion: nil,
|
|
124
|
+
customer: nil,
|
|
125
|
+
# Whether the invoice is subject to VAT.
|
|
126
|
+
has_vat: nil,
|
|
127
|
+
# A unique invoice number. If not provided, defaults to an auto-incremented
|
|
128
|
+
# number.
|
|
129
|
+
invoice_number: nil,
|
|
130
|
+
# Whether the invoice is a copy of a primary invoice.
|
|
131
|
+
is_copy: nil,
|
|
132
|
+
# Whether the invoice is zero-rated due to reverse charge.
|
|
133
|
+
is_reverse_charge: nil,
|
|
134
|
+
# Any additional notes for the invoice.
|
|
135
|
+
notes: nil,
|
|
136
|
+
# Pad the auto-generated invoice number with leading zeros to this length.
|
|
137
|
+
pad_invoice_number: nil,
|
|
138
|
+
# A serial prepended to the auto-generated invoice number. Each unique serial has
|
|
139
|
+
# its own auto-increment range.
|
|
140
|
+
serial: nil,
|
|
141
|
+
# Whether item prices include or exclude VAT.
|
|
142
|
+
tax_type: nil,
|
|
143
|
+
# The type of invoice.
|
|
144
|
+
type: nil,
|
|
145
|
+
# Whether the invoice has been zero-rated.
|
|
146
|
+
zero_rated: nil,
|
|
147
|
+
request_options: {}
|
|
148
|
+
)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Retrieve a paginated list of all invoices.
|
|
152
|
+
sig do
|
|
153
|
+
params(
|
|
154
|
+
limit: Integer,
|
|
155
|
+
offset: Integer,
|
|
156
|
+
search: String,
|
|
157
|
+
request_options: Vatsense::RequestOptions::OrHash
|
|
158
|
+
).returns(Vatsense::Models::InvoiceListResponse)
|
|
159
|
+
end
|
|
160
|
+
def list(
|
|
161
|
+
# Number of invoices to return (default 10, max 100).
|
|
162
|
+
limit: nil,
|
|
163
|
+
# Number of invoices to skip (default 0).
|
|
164
|
+
offset: nil,
|
|
165
|
+
# Search query to filter invoices.
|
|
166
|
+
search: nil,
|
|
167
|
+
request_options: {}
|
|
168
|
+
)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Permanently delete an invoice.
|
|
172
|
+
sig do
|
|
173
|
+
params(
|
|
174
|
+
invoice_id: String,
|
|
175
|
+
request_options: Vatsense::RequestOptions::OrHash
|
|
176
|
+
).returns(Vatsense::Models::InvoiceDeleteResponse)
|
|
177
|
+
end
|
|
178
|
+
def delete(
|
|
179
|
+
# The unique identifier of the invoice.
|
|
180
|
+
invoice_id,
|
|
181
|
+
request_options: {}
|
|
182
|
+
)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# @api private
|
|
186
|
+
sig { params(client: Vatsense::Client).returns(T.attached_class) }
|
|
187
|
+
def self.new(client:)
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module Vatsense
|
|
4
|
+
module Resources
|
|
5
|
+
# VAT/GST rate lookups for countries worldwide
|
|
6
|
+
class Rates
|
|
7
|
+
# Returns a list of VAT/GST rates for all countries, sorted alphabetically by
|
|
8
|
+
# country code. Each rate is returned as a rate object containing the standard
|
|
9
|
+
# rate and any other applicable rates.
|
|
10
|
+
#
|
|
11
|
+
# You can optionally filter by country code, IP address, or EU membership.
|
|
12
|
+
sig do
|
|
13
|
+
params(
|
|
14
|
+
country_code: String,
|
|
15
|
+
eu: T::Boolean,
|
|
16
|
+
ip_address: String,
|
|
17
|
+
period: Time,
|
|
18
|
+
request_options: Vatsense::RequestOptions::OrHash
|
|
19
|
+
).returns(Vatsense::Models::RateListResponse)
|
|
20
|
+
end
|
|
21
|
+
def list(
|
|
22
|
+
# A 2-character ISO 3166-1 alpha-2 country code (e.g. "GB", "FR").
|
|
23
|
+
country_code: nil,
|
|
24
|
+
# Filter results by EU membership. Use 1 for EU countries only, 0 for non-EU only.
|
|
25
|
+
eu: nil,
|
|
26
|
+
# An IPv4 or IPv6 address. If provided, the country will be determined from the IP
|
|
27
|
+
# address.
|
|
28
|
+
ip_address: nil,
|
|
29
|
+
# A historical date to retrieve rates for (format "YYYY-MM-DD HH:MM:SS"). Must be
|
|
30
|
+
# a past date.
|
|
31
|
+
period: nil,
|
|
32
|
+
request_options: {}
|
|
33
|
+
)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Combines the functionality of the "Find a tax rate" and "VAT price calculation"
|
|
37
|
+
# endpoints to return the particular VAT price for an applicable VAT rate.
|
|
38
|
+
# Requires both a location (country_code or ip_address) and a price to calculate.
|
|
39
|
+
sig do
|
|
40
|
+
params(
|
|
41
|
+
price: String,
|
|
42
|
+
tax_type: Vatsense::RateCalculatePriceParams::TaxType::OrSymbol,
|
|
43
|
+
country_code: String,
|
|
44
|
+
eu: T::Boolean,
|
|
45
|
+
ip_address: String,
|
|
46
|
+
province_code: String,
|
|
47
|
+
type: String,
|
|
48
|
+
request_options: Vatsense::RequestOptions::OrHash
|
|
49
|
+
).returns(Vatsense::Models::RateCalculatePriceResponse)
|
|
50
|
+
end
|
|
51
|
+
def calculate_price(
|
|
52
|
+
# The price to calculate on. Must be a string with exactly 2 decimal places (e.g.
|
|
53
|
+
# "30.00", "59.95").
|
|
54
|
+
price:,
|
|
55
|
+
# Whether the provided price is inclusive or exclusive of VAT.
|
|
56
|
+
tax_type:,
|
|
57
|
+
# A 2-character ISO 3166-1 alpha-2 country code (e.g. "GB", "FR").
|
|
58
|
+
country_code: nil,
|
|
59
|
+
# Filter results by EU membership. Use 1 for EU countries only, 0 for non-EU only.
|
|
60
|
+
eu: nil,
|
|
61
|
+
# An IPv4 or IPv6 address. If provided, the country will be determined from the IP
|
|
62
|
+
# address.
|
|
63
|
+
ip_address: nil,
|
|
64
|
+
# A 2-character province code (e.g. "NU", "NT"). If providing a province code, you
|
|
65
|
+
# must also provide the relevant country_code.
|
|
66
|
+
province_code: nil,
|
|
67
|
+
# The product type to find the applicable rate for. See the /rates/types endpoint
|
|
68
|
+
# for a full list of valid values.
|
|
69
|
+
type: nil,
|
|
70
|
+
request_options: {}
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Get detailed tax rate information for a location, including all applicable rate
|
|
75
|
+
# classes (standard, reduced, zero, etc.).
|
|
76
|
+
sig do
|
|
77
|
+
params(
|
|
78
|
+
country_code: String,
|
|
79
|
+
eu: T::Boolean,
|
|
80
|
+
ip_address: String,
|
|
81
|
+
period: Time,
|
|
82
|
+
province_code: String,
|
|
83
|
+
type: String,
|
|
84
|
+
request_options: Vatsense::RequestOptions::OrHash
|
|
85
|
+
).returns(Vatsense::FindRate)
|
|
86
|
+
end
|
|
87
|
+
def details(
|
|
88
|
+
# A 2-character ISO 3166-1 alpha-2 country code (e.g. "GB", "FR").
|
|
89
|
+
country_code: nil,
|
|
90
|
+
# Filter results by EU membership. Use 1 for EU countries only, 0 for non-EU only.
|
|
91
|
+
eu: nil,
|
|
92
|
+
# An IPv4 or IPv6 address. If provided, the country will be determined from the IP
|
|
93
|
+
# address.
|
|
94
|
+
ip_address: nil,
|
|
95
|
+
# A historical date to retrieve rates for (format "YYYY-MM-DD HH:MM:SS"). Must be
|
|
96
|
+
# a past date.
|
|
97
|
+
period: nil,
|
|
98
|
+
# A 2-character province code (e.g. "NU", "NT"). If providing a province code, you
|
|
99
|
+
# must also provide the relevant country_code.
|
|
100
|
+
province_code: nil,
|
|
101
|
+
# The product type to find the applicable rate for. See the /rates/types endpoint
|
|
102
|
+
# for a full list of valid values.
|
|
103
|
+
type: nil,
|
|
104
|
+
request_options: {}
|
|
105
|
+
)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# A handy endpoint for finding a rate that applies to a particular country and
|
|
109
|
+
# optional product type, based on country code or IP address.
|
|
110
|
+
#
|
|
111
|
+
# If no type is provided, or no specific rate is applied to the given type, then
|
|
112
|
+
# the standard rate will be returned if the country is subject to tax.
|
|
113
|
+
#
|
|
114
|
+
# If the country is not subject to VAT/GST then an error response will be
|
|
115
|
+
# returned, indicating no tax applies.
|
|
116
|
+
sig do
|
|
117
|
+
params(
|
|
118
|
+
country_code: String,
|
|
119
|
+
eu: T::Boolean,
|
|
120
|
+
ip_address: String,
|
|
121
|
+
period: Time,
|
|
122
|
+
province_code: String,
|
|
123
|
+
type: String,
|
|
124
|
+
request_options: Vatsense::RequestOptions::OrHash
|
|
125
|
+
).returns(Vatsense::FindRate)
|
|
126
|
+
end
|
|
127
|
+
def find(
|
|
128
|
+
# A 2-character ISO 3166-1 alpha-2 country code (e.g. "GB", "FR").
|
|
129
|
+
country_code: nil,
|
|
130
|
+
# Filter results by EU membership. Use 1 for EU countries only, 0 for non-EU only.
|
|
131
|
+
eu: nil,
|
|
132
|
+
# An IPv4 or IPv6 address. If provided, the country will be determined from the IP
|
|
133
|
+
# address.
|
|
134
|
+
ip_address: nil,
|
|
135
|
+
# A historical date to retrieve rates for (format "YYYY-MM-DD HH:MM:SS"). Must be
|
|
136
|
+
# a past date.
|
|
137
|
+
period: nil,
|
|
138
|
+
# A 2-character province code (e.g. "NU", "NT"). If providing a province code, you
|
|
139
|
+
# must also provide the relevant country_code.
|
|
140
|
+
province_code: nil,
|
|
141
|
+
# The product type to find the applicable rate for. See the /rates/types endpoint
|
|
142
|
+
# for a full list of valid values.
|
|
143
|
+
type: nil,
|
|
144
|
+
request_options: {}
|
|
145
|
+
)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Returns a list of all available product types that can be used to filter tax
|
|
149
|
+
# rates.
|
|
150
|
+
sig do
|
|
151
|
+
params(request_options: Vatsense::RequestOptions::OrHash).returns(
|
|
152
|
+
Vatsense::Models::RateListTypesResponse
|
|
153
|
+
)
|
|
154
|
+
end
|
|
155
|
+
def list_types(request_options: {})
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# @api private
|
|
159
|
+
sig { params(client: Vatsense::Client).returns(T.attached_class) }
|
|
160
|
+
def self.new(client:)
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module Vatsense
|
|
4
|
+
module Resources
|
|
5
|
+
# Temporary sandbox API keys for testing
|
|
6
|
+
class Sandbox
|
|
7
|
+
# Generate a temporary sandbox API key for testing. Sandbox keys have limited
|
|
8
|
+
# request allowances and restricted endpoint access (no invoice endpoints). Rate
|
|
9
|
+
# limited to 1 key per IP address per 6 hours.
|
|
10
|
+
sig do
|
|
11
|
+
params(request_options: Vatsense::RequestOptions::OrHash).returns(
|
|
12
|
+
Vatsense::Models::SandboxGenerateKeyResponse
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
def generate_key(request_options: {})
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# @api private
|
|
19
|
+
sig { params(client: Vatsense::Client).returns(T.attached_class) }
|
|
20
|
+
def self.new(client:)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module Vatsense
|
|
4
|
+
module Resources
|
|
5
|
+
# API usage statistics
|
|
6
|
+
class Usage
|
|
7
|
+
# Check your used and remaining API requests.
|
|
8
|
+
sig do
|
|
9
|
+
params(request_options: Vatsense::RequestOptions::OrHash).returns(
|
|
10
|
+
Vatsense::Models::UsageRetrieveResponse
|
|
11
|
+
)
|
|
12
|
+
end
|
|
13
|
+
def retrieve(request_options: {})
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @api private
|
|
17
|
+
sig { params(client: Vatsense::Client).returns(T.attached_class) }
|
|
18
|
+
def self.new(client:)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module Vatsense
|
|
4
|
+
module Resources
|
|
5
|
+
# VAT and EORI number validation
|
|
6
|
+
class Validate
|
|
7
|
+
# Check whether a given VAT number or EORI number is valid against live government
|
|
8
|
+
# records.
|
|
9
|
+
#
|
|
10
|
+
# **VAT validation** checks against UK (HMRC), EU (VIES), Australia, Norway,
|
|
11
|
+
# Switzerland, South Africa, and Brazil records.
|
|
12
|
+
#
|
|
13
|
+
# **EORI validation** checks against UK and EU records only.
|
|
14
|
+
#
|
|
15
|
+
# If the external validation service is temporarily unavailable, the API returns a
|
|
16
|
+
# `412` error and the request does not count against your usage quota.
|
|
17
|
+
#
|
|
18
|
+
# Provide either `vat_number` or `eori_number`, but not both.
|
|
19
|
+
sig do
|
|
20
|
+
params(
|
|
21
|
+
eori_number: String,
|
|
22
|
+
requester_vat_number: String,
|
|
23
|
+
vat_number: String,
|
|
24
|
+
request_options: Vatsense::RequestOptions::OrHash
|
|
25
|
+
).returns(Vatsense::Models::ValidateCheckResponse)
|
|
26
|
+
end
|
|
27
|
+
def check(
|
|
28
|
+
# The EORI number to validate. Must include the leading 2-character country code
|
|
29
|
+
# (e.g. "GB123456789123"). UK and EU only.
|
|
30
|
+
eori_number: nil,
|
|
31
|
+
# Your own VAT number. If supplied, the response will include a unique
|
|
32
|
+
# consultation number issued by the relevant authority (VIES or HMRC). Must
|
|
33
|
+
# include the leading 2-character country code.
|
|
34
|
+
#
|
|
35
|
+
# Note: GB requester numbers only work for GB validations; EU requester numbers
|
|
36
|
+
# only work for EU validations. Cross-region is not supported.
|
|
37
|
+
requester_vat_number: nil,
|
|
38
|
+
# The VAT number to validate. Must include the leading 2-character country code
|
|
39
|
+
# (e.g. "GB288305674", "FR12345678901").
|
|
40
|
+
vat_number: nil,
|
|
41
|
+
request_options: {}
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# @api private
|
|
46
|
+
sig { params(client: Vatsense::Client).returns(T.attached_class) }
|
|
47
|
+
def self.new(client:)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module Vatsense
|
|
2
|
+
class Client < Vatsense::Internal::Transport::BaseClient
|
|
3
|
+
DEFAULT_MAX_RETRIES: 2
|
|
4
|
+
|
|
5
|
+
DEFAULT_TIMEOUT_IN_SECONDS: Float
|
|
6
|
+
|
|
7
|
+
DEFAULT_INITIAL_RETRY_DELAY: Float
|
|
8
|
+
|
|
9
|
+
DEFAULT_MAX_RETRY_DELAY: Float
|
|
10
|
+
|
|
11
|
+
attr_reader username: String
|
|
12
|
+
|
|
13
|
+
attr_reader password: String
|
|
14
|
+
|
|
15
|
+
attr_reader rates: Vatsense::Resources::Rates
|
|
16
|
+
|
|
17
|
+
attr_reader countries: Vatsense::Resources::Countries
|
|
18
|
+
|
|
19
|
+
attr_reader validate: Vatsense::Resources::Validate
|
|
20
|
+
|
|
21
|
+
attr_reader currency: Vatsense::Resources::Currency
|
|
22
|
+
|
|
23
|
+
attr_reader invoice: Vatsense::Resources::Invoice
|
|
24
|
+
|
|
25
|
+
attr_reader usage: Vatsense::Resources::Usage
|
|
26
|
+
|
|
27
|
+
attr_reader sandbox: Vatsense::Resources::Sandbox
|
|
28
|
+
|
|
29
|
+
private def auth_headers: (
|
|
30
|
+
security: { basic_auth: bool }
|
|
31
|
+
) -> ::Hash[String, String]
|
|
32
|
+
|
|
33
|
+
private def basic_auth: -> ::Hash[String, String]
|
|
34
|
+
|
|
35
|
+
def initialize: (
|
|
36
|
+
?username: String?,
|
|
37
|
+
?password: String?,
|
|
38
|
+
?base_url: String?,
|
|
39
|
+
?max_retries: Integer,
|
|
40
|
+
?timeout: Float,
|
|
41
|
+
?initial_retry_delay: Float,
|
|
42
|
+
?max_retry_delay: Float
|
|
43
|
+
) -> void
|
|
44
|
+
end
|
|
45
|
+
end
|