Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/fortnox/api/models/article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ class Article < Fortnox::API::Model::Base
attribute :purchase_account, Types::Sized::Integer[0, 9_999]

# PurchasePrice Purchase price of the article
attribute :purchase_price, Types::Sized::Float[0.0, 99_999_999_999_999.9]
attribute :purchase_price, Types::Sized::Float[-9_999_999_999_999.9, 9_999_999_999_999.9]

# QuantityInStock Quantity in stock of the article
attribute :quantity_in_stock, Types::Sized::Float[0.0, 99_999_999_999_999.9]
attribute :quantity_in_stock, Types::Sized::Float[-9_999_999_999_999.9, 9_999_999_999_999.9]

# ReservedQuantity Reserved quantity of the article
attribute :reserved_quantity, Types::Nullable::Float.is(:read_only)
Expand All @@ -98,7 +98,7 @@ class Article < Fortnox::API::Model::Base
attribute :stock_value, Types::Nullable::Float.is(:read_only)

# StockWarning When to start warning for low quantity in stock
attribute :stock_warning, Types::Sized::Float[0.0, 99_999_999_999_999.9]
attribute :stock_warning, Types::Sized::Float[-9_999_999_999_999.9, 9_999_999_999_999.9]

# SupplierName Name of the supplier
attribute :supplier_name, Types::Nullable::String.is(:read_only)
Expand Down
10 changes: 4 additions & 6 deletions lib/fortnox/api/types/document_row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ class DocumentRow < Fortnox::API::Types::Model
attribute :cost_center, Types::Nullable::String

# DeliveredQuantity Delivered quantity. 14 digits
attribute :delivered_quantity, Types::Sized::Float[-9_999_999_999_999.9, 9_999_999_999_999.9]
attribute :delivered_quantity, Types::Sized::Float[-999_999.9, 999_999.9]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure about this? The documentation says float, 14 digits...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I got when posting data to the API:

I tried the old value at first, but that was too big:

pry(main)> Fortnox::API::Repository::Order.new.save(Fortnox::API::Model::Order.new(customer_number: '1', order_rows: [Fortnox::API::Types::OrderRow.new(ordered_quantity: 1, delivered_quantity: 9999999999999, article_number: '0000')]))
Fortnox::API::RemoteServerError: Värdet får inte vara större än 999999999999 (9999999999999.00)

So the limit should apparently be 999_999_999_999.0

pry(main)> Fortnox::API::Repository::Order.new.save(Fortnox::API::Model::Order.new(customer_number: '1', order_rows: [Fortnox::API::Types::OrderRow.new(ordered_quantity: 1, delivered_quantity: 999999999999, article_number: '0000')]))
=> #<Fortnox::API::Model::Order url=nil administration_fee=0.0 administration_fee_vat=0.0 address1="" address2="" basis_tax_reduction=0.0 cancelled=false city="" comments="" contribution_percent=0.0 contribution_value=0.0 country=nil cost_center="" currency="SEK" currency_rate=1.0 currency_unit=1.0 customer_name="Old name" customer_number="1" delivery_address1="" delivery_address2="" delivery_city="" delivery_country=nil delivery_date=nil delivery_name="" delivery_zip_code="" document_number=306 email_information=#<Fortnox::API::Types::EmailInformation email_address_to="" email_address_cc=nil email_address_bcc=nil email_subject="Order {no} bifogas" email_body=" "> external_invoice_reference1="" external_invoice_reference2="" freight=0.0 freight_vat=0.0 gross=0.0 housework=false labels=[] net=0.0 not_completed=false offer_reference=0 organisation_number="860101-8735" our_reference="" phone1="" phone2="" price_list="A" print_template="oc" project="" remarks="" round_off=0.0 sent=false tax_reduction=nil terms_of_delivery="" terms_of_payment="0" total=0.0 total_vat=0.0 vat_included=false way_of_delivery="" your_order_number="" your_reference="" zip_code="" copy_remarks=false invoice_reference=0 order_date=#<Date: 2018-03-28 ((2458206j,0s,0n),+0s,2299161j)> order_rows=[#<Fortnox::API::Types::OrderRow account_number=1250 article_number="0000" contribution_percent=0.0 contribution_value=0.0 cost_center="" delivered_quantity=999999999999.0 description="Testartikel" discount=0.0 discount_type="PERCENT" housework=false housework_hours_to_report=nil housework_type=nil price=0.0 project="" total=0.0 unit="" vat=0 ordered_quantity=1.0>]>

999_999_999_999.1 is not allowed:

pry(main)> Fortnox::API::Repository::Order.new.save(Fortnox::API::Model::Order.new(customer_number: '1', order_rows: [Fortnox::API::Types::OrderRow.new(ordered_quantity: 1, delivered_quantity: 999999999999.1, article_number: '0000')]))
Fortnox::API::RemoteServerError: Värdet får inte vara större än 999999999999 (999999999999.10)

About the lower limit:

