Hello there!

I would like to know if there´s a way in Drupal (and if it´s not whare should I start looking for in php to add that functionality, as I´m not a developer and my php knowledge is pretty small) to do certain calculations.

In example:
John has 17% of the cake
David has 23% of the cake
Martha has 32% of the cake
Sam has 8% of the cake
Jim has 20% of the cake
= 100% of the cake is divided.

So if the cake´s value is $100, you could easily (with views or something) tell what aumont of money has everyone to pay for their piece of cake.

John has to pay $17
David has to pay $23
Martha has to pay $32
Sam has to pay $8
Jim has to pay $20

Is there a way to achieve this?
I´ve thoroughly searched Drupal forums and modules, and I´ve only found that there are two modules that maybe could help (I´m installing them right now): Views Calc and computed field.

But as I´m not experienced with this stuff, I would like to know your thoughts about this.

Thankls in advance for your help and ideas!!!

Rosamunda

Comments

Rosamunda’s picture

Ok, there are some variables here:
1. There´s no way to do math in Drupal
2. It´s a very silly question that does not deserve even an answer.
3. It´s a very hard question: I should create a new complicated module
4. I haven´t explained myself clear enough. My english just sucks.

1. I just don´t think so.
2. I just don´t think that´s the case either.
3. I really, really hope this isn´t the case, really. Gulp.
4. Maybe that´s it, because sometimes, my english really suck. Really.

So, let´s see if I can tell this in another way.

Let´s suppose that I´ve got a business and I have three clients. They do pay each month some online courses, and some extra stuff (ie. books, goodies, etc.).
So, January 2008 invoices could be:
= Martha
Online Course payment $200
Book XX $50

= John
Online Course payment $150
Book XX $50
Book YY $25

= Joseph
Online Course payment $100

So in Jan/08 they should pay:
Martha $250
John $225
Joseph $100

Let´s suppose that Martha doesn´t pay it all.
So:
Martha pays $200. She is in debt for $50, plus interest rate (X% per month... $3). In total she is in debt with us for $53.

In february Martha´s account would be:
Online Course payment $200
Some X goodies $15
PLUS her debt $53
PLUS X% for the new month, another $3 (it´s an example, I´m not actually calculating percentages here).

So, her total payment should be:
Online Course payment $200
goodies $15
January debt $50
January interest: $3
February interest: $3
TOTAL: $271

PLUS THAT, every studen is paying a different course aumont of money based on a percentage. All students are 100%.
Each one has a different percentage, so they pay a different aumont of money, according to their percentage.

So the calculations here are PERCENTAGES and INTEREST RATES.
I have´nt seen this on Drupal, yet.

Is there a way to do this in Drupal?
I´ve checked the ecomm module and it doesn´t suits me.
Plus that it´s far too huge for what I need. I just need this.

If there´s no way an "existent" module could do this, please point me in some direction, as to know where should I start, or what should I look for. I´m not a programmer myself, so I know this is a damn hard task, but I´m willing to give it a try!

Thanks for your patience... and help!!!!

Rosamunda
Buenos Aires

Rosamunda’s picture

Keeping alive...

Rosamunda’s picture

...?

Ian Burge’s picture

I would like to know how one might do math calculations as well, the ability would be very useful.

Rosamunda’s picture

Keeping it alive...
I really hope that someone could give some help here, or some advice of where to look for.

jfall’s picture

Here's something that might help:
http://drupal.org/project/computed_field

I have not actually worked with this module, but I'm certain it can do what you want - however, it does require a little PHP, but minimal from what I understand.

Best of luck.

styro’s picture

The simplest part of learning to program in any language is adding up a few numbers.

But the reason this question hasn't really been answered is...

You haven't actually asked us anything specific yet.

Practically every task in programming breaks down to:
1 - get some input data from somewhere
2 - do something with the data
3 - output the results to someplace

OK we've established what you want to happen in step 2 (the easy bit), but you'll need to describe steps 1 & 3 (ie where is the data coming from, what format is it in, and where do you want it to end up) before anyone can give you an actual answer that you can use on a Drupal site.

--
Anton
New to Drupal? | Troubleshooting FAQ
Example knowledge base built with Drupal

Rosamunda’s picture

Thanks for your comment Anton. I´ll try to explain those three points:

1 - get some input data from somewhere

I thought of using cck nodes. Using the example of the three students, I could use a cck node for each one of the goodies added to accounts. With this structure:
goodie´s name .......... i.e. book X
cost of it .......... i.e. $50
date of the adquisition .......... i.e. 14/02/2008
account to be added to (I don´t know wich could be better (yet): assigning it directely user or to a bio node for that user) .......... i.e. Martha
user´s payment percentage of the total goodies cost spent in that month: .......... i.e. 1.23%

