Hot Topic (More than 10 Replies) Inventory Control, Programming Question (Read 1616 times)
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Inventory Control, Programming Question
Jun 3rd, 2005 at 6:13pm
Print Post Print Post  
Hello
I have form (orders) that xposts a (cost) onto the form (inventory). I also have a form (sales) that does an xlookup and retrieves a (sales price) from the (inventory) form. The (inventory) form takes the (cost) and calculates the (sales price).
My question is how can I get the (inventory) form to calculate the sales price without going into the (inventory) form every time? Can I put the calculation in global code?

Thank you for any help
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Inventory Control, Programming Question
Reply #1 - Jun 3rd, 2005 at 9:13pm
Print Post Print Post  
How are you calculating Sales Price?  Is it a certain markup % over the cost? 

Calculate the Sales Price on the Sales form, not in inventory.  On the Sales form, look up the Cost from the Inventory, and muliptly that times the quantity.

If different inventory items have different markup %, can you make some type of MarkupClass, and then make a database for MarkupClass values to use when calculating Sales price in Sales form.

Example: 
1.  Every inventory item has a MarkupClass value based on type of inventory.

2.  Inventory items: hardware = MarkupClass A, software = MarkupClass C, Packaging = MarkupClass B.

3.  MarkupClass database records: A=20%, B=33%, C=50%

4a.  Sales form does LU of Inventory item fields including Cost and MarkupClass. 

4b.  Sales Price = XLU(....Cost...)  x XLU(......MarkupClass.......)



  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: Inventory Control, Programming Question
Reply #2 - Jun 4th, 2005 at 5:54pm
Print Post Print Post  
Thank you Bob
A very refreshing perspective! I seem to have over thought the situation.
My next question would be how I could compare my marked up price to what the factory list price is? The factory list price is on the inventory form. Sometimes the factory list price is higher than my markup and some times its not. I would like to use the greater of the two values.
Anyway you look at it yours is a much better idea and will take a lot less work (another benefit) 
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Inventory Control, Programming Question
Reply #3 - Jun 4th, 2005 at 7:29pm
Print Post Print Post  
No time for code, but use @Max() math function, something like this structure:

