Skip to content

Commit

Permalink
feat(Taxes) corebos.filter.TaxCalculation.isExternal and corebos.filt…
Browse files Browse the repository at this point in the history
…er.TaxCalculation.getTaxSQLColumns events for inventory module export and similar SQL manipulation
  • Loading branch information
joebordes committed May 24, 2024
1 parent c79747e commit eed586d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
30 changes: 16 additions & 14 deletions include/fields/InventoryLineField.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,22 @@ public function __construct($fieldname = '') {
'item discount amount' => InventoryLineField::$ILFieldsName['discount_amount'],
'item discount percent' => InventoryLineField::$ILFieldsName['discount_percent'],
);
$taxes = getAllTaxes('all');
foreach ($taxes as $tax) {
$fieldlabel = strtolower($tax['taxlabel']);
InventoryLineField::$ILFieldsLabel[$fieldlabel] = array(
'uitype' => 7,
'fieldtype' => 'double',
'fieldname' => $tax['taxname'],
'columnname' => $tax['taxname'],
'fieldlabel' => $tax['taxlabel'],
'tablename' => 'vtiger_inventoryproductrel',
'typeofdata'=>'N~O',
'mandatory'=>'false',
);
InventoryLineField::$ILFieldsName[$tax['taxname']] = InventoryLineField::$ILFieldsLabel[$fieldlabel];
if (!cbEventHandler::do_filter('corebos.filter.TaxCalculation.isExternal', false)) {
$taxes = getAllTaxes('all');
foreach ($taxes as $tax) {
$fieldlabel = strtolower($tax['taxlabel']);
InventoryLineField::$ILFieldsLabel[$fieldlabel] = array(
'uitype' => 7,
'fieldtype' => 'double',
'fieldname' => $tax['taxname'],
'columnname' => $tax['taxname'],
'fieldlabel' => $tax['taxlabel'],
'tablename' => 'vtiger_inventoryproductrel',
'typeofdata'=>'N~O',
'mandatory'=>'false',
);
InventoryLineField::$ILFieldsName[$tax['taxname']] = InventoryLineField::$ILFieldsLabel[$fieldlabel];
}
}
$this->fieldname = $fieldname;
}
Expand Down
4 changes: 4 additions & 0 deletions include/utils/InventoryUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,10 @@ function getInventoryFieldsForExport($tableName) {
$sql .= $fdesc['tablename'].'.'.$fdesc['columnname'].' AS "'.$fdesc['fieldlabel'].'",';
}
$sql = rtrim($sql, ',').' ';
if (cbEventHandler::do_filter('corebos.filter.TaxCalculation.isExternal', false)) {
$taxSQLColumns = cbEventHandler::do_filter('corebos.filter.TaxCalculation.getTaxSQLColumns', $sql);
$sql .= ','.$taxSQLColumns;
}
return $sql;
}

Expand Down

0 comments on commit eed586d

Please sign in to comment.