CALPFM: Adding an additional cost to the production cost calculated before the m

This entry point concerns the calculation of the margin in sales.

It is used to add an additional cost to the production cost calculated by X3 before the calculation of the margin.

It is called in every processing performing a margin calculation.

Context and operating mode

Transaction

There is no transaction in progress when the entry point is called from a line entry (quote, order, delivery, invoice, credit memo).

There is a transaction in progress when the entry point is called from:

.          The delivery button from the order management, the validation button from the delivery management

.          The automatic order delivery and automatic delivery validation functions

.          The invoice button from the order management, the validation button from the invoice management

.          The automatic order invoicing and automatic invoice validation functions.

.          The contract management.

.          The creation of a credit memo line with stock transaction.

.          The modification window of the stock issues in delivery management

.          The price adjustment function

 Log file

There is no open log file when the entry point is called from the line entry (quote, order, delivery, invoice, credit memo), the creation of a credit memo line on stock transaction, the modification window of the stock issues in delivery management.

There is an open log file when in the delivery or automatic invoicing of orders or automatic validation of deliveries or invoices, price adjustment functions.

Different call cases - Available variables and masks

A ‘GCALPFM’ global variable is used to identify these different call cases.     

            GCALPFM = 0           Quote, order, delivery, invoice, credit memo line

            GCALPFM = 1           "Delivery" button or "Automatic delivery" function

            GCALPFM = 2           "Delivery validation" button or "Delivery validation " function

            GCALPFM = 3           "Invoice" button (from an order) or "Automatic invoicing of orders" function

            GCALPFM = 4           "Invoice validation" button or "Invoice validation" function

            GCALPFM = 5          Entry of contracts

            GCALPFM = 6          Creation of a credit memo line with stock transaction.

            GCALPFM = 7          Modification window of the stock issues in delivery management

            GCALPFM = 8          Price adjustment function

It can thus be necessary to test this variable in order to use the correct context. 

This entry point is called:

tab.           In the sub-program of the margin calculation (GCALPFM=0)

This sub-program is a sub-program common to all the sales functions. It is called upon each line entry (quote, order, delivery, invoice, credit memo), each time the margin must be recalculated:

·               After entering the quantity

A price list search is carried out to recover the gross price. The net price is calculated and then the margin.

·               After modification of the gross price or a charge/discount column. Such a modification leads to a recalculation of the net price and as a result a recalculation of the margin.

·               After validation of the line

The screen class linked to the processed object is loaded ([M:SQH], [M:SOH], [M:SDH], [M:SIH]). The location is now within the CALPFM sub-program.

The following variables are the variables passed as parameters in the sub-program:

·               MSK               :           Screen class (if not specified, MSK is loaded with [M])

·               NLIG               :           Index of the line in the grid.

·               PRI                 :           Net price of the line.

·               VAT                :           Grid for the 3 tax codes for the line (VAT(0), VAT(1), VAT(2))

·               PRITYP          :           Price type for the document

·               SIT                  :           Stock site

·               LITM              :           Product reference

·               CHGTYP        :           Exchange rate type

·               DAT                :           Date of the document

·               CUR               :           Currency of the document

·               COEF             :           Conversion coefficient order unit/stock unit for the line.

·               INICPRPRI      :           Init. flag of cost price (0=No init.,1=Init. without rtz,2=Init. with rtz)

·               XSTOMGTCOD:           Stock update flag

The following variables are work variables calculated by the sub-program:

·               PHTNET         :           Net price used in the calculation of the margin (Ex-tax price)

·               WQTY            :           Quantity in stock unit

·               COUTHT        :           Calculated cost price

The following variables are the variables calculated and sent by the sub-program:

·               XPFM             :           Margin

·               XCPRPRI:           Cost price

The calculation of the margin and therefore the entry point are called only when the INICPRPRI variable is equal to 1 or 2.

 .           During the delivery of an order via button or the automatic delivery function (GCALPFM=1)