pry(main)> Fortnox::API::Repository::Order.new.save(Fortnox::API::Model::Order.new(customer_number: '1', order_rows: [Fortnox::API::Types::OrderRow.new(ordered_quantity: 1, delivered_quantity: -999999999999, article_number: '0000')]))
=> #<Fortnox::API::Model::Order url=nil administration_fee=0.0 administration_fee_vat=0.0 address1="" address2="" basis_tax_reduction=0.0 cancelled=false city="" comments="" contribution_percent=0.0 contribution_value=0.0 country=nil cost_center="" currency="SEK" currency_rate=1.0 currency_unit=1.0 customer_name="Old name" customer_number="1" delivery_address1="" delivery_address2="" delivery_city="" delivery_country=nil delivery_date=nil delivery_name="" delivery_zip_code="" document_number=308 email_information=#<Fortnox::API::Types::EmailInformation email_address_to="" email_address_cc=nil email_address_bcc=nil email_subject="Order {no} bifogas" email_body=" "> external_invoice_reference1="" external_invoice_reference2="" freight=0.0 freight_vat=0.0 gross=0.0 housework=false labels=[] net=0.0 not_completed=false offer_reference=0 organisation_number="860101-8735" our_reference="" phone1="" phone2="" price_list="A" print_template="oc" project="" remarks="" round_off=0.0 sent=false tax_reduction=nil terms_of_delivery="" terms_of_payment="0" total=0.0 total_vat=0.0 vat_included=false way_of_delivery="" your_order_number="" your_reference="" zip_code="" copy_remarks=false invoice_reference=0 order_date=#<Date: 2018-03-28 ((2458206j,0s,0n),+0s,2299161j)> order_rows=[#<Fortnox::API::Types::OrderRow account_number=1250 article_number="0000" contribution_percent=0.0 contribution_value=0.0 cost_center="" delivered_quantity=-999999999999.0 description="Testartikel" discount=0.0 discount_type="PERCENT" housework=false housework_hours_to_report=nil housework_type=nil price=0.0 project="" total=0.0 unit="" vat=0 ordered_quantity=1.0>]>

and

 pry(main)> Fortnox::API::Repository::Order.new.save(Fortnox::API::Model::Order.new(customer_number: '1', order_rows: [Fortnox::API::Types::OrderRow.new(ordered_quantity: 1, delivered_quantity: -999999999999.1, article_number: '0000')]))
Fortnox::API::RemoteServerError: Värdet får inte vara mindre än  pry(main)> Fortnox::API::Repository::Order.new.save(Fortnox::API::Model::Order.new(customer_number: '1', order_rows: [Fortnox::API::Types::OrderRow.new(ordered_quantity: 1, delivered_quantity: -999999999999.1, article_number: '0000')]))
Fortnox::API::RemoteServerError: Värdet får inte vara mindre än -999999999999 (-999999999999.10) (-999999999999.10)

So the lower limit should be -999_999_999_999.0


# Description Description Row description. 50 characters
attribute :description, Types::Sized::String[50]

# Discount amount. 12 digits (for amount) / 5 digits (for percent)
# TODO(hannes): Verify that we can send in more than 5 digits through
# the actual API for DiscountType PERCENT. This cannot be done until
# we fix issue #62...
attribute :discount, Types::Sized::Float[0.0, 99_999_999_999.9]
# TODO: Should be [-100.0, 100.0] for DiscountType PERCENT.
Copy link
Member

@ehannes ehannes Mar 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the TODO 😄

attribute :discount, Types::Sized::Float[-9_999_999_999.9, 9_999_999_999.9]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure about this as well? The maximum value is one digit less than before.


# DiscountType The type of discount used for the row.
attribute :discount_type, Types::DiscountType
Expand All @@ -45,7 +43,7 @@ class DocumentRow < Fortnox::API::Types::Model
attribute :housework_type, Types::HouseworkType

# Price Price per unit. 12 digits
attribute :price, Types::Sized::Float[0.0, 99_999_999_999.9]
attribute :price, Types::Sized::Float[-9_999_999_999.9, 9_999_999_999.9]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure about this as well? The maximum value is one digit less than before.


# Project Code of the project for the row.
attribute :project, Types::Nullable::String
Expand Down
13 changes: 3 additions & 10 deletions spec/fortnox/api/types/examples/document_row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@

it { is_expected.to have_housework_type(:housework_type, valid_hash) }

it { is_expected.to have_sized_float(:price, 0.0, 99_999_999_999.9, valid_hash) }

it do
is_expected.to have_sized_float(
:delivered_quantity,
-9_999_999_999_999.9,
9_999_999_999_999.9,
valid_hash
)
end
it { is_expected.to have_sized_float(:discount, -9_999_999_999.9, 9_999_999_999.9, valid_hash) }
it { is_expected.to have_sized_float(:price, -9_999_999_999.9, 9_999_999_999.9, valid_hash) }
it { is_expected.to have_sized_float(:delivered_quantity, -999_999.9, 999_999.9, valid_hash) }
end