Use BOI to create AR Receipt error "This distribution is out of balance. Do you want to delete the distribution?"

SOLVED

Using Sage BOI, trying to write an AR_CashReceiptsDetail will fail!

I am trying to make a tool to help AR out. We have customers that may pay for one to many other customers. AR is simply given a check with an amount and has to figure out how to apply it. They have to look up many customers and find open invoices and this takes hours. I have a GUI that shows the main customer and all of their customers with open invoices. The check amount is entered. Each invoice can be paid off but if there is a remainder it goes to OVPMT of the main customer instead of an invoice from one of 'their' customers.

So far I can make cash deposits all day (later I will make credit card deposits) and it looks like I can mostly make a cash receipt header but not sure if I get the cash receipt details right as it fails when I try to write with: "This distribution is out of balance. Do you want to delete the distribution?" just like I see on Sage's GUI. I am either doing something wrong, or I do not know how to answer that question: is there a function to address the question and tell BOI 'NO'?

I want to make one deposit and use it for many transactions against other accounts and also perhaps place any remainder back into the originator of that deposit as well... so I need to make many transactions against the same deposit. Ultimately it will zero out, my GUI wont let the AR person continue unless all is accounted for (and any remainder goes to the check originator anyway)

Sorry for the long post but I err on too much info instead of too little (he said hopefully). C# and com

I will post the code context where I have the issue but here is the actual line it fails on

