diff --git a/.liquibase/Data_alias/basic/2021.2.2/OfferOrder/alter_offer.xml b/.liquibase/Data_alias/basic/2021.2.2/OfferOrder/alter_offer.xml new file mode 100644 index 0000000000000000000000000000000000000000..1a4e28becff4011d16f6cf85748d990a449374ea --- /dev/null +++ b/.liquibase/Data_alias/basic/2021.2.2/OfferOrder/alter_offer.xml @@ -0,0 +1,11 @@ +<?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="a76dd9e5-5b66-4b5d-8c93-9fc8104f695e"> + <dropColumn tableName="OFFER"> + <column name="DISCOUNTED_NET"/> + <column name="DISCOUNTED_VAT"/> + </dropColumn> + </changeSet> +</databaseChangeLog> \ No newline at end of file diff --git a/.liquibase/Data_alias/basic/2021.2.2/OfferOrder/alter_order.xml b/.liquibase/Data_alias/basic/2021.2.2/OfferOrder/alter_order.xml new file mode 100644 index 0000000000000000000000000000000000000000..eb835d2ca05bface467d9293e68619aeb3119eb5 --- /dev/null +++ b/.liquibase/Data_alias/basic/2021.2.2/OfferOrder/alter_order.xml @@ -0,0 +1,11 @@ +<?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="b5cd257d-1df9-4704-9e66-45c220c67158"> + <dropColumn tableName="SALESORDER"> + <column name="DISCOUNTED_NET"/> + <column name="DISCOUNTED_VAT"/> + </dropColumn> + </changeSet> +</databaseChangeLog> \ No newline at end of file diff --git a/.liquibase/Data_alias/basic/2021.2.2/OfferOrder/changelog.xml b/.liquibase/Data_alias/basic/2021.2.2/OfferOrder/changelog.xml new file mode 100644 index 0000000000000000000000000000000000000000..7179a953f3f64c2cc67f6d6355cbfff16e564e78 --- /dev/null +++ b/.liquibase/Data_alias/basic/2021.2.2/OfferOrder/changelog.xml @@ -0,0 +1,7 @@ +<?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"> + <include relativeToChangelogFile="true" file="alter_offer.xml"/> + <include relativeToChangelogFile="true" file="alter_order.xml"/> +</databaseChangeLog> \ No newline at end of file diff --git a/.liquibase/Data_alias/basic/2021.2.2/changelog.xml b/.liquibase/Data_alias/basic/2021.2.2/changelog.xml index af0da5741524c6cb76dca2e049808995e9ac873e..3531213312bf23271c6677894a9531fe4641d136 100644 --- a/.liquibase/Data_alias/basic/2021.2.2/changelog.xml +++ b/.liquibase/Data_alias/basic/2021.2.2/changelog.xml @@ -9,4 +9,5 @@ <include relativeToChangelogFile="true" file="Employee/changelog.xml"/> <include relativeToChangelogFile="true" file="Mosaico/insert_mosaico_color_keyword.xml"/> <include relativeToChangelogFile="true" file="mailbridge/changelog.xml"/> + <include relativeToChangelogFile="true" file="OfferOrder/changelog.xml"/> </databaseChangeLog> \ No newline at end of file diff --git a/.liquibase/Data_alias/basic/_demoData/generatedData/offer.xml b/.liquibase/Data_alias/basic/_demoData/generatedData/offer.xml index d761d01164cd17ddd82d092474bcca487e98cd17..d129c2559996f8555a7a63db20ae4fa1bf3856cf 100644 --- a/.liquibase/Data_alias/basic/_demoData/generatedData/offer.xml +++ b/.liquibase/Data_alias/basic/_demoData/generatedData/offer.xml @@ -153,7 +153,6 @@ <column name="CONTACT_ID" value="a059aa9d-0463-4dbd-8b54-e85e235e63e0"/> <column name="USER_NEW" value="Birgit Leicht"/> <column name="OBJECT_ROWID" value="cdaa7f90-6e3d-4199-974b-0847b867a419"/> - <column name="DISCOUNTED_VAT" valueNumeric="712.50"/> <column name="ISOLANGUAGE" value="deu"/> <column name="VERSNR" valueNumeric="1"/> <column name="OFFERID" value="4f877dc9-8fce-41d5-bce4-f3ac34b12fde"/> @@ -165,7 +164,6 @@ <column name="OBJECT_TYPE" value="Salesproject"/> <column name="PROBABILITY" valueNumeric="50"/> <column name="OFFERCODE" valueNumeric="1015"/> - <column name="DISCOUNTED_NET" valueNumeric="3750.00"/> <column name="VAT" valueNumeric="712.50"/> <column name="DATE_NEW" valueDate="2021-06-28T05:49:22"/> <column name="HEADER" value="Wir danken Ihnen für Ihre Anfrage und bieten Ihnen die von Ihnen genannten Produkte wie folgt an:"/> @@ -220,7 +218,6 @@ <column name="CONTACT_ID" value="aee383d4-a34a-45aa-b2f3-abab9da800e3"/> <column name="USER_NEW" value="Birgit Leicht"/> <column name="OBJECT_ROWID" value="7683f92d-a949-4b76-ba6f-57344d730f40"/> - <column name="DISCOUNTED_VAT" valueNumeric="1900.00"/> <column name="ISOLANGUAGE" value="deu"/> <column name="VERSNR" valueNumeric="1"/> <column name="OFFERID" value="98ee9b03-b4cb-4e69-bf3b-ab6fd63e7b7a"/> @@ -232,7 +229,6 @@ <column name="OBJECT_TYPE" value="Salesproject"/> <column name="PROBABILITY" valueNumeric="0"/> <column name="OFFERCODE" valueNumeric="1016"/> - <column name="DISCOUNTED_NET" valueNumeric="10600.00"/> <column name="VAT" valueNumeric="1900.00"/> <column name="DATE_NEW" valueDate="2021-06-28T06:29:59"/> <column name="ACTIONUSER" value="c7ddf982-0e58-4152-b82b-8f5673b0b729"/> @@ -267,7 +263,6 @@ <column name="CONTACT_ID" value="3da2a794-7155-4009-95e0-b8aeb703acfc"/> <column name="USER_NEW" value="Birgit Leicht"/> <column name="OBJECT_ROWID" value="ef7f4726-4476-4f59-97c2-706dc1e0046f"/> - <column name="DISCOUNTED_VAT" valueNumeric="76950.00"/> <column name="ISOLANGUAGE" value="deu"/> <column name="VERSNR" valueNumeric="1"/> <column name="OFFERID" value="b25b1da5-c179-4142-a9c8-130c888a9b29"/> @@ -279,7 +274,6 @@ <column name="PROBABILITY" valueNumeric="0"/> <column name="APPROVAL" value="2"/> <column name="OFFERCODE" valueNumeric="1014"/> - <column name="DISCOUNTED_NET" valueNumeric="49000.00"/> <column name="VAT" valueNumeric="76950.00"/> <column name="DATE_NEW" valueDate="2020-01-23T10:55:49"/> <column name="HEADER" value="Wir danken Ihnen für Ihre Anfrage und bieten Ihnen die von Ihnen genannten Produkte wie folgt an:"/> diff --git a/.liquibase/Data_alias/basic/_demoData/generatedData/salesorder.xml b/.liquibase/Data_alias/basic/_demoData/generatedData/salesorder.xml index 5b694cd653792f42785025028bbcdf4962e82750..f85458736f5134c152c38c4263ff595762d7a793 100644 --- a/.liquibase/Data_alias/basic/_demoData/generatedData/salesorder.xml +++ b/.liquibase/Data_alias/basic/_demoData/generatedData/salesorder.xml @@ -76,12 +76,10 @@ <column name="OBJECT_ROWID" value="7683f92d-a949-4b76-ba6f-57344d730f40"/> <column name="SALESORDERDATE" valueDate="2020-08-11T12:00:00"/> <column name="DUNNINGDATE" valueDate="2021-06-29T12:00:00"/> - <column name="DISCOUNTED_VAT" valueNumeric="1900.00"/> <column name="ISOLANGUAGE" value="deu"/> <column name="CURRENCY" value="EUR"/> <column name="NET" valueNumeric="10600.00"/> <column name="OBJECT_TYPE" value="Salesproject"/> - <column name="DISCOUNTED_NET" valueNumeric="10600.00"/> <column name="VAT" valueNumeric="1900.00"/> <column name="PAYDUEDATE" valueDate="2020-08-18T12:00:00"/> <column name="PAYMENTADDRESS" value="Meister Messebau Aitrachstraße 5 84130 Dingolfing"/> @@ -104,12 +102,10 @@ <column name="OBJECT_ROWID" value="cdaa7f90-6e3d-4199-974b-0847b867a419"/> <column name="SALESORDERDATE" valueDate="2021-06-29T12:00:00"/> <column name="DUNNINGDATE" valueDate="2021-06-29T12:02:24"/> - <column name="DISCOUNTED_VAT" valueNumeric="712.50"/> <column name="ISOLANGUAGE" value="deu"/> <column name="CURRENCY" value="EUR"/> <column name="NET" valueNumeric="3750.00"/> <column name="OBJECT_TYPE" value="Salesproject"/> - <column name="DISCOUNTED_NET" valueNumeric="3750.00"/> <column name="VAT" valueNumeric="712.50"/> <column name="PAYDUEDATE" valueDate="2020-08-15T12:00:00"/> <column name="PAYMENTADDRESS" value="Meister Messebau GmbH Aitrachstraße 7 84130 Dingolfing"/> @@ -158,12 +154,10 @@ <column name="OBJECT_ROWID" value="7683f92d-a949-4b76-ba6f-57344d730f40"/> <column name="SALESORDERDATE" valueDate="2021-06-29T12:00:00"/> <column name="DUNNINGDATE" valueDate="2021-06-29T12:06:46"/> - <column name="DISCOUNTED_VAT" valueNumeric="1900.00"/> <column name="ISOLANGUAGE" value="deu"/> <column name="CURRENCY" value="EUR"/> <column name="NET" valueNumeric="10600.00"/> <column name="OBJECT_TYPE" value="Salesproject"/> - <column name="DISCOUNTED_NET" valueNumeric="10600.00"/> <column name="VAT" valueNumeric="1900.00"/> <column name="PAYDUEDATE" valueDate="2020-08-18T12:00:00"/> <column name="PAYMENTADDRESS" value="Meister Messebau Aitrachstraße 5 84130 Dingolfing"/> @@ -283,12 +277,10 @@ <column name="OBJECT_ROWID" value="cdaa7f90-6e3d-4199-974b-0847b867a419"/> <column name="SALESORDERDATE" valueDate="2020-07-06T12:00:00"/> <column name="DUNNINGDATE" valueDate="2021-06-29T12:02:24"/> - <column name="DISCOUNTED_VAT" valueNumeric="712.50"/> <column name="ISOLANGUAGE" value="deu"/> <column name="CURRENCY" value="EUR"/> <column name="NET" valueNumeric="3750.00"/> <column name="OBJECT_TYPE" value="Salesproject"/> - <column name="DISCOUNTED_NET" valueNumeric="3750.00"/> <column name="VAT" valueNumeric="712.50"/> <column name="PAYDUEDATE" valueDate="2020-08-13T12:00:00"/> <column name="PAYMENTADDRESS" value="Meister Messebau GmbH Aitrachstraße 7 84130 Dingolfing"/> @@ -378,12 +370,10 @@ <column name="OBJECT_ROWID" value="cdaa7f90-6e3d-4199-974b-0847b867a419"/> <column name="SALESORDERDATE" valueDate="2020-07-08T12:00:00"/> <column name="DUNNINGDATE" valueDate="2021-06-29T12:00:00"/> - <column name="DISCOUNTED_VAT" valueNumeric="712.50"/> <column name="ISOLANGUAGE" value="deu"/> <column name="CURRENCY" value="EUR"/> <column name="NET" valueNumeric="3750.00"/> <column name="OBJECT_TYPE" value="Salesproject"/> - <column name="DISCOUNTED_NET" valueNumeric="3750.00"/> <column name="VAT" valueNumeric="712.50"/> <column name="PAYDUEDATE" valueDate="2020-08-15T12:00:00"/> <column name="PAYMENTADDRESS" value="Meister Messebau GmbH Aitrachstraße 7 84130 Dingolfing"/> @@ -406,12 +396,10 @@ <column name="OBJECT_ROWID" value="7683f92d-a949-4b76-ba6f-57344d730f40"/> <column name="SALESORDERDATE" valueDate="2020-08-11T12:00:00"/> <column name="DUNNINGDATE" valueDate="2021-06-29T12:07:39"/> - <column name="DISCOUNTED_VAT" valueNumeric="1900.00"/> <column name="ISOLANGUAGE" value="deu"/> <column name="CURRENCY" value="EUR"/> <column name="NET" valueNumeric="10600.00"/> <column name="OBJECT_TYPE" value="Salesproject"/> - <column name="DISCOUNTED_NET" valueNumeric="10600.00"/> <column name="VAT" valueNumeric="1900.00"/> <column name="PAYDUEDATE" valueDate="2020-08-18T12:00:00"/> <column name="PAYMENTADDRESS" value="Meister Messebau Aitrachstraße 5 84130 Dingolfing"/> diff --git a/entity/Offer_entity/Offer_entity.aod b/entity/Offer_entity/Offer_entity.aod index 0d46bf7b97d26c3887302b467074d26dc7c070c9..f1a45c9a9b36e685e783cdf9277f77224a3831ac 100644 --- a/entity/Offer_entity/Offer_entity.aod +++ b/entity/Offer_entity/Offer_entity.aod @@ -97,7 +97,6 @@ <contentType>NUMBER</contentType> <inputFormat>#,##0.00</inputFormat> <state>READONLY</state> - <stateProcess>%aditoprj%/entity/Offer_entity/entityfields/vat/stateProcess.js</stateProcess> <displayValueProcess>%aditoprj%/entity/Offer_entity/entityfields/vat/displayValueProcess.js</displayValueProcess> </entityField> <entityField> @@ -166,17 +165,6 @@ <state>READONLY</state> <displayValueProcess>%aditoprj%/entity/Offer_entity/entityfields/net/displayValueProcess.js</displayValueProcess> </entityField> - <entityField> - <name>TotalGross</name> - <documentation>%aditoprj%/entity/Offer_entity/entityfields/totalgross/documentation.adoc</documentation> - <title>Total gross</title> - <contentType>NUMBER</contentType> - <outputFormat>#,##0.00</outputFormat> - <inputFormat>#,##0.00</inputFormat> - <state>READONLY</state> - <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/totalgross/valueProcess.js</valueProcess> - <displayValueProcess>%aditoprj%/entity/Offer_entity/entityfields/totalgross/displayValueProcess.js</displayValueProcess> - </entityField> <entityField> <name>ISOLANGUAGE</name> <title>Language</title> @@ -964,16 +952,12 @@ </entityField> <entityField> <name>DISCOUNT</name> - <title>Discount</title> <contentType>NUMBER</contentType> <outputFormat>0.00'%'</outputFormat> <inputFormat>0.00</inputFormat> <stateProcess>%aditoprj%/entity/Offer_entity/entityfields/discount/stateProcess.js</stateProcess> + <titleProcess>%aditoprj%/entity/Offer_entity/entityfields/discount/titleProcess.js</titleProcess> <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/discount/valueProcess.js</valueProcess> - <onValueChange>%aditoprj%/entity/Offer_entity/entityfields/discount/onValueChange.js</onValueChange> - <onValueChangeTypes> - <element>MASK</element> - </onValueChangeTypes> <onValidation>%aditoprj%/entity/Offer_entity/entityfields/discount/onValidation.js</onValidation> </entityField> <entityField> @@ -982,7 +966,6 @@ <contentType>NUMBER</contentType> <outputFormat>#,##0.00</outputFormat> <inputFormat>#,##0.00</inputFormat> - <state>READONLY</state> <stateProcess>%aditoprj%/entity/Offer_entity/entityfields/discounted_net/stateProcess.js</stateProcess> <displayValueProcess>%aditoprj%/entity/Offer_entity/entityfields/discounted_net/displayValueProcess.js</displayValueProcess> </entityField> @@ -991,17 +974,6 @@ <expose v="true" /> <description>PARAMETER</description> </entityParameter> - <entityField> - <name>DiscountChanged</name> - </entityField> - <entityField> - <name>DISCOUNTED_VAT</name> - <title>discounted Vat</title> - <contentType>NUMBER</contentType> - <inputFormat>#,##0.00</inputFormat> - <stateProcess>%aditoprj%/entity/Offer_entity/entityfields/discounted_vat/stateProcess.js</stateProcess> - <displayValueProcess>%aditoprj%/entity/Offer_entity/entityfields/discounted_vat/displayValueProcess.js</displayValueProcess> - </entityField> <entityConsumer> <name>Products</name> <dependency> @@ -1202,6 +1174,24 @@ </entityParameter> </children> </entityConsumer> + <entityField> + <name>DISCOUNT_NET</name> + <contentType>NUMBER</contentType> + <outputFormat>#,##0.00</outputFormat> + <inputFormat>#,##0.00</inputFormat> + <stateProcess>%aditoprj%/entity/Offer_entity/entityfields/discount_net/stateProcess.js</stateProcess> + <titleProcess>%aditoprj%/entity/Offer_entity/entityfields/discount_net/titleProcess.js</titleProcess> + <displayValueProcess>%aditoprj%/entity/Offer_entity/entityfields/discount_net/displayValueProcess.js</displayValueProcess> + </entityField> + <entityField> + <name>GROSS</name> + <title>Total gross</title> + <contentType>NUMBER</contentType> + <outputFormat>#,##0.00</outputFormat> + <inputFormat>#,##0.00</inputFormat> + <state>READONLY</state> + <displayValueProcess>%aditoprj%/entity/Offer_entity/entityfields/gross/displayValueProcess.js</displayValueProcess> + </entityField> </entityFields> <recordContainers> <dbRecordContainer> @@ -1414,16 +1404,12 @@ </dbRecordFieldMapping> <dbRecordFieldMapping> <name>DISCOUNTED_NET.value</name> - <recordfield>OFFER.DISCOUNTED_NET</recordfield> + <expression>%aditoprj%/entity/Offer_entity/recordcontainers/db/recordfieldmappings/discounted_net.value/expression.js</expression> </dbRecordFieldMapping> <dbRecordFieldMapping> <name>DISCOUNT.value</name> <recordfield>OFFER.DISCOUNT</recordfield> </dbRecordFieldMapping> - <dbRecordFieldMapping> - <name>DISCOUNTED_VAT.value</name> - <recordfield>OFFER.DISCOUNTED_VAT</recordfield> - </dbRecordFieldMapping> <aggregateFieldDbMapping> <name>PROBABILITY_aggregate.value</name> <recordfield>OFFER.PROBABILITY</recordfield> @@ -1437,6 +1423,14 @@ <name>APPROVAL.value</name> <recordfield>OFFER.APPROVAL</recordfield> </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>DISCOUNT_NET.value</name> + <expression>%aditoprj%/entity/Offer_entity/recordcontainers/db/recordfieldmappings/net_discount.value/expression.js</expression> + </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>GROSS.value</name> + <expression>%aditoprj%/entity/Offer_entity/recordcontainers/db/recordfieldmappings/gross.value/expression.js</expression> + </dbRecordFieldMapping> </recordFieldMappings> <linkInformation> <linkInformation> diff --git a/entity/Offer_entity/contentDescriptionProcess.js b/entity/Offer_entity/contentDescriptionProcess.js index f531fc13941d2e2f5b6ed501c3d0081337cbd997..eba4c63cfc00efc7f42d803b7179b9534c0cf9b9 100644 --- a/entity/Offer_entity/contentDescriptionProcess.js +++ b/entity/Offer_entity/contentDescriptionProcess.js @@ -1,13 +1,12 @@ import("Util_lib"); -import("system.eMath"); import("system.translate"); import("system.datetime"); import("system.vars"); import("system.result"); -var formattedGross = NumberUtils.formatWithCurrency(vars.get("$field.TotalGross"), translate.text("#,##0.00"), vars.get("$field.CURRENCY")); -var res = [translate.text("Total gross") + ": " + formattedGross, - translate.text("Probability") + ": " + vars.get("$field.PROBABILITY") + "%", - translate.text("Creation date") + ": " + datetime.toDate(vars.get("$field.DATE_NEW"), translate.text("dd.MM.yyyy"))]; - -result.string(res.join(" | ")); \ No newline at end of file +var res = [ + translate.text("Total gross") + ": " + vars.get("$field.GROSS.displayValue"), + translate.text("Probability") + ": " + vars.get("$field.PROBABILITY") + "%", + translate.text("Creation date") + ": " + datetime.toDate(vars.get("$field.DATE_NEW"), translate.text("dd.MM.yyyy")) +]; +result.string(res.join(" | ")); diff --git a/entity/Offer_entity/entityfields/discount/onValueChange.js b/entity/Offer_entity/entityfields/discount/onValueChange.js deleted file mode 100644 index 5fc7651884946ad0f59a3f5c51b5bb93f0505c30..0000000000000000000000000000000000000000 --- a/entity/Offer_entity/entityfields/discount/onValueChange.js +++ /dev/null @@ -1,5 +0,0 @@ -import("system.neon"); -import("system.vars"); -if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon. OPERATINGSTATE_EDIT){ - neon.setFieldValue("$field.DiscountChanged", "true"); -} \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/discount/titleProcess.js b/entity/Offer_entity/entityfields/discount/titleProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..e31d4834c9c6aaafaaf857dc05c695f3825ccf49 --- /dev/null +++ b/entity/Offer_entity/entityfields/discount/titleProcess.js @@ -0,0 +1,4 @@ +import("system.result"); +import("system.translate"); + +result.string(translate.withArguments("Discount in %0", ["%"])); diff --git a/entity/Offer_entity/entityfields/discount_net/displayValueProcess.js b/entity/Offer_entity/entityfields/discount_net/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..7f086986db455cffe066461c5b6575072f69915f --- /dev/null +++ b/entity/Offer_entity/entityfields/discount_net/displayValueProcess.js @@ -0,0 +1,6 @@ +import("system.result"); +import("system.vars"); +import("system.translate"); +import("Util_lib"); + +result.string(NumberUtils.formatWithCurrency(vars.get("$this.value"), translate.text("#,##0.00"), vars.get("$field.CURRENCY"))); diff --git a/entity/Offer_entity/entityfields/discount_net/stateProcess.js b/entity/Offer_entity/entityfields/discount_net/stateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..5a6fb24db9fc6226b60e8f57ea8560234976c17a --- /dev/null +++ b/entity/Offer_entity/entityfields/discount_net/stateProcess.js @@ -0,0 +1,10 @@ +import("system.result"); +import("system.neon"); +import("system.vars"); + +var state = neon.COMPONENTSTATE_INVISIBLE; +if((vars.get("$field.DISCOUNT") || 0) > 0) +{ + state = neon.COMPONENTSTATE_READONLY; +} +result.string(state); diff --git a/entity/Offer_entity/entityfields/discount_net/titleProcess.js b/entity/Offer_entity/entityfields/discount_net/titleProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..1fcc19648ab8c254dec9adf3ea45bf4bd12c7480 --- /dev/null +++ b/entity/Offer_entity/entityfields/discount_net/titleProcess.js @@ -0,0 +1,8 @@ +import("system.result"); +import("system.vars"); +import("system.translate"); +import("Keyword_lib"); +import("KeywordRegistry_basic"); + +var currency = KeywordUtils.getViewValue($KeywordRegistry.currency(), vars.get("$field.CURRENCY")); +result.string(translate.withArguments("Discount in %0", [currency])); diff --git a/entity/Offer_entity/entityfields/discounted_net/displayValueProcess.js b/entity/Offer_entity/entityfields/discounted_net/displayValueProcess.js index c7473e812c66616164442674dc87bdd5282dc50d..7f086986db455cffe066461c5b6575072f69915f 100644 --- a/entity/Offer_entity/entityfields/discounted_net/displayValueProcess.js +++ b/entity/Offer_entity/entityfields/discounted_net/displayValueProcess.js @@ -1,6 +1,6 @@ -import("Util_lib"); +import("system.result"); import("system.vars"); import("system.translate"); -import("system.result"); +import("Util_lib"); -result.string(NumberUtils.formatWithCurrency(vars.get("$field.DISCOUNTED_NET"), translate.text("#,##0.00"), vars.get("$field.CURRENCY"))); \ No newline at end of file +result.string(NumberUtils.formatWithCurrency(vars.get("$this.value"), translate.text("#,##0.00"), vars.get("$field.CURRENCY"))); diff --git a/entity/Offer_entity/entityfields/discounted_net/stateProcess.js b/entity/Offer_entity/entityfields/discounted_net/stateProcess.js index 7443b0c0dcb6c9e38045968ddaa64b5763dfd85e..5a6fb24db9fc6226b60e8f57ea8560234976c17a 100644 --- a/entity/Offer_entity/entityfields/discounted_net/stateProcess.js +++ b/entity/Offer_entity/entityfields/discounted_net/stateProcess.js @@ -1,10 +1,10 @@ -import("system.vars"); -import("system.neon"); import("system.result"); +import("system.neon"); +import("system.vars"); -var discount = vars.get("$field.DISCOUNT"); - -if(parseInt(discount) == parseInt("0") || !discount) - result.string(neon.COMPONENTSTATE_INVISIBLE); -else - result.string(neon.COMPONENTSTATE_READONLY); \ No newline at end of file +var state = neon.COMPONENTSTATE_INVISIBLE; +if((vars.get("$field.DISCOUNT") || 0) > 0) +{ + state = neon.COMPONENTSTATE_READONLY; +} +result.string(state); diff --git a/entity/Offer_entity/entityfields/discounted_vat/displayValueProcess.js b/entity/Offer_entity/entityfields/discounted_vat/displayValueProcess.js deleted file mode 100644 index 730396f16084a8c954d9cd54640efdd758e8cb52..0000000000000000000000000000000000000000 --- a/entity/Offer_entity/entityfields/discounted_vat/displayValueProcess.js +++ /dev/null @@ -1,6 +0,0 @@ -import("Util_lib"); -import("system.vars"); -import("system.translate"); -import("system.result"); - -result.string(NumberUtils.formatWithCurrency(vars.get("$field.DISCOUNTED_VAT"), translate.text("#,##0.00"), vars.get("$field.CURRENCY"))); \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/discounted_vat/stateProcess.js b/entity/Offer_entity/entityfields/discounted_vat/stateProcess.js deleted file mode 100644 index 7443b0c0dcb6c9e38045968ddaa64b5763dfd85e..0000000000000000000000000000000000000000 --- a/entity/Offer_entity/entityfields/discounted_vat/stateProcess.js +++ /dev/null @@ -1,10 +0,0 @@ -import("system.vars"); -import("system.neon"); -import("system.result"); - -var discount = vars.get("$field.DISCOUNT"); - -if(parseInt(discount) == parseInt("0") || !discount) - result.string(neon.COMPONENTSTATE_INVISIBLE); -else - result.string(neon.COMPONENTSTATE_READONLY); \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/gross/displayValueProcess.js b/entity/Offer_entity/entityfields/gross/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..7f086986db455cffe066461c5b6575072f69915f --- /dev/null +++ b/entity/Offer_entity/entityfields/gross/displayValueProcess.js @@ -0,0 +1,6 @@ +import("system.result"); +import("system.vars"); +import("system.translate"); +import("Util_lib"); + +result.string(NumberUtils.formatWithCurrency(vars.get("$this.value"), translate.text("#,##0.00"), vars.get("$field.CURRENCY"))); diff --git a/entity/Offer_entity/entityfields/net/displayValueProcess.js b/entity/Offer_entity/entityfields/net/displayValueProcess.js index 450ae0cfd9fa1701eeb4d4e7c049a3c8fb8fc7a0..7f086986db455cffe066461c5b6575072f69915f 100644 --- a/entity/Offer_entity/entityfields/net/displayValueProcess.js +++ b/entity/Offer_entity/entityfields/net/displayValueProcess.js @@ -1,6 +1,6 @@ -import("Util_lib"); +import("system.result"); import("system.vars"); import("system.translate"); -import("system.result"); +import("Util_lib"); -result.string(NumberUtils.formatWithCurrency(vars.get("$field.NET"), translate.text("#,##0.00"), vars.get("$field.CURRENCY"))); \ No newline at end of file +result.string(NumberUtils.formatWithCurrency(vars.get("$this.value"), translate.text("#,##0.00"), vars.get("$field.CURRENCY"))); diff --git a/entity/Offer_entity/entityfields/startworkflow/onActionProcess.js b/entity/Offer_entity/entityfields/startworkflow/onActionProcess.js index 287769a40ca72c10ec841bc2c7366cc2f5fc40df..b13e936fab92793b1f47bfad5fd3545bc86f3944 100644 --- a/entity/Offer_entity/entityfields/startworkflow/onActionProcess.js +++ b/entity/Offer_entity/entityfields/startworkflow/onActionProcess.js @@ -1,4 +1,4 @@ import("system.vars"); import("Workflow_lib"); -WorkflowUtils.openNewInstance({sum : Number(vars.get("$field.TotalGross"))}); \ No newline at end of file +WorkflowUtils.openNewInstance({sum : Number(vars.get("$field.GROSS"))}); diff --git a/entity/Offer_entity/entityfields/totalgross/displayValueProcess.js b/entity/Offer_entity/entityfields/totalgross/displayValueProcess.js deleted file mode 100644 index 7e05663a8bc4754d820b79c99b32536c38cb3916..0000000000000000000000000000000000000000 --- a/entity/Offer_entity/entityfields/totalgross/displayValueProcess.js +++ /dev/null @@ -1,6 +0,0 @@ -import("Util_lib"); -import("system.vars"); -import("system.translate"); -import("system.result"); - -result.string(NumberUtils.formatWithCurrency(vars.get("$field.TotalGross"), translate.text("#,##0.00"), vars.get("$field.CURRENCY"))); \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/totalgross/documentation.adoc b/entity/Offer_entity/entityfields/totalgross/documentation.adoc deleted file mode 100644 index c727abed66886d38bd46c6df6e1045b82666eb30..0000000000000000000000000000000000000000 --- a/entity/Offer_entity/entityfields/totalgross/documentation.adoc +++ /dev/null @@ -1,6 +0,0 @@ -= TotalGross -:hardbreaks: - -Contains the total gross of the offer (net). -This is calculated as follows: _NET_ + _VAT_. -Both are calculated in *_Offeritem_entity_* at _onDBInsert_, _onDBUpdate_ and _onDBDelete_. \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/totalgross/valueProcess.js b/entity/Offer_entity/entityfields/totalgross/valueProcess.js deleted file mode 100644 index 9d6a6c9330d2fd3eb57fa5f5102e55ad5eb0ef3b..0000000000000000000000000000000000000000 --- a/entity/Offer_entity/entityfields/totalgross/valueProcess.js +++ /dev/null @@ -1,9 +0,0 @@ -import("system.result"); -import("system.vars"); -import("system.eMath"); - -var discount = vars.get("$field.DISCOUNT"); -var netValue = discount && parseInt(discount) != parseInt("0") ? vars.get("$field.DISCOUNTED_NET") : vars.get("$field.NET") -var vatValue = discount && parseInt(discount) != parseInt("0") ? vars.get("$field.DISCOUNTED_VAT") : vars.get("$field.VAT"); - -result.string( eMath.addDec(netValue, vatValue) ); \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/vat/stateProcess.js b/entity/Offer_entity/entityfields/vat/stateProcess.js deleted file mode 100644 index 42a2d8e6788a09e0c2c8b410c5e4eadb7bfeb115..0000000000000000000000000000000000000000 --- a/entity/Offer_entity/entityfields/vat/stateProcess.js +++ /dev/null @@ -1,10 +0,0 @@ -import("system.neon"); -import("system.result"); -import("system.vars"); -var discount = vars.get("$field.DISCOUNT"); - -if(discount && parseInt(discount) != parseInt("0")){ - result.string(neon.COMPONENTSTATE_INVISIBLE); -} -else - result.string(neon.COMPONENTSTATE_READONLY) \ No newline at end of file diff --git a/entity/Offer_entity/recordcontainers/db/onDBUpdate.js b/entity/Offer_entity/recordcontainers/db/onDBUpdate.js index 866c488632bc1e0629e2bfd4b4681a8f3baad6a5..8045dda78ef88bd99de81a46f827aec85311ec1c 100644 --- a/entity/Offer_entity/recordcontainers/db/onDBUpdate.js +++ b/entity/Offer_entity/recordcontainers/db/onDBUpdate.js @@ -1,38 +1,3 @@ -import("system.entities"); -import("Offer_lib"); -import("system.vars"); import("Workflow_lib"); -var rowdata = vars.get("$local.rowdata"); -var oid = rowdata["OFFER.OFFERID"]; -if(vars.get("$field.DiscountChanged") == "true" && oid){ - var discount = rowdata["OFFER.DISCOUNT"]; - var oiUtils = new OfferItemUtils(oid); - - var vals = oiUtils.getNetAndVat(); - var discountedVals = OfferItemUtils.getDiscountedNet(null, oid, discount); - - let config = entities.createConfigForUpdatingRows(); - config.entity("Offer_entity"); - if(discountedVals){ - config.fieldValues({ - "NET": vals[0], - "VAT": vals[1], - "DISCOUNTED_NET": discountedVals[0], - "DISCOUNTED_VAT": discountedVals[1] - }); - } - else - { - config.fieldValues({ - "NET": vals[0], - "VAT": vals[1] - }); - } - - config.uid(oid); - entities.updateRow(config); - -} - -WorkflowSignalSender.updated(); \ No newline at end of file +WorkflowSignalSender.updated(); diff --git a/entity/Offer_entity/recordcontainers/db/recordfieldmappings/discounted_net.value/expression.js b/entity/Offer_entity/recordcontainers/db/recordfieldmappings/discounted_net.value/expression.js new file mode 100644 index 0000000000000000000000000000000000000000..50031b03c6b4cf95b293045da409ebae2c7b1748 --- /dev/null +++ b/entity/Offer_entity/recordcontainers/db/recordfieldmappings/discounted_net.value/expression.js @@ -0,0 +1,3 @@ +import("system.result"); + +result.string("OFFER.NET - OFFER.NET * OFFER.DISCOUNT / 100"); diff --git a/entity/Offer_entity/recordcontainers/db/recordfieldmappings/gross.value/expression.js b/entity/Offer_entity/recordcontainers/db/recordfieldmappings/gross.value/expression.js new file mode 100644 index 0000000000000000000000000000000000000000..43238579d431632de698df46f09e494c01ac606b --- /dev/null +++ b/entity/Offer_entity/recordcontainers/db/recordfieldmappings/gross.value/expression.js @@ -0,0 +1,6 @@ +import("system.result"); +import("Sql_lib"); + +var maskingUtils = new SqlMaskingUtils(); +var discount = maskingUtils.isNull("OFFER.DISCOUNT", "0"); +result.string("OFFER.NET - OFFER.NET * " + discount + " / 100 + OFFER.VAT - OFFER.VAT * " + discount + " / 100"); diff --git a/entity/Offer_entity/recordcontainers/db/recordfieldmappings/net_discount.value/expression.js b/entity/Offer_entity/recordcontainers/db/recordfieldmappings/net_discount.value/expression.js new file mode 100644 index 0000000000000000000000000000000000000000..bcb815fcaa1266fb0881d287e46dd0849affa9be --- /dev/null +++ b/entity/Offer_entity/recordcontainers/db/recordfieldmappings/net_discount.value/expression.js @@ -0,0 +1,3 @@ +import("system.result"); + +result.string("OFFER.NET * OFFER.DISCOUNT / 100"); diff --git a/entity/Offeritem_entity/Offeritem_entity.aod b/entity/Offeritem_entity/Offeritem_entity.aod index 11fa6807168d590f9d7c5db1b894b0d63e4e0860..8791f8cf6abb0d5a2632c3b425aea6ba1c603faa 100644 --- a/entity/Offeritem_entity/Offeritem_entity.aod +++ b/entity/Offeritem_entity/Offeritem_entity.aod @@ -21,10 +21,10 @@ </entityField> <entityField> <name>DISCOUNT</name> - <title>Discount</title> <contentType>NUMBER</contentType> <outputFormat>0.00'%'</outputFormat> <inputFormat>0.00</inputFormat> + <titleProcess>%aditoprj%/entity/Offeritem_entity/entityfields/discount/titleProcess.js</titleProcess> <onValidation>%aditoprj%/entity/Offeritem_entity/entityfields/discount/onValidation.js</onValidation> </entityField> <entityField> diff --git a/entity/Offeritem_entity/entityfields/discount/titleProcess.js b/entity/Offeritem_entity/entityfields/discount/titleProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..e31d4834c9c6aaafaaf857dc05c695f3825ccf49 --- /dev/null +++ b/entity/Offeritem_entity/entityfields/discount/titleProcess.js @@ -0,0 +1,4 @@ +import("system.result"); +import("system.translate"); + +result.string(translate.withArguments("Discount in %0", ["%"])); diff --git a/entity/Offeritem_entity/recordcontainers/db/onDBDelete.js b/entity/Offeritem_entity/recordcontainers/db/onDBDelete.js index 5d2691b811b6ad90eecd496864b50433947b30f6..88a3c5757231d8f78f72faa41d529ee97397c189 100644 --- a/entity/Offeritem_entity/recordcontainers/db/onDBDelete.js +++ b/entity/Offeritem_entity/recordcontainers/db/onDBDelete.js @@ -16,19 +16,10 @@ if(oid != "") oiUtils.reOrgItems(); var vals = oiUtils.getNetAndVat(deletedIds); - var discountedVals = OfferItemUtils.getDiscountedNet(deletedIds, oid, discount); - var fieldValues = { NET: vals[0].toString(), VAT: vals[1].toString() }; - if(discountedVals) - { - Object.assign(fieldValues, { - DISCOUNTED_NET: discountedVals[0].toString(), - DISCOUNTED_VAT: discountedVals[1].toString() - }); - } var config = entities.createConfigForUpdatingRows(); config.entity("Offer_entity"); diff --git a/entity/Offeritem_entity/recordcontainers/db/onDBUpdate.js b/entity/Offeritem_entity/recordcontainers/db/onDBUpdate.js index 52e5779595bbd95dea595795bca84d45130a3292..0c21ed1243a9982c6067b1ee46134dfcee02cf88 100644 --- a/entity/Offeritem_entity/recordcontainers/db/onDBUpdate.js +++ b/entity/Offeritem_entity/recordcontainers/db/onDBUpdate.js @@ -29,19 +29,10 @@ if(offerId != "") var discount = vars.exists("$param.Discount_param") ? vars.get("$param.Discount_param"): ""; var cols = ["NET", "VAT"]; var vals = offerItemUtils.getNetAndVat(); - var discountedVals = OfferItemUtils.getDiscountedNet(null, offerId, discount); - var fieldValues = { NET: vals[0].toString(), VAT: vals[1].toString() }; - if(discountedVals) - { - Object.assign(fieldValues, { - DISCOUNTED_NET: discountedVals[0].toString(), - DISCOUNTED_VAT: discountedVals[1].toString() - }); - } var config = entities.createConfigForUpdatingRows(); config.entity("Offer_entity"); diff --git a/entity/Order_entity/Order_entity.aod b/entity/Order_entity/Order_entity.aod index 74e49cad4413ed7e95cfe8373abf36812fb6b3c2..1b022481dbdc49732ce49dd4f5dc1e8b2bbaf766 100644 --- a/entity/Order_entity/Order_entity.aod +++ b/entity/Order_entity/Order_entity.aod @@ -72,7 +72,6 @@ <contentType>NUMBER</contentType> <minValue v="0" /> <state>READONLY</state> - <stateProcess>%aditoprj%/entity/Order_entity/entityfields/vat/stateProcess.js</stateProcess> <displayValueProcess>%aditoprj%/entity/Order_entity/entityfields/vat/displayValueProcess.js</displayValueProcess> </entityField> <entityField> @@ -135,18 +134,8 @@ <contentType>NUMBER</contentType> <groupable v="true" /> <state>READONLY</state> - <valueProcess></valueProcess> <displayValueProcess>%aditoprj%/entity/Order_entity/entityfields/net/displayValueProcess.js</displayValueProcess> </entityField> - <entityField> - <name>TotalGross</name> - <documentation>%aditoprj%/entity/Order_entity/entityfields/totalgross/documentation.adoc</documentation> - <title>Total gross</title> - <contentType>NUMBER</contentType> - <state>READONLY</state> - <valueProcess>%aditoprj%/entity/Order_entity/entityfields/totalgross/valueProcess.js</valueProcess> - <displayValueProcess>%aditoprj%/entity/Order_entity/entityfields/totalgross/displayValueProcess.js</displayValueProcess> - </entityField> <entityField> <name>ISOLANGUAGE</name> <title>Language</title> @@ -972,15 +961,11 @@ </entityConsumer> <entityField> <name>DISCOUNT</name> - <title>Discount</title> <contentType>NUMBER</contentType> <outputFormat>0.00'%'</outputFormat> <inputFormat>0.00</inputFormat> + <titleProcess>%aditoprj%/entity/Order_entity/entityfields/discount/titleProcess.js</titleProcess> <valueProcess>%aditoprj%/entity/Order_entity/entityfields/discount/valueProcess.js</valueProcess> - <onValueChange>%aditoprj%/entity/Order_entity/entityfields/discount/onValueChange.js</onValueChange> - <onValueChangeTypes> - <element>MASK</element> - </onValueChangeTypes> <onValidation>%aditoprj%/entity/Order_entity/entityfields/discount/onValidation.js</onValidation> </entityField> <entityField> @@ -989,23 +974,9 @@ <contentType>NUMBER</contentType> <outputFormat>#,##0.00</outputFormat> <inputFormat>#,##0.00</inputFormat> - <state>READONLY</state> <stateProcess>%aditoprj%/entity/Order_entity/entityfields/discounted_net/stateProcess.js</stateProcess> <displayValueProcess>%aditoprj%/entity/Order_entity/entityfields/discounted_net/displayValueProcess.js</displayValueProcess> </entityField> - <entityField> - <name>DISCOUNTED_VAT</name> - <title>discounted Vat</title> - <contentType>NUMBER</contentType> - <outputFormat>#,##0.00</outputFormat> - <inputFormat>#,##0.00</inputFormat> - <state>READONLY</state> - <stateProcess>%aditoprj%/entity/Order_entity/entityfields/discounted_vat/stateProcess.js</stateProcess> - <displayValueProcess>%aditoprj%/entity/Order_entity/entityfields/discounted_vat/displayValueProcess.js</displayValueProcess> - </entityField> - <entityField> - <name>DiscountChanged</name> - </entityField> <entityParameter> <name>Discount_param</name> <expose v="true" /> @@ -1044,6 +1015,24 @@ </entityParameter> </children> </entityConsumer> + <entityField> + <name>DISCOUNT_NET</name> + <contentType>NUMBER</contentType> + <outputFormat>#,##0.00</outputFormat> + <inputFormat>#,##0.00</inputFormat> + <stateProcess>%aditoprj%/entity/Order_entity/entityfields/discount_net/stateProcess.js</stateProcess> + <titleProcess>%aditoprj%/entity/Order_entity/entityfields/discount_net/titleProcess.js</titleProcess> + <displayValueProcess>%aditoprj%/entity/Order_entity/entityfields/discount_net/displayValueProcess.js</displayValueProcess> + </entityField> + <entityField> + <name>GROSS</name> + <title>Total gross</title> + <contentType>NUMBER</contentType> + <outputFormat>#,##0.00</outputFormat> + <inputFormat>#,##0.00</inputFormat> + <state>READONLY</state> + <displayValueProcess>%aditoprj%/entity/Order_entity/entityfields/gross/displayValueProcess.js</displayValueProcess> + </entityField> <entityAggregateField> <name>NET_aggregate</name> <parentField>NET</parentField> @@ -1267,11 +1256,15 @@ </dbRecordFieldMapping> <dbRecordFieldMapping> <name>DISCOUNTED_NET.value</name> - <recordfield>SALESORDER.DISCOUNTED_NET</recordfield> + <expression>%aditoprj%/entity/Order_entity/recordcontainers/db/recordfieldmappings/discounted_net.value/expression.js</expression> + </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>DISCOUNT_NET.value</name> + <expression>%aditoprj%/entity/Order_entity/recordcontainers/db/recordfieldmappings/discount_net.value/expression.js</expression> </dbRecordFieldMapping> <dbRecordFieldMapping> - <name>DISCOUNTED_VAT.value</name> - <recordfield>SALESORDER.DISCOUNTED_VAT</recordfield> + <name>GROSS.value</name> + <expression>%aditoprj%/entity/Order_entity/recordcontainers/db/recordfieldmappings/gross.value/expression.js</expression> </dbRecordFieldMapping> <aggregateFieldDbMapping> <name>NET_aggregate.value</name> diff --git a/entity/Order_entity/contentDescriptionProcess.js b/entity/Order_entity/contentDescriptionProcess.js index bd351d26e62473bda001b51a8393d3ed4f2cdb19..a51df75a71aa69923680945f967a6146113234e7 100644 --- a/entity/Order_entity/contentDescriptionProcess.js +++ b/entity/Order_entity/contentDescriptionProcess.js @@ -7,13 +7,16 @@ import("KeywordRegistry_basic"); var orderstatus = vars.get("$field.ORDERSTATUS") == "1" ? translate.text("Yes"): translate.text("No") -var res = [translate.text("Sent") + ": " + orderstatus, - translate.text("Total gross") + ": " + vars.get("$field.TotalGross.displayValue")] +var res = [ + translate.text("Sent") + ": " + orderstatus, + translate.text("Total gross") + ": " + vars.get("$field.GROSS.displayValue") +]; if(vars.get("$field.PAYDATE")) - res.push(translate.text("Pay date") + ": " + datetime.toDate(vars.get("$field.PAYDATE"), translate.text("dd.MM.yyyy"))) - +{ + res.push(translate.text("Pay date") + ": " + datetime.toDate(vars.get("$field.PAYDATE"), translate.text("dd.MM.yyyy"))); +} res.push(translate.text("Creation date") + ": " + datetime.toDate(vars.get("$field.DATE_NEW"), translate.text("dd.MM.yyyy"))); -result.string(res.join(" | ")); \ No newline at end of file +result.string(res.join(" | ")); diff --git a/entity/Order_entity/entityfields/discount/onValueChange.js b/entity/Order_entity/entityfields/discount/onValueChange.js deleted file mode 100644 index 5fc7651884946ad0f59a3f5c51b5bb93f0505c30..0000000000000000000000000000000000000000 --- a/entity/Order_entity/entityfields/discount/onValueChange.js +++ /dev/null @@ -1,5 +0,0 @@ -import("system.neon"); -import("system.vars"); -if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon. OPERATINGSTATE_EDIT){ - neon.setFieldValue("$field.DiscountChanged", "true"); -} \ No newline at end of file diff --git a/entity/Order_entity/entityfields/discount/titleProcess.js b/entity/Order_entity/entityfields/discount/titleProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..e31d4834c9c6aaafaaf857dc05c695f3825ccf49 --- /dev/null +++ b/entity/Order_entity/entityfields/discount/titleProcess.js @@ -0,0 +1,4 @@ +import("system.result"); +import("system.translate"); + +result.string(translate.withArguments("Discount in %0", ["%"])); diff --git a/entity/Order_entity/entityfields/discount_net/displayValueProcess.js b/entity/Order_entity/entityfields/discount_net/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..7f086986db455cffe066461c5b6575072f69915f --- /dev/null +++ b/entity/Order_entity/entityfields/discount_net/displayValueProcess.js @@ -0,0 +1,6 @@ +import("system.result"); +import("system.vars"); +import("system.translate"); +import("Util_lib"); + +result.string(NumberUtils.formatWithCurrency(vars.get("$this.value"), translate.text("#,##0.00"), vars.get("$field.CURRENCY"))); diff --git a/entity/Order_entity/entityfields/discount_net/stateProcess.js b/entity/Order_entity/entityfields/discount_net/stateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..5a6fb24db9fc6226b60e8f57ea8560234976c17a --- /dev/null +++ b/entity/Order_entity/entityfields/discount_net/stateProcess.js @@ -0,0 +1,10 @@ +import("system.result"); +import("system.neon"); +import("system.vars"); + +var state = neon.COMPONENTSTATE_INVISIBLE; +if((vars.get("$field.DISCOUNT") || 0) > 0) +{ + state = neon.COMPONENTSTATE_READONLY; +} +result.string(state); diff --git a/entity/Order_entity/entityfields/discount_net/titleProcess.js b/entity/Order_entity/entityfields/discount_net/titleProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..1fcc19648ab8c254dec9adf3ea45bf4bd12c7480 --- /dev/null +++ b/entity/Order_entity/entityfields/discount_net/titleProcess.js @@ -0,0 +1,8 @@ +import("system.result"); +import("system.vars"); +import("system.translate"); +import("Keyword_lib"); +import("KeywordRegistry_basic"); + +var currency = KeywordUtils.getViewValue($KeywordRegistry.currency(), vars.get("$field.CURRENCY")); +result.string(translate.withArguments("Discount in %0", [currency])); diff --git a/entity/Order_entity/entityfields/discounted_net/displayValueProcess.js b/entity/Order_entity/entityfields/discounted_net/displayValueProcess.js index c7473e812c66616164442674dc87bdd5282dc50d..7f086986db455cffe066461c5b6575072f69915f 100644 --- a/entity/Order_entity/entityfields/discounted_net/displayValueProcess.js +++ b/entity/Order_entity/entityfields/discounted_net/displayValueProcess.js @@ -1,6 +1,6 @@ -import("Util_lib"); +import("system.result"); import("system.vars"); import("system.translate"); -import("system.result"); +import("Util_lib"); -result.string(NumberUtils.formatWithCurrency(vars.get("$field.DISCOUNTED_NET"), translate.text("#,##0.00"), vars.get("$field.CURRENCY"))); \ No newline at end of file +result.string(NumberUtils.formatWithCurrency(vars.get("$this.value"), translate.text("#,##0.00"), vars.get("$field.CURRENCY"))); diff --git a/entity/Order_entity/entityfields/discounted_net/stateProcess.js b/entity/Order_entity/entityfields/discounted_net/stateProcess.js index 73fcdafe7c5bd47935d3f961a106bd995308316b..5a6fb24db9fc6226b60e8f57ea8560234976c17a 100644 --- a/entity/Order_entity/entityfields/discounted_net/stateProcess.js +++ b/entity/Order_entity/entityfields/discounted_net/stateProcess.js @@ -1,14 +1,10 @@ -import("system.vars"); -import("system.neon"); import("system.result"); +import("system.neon"); +import("system.vars"); -var discount = vars.get("$field.DISCOUNT"); - -if(parseInt(discount) == 0 || !discount) +var state = neon.COMPONENTSTATE_INVISIBLE; +if((vars.get("$field.DISCOUNT") || 0) > 0) { - result.string(neon.COMPONENTSTATE_INVISIBLE); + state = neon.COMPONENTSTATE_READONLY; } -else -{ - result.string(neon.COMPONENTSTATE_READONLY); -} \ No newline at end of file +result.string(state); diff --git a/entity/Order_entity/entityfields/discounted_vat/displayValueProcess.js b/entity/Order_entity/entityfields/discounted_vat/displayValueProcess.js deleted file mode 100644 index 730396f16084a8c954d9cd54640efdd758e8cb52..0000000000000000000000000000000000000000 --- a/entity/Order_entity/entityfields/discounted_vat/displayValueProcess.js +++ /dev/null @@ -1,6 +0,0 @@ -import("Util_lib"); -import("system.vars"); -import("system.translate"); -import("system.result"); - -result.string(NumberUtils.formatWithCurrency(vars.get("$field.DISCOUNTED_VAT"), translate.text("#,##0.00"), vars.get("$field.CURRENCY"))); \ No newline at end of file diff --git a/entity/Order_entity/entityfields/discounted_vat/stateProcess.js b/entity/Order_entity/entityfields/discounted_vat/stateProcess.js deleted file mode 100644 index 73fcdafe7c5bd47935d3f961a106bd995308316b..0000000000000000000000000000000000000000 --- a/entity/Order_entity/entityfields/discounted_vat/stateProcess.js +++ /dev/null @@ -1,14 +0,0 @@ -import("system.vars"); -import("system.neon"); -import("system.result"); - -var discount = vars.get("$field.DISCOUNT"); - -if(parseInt(discount) == 0 || !discount) -{ - result.string(neon.COMPONENTSTATE_INVISIBLE); -} -else -{ - result.string(neon.COMPONENTSTATE_READONLY); -} \ No newline at end of file diff --git a/entity/Order_entity/entityfields/gross/displayValueProcess.js b/entity/Order_entity/entityfields/gross/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..7f086986db455cffe066461c5b6575072f69915f --- /dev/null +++ b/entity/Order_entity/entityfields/gross/displayValueProcess.js @@ -0,0 +1,6 @@ +import("system.result"); +import("system.vars"); +import("system.translate"); +import("Util_lib"); + +result.string(NumberUtils.formatWithCurrency(vars.get("$this.value"), translate.text("#,##0.00"), vars.get("$field.CURRENCY"))); diff --git a/entity/Order_entity/entityfields/net/displayValueProcess.js b/entity/Order_entity/entityfields/net/displayValueProcess.js index 450ae0cfd9fa1701eeb4d4e7c049a3c8fb8fc7a0..7f086986db455cffe066461c5b6575072f69915f 100644 --- a/entity/Order_entity/entityfields/net/displayValueProcess.js +++ b/entity/Order_entity/entityfields/net/displayValueProcess.js @@ -1,6 +1,6 @@ -import("Util_lib"); +import("system.result"); import("system.vars"); import("system.translate"); -import("system.result"); +import("Util_lib"); -result.string(NumberUtils.formatWithCurrency(vars.get("$field.NET"), translate.text("#,##0.00"), vars.get("$field.CURRENCY"))); \ No newline at end of file +result.string(NumberUtils.formatWithCurrency(vars.get("$this.value"), translate.text("#,##0.00"), vars.get("$field.CURRENCY"))); diff --git a/entity/Order_entity/entityfields/totalgross/displayValueProcess.js b/entity/Order_entity/entityfields/totalgross/displayValueProcess.js deleted file mode 100644 index 7e05663a8bc4754d820b79c99b32536c38cb3916..0000000000000000000000000000000000000000 --- a/entity/Order_entity/entityfields/totalgross/displayValueProcess.js +++ /dev/null @@ -1,6 +0,0 @@ -import("Util_lib"); -import("system.vars"); -import("system.translate"); -import("system.result"); - -result.string(NumberUtils.formatWithCurrency(vars.get("$field.TotalGross"), translate.text("#,##0.00"), vars.get("$field.CURRENCY"))); \ No newline at end of file diff --git a/entity/Order_entity/entityfields/totalgross/documentation.adoc b/entity/Order_entity/entityfields/totalgross/documentation.adoc deleted file mode 100644 index ef4fe9e600767286a8bca167aedd6c70c33530b3..0000000000000000000000000000000000000000 --- a/entity/Order_entity/entityfields/totalgross/documentation.adoc +++ /dev/null @@ -1,6 +0,0 @@ -= TotalGross -:hardbreaks: - -Contains the total gross of the order (net). -This is calculated as follows: _NET_ + _VAT_. -Both are calculated in *_Orderitem_entity_* at _onDBInsert_, _onDBUpdate_ and _onDBDelete_. \ No newline at end of file diff --git a/entity/Order_entity/entityfields/totalgross/valueProcess.js b/entity/Order_entity/entityfields/totalgross/valueProcess.js deleted file mode 100644 index 2177ad85cf1f90944d9ef3dc5f5f546dda75c990..0000000000000000000000000000000000000000 --- a/entity/Order_entity/entityfields/totalgross/valueProcess.js +++ /dev/null @@ -1,9 +0,0 @@ -import("system.result"); -import("system.vars"); -import("system.eMath"); - -var discount = vars.get("$field.DISCOUNT"); -var netValue = discount && parseInt(discount) != 0 ? vars.get("$field.DISCOUNTED_NET") : vars.get("$field.NET"); -var vatValue = discount && parseInt(discount) != 0 ? vars.get("$field.DISCOUNTED_VAT") : vars.get("$field.VAT"); - -result.string(eMath.addDec(netValue, vatValue)); \ No newline at end of file diff --git a/entity/Order_entity/entityfields/vat/stateProcess.js b/entity/Order_entity/entityfields/vat/stateProcess.js deleted file mode 100644 index 58cd7c749ad71ae22fb4df03fbd71aed82ed7b6e..0000000000000000000000000000000000000000 --- a/entity/Order_entity/entityfields/vat/stateProcess.js +++ /dev/null @@ -1,14 +0,0 @@ -import("system.neon"); -import("system.result"); -import("system.vars"); - -var discount = vars.get("$field.DISCOUNT"); - -if(discount && parseInt(discount) != 0) -{ - result.string(neon.COMPONENTSTATE_INVISIBLE); -} -else -{ - result.string(neon.COMPONENTSTATE_READONLY); -} \ No newline at end of file diff --git a/entity/Order_entity/recordcontainers/db/onDBUpdate.js b/entity/Order_entity/recordcontainers/db/onDBUpdate.js index 6775ae5411e9caadfbe13314c618d96468da8fee..8045dda78ef88bd99de81a46f827aec85311ec1c 100644 --- a/entity/Order_entity/recordcontainers/db/onDBUpdate.js +++ b/entity/Order_entity/recordcontainers/db/onDBUpdate.js @@ -1,46 +1,3 @@ -import("Entity_lib"); -import("Order_lib"); -import("system.entities"); -import("system.vars"); import("Workflow_lib"); -var rowdata = vars.get("$local.rowdata"); -var oid = rowdata["SALESORDER.SALESORDERID"]; - -if(vars.exists("$field.Links.deletedRows")) -{ - // only if Links are aviable (e.g. if the Order is updated via write entities) - var links = EntityConsumerRowsHelper.getCurrentConsumerRows("Links", ["OBJECT_ROWID", "OBJECT_TYPE", "SALESORDER_ID"]); - OrderLinkUtils.handleLinks(links, oid, vars.get("$field.Links.deletedRows")); -} - -if(vars.get("$field.DiscountChanged") == "true" && oid){ - var discount = rowdata["SALESORDER.DISCOUNT"]; - var oiUtils = new OrderItemUtils(oid); - - var vals = oiUtils.getNetAndVat(); - var discountedVals = OrderItemUtils.getDiscountedNet(null, oid, discount); - - let config = entities.createConfigForUpdatingRows(); - config.entity("Order_entity"); - if(discountedVals){ - config.fieldValues({ - "NET": vals[0], - "VAT": vals[1], - "DISCOUNTED_NET": discountedVals[0], - "DISCOUNTED_VAT": discountedVals[1] - }); - } - else - { - config.fieldValues({ - "NET": vals[0], - "VAT": vals[1] - }); - } - - config.uid(oid); - entities.updateRow(config); - -} -WorkflowSignalSender.updated(); \ No newline at end of file +WorkflowSignalSender.updated(); diff --git a/entity/Order_entity/recordcontainers/db/recordfieldmappings/discount_net.value/expression.js b/entity/Order_entity/recordcontainers/db/recordfieldmappings/discount_net.value/expression.js new file mode 100644 index 0000000000000000000000000000000000000000..21cd95654920bf164a41412ed2dc949af725fee6 --- /dev/null +++ b/entity/Order_entity/recordcontainers/db/recordfieldmappings/discount_net.value/expression.js @@ -0,0 +1,3 @@ +import("system.result"); + +result.string("SALESORDER.NET * SALESORDER.DISCOUNT / 100"); diff --git a/entity/Order_entity/recordcontainers/db/recordfieldmappings/discounted_net.value/expression.js b/entity/Order_entity/recordcontainers/db/recordfieldmappings/discounted_net.value/expression.js new file mode 100644 index 0000000000000000000000000000000000000000..f95e110f7ba8ca5a4dbf5d0dab191e3a17ef0ec6 --- /dev/null +++ b/entity/Order_entity/recordcontainers/db/recordfieldmappings/discounted_net.value/expression.js @@ -0,0 +1,3 @@ +import("system.result"); + +result.string("SALESORDER.NET - SALESORDER.NET * SALESORDER.DISCOUNT / 100"); diff --git a/entity/Order_entity/recordcontainers/db/recordfieldmappings/gross.value/expression.js b/entity/Order_entity/recordcontainers/db/recordfieldmappings/gross.value/expression.js new file mode 100644 index 0000000000000000000000000000000000000000..d6de5c1251bb9360b79ed76acee49864dada78b3 --- /dev/null +++ b/entity/Order_entity/recordcontainers/db/recordfieldmappings/gross.value/expression.js @@ -0,0 +1,6 @@ +import("system.result"); +import("Sql_lib"); + +var maskingUtils = new SqlMaskingUtils(); +var discount = maskingUtils.isNull("SALESORDER.DISCOUNT", "0"); +result.string("SALESORDER.NET - SALESORDER.NET * " + discount + " / 100 + SALESORDER.VAT - SALESORDER.VAT * " + discount + " / 100"); diff --git a/entity/Orderitem_entity/Orderitem_entity.aod b/entity/Orderitem_entity/Orderitem_entity.aod index e5cea0d0343067e43d5c165048f8f1d45576c0a7..a4e328e26d2589f1a36add6b6109a0b94acd32c6 100644 --- a/entity/Orderitem_entity/Orderitem_entity.aod +++ b/entity/Orderitem_entity/Orderitem_entity.aod @@ -21,9 +21,10 @@ </entityField> <entityField> <name>DISCOUNT</name> - <title>Discount</title> <contentType>NUMBER</contentType> - <outputFormat>#,##0.00</outputFormat> + <outputFormat>0.00'%'</outputFormat> + <inputFormat>0.00</inputFormat> + <titleProcess>%aditoprj%/entity/Orderitem_entity/entityfields/discount/titleProcess.js</titleProcess> <onValidation>%aditoprj%/entity/Orderitem_entity/entityfields/discount/onValidation.js</onValidation> </entityField> <entityField> diff --git a/entity/Orderitem_entity/entityfields/discount/titleProcess.js b/entity/Orderitem_entity/entityfields/discount/titleProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..e31d4834c9c6aaafaaf857dc05c695f3825ccf49 --- /dev/null +++ b/entity/Orderitem_entity/entityfields/discount/titleProcess.js @@ -0,0 +1,4 @@ +import("system.result"); +import("system.translate"); + +result.string(translate.withArguments("Discount in %0", ["%"])); diff --git a/entity/Orderitem_entity/recordcontainers/db/onDBDelete.js b/entity/Orderitem_entity/recordcontainers/db/onDBDelete.js index f6df71bd95d805f8e687e7a99178f850456e0266..840086da698df0c69533689af55707871d2d5ac5 100644 --- a/entity/Orderitem_entity/recordcontainers/db/onDBDelete.js +++ b/entity/Orderitem_entity/recordcontainers/db/onDBDelete.js @@ -15,20 +15,11 @@ if(oid != "") deletedIds.push(oiid); oiUtils.reOrgItems(); - var vals = oiUtils.getNetAndVat(deletedIds); - var discountedVals = OrderItemUtils.getDiscountedNet(deletedIds, oid, discount); - + var vals = oiUtils.getNetAndVat(deletedIds); var fieldValues = { NET: vals[0].toString(), VAT: vals[1].toString() }; - if(discountedVals) - { - Object.assign(fieldValues, { - DISCOUNTED_NET: discountedVals[0].toString(), - DISCOUNTED_VAT: discountedVals[1].toString() - }); - } var config = entities.createConfigForUpdatingRows(); config.entity("Order_entity"); diff --git a/entity/Orderitem_entity/recordcontainers/db/onDBUpdate.js b/entity/Orderitem_entity/recordcontainers/db/onDBUpdate.js index d55c98c32667c0ecdbf17276410e01ff5a087553..d96eedd5e3d6e49302083d0d3ba84dee5874bdc1 100644 --- a/entity/Orderitem_entity/recordcontainers/db/onDBUpdate.js +++ b/entity/Orderitem_entity/recordcontainers/db/onDBUpdate.js @@ -15,20 +15,12 @@ if(oid != "") var cols = ["NET", "VAT"]; var oiUtils = new OrderItemUtils(oid); var vals = oiUtils.getNetAndVat(); - var discountedVals = OrderItemUtils.getDiscountedNet(null, oid, discount); var fieldValues = { NET: vals[0].toString(), VAT: vals[1].toString() }; - if(discountedVals) - { - Object.assign(fieldValues, { - DISCOUNTED_NET: discountedVals[0].toString(), - DISCOUNTED_VAT: discountedVals[1].toString() - }); - } - + var config = entities.createConfigForUpdatingRows(); config.entity("Order_entity"); config.uid(oid); diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod index 4fefbed19976f1fd3fa397bbb17397541f9632dc..85b7bf7f359f6955d17101cbe46fb97b88057151 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -696,7 +696,7 @@ </entry> <entry> <key>discounted Price</key> - <value>Rbt. Betrag netto</value> + <value>Red. Betrag netto</value> </entry> <entry> <key>Add app</key> @@ -14687,6 +14687,10 @@ Bitte Datumseingabe prüfen</value> <key>You were assigned as new district contact to district %0 and %1 organisation(s).</key> <value>Sie wurden Distrikt %0 und %1 Organisation(en) als neuer Distriktkontakt zugewiesen.</value> </entry> + <entry> + <key>Discount in %0</key> + <value>Rabatt in %0</value> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/neonView/OfferPreview_view/OfferPreview_view.aod b/neonView/OfferPreview_view/OfferPreview_view.aod index 3351f58318296f98404e708ff528eb9d976268e4..37e53146cd61b2c777ff5183cd17d237946f44a2 100644 --- a/neonView/OfferPreview_view/OfferPreview_view.aod +++ b/neonView/OfferPreview_view/OfferPreview_view.aod @@ -67,6 +67,14 @@ <name>d7ca2b66-5e7a-4951-a89b-fbeab0f4f798</name> <entityField>NET</entityField> </entityFieldLink> + <entityFieldLink> + <name>1d19fabe-3f13-47a6-baf5-1f9f0eadc53c</name> + <entityField>DISCOUNT</entityField> + </entityFieldLink> + <entityFieldLink> + <name>cc0d2b0d-b1b6-4a98-b715-71f7f7824ae1</name> + <entityField>DISCOUNT_NET</entityField> + </entityFieldLink> <entityFieldLink> <name>3e9e37e2-6756-41c2-ace7-6ff094dc78c1</name> <entityField>DISCOUNTED_NET</entityField> @@ -76,12 +84,8 @@ <entityField>VAT</entityField> </entityFieldLink> <entityFieldLink> - <name>5cc461e4-fd0f-47e6-ab06-886a18621c31</name> - <entityField>DISCOUNTED_VAT</entityField> - </entityFieldLink> - <entityFieldLink> - <name>43972a26-67f7-4fb5-9107-111731d326af</name> - <entityField>TotalGross</entityField> + <name>66557054-e556-428b-b9aa-9991f5ab89b2</name> + <entityField>GROSS</entityField> </entityFieldLink> </fields> </genericViewTemplate> @@ -107,10 +111,6 @@ <name>a3a9ee30-bdd2-4907-b215-d4b4adcc0f1d</name> <entityField>DELIVERYTERMS</entityField> </entityFieldLink> - <entityFieldLink> - <name>b67494ee-f7c1-4002-a550-50ce1eac5020</name> - <entityField>DISCOUNT</entityField> - </entityFieldLink> </fields> </genericViewTemplate> <neonViewReference> diff --git a/neonView/OrderPreview_view/OrderPreview_view.aod b/neonView/OrderPreview_view/OrderPreview_view.aod index cc5cdd5c9557e602e8a8cebb93ace6cf6d7a86e5..af39e62be4515b062581fa9f27fdf216bd34f676 100644 --- a/neonView/OrderPreview_view/OrderPreview_view.aod +++ b/neonView/OrderPreview_view/OrderPreview_view.aod @@ -79,6 +79,14 @@ <name>d7ca2b66-5e7a-4951-a89b-fbeab0f4f798</name> <entityField>NET</entityField> </entityFieldLink> + <entityFieldLink> + <name>e8d0649b-dbcf-4c2e-9f4c-7f673e4f1f02</name> + <entityField>DISCOUNT</entityField> + </entityFieldLink> + <entityFieldLink> + <name>ec752803-20bc-4b37-854b-39a553c4e3c4</name> + <entityField>DISCOUNT_NET</entityField> + </entityFieldLink> <entityFieldLink> <name>4baf8275-e96d-4b26-9808-17fc1e515134</name> <entityField>DISCOUNTED_NET</entityField> @@ -88,12 +96,8 @@ <entityField>VAT</entityField> </entityFieldLink> <entityFieldLink> - <name>2b919444-e34e-4f89-9894-8916da00a709</name> - <entityField>DISCOUNTED_VAT</entityField> - </entityFieldLink> - <entityFieldLink> - <name>43972a26-67f7-4fb5-9107-111731d326af</name> - <entityField>TotalGross</entityField> + <name>e69ec466-d2fb-462c-aa03-8c5646bc2ece</name> + <entityField>GROSS</entityField> </entityFieldLink> <entityFieldLink> <name>893e3b20-891e-49ba-a460-7dadfca7b18a</name> diff --git a/process/Offer_lib/process.js b/process/Offer_lib/process.js index 892a9d06cea1c081e06c1b669700801aca7fc592..142d079b0f87a61efbaef0ef16f59893f484ea66 100644 --- a/process/Offer_lib/process.js +++ b/process/Offer_lib/process.js @@ -150,8 +150,8 @@ OfferUtils.buildOfferReport = function (pOfferID, pExclDiscountGroupcodes) "LETTERSALUTATION", // 15 "DISCOUNT", "NET", - "DISCOUNTED_NET", - "DISCOUNTED_VAT" + "OFFER.NET - OFFER.NET * OFFER.DISCOUNT / 100", + "OFFER.VAT - OFFER.VAT * OFFER.DISCOUNT / 100" ]; var offerData = newSelect(offerFields) @@ -451,24 +451,11 @@ OfferUtils.copyOfferItems = function (pSourceOfferId, pTargetOfferId, pDiscount) //update order price var [netPrice, vat] = oiUtils.getNetAndVat(); - var discountedVals = OfferItemUtils.getDiscountedNet(null, pSourceOfferId, pDiscount); - - if(discountedVals){ - newWhere("OFFER.OFFERID", pTargetOfferId) - .updateFields({ - "NET": netPrice, - "VAT": vat, - "DISCOUNTED_NET": discountedVals[0], - "DISCOUNTED_VAT": discountedVals[1] - }); - } - else{ - newWhere("OFFER.OFFERID", pTargetOfferId) - .updateFields({ - "NET": netPrice, - "VAT": vat - }); - } + newWhere("OFFER.OFFERID", pTargetOfferId) + .updateFields({ + "NET": netPrice, + "VAT": vat + }); } /** @@ -665,65 +652,6 @@ OfferItemUtils.updateOfferNet = function(pOfferId, pDiscount) { var oiUtils = new OfferItemUtils(pOfferId) var vals = oiUtils.getNetAndVat(); - var discountedVals = OfferItemUtils.getDiscountedNet(null, pOfferId, pDiscount); - if(discountedVals) - { - newWhere("OFFER.OFFERID", pOfferId).updateFields({ - NET: vals[0], VAT: vals[1], - DISCOUNTED_NET: discountedVals[0], - DISCOUNTED_VAT: discountedVals[1] - }); - } -} - -OfferItemUtils.getDiscountedNet = function(pExcludedIs, pOfferId, pDiscount, pExcludedProductgroups){ - pDiscount = pDiscount ? pDiscount : 0; - var ret; - var sum = 0; - var sumExcluded = 0; - var vat = 0; - var vatExcluded = 0; - if(pOfferId){ - var offeritemData = newSelect("QUANTITY, PRICE, DISCOUNT, VAT, OPTIONAL, ITEMPOSITION") - .from("OFFERITEM") - .where("OFFERITEM.OFFER_ID", pOfferId) - .andIfSet("OFFERITEM.GROUPCODEID", pExcludedProductgroups, SqlBuilder.NOT_IN()) - .andIfSet("OFFERITEM.OFFERITEMID", pExcludedIs, SqlBuilder.NOT_IN()) - .and("OFFERITEM.ASSIGNEDTO is null") - .table(); - for (var i = 0; i < offeritemData.length; i++) - { - if(!offeritemData[i][5].toString().includes(".")//only top items - && offeritemData[i][4] == "0")//which are not optional - { - sum = eMath.addDec(sum, eMath.subDec(offeritemData[i][1], offeritemData[i][1]/100*offeritemData[i][2])*offeritemData[i][0]); - vat = eMath.addDec(vat, offeritemData[i][3]*eMath.subDec(offeritemData[i][1], offeritemData[i][1]/100*offeritemData[i][2])*offeritemData[i][0]/100); - } - } - - sum = eMath.subDec(sum, eMath.divDec(eMath.mulDec(sum, pDiscount), "100")); - vat = eMath.subDec(vat, eMath.divDec(eMath.mulDec(vat, pDiscount), "100")); - - if(pExcludedProductgroups){ - var excludedOfferitemData = newSelect("QUANTITY, PRICE, DISCOUNT, VAT, OPTIONAL") - .from("OFFERITEM") - .where("OFFERITEM.OFFER_ID", pOfferId) - .and("OFFERITEM.GROUPCODEID", pExcludedProductgroups, SqlBuilder.IN()) - .andIfSet("OFFERITEM.OFFERITEMID", pExcludedIs, SqlBuilder.NOT_IN()) - .table(); - for (var j = 0; j < excludedOfferitemData.length; j++) - { - sumExcluded = eMath.addDec(sumExcluded, ItemUtils.prototype.getItemSum(excludedOfferitemData[j][0], excludedOfferitemData[j][1], excludedOfferitemData[j][2], excludedOfferitemData[j][4])); - vatExcluded = eMath.addDec(vatExcluded, ItemUtils.prototype.getItemVAT(excludedOfferitemData[i][0], excludedOfferitemData[i][1], excludedOfferitemData[i][2], excludedOfferitemData[i][3], excludedOfferitemData[i][4])); - } - } - if(sumExcluded){ - sum = eMath.addDec(sum, sumExcluded); - } - if(vatExcluded){ - vat = eMath.addDec(vat, vatExcluded); - } - } - ret = [sum, vat] - return ret; + newWhere("OFFER.OFFERID", pOfferId) + .updateFields({ NET: vals[0], VAT: vals[1] }); } diff --git a/process/Order_lib/process.js b/process/Order_lib/process.js index db4ee6805e7cb51a9c462099c9851bb779565b12..6b1efbe2688b0c887b241a561f9322ca0f512ca2 100644 --- a/process/Order_lib/process.js +++ b/process/Order_lib/process.js @@ -197,25 +197,11 @@ OrderUtils.copyOfferItemsToOrder = function (pSourceOfferId, pOrderId, pDiscount var oiUtils = new OrderItemUtils(pOrderId); //update order price var [netPrice, vat] = oiUtils.getNetAndVat(); - var discountedVals = OrderItemUtils.getDiscountedNet(null, pOrderId, pDiscount); - - if(discountedVals){ - newWhere("SALESORDER.SALESORDERID", pOrderId) - .updateFields({ - "NET": netPrice, - "VAT": vat, - "DISCOUNTED_NET": discountedVals[0], - "DISCOUNTED_VAT": discountedVals[1] - }); - } - else - { - newWhere("SALESORDER.SALESORDERID", pTargetOfferId) - .updateFields({ - "NET": netPrice, - "VAT": vat - }); - } + newWhere("SALESORDER.SALESORDERID", pTargetOfferId) + .updateFields({ + "NET": netPrice, + "VAT": vat + }); } /** @@ -241,26 +227,11 @@ OrderUtils.copyOrderItems = function (pSourceOrderId, pTargetOrderId, pDiscount) //update order price var [netPrice, vat] = oiUtils.getNetAndVat(); - var discountedVals = OrderItemUtils.getDiscountedNet(null, pSourceOrderId, pDiscount); - - if(discountedVals){ - newWhere("SALESORDER.SALESORDERID", pTargetOrderId) - .updateFields({ - "NET": netPrice, - "VAT": vat, - "DISCOUNTED_NET": discountedVals[0], - "DISCOUNTED_VAT": discountedVals[1] - }); - } - else - { - newWhere("SALESORDER.SALESORDERID", pTargetOfferId) - .updateFields({ - "NET": netPrice, - "VAT": vat - }); - } - + newWhere("SALESORDER.SALESORDERID", pTargetOfferId) + .updateFields({ + "NET": netPrice, + "VAT": vat + }); } /** @@ -796,67 +767,8 @@ OrderItemUtils.updateOrderNet = function(pOrderId, pDiscount) { var oiUtils = new OrderItemUtils(pOrderId); var vals = oiUtils.getNetAndVat(); - var discountedVals = OrderItemUtils.getDiscountedNet(null, pOrderId, pDiscount); - if(discountedVals) - { - newWhere("SALESORDER.SALESORDERID", pOrderId).updateFields({ - NET: vals[0], VAT: vals[1], - DISCOUNTED_NET: discountedVals[0], - DISCOUNTED_VAT: discountedVals[1] - }); - } -} - -OrderItemUtils.getDiscountedNet = function(pExcludedIs, pOrderId, pDiscount, pExcludedProductgroups){ - pDiscount = pDiscount || 0; - var ret; - var sum = 0; - var sumExcluded = 0; - var vat = 0; - var vatExcluded = 0; - if(pOrderId){ - var orderitemData = newSelect("QUANTITY, PRICE, DISCOUNT, VAT") - .from("SALESORDERITEM") - .where("SALESORDERITEM.SALESORDER_ID", pOrderId) - .andIfSet("SALESORDERITEM.GROUPCODEID", pExcludedProductgroups, SqlBuilder.NOT_IN()) - .andIfSet("SALESORDERITEM.SALESORDERITEMID", pExcludedIs, SqlBuilder.NOT_IN()) - .table(); - - for (var i = 0; i < orderitemData.length; i++) - { - sum = eMath.addDec(sum, ItemUtils.prototype.getItemSum(orderitemData[i][0], orderitemData[i][1], orderitemData[i][2])); - vat = eMath.addDec(vat, ItemUtils.prototype.getItemVAT(orderitemData[i][0], orderitemData[i][1], orderitemData[i][2], orderitemData[i][3])); - } - - sum = eMath.subDec(sum, eMath.divDec(eMath.mulDec(sum, pDiscount), "100")); - vat = eMath.subDec(vat, eMath.divDec(eMath.mulDec(vat, pDiscount), "100")); - - - if(pExcludedProductgroups) - { - var excludedOrderitemData = newSelect("QUANTITY, PRICE, DISCOUNT, VAT") - .from("SALESORDERITEM") - .where("SALESORDERITEM.SALESORDERITEM_ID", pOrderId) - .and("SALESORDERITEM.GROUPCODEID", pExcludedProductgroups, SqlBuilder.IN()) - .andIfSet("OFFERITEM.SALESORDERITEMID", pExcludedIs, SqlBuilder.NOT_IN()) - .table(); - - excludedOrderitemData.forEach(function(excludedOrderItem){ - sumExcluded = eMath.addDec(sumExcluded, ItemUtils.prototype.getItemSum(excludedOrderItem[0], excludedOrderItem[1], excludedOrderItem[2])); - vatExcluded = eMath.addDec(vatExcluded, ItemUtils.prototype.getItemVAT(excludedOrderitemData[i][0], excludedOrderitemData[i][1], excludedOrderitemData[i][2], excludedOrderitemData[i][3])); - }); - } - if(sumExcluded) - { - sum = eMath.addDec(sum, sumExcluded); - } - if(vatExcluded) - { - vat = eMath.addDec(vat, vatExcluded); - } - } - ret = [sum, vat]; - return ret; + newWhere("SALESORDER.SALESORDERID", pOrderId) + .updateFields({ NET: vals[0], VAT: vals[1] }); } /**