isDiscountAmountValid function

bool isDiscountAmountValid(
  1. MatexVatCalculatorState state
)

Implementation

bool isDiscountAmountValid(MatexVatCalculatorState state) {
  if (state.priceBeforeVat != null) {
    return state.discountAmount == null ||
        (state.discountAmount! < state.priceBeforeVat! &&
            state.discountAmount! >= 0);
  } else if (state.priceAfterVat != null) {
    return state.discountAmount == null ||
        (state.discountAmount! < state.priceAfterVat! &&
            state.discountAmount! >= 0);
  }

  return false;
}