retVal = pvxNoParam(AR_Header_Bus, "WRITE", out sLastErrorMsg); //!!ERROR HERE!!! This distribution is out of balance. Do you want to delete the distribution?

  • 0

    I recently changed decVal to the same value and used it on deposit, header and detail for now as a test to try to get a successful write

    //!**DEPOSIT
    retVal = pvxGetParam(AR_Deposit_Bus, "GetNextDepositNo", out sNextDepositNo, out sLastErrorMsg);
    retVal = pvxSetParam(AR_Deposit_Bus, "SetKey", sNextDepositNo, out sLastErrorMsg);
    retVal = pvxSetString(AR_Deposit_Bus, "BankCode$", "F", out sLastErrorMsg);
    retVal = pvxSetString(AR_Deposit_Bus, "DepositDate$", sDepositDate, out sLastErrorMsg);
    retVal = pvxSetDecimal(AR_Deposit_Bus, "CashDepositAmt", decVal, out sLastErrorMsg);
    retVal = pvxSetString(AR_Deposit_Bus, "DepositDesc$", "CHECK-Custom BOI", out sLastErrorMsg);
    //WRITE THE DEPOSIT
    retVal = pvxNoParam(AR_Deposit_Bus, "WRITE", out sLastErrorMsg); //Creates the deposit NO problem!! :-)

    //!**HEADER
    retVal = pvxSetParam(AR_Header_Bus, "ValidateDepositNo", sNextDepositNo, out sLastErrorMsg);
    retVal = pvxSetString(AR_Header_Bus, "DepositNo$", sNextDepositNo, out sLastErrorMsg);
    retVal = pvxSetString(AR_Header_Bus, "ARDivisionNo$", doctorDiv, out sLastErrorMsg);
    retVal = pvxSetString(AR_Header_Bus, "CustomerNo$", doctorAccount, out sLastErrorMsg);
    retVal = pvxSetString(AR_Header_Bus, "CheckNo$", checkNumber, out sLastErrorMsg);
    retVal = pvxSetString(AR_Header_Bus, "DepositType$", "C", out sLastErrorMsg); //likely NOT needed?!
    retVal = pvxSetDecimal(AR_Header_Bus, "PostingAmt", decVal, out sLastErrorMsg);

    //!**DETAIL
    retVal = pvxNoParam(AR_Detail_Bus, "MoveFirst", out sLastErrorMsg); //had a lot of problems until added this line
    //retVal = pvxSetString(AR_Detail_Bus, "DepositNo$", sNextDepositNo, out sLastErrorMsg); //thinking this already set
    retVal = pvxSetString(AR_Detail_Bus, "Comment$", "Custom BOI", out sLastErrorMsg);
    retVal = pvxSetString(AR_Detail_Bus, "InvoiceType$", "PP", out sLastErrorMsg);
    retVal = pvxSetString(AR_Detail_Bus, "LineType$", "I", out sLastErrorMsg);
    retVal = pvxSetString(AR_Detail_Bus, "InvoiceNo$", "OVPMT", out sLastErrorMsg);
    retVal = pvxSetDecimal(AR_Detail_Bus, "AmountPosted", decVal, out sLastErrorMsg);


    //WRITE!
    retVal = pvxNoParam(AR_Header_Bus, "WRITE", out sLastErrorMsg); //!!ERROR HERE!!! This distribution is out of balance. Do you want to delete the distribution?


    //I removed the follwing for clairity
    if (retVal == 0) { statusMsg = sLastErrorMsg; return; }

    I have helper functions that use System.Reflection I have used successfully in creating sales orders and customers, etc.

  • 0
    I don't think there is a way around it, when you enter it manually it has to balance as well.
  • 0 in reply to 49153

    Thanks for the reply. When you enter it manually/using SAGE, you can say 'no' and continue on... however in the example I show and what I am currently trying, I make a deposit of $10 and then I make a receipt of $10... AFAICT there is nothing out of balance, however the code failed at the same spot with the same error! :-(  This is why I believe that I am missing something / doing something wrong! Please help!!!

    $10 in, $10 out should equal not say 'out of balance'?

  • 0 in reply to 49153
    Hmm.. I just tested SAGE UI... it does not have to balance. For this prepayment "OVPMT" type is simply asks: is this a prepayment? and you click OK
  • 0 in reply to SageAcolyte
    verified answer
    Just a couple things I noticed:

    You should call AddLine instead of MoveFirst.

    retVal = pvxNoParam(AR_Detail_Bus, "MoveFirst", out sLastErrorMsg); //had a lot of problems until added this line

    You need to write the line before writing the header.
  • 0 in reply to Natasha Chang

    Natasha Chang, thank you So Much for your reply.  Over the weekend I had noticed the same thing you did and modified my code as shown below.  Unfortunately, even though I can 1) create deposit and 2,3) make receipt header and detail line... the receipts do NOT take the value from the deposit!  

    (hmm maybe I should make a new question?  what does etiquette say?)

    retVal = pvxGetParam(AR_Deposit_Bus, "GetNextDepositNo", out sNextDepositNo, out sLastErrorMsg);
    retVal = pvxSetString(AR_Deposit_Bus, "BankCode$", "F", out sLastErrorMsg);
    retVal = pvxSetParam(AR_Deposit_Bus, "ValidateDepositDate", sDepositDate, out sLastErrorMsg);
    retVal = pvxSetString(AR_Deposit_Bus, "DepositDate$", sDepositDate, out sLastErrorMsg);
    retVal = pvxSetDecimal(AR_Deposit_Bus, "CashDepositAmt", decVal, out sLastErrorMsg);
    retVal = pvxSetString(AR_Deposit_Bus, "DepositDesc$", "CHECK-Custom BOI", out sLastErrorMsg);
    //WRITE THE DEPOSIT
    retVal = pvxNoParam(AR_Deposit_Bus, "WRITE", out sLastErrorMsg);

    //!**HEADER
    retVal = pvxSetParam(AR_Header_Bus, "ValidateDepositNo", sNextDepositNo, out sLastErrorMsg);
    retVal = pvxSetString(AR_Header_Bus, "DepositNo$", sNextDepositNo, out sLastErrorMsg);
    retVal = pvxSetString(AR_Header_Bus, "ARDivisionNo$", doctorDiv, out sLastErrorMsg);
    retVal = pvxSetString(AR_Header_Bus, "CustomerNo$", doctorAccount, out sLastErrorMsg);
    retVal = pvxSetString(AR_Header_Bus, "CheckNo$", checkNumber, out sLastErrorMsg);
    retVal = pvxSetString(AR_Header_Bus, "DepositType$", "C", out sLastErrorMsg);
    retVal = pvxNoParam(AR_Header_Bus, "SetKey", out sLastErrorMsg);
    retVal = pvxSetDecimal(AR_Header_Bus, "PostingAmt", decVal, out sLastErrorMsg);

    //!**DETAIL
    retVal = pvxNoParam(AR_Detail_Bus, "AddLine", out sLastErrorMsg);
    retVal = pvxSetString(AR_Detail_Bus, "InvoiceNo$", "OVPMT", out sLastErrorMsg);
    retVal = pvxSetString(AR_Detail_Bus, "Comment$", "Custom BOI", out sLastErrorMsg);
    retVal = pvxSetString(AR_Detail_Bus, "InvoiceType$", "PP", out sLastErrorMsg);
    retVal = pvxSetString(AR_Detail_Bus, "LineType$", "I", out sLastErrorMsg);
    retVal = pvxSetDecimal(AR_Detail_Bus, "AmountPosted", decVal, out sLastErrorMsg);
    retVal = pvxNoParam(AR_Detail_Bus, "WRITE", out sLastErrorMsg);
    retVal = pvxNoParam(AR_Header_Bus, "WRITE", out sLastErrorMsg);

  • 0 in reply to SageAcolyte

    I ran SQL trace when an employee was working with Deposits and Receipts... (she is the one I am creating this for) I noticed a line

    UPDATE [AR_CASHRECEIPTSDEPOSIT] SET [CashBalanceAmt] = 0, [DepositBalance] = 0, [TimeUpdated] = '11.30481' WHERE [DepositNo] = '17065' -- WRITE(32706) SY_Maint.pvc@428, CacheMode=-1


    it looks like a separate step... but I think Sage UI takes care of it automatically? Am I missing something: can I make a cash receipt automatically pull from a deposit? Thanks!

    UPDATE:
    It looks like I can MANUALLY HACK IT.... <sigh> after brute forcing it... trying out different combinations it *APPEARS* to work just like Sage UI now... If, after I have completed all transactions and deposit should be ZERO I state:
    retVal = pvxSetParam(AR_Deposit_Bus, "SetKey", sNextDepositNo, out sLastErrorMsg);

    retVal = pvxSetDecimal(AR_Deposit_Bus, "CashBalanceAmt", 0, out sLastErrorMsg);
    //retVal = pvxSetDecimal(AR_Deposit_Bus, "DepositBalance", 0, out sLastErrorMsg);  //this should not be used
    retVal = pvxNoParam(AR_Deposit_Bus, "WRITE", out sLastErrorMsg);

  • 0 in reply to SageAcolyte
    You will be happy to know that this HACK isn't required anymore in the 2016 version... however it is necessary for all versions up to and including 2015...
  • 0 in reply to Kent Rhodes
    Kent, I am indeed happy to know that. We are actually moving forward on upgrading to 2016 as I type so that will be interesting... as well as the whole credit card processing change (currently our Sage product has all of our payment information in the db but of course it must be moved to the Sage Vault - and this will affect our automation software that makes batch orders and posts payments) Thanks for chiming in!