-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pu/pm/SalesXlsExportDebitor' into '2024.11'
tweak(Sales) add debitor xls export See merge request tine20/tine20!4749
- Loading branch information
Showing
4 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* | ||
* @package Sales | ||
* @license http://www.gnu.org/licenses/agpl.html | ||
* @copyright Copyright (c) 2008-2022 Metaways Infosystems GmbH (http://www.metaways.de) | ||
* @copyright Copyright (c) 2008-2024 Metaways Infosystems GmbH (http://www.metaways.de) | ||
* @author Philipp Schuele <[email protected]> | ||
*/ | ||
|
||
|
@@ -40,6 +40,7 @@ public static function suite () | |
$suite->addTestSuite(Sales_Document_ControllerTest::class); | ||
$suite->addTestSuite(Sales_Document_ExportTest::class); | ||
$suite->addTestSuite(Sales_Document_JsonTest::class); | ||
$suite->addTestSuite(Sales_Export_DebitorTest::class); | ||
$suite->addTestSuite(Sales_Export_ProductTest::class); | ||
|
||
return $suite; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* Tine 2.0 - http://www.tine20.org | ||
* | ||
* @package Sales | ||
* @license http://www.gnu.org/licenses/agpl.html | ||
* @copyright Copyright (c) 2024 Metaways Infosystems GmbH (http://www.metaways.de) | ||
* @author Paul Mehrer <[email protected]> | ||
*/ | ||
|
||
/** | ||
* Sales Debitor export tests | ||
* | ||
* @package Sales | ||
* @subpackage Export | ||
*/ | ||
class Sales_Export_DebitorTest extends Sales_Document_Abstract | ||
{ | ||
public function testXlsExport() | ||
{ | ||
$customer = $this->_createCustomer(); | ||
$customer->{Sales_Model_Customer::FLD_DEBITORS}->addRecord(new Sales_Model_Debitor([ | ||
Sales_Model_Debitor::FLD_NAME => 'unittest', | ||
Sales_Model_Debitor::FLD_DIVISION_ID => Sales_Config::getInstance()->{Sales_Config::DEFAULT_DIVISION}, | ||
], true)); | ||
$customer = Sales_Controller_Customer::getInstance()->update($customer); | ||
|
||
$export = new Sales_Export_DebitorXls(Tinebase_Model_Filter_FilterGroup::getFilterForModel( | ||
Sales_Model_Debitor::class, [ | ||
['field' => Sales_Model_Debitor::FLD_CUSTOMER_ID, 'operator' => 'equals', 'value' => $customer->getId()], | ||
]), null, | ||
[ | ||
'definitionId' => Tinebase_ImportExportDefinition::getInstance()->search(Tinebase_Model_Filter_FilterGroup::getFilterForModel(Tinebase_Model_ImportExportDefinition::class, [ | ||
'model' => Sales_Model_Debitor::class, | ||
'name' => 'debitor_xls' | ||
]))->getFirstRecord()->getId() | ||
]); | ||
|
||
$xls = Tinebase_TempFile::getTempPath(); | ||
$export->generate(); | ||
$export->write($xls); | ||
|
||
$reader = PHPExcel_IOFactory::createReader('Excel2007'); | ||
$doc = $reader->load($xls); | ||
$arrayData = $doc->getActiveSheet()->rangeToArray('A1:M4'); | ||
|
||
for ($i = 2; $i < 4; ++$i) { | ||
$this->assertTrue(in_array($customer->getTitle(), $arrayData[$i])); | ||
$this->assertTrue(in_array($customer->{Sales_Model_Customer::FLD_DEBITORS}->getFirstRecord()->{Sales_Model_Debitor::FLD_DIVISION_ID}->getTitle(), $arrayData[$i]) | ||
|| in_array($customer->{Sales_Model_Customer::FLD_DEBITORS}->getLastRecord()->{Sales_Model_Debitor::FLD_DIVISION_ID}->getTitle(), $arrayData[$i])); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* Sales xls generation class | ||
* | ||
* @package Sales | ||
* @subpackage Export | ||
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3 | ||
* @author Paul Mehrer <[email protected]> | ||
* @copyright Copyright (c) 2024 Metaways Infosystems GmbH (http://www.metaways.de) | ||
* | ||
*/ | ||
|
||
/** | ||
* Sales xls generation class | ||
* | ||
* @package Sales | ||
* @subpackage Export | ||
*/ | ||
class Sales_Export_DebitorXls extends Tinebase_Export_Xls | ||
{ | ||
/** | ||
* @var string $_applicationName | ||
*/ | ||
protected $_applicationName = 'Sales'; | ||
|
||
/** | ||
* default export definition name | ||
* | ||
* @var string | ||
*/ | ||
protected $_defaultExportname = 'debitor_default_xls'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<config> | ||
<model>Sales_Model_Debitor</model> | ||
<name>debitor_xls</name> | ||
<!-- _('Excel all data') --> | ||
<label>Excel all data</label> | ||
<type>export</type> | ||
<plugin>Sales_Export_DebitorXls</plugin> | ||
<icon_class>tinebase-action-export-xls</icon_class> | ||
<favorite>true</favorite> | ||
<order>600</order> | ||
<scope>multi</scope> | ||
</config> |