@bytebrand/export-cars 1.21.35 → 1.21.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/export-cars",
3
- "version": "1.21.35",
3
+ "version": "1.21.37",
4
4
  "description": "",
5
5
  "author": "bytebrand",
6
6
  "license": "UNLICENSED",
@@ -58,4 +58,4 @@
58
58
  "node": ">=14.0.0"
59
59
  },
60
60
  "gitHead": "e827f35865032821bf3a081f03a026d3d3f8a540"
61
- }
61
+ }
@@ -3,6 +3,7 @@ import { ModuleRef } from '@nestjs/core';
3
3
 
4
4
  import { CronicleUtils } from '@bytebrand/cronicle-helper';
5
5
  import { FsChunkInterface } from '@bytebrand/chunkable';
6
+ import { Car } from '@bytebrand/car-schema/dist/schema/data';
6
7
 
7
8
  import { CarService, RulesService, LoaderService, ConfigService } from '../services';
8
9
  import { MobileTransformer } from '../transformers/mobile.transformer';
@@ -37,10 +38,11 @@ export class SantanderExporter implements Exporter {
37
38
  if (chunk && chunk.data) {
38
39
  for (const data of chunk.data) {
39
40
  const { car, images } = data;
40
- const transformedData = await santanderTransformer.transform(car, images);
41
- const transformedNormalizedData = await santanderTransformer.normalizeCarData(transformedData);
42
- await santanderCSVBuilder.addItem(transformedNormalizedData);
43
-
41
+ if (!(!car.mainData.firstRegistration && car.mainData.mileage > 1000)) {
42
+ const transformedData = await santanderTransformer.transform(car, images);
43
+ const transformedNormalizedData = await santanderTransformer.normalizeCarData(transformedData);
44
+ await santanderCSVBuilder.addItem(transformedNormalizedData);
45
+ }
44
46
  this.carService.counter.countCar(images);
45
47
  }
46
48
  }
@@ -413,7 +413,7 @@ export class MobileTransformer {
413
413
  return this.booleanToString(match);
414
414
  }
415
415
 
416
- private dateToString(fieldValue: number, rule: MappingRules): string {
416
+ protected dateToString(fieldValue: number, rule: MappingRules): string {
417
417
  const date = new Date(fieldValue * 1000);
418
418
  if (["['6']", "['7']", "['8']"].includes(rule.importField)) {
419
419
  return `${date.getMonth() + 1}.${date.getFullYear()}`;
@@ -13,6 +13,7 @@ import { isNotEmptyArray } from '../utils';
13
13
  import { ConfigService } from '../services';
14
14
  import { ExportType } from '../enums';
15
15
  import { MobileTransformer } from './mobile.transformer';
16
+ import { Car } from '@bytebrand/car-schema/dist/schema/data';
16
17
 
17
18
  const vinGenerator = require('vin-generator');
18
19
 
@@ -27,6 +28,22 @@ export class SantanderTransformer extends MobileTransformer {
27
28
  super(mappingService, userService, configService, imagesService);
28
29
  }
29
30
 
31
+ protected dateToString(fieldValue: number, rule: MappingRules): string {
32
+ const date = new Date(fieldValue * 1000);
33
+ if (rule.importField === "['8']") {
34
+ if (!fieldValue) {
35
+ const now = new Date()
36
+ const month = String(now.getMonth() + 1);
37
+ const year = now.getFullYear();
38
+ return `${month}.${year}`;
39
+ }
40
+ }
41
+ if (["['6']", "['7']", "['8']"].includes(rule.importField)) {
42
+ return `${date.getMonth() + 1}.${date.getFullYear()}`;
43
+ }
44
+ return `${date.getDate()}.${date.getMonth() + 1}.${date.getFullYear()}`;
45
+ }
46
+
30
47
  async normalizeCarData(transformedCarData: unknown) {
31
48
  const data = transformedCarData as Array<{ [key: string]: any }>;
32
49