Changeset 01b538c in rattail


Ignore:
Timestamp:
07/08/2022 12:48:39 PM (7 months ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
b5688a0
Parents:
a732a76c
Message:

Add basic pricing.calculate_markup() function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rattail/pricing.py

    ra732a76c r01b538c  
    33#
    44#  Rattail -- Retail Software Framework
    5 #  Copyright © 2010-2019 Lance Edgar
     5#  Copyright © 2010-2022 Lance Edgar
    66#
    77#  This file is part of Rattail.
     
    2626
    2727from __future__ import unicode_literals, absolute_import
    28 
    29 
    30 __all__ = ['gross_margin']
    3128
    3229
     
    5956        return margin
    6057    return 100 * margin
     58
     59
     60def calculate_markup(margin):
     61    """
     62    Calculate the "markup" value corresponding to the given margin.
     63
     64    :param margin: Profit margin as decimal percentage (e.g. between
     65       0.0 and 1.0).
     66
     67    :returns: Equivalent cost markup as decimal value (e.g. 1.4).
     68    """
     69    if margin is None:
     70        return
     71    if margin == 0:
     72        return 1
     73
     74    return 1 / (1 - margin)
Note: See TracChangeset for help on using the changeset viewer.