Announcement

Collapse
No announcement yet.

Entity List View - Adding "Total" Field.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Entity List View - Adding "Total" Field.

    Hi.

    I have created a simple entity to allow me to make a list of my "food shopping items".

    I currently have this in the list view:

    Click image for larger version  Name:	image.png Views:	0 Size:	21.0 KB ID:	97657
    I would like to add another display field similar to the "top right" records count ("45") with the new field displaying the sum of the "Item Sub Total" in the "grey area above the column.

    Thanks in advance for any ideas.

    Regards
    David.

  • #2
    Would be nice! Try to do a Feature Request for it.

    Unfortunately this method​ you will need a field to have this written somehow, I create a "AccountingCalculation" (field type: varchar) field for this purpose.

    // mean comments, I add in a bit more in this post to help you since I'm not sure how good you are with formula.
    Anyway currently I do by using formula, like so:

    Code:
    //Calculate AccountingCase //comments
    $credit = entity\sumRelated('accountings', 'credit'); // create a "Variable formula call it $credit", I want to "Sum all thing in Accounting entity, with a filter "Credit"
    $debit = entity\sumRelated('accountings', 'debit'); // same as above but Debit
    accountingCalculation = string\concatenate(  // here is how I want my information to be displayed.
    'Credit: ', $credit, '\n',
    'Debit: ', $debit, '\n',
    'Balance is: ', $credit-$debit, '\n',  // here how I math it.
    'Calculate: ', '$',number\format($credit,0), ' - $', number\format($credit,0), ' = $', number\format($credit-$debit,0), '\n',
    );​
    And the result:

    Click image for larger version

Name:	image.png
Views:	191
Size:	8.7 KB
ID:	97660

    Comment


    • murugappan
      murugappan commented
      Editing a comment
      espcrm ,

      I am bit hazy on this one. Let me detail on how to do this, then you can correct me. Appreciate your help.

      (1) I create a field in Case entity called AccountingCalculation" which is read only
      (2) I enter the formula in the Case->formlua
      (3) Save.

      If this is correct then i can only these calculation details when I open a case entity?

      I know i am confusing everyone. My apologies.

    • espcrm
      espcrm commented
      Editing a comment
      Asked away! Yes that correct, that what I do for ours EspoCRM, except I don't

      Since you have Workflow (iirc) you can also do the same thing but better!

      We don't have workflow extension so these only get update if we edit the (Case) entity. Whereas with workflow you can set it to automate refresh formula daily for example.

      Big caveat, it will only update if we make edit! Which can be a major weakness. I try to play smart with a few "auto-refresh" formula but failing so far. I haven't got time to explore it again yet... Since my current formula is sufficient for me to work with (for now).

    • murugappan
      murugappan commented
      Editing a comment
      espcrm thank you so much. I will try other ways and post it here when i can something working better and easier. I have a lot of time to research i want to innovate the usage of Espocrm without fiddling with the core code.

      NOTE for yuri, The forum seem to be getting slower. Perhaps there are too many entries. I notice this when i save a post, it takes a bit of time.
      Last edited by murugappan; 09-26-2023, 03:26 AM.

  • #3
    espcrm Thanks. Very clear. Very helpful.

    Comment

    Working...
    X