Wednesday, October 27, 2010

Mark All for Open Cust Trans and Open Vend Trans

We have situations where there are lots of open transactions that need to be settled against each other.  This can be the case if auto settlement is turned off.

One solution is to add a "Mark All" button to the custOpenTrans or vendOpenTrans forms.  This button "checks" the mark checkbox on every line.  The user can then uncheck several lines if needed and Update to settle the lines.

The code below is an example of what we used on the open vendor transaction screen.  The code is very similar on the AR side.  One note: I used vendTable.AccountNum in the code below.  That should be generalized to work with any buffer that is passed into the open trans form.

void customMarkAll()
{
    VendTransOpen   localVendTransOpen;
    VendTrans       localVendTrans;
    container       conSum;

    int             linesProcessed;
    ;

    //show wait cursor
    startLengthyOperation();

    element.lock();

    //remove all prior markings
    specOffsetVoucher.deleteSpecifications();
    settle.empty();

    ttsbegin;
    while select localVendTransOpen where localVendTransOpen.AccountNum == vendTable.AccountNum
    {
        localVendTrans = VendTrans::find(localVendTransOpen.RefRecId);

        specOffsetVoucher.create(localVendTransOpen.TableId,
                                             localVendTransOpen.RecId,
                                             localVendTransOpen.AmountCur,
                                             localVendTrans.CurrencyCode);

        settle.insert(localVendTransOpen.RecId,localVendTransOpen.AmountCur);

        linesProcessed++;
    }
    ttscommit;

    element.unLock();

    //calculate totals for display
    conSum = custVendSettle_Vend.openSumRemainAmount(common,currencyCode);
    remainAmountCur = conpeek(conSum,1);
    remainAmountMST = conpeek(conSum,2);
    element.initCashDiscTotal();

    element.initVendBalance();

    //refresh the screen with the calculated totals
    element.redraw();

    //remove wait cursor
    endLengthyOperation();

    box::info(strfmt("%1 Vouchers Marked",linesProcessed));

}

3 comments:

  1. You forget to mention "specOffsetVoucher". What object is that? class, form, or what?

    ReplyDelete
  2. specOffsetVoucher is already declared and instantiated for you in the custOpenTrans or vendOpenTrans forms. If you look in the form's class declaration, you can see that specOffsetVoucher is an instance of the Specification class. Hope that helps.

    ReplyDelete