3131import io .snabble .sdk .coupons .CouponType ;
3232import io .snabble .sdk .utils .Dispatch ;
3333import io .snabble .sdk .utils .GsonHolder ;
34+ import io .snabble .sdk .utils .Logger ;
3435
3536/**
3637 * Class representing the snabble shopping cart
@@ -1366,7 +1367,9 @@ public BackendCart toBackendCart() {
13661367
13671368 if (cartItem .coupon != null ) {
13681369 BackendCartItem couponItem = new BackendCartItem ();
1369- couponItem .id = cartItem .coupon .getId ();
1370+ // this item id needs to be unique per item or else the
1371+ // promotion engine on the backend gets confused
1372+ couponItem .id = UUID .randomUUID ().toString ();
13701373 couponItem .refersTo = item .id ;
13711374 couponItem .amount = 1 ;
13721375 couponItem .couponID = cartItem .coupon .getId ();
@@ -1396,9 +1399,10 @@ public BackendCart toBackendCart() {
13961399 void resolveViolations (List <Violation > violations ) {
13971400 for (Violation violation : violations ) {
13981401 for (int i = data .items .size () - 1 ; i >= 0 ; i --) {
1399- if ( data . items . get ( i ). coupon != null && data .items .get (i ). backendCouponId . equals ( violation . getRefersTo ())) {
1400- Item item = data . items . get ( i );
1402+ Item item = data .items .get (i );
1403+ if ( item . coupon != null && item . backendCouponId != null && item . backendCouponId . equals ( violation . getRefersTo ())) {
14011404 data .items .remove (item );
1405+ data .modCount ++;
14021406 boolean found = false ;
14031407 for (ViolationNotification notification : data .violationNotifications ) {
14041408 if (notification .getRefersTo ().equals (violation .getRefersTo ())) {
@@ -1418,6 +1422,7 @@ void resolveViolations(List<Violation> violations) {
14181422 }
14191423 }
14201424 notifyViolations ();
1425+ updatePrices (false );
14211426 }
14221427
14231428 /**
@@ -1427,6 +1432,8 @@ void resolveViolations(List<Violation> violations) {
14271432 */
14281433 public void removeViolationNotification (List <ViolationNotification > violations ) {
14291434 data .violationNotifications .removeAll (violations );
1435+ data .modCount ++;
1436+ notifyCartDataChanged (this );
14301437 }
14311438
14321439 @ NonNull
0 commit comments