Pages

Banner 468 x 60px

 

Tuesday, November 21, 2017

close, write, delete, init, lookup using x++

0 comments
close, write, delete, init, lookup using x++ :

public void close()
{
    FormRun     _FormRun;
    super();

    _FormRun    = element.args().caller();

    if (_FormRun)
    _FormRun.dataSource().research();
}


public void write()
{
    GG_FPJVoucherId     GG_FPJVoucherOrigin;
    Soltius_NSNRFP      _Soltius_NSNRFP;
    ;
    GG_FPJVoucherOrigin = GG_PPNRETTable.orig().FPJVoucherId;

    super();

    if (GG_FPJVoucherOrigin         != "")
        GG_FPJVoucher::setStatusVoucher(GG_FPJVoucherOrigin);

    if (GG_PPNRETTable.FPJVoucherId    != "")
        GG_FPJVoucher::setStatusVoucher(GG_PPNRETTable.FPJVoucherId);

    ttsBegin;
        Delete_From _Soltius_NSNRFP
            Where _Soltius_NSNRFP.NSNRFP == GG_PPNRETTable.orig().FPJNotaReturNum;
    ttsCommit;
}

 ================================== GG_FPJVouhcer ================
STATIC void setStatusVoucher(GG_FPJVoucherId   _GG_FPJVoucherId)
{
    GG_FPJTable     _GG_FPJTable;
    GG_PPhTable     _GG_PPhTable;
    GG_FPJVoucher   _GG_FPJVoucher;
    GG_PPNRETTable  _GG_PPNRETTable
    ;

    select _GG_FPJTable index hint VoucherListIdx where _GG_FPJTable.FPJVoucherId == _GG_FPJVoucherId;


    select _GG_PPhTable index hint VoucherListIdx where _GG_PPhTable.FPJVoucherId == _GG_FPJVoucherId;

    Select _GG_PPNRETTable Where _GG_PPNRETTable.FPJVoucherId == _GG_FPJVoucherId;

    try
    {
        ttsbegin;
        select forupdate _GG_FPJVoucher index hint VoucherListIdx where
            _GG_FPJVoucher.FPJVoucherId     == _GG_FPJVoucherId;

        if (_GG_FPJVoucher)
        {
            if ((_GG_FPJTable || _GG_PPNRETTable) && _GG_PPhTable)
            {
                _GG_FPJVoucher.Status   = GG_OpenClose::Closed;
                _GG_FPJVoucher.FPJFakturPajakNum = _GG_FPJTable.FPJFakturPajakNum;
                _GG_FPJVoucher.FPJPPhNum = _GG_PPhTable.FPJPPhNum;
            }
            else
            if ((_GG_FPJTable || _GG_PPNRETTable) && _GG_FPJVoucher.PPhPercent <= 0)//AmountPPhFaktur  == 0)
            {
                _GG_FPJVoucher.Status   = GG_OpenClose::Closed;
                _GG_FPJVoucher.FPJFakturPajakNum = _GG_FPJTable.FPJFakturPajakNum;

                // added by adit - untuk mengisi nomor faktur pajak pada nota return
                if(_GG_PPNRettable)
                {
                    _GG_FPJVoucher.FPJFakturPajakNum = _GG_PPNRETTable.FPJNotaReturNum;
                }
            }

            else
            if (_GG_PPhTable && _GG_FPJVoucher.AmountPPNFaktur  == 0)
            {
                _GG_FPJVoucher.Status   = GG_OpenClose::Closed;
                _GG_FPJVoucher.FPJPPhNum = _GG_PPhTable.FPJPPhNum;
                //_GG_FPJVoucher.FPJFakturPajakNum = _GG_FPJTable.FPJFakturPajakNum;
            }
            else
            if ((_GG_FPJTable || _GG_PPNRETTable) && !_GG_PPhTable && _GG_FPJVoucher.PPhPercent > 0)
            {
                _GG_FPJVoucher.Status   = GG_OpenClose::OpenPPh;
                _GG_FPJVoucher.FPJFakturPajakNum = _GG_FPJTable.FPJFakturPajakNum;
                _GG_FPJVoucher.FPJPPhNum = '';//_GG_PPhTable.FPJPPhNum
            }

            else
            if ((!_GG_FPJTable || _GG_PPNRETTable) && _GG_PPhTable)
            {
                _GG_FPJVoucher.Status   = GG_OpenClose::OpenVAT;
                //_GG_FPJVoucher.FPJFakturPajakNum = '';//_GG_FPJTable.FPJFakturPajakNum; // adit
                _GG_FPJVoucher.FPJFakturPajakNum = _GG_FPJTable.FPJFakturPajakNum;
                _GG_FPJVoucher.FPJPPhNum = _GG_PPhTable.FPJPPhNum;
            }
            else
            {
                _GG_FPJVoucher.Status   = GG_OpenClose::Open;
                _GG_FPJVoucher.FPJFakturPajakNum = '';
                _GG_FPJVoucher.FPJPPhNum = '';
            }

            /*IF ((_GG_FPJVoucher.Status == GG_OpenClose::OpenVAT ) &&
                (_GG_FPJVoucher.AmountPPNFaktur <= 0))
                _GG_FPJVoucher.Status   = GG_OpenClose::Closed;

            ELSE IF ((_GG_FPJVoucher.Status == GG_OpenClose::OpenPPh ) &&
                (_GG_FPJVoucher.AmountPPhFaktur <= 0))
                _GG_FPJVoucher.Status   = GG_OpenClose::Closed;*/



            _GG_FPJVoucher.update();
        }
        ttscommit;
    } catch
        {
            ttsabort;
        }
}

