logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Ken Morey  
#1 Posted : Monday, August 10, 2020 1:37:37 PM(UTC)
Ken Morey

Rank: Newbie

Groups: Registered
Joined: 3/6/2018(UTC)
Posts: 7
United States
Location: Peoria, IL

How do I populate the BankAmount and TotalBankAmount fields. The following VB.net code seems to work but the two fields are readonly. I am sure I have missed something. The following is the transaction presenter code. What have I missed?

Console.WriteLine("Setting company")
API.TransactionPresenter.Company = API.LookupId(LookupFields.Company, LookupColumns.Abbreviation, pCompany)
Console.WriteLine("Setting transaction date")
API.TransactionPresenter.TransactionDate = DateTime.Today ' New DateTime(2015, 1, 1) ' DateTime.Today
'Console.WriteLine("Setting vendor name")
'API.TransactionPresenter.Name = API.LookupId(LookupFields.Name, LookupColumns.NamesFirstLast, "Ice Man Supplies")
Console.WriteLine("Setting account")
API.TransactionPresenter.Account = API.LookupId(LookupFields.Account, LookupColumns.Name, "Prepaid Inventory")

Console.WriteLine("Creating New AP Invoice")
API.TransactionPresenter.NewTransaction(TransactionTypeTypes.SalesOrders)

Console.WriteLine("Adding a line item to transaction")
Dim Line As SalesItemLineObject = API.TransactionPresenter.AddSalesItemLine(API.LookupId(LookupFields.SalesItem,
LookupColumns.Abbreviation, "3"), 100)

Line.LineValues.AddReplace(InputFieldTypes.Amount, 1250)

API.TransactionPresenter.TransactionComment = "Add Booking"

API.TransactionPresenter.TransactionComment = "Add Ap Invoice"
API.TransactionPresenter.MemoLine1 = "Memo Line 1 text"
API.TransactionPresenter.MemoLine2 = "Memo Line 2 text"
API.TransactionPresenter.BillingLocation = 2147469995
API.TransactionPresenter.ShippingLocation = 2147469995


Console.WriteLine("Posting transaction")
API.TransactionPresenter.PostNewTransaction()

tony  
#2 Posted : Monday, August 10, 2020 1:54:54 PM(UTC)
tony

Rank: Advanced Member

Groups: Registered
Joined: 2/28/2018(UTC)
Posts: 65
United States
Location: Pennsylvani mostly

Was thanked: 9 time(s) in 9 post(s)
Those are read-only because they are calculated fields so you do not need to set them.

On sales orders, I don't think that it will do any good to set the amount field since it is calculated from a quantity and a sales price.

So instead of:

Code:

Line.LineValues.AddReplace(InputFieldTypes.Amount, 1250)


Try:

Code:

Line.LineValues.AddReplace(InputFieldTypes.Quantity1, 100);
Line.LineValues.AddReplace(InputFieldTypes.SalesPrice, 12.5);

Edited by user Monday, August 10, 2020 1:55:47 PM(UTC)  | Reason: Not specified

Ken Morey  
#3 Posted : Wednesday, August 12, 2020 9:55:43 PM(UTC)
Ken Morey

Rank: Newbie

Groups: Registered
Joined: 3/6/2018(UTC)
Posts: 7
United States
Location: Peoria, IL

Thanks Tony. I made the changes but they did not give me any amounts. I also found that I was writing a transaction when I needed to write a salesordertransaction. Changed to code to the following, and am now writing to salesordertransaction but again no amounts. I feel I am missing a step somewhere. I would appreciate any suggestions.

API.SalesOrderPresenter.Company = API.LookupId(LookupFields.Company, LookupColumns.Abbreviation, pCompany)
API.SalesOrderPresenter.TransactionDate = DateTime.Today
API.SalesOrderPresenter.EarliestDate = DateTime.Today
API.SalesOrderPresenter.ExistingStatus = SalesOrderStatus.Open
API.SalesOrderPresenter.Customer = API.LookupId(LookupFields.Customer, LookupColumns.Abbreviation, pCustomer)


API.SalesOrderPresenter.TransNumber = ptransno

Console.WriteLine("Adding a line item to transaction")
Dim subline As SalesItemLineObject = API.TransactionPresenter.AddSalesItemLine(2147469992, 1000)

Dim acctline As AccountLineObject = API.TransactionPresenter.AddAccountLine(API.LookupId(LookupFields.Account,
LookupColumns.AccountNumber, "305032-02"), 1500)

API.SalesOrderPresenter.AddSalesItemLine(subline.SalesItem, 500)
subline.Amount = 1200
subline.LineType = TransactionLineTypes.SalesItemTemplate
subline.LineValues.AddReplace(InputFieldTypes.Quantity1, 100)
subline.LineValues.AddReplace(InputFieldTypes.SalesPrice, 12.5)

