File tree 2 files changed +34
-1
lines changed
2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -618,7 +618,12 @@ public function canCreditmemo()
618
618
* for this we have additional diapason for 0
619
619
* TotalPaid - contains amount, that were not rounded.
620
620
*/
621
- if (abs ($ this ->priceCurrency ->round ($ this ->getTotalPaid ()) - $ this ->getTotalRefunded ()) < .0001 ) {
621
+ $ totalRefunded = $ this ->priceCurrency ->round ($ this ->getTotalPaid ()) - $ this ->getTotalRefunded ();
622
+ if (abs ($ totalRefunded ) < .0001 ) {
623
+ return false ;
624
+ }
625
+ // Case when Adjustment Fee (adjustment_negative) has been used for first creditmemo
626
+ if (abs ($ totalRefunded - $ this ->getAdjustmentNegative ()) < .0001 ) {
622
627
return false ;
623
628
}
624
629
Original file line number Diff line number Diff line change @@ -357,6 +357,34 @@ public function testCanNotCreditMemoWithTotalNull()
357
357
$ this ->assertFalse ($ this ->order ->canCreditmemo ());
358
358
}
359
359
360
+ public function testCanNotCreditMemoWithAdjustmentNegative ()
361
+ {
362
+ $ totalPaid = 100 ;
363
+ $ adjustmentNegative = 10 ;
364
+ $ totalRefunded = 90 ;
365
+
366
+ $ this ->order ->setTotalPaid ($ totalPaid );
367
+ $ this ->order ->setTotalRefunded ($ totalRefunded );
368
+ $ this ->order ->setAdjustmentNegative ($ adjustmentNegative );
369
+ $ this ->priceCurrency ->expects ($ this ->once ())->method ('round ' )->with ($ totalPaid )->willReturnArgument (0 );
370
+
371
+ $ this ->assertFalse ($ this ->order ->canCreditmemo ());
372
+ }
373
+
374
+ public function testCanCreditMemoWithAdjustmentNegativeLowerThanTotalPaid ()
375
+ {
376
+ $ totalPaid = 100 ;
377
+ $ adjustmentNegative = 9 ;
378
+ $ totalRefunded = 90 ;
379
+
380
+ $ this ->order ->setTotalPaid ($ totalPaid );
381
+ $ this ->order ->setTotalRefunded ($ totalRefunded );
382
+ $ this ->order ->setAdjustmentNegative ($ adjustmentNegative );
383
+ $ this ->priceCurrency ->expects ($ this ->once ())->method ('round ' )->with ($ totalPaid )->willReturnArgument (0 );
384
+
385
+ $ this ->assertTrue ($ this ->order ->canCreditmemo ());
386
+ }
387
+
360
388
/**
361
389
* @param string $state
362
390
*
You can’t perform that action at this time.
0 commit comments