The recalculation of the margin is carried out when loading the delivery line detail from the order line detail upon creation of a delivery line. This is just before the entry of the delivery line detail.

The [F :SOH], [F :SOQ], [F :SOP] buffers are loaded with the order to deliver. [F :SDH], [F :SDD] are loaded with the delivery being created. The [F :ITM], [F :ITS] buffers are loaded with the product.

.           During the validation of a delivery by button or by the automatic validation of deliveries function (GCALPFM=2)

The recalculation of the margin is carried out for products managed in stock, before updating the stocks.

The [F :SDH], [F :SDD] buffers, as well as the [F :ITM], [F :ITS] buffers are loaded.

.           During the invoicing of an order by button or by the automatic invoicing of orders function (GCALPFM=3)

The calculation of the margin is carried out when loading the invoice line detail from the order line detail upon creation of an invoice line. This is just before the entry of the delivery line detail.

The [F :SOH], [F :SOP], [F :SOQ] buffers are loaded with the order to invoice. [F :SIH], [F :SIV], [F :SID] are loaded with the invoice being created. The [F :ITM], [F :ITS] buffers are loaded with the product.

.           During the validation of an invoice by button or by the automatic validation of invoices function (GCALPFM=4)

            The recalculation of the margin is carried out for the order invoices and the products managed in stock before updating the stocks.

The [F :SIH], [F :SIV], [F :SDD] buffers, as well as the [F :ITM], [F :ITS] buffers are loaded.

.           In contract management (GCALPFM=5)

The recalculation of the margin is carried out when modifying a contract if the tax rule has been modified. It is, in fact, necessary, to perform again the tax code search for each product line. If price lines have been entered for this product line, it is also necessary to recalculate the Ex-tax and Tax incl prices and the margin.

This processing is carried out when saving the modification, in the contract update transaction, at the level of the AVANT_MODFIC action.

The [F :SOH], [F :SOC], [F :SOP] buffers are loaded with the contract, the product line and the price line. The screen class [M:SOR1] is also loaded with the contract. The [F :ITM], [F :ITS] buffers are loaded with the product.

.           Upon creation of a credit memo line with stock transactions for a product whose margin calculation basis is the batch average price (GCALPFM=6)

The margin calculation is carried out again upon line creation. At this level, the context is not the same as upon line entry. The calculation is carried out in the INICRE_LIG action of this object, when loading the [F:SID] invoice detail line from the [M:SIH4] screen. The NOL(nolign-1) variable contains the index of the line being created in the [M:SIH4] line grid.  

The [F :SIH], [F :SIV], [F :SID] buffers are loaded with the credit memo being created. The invoice object screens are loaded with the credit memo being created. One is positioned just before writing the [F:SID] record. Recordings [F :SIH], [F :SIV] are written. The [F :ITM], [F :ITS] buffers are loaded with the product.

.           When modifying stock issues on a validated delivery from the Actions icon on the "Modification of issues" lines in delivery management (GCALPFM=7)

Modifying issues can trigger a recalculation of the cost price if the lot is modified and the margin calculation basis corresponds to the lot average price. The calculation is carried out in the ENR action of the SAISTOSORM action during the additional updates performed after modifications on stocks are saved.  

The [F :SDH], [F :SDD] buffers are loaded with the delivery. The [F :ITM], [F :ITS] buffers are loaded with the product.  The [M:SOM] screen class (issue modification screen) is on line.

.           During the price adjustment from the Price adjustment function (GCALPFM=8) that can update the value of the stock transactions linked to a delivery

This function can update the value of stock transactions linked to a delivery. It recalculates the average cost and the margins.

The [F :SDH], [F :SDD] buffers are loaded with the delivery. The [F :ITM], [F :ITS] buffers are loaded with the product. 

In all cases:

The COUTHT variable contains the calculated cost price.

The entry point is located just after the call to the cost price calculation sub-program and just before the margin calculation. The following variables are used:

