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.
Comments
Comment #1
colanThe 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.
Comment #2
billp44ruby CreditAttribution: billp44ruby commentedThanks 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.
Comment #3
colanOkay, great. If someone else is interested in this, please reopen.
Comment #4
sylvaticus CreditAttribution: sylvaticus commentedI 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...
Comment #5
nithinkolekar CreditAttribution: nithinkolekar commentedThis 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.
Comment #6
ssoulless CreditAttribution: ssoulless commented+1 I follow this!
Comment #7
colanThis is a duplicate of #378312: Fields NOT computed in 'weight' order then.
Comment #8
8bitplateau CreditAttribution: 8bitplateau commentedYou 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.