CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Adding a Tax Field
Pages: [1]

Author Topic: Adding a Tax Field  (Read 1484 times)

awasson

  • I post frequently
  • ***
  • Posts: 230
  • Karma: 7
  • Living in a world of Drupal / CiviCRM
    • My Company: Luna Design
  • CiviCRM version: Latest
  • CMS version: Drupal 6/7/8
  • MySQL version: 5.x
  • PHP version: 5.3.x
Adding a Tax Field
July 19, 2010, 04:55:03 pm
Hello All.
I have a few months of experience with civiCRM and several years with Drupal. I have seen several postings about incorporating a tax field into their civiCRM installations however I haven't seen any solutions so, I'm going to work on one and publish whatever I manage to produce in this thread. First I could do with some direction from those in the know. With regard to approach... Would the recommended course of action be to create a Drupal Module or create a custom template?

I've started moving in the direction of a module but it just occurred to me that I can probably create a custom field and then add it to the template.

I'm not sure who else can benefit from this but it seems that those from Canada and perhaps the UK & Australia could use it.

Thanks,
Andrew  

EDIT: So a little further on the subject, I've kind of mapped out what I think will work well but I'm open to comments and suggestions.

1) I've made a copy of MembershipBlock.tpl and added it to my custom template folder which coincides with the path that I assigned in Administer -> Configure -> Global Settings -> Directories  I edited the template between lines 79 & 90 where the template creates a table column of "Membership Costs" I added some text indicating that there would be tax applied.

Code: [Select]
<td style="width: auto;">
                <span class="bold">{$row.name} &nbsp;
                {if ($membershipBlock.display_min_fee AND $context EQ "makeContribution") AND $row.minimum_fee GT 0 }
                    {if $is_separate_payment OR ! $form.amount.label}
                        - {$row.minimum_fee|crmMoney}
                    {else}
                        {ts 1=$row.minimum_fee|crmMoney}(contribute at least %1 to be eligible for this membership){/ts}
                    {/if}
                {/if}
               
                </span> Insert Text For Tax Statement Here!<br />
                {$row.description} &nbsp;                     
           </td>

All this does of course is update the presentation adding " Insert Text For Tax Statement Here!" after the amount shown for each membership category.

2) Now that I've added a statement to each membership item, I need to do something to effect the invoice. In this case I want to add a field that is a percentage of the value of the membership and then add the two values together so that we have a grand total.  I suppose that will have to happen on the confirmation page before it gets sent for processing. I think it may have to be done with a module invoking one of civiCRM's hooks but I'm not sure which one will actually do the job. The candidates I'm looking at are:
hook_civicrm_buildForm()
hook_civicrm_buildAmount()

Tips and suggestions are welcome!
« Last Edit: July 19, 2010, 08:32:41 pm by awasson »
My CiviCRM Extension Workshop: https://github.com/awasson

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Adding a Tax Field
July 19, 2010, 10:34:19 pm
Have you consider using view only Custom Data ( may be of type contribute )?
So using your module you will do tax calculation etc. and store the values in this custom field. Does this make sense to you?

HTh

Kurund
Found this reply helpful? Support CiviCRM

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Adding a Tax Field
July 20, 2010, 01:42:08 am

i think you might need to do both. Create a view only field(s) that the postProcess hook populates. use the buildAmount hook to increase the amount based on the "tax code" pertinent to that location.

THis is a bit similar to the discount hook (check the module multicurrency: http://svn.civicrm.org/tools/trunk/drupal/modules/multicurrency/)

your discount is basically an addition to the amount. You might want to store the percentage etc in a separate table (option group?)

ping us on IRC and we can help sort out details. definitely a needed feature

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

awasson

  • I post frequently
  • ***
  • Posts: 230
  • Karma: 7
  • Living in a world of Drupal / CiviCRM
    • My Company: Luna Design
  • CiviCRM version: Latest
  • CMS version: Drupal 6/7/8
  • MySQL version: 5.x
  • PHP version: 5.3.x
Re: Adding a Tax Field
July 21, 2010, 12:11:14 am
Thanks for the replies and help!
I got a bit tied up today but I'll look you up on IRC tomorrow.

Cheers,
Andrew
My CiviCRM Extension Workshop: https://github.com/awasson

awasson

  • I post frequently
  • ***
  • Posts: 230
  • Karma: 7
  • Living in a world of Drupal / CiviCRM
    • My Company: Luna Design
  • CiviCRM version: Latest
  • CMS version: Drupal 6/7/8
  • MySQL version: 5.x
  • PHP version: 5.3.x
Re: Adding a Tax Field
October 19, 2011, 04:42:27 pm
I know this is an old thread but it has some good keywords and has been looked at nearly 500 times so... I thought I would put a link to our recipe for adding a tax field to civiCRM. I worked on this with a colleague and it does work but it isn't a simple plug-n-play solution and it's a bit of a pain to maintain when updating civiCRM.

Link to Drupal civiCRM Group posting: http://groups.drupal.org/node/182444

If anyone wants to help roll up these changes into a module, please let me know. I think it would be quite handy to be able to plug this into civi as a module.   
My CiviCRM Extension Workshop: https://github.com/awasson

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Adding a Tax Field

This forum was archived on 2017-11-26.