Skip to content

Commit

Permalink
Merge pull request #362 from FatchipRobert/MAG2-180-MultipleAppointed…
Browse files Browse the repository at this point in the history
…LeadsToMultipleInvoices

MAG2-180 - Fixes problem with multiple invoices being generated when …
  • Loading branch information
Florian Bender committed Nov 25, 2020
2 parents 150389d + 7450b72 commit bf6e450
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Observer/Transactionstatus/Appointed.php
Expand Up @@ -127,7 +127,7 @@ public function execute(Observer $observer)
}

// preauthorization-orders and advance payment should not create an invoice
if ($oOrder->getPayoneAuthmode() !== 'authorization' || $oOrder->getPayment()->getMethodInstance()->getCode() === PayoneConfig::METHOD_ADVANCE_PAYMENT){
if ($oOrder->getPayoneAuthmode() !== 'authorization' || $oOrder->getPayment()->getMethodInstance()->getCode() === PayoneConfig::METHOD_ADVANCE_PAYMENT || !$oOrder->canInvoice()){
return;
}

Expand Down
6 changes: 4 additions & 2 deletions Test/Unit/Observer/Transactionstatus/AppointedTest.php
Expand Up @@ -89,10 +89,11 @@ public function testExecute()

$order = $this->getMockBuilder(Order::class)
->disableOriginalConstructor()
->setMethods(['getPayment', 'getEmailSent', 'getPayoneAuthmode', 'save'])
->setMethods(['getPayment', 'getEmailSent', 'getPayoneAuthmode', 'save', 'canInvoice'])
->getMock();
$order->method('getPayment')->willReturn($payment);
$order->method('getPayoneAuthmode')->willReturn('authorization');
$order->method('canInvoice')->willReturn(true);

$observer = $this->getMockBuilder(Observer::class)->disableOriginalConstructor()->setMethods(['getOrder'])->getMock();
$observer->method('getOrder')->willReturn($order);
Expand All @@ -115,10 +116,11 @@ public function testExecuteException()

$order = $this->getMockBuilder(Order::class)
->disableOriginalConstructor()
->setMethods(['getPayment', 'getEmailSent', 'getPayoneAuthmode', 'save'])
->setMethods(['getPayment', 'getEmailSent', 'getPayoneAuthmode', 'save', 'canInvoice'])
->getMock();
$order->method('getPayment')->willReturn($payment);
$order->method('getPayoneAuthmode')->willReturn('authorization');
$order->method('canInvoice')->willReturn(true);

$observer = $this->getMockBuilder(Observer::class)->disableOriginalConstructor()->setMethods(['getOrder'])->getMock();
$observer->method('getOrder')->willReturn($order);
Expand Down

0 comments on commit bf6e450

Please sign in to comment.