API.SalesOrderPresenter.CustomField1 = "AP"
API.SalesOrderPresenter.TransactionComment = "Add Sales Order"
API.SalesOrderPresenter.MemoLine1 = "Memo Line 1 text"
API.SalesOrderPresenter.MemoLine2 = "Memo Line 2 text"
API.SalesOrderPresenter.BillingLocation = 2147469995
API.SalesOrderPresenter.ShippingLocation = 2147469995


API.SalesOrderPresenter.CalculateTotals(False)
API.SalesOrderPresenter.SaveTransaction(True)
tony  
#4 Posted : Thursday, August 13, 2020 6:28:29 PM(UTC)
tony

Rank: Advanced Member

Groups: Registered
Joined: 2/28/2018(UTC)
Posts: 65
United States
Location: Pennsylvani mostly

Was thanked: 9 time(s) in 9 post(s)
Sorry for the delay. So the problem is that the import goes through and there are no amounts?

Ah, I think I can guess what is going on now.

subline.LineValues.AddReplace(InputFieldTypes.Quantity1, 100) // this line is actually setting the quantity shipped, not the quantity ordered

I think that you want to do the following instead (my sample code was wrong because I was setting Quantity1 too):

subline.LineValues.AddReplace(InputFieldTypes.QuantityOrdered, 100)

FYI, if you want CenterPoint to handle the pricing, I don't even think that you have to specify InputFieldType.SalesPrice.

I believe that this will fix it, but if it doesn't, can you send me a screen print of the sales order as you see it on the Edit Sales Order screen? There's a surprising number of variables at work here. tonyc@redwingsoftware.com

Edited by user Thursday, August 13, 2020 6:35:47 PM(UTC)  | Reason: Not specified

Ken Morey  
#5 Posted : Monday, August 17, 2020 3:54:33 PM(UTC)
Ken Morey

Rank: Newbie

Groups: Registered
Joined: 3/6/2018(UTC)
Posts: 7
United States
Location: Peoria, IL

I changed to code to use the quantity ordered in the salesordertransaction salesorder object. It still does not give me the quantity ordered or a total amount for the sale. In addition in CenterPoint I added prices for the item used and it appears to now give me the default of 1 and the first default price. It acts like it does not accept the price or quantity changes from the API. I do not want CenterPoint to handle the pricing. I will send a screen shot of what I want. Any thoughts or suggestions?
tony  
#6 Posted : Monday, August 17, 2020 4:02:30 PM(UTC)
tony

Rank: Advanced Member

Groups: Registered
Joined: 2/28/2018(UTC)
Posts: 65
United States
Location: Pennsylvani mostly

Was thanked: 9 time(s) in 9 post(s)
Can I see the code as it is now?

The inputs are determined by the kind of template that is selected for the transaction. From the screen shot you send me, I hope to learn what that the template is.

If I was debugging this, I'd enter a sales order with the same information in CenterPoint as I'm trying to import and see what, if anything, is different.
Ken Morey  
#7 Posted : Tuesday, August 18, 2020 1:31:06 PM(UTC)
Ken Morey

Rank: Newbie

Groups: Registered
Joined: 3/6/2018(UTC)
Posts: 7
United States
Location: Peoria, IL

Thanks for your help Tony, it is finally adding a sales order. Here is a copy of the working code for an addition:

API.SalesOrderPresenter.Company = API.LookupId(LookupFields.Company, LookupColumns.Abbreviation, pCompany)
API.SalesOrderPresenter.TransactionDate = DateTime.Today
API.SalesOrderPresenter.EarliestDate = DateTime.Today
API.SalesOrderPresenter.ExistingStatus = SalesOrderStatus.Open
API.SalesOrderPresenter.Customer = API.LookupId(LookupFields.Customer, LookupColumns.Abbreviation, pCustomer)


API.SalesOrderPresenter.TransNumber = ptransno

Dim subline As SalesItemLineObject
subline = API.SalesOrderPresenter.AddSalesItemLine(2147469992, 0)
subline.LineValues.AddReplace(InputFieldTypes.QuantityOrdered, 100)
subline.LineValues.AddReplace(InputFieldTypes.SalesPrice, 12.5)

API.SalesOrderPresenter.CustomField1 = "AP"
API.SalesOrderPresenter.TransactionComment = "Add Sales Order"
API.SalesOrderPresenter.MemoLine1 = "Memo Line 1 text"
API.SalesOrderPresenter.MemoLine2 = "Memo Line 2 text"
API.SalesOrderPresenter.BillingLocation = 2147469995
API.SalesOrderPresenter.ShippingLocation = 2147469995


API.SalesOrderPresenter.CalculateTotals(False)
API.SalesOrderPresenter.SaveTransaction(True)
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.