2 - do something with the data

according to this example

3 - output the results to someplace

Naturally, I thought of a view.
Something like:
Period of time: January 2008
Total aumont spent this month: $1200 (lists all goodies of all students)

Student -------- Percentage ----------------- Payment
Martha------------1.23% ---------------------- $200
John --------------2.56% ---------------------- $250

and so on and on.

Another view should show the payments that students actually did, and the aumont of money that remains to pay for aech one. In each case adding more money according to a certain interest rate.

Thanks for your comments!!!

Rosamunda
Buenos Aires | Argentina
www.ligadelconsorcista.org

styro’s picture

Yep, steps 1 and 3 are the hardest because you need to invent and/or understand the mechanism you are going to use for the input and output.

I thought of using cck nodes. Using the example of the three students, I could use a cck node for each one of the goodies added to accounts. With this structure:
goodie´s name .......... i.e. book X
cost of it .......... i.e. $50
date of the adquisition .......... i.e. 14/02/2008
account to be added to (I don´t know wich could be better (yet): assigning it directely user or to a bio node for that user) .......... i.e. Martha
user´s payment percentage of the total goodies cost spent in that month: .......... i.e. 1.23%

I don't have any CCK experience, so I can't really offer much advice in that area.

Naturally, I thought of a view.
Something like:
Period of time: January 2008
Total aumont spent this month: $1200 (lists all goodies of all students)

Student -------- Percentage ----------------- Payment
Martha------------1.23% ---------------------- $200
John --------------2.56% ---------------------- $250

I also don't have much Views experience, but I don't think Views is the right approach here. Views is for generating node listings with custom criteria and/or formatting.

It sounds like you will need to do some amount of custom coding for this. The calculations bit will be very easy compared to the database stuff like figuring out how to get data out of the right CCK fields, and generating a report page etc.

While CCK and Views make it easy for non programmers to put together customised solutions, they are a bit more complex under the hood from a programmers perspective than plain old database queries if you need to go beyond what you can do with the user interface.

How much custom coding you need to do depends on how far you can get with existing modules. I would recommend if possible using one of the existing ecommerce modules (and no I don't have any experience with those either) for gathering the input data (eg step one) - they might even have reports that are close to what you want as well which could form the starting point for a new report.

Before you start coding though, you need to specify/design the details of the solution and break it down into smaller chunks. A the moment it isn't really well defined enough for actual coding.

--
Anton
New to Drupal? | Troubleshooting FAQ
Example knowledge base built with Drupal

jfall’s picture

I would, respectfully, disagree.
I do have a fair amount of experience with both CCK and Views, just not with the computed field module. This actually looks like a straight-forward application of CCK, Views, and computed Field modules - I actually doubt any custom programming or custom database queries will be required.
That said - I have not tried it, so what do I know.

Rosamunda’s picture

I can say that it was a bless to read your comment ;)
I was starting to feel a bit restless, because of all the stuff I needed to learn before even start anything.
Anyway, I´m studying PHP, I need to get things done by the end of the day, anyhow.
... But if I can do all this (ideally) with computing field, it´s a BIG progress.

Now, the thing is to get acquainted with this computed field. I´m looking to some examples that are stored in the handbooks.

Any clue is very welcome!!

Thanks!!

Rosamunda

jfall’s picture

Rosamunda’s picture

I haven´t create a single computed field that actually works. They don´t even show on the add node form...
I think there isn´t yet a dummy explanation for this module (cojmputed field).
I´m absolutely clueless on how to make it work, and I´ve started to learn some php coding, but it seems very confusing.
I´m still trying...

jfall’s picture

not sure what to suggest - programming is unfortunately not something that can be learned in just a few days.
Documentation here looks very clear and complete (by Drupal standards): http://drupal.org/node/149225
This is about as simple and clear an example as could really be expected: http://drupal.org/node/149233

The problem you are going to run into is that this module simply isn't designed for non-programmers - unless you understand PHP, its just going to look like gobldy-goo or magic... and this is probably not the best scenario for learning how to program PHP - there is a lot to understand "behind the scenes" to configure this particular module.

I'd suggest you hire someone to work with you to create the functionality you need here - hire a tutor who can help you solve the problem and show you how the solution works. Either that or change your expectations - you could waste a lot of time trying to get this working...

good luck.

brisath’s picture

Subscribing / bookmarking