Skip to content
Snippets Groups Projects
Commit 572f67d1 authored by Pascal Neub's avatar Pascal Neub Committed by Sebastian Pongratz
Browse files

[Projekt: xRM-Sales][TicketNr.: 2001383][Angebots-Unterpositionen Preis ausweisen]

parent cfbc59ca
No related branches found
No related tags found
No related merge requests found
Showing with 162 additions and 65 deletions
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
<changeSet author="p.neub" id="7b89c0c8-1d74-4a70-9c78-a271e1fb6444">
<addColumn tableName="OFFERITEM">
<column name="SHOWPRICE" type="TINYINT"/>
</addColumn>
</changeSet>
</databaseChangeLog>
\ No newline at end of file
......@@ -2,5 +2,6 @@
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
<include relativeToChangelogFile="true" file="add_offer_showprice.xml"/>
<include relativeToChangelogFile="true" file="Ticket/changelog.xml"/>
</databaseChangeLog>
\ No newline at end of file
......@@ -305,6 +305,11 @@
<name>PICTURE</name>
<contentType>IMAGE</contentType>
</entityField>
<entityField>
<name>SHOWPRICE</name>
<title>Reveal the price in the offer</title>
<contentType>BOOLEAN</contentType>
</entityField>
</entityFields>
<recordContainers>
<dbRecordContainer>
......@@ -421,6 +426,10 @@
<name>PICTURE.value</name>
<expression>%aditoprj%/entity/Offeritem_entity/recordcontainers/db/recordfieldmappings/picture.value/expression.js</expression>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>SHOWPRICE.value</name>
<recordfield>OFFERITEM.SHOWPRICE</recordfield>
</dbRecordFieldMapping>
</recordFieldMappings>
<linkInformation>
<linkInformation>
......
import("Sql_lib");
import("system.db");
import("system.vars");
import("Offer_lib");
......@@ -12,6 +13,11 @@ if(oid != "")
var insertStatements = JSON.parse(vars.get("$field.itemInsertStatements"));
if(insertStatements)
{
insertStatements.forEach(function(insertStatement)
{
insertStatement[1].push("SHOWPRICE");
insertStatement[3].push(vars.get("$field.SHOWPRICE"));
});
db.execute(insertStatements, "Data_alias", 10000000);
}
}
......@@ -6,17 +6,31 @@ import("system.neon");
import("Offer_lib");
import("Sql_lib");
var oid = vars.get("$field.OFFER_ID");
if(oid != "")
var offerId = vars.get("$field.OFFER_ID");
if(offerId != "")
{
var offerItemUtils = new OfferItemUtils(offerId);
offerItemUtils.initItemTree();
var childIds = new Set();
function _traverseChilds(pId)
{
if(!childIds.has(pId))
{
childIds.add(pId);
offerItemUtils.ItemTree[pId].ids.forEach(_traverseChilds);
}
}
_traverseChilds(vars.get("$sys.uid"));
newWhere("OFFERITEM.OFFERITEMID", Array.from(childIds), SqlBuilder.IN())
.updateFields({"SHOWPRICE": vars.get("$field.SHOWPRICE")});
if(!vars.get("$field.ITEMPOSITION").includes("."))//only the topItems affect the Offer price
{
var discount = vars.exists("$param.Discount_param") ? vars.get("$param.Discount_param"): "";
var cols = ["NET", "VAT"];
var oiUtils = new OfferItemUtils(oid);
var vals = oiUtils.getNetAndVat();
var discountedVals = OfferItemUtils.getDiscountedNet(null, oid, discount);
var vals = offerItemUtils.getNetAndVat();
var discountedVals = OfferItemUtils.getDiscountedNet(null, offerId, discount);
var fieldValues = {
NET: vals[0].toString(),
VAT: vals[1].toString()
......@@ -31,7 +45,7 @@ if(oid != "")
var config = entities.createConfigForUpdatingRows();
config.entity("Offer_entity");
config.uid(oid);
config.uid(offerId);
config.fieldValues(fieldValues);
entities.updateRow(config);
}
......@@ -46,7 +60,7 @@ if(oid != "")
{
var multiplier = newQuanitity/oldQuantity;
var loadConfig = entities.createConfigForLoadingRows().entity("Offeritem_entity").addParameter("OfferId_param", oid).fields(["OFFERITEMID", "ASSIGNEDTO", "PRODUCT_ID", "QUANTITY"])
var loadConfig = entities.createConfigForLoadingRows().entity("Offeritem_entity").addParameter("OfferId_param", offerId).fields(["OFFERITEMID", "ASSIGNEDTO", "PRODUCT_ID", "QUANTITY"])
var rows = entities.getRows(loadConfig);
var potentialAsignees = {};
......
......@@ -14651,6 +14651,10 @@ Bitte Datumseingabe prüfen</value>
<entry>
<key>Contact &amp; Service ticket</key>
</entry>
<entry>
<key>Reveal the price in the offer</key>
<value>Preis im Angebot ausweisen</value>
</entry>
</keyValueMap>
<font name="Dialog" style="0" size="11" />
</language>
......@@ -52,6 +52,10 @@
<name>e40aa70c-2a6a-4ff4-818f-0a56bc4c63f4</name>
<entityField>OPTIONAL</entityField>
</entityFieldLink>
<entityFieldLink>
<name>33bbead7-74d9-407e-b459-6e7ae40f7ddb</name>
<entityField>SHOWPRICE</entityField>
</entityFieldLink>
<entityFieldLink>
<name>0b26591b-e97b-4c09-9584-3bdd6dc2740c</name>
<entityField>TotalPrice</entityField>
......
......@@ -58,6 +58,10 @@
<name>e43213db-8867-495f-8305-3472a8906222</name>
<entityField>TotalPrice</entityField>
</neonTreeTableColumn>
<neonTableColumn>
<name>5a340c30-ddbe-46f0-8b5e-e3c2ab25d2d4</name>
<entityField>SHOWPRICE</entityField>
</neonTableColumn>
<neonTreeTableColumn>
<name>ee165147-d91b-4d87-bd8a-90428d6f52be</name>
<entityField>INFO</entityField>
......@@ -126,6 +130,10 @@
<name>e43213db-8867-495f-8305-3472a8906222</name>
<entityField>TotalPrice</entityField>
</neonTreeTableColumn>
<neonTreeTableColumn>
<name>0451dd35-6a5a-4868-add2-c922e1f308a8</name>
<entityField>SHOWPRICE</entityField>
</neonTreeTableColumn>
<neonTreeTableColumn>
<name>ee165147-d91b-4d87-bd8a-90428d6f52be</name>
<entityField>INFO</entityField>
......
......@@ -52,6 +52,10 @@
<name>e25386dc-a740-4f93-a1f0-32317cf5a36a</name>
<entityField>OPTIONAL</entityField>
</entityFieldLink>
<entityFieldLink>
<name>59a538df-5789-48c8-849d-420524b0d355</name>
<entityField>SHOWPRICE</entityField>
</entityFieldLink>
</fields>
</genericViewTemplate>
<genericViewTemplate>
......
......@@ -172,32 +172,33 @@ OfferUtils.buildOfferReport = function (pOfferID, pExclDiscountGroupcodes)
offerData[7] = datetime.toDate(offerData[7], translate.text("dd.MM.yyyy", language));
var offerItemFields = [
"OFFERITEM.INFO",
"OFFERITEM.ASSIGNEDTO",
"OFFERITEM.PRODUCT_ID",
"OFFERITEM.ITEMNAME" ,
"OFFERITEM.OPTIONAL", //4
"OFFERITEM.ITEMPOSITION",
"PRODUCT.PRODUCTCODE",
"PRODUCT.PRODUCTID",
"OFFERITEM.UNIT", //8
sqlUtil.isNull("OFFERITEM.QUANTITY", "0"),
sqlUtil.isNull("OFFERITEM.PRICE", "0"),
sqlUtil.isNull("OFFERITEM.DISCOUNT", "0"),
sqlUtil.isNull("OFFERITEM.VAT", "0"), //12
"0",
"''",
"OFFERITEM.GROUPCODEID"
"OFFERITEM.INFO",
"OFFERITEM.ASSIGNEDTO",
"OFFERITEM.PRODUCT_ID",
"OFFERITEM.ITEMNAME",
"OFFERITEM.OPTIONAL", //4
"OFFERITEM.ITEMPOSITION",
"PRODUCT.PRODUCTCODE",
"PRODUCT.PRODUCTID",
"OFFERITEM.UNIT", //8
sqlUtil.isNull("OFFERITEM.QUANTITY", "0"),
sqlUtil.isNull("OFFERITEM.PRICE", "0"),
sqlUtil.isNull("OFFERITEM.DISCOUNT", "0"),
sqlUtil.isNull("OFFERITEM.VAT", "0"), //12
"0",
"''",
"OFFERITEM.GROUPCODEID",
"OFFERITEM.SHOWPRICE" // 16
];
var itemData = newSelect(offerItemFields)
var offeritemData = newSelect(offerItemFields)
.from("OFFERITEM")
.leftJoin("PRODUCT", "PRODUCT.PRODUCTID = OFFERITEM.PRODUCT_ID")
.where("OFFERITEM.OFFER_ID", pOfferID)
.orderBy("OFFERITEM.ITEMSORT asc")
.table();
if (itemData.length == 0)
if (offeritemData.length == 0)
return null;
var fullPrice = 0;
......@@ -230,68 +231,75 @@ OfferUtils.buildOfferReport = function (pOfferID, pExclDiscountGroupcodes)
offerData[18] = text.formatDouble(offerData[18], "#,##0.00", true);
}
itemData = itemData.map(function (item)
offeritemData = offeritemData.map(function (offeritem)
{
if (!item[5].includes(".") && item[4] != "1") //only if it's no child and its not optional
if(offeritem[4] != "1")
{
//quantity * price
fullPrice = eMath.mulDec(parseFloat(item[9]), parseFloat(item[10])); //price without discount
fullPrice = eMath.mulDec(parseFloat(offeritem[9]), parseFloat(offeritem[10])); //price without discount
//itemSum = (fullPrice * (100 - discount)) / 100
itemSum = eMath.roundDec(eMath.divDec(eMath.mulDec(fullPrice, eMath.subDec(100, item[11])), 100), 2, eMath.ROUND_HALF_EVEN); //sum of the item (with discount)
itemSum = eMath.roundDec(eMath.divDec(eMath.mulDec(fullPrice, eMath.subDec(100, offeritem[11])), 100), 2, eMath.ROUND_HALF_EVEN); //sum of the item (with discount)
sumItemSum += itemSum; //total sum (without vat)
let excluded = -1
if(pExclDiscountGroupcodes)
{
excluded = pExclDiscountGroupcodes.indexOf(item[15])
excluded = pExclDiscountGroupcodes.indexOf(offeritem[15])
}
//vatsum = itemSum * vat / 100
if(printHeadDiscount && offerData[16] && excluded == -1){
vatsum = ItemUtils.prototype.getItemVAT(item[9], item[10], item[11], item[12], item[4]);
if(printHeadDiscount && offerData[16] && excluded == -1)
{
vatsum = ItemUtils.prototype.getItemVAT(offeritem[9], offeritem[10], offeritem[11], offeritem[12], offeritem[4]);
vatsum = eMath.subDec(vatsum, eMath.divDec(eMath.mulDec(vatsum, offerData[16]), "100"));
}
else
{
vatsum = ItemUtils.prototype.getItemVAT(item[9], item[10], item[11], item[12], item[4])
vatsum = ItemUtils.prototype.getItemVAT(offeritem[9], offeritem[10], offeritem[11], offeritem[12], offeritem[4])
}
if (item[12] > 0)
sums.push([item[12], vatsum]); //MWSteuerwerte für Map vorbereiten
if(offeritem[12] > 0)
{
sums.push([offeritem[12], vatsum]); //MWSteuerwerte für Map vorbereiten
}
}
// sumItemSum + vat
if(!printHeadDiscount)
{
total = eMath.addDec(sumItemSum, vatsum); //total sum with vat
}
if (!printDiscount && item[11] > 0)
if(!printDiscount && offeritem[11] > 0)
{
printDiscount = true;
}
return [
offerData[6], //currency
offerData[7], //offerdate
pOfferID, //offerId
item[0], //info
item[1], //assignedTo
item[3], //itemname
parseInt(item[4]) ? translate.text("Yes", language) : translate.text("No", language), //optional
item[5], //itemposition
item[6], //productcode
header, //header
footer, //footer
text.formatDouble(item[9], "#,##0", true), //quantity
text.formatDouble(item[10], "#,##0.00", true), //price
text.formatDouble(item[11], "0.00", true), //discount
offerData[10], //versnr
offerData[5], //offercode
text.formatDouble(item[12], "#,##0.00", true), //vat
text.formatDouble(itemSum, "#,##0.00", true), //itemsum
KeywordUtils.getViewValue($KeywordRegistry.quantityUnit(), item[8]), //unittext
discValue,
offerData[18],
discount
offerData[6], //currency
offerData[7], //offerdate
pOfferID, //offerId
offeritem[0], //info
offeritem[1], //assignedTo
offeritem[3], //itemname
parseInt(offeritem[4]) ? translate.text("Yes", language) : translate.text("No", language), //optional
offeritem[5], //itemposition
offeritem[6], //productcode
header, //header
footer, //footer
text.formatDouble(offeritem[9], "#,##0", true), //quantity
text.formatDouble(offeritem[10], "#,##0.00", true), //price
text.formatDouble(offeritem[11], "0.00", true), //discount
offerData[10], //versnr
offerData[5], //offercode
text.formatDouble(offeritem[12], "#,##0.00", true), //vat
text.formatDouble(itemSum, "#,##0.00", true), //itemsum
KeywordUtils.getViewValue($KeywordRegistry.quantityUnit(), offeritem[8]), //unittext
discValue,
offerData[18],
discount,
offeritem[16]
];
});
......@@ -368,9 +376,10 @@ OfferUtils.buildOfferReport = function (pOfferID, pExclDiscountGroupcodes)
"OFFERITEM_UNITTEXT",
"OFFER_DISCOUNT",
"OFFER_DISCOUNTED_NET",
"OFFER_DISCOUNTSUM"
"OFFER_DISCOUNTSUM",
"OFFERITEM_SHOWPRICE"
])
.add(itemData));
.add(offeritemData));
return offerReport.exportReport();
}
......
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="e7a916c8-3f9a-497d-84bb-3909b15271ea">
<property name="ireport.zoom" value="2.1435888100000016"/>
<property name="ireport.x" value="260"/>
<property name="ireport.y" value="395"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="233"/>
<parameter name="myAddr" class="java.lang.String"/>
<parameter name="Pos" class="java.lang.String"/>
<parameter name="Articledescription" class="java.lang.String"/>
......@@ -24,7 +24,7 @@
<parameter name="OfferDeliveryTerm" class="java.lang.String"/>
<parameter name="responsible" class="java.lang.String"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["C:\\entwicklungszweige\\master\\project\\xRM-Basic\\report\\Offer_report\\"]]></defaultValueExpression>
<defaultValueExpression><![CDATA["C:\\dev\\project\\xRM-Basic\\report\\Offer_report\\"]]></defaultValueExpression>
</parameter>
<parameter name="adito.datasource.subdata" class="java.lang.Object"/>
<parameter name="SUMITEMSUM" class="java.lang.Double"/>
......@@ -62,6 +62,7 @@
<field name="OFFER_DISCOUNT" class="java.lang.String"/>
<field name="OFFER_DISCOUNTED_NET" class="java.lang.String"/>
<field name="OFFER_DISCOUNTSUM" class="java.lang.String"/>
<field name="OFFERITEM_SHOWPRICE" class="java.lang.String"/>
<sortField name="OFFER_OFFERID"/>
<group name="OFFERID" isStartNewPage="true">
<groupExpression><![CDATA[$F{OFFER_OFFERID}]]></groupExpression>
......@@ -527,6 +528,33 @@
</textElement>
<textFieldExpression><![CDATA[$F{OFFERITEM_OPTIONAL}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="495" y="0" width="56" height="15" forecolor="#999999" uuid="3d3fb6da-5ddb-4fec-bf59-bd1cfbae9c99">
<printWhenExpression><![CDATA[$F{OFFERITEM_SHOWPRICE}.equals("1") && !$F{OFFERITEM_OPTIONAL}.equals("1")]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Right">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{ITEMSUM}]]></textFieldExpression>
</textField>
<textField pattern="#,##0.00;-#,##0.00">
<reportElement x="389" y="0" width="63" height="15" forecolor="#999999" uuid="60239f2b-66fe-4cee-8664-7b6ffe9d5ce7">
<printWhenExpression><![CDATA[$F{OFFERITEM_SHOWPRICE}.equals("1")]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Right">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{OFFERITEM_PRICE}]]></textFieldExpression>
</textField>
<textField pattern="###0.00;###0.00-">
<reportElement x="454" y="0" width="38" height="15" forecolor="#999999" uuid="9974a275-0651-440f-a98b-43828f69a2ae">
<printWhenExpression><![CDATA[$F{OFFERITEM_SHOWPRICE}.equals("1")]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Right">
<font size="8" isBold="false" isUnderline="false"/>
</textElement>
<textFieldExpression><![CDATA[!$F{OFFERITEM_VAT}.equals(null)? $F{OFFERITEM_VAT} : ""]]></textFieldExpression>
</textField>
</band>
<band height="18">
<textField isStretchWithOverflow="true">
......
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