I have tried the latest version and reinstalled with this patch and I am experiencing the same issue:

The entity that has the entityreference_calc field is updated with the previous value of the referencing entity's value. For instance, each time I change one of the values that should be used for calculating the sum, the sum shown in the _calc field is changed by the previous value. To make it correct, I must edit and save the referenced entity node that I had just updated or the node with the _calc field.

Let's say:
Content A
Estimate: $5

Content B
Estimate: $3

Content C (the entityreference_calc field sums the related content in A & B)
Estimate: $8 (3+5)

Now, I change Content A's estimate to $6 and refresh Content C. No change.
I edit Content A's estimate to $20 and refresh Content C and the sum changes by $6.

Edit again and it will change by the previous value of $20, etc. It is like it is using the value before the content is saved?

Comments

frjo’s picture

I run this in production for a client and I just tested it in my local dev environment. I can't replicate your problem. For me the calculation is updated as it should.

Do you by any chance use the entitycache module?

I use it routinely but found that it clashed with entityreference_calc (and entityreference_count). I have added information on the project page about this now.

Mr Richards’s picture

I am not using entitycahche module. I have uninstalled the patched version mentioned above and reinstalled the current dev version available.

I have made some changes and it is working now! (Sort of)

Changed Line 458 within the module file from this:
function entityreference_calc_references_update($entity_type, $entity, $delay = FALSE)

to this (changed false to true):
function entityreference_calc_references_update($entity_type, $entity, $delay = TRUE)

Now, if I can get the formatter to work correctly and have the field display when viewing the node, I will be good. The totals show up in a views table, just not on the page. I assured the display was setup properly and also applied the changes seen in this patch without success.

The patched version of this module that I mentioned in my original post did display the value when viewing the node so I will try to compare the two to see where the issue lies.

Should we close this issue and start another if I cannot resolve?

frjo’s picture

The issue #2105435: Field is not showing up in entity view page is not for this module but for "Entity Reference Count". (This module is heavily based on that module.)

Mr Richards’s picture

I apologize for not mentioning that I did not apply the patch through GIT or anything directly. I did a manual update by hand. I just reviewed and replaced the code within this module in the same manner in which that patch was applied to the Count module. Basically it just added "formatter" to 4 lines.

Mr Richards’s picture

Status: Active » Closed (fixed)

Is working as desired now. I had already cleared caches and ran chron. Changed format on field's html markup and then back to sitewide default and all is well. Thanks for everything.