Overlap between the record

Voici la méthode pour contrôle s’il y a un overlap de date entre deux enregistrements.

Dans la méthode validateWrite():

    if (this.mCheckOverlapDate())
    {
        ret = checkFailed("@SYS39599");
    }

Maintenant dans la méthode mCheckOverlapDate:

// Control the overlapping with the FromDate and ToDate with other record in this table.
public boolean mCheckOverlapDate(boolean _checkOtherRecordOverlap = true)
{
    Table       mTable;

    boolean     ret;
    boolean     fromDateOverlapped;
    boolean     toDateOverlapped;
    boolean     ourRangeOverlapped;
    ;

    //  We loop over the record for the same paym term condition
    while select mFromDate, mToDate from mTable
    where mTable.RecId != this.RecId
    {
        //  First we control if there are no overlapping for the MyFromDate field
        if (this.MyFromDate >= mPaymTerm.MyFromDate && this.MyFromDate <= mPaymTerm.MyToDate)
        {
            fromDateOverlapped = true;
            break;
        }

        //  Second time, we control if there are no overlapping for the MyToDate field
        if (this.MyToDate >= mPaymTerm.MyFromDate && this.MyToDate <= mPaymTerm.MyToDate)
        {
            toDateOverlapped = true;
            break;
        }
    }

    if (fromDateOverlapped || toDateOverlapped)
    {
        ret = true;
    }

    if (_checkOtherRecordOverlap)
    {
        //  Now we will control if each other record are not in our range !
        while select mTable
        where mTable.RecId != this.RecId
        {
            if (mPaymTerm.mCheckOverlapDate(false))
            {
                ourRangeOverlapped = true;
            }
        }

        if (ourRangeOverlapped)
        {
            ret = true;
        }
    }

    return ret;
}