Get selling price for inventory  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Get selling price for inventory

Postby SBarnes » Tue Nov 16, 2021 12:33 pm

How can I in c# get a sell price for an inventory object such as P1 based upon its effective date, i.e. at today's date?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1621
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 176

Re: Get selling price for inventory

Postby Mike.Sheen » Fri Nov 26, 2021 12:32 pm

SBarnes wrote:How can I in c# get a sell price for an inventory object such as P1 based upon its effective date, i.e. at today's date?


The sure-fire lazy method is to use a price scheme - create a disposable price scheme, add the sell price 1 stored proc to it, call the GetPrice method with the InventoryID, DebtorID, WarehouseId and date and quantity, then discard the price scheme without saving it.

Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GetInventorySellPriceAsAtDate
{
    class Program
    {
        static void Main(string[] args)
        {
            JiwaFinancials.Jiwa.JiwaApplication.Manager manager = new JiwaFinancials.Jiwa.JiwaApplication.Manager();
            manager.Logon("localhost", "JiwaDemo721-3", JiwaFinancials.Jiwa.JiwaODBC.database.AuthenticationModes.JiwaAuthentication, "Admin", "password");

            JiwaFinancials.Jiwa.JiwaPriceSchemes.PriceScheme priceScheme = manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaPriceSchemes.PriceScheme>(null);
            priceScheme.CreateNew();
            JiwaFinancials.Jiwa.JiwaPriceSchemes.PriceUsed usedPrice = manager.CollectionItemFactory.CreateCollectionItem<JiwaFinancials.Jiwa.JiwaPriceSchemes.PriceUsed>();
            usedPrice.Price = manager.CollectionItemFactory.CreateCollectionItem<JiwaFinancials.Jiwa.JiwaPriceSchemes.Price>();
            usedPrice.Price.IsStoredProc = true;
            usedPrice.Price.StoredProcName = "usp_Jiwa_Price_SellPrice1";
            priceScheme.PriceUsedCollection.Add(usedPrice);

            JiwaFinancials.Jiwa.JiwaApplication.Entities.Inventory.Inventory inventory = manager.EntityFactory.CreateEntity<JiwaFinancials.Jiwa.JiwaApplication.Entities.Inventory.Inventory>();
            inventory.ReadRecordFromPartNo("1170");

            JiwaFinancials.Jiwa.JiwaApplication.Entities.Debtor.Debtor debtor = manager.EntityFactory.CreateEntity<JiwaFinancials.Jiwa.JiwaApplication.Entities.Debtor.Debtor>();
            debtor.ReadRecordFromAccountNo("1001");

            decimal price = 0;
            bool priceIsIncTax = false;
            priceScheme.GetPrice(JiwaFinancials.Jiwa.JiwaPriceSchemes.PriceScheme.PriceSchemePriceChangeOrigin.e_PriceSchemePriceChangeOriginSalesOrder, null, inventory.InventoryID, debtor.DebtorID, DateTime.Now, "ZZZZZZZZZZ0000000000", 1, ref price, ref priceIsIncTax);

            Console.WriteLine("Price is {0}", price);
        }
    }
}



Or you can just call the stored proc directly.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2445
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 757

Re: Get selling price for inventory  Topic is solved

Postby SBarnes » Fri Nov 26, 2021 12:39 pm

Thanks Mike,

But I wasn't after it for a given debtor, my request was unclear sorry, what I was actually after was

Code: Select all
Inventory.SellingPrices["P1"].get_CurrentPrice(this.get_Manager().SysDateTime);


depending on the decompiler you can get you can get

Code: Select all
Inventory.SellingPrices["P1"][this.get_Manager().SysDateTime];


which won't compile in a plugin.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1621
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 176


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 6 guests