@thecb/components 7.11.0-beta.6 → 7.11.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -46525,14 +46525,12 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
46525
46525
 
46526
46526
  var amountErrors = (_amountErrors = {}, _defineProperty(_amountErrors, required.error, "Amount is required"), _defineProperty(_amountErrors, numberGreaterThanOrEqualTo.error, "There is a minimum payment of ".concat(displayCurrency(minimum))), _defineProperty(_amountErrors, numberLessThanOrEqualTo.error, "There is a maximum payment of ".concat(displayCurrency(maximum))), _amountErrors);
46527
46527
 
46528
- var getPartialAmountFormErrors = function getPartialAmountFormErrors(maximum, itemAmount) {
46528
+ var getPartialAmountFormErrors = function getPartialAmountFormErrors(itemAmount) {
46529
46529
  var errorMessages = amountErrors;
46530
46530
 
46531
46531
  if (blockPartialPaymentOverpay) {
46532
46532
  console.log("item amount in form is", itemAmount);
46533
- var maxAmount = !maximum || itemAmount < maximum ? itemAmount : maximum;
46534
- var maxAmountError = "There is a maximum payment of ".concat(displayCurrency(maxAmount));
46535
- console.log("max amount in form is", maxAmount);
46533
+ var maxAmountError = "There is a maximum payment of ".concat(displayCurrency(itemAmount));
46536
46534
  return _objectSpread2(_objectSpread2({}, errorMessages), {}, _defineProperty({}, numberLessThanOrEqualTo.error, maxAmountError));
46537
46535
  }
46538
46536
 
@@ -46558,7 +46556,7 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
46558
46556
  field: fields[li.id],
46559
46557
  fieldActions: actions.fields[li.id],
46560
46558
  showErrors: showErrors,
46561
- errorMessages: getPartialAmountFormErrors(maximum, li.amount),
46559
+ errorMessages: getPartialAmountFormErrors(li.amount),
46562
46560
  style: {
46563
46561
  textAlign: "right"
46564
46562
  },
@@ -46578,15 +46576,6 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
46578
46576
  var createPartialAmountFormState = function createPartialAmountFormState(lineItems, maximum) {
46579
46577
  var minimum = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
46580
46578
  var blockPartialPaymentOverpay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
46581
-
46582
- var getPaymentMax = function getPaymentMax(maximum, itemAmount) {
46583
- if (blockPartialPaymentOverpay) {
46584
- return !maximum || itemAmount < maximum ? itemAmount : maximum;
46585
- }
46586
-
46587
- return maximum;
46588
- };
46589
-
46590
46579
  var formConfig = lineItems.reduce(function (acc, item) {
46591
46580
  console.log("maximum is", maximum);
46592
46581
  console.log("item amount is", item.amount);
@@ -46597,14 +46586,18 @@ var createPartialAmountFormState = function createPartialAmountFormState(lineIte
46597
46586
  return [].concat(_toConsumableArray(acc), [curr.id]);
46598
46587
  }, []))];
46599
46588
 
46600
- if (!!maximum || blockPartialPaymentOverpay) {
46601
- validators.push(validateSum(numberLessThanOrEqualTo(getPaymentMax(maximum, item.amount)), lineItems.filter(function (lineItem) {
46589
+ if (!!maximum) {
46590
+ validators.push(validateSum(numberLessThanOrEqualTo(maximum), lineItems.filter(function (lineItem) {
46602
46591
  return lineItem != item;
46603
46592
  }).reduce(function (acc, curr) {
46604
46593
  return [].concat(_toConsumableArray(acc), [curr.id]);
46605
46594
  }, [])));
46606
46595
  }
46607
46596
 
46597
+ if (blockPartialPaymentOverpay) {
46598
+ validators.push(numberLessThanOrEqualTo(item.amount));
46599
+ }
46600
+
46608
46601
  return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, item.id, {
46609
46602
  validators: validators,
46610
46603
  constraints: [onlyNaturals()],