Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
Merge branch 'pu/pm/SalesDocumentOrderBookedUpdatableFlds' into '2022…
Browse files Browse the repository at this point in the history
….11'

tweak(Sales Document) order booked updatedable fields amended, test

See merge request tine20/tine20!3477
  • Loading branch information
paulmhh committed Feb 16, 2023
2 parents 1b6b823 + aa89fbe commit e72c809
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
39 changes: 36 additions & 3 deletions tests/tine20/Sales/Document/JsonTest.php
Expand Up @@ -335,7 +335,7 @@ public function testOfferDocumentPosition()
$this->_instance->saveDocument_Offer($document->toArray(true));
}

public function testOfferToOrderTransition()
public function testOfferToOrderToInvoiceTransition()
{
$customer = $this->_createCustomer();
$subProduct = $this->_createProduct();
Expand Down Expand Up @@ -392,10 +392,41 @@ public function testOfferToOrderTransition()
$this->assertSame(Sales_Config::DOCUMENT_FOLLOWUP_STATUS_NONE, $updatedOffer[Sales_Model_Document_Offer::FLD_FOLLOWUP_ORDER_BOOKED_STATUS]);

$result[Sales_Model_Document_Order::FLD_ORDER_STATUS] = Sales_Model_Document_Order::STATUS_ACCEPTED;
$this->_instance->saveDocument_Order($result);
$order = $this->_instance->saveDocument_Order($result);
$updatedOffer = $this->_instance->getDocument_Offer($savedDocument['id']);
$this->assertSame(Sales_Config::DOCUMENT_FOLLOWUP_STATUS_COMPLETED, $updatedOffer[Sales_Model_Document_Offer::FLD_FOLLOWUP_ORDER_CREATED_STATUS]);
$this->assertSame(Sales_Config::DOCUMENT_FOLLOWUP_STATUS_COMPLETED, $updatedOffer[Sales_Model_Document_Offer::FLD_FOLLOWUP_ORDER_BOOKED_STATUS]);

$this->assertSame(Sales_Config::DOCUMENT_FOLLOWUP_STATUS_NONE, $order[Sales_Model_Document_Order::FLD_FOLLOWUP_INVOICE_CREATED_STATUS]);
$this->assertSame(Sales_Config::DOCUMENT_FOLLOWUP_STATUS_NONE, $order[Sales_Model_Document_Order::FLD_FOLLOWUP_INVOICE_BOOKED_STATUS]);
$this->assertSame(Sales_Config::DOCUMENT_FOLLOWUP_STATUS_NONE, $order[Sales_Model_Document_Order::FLD_FOLLOWUP_DELIVERY_CREATED_STATUS]);
$this->assertSame(Sales_Config::DOCUMENT_FOLLOWUP_STATUS_NONE, $order[Sales_Model_Document_Order::FLD_FOLLOWUP_DELIVERY_CREATED_STATUS]);
$result = $this->_instance->createFollowupDocument((new Sales_Model_Document_Transition([
Sales_Model_Document_Transition::FLD_SOURCE_DOCUMENTS => [
new Sales_Model_Document_TransitionSource([
Sales_Model_Document_TransitionSource::FLD_SOURCE_DOCUMENT_MODEL => Sales_Model_Document_Order::class,
Sales_Model_Document_TransitionSource::FLD_SOURCE_DOCUMENT => $order,
]),
],
Sales_Model_Document_Transition::FLD_TARGET_DOCUMENT_TYPE =>
Sales_Model_Document_Invoice::class,
]))->toArray());

$updatedOrder = $this->_instance->getDocument_Order($order['id']);
$this->assertSame(Sales_Config::DOCUMENT_FOLLOWUP_STATUS_COMPLETED, $updatedOrder[Sales_Model_Document_Order::FLD_FOLLOWUP_INVOICE_CREATED_STATUS]);
$this->assertSame(Sales_Config::DOCUMENT_FOLLOWUP_STATUS_NONE, $updatedOrder[Sales_Model_Document_Order::FLD_FOLLOWUP_INVOICE_BOOKED_STATUS]);
$this->assertSame(Sales_Config::DOCUMENT_FOLLOWUP_STATUS_NONE, $updatedOrder[Sales_Model_Document_Order::FLD_FOLLOWUP_DELIVERY_CREATED_STATUS]);
$this->assertSame(Sales_Config::DOCUMENT_FOLLOWUP_STATUS_NONE, $updatedOrder[Sales_Model_Document_Order::FLD_FOLLOWUP_DELIVERY_CREATED_STATUS]);

$result[Sales_Model_Document_Invoice::FLD_RECIPIENT_ID] = $customer->postal->toArray();
$result[Sales_Model_Document_Invoice::FLD_INVOICE_STATUS] = Sales_Model_Document_Invoice::STATUS_BOOKED;
$this->_instance->saveDocument_Invoice($result);

$updatedOrder = $this->_instance->getDocument_Order($order['id']);
$this->assertSame(Sales_Config::DOCUMENT_FOLLOWUP_STATUS_COMPLETED, $updatedOrder[Sales_Model_Document_Order::FLD_FOLLOWUP_INVOICE_CREATED_STATUS]);
$this->assertSame(Sales_Config::DOCUMENT_FOLLOWUP_STATUS_COMPLETED, $updatedOrder[Sales_Model_Document_Order::FLD_FOLLOWUP_INVOICE_BOOKED_STATUS]);
$this->assertSame(Sales_Config::DOCUMENT_FOLLOWUP_STATUS_NONE, $updatedOrder[Sales_Model_Document_Order::FLD_FOLLOWUP_DELIVERY_CREATED_STATUS]);
$this->assertSame(Sales_Config::DOCUMENT_FOLLOWUP_STATUS_NONE, $updatedOrder[Sales_Model_Document_Order::FLD_FOLLOWUP_DELIVERY_CREATED_STATUS]);
}

public function testOrderDocument()
Expand All @@ -409,7 +440,9 @@ public function testOrderDocument()
$offer
]
]);
$this->_instance->saveDocument_Order($order->toArray());
$order = $this->_instance->saveDocument_Order($order->toArray());

$this->assertEmpty($order[Sales_Model_Document_Order::FLD_PRECURSOR_DOCUMENTS]);
}

protected function getTrackingTestData()
Expand Down
2 changes: 2 additions & 0 deletions tine20/Sales/Controller/Document/Order.php
Expand Up @@ -51,7 +51,9 @@ protected function __construct()
Sales_Model_Document_Order::FLD_SHARED_DELIVERY,
Sales_Model_Document_Order::FLD_DELIVERY_RECIPIENT_ID,
Sales_Model_Document_Order::FLD_FOLLOWUP_DELIVERY_CREATED_STATUS,
Sales_Model_Document_Order::FLD_FOLLOWUP_DELIVERY_BOOKED_STATUS,
Sales_Model_Document_Order::FLD_FOLLOWUP_INVOICE_CREATED_STATUS,
Sales_Model_Document_Order::FLD_FOLLOWUP_INVOICE_BOOKED_STATUS,
'tags', 'attachments', 'relations',
];
$this->_bookRecordRequiredFields = [
Expand Down

0 comments on commit e72c809

Please sign in to comment.