function pm_taxation in Drupal PM (Project Management) 7
Calculates taxation for Project Management nodes
2 calls to pm_taxation()
- _pmexpense_beforesave in pmexpense/
pmexpense.module - Prepare expense date before saving it to the database.
- _pminvoice_beforesave in pminvoice/
pminvoice.module - Prepares pminvoice for saving.
File
- ./
pm.module, line 641 - Main module file for the Project Management module.
Code
function pm_taxation(&$node) {
// If values are not set, then use default values
if (!isset($node->tax1app)) {
$node->tax1app = variable_get('pm_tax1_app', 'none');
}
if (!isset($node->tax1percent)) {
$node->tax1percent = variable_get('pm_tax1_percent', '20');
}
if (!isset($node->tax2app)) {
$node->tax2app = variable_get('pm_tax2_app', 'none');
}
if (!isset($node->tax2percent)) {
$node->tax2percent = variable_get('pm_tax2_percent', '20');
}
switch ($node->tax1app) {
case 0:
$node->tax1 = 0;
break;
case 1:
$node->tax1 = $node->amount * $node->tax1percent / 100;
break;
default:
// ERROR
drupal_set_message(t('Error during tax calculations (Project Management module)'), 'error');
}
$node->subtotal = $node->amount + $node->tax1;
switch ($node->tax2app) {
case 0:
$node->tax2 = 0;
break;
case 1:
$node->tax2 = $node->amount * $node->tax2percent / 100;
break;
case 2:
$node->tax2 = $node->subtotal * $node->tax2percent / 100;
break;
default:
// ERROR
drupal_set_message(t('Error during tax calculations (Project Management module)'), 'error');
}
$node->total = $node->subtotal + $node->tax2;
}