dodil/erp-brick-sales-order
DODIL ERP brick: sales order
src/brick_sales_order/domain/errors.py
"""The refusals a rule makes. The use cases turn them into a 409 with these words, through both doors."""
class RuleBroken(Exception):
"""A business rule said no. The message is written for the person who tried."""
class GateUnmet(RuleBroken):
"""A transition refused for readiness gates. The words are the readiness answer's own: gate, reason, fix."""
def __init__(self, gates):
self.gates = list(gates)
super().__init__("; ".join(f"{g.gate}: {g.reason} (fix: {g.fix})" for g in self.gates))
class GateAnswer(GateUnmet):
"""A refusal a CALLER acts on by rule (timesheets, SO-51): the door answers 409 {gate, reason, fix}, not only the sentence."""
class OutOfBounds(RuleBroken):
"""A rate, an amount or a quantity beyond what its column holds (NUMERIC 19,4 / 18,2, a quantity below 10^12): a 422 with the
reason through both doors, never a 500 from the engine."""