Tuesday, 16 December 2014

Sample: Display method for Sales Quotation report (conditional display)

\Data Dictionary\Tables\CustQuotationTrans\Methods\MTI_lineAmountInclTax
// Created by Vimal on Dec 11, 2014
/// <summary>
///     To Display MTI_LineAmount as per the condition of MTI_ShowPrice true/false value.
/// </summary>
/// <returns>
///     if MTI_ShowPrice is false then LineAmount should be zero
///     if MTI_ShowPrice is true then LineAmount should be displayed with the summation of
///     itself along with MTI_RollTo matching items value.
/// </returns>
display LineAmount MTI_lineAmountInclTax()
{
    LineAmount          lineAmount;
    CustQuotationTrans  custQuotationTrans_loc;
    ;

    if (this.MTI_ShowPrice == NoYes::Yes)
    {
        select sum (LineAmount), sum (LineAmountTax) from custQuotationTrans_loc
                where custQuotationTrans_loc.MTI_RollTo     == this.ItemId
                &&    custQuotationTrans_loc.MTI_ShowPrice  == NoYes::No
                &&    custQuotationTrans_loc.QuotationId    == this.QuotationId;
        lineAmount = custQuotationTrans_loc.LineAmount + custQuotationTrans_loc.LineAmountTax
                                                        + this.LineAmount + this.lineAmountTax;
    }
    else
    {
        lineAmount = 0.00;
    }
    return lineAmount;
}

\Data Dictionary\Tables\CustQuotationTrans\Methods\MTI_SalesPrice
// Created by Vimal on Dec 11, 2014
/// <summary>
///     To Display MTI_SalesPrice as per the condition of MTI_ShowPrice true/false value.
/// </summary>
/// <returns>
///     if MTI_ShowPrice is false then salesPrice should be zero
///     if MTI_ShowPrice is true then salesPrice would be LineAmount/Qty.
/// </returns>
display SalesPrice MTI_SalesPrice()
{
    SalesPrice      salesPrice;
    ;

    if (this.MTI_ShowPrice == NoYes::Yes)
    {
        salesPrice = this.MTI_lineAmountInclTax()/this.Qty;
    }
    else
    {
        salesPrice = 0.00;
    }
    return salesPrice;
}
Output:

No comments:

Post a Comment