·               WPOINT_COUT (local decimal)      :

It is initialized before the entry point is called. This is the additional cost to impact on the margin. The entry point must load it.

·               WPOINT_RET (local integer)                       :

It is initialized to 0 before the entry point is called. This is the variable for the status of return. The entry point must set it to 1 so that WPOINT_COUT can be used.

The entry point must therefore position this 2 variables.

On exiting the entry point, if WPOINT_RET is set to 1, the new cost price is calculated:

COUTHT= COUTHT+WPOINT_COUT

The margin is calculated :

PFM=PHTNET-COUTHT 

Important notes :          

The X3 cost price is calculated in the company currency (given by the GLOCALDEV global variable). It is converted into the document currency if this currency is different to GLOCALDEV.

It is therefore necessary that WPOINT_COUT is returned in the document currency.

The X3 cost price is calculated in stock unit. It is converted into order unit. (it is multiplied by the COEFF variable that corresponds to the conversion coefficient SAL-STK).

It is therefore necessary that WPOINT_COUT is sent in order unit.

The margin calculation sub-program being common to all the functions, it is necessary to know the context, it will be necessary to use the GCALPFM variable as indicated previously.

CALPFM1: Calculation of the margin cost price

This entry point concerns the calculation of the cost price and of the margin in sales.

It is used to directly intervene on the calculated cost price and the margin in order to modify them.

It is called in every processing performing a margin calculation.

Context and operating mode

Transaction

There is no transaction in progress when the entry point is called from a line entry (quote, order, delivery, invoice, credit memo).

There is a transaction in progress when the entry point is called from:

.          The delivery button from the order management, the validation button from the delivery management

.          The automatic order delivery and automatic delivery validation functions

.          The invoice button from the order management, the validation button from the invoice management

.          The automatic order invoicing and automatic invoice validation functions.

.          The contract management.

.          The creation of a credit memo line with stock transaction.

.          The modification window of the stock issues in delivery management

tab.          The price adjustment function

 Log file

There is no open log file when the entry point is called from the line entry (quote, order, delivery, invoice, credit memo), the creation of a credit memo line on stock transaction, the modification window of the stock issues in delivery management.

There is an open log file when in the delivery or automatic invoicing of orders or automatic validation of deliveries or invoices, price adjustment functions.

Different call cases - Available variables and masks

A ‘GCALPFM’ global variable is used to identify these different call cases.     

            GCALPFM = 0           Enter quote, order, shipment, invoice, credit memo line

            GCALPFM = 1           "Delivery" button or "Automatic delivery" function

            GCALPFM = 2           "Delivery validation" button or "Delivery validation " function

            GCALPFM = 3           "Invoice" button (from an order) or "Automatic invoicing of orders" function

            GCALPFM = 4           "Invoice validation" button or "Invoice validation" function

            GCALPFM = 5          Entry of contracts

            GCALPFM = 6          Creation of a credit memo line with stock transaction.

            GCALPFM = 7          Modification window of the issues in delivery management

            GCALPFM = 8          Price adjustment function

It can thus be necessary to test this variable in order to use the correct context.

 

This entry point is called:

tab.           In the sub-program of the margin calculation (GCALPFM=0)

This sub-program is a sub-program common to all the sales functions. It is called upon each line entry (quote, order, delivery, invoice, credit memo), each time the margin must be recalculated:

·               After entering the quantity

A price list search is carried out to recover the gross price. The net price is calculated and then the margin.

·               After modification of the gross price or a charge/discount column. Such a modification leads to a recalculation of the net price and as a result a recalculation of the margin.

·               After validation of the line

The screen class linked to the processed OBJect is loaded ([M:SQH], [M:SOH], [M:SDH], [M:SIH]). The location is now within the CALPFM sub-program.

The following variables are the variables passed as parameters in the sub-program:

·               MSK               :           Screen class (if not specified, MSK is loaded with [M])

·               NLIG               :           Index of the line in the grid.

