Changed item validation
@@ -98,7 +98,7 @@ public class Item implements Serializable, Parcelable {
}
public static boolean areItemsValid(@NonNull final Collection<Item> items) {
- return !items.isEmpty() && isEachItemValid(items);
+ return !items.isEmpty() && isEachItemValid(items) && BigDecimal.ZERO.compareTo(getTotalAmountWith(items)) < 0;
}
private static boolean isEachItemValid(@NonNull final Iterable<Item> items) {
@@ -110,8 +110,7 @@ public class Item implements Serializable, Parcelable {
}
private boolean isItemValid() {
- return BigDecimal.ZERO.compareTo(getUnitPrice()) < 0
- && getQuantity() > 0;
+ return getQuantity() > 0;
}
public static BigDecimal getTotalAmountWith(@NonNull final Iterable<Item> items) {
@@ -175,9 +174,8 @@ public class Item implements Serializable, Parcelable {
/* default */ @Nullable String pictureUrl;
/**
- * Builder for item construction.
- * It should be used when checkout initialize without a preference id and
- * it is initialize with a preference created programmatically.
+ * Builder for item construction. It should be used when checkout initialize without a preference id and it is
+ * initialize with a preference created programmatically.
*
* @param title item title
* @param quantity item quantity
@@ -191,8 +189,8 @@ public class Item implements Serializable, Parcelable {
}
/**
- * Item identification is an optional value.
- * You could use this value when you want to send an item identification to the backend.
+ * Item identification is an optional value. You could use this value when you want to send an item
+ * identification to the backend.
*
* @param id item identification.
* @return builder
@@ -203,8 +201,8 @@ public class Item implements Serializable, Parcelable {
}
/**
- * You can add an item description with more information.
- * Item description will be shown along the payment process.
+ * You can add an item description with more information. Item description will be shown along the payment
+ * process.
*
* @param description item description.
* @return builder
@@ -215,8 +213,8 @@ public class Item implements Serializable, Parcelable {
}
/**
- * Item category id is an optional value.
- * You could use this value when you want to send an item category identification to the backend.
+ * Item category id is an optional value. You could use this value when you want to send an item category
+ * identification to the backend.
*
* @param categoryId item category identification.
* @return builder
@@ -227,8 +225,7 @@ public class Item implements Serializable, Parcelable {
}
/**
- * This value represents the URL of the item picture.
- * Item picture will be shown along the payment process.
+ * This value represents the URL of the item picture. Item picture will be shown along the payment process.
*
* @param pictureUrl item picture URL.
* @return builder
