- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
case 'create': {
promisesCount.create++;
try {
var data = item.data;
data.status = 'new';
data.syncItemType = item.data.itemType;
} catch (e) {
console.log('create');
console.log(e);
console.log(e.stack);
}
return new vow.Promise(function(resolve, reject){
//resolve();
app.crud.create('items', data, req.user).then(function () {
resolve();
}, function (error) {
reject(error)
});
});
}
case 'update': {
promisesCount.update++;
try{
var data = item.actual;
data.citiesPrices = item.data.citiesPrices;
if (item.actual.type == 'brick') {
for(var key in data.citiesPrices) {
data.citiesPrices[key] = item.data.citiesPrices.brickAllRegion;
}
}
data.syncItemType = item.data.itemType;
if (item.actual.type && item.actual.status == 'site') {
if (item.actual.type == 'brick') {
if (!item.data.convertion || !item.data.convertion.piecesInPalette || !item.data.convertion.piecesPerMeter) {
/*console.log(item.actual.type, item.actual.subType, item.actual.axaptaItemId);
console.log(indexProducers[item.actual.producer].name, indexCollections[item.actual.collection].name);*/
wrongItems.push(item);
wrongItemsCount.brick++;
} else {
rightItemsCount.brick++;
data.countInPallet = item.data.convertion.piecesInPalette;
data.piecesPerMeter = item.data.convertion.piecesPerMeter;
}
} else {
if (item.data.measure && ['кв.м.', 'шт.'].indexOf(item.data.measure) != -1) {
switch(item.data.measure) {
case 'кв.м.': {
if (!item.data.convertion || !item.data.convertion.metersInPalette || !item.data.convertion.metersInBox || !item.data.convertion.metersInPiece) {
/*console.log(item.actual.type, item.actual.subType, item.actual.axaptaItemId);
console.log(indexProducers[item.actual.producer].name, indexCollections[item.actual.collection].name);*/
wrongItems.push(item);
wrongItemsCount.clinkerItems++;
} else {
rightItemsCount.clinkerItems++;
data.countInPallet = parseInt(item.data.convertion.metersInPalette / item.data.convertion.metersInBox);
data.countInPack = parseInt(item.data.convertion.metersInBox / item.data.convertion.metersInPiece);
}
break;
}
case 'шт.': {
if (!item.data.convertion || !item.data.convertion.piecesInBox) {
/*console.log(item.actual.type, item.actual.subType, item.actual.axaptaItemId);
console.log(indexProducers[item.actual.producer].name, indexCollections[item.actual.collection].name);*/
wrongItems.push(item);
wrongItemsCount.clinkerMeters++;
} else {
rightItemsCount.clinkerMeters++;
data.countInPack = item.data.convertion.piecesInBox;
}
break;
}
}
}
}
}
} catch(e) {
console.log('update');
console.log(e);
console.log(e.stack);
}