generate/cbs2.gif Quantity Calculation Hook (R-STCnn.MAC) generate/en72.jpg

Stock Tracing Component Only


 

The script file must be located in your CAPITAL program directory and must have the file name R-STCnn.MAC, where nn is the ID number of the stock tracing property for which you wish to calculate a quantity.

Entry Values

Variable

Purpose

Quantity

The quantity allotted.

nBackOrder

The invoice quantity back ordered (if applicable).

nID

The stock tracing property ID number.

cProperty

The property allotment description.

stock->

Stock control fields of the transaction line item.

staux000->

Stock control user fields of the transaction line item.

Return Values

If the script returns a numeric value, this is used as the quantity invoiced, ordered, purchased, etc.

Description

This script hook is used to calculate a quantity to sell, order, quote or purchase based on a Stock Tracing Component list of selected allotments.

You must incorporate into the script name the Stock Tracing Property Maintenance ID. The ID is the number in the first column of the Stock Tracing Property table. For example, the serial number property has an ID reference of 1, so the script name would be R-STC001.MAC. For the batch number property, which has an ID of 2, the script name would be R-STC002.MAC and so on.

You must also untick the property setting Maintain Quantity Relation to ensure that CAPITAL will permit the quantity relationship you calculate with this script.

The script is executed for every allotment made for each line item.

Example

You have created a property called "sheets" which tracks sheets of varies lengths and widths. You also wish to track the quantity carried of each stock item by the sheet. So if the Stock In quantity is 10 this means 10 sheets are held in stock.

In order to manage this relationship, you have created a user defined field in Stock Control called SQRMETRE which holds a number that indicates how many square metres make up a sheet of standard length and width.

The script property assignments typically take the following form:

10x5.0

12x3.0

08x2.5

The following script converts the assignment description to a square metre value by multiplying the length by the width. E.g., 10 x 5 = 50 square metres. It then divides this by the standard square metre size (held in SQRMETRE), to calculate the quantity sold in sheets or portions of sheets.

* Convert sheet sizes to square metres and use this

* to calculate the sheets or portions of sheets to place in the

* transaction's quantity (Qty) column.

 

* If the standard square metre size is not specified

* cannot calculate quantity ordered or sold

If staux000->SQRMetre = 0

   Return 0

Endif

 

Declare nLen Type Number

Declare nWidth Type Number

Declare nSQRMetre Type Number

* Grab the first number (width) of the property description

nWidth := Val(cProperty)

* Grab the number after the 'x' (the length)

nLen := Val(SUBSTR(cProperty, AT("X", UPPER(cProperty)) + 1))

* Length x Width = Square metres

nSQRMetre := nLen * nWidth

* Multiply the total square metres sold by the quantity alloted

* then divide this by the standard square meterage.

* Return the portion of a sheet sold based on the user's

* sheet allotments.

Return (nSQRMetre * Quantity) / staux000->SQRMetre

____________________________

Related Topics:

Stock Tracing Concepts

Scripting Hooks

Script Programming

 



Help Topic Map