Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
basic
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Gitlab Maintenance 28.03.2025 | 20:00 - 23:00 MEZ
Show more breadcrumbs
xrm
basic
Commits
583c5bd1
Commit
583c5bd1
authored
6 years ago
by
Johannes Hörmann
Browse files
Options
Downloads
Patches
Plain Diff
refactor all libs
parent
67ac69b3
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
process/OfferOrder_lib/process.js
+38
-38
38 additions, 38 deletions
process/OfferOrder_lib/process.js
with
38 additions
and
38 deletions
process/OfferOrder_lib/process.js
+
38
−
38
View file @
583c5bd1
...
...
@@ -54,13 +54,13 @@ OfferUtils.getOfferNetAndVAT = function(offerId, offeritemIdsToDel) {
var
oiUtils
=
new
OfferItemUtils
(
offerId
);
var
condition
=
"
where OFFER_ID = '
"
+
offerId
+
"
'
"
;
if
(
offeritemIdsToDel
!=
undefined
)
if
(
offeritemIdsToDel
!=
undefined
)
condition
+=
"
and OFFERITEMID not in ('
"
+
offeritemIdsToDel
.
join
(
"
','
"
)
+
"
')
"
;
var
offerItems
=
db
.
table
(
"
select QUANTITY, PRICE, DISCOUNT, VAT, OPTIONAL
"
+
"
from OFFERITEM
"
+
condition
);
for
(
var
i
=
0
;
i
<
offerItems
.
length
;
i
++
)
for
(
var
i
=
0
;
i
<
offerItems
.
length
;
i
++
)
{
sum
+=
oiUtils
.
getItemSum
(
offerItems
[
i
][
0
],
offerItems
[
i
][
1
],
offerItems
[
i
][
2
],
offerItems
[
i
][
4
]);
vat
+=
oiUtils
.
getItemVAT
(
offerItems
[
i
][
0
],
offerItems
[
i
][
1
],
offerItems
[
i
][
2
],
offerItems
[
i
][
3
],
offerItems
[
i
][
4
]);
...
...
@@ -166,7 +166,7 @@ OfferItemUtils.prototype.reOrgItems = function() {
* @class
*/
function
ItemUtils
(
pOfferOrderId
)
{
if
(
this
.
constructor
===
ItemUtils
)
if
(
this
.
constructor
===
ItemUtils
)
throw
new
Error
(
"
Can't instantiate abstract class ItemUtils!
"
);
...
...
@@ -195,9 +195,9 @@ function ItemUtils(pOfferOrderId) {
* @ignore
*/
this
.
_appendNode
=
function
(
itemId
,
assignedTo
,
tree
,
ids
)
{
if
(
tree
==
undefined
)
if
(
tree
==
undefined
)
tree
=
this
.
ItemTree
;
if
(
ids
==
undefined
)
if
(
ids
==
undefined
)
ids
=
this
.
ItemIds
;
tree
[
itemId
]
=
this
.
_getItemTreeNodeObject
(
assignedTo
...
...
@@ -205,7 +205,7 @@ function ItemUtils(pOfferOrderId) {
,
this
.
getNextItemSort
(
ids
));
ids
.
push
(
itemId
);
if
(
assignedTo
!=
""
)
if
(
assignedTo
!=
""
)
{
tree
[
assignedTo
].
ids
.
push
(
itemId
);
}
...
...
@@ -222,9 +222,9 @@ function ItemUtils(pOfferOrderId) {
* @ignore
*/
this
.
_deleteNodes
=
function
(
itemId
,
tree
,
ids
)
{
if
(
tree
==
undefined
)
if
(
tree
==
undefined
)
tree
=
this
.
ItemTree
;
if
(
ids
==
undefined
)
if
(
ids
==
undefined
)
ids
=
this
.
ItemIds
;
__delete
(
tree
[
itemId
]);
...
...
@@ -232,7 +232,7 @@ function ItemUtils(pOfferOrderId) {
_deleteNode
(
itemId
);
function
__delete
(
pNode
)
{
for
(
var
i
=
0
;
i
<
pNode
.
ids
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
pNode
.
ids
.
length
;
i
++
)
{
__delete
(
tree
[
pNode
.
ids
[
i
]]);
_deleteNode
(
pNode
.
ids
[
i
]);
}
...
...
@@ -244,13 +244,13 @@ function ItemUtils(pOfferOrderId) {
//delete id in global Array "ItemIds"
var
idx
=
ids
.
indexOf
(
itemId
);
if
(
idx
>
-
1
)
if
(
idx
>
-
1
)
ids
.
splice
(
idx
,
1
);
//delete id in Array from property "ids" of Tree
for
(
var
oiid
in
tree
)
{
for
(
var
oiid
in
tree
)
{
idx
=
tree
[
oiid
].
ids
.
indexOf
(
itemId
);
if
(
idx
>
-
1
)
if
(
idx
>
-
1
)
tree
[
oiid
].
ids
.
splice
(
idx
,
1
);
}
}
...
...
@@ -271,17 +271,17 @@ function ItemUtils(pOfferOrderId) {
var
colTypes
=
db
.
getColumnTypes
(
table
,
cols
);
var
oiTree
=
this
.
ItemTree
;
for
(
var
oiid
in
compTree
)
{
if
(
oiTree
[
oiid
]
!=
undefined
)
{
for
(
var
oiid
in
compTree
)
{
if
(
oiTree
[
oiid
]
!=
undefined
)
{
//check if itemsort/pos has been changed
if
(
oiTree
[
oiid
].
itemsort
!=
compTree
[
oiid
].
itemsort
||
oiTree
[
oiid
].
pos
!=
compTree
[
oiid
].
pos
)
{
if
(
oiTree
[
oiid
].
itemsort
!=
compTree
[
oiid
].
itemsort
||
oiTree
[
oiid
].
pos
!=
compTree
[
oiid
].
pos
)
{
var
vals
=
[
compTree
[
oiid
].
itemsort
,
compTree
[
oiid
].
pos
];
statements
.
push
([
table
,
cols
,
colTypes
,
vals
,
table
+
"
ID = '
"
+
oiid
+
"
'
"
]);
}
}
}
if
(
statements
.
length
>
0
)
if
(
statements
.
length
>
0
)
db
.
updates
(
statements
);
}
}
...
...
@@ -296,22 +296,22 @@ function ItemUtils(pOfferOrderId) {
* @abstract
*/
ItemUtils
.
prototype
.
initItemTree
=
function
(
table
,
foreignKeyColumn
)
{
if
(
this
.
ItemTree
==
undefined
)
{
if
(
this
.
ItemTree
==
undefined
)
{
this
.
ItemTree
=
{};
this
.
ItemIds
=
[];
var
data
=
db
.
table
(
"
select
"
+
table
+
"
ID, ASSIGNEDTO, ITEMPOSITION, ITEMSORT from
"
+
table
+
"
where
"
+
foreignKeyColumn
+
"
= '
"
+
this
.
offerOrderId
+
"
' order by ITEMSORT
"
);
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
this
.
ItemTree
[
data
[
i
][
0
]]
=
this
.
_getItemTreeNodeObject
(
data
[
i
][
1
],
data
[
i
][
2
],
data
[
i
][
3
]);
this
.
ItemIds
.
push
(
data
[
i
][
0
]);
}
for
(
var
oiid
in
this
.
ItemTree
)
for
(
var
oiid
in
this
.
ItemTree
)
{
if
(
this
.
ItemTree
[
oiid
].
assignedto
!=
""
)
if
(
this
.
ItemTree
[
oiid
].
assignedto
!=
""
)
this
.
ItemTree
[
this
.
ItemTree
[
oiid
].
assignedto
].
ids
.
push
(
oiid
);
}
}
...
...
@@ -367,15 +367,15 @@ ItemUtils.prototype.insertPartsList = function(columns, table, productId, assign
//save address for this here to call methods in recursive sub function __itemInsertStatement
var
self
=
this
;
if
(
assignedTo
==
undefined
)
if
(
assignedTo
==
undefined
)
assignedTo
=
""
;
if
(
currency
==
undefined
)
if
(
currency
==
undefined
)
currency
=
""
;
if
(
relationId
==
undefined
)
if
(
relationId
==
undefined
)
relationId
=
""
;
var
rootProdId
=
productId
;
if
(
rootProdId
!=
""
)
{
if
(
rootProdId
!=
""
)
{
var
p2pUtils
=
new
Prod2ProdUtils
(
rootProdId
);
var
partsList
=
p2pUtils
.
getPartsListObject
();
...
...
@@ -384,7 +384,7 @@ ItemUtils.prototype.insertPartsList = function(columns, table, productId, assign
__itemInsertStatement
(
partsList
.
root
,
assignedTo
,
currency
,
relationId
);
if
(
statements
.
length
>
0
)
if
(
statements
.
length
>
0
)
db
.
inserts
(
statements
);
}
...
...
@@ -392,7 +392,7 @@ ItemUtils.prototype.insertPartsList = function(columns, table, productId, assign
//recursive function for building item insert statements
function
__itemInsertStatement
(
partsListObj
,
assignedTo
,
currency
,
relationId
)
{
for
(
var
i
=
0
;
i
<
partsListObj
.
ids
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
partsListObj
.
ids
.
length
;
i
++
)
{
var
newid
=
util
.
getNewUUID
();
self
.
_appendNode
(
newid
,
assignedTo
);
var
pos
=
self
.
ItemTree
[
newid
].
pos
;
...
...
@@ -405,7 +405,7 @@ ItemUtils.prototype.insertPartsList = function(columns, table, productId, assign
var
price
=
""
;
var
vat
=
""
;
if
(
P2pObject
.
takeprice
==
"
Y
"
&&
ProductDetails
.
productId
&&
ProductDetails
.
PriceListToUse
)
{
if
(
P2pObject
.
takeprice
==
"
Y
"
&&
ProductDetails
.
productId
&&
ProductDetails
.
PriceListToUse
)
{
price
=
ProductDetails
.
PriceListToUse
.
price
;
vat
=
ProductDetails
.
PriceListToUse
.
vat
;
}
...
...
@@ -454,7 +454,7 @@ ItemUtils.prototype.deletePartsList = function(itemId, table) {
__itemDeleteStatement
(
itemId
);
if
(
statements
.
length
>
0
)
if
(
statements
.
length
>
0
)
db
.
deletes
(
statements
);
self
.
_deleteNodes
(
itemId
);
...
...
@@ -465,7 +465,7 @@ ItemUtils.prototype.deletePartsList = function(itemId, table) {
function
__itemDeleteStatement
(
itemId
)
{
var
itemsToDelete
=
self
.
ItemTree
[
itemId
].
ids
;
for
(
var
i
=
0
;
i
<
itemsToDelete
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
itemsToDelete
.
length
;
i
++
)
{
//unshift due to foreign key constraints (Delete hierarchically starting at the bottom)
statements
.
unshift
([
table
,
table
+
"
ID = '
"
+
itemsToDelete
[
i
]
+
"
'
"
]);
deletedItemIds
.
push
(
itemsToDelete
[
i
]);
...
...
@@ -485,7 +485,7 @@ ItemUtils.prototype.deletePartsList = function(itemId, table) {
* @abstract
*/
ItemUtils
.
prototype
.
getNextItemSort
=
function
(
ids
)
{
if
(
ids
==
undefined
)
if
(
ids
==
undefined
)
ids
=
this
.
ItemIds
;
return
(
ids
.
length
+
1
).
toString
();
...
...
@@ -517,17 +517,17 @@ ItemUtils.prototype.getNextItemSort = function(ids) {
* @abstract
*/
ItemUtils
.
prototype
.
getNextItemPosition
=
function
(
assignedTo
,
tree
,
ids
)
{
if
(
assignedTo
==
undefined
)
if
(
assignedTo
==
undefined
)
assignedTo
=
""
;
if
(
tree
==
undefined
)
if
(
tree
==
undefined
)
tree
=
this
.
ItemTree
;
if
(
ids
==
undefined
)
if
(
ids
==
undefined
)
ids
=
this
.
ItemIds
;
var
maxPos
=
[
"
0
"
];
if
(
assignedTo
!=
""
)
{
if
(
tree
[
assignedTo
].
ids
.
length
<
1
)
{
//first item in this level
if
(
assignedTo
!=
""
)
{
if
(
tree
[
assignedTo
].
ids
.
length
<
1
)
{
//first item in this level
maxPos
=
tree
[
assignedTo
].
pos
.
split
(
"
.
"
);
maxPos
=
maxPos
.
concat
([
"
0
"
]);
//next level pos
}
else
{
...
...
@@ -535,7 +535,7 @@ ItemUtils.prototype.getNextItemPosition = function(assignedTo, tree, ids) {
maxPos
=
tree
[
childIds
[
childIds
.
length
-
1
]].
pos
.
split
(
"
.
"
);
}
}
else
{
if
(
ids
.
length
>
0
)
{
if
(
ids
.
length
>
0
)
{
maxPos
[
0
]
=
this
.
ItemTree
[
ids
[
ids
.
length
-
1
]].
pos
;
}
}
...
...
@@ -569,8 +569,8 @@ ItemUtils.prototype.reOrgItems = function(table) {
//recursive function to build new ItemTree Structure
function
__reorg
(
pIds
,
pAssignedTo
)
{
for
(
var
i
=
0
;
i
<
pIds
.
length
;
i
++
)
{
if
(
newTree
[
pIds
[
i
]]
==
undefined
)
{
for
(
var
i
=
0
;
i
<
pIds
.
length
;
i
++
)
{
if
(
newTree
[
pIds
[
i
]]
==
undefined
)
{
//build new tree
self
.
_appendNode
(
pIds
[
i
],
pAssignedTo
,
newTree
,
newIds
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment