Skip to content
Snippets Groups Projects
Commit c69ac3e4 authored by Maximilian Schröger's avatar Maximilian Schröger
Browse files

Produkt - Anzeigefelder, Product_lib.aod

parent bd00341a
No related branches found
No related tags found
No related merge requests found
......@@ -134,6 +134,10 @@
<entityField>
<name>STOCKCOUNT</name>
<caption>Stock</caption>
<contentType>NUMBER</contentType>
<outputFormat>#.##0</outputFormat>
<state>READONLY</state>
<valueProcess>%aditoprj%/entity/Product_entity/entityfields/stockcount/valueProcess.js</valueProcess>
</entityField>
<entityParameter>
<name>OrgId_param</name>
......@@ -145,10 +149,16 @@
<entityField>
<name>currentPurchasePrice</name>
<caption>Curr. purchase price</caption>
<contentType>NUMBER</contentType>
<outputFormat>#,##0.00 €</outputFormat>
<state>READONLY</state>
<valueProcess>%aditoprj%/entity/Product_entity/entityfields/currentpurchaseprice/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>currentSalesPrice</name>
<caption>Curr. sales price</caption>
<state>READONLY</state>
<valueProcess>%aditoprj%/entity/Product_entity/entityfields/currentsalesprice/valueProcess.js</valueProcess>
</entityField>
<entityOutgoingField>
<name>ProductProductprice_dfo</name>
......
import("system.result");
import("system.vars");
import("Product_lib");
var ProductUtils = new ProductUtils();
result.string( ProductUtils.getCurrentProductPrice(vars.get("$field.PRODUCTID"), "PP") );
\ No newline at end of file
import("system.result");
import("system.vars");
import("Product_lib");
var productUtils = new ProductUtils();
result.string( productUtils.getCurrentProductPrice(vars.get("$field.PRODUCTID"), "SP") );
\ No newline at end of file
import("system.result");
import("system.vars");
import("Product_lib");
var ProductUtils = new ProductUtils();
result.string( ProductUtils.getStockCount(vars.get("$field.PRODUCTID")) );
\ No newline at end of file
......@@ -2,7 +2,7 @@
<preferences xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="3.0.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/preferences/3.0.1">
<name>_____PREFERENCES_PROJECT</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<projectName>xRM-Basic 5</projectName>
<projectName>xRM-Basic</projectName>
<jditoMaxContentSize v="57671680" />
<calendarCategoriesEvent>
<entry>
......
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.7" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.1.7">
<name>Product_lib</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<process>%aditoprj%/process/Product_lib/process.js</process>
</process>
import("system.logging");
import("system.SQLTYPES");
import("system.datetime");
import("system.db");
import("system.vars");
function ProductUtils()
{
/**
* Delivers the currently valid product price
*
* @param pPid {String} ProductID
* @param pBuySell {String} possible values: PP, SP
*
* @example productUtils.getCurrentProductPrice(vars.get("$field.PRODUCTID"), "PP")
*
* @result {String} currently valid product price
*/
this.getCurrentProductPrice = function( pPid, pBuySell )
{
if(pPid != undefined && pPid != "" && pBuySell != undefined && pBuySell != "")
{
var actualpriceSelect = "select PRICE from PRODUCTPRICE \n\
where BUYSELL = '" + pBuySell + "' and PRODUCT_ID = '" + pPid + "' and CURRENCY = 1 \n\
and VALID_FROM <= ? and (VALID_TO >= ? or VALID_TO is null) \n\
order by VALID_FROM desc";
var today = datetime.today();
var sqltypes = [ [today.toString(), SQLTYPES.TIMESTAMP], [today.toString(), SQLTYPES.TIMESTAMP] ];
var actualprice = db.cell([actualpriceSelect, sqltypes]);
if(actualprice != "")
return actualprice;
else
return "0.00";
}
else
{
throw new Error();//TODO: add message
}
}
/**
* Delivers the stock
*
* @param pPid {String} ProductID
*
* @example productUtils.getStockCount(vars.get("$field.PRODUCTID"))
*
* @result {String} stock count
*/
this.getStockCount = function( pPid )
{
if(pPid != undefined && pPid != "")//TODO: could this not be solved with dfo's ?
{
var sum = db.cell("select sum(QUANTITY * IN_OUT) from STOCK where PRODUCT_ID = '" + pPid + "'");
if(sum == "")
sum = "0";
return sum;
}
else
{
throw new Error();//TODO: add message
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment