Skip to content
Snippets Groups Projects
Commit 90a30705 authored by Benjamin Ulrich's avatar Benjamin Ulrich :speech_balloon: Committed by Sebastian Pongratz
Browse files

[Projekt: xRM-Sales][TicketNr.: 1080111][Währungsbugs und unreinheiten im Angebot + Angepotsposten]

parent 92ea0496
No related branches found
No related tags found
No related merge requests found
Showing
with 78 additions and 9 deletions
......@@ -296,6 +296,12 @@
<name>itemInsertStatements</name>
<documentation>%aditoprj%/entity/Offeritem_entity/entityfields/iteminsertstatements/documentation.adoc</documentation>
</entityField>
<entityField>
<name>currency</name>
<title>Currency</title>
<state>READONLY</state>
<valueProcess>%aditoprj%/entity/Offeritem_entity/entityfields/currency/valueProcess.js</valueProcess>
</entityField>
</entityFields>
<recordContainers>
<dbRecordContainer>
......
import("KeywordRegistry_basic");
import("Keyword_lib");
import("system.result");
import("system.neon");
import("system.vars");
if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT)
{
if(vars.get("$param.Currency_param") && vars.get("$param.Currency_param") != "")
{
result.string(KeywordUtils.getViewValue($KeywordRegistry.currency(), vars.getString("$param.Currency_param")));
}
}
\ No newline at end of file
......@@ -282,6 +282,12 @@
<name>itemInsertStatements</name>
<documentation>%aditoprj%/entity/Orderitem_entity/entityfields/iteminsertstatements/documentation.adoc</documentation>
</entityField>
<entityField>
<name>currency</name>
<title>Currency</title>
<state>READONLY</state>
<valueProcess>%aditoprj%/entity/Orderitem_entity/entityfields/currency/valueProcess.js</valueProcess>
</entityField>
</entityFields>
<recordContainers>
<dbRecordContainer>
......
import("KeywordRegistry_basic");
import("Keyword_lib");
import("system.result");
import("system.neon");
import("system.vars");
if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT)
{
if(vars.get("$param.Currency_param") && vars.get("$param.Currency_param") != "")
{
result.string(KeywordUtils.getViewValue($KeywordRegistry.currency(), vars.getString("$param.Currency_param")));
}
}
\ No newline at end of file
......@@ -25,10 +25,10 @@ if(pId != "" && vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
var partsListObject = oiUtils.insertPartsList(pId, vars.get("$field.SALESORDERITEMID"), curr, contactid, quantity, true, vars.get("$field.SALESORDER_ID"), sumUpTop);
neon.setFieldValue("$field.itemInsertStatements", JSON.stringify(partsListObject["partsList"]));
if(sumUpTop)//only sum-up this price if there is no valid Price
if(sumUpTop && partsListObject["topProductInfo"])//only sum-up this price if there is no valid Price
{
neon.setFieldValue("$field.PRICE", partsListObject["topProductInfo"]["price"]*quantity);
neon.setFieldValue("$field.VAT", partsListObject["topProductInfo"]["vat"]);
neon.setFieldValue("$field.PRICE", partsListObject["topProductInfo"]["price"]*quantity);
neon.setFieldValue("$field.VAT", partsListObject["topProductInfo"]["vat"]);
}
}
......@@ -4,6 +4,14 @@ import("system.result");
import("system.vars");
import("Product_lib");
var price = ProductUtils.getCurrentProductPrice(vars.get("$field.PRODUCTID"), "PP", true);
var currency;
if(vars.get("$param.OrderOfferInformations_param"))
{
currency = JSON.parse(vars.get("$param.OrderOfferInformations_param")).Currency_param;
}
var price = ProductUtils.getCurrentProductPrice(vars.get("$field.PRODUCTID"), "PP", true, currency);
if (price.length > 0)
result.string(text.formatDouble(price[0], "#,##0.00", true) + " " + price[1]);
\ No newline at end of file
{
result.string(text.formatDouble(price[0], "#,##0.00", true) + " " + price[1]);
}
\ No newline at end of file
......@@ -4,6 +4,14 @@ import("system.result");
import("system.vars");
import("Product_lib");
var price = ProductUtils.getCurrentProductPrice(vars.get("$field.PRODUCTID"), "SP", true);
var currency;
if(vars.get("$param.OrderOfferInformations_param"))
{
currency = JSON.parse(vars.get("$param.OrderOfferInformations_param")).Currency_param;
}
var price = ProductUtils.getCurrentProductPrice(vars.get("$field.PRODUCTID"), "SP", true, currency);
if (price.length > 0)
result.string(text.formatDouble(price[0], "#,##0.00", true) + " " + price[1]);
\ No newline at end of file
{
result.string(text.formatDouble(price[0], "#,##0.00", true) + " " + price[1]);
}
\ No newline at end of file
......@@ -40,6 +40,10 @@
<name>2b635ddb-d52c-4063-af11-aea8eeee151b</name>
<entityField>PRICE</entityField>
</entityFieldLink>
<entityFieldLink>
<name>fa6d99df-4f30-4737-8064-28eb5c88f17f</name>
<entityField>currency</entityField>
</entityFieldLink>
<entityFieldLink>
<name>4f339738-6358-463e-b941-3b2693ab115a</name>
<entityField>DISCOUNT</entityField>
......
......@@ -39,6 +39,10 @@
<name>f7bd09a0-ed27-4989-940e-e3baac4c3c80</name>
<entityField>PRICE</entityField>
</entityFieldLink>
<entityFieldLink>
<name>f4e3ecc2-6303-493b-aa5a-5d6b974ae9da</name>
<entityField>currency</entityField>
</entityFieldLink>
<entityFieldLink>
<name>2b38de6e-85de-479c-99fd-27ff0d2e1c33</name>
<entityField>DISCOUNT</entityField>
......
......@@ -628,6 +628,11 @@ ItemUtils.product_IdOnValueChange = function (pProductId, pUid, pEntity)
neon.setFieldValue("$field.PRICE", ProductDetails.PriceListToUse.price);
neon.setFieldValue("$field.VAT", ProductDetails.PriceListToUse.vat);
}
else
{
neon.setFieldValue("$field.PRICE", "");
neon.setFieldValue("$field.VAT", 0);
}
}
};
......@@ -669,7 +674,7 @@ ItemUtils.sumUpPricesWhenInserting = function (pStatements, pCorrectOrder, pTree
let price = 0;
if(pPriceObj[id])
{
price = pPriceObj[id]["price"]*pPriceObj[id]["quantity"];
price = pPriceObj[id]["price"]*(pPriceObj[id]["quantity"] == undefined ? 1 : pPriceObj[id]["quantity"]);
}
calcPrice = eMath.addDec(price, calcPrice);
if(pPriceObj[id] && pPriceObj[id]["vat"] && pPriceObj[id]["vat"] > 0)
......
......@@ -29,12 +29,13 @@ function ProductUtils() {}
* @param {String} pid ProductID
* @param {String} buySell possible values: PP, SP
* @param {String} [onlyStandard=false] if true, only standard price lists are selected.
* @param {String} pCurrency
*
* @example productUtils.getCurrentProductPrice(vars.get("$field.PRODUCTID"), "PP")
*
* @return {Array[]} currently valid product price with currency: [price, "CURRENCY", "VAT"] or [] if no price found
*/
ProductUtils.getCurrentProductPrice = function(pid, buySell, onlyStandard) {
ProductUtils.getCurrentProductPrice = function(pid, buySell, onlyStandard, pCurrency) {
if (pid != undefined && pid != "" && buySell != undefined && buySell != "")
{
var today = datetime.clearTime(vars.get("sys.date"), "utc");
......@@ -49,6 +50,7 @@ ProductUtils.getCurrentProductPrice = function(pid, buySell, onlyStandard) {
actualPriceSelect.and("PRODUCTPRICE.BUYSELL", buySell)
.and("PRODUCTPRICE.PRODUCT_ID", pid)
.andIfSet("PRODUCTPRICE.CURRENCY", pCurrency)
.and("PRODUCTPRICE.VALID_FROM", today, SqlBuilder.LESS_OR_EQUAL())
.and(newWhere("PRODUCTPRICE.VALID_TO", today, SqlBuilder.GREATER_OR_EQUAL())
.or("PRODUCTPRICE.VALID_TO is null"));
......
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