Global
Price Updates Hook (R-GPA.MAC)
The script file must be located in your CAPITAL program directory and must have the file name R-GPA.MAC. A sample script can be found in your \CAPITAL\MAC directory.
Entry Values
|
Variable |
Purpose |
|
Stock->X |
You may query the contents of the fields of the stock record. |
|
Staux000->X |
You may query the contents of any user fields if applicable. |
Return Values
If you execute a script CAPITAL ignores the Apply All Formulas and Price To Adjust fields if the script returns a value of FALSE. These parameters can then be controlled by the script. If you return another value (TRUE is recommended) CAPITAL will update pricing as normal. This is useful if you want selective control over which stock item prices are changed. Return FALSE when you don't want a certain type of stock record price changed, otherwise return TRUE.
Comments
CAPITAL will still only execute the script in accordance with the other conditions you specify; such as
for the stock groups you have selected.
The procedure for executing a script is as follows:
1. Place your script in your CAPITAL program directory. The script must be in the file named R-GPA.MAC
2. Start the Global Price Adjustment Utility.
3. Tick
Apply All Formulas and press the Update button.
Example #1 - Update On Keyword
The following script updates pricing in Stock Control for any product description containing the character string "BEEANCO". Upper and lower case wordings will be matched. Price A in Stock Control is increased by 20% when a match is found.
Note the use of the $ operator which means "within".
* Sample price update script that increases the "A" price
* in Stock Control by 20% each time it is run.
* Only product descriptions containing the word "BEEANCO"
* are updated.
If ( .NOT. "BEEANCO" $ Upper(stock->Title) ) Goto End
Write("A", A * 1.2)
:End
* Return FALSE to prevent default price updating to occur
Return FALSE
Example #2 - Coin Rounding
The following script will check the last digit of price A in Stock Control. If the last digit is between the range 3-7, it is assigned the value of 5. Otherwise, the number is rounded to 1 decimal point accuracy. Therefore any number where the last digit is 8 or higher is rounded up to the nearest 10c. Any number below 3 is rounded down to the nearest 10c.
* This script adjusts stock price A if the A price
* is greater than $5.00
* If last digit of price is 3-7, last digit is set to 5,
* Otherwise number is rounded up or down to nearest 10c
* Assumes 2 decimal point rounding in Stock Control
If ( stock->A < 5.00 ) Goto End
* If last digit 3-7, set last digit to 5
If Right(Str(Stock->A, 15, 2), 1) $ "34567"
Write("A", AsVal(Left(Str(Stock->A, 15, 2), 14) + "5"))
Goto End
Endif
* Round to 1 decimal
Write("A", Round(Stock->A, 1))
:End
* Return FALSE to prevent default price updating to occur
Return FALSE
____________________________
Related Topics:
![]() |