Tuesday 16 December 2014

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

\Data Dictionary\Tables\CustInvoiceTrans\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;
    CustInvoiceTrans    custInvoiceTrans_loc;
    ;

    if (this.MTI_ShowPrice == NoYes::Yes)
    {
        select sum (LineAmount), sum (LineAmountTax) from custInvoiceTrans_loc
                where custInvoiceTrans_loc.MTI_RollTo     == this.ItemId
                &&    custInvoiceTrans_loc.MTI_ShowPrice  == NoYes::No
                &&    custInvoiceTrans_loc.SalesId        == this.SalesId
                &&    custInvoiceTrans_loc.InvoiceId      == this.InvoiceId;
        lineAmount = custInvoiceTrans_loc.LineAmount + custInvoiceTrans_loc.LineAmountTax
                                                        + this.LineAmount + this.lineAmountTax;
    }
    else
    {
        lineAmount = 0.00;
    }
    return lineAmount;
}
\Data Dictionary\Tables\CustInvoiceTrans\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