I'm trying to use "Computed Fields" for a content type "Loan". There are a number of charges associated with a loan that are categorized and summed, which then roll up to a "Total Charges" field. As an example, you have:

Items Payable (6)
     Application Fee (2)
     Appraisal Fee (3)

Title Charges (7)
     Title Insurance (4)
     Title Examination (5)

Total Charges (8)

As part of the implementation, "Items Payable"=("Application Fee" + "Appraisal Fee"), "Title Charges"=("Title Insurance" + "Title Examination") and "Total Charges"=("Items Payable" + "Title Charges"). Items Payable, Title Charges and Total Charges are all field type "Computed", while the others are "Float".

When I save the content type and go to add "Loan" content, I input "Application Fee", "Appraisal Fee", "Title Insurance" and "Title Examination". When I save the content, Items Payable and Title Charges are summed correctly, but "Total Charges" remains at "0". In order to get Total Charges computed, I have to go back and re-save the content a second time. After that pass, the numbers are all calculated correctly.

As I understand, in order to get the correct order of calculations, I need to define the 'order of calculations' using the "Weight" column. I've gone back and done so using the numbers in the parentheses, but keep getting the same result.


colan’s picture

Title:Computed Field, Order of Calculations using Weight» Have Computed Field order calculations by weight
Category:bug» feature

The weight is for the order of display. Computed Field doesn't do anything with it. It's not an unreasonable feature request, however. If someone can provide a patch, I'll happily entertain it.

billp44ruby’s picture

Thanks for letting me know. I had read elsewhere (in a blog or something) that weight did play a role. Obviously that was incorrect. I do think it would be helpful to have some sort of mechanism to designate the order of calculations. FWIW, after looking at other ways to perform this task, I think I can do most of what I want to do with the Rules module.

colan’s picture

Status:Active» Closed (works as designed)

Okay, great. If someone else is interested in this, please reopen.

sylvaticus’s picture

Priority:Normal» Minor
Status:Closed (works as designed)» Active

I am :-)

I have two computed fields: A depends on standard CCK fields and B depends on standard CCK fields and A.

How can I be sure than A is computed before B?

Sorry, no PHP skills for a patch...

nithinkolekar’s picture

This patch is provided by Martijn Houtman.It has some limitation on getting weight info of computed field if it is inside field collection.This feature should be provided in core.

ssoulless’s picture

+1 I follow this!

colan’s picture

Issue summary:View changes
Status:Active» Closed (duplicate)
digitisation’s picture

You can just recalculate you fields.
For example, if A and B are number inputs and C and D are computed where :

C = A + B
D = C * 2

but the order of the fields being computed is wrong you can just D isn't calculated the first save, you can simply do :

C = A + B
D = (A + B) *2

That way both C and D are computed correctly and at the same time.