How to let a manager to choose a vendor with best prices?

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Sep 16, 2011
Company: Oksley Shipping

Good afternoon!

I'm trying to create a helper for purchase order creation which allows a manager to choose where to buy items. I have imported price lists for several vendors and some items are cheaper in one company while others are cheaper in another. The delivery is free starting from some amount of the order.

So, after the user enters items and quantities in this document, and clicks Fill vendors, the Vendor column of the document's tabular section should be filled with vendors having cheapest price for that item. After that I need to allow a user to choose a vendor from a choice list which should contain values with presentations like "vendor (price)".

In the footer of that document the summary of the document should be displayed as:
vendor | amount | delivery cost

I know how to implement the summary, problems are:
The query to get best prices with vendors.
How to fill choice lists of vendor column fields.

The Vendor prices information register has Daily periodicity, Item and Vendor dimensions, and Price resource.

 
#2
People who like this:0Yes/0No
Active user
Rating: 7
Joined: Sep 26, 2012
Company: individual

Quote
The query to get best prices with vendors.
May be it can help you..
Code
Query = New Query;
Query.Text = "
|SELECT
|   VendorPrices.Vendor,
|   VendorPrices.Item,
|   VendorPrices.Price
|FROM
|   InformationRegister.VendorPrices.SliceLast(
|         &DateProcessing, Item IN (&Items)
|   ) AS VendorPrices
|Order By
|   VendorPrices.Price";
­
Query.SetParameter("DateProcessing", SomeDate);

 
#3
People who like this:1Yes/0No
Active user
Rating: 7
Joined: Sep 26, 2012
Company: individual

Quote
How to fill choice lists of vendor column fields.
You can fill choise list in OnChange event handler of some field, in my example it is column of tabular section.
Code
&AtClient
Procedure TabularSection1Attribute1OnChange(Item)
   Items.TabularSection1Attribute2.ChoiceList.Add("price1", "vendor1(price1)");
   Items.TabularSection1Attribute2.ChoiceList.Add("price2", "vendor2(price2)");
   Items.TabularSection1Attribute2.ChoiceList.Add("price3", "vendor3(price3)");
   
   Items.TabularSection1Attribute2.ChoiceListButton = True;
EndProcedure

 
#4
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Sep 16, 2011
Company: Oksley Shipping

Thank you, Ivan! That is a good start, but I get prices of all vendors in that query...

 
#5
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Sep 16, 2011
Company: Oksley Shipping

And maybe you could help also: I need to set Price and Vendor column values at a time when a user selects an item in the choice list.

 
#6
People who like this:0Yes/0No
Active user
Rating: 7
Joined: Sep 26, 2012
Company: individual

Quote
That is a good start, but I get prices of all vendors in that query...
Yes, and in query you can make different filters, like filter on item: Item IN (&Items)
in query
Code
SliceLast(
|         &DateProcessing, Item IN (&Items) AND Vendor = &Vendor
|   ) AS VendorPrices

after query
Code
Query.SetParameter("Items", Items);
Query.SetParameter("Vendor", Vendor);


Quote
I need to set Price and Vendor column values at a time when a user selects an item in the choice list
you can process value of selection in OnChange event handler

Edited: ivan avdonin - Nov 27, 2012 01:27 PM
 
#7
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Sep 16, 2011
Company: Oksley Shipping

If I could know the Vendor I would not need to search for a better price... Thus the filter for Vendor is not what I can use.

 
#8
People who like this:2Yes/0No
Just came
Rating: 0
Joined: Sep 3, 2012
Company:

Here is an example for both tasks in attachment (works on latest Small Business).

 
#9
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Sep 16, 2011
Company: Oksley Shipping

Thank you very much, Dmitrij! Works perfect for me!

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.