Skip to content

Conversation

@mbirman
Copy link
Contributor

@mbirman mbirman commented Mar 9, 2018

Updated:
Article - quantity_in_stock , purchase_price, stock_warning.
DocumentRow - discount, price.

As for discount, I tested setting it to 100+% and got Ogiltig rabatt. Får inte överstiga 100%. I'm unfamiliar with dry-types and haven't found a way to implement this in code. Does it support conditional types or something like that?

@ehannes
Copy link
Member

ehannes commented Mar 28, 2018

@mbirman Sorry for the long response time here.

About the changes in Article, have you tried using these negative values so you know we have the right limits now?


# 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


# 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.

# 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.
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.

# 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 😄

@ehannes
Copy link
Member

ehannes commented Jun 13, 2018

@mbirman have you had time to look at my feedback?

@ehannes ehannes force-pushed the development branch 2 times, most recently from e19d08d to bd64a28 Compare February 17, 2025 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants