When we were hooking up RPCSHOPPINGCART_CREATEORDER to the UI and were determining what named params needed to be available for this program, we realized that we do not have access to the Stock Price List and therefore no access to unit prices for stock items needed to build the sales orders. This program is assuming that the unit prices are in SHOPPINGCART.USR<7>, but this field is intended to be used for 'price overrides' only for both stock and MOD items. The reason for not storing stock prices is because we would have old prices in carts when stock prices increases are done. To fix this issue, we've decided to use create a new global program that will return all unit prices for both Stock and MOD items in the cart. The price list will also be returned. This new program can then be called by any program that needs a Unit Price (stock and MOD cart value programs, stock and MOD order creation, etc).
We currently have two programs (FCT.CART.STOCKVALUE and FCT.CART.MODVALUE) that calculate the Total Stock Price and Total MOD Price of all items in a shopping cart. These programs are currently called when displaying the Cart Value on all Checkout Screens and also by the bundling program for FOB Code Setting as well as by a number of other programs. We would like to create a new global process using the code that is in these two VALUE programs that can be called by anything requiring a unit price (including the two VALUE programs). This new global program will also take into account whether the stock/MOD unit price has been overridden by CE.
RPC$SHOPPINGCARTITEM_SAVE - Write Billto Customer# (timeline 85-1):
The billto number should be written to the cart as soon as the first item is placed in the cart. Modify RPC$SHOPPINGCARTITEM_SAVE to write BILLTO.NBR to SHOPPINGCART.USR<10> if <10> is null.
RPC$SHOPPINGCART_CREATEORDER - Use Cart Billto # (timeline 85-2):
Modify RPC$SHOPPINGCART_CREATEORDER (and the stock/Convert Quote programs if used there) to get the billto customer# from SHOPPINGCART.USR<10> instead of using the named param BILLTO.NBR.
New BP FCT.CART.PRICES (timeline 85-3):
Remove the logic for stock items from FCT.CART.STOCKVALUE and move into FCT.CART.PRICES. Remove the logic from FCT.CART.MODVALUE and move into FCT.CART.PRICES (execute this logic when the quote# in SHOPPINGCART.USR<6,x> is not null.
- Receive an empty REC in the argument list. You will use this to pass back the price list and a multi-valued field of prices (associated with the items in SHOPPINGCART.USR<1>)
- Read SHOPPINGCART.USR using CONTACT.NBR and CART.NAME
- Get the Billto Customer# from SHOPPINGCART.USR<10> instead of reading from SLSCONTACT.USR<1>, because the contact may be working on behalf of another contact (if they are a master user).
- Loop through the items in the cart:
- If there's a price override for the item in SHOPPINGCART.USR<7,x>, return this price
- If the price wasn't overridden: When a MOD Item, execute the logic from FCT.CART.MODVALUE and when a Stock Item, execute the logic from FCT.CART.MODVALUE.
- Return the Price List that was used (from PRICE.RECALC) in REC<1>). Return this regardless of if there were any stock items in the cart or not.
- Return a unit price for every item in the cart in REC<2>
Make sure to add this new fuction to BP.INCLUDES LAD.DEFAULT.FUNCTIONS
Modify BP FCT.CART.STOCKVALUE (timeline 85-4):
- Remove the logic that gets the unit price for each stock item in the cart using the price list (this is the logic that you moved to FCT.CART.PRICES)
- Call BP FCT.CART.PRICES once outside of the loop passing a null record in the argument list
- The record will be returned to you with the price list in <1> and the unit prices of all items in the cart multi-valued in <2> (associated with Field 1 of the SHOPPINGCART.USR rec)
- Use the price for each Stock item and calculate the Total stock value
Modify BP FCT.CART.MODVALUE (timeline 85-5):
- Remove the logic that gets the unit price for each MOD item in the cart using QUHDR/QUDET (this is the logic that you moved to FCT.CART.PRICES)
- Call BP FCT.CART.PRICES once outside of the loop passing a null record in the argument list
- The record will be returned to you with the price list in <1> and the unit prices of all items in the cart multi-valued in <2> (associated with Field 1 of the SHOPPINGCART.USR rec)
- Use the price for each MOD item and calculate the Total MOD value
Modify LDLIB RPC$CREATE_STOCKORDER (timeline 85-6):
- Call FCT.CART.PRICES to get the unit prices for every stock item on the order. The program currently uses SHOPPINGCART.USR<7>, which is an override price
- Change the logic where you are using PRICE.LIST for the price list. Use the price list returned from FCT.CART.PRICES
- I don't think you need to change the CONVERT_QUOTE program. It's probably using the QUDET file for its info, which is fine