·               PRI                 :           Net price of the line.

·               VAT                :           Grid for the 3 tax codes for the line (VAT(0), VAT(1), VAT(2))

·               PRITYP          :           Price type for the document

·               SIT                  :           Stock site

·               LITM                :           Product reference

·               CHGTYP        :           Exchange rate type

·               DAT                :           Date of the document

·               CUR               :           Currency of the document

·               COEF             :           Conversion coefficient order unit/stock unit for the line.

·               INICPRPRI      :           Init. flag of cost price (0=No init.,1=Init. without rtz,2=Init. with rtz)

·               XSTOMGTCOD:           Stock update flag

The following variables are work variables calculated by the sub-program:

·               PHTNET         :           Net price used in the calculation of the margin (Ex-tax price)

·               WQTY            :           Quantity in stock unit

·               COUTHT        :           Calculated cost price

The following variables are the variables calculated and sent by the sub-program:

·               XPFM             :           Margin

·               XCPRPRI:           Cost price

The entry point is called regardless of the value of the INICPRPRI variable.

.           During the delivery of an order via button or the automatic delivery function (GCALPFM=1)

The recalculation of the margin is carried out when loading the delivery line detail from the order line detail upon creation of a delivery line. This is just before the entry of the delivery line detail.

The [F :SOH], [F :SOQ], [F :SOP] buffers are loaded with the order to deliver. [F :SDH], [F :SDD] are loaded with the delivery being created. The [F :ITM], [F :ITS] buffers are loaded with the product.

.           During the validation of a delivery by button or by the automatic validation of deliveries function (GCALPFM=2)

The recalculation of the margin is carried out for products managed in stock, before updating the stocks.

The [F :SDH], [F :SDD] buffers, as well as the [F :ITM], [F :ITS] buffers are loaded.

.           During the invoicing of an order by button or by the automatic invoicing of orders function (GCALPFM=3)

The calculation of the margin is carried out when loading the invoice line detail from the order line detail upon creation of an invoice line. This is just before the entry of the delivery line detail.

The [F :SOH], [F :SOP], [F :SOQ] buffers are loaded with the order to invoice. [F :SIH], [F :SIV], [F :SID] are loaded with the invoice being created. The [F :ITM], [F :ITS] buffers are loaded with the product.

.           During the validation of an invoice by button or by the automatic validation of invoices function (GCALPFM=4)

            The recalculation of the margin is carried out for the order invoices and the products managed in stock before updating the stocks.

The [F :SIH], [F :SIV], [F :SDD] buffers, as well as the [F :ITM], [F :ITS] buffers are loaded.

.           In contract management (GCALPFM=5)

The recalculation of the margin is carried out when modifying a contract if the tax rule has been modified. It is, in fact, necessary, to perform again the tax code search for each product line. If the price lines have been entered for this product line, it is also necessary to re-calculate the Ex-tax and Tax incl prices and the margin.

This processing is carried out when saving the modification, in the contract update transaction, at the level of the AVANT_MODFIC action.

The [F :SOH], [F :SOC], [F :SOP] buffers are loaded with the contract, the product line and the price line. The screen class [M:SOR1] is also loaded with the contract. The [F :ITM], [F :ITS] buffers are loaded with the product.

.           Upon creation of a credit memo line with stock transactions for a product whose margin calculation basis is the batch average price (GCALPFM=6)

The margin calculation is carried out again upon line creation. At this level, the context is not the same as upon line entry. The calculation is carried out in the INICRE_LIG action of this object, when loading the [F:SID] invoice detail line from the [M:SIH4] screen. The NOL(nolign-1) variable contains the index of the line being created in the [M:SIH4] line grid.  

The [F :SIH], [F :SIV], [F :SID] buffers are loaded with the credit memo being created. The invoice object screens are loaded with the credit memo being created. One is positioned just before writing the [F:SID] record. Recordings [F :SIH], [F :SIV] are written. The [F :ITM], [F :ITS] buffers are loaded with the product.

