Filtering Overdue Fees by Account

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • carlosptf
    Junior Member
    • Jul 2024
    • 20

    Filtering Overdue Fees by Account

    Hello EspoCRM community,


    I have three entities in EspoCRM:

    Account: Stores account data.

    Payments: Records monthly fees (paid or overdue).

    Negotiation: Centralizes negotiations related to the overdue and outstanding fees for each account.


    When creating a new negotiation and selecting the fees to be linked, I need the list to show only those linked to the same account as the negotiation. I have already created a filter to list only the open (overdue) fees, but I also need a predefined filter that lists only the open fees for the associated account.


    For example, I created a negotiation record for this account called “top max.”
    Click image for larger version

Name:	CleanShot 2024-12-24 at 01.13.56@2x.png
Views:	33
Size:	93.0 KB
ID:	113307



    When selecting the payments, I receive a list of all outstanding payments:

    Click image for larger version

Name:	CleanShot 2024-12-24 at 01.16.49@2x.png
Views:	33
Size:	349.3 KB
ID:	113308

    As shown in the image below, I can filter to display only the payments for the “top max” account, but I want this list to show only the payments for the “top max” account by default.


    Click image for larger version

Name:	CleanShot 2024-12-24 at 01.17.44@2x.png
Views:	33
Size:	265.3 KB
ID:	113309

    To achieve the result of displaying only the outstanding payments, I created a filter in “Reports.” I noticed there’s also an option to add an expression as a filter, but I couldn’t make progress with the formula. Could you help me?

    Click image for larger version

Name:	CleanShot 2024-12-24 at 01.29.01@2x.png
Views:	33
Size:	57.5 KB
ID:	113310


    Attached Files
  • yuri
    Member
    • Mar 2014
    • 8451

    #2
    Hi,

    This has been already covered on the forum a few times. One topic that I found: https://forum.espocrm.com/forum/deve...current-record

    You need to define a selectHandler.

    Assuming your entity type is named CNegiation.

    Create (or edit if the file already exists):

    custom/Espo/Custom/Resources/metadata/clientDefs/CNegiation.json

    Code:
    {
        "relationshipPanels": {
            "selectHandler": "handlers/select-related/same-account"
        }
    }
    Make sure the JSON is valid.

    Then clear cache.

    "handlers/select-related/same-account" is the built-in handler that should covers your case when there are belongs-to links named "account" in both entity types. If the naming is different, you will need to write a custom handler.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    Working...