Skip to content

Commit

Permalink
tweak(Sales Division/debitor) migration script create missing debitors
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmhh committed Jan 11, 2024
1 parent 780024b commit 003ea9c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tine20/Sales/Setup/Update/17.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,16 @@ public function update007()
$cat = $allCat->getById($stdCat);
}
$customer = $allCustomer->getById($did2c[$row[0]]);
$debitor = $customer->{Sales_Model_Customer::FLD_DEBITORS}
->find(Sales_Model_Debitor::FLD_DIVISION_ID, $cat->{Sales_Model_Document_Category::FLD_DIVISION_ID});
if (!($debitor = $customer->{Sales_Model_Customer::FLD_DEBITORS}
->find(Sales_Model_Debitor::FLD_DIVISION_ID, $cat->{Sales_Model_Document_Category::FLD_DIVISION_ID}))) {
$customer->{Sales_Model_Customer::FLD_DEBITORS}->addRecord($debitor = Sales_Controller_Debitor::getInstance()->create(
new Sales_Model_Debitor([
Sales_Model_Debitor::FLD_DIVISION_ID => $cat->{Sales_Model_Document_Category::FLD_DIVISION_ID},
Sales_Model_Debitor::FLD_CUSTOMER_ID => $customer->getId(),
Sales_Model_Debitor::FLD_NAME => '-',
], true)
));
}
$data = array_intersect_key($debitor->toArray(), $flds);
$data[Sales_Model_Document_Debitor::FLD_ORIGINAL_ID] = $data['id'];
unset($data['id']);
Expand Down

0 comments on commit 003ea9c

Please sign in to comment.