.           When modifying stock issues on a validated delivery from the Actions icon on the "Modification of issues" lines in delivery management (GCALPFM=7)

Modifying issues can trigger a recalculation of the cost price if the lot is modified and the margin calculation basis corresponds to the lot average price. The calculation is carried out in the ENR action of the SAISTOSORM action during the additional updates performed after modifications on stocks are saved.  

The [F :SDH], [F :SDD] buffers are loaded with the deliveries. The [F :ITM], [F :ITS] buffers are loaded with the product.  The [M:SOM] screen class (issue modification screen) is on line.

.           During the price adjustment from the Price adjustment function (GCALPFM=8) that can update the value of the stock transactions linked to a delivery

This function can update the value of stock transactions linked to a delivery. It recalculates the average cost and the margins.

The [F :SDH], [F :SDD] buffers, as well as the [F :ITM], [F :ITS] buffers are loaded with the delivery.  

In all cases:

The entry point is located just after the call to the cost price calculation sub-program and just after the margin calculation.

The XPFM variable contains the calculated margin.

The XCPRPRI variable contains the calculated cost price.

The entry point is thus used to intervene on these 2 variables.

Important notes :          

The XCPRPRI cost price and the XPFM margin are calculated for a sales unit and in the document currency.

These 2 values must be rounded based on the number of decimals of the GDECPRI price.

The margin calculation sub-program being common to all the functions, it is necessary to know the context, it will be necessary to use the GCALPFM variable as indicated previously. 

DSPCTLPFM: Modification of the display of the margin control message

This entry point concerns the control of the margin in sales.

It is used to intervene during the display of the message warning the user that the margin is less than the minimum margin defined in the product-sales record. It is used to either modify the message or not to carry out the control.

It is called upon each control of the margin calculation.

Context and operating mode

Transaction

There is no transaction in progress. 

Log file

There is no open log file.

Different call cases - Available variables and masks

The entry point is called in the CTLPFM margin control sub-program.

This sub-program is called during the entry of the lines for the quote, orders, contact-product, deliveries, invoices at the end of the line and every time an element involved in the margin calculation is modified (after each price list search, after modification of the shipping site, the charges/discounts, the cost price). This sub-program is common to all the sales functions.

The screen class linked to the processed object is loaded ([M:SQH], [M:SOH], [M:SDH], [M:SIH], [M:SOI]). The location is now within the CTLPFM sub-program.

The following variables are the variables passed as parameters in the sub-program:

·               CUR               :           Currency of the document

·               XCPRPRI       :           Cost price of the line

·               NLIG               :           Index of the line in the grid. Not entered and not significant if contract-product.

The following variables are loaded:

·               WITMREF      :           Product reference

·               WSAU            :           Sales unit

·               PFMRAT        :           % of the calculated margin.

When the entry point is called, the calculation of the % margin has been carried out, this % is less than the minimum % defined in the product-sales record.

GMESSAGE is loaded with the message to be displayed.

The entry point is used to modify this message. To that purpose, the GMESSAGE variable must be modified.  If GMESSAGE is reset, no message will be displayed and the control will not be active (no warning nor blocking).

Open tables

In the table below, the significant content flag indicates that the content matches the context (the current customer is loaded…).

Table

Significant content

Table Title

ITMSALES

Yes

Product-sales

 

DSPCTLPRI: Modification of the display of the net price control message.

This entry point concerns the control of the net price in sales.

It is used to intervene during the display of the message warning the user that the net price is less than the minimum price defined in the product-sales record. It is used to either modify the message or not to carry out the control.

It is called during each control of the net price calculation.

Context and operating mode

Transaction

There is no transaction in progress. 

Log file

There is no open log file.

Different call cases - Available variables and masks

The entry point is called in the CTLNETPRI net price control sub-program.