public void delete()
{
    GG_FPJVoucherId     GG_FPJVoucherOrigin;
    Soltius_NSNRFP      _Soltius_NSNRFP;
    ;
    GG_FPJVoucherOrigin = GG_PPNRETTable.orig().FPJVoucherId;

    super();

    if (GG_FPJVoucherOrigin         != "")
        GG_FPJVoucher::setStatusVoucher(GG_FPJVoucherOrigin);

    if (GG_PPNRETTable.FPJVoucherId != "")
        GG_FPJVoucher::setStatusVoucher(GG_PPNRETTable.FPJVoucherId);

    ttsBegin;
        Delete_From _Soltius_NSNRFP
            Where _Soltius_NSNRFP.InvoiceID == GG_FPJVoucherOrigin;
    ttsCommit;
}

public void init()
{
    super();
    GG_PPNRETTable_q.dataSourceNo(1).clearRanges();
    GG_PPNRETTable_q.dataSourceNo(1).clearDynalinks();
    GG_PPNRETTable_q.dataSourceNo(1).clearLinks();
}

public void init()
{
    super();
    GG_PPNRETTable_q.dataSourceNo(1).clearRanges();
    GG_PPNRETTable_q.dataSourceNo(1).clearDynalinks();
    GG_PPNRETTable_q.dataSourceNo(1).clearLinks();
}
public void lookup(FormControl _formControl, str _filterStr)
{
    //super(_formControl, _filterStr);
    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDataSource;
    SysTableLookup          sysTableLookup;
    ;

    //Create an instance of SysTableLookup with the form control passed in
    sysTableLookup = SysTableLookup::newParameters(tablenum(GG_FPJVoucher), _formControl);

    //Add the fields to be shown in the lookup form
    sysTableLookup.addLookupfield(fieldnum(GG_FPJVoucher, FPJVoucherId), true);
    sysTableLookup.addLookupfield(fieldnum(GG_FPJVoucher, Voucher));
    sysTableLookup.addLookupfield(fieldnum(GG_FPJVoucher, JournalId));
    sysTableLookup.addLookupfield(fieldnum(GG_FPJVoucher, VoucherDate));
    sysTableLookup.addLookupfield(fieldnum(GG_FPJVoucher, AmountDPPFaktur));
    sysTableLookup.addLookupfield(fieldnum(GG_FPJVoucher, AmountPPNFaktur));

    //create the query datasource
    queryBuildDataSource = query.addDataSource(tablenum(GG_FPJVoucher));
    queryBuildDataSource.addRange(fieldnum(GG_FPJVoucher, FPJVoucherType)).value(sysquery::value(GG_FPJVoucherType::ReturnCR));
    queryBuildDataSource.addRange(fieldnum(GG_FPJVoucher, FPJVoucherType)).value(sysquery::value(GG_FPJVoucherType::ReturnInv));
    queryBuildDataSource.addRange(fieldnum(GG_FPJVoucher, Status)).value(sysquery::value(GG_OpenClose::Open));
    queryBuildDataSource.addRange(fieldnum(GG_FPJVoucher, Status)).value(sysquery::value(GG_OpenClose::OpenVAT));
    queryBuildDataSource.addRange(fieldnum(GG_FPJVoucher, AmountPPNFaktur)).value(sysquery::valueNot(0));


    //add the query to the lookup form
    sysTableLookup.parmQuery(query);

    // Perform lookup
    sysTableLookup.performFormLookup();
}


0 comments:

A financial dimension value is based on the record and has been used on a transaction. You cannot delete the record

  SOLUTION delete in table DimensionAttributeLevelValue base on Bank Account  :  and Delete the Bank Account FINISH