SalesPrice= @max( @XLU(..ListPrice...) ,   @XLU(...Cost..) * (@XLU(...MarkupClass...) )
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: Inventory Control, Programming Question
Reply #4 - Jun 4th, 2005 at 9:16pm
Print Post Print Post  
very helpful, thank you
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: Inventory Control, Programming Question
Reply #5 - Jun 5th, 2005 at 9:08pm
Print Post Print Post  
Ok, it looks like Im going to need help on the code. Kind of looks like this

If @IsBlank(lp1) then
     lp1 = @max(@XLU(@fn, brp_1, "brpinv!brp_no", "cost"), @XLU(@fn, brp_1, "brpinv!brp_no", "brp list") * (1.3))

I get a type mismatch error with the * multiplier. Would a variable be better?
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Inventory Control, Programming Question
Reply #6 - Jun 5th, 2005 at 9:33pm
Print Post Print Post  
XLus are returning Strings.  Need to convert to Numbers

If @IsBlank(lp1) then 
lp1 = @max(@ToNumber(@XLU(@fn, brp_1, "brpinv!brp_no", "cost")), @ToNumber(@XLU(@fn, brp_1, "brpinv!brp_no", "brp list")) * (1.3))

[/color][/b]
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: Inventory Control, Programming Question
Reply #7 - Jun 5th, 2005 at 10:58pm
Print Post Print Post  
Bob
Do you never rest? I was not expecting you to get back so fast. Your help is greatly appreciated. I think I will end up using a variable so I can produce the mess you see below. Any criticism or critiquing would also be appreciated.

var vCost as Double
var vPrice as Double
var vBPrice as Double

//vcost is our cost
//vprice = factory list price
//vbprice is our list price

If @isblank(lp1) then {
     vCost = @xlu(@fn, brp_1, "brpinv!brp_no", "cost")
     vPrice = @xlu(@fn, brp_1, "brpinv!brp_no", "list1")
}

if brp_1 = "oliv0038" then
vBPrice = vPrice else
if vCost > 0.00 and vCost < 3.01 then vBPrice = "6.50"
if vCost > 3.00 and vCost < 10.01 then vBPrice = vCost * 2
if vCost > 10.00 and vCost < 20.01 then vBPrice = vCost * 1.9
if vCost > 20.00 and vCost < 30.01 then vBPrice = vCost * 1.8
if vCost > 30.00 and vCost < 40.01 then vBPrice = vCost * 1.7
if vCost > 40.00 and vCost < 50.01 then vBPrice = vCost * 1.6
if vCost > 50.00 and vCost < 60.01 then vBPrice = vCost * 1.5
if vCost > 60.00 and vCost < 70.01 then vBPrice = vCost * 1.4
if vCost > 70.00 and vCost < 100.01 then vBPrice = vCost * 1.3
if vCost > 100.00 then vBPrice = vCost * 1.2

If vPrice > vBPrice lp1 = vPrice
If vBPrice > vPrice lp1 = vBPrice

thanks again for your help!
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Inventory Control, Programming Question
Reply #8 - Jun 6th, 2005 at 12:43am
Print Post Print Post  
1.  One comment: You can add your comments to the same line as your variables, makes it a bit easier to read.

var vCost as Double           //vcost is our cost
var vPrice as Double          //vprice = factory list price
var vBPrice as Double        //vbprice is our list price

2.  Good job FlipGilbert.  The only thing I would suggest is to remove the dollar ranges and put them into their own database for XLR lookups.  Current method is "hard-coded" requiring programming if changes are needed.  By having a Markup database for lookups, you can just change the values in the database, add new records if needed.  It may just be a personal design criteria, but I try to avoid hardcoding anything that might be changed in the future.

Markup database would have two values: Lower limit and multiple factor, like: 100,1.2 / 70,1.3 / 60,1.4, etc.  @XLR would find the closest highest value and use that multiplier.

But, you don't need to do that, just my own observation.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: Inventory Control, Programming Question
Reply #9 - Jun 6th, 2005 at 1:04am
Print Post Print Post  
Thank you Bob
I like your ideas, I like the idea also on having a markup database and not hard coding everything, could you explain that?
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Inventory Control, Programming Question
Reply #10 - Jun 6th, 2005 at 4:19am
Print Post Print Post  
Create a database named MarkUp. Fields as noted above, nine records based on your example at this time:

               LowerLimit     Multiplier
Record 1:               100      1.2
Record 2:                 70      1.3
Record 3:                 60      1.4
...
...
Record 9:                  3        2.0
-----------------------------

Change code as follows:

Code
Select All
var vCost as Double     //vcost is our cost
var vPrice as Double		  //vprice = factory list price
var vBPrice as Double		//vbprice is our list price
var vMultiplier as Double	  //From MarkUp database

If @isblank(lp1) then {
    vCost = @xlu(@fn, brp_1, "brpinv!brp_no", "cost")
    vPrice = @xlu(@fn, brp_1, "brpinv!brp_no", "list1")
    If vCost>2.99 then {
	   vMultiplier = @XLR(@fn, vCost, frmMarkUp!LowerLimit", "Multiplier")
	  }
    }

if brp_1 = "oliv0038" then {
     vBPrice = vPrice else {
	    vBPrice = vCost * vMultiplier
	    If vCost<3.00 then {
		  vBPrice=6.50 //No multiplier for vCost under $3.00
		  }
	    }
   }

If vPrice > vBPrice lp1 = vPrice
If vBPrice > vPrice lp1 = vBPrice 



Note that code here is untested.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
FlipGilbert
Full Member
***
Offline


Running Ver 2.6.4

Posts: 236
Location: Sandy Eggo
Joined: Mar 8th, 2005
Re: Inventory Control, Programming Question
Reply #11 - Jun 6th, 2005 at 6:42pm
Print Post Print Post  
Bob
Very very nice! I like being able to adjust pricing on the fly. I even added a date field to the markup form to show the date of the last adjustment. Works beautifully

you note your code as untested is comparable to Burt Rutan saying I think it will fly.
Thank you for your help and words of encouragement. This is what it will look like


var vCost as Double     //vcost is our cost
var vPrice as Double    //vprice = factory list price
var vBPrice as Double  //vbprice is our list price
var vMultiplier as Double   //From MarkUp database
 
If @isblank(lp1) then {
    vCost = @xlu(@fn, brp_1, "brpinv!brp_no", "cost")
    vPrice = @xlu(@fn, brp_1, "brpinv!brp_no", "list1")
    If vCost > 2.99 then {
    vMultiplier = @XLR(@fn, vCost, "MarkUp!LowerLimit", "Multiplier")
   }   
    }
 
vBPrice = vCost * vMultiplier
     If vCost < 3.00 then {
    vBPrice = 6.50 //No multiplier for vCost under $3.00 
    }


If vPrice > vBPrice lp1 = vPrice
If vBPrice > vPrice lp1 = vBPrice

If brp_1 = "oliv0038" Then
lp1 = vPrice
  

It's not what a man says that matters or how he says it, but what he does and how he does it.
Back to top
 
IP Logged