This sub-program is called during the entry of the lines for quotes, orders, contact-product, deliveries, invoices at the end of the line and every time an element involved in the net price calculation is modified (after each price list search, after modification of the conversion coefficient SAL-STK, the charges/discounts). This sub-program is common to all the sales functions.

The screen class linked to the processed object is loaded ([M:SQH], [M:SOH], [M:SDH], [M:SIH], [M:SOI]). The location is now within the CTLNETPRI sub-program.

The following variables are the variables passed as parameters in the sub-program:

·               BPC               :           Customer

·               CHGTYP         :           Price type

·               DAT               :           Date

·               CUR               :           Currency

·               NLIG               :           Index of the line in the grid. Not entered and not significant if contract-product.

The following variables are loaded:

·               WITMREF        :           Product reference

·               WSAU            :           Sales unit

·               WNETPRINOT  :           Ex-tax net price

·               MONT             :           Calculated minimum price (converted in the right unit and currency).

When the entry point is called, the calculation of the ex-tax net price is carried out, this ex-tax net price is less than the minimum price defined in the product-sales record.

GMESSAGE is loaded with the message to be displayed.

The entry point is used to modify this message. To that purpose, the GMESSAGE variable must be modified.  If GMESSAGE is reset, no message will be displayed and the control will not be active (no warning nor blocking).

Open tables

In the table below, the significant content flag indicates that the content matches the context (the current customer is loaded…).

Table

Significant content

Table Title

ITMSALES

Yes

Product-sales

ITMMASTER

Yes

Product

 

CALPFM0: Calculation of the ex-tax net price, the net tax incl price and the mar

This entry point concerns the calculation of the ex-tax net price, the net tax incl price and the margin in sales.

It is used to intervene before the margin calculation when calculating the ex-tax net price and the net tax incl price.

It is called upon entry of a sales document line (quote, order, delivery, invoice, credit memo).

Context and operating mode

Transaction

There is no transaction in progress.

Log file

There is no open log file.

Different call cases - Available variables and masks

A WABREV variable is used to identify the context and in particular the processed document:

WABREV= SQH2 Quote line entry

WABREV= SOH4 Order line entry

WABREV= SDH1 Delivery line entry

WABREV= SIH4 Invoice line entry

The entry point is called in the margin calculation subprogram. This sub-program is a sub-program common to all the sales functions. It is called upon each line entry (quote, order, delivery, invoice, credit memo), each time the margin must be recalculated:

After entering the quantity

A price list search is carried out to recover the gross price. The net price and the margin are then calculated.

After modification of the gross price or a charge/discount column. Such a modification leads to a recalculation of the net price and the margin.

After validation of the line

The screen class linked to the processed OBJect is loaded ([M:SQH], [M:SOH], [M:SDH], [M:SIH]). The location is now within the CALPFM sub-program.

The following variables are the variables passed as parameters in the sub-program:

MSK: Screen class (if not specified, MSK is loaded with [M])

NLIG: Index of the line in the grid.

PRI: Net price of the line.

VAT: Grid for the 3 tax codes for the line (VAT(0), VAT(1), VAT(2))

PRITYP: Price type for the document

SIT: Stock site

LITM: Product reference

CHGTYP: Exchange rate type

DAT: Date of the document

CUR: Currency of the document

COEF: Conversion coefficient order unit/stock unit for the line.

INICPRPRI: Init. flag of cost price (0=No init.,1=Init. without rtz,2=Init. with rtz)

XSTOMGTCOD: Stock update flag

The following variables are work variables calculated by the sub-program:

. LQTY: Quantity in sales units

. WITMREF: Product reference

. LCLCAMT1: Tax calculation base amount1

. LCLCAMT2: Tax calculation base amount2

The entry point is located before the call to the sub-program calculating the net tax incl price according to the ex-tax net price in the case of a document in ex-tax, and calculating the ex-tax net price according to the net tax incl price in the case of a document in tax incl.

The margin calculation sub-program being common to all the functions, if it is necessary to know the context, the WABREV variable will need to be used as indicated previously.