Skip to content

supplier minimum order quantity: change sum from gros to net for decision if minimum is reached #1296

Description

@mjavurek

The end action auto_close_and_send_min_quantity for orders uses currently the gross value of the order sum to compare it with the minimum order quantity of the supplier:

send_to_supplier!(created_by) if sum >= supplier.min_order_quantity.to_r

We have a supplier in our foodcoop with mainly articles with deposits and a minimum order quantity. This minimum order quantity is defined by the supplier without deposit, but sum without argument calculates the gross sum including the deposit:

def sum(type = :gross)
total = 0
if %i[net gross fc].include?(type)
for oa in order_articles.ordered.includes(:article_version)
quantity = oa.units * oa.article_version.convert_quantity(1, oa.article_version.supplier_order_unit,
oa.article_version.group_order_unit)
case type
when :net
total += quantity * oa.article_version.group_order_price
when :gross
total += quantity * oa.article_version.gross_group_order_price

def gross_price
add_percent(price + deposit, tax)
end

I would like to change the sum to sum(:net) so that the deposit is excluded. I think it is a small drawback to set a net minimum order quantity if the article prices are without tax in comparison to not being able to use the feature because of the deposit.

An alternative without this small drawback would be to add a "gross price without deposit" sum and use it for the order-send-to-supplier decision.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions