Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • CiviCRM Core CiviCRM Core
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Graph
    • Compare revisions
  • Issues 1k
    • Issues 1k
    • List
    • Boards
    • Service Desk
    • Milestones
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Model experiments
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • DevelopmentDevelopment
  • CiviCRM CoreCiviCRM Core
  • Issues
  • #2796

Regression? No way to change the tax rate and tax amount using buildamount hook

In 5.35.x LineItem create api allowed one to set a different tax_amount in api params for a financial type that had tax enabled. The tax amount could then be calculated programatically based on region, location etc instead of using the config specified in the UI.

civicrm_api3('LineItem', 'create', [
  'entity_id' => 284,
  'qty' => 1,
  'unit_price' => 100,
  'line_total' => 100,
  'entity_table' => "civicrm_contribution",
  'tax_amount' => 20,
  'financial_type_id' => "Donation",
  'price_field_id' => "contribution_amount",
  'price_field_value_id' => "single",
]);

Another way of calculating tax on online forms was using the buildamount hook

function advanceinvoicing_civicrm_buildAmount($pageType, &$form, &$amount) {
  $amount[$priceFieldId]['options'][$priceFieldValueId]['tax_rate'] = 10;
  $amount[$priceFieldId]['options'][$priceFieldValueId]['tax_amount'] = 0.1;
}

A recent change to the line item create function has stopped allowing tax amount to be set programmatically.

Is this intentional? Is there any way to support different tax rate for single financial type?

Edited Sep 02, 2021 by JoeMurray
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking