Why is "Pay Later" never properly selected?

Hello

I have this issue where all invoices created from the below code are always created with payment method "Cash", even though I make it "Pay Later". Also, the invoices have a "PAID" stamp on them, which they shouldn't according to SAGE users here.

Here's the code:

salesInvoice = SDKInstanceManager.Instance.OpenSalesJournal();

salesInvoice.SetJournalDate(invDate.ToString("yyyy-MM-dd"));

salesInvoice.SelectTransType(0);
salesInvoice.SelectPaidByType("Pay Later");
salesInvoice.InvoiceNumber = inv.tec_manualinvoicenumber;
salesInvoice.SetShipDate(salesInvoice.GetJournalDate());

if (!string.IsNullOrEmpty(custLedger.Contact)) {
    salesInvoice.SelectAPARLedger(custLedger.Contact);

}

salesInvoice.SelectShiptoAddressName("<Mailing Address>");
salesInvoice.SetShipToAddressLine(inv.invoice_customer_accounts.Name, 1);
if (!string.IsNullOrEmpty(custLedger.Contact)) salesInvoice.SetShipToAddressLine(custLedger.Contact, 2);
if (!string.IsNullOrEmpty(custLedger.Street1)) salesInvoice.SetShipToAddressLine(custLedger.Street1, 3);
if (!string.IsNullOrEmpty(custLedger.City) && !string.IsNullOrEmpty(custLedger.Province)) salesInvoice.SetShipToAddressLine(string.Format("{0}, {1}", custLedger.City, custLedger.Province), 4);
if (!string.IsNullOrEmpty(custLedger.PostalCode)) salesInvoice.SetShipToAddressLine(custLedger.PostalCode, 5);

//add all the lines...

salesInvoice.SetFreightAmount(0.00);
salesInvoice.SetComment("");

salesInvoice.Post();

custLedger is a CustomerLedger, fetched by another method (that works fine).

Any ideas as to why this is happening ? I literally took the code from a console application and put it in a web service and it's not doing what people expect apparently.

Thanks.

  • 0
    Does the final invoice in Sage 50 show up appropriate with the proper lines other than the Paid By type?

    What does the look up show as the Payment Method on screen?

    Does the final invoice lookup show any total owing?

    Does the customer history show a payment? If so, is it the same date?

    I don't program in C# but I assume your line

    //add all the lines...

    actually adds real lines but if your invoice adds to zero dollars, then it will be marked as paid because nothing is owing on zero dollar balance invoices. Could this be the problem?
  • 0 in reply to Richard S. Ridings
    Hi Richard,

    I just realized the amount owing is indeed 0 but all the invoice lines are there, taxes too and the total is definitely more than 0. There is a method called GetAmountOwing, but how to set it to the invoice's total ?
  • 0 in reply to FrancisD
    I believe GetAmountOwing first requires you to look up an invoice before you can do that so it must be posted first. I am guessing because I don't use the SDK to post invoices.

    In a quick test here in VB, I get an error saying my SalesJournal variable needs to be assigned a value before I can use the GetAmountOwing method however, I am not sure how to assign it the invoice you wish to look at.

    Did you check the customer history report in Sage 50 to see if you see a Payment for the same amount as the Invoice?

    You can also check tcustrdt.nTransType = 0 (Invoice) and another record = 1 (Payment) for the same tcustrdt.lCusTrId that you posted with your program. Check the tcustrdt.sSource field to see what is put in for the invoice and payment.

    You can check trcpthdr to see if an entry was posted there as well.
  • 0 in reply to Richard S. Ridings
    I'm not seeing any recent records in either tcustrdt or trcpthdr that are related to my tests. Althought, the sales invoice(s) are in the system when I use the Sage Quantum client. (2016.3).
  • 0 in reply to FrancisD
    If it was an invoice only that was posted, then there should not be any records in trcpthdr. If an invoice is properly posted, there should be new records in tjourent, tjentact (current year entries), tcustr, tcustrdt, titrec, titlu, titluli, titrline, etc. (there are about 30 tables updated or added to if you fully use inventory, projects, serial numbers, etc. - assuming the SDK posts just like the Sage 50 program itself does). A single invoice without payment should show a single record in tcustr and tcustrdt.

    In Sage 50, you should be able to see the test invoice in the sales journal invoice lookup, in the customer aged detail report, the customer sales report and if inventory is applicable, then it should be in the inventory reports. It should show in the journal entry report and in the ledger reports for the accounts you posted to, and other reports if the features were included (projects, departments, serial numbers).

    The customer aged detail should show you the invoice and payment if it really had an amount owing at the time of posting and a payment was posted as well. If there is an amount owing and no payment showing in the customer aged detail report, then the invoice lookup should not show any payment and the Payment Method should still say Pay Later. What does it say?
  • 0 in reply to Richard S. Ridings
    I'm not seeing any of my tests in tcustr neither tcustrdt. To validate that the sales invoices are in SAGE, I open the client and search (and find) them. Then (leaving the client open) I fire up a program with which I can issue queries to a database. I connect it to "localhost" (the SAI file and database files are all on my own workstation) on the correct port, then I have a list of all the tables. I can't find anything matching a recent date (like 5 mins ago) in either tables.

    Where are the invoices I'm looking at through the client?
  • 0 in reply to FrancisD
    I see there's a column "dAmtOwg" in "tcustrdt" but my invoices are floating somewhere in the database without a corresponding record in "tcustrdt" so they could have a "dAmtOwg" greater than 0.
  • 0 in reply to FrancisD
    OK, since you are a techie, let's get technical.

    You haven't answered all the questions I have asked so you are going to have to go back and do it again. However, this time, just do the following.

    1) Post an image of the invoice from Sage 50 of the invoice you posted.

    2) Post an image of the journal entry from the Report menu of the sales journal.

    3) Post an image of the journal entry from the Reports, Journal Entries (Transaction Details), All report for just that journal entry number (number you will be able to see in #2 above).

    4) Post the Customer Aged Detail report for the client you import an invoice for, showing only enough to cover the test invoice if you can. From the Homescreen under Reports, Receivables (Customers and Sales), Customer Aged..., Detail, select the customer, end date and set the number of days to include fully paid invoices to enough to show the test invoice (usually 2 will work)

    No need to show the entire history if it is a real client (hide any confidential information - eg client name). I'm interested in seeing the dates, invoice/payment numbers, dollars and on the data entry screen, the Payment Method, etc.

    We will go forward from there.
  • 0 in reply to Richard S. Ridings
    Thanks Richard. I found out what was wrong, I was assigning the order to the account contact (CustomerLedger.Contact) rather than the account itself (CustomerLedger.Name). Assigning it to the latter fixed the issue.
  • 0 in reply to FrancisD
    Ok thanks. I was starting to think there was something wrong in the code because you were not getting the correct records showing up and I was going to have you go through the tables where we would expect them to show once I saw some details of the entry. This way I could direct you more easily to the exact entries. But if you have it working now, that's great too.