billing aws
diff --git a/services/billing-aws/billing.yml b/services/billing-aws/billing.yml
index 9175c98..3b1943f 100644
--- a/services/billing-aws/billing.yml
+++ b/services/billing-aws/billing.yml
@@ -32,11 +32,6 @@
 password: MONGO_PASSWORD
 database: dlabdb
 
-scheduler:
-# Schedule is comma separated values of time in format hh[:mm[:ss]]. hh - in the 24-hour clock, at 8:15PM is 20:15.
-  schedule: 0:00, 1:00, 2:00, 3:00, 4:00, 5:00, 6:00, 7:00, 8:00, 9:00, 10:00, 11:00, 12:00, 13:00, 14:00, 15:00, 16:00,
-    17:00, 18:00, 19:00, 20:00, 21:00, 22:00, 23:00
-
 # Adapter for reading source data. Known types: file, s3file
 adapterIn:
   - type: s3file
diff --git a/services/billing-aws/src/main/java/com/epam/dlab/BillingAwsApplication.java b/services/billing-aws/src/main/java/com/epam/dlab/BillingAwsApplication.java
index cede034..c878370 100644
--- a/services/billing-aws/src/main/java/com/epam/dlab/BillingAwsApplication.java
+++ b/services/billing-aws/src/main/java/com/epam/dlab/BillingAwsApplication.java
@@ -32,6 +32,6 @@
 
     public static void main(String[] args) throws InitializationException {
         SpringApplication.run(BillingAwsApplication.class, args);
-        BillingScheduler.startScheduler(args);
+        BillingServiceImpl.startApplication(args);
     }
 }
diff --git a/services/billing-aws/src/main/java/com/epam/dlab/BillingScheduler.java b/services/billing-aws/src/main/java/com/epam/dlab/BillingScheduler.java
deleted file mode 100644
index 7a7d5ff..0000000
--- a/services/billing-aws/src/main/java/com/epam/dlab/BillingScheduler.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.epam.dlab;
-
-import com.epam.dlab.configuration.BillingToolConfiguration;
-import com.epam.dlab.configuration.BillingToolConfigurationFactory;
-import com.epam.dlab.configuration.SchedulerConfiguration;
-import com.epam.dlab.core.parser.ParserBase;
-import com.epam.dlab.exceptions.AdapterException;
-import com.epam.dlab.exceptions.DlabException;
-import com.epam.dlab.exceptions.InitializationException;
-import com.epam.dlab.exceptions.ParseException;
-import com.epam.dlab.util.ServiceUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-
-/**
- * Billing scheduler for loading billing report.
- */
-public class BillingScheduler implements Runnable {
-	private static final Logger LOGGER = LoggerFactory.getLogger(BillingScheduler.class);
-
-	/**
-	 * Timeout for check the schedule in milliseconds.
-	 */
-	private static final long CHECK_TIMEOUT_MILLIS = 60000;
-
-	/**
-	 * Billing scheduler instance.
-	 */
-	private static BillingScheduler scheduler;
-	private final boolean enabled;
-	private final BillingToolConfiguration configuration;
-
-	/**
-	 * Starts the scheduler for given configuration.
-	 *
-	 * @param filename the name of file for billing configuration.
-	 * @throws InitializationException
-	 */
-	public static void start(String filename) throws InitializationException {
-		if (scheduler == null) {
-			scheduler = new BillingScheduler(filename);
-			scheduler.thread.start();
-		} else {
-			LOGGER.debug("Billing scheduler already started");
-		}
-	}
-
-	/**
-	 * Stops the scheduler.
-	 */
-	public static void stop() {
-		if (scheduler.thread != null) {
-			LOGGER.debug("Billing scheduler will be stopped ...");
-			synchronized (scheduler.thread) {
-				scheduler.thread.interrupt();
-				scheduler.thread = null;
-			}
-			LOGGER.info("Scheduler has been stopped");
-		}
-	}
-
-
-	/**
-	 * Thread of the scheduler.
-	 */
-	private Thread thread = new Thread(this, this.getClass().getSimpleName());
-
-	/**
-	 * Name of configuration file.
-	 */
-	private final String confFilename;
-
-	/**
-	 * Current schedule.
-	 */
-	private SchedulerConfiguration schedule;
-
-	/**
-	 * Instantiate billing scheduler for given configuration.
-	 *
-	 * @param filename the name of file for billing configuration.
-	 * @throws InitializationException
-	 */
-	public BillingScheduler(String filename) throws InitializationException {
-		this.confFilename = filename;
-		LOGGER.debug("Billing report configuration file: {}", filename);
-		configuration = BillingToolConfigurationFactory.build(confFilename, BillingToolConfiguration.class);
-		this.enabled = configuration.isBillingEnabled();
-		setSchedule(configuration);
-	}
-
-	/**
-	 * Loads the billing report.
-	 *
-	 * @throws InitializationException
-	 * @throws AdapterException
-	 * @throws ParseException
-	 */
-	private void load() throws InitializationException, AdapterException, ParseException {
-		ParserBase parser = configuration.build();
-		long time = schedule.getNearTime().getTimeInMillis();
-		if (setSchedule(configuration)) {
-			if (time != schedule.getNearTime().getTimeInMillis()) {
-				LOGGER.info("Previous billing schedule has been canceled");
-				return;
-			}
-		}
-
-		LOGGER.info("Try to laod billing report for configuration: {}", configuration);
-		parser.parse();
-		if (!parser.getStatistics().isEmpty()) {
-			LOGGER.info("Billing report parser statistics:");
-			for (int i = 0; i < parser.getStatistics().size(); i++) {
-				LOGGER.info("  {}", parser.getStatistics().get(i).toString());
-			}
-		}
-	}
-
-	/**
-	 * Read the schedule from configuration.
-	 *
-	 * @param configuration the billing configuration.
-	 * @return <b>true>/b> if new schedule was loaded, otherwise <b>false</b>.
-	 * @throws InitializationException
-	 */
-	private boolean setSchedule(BillingToolConfiguration configuration) throws InitializationException {
-		SchedulerConfiguration schedulerConfiguration = configuration.getScheduler();
-		boolean isModified = false;
-		if (schedulerConfiguration == null) {
-			throw new InitializationException(String.format("Schedule of billing report in configuration file \"%s " +
-					"not found", confFilename));
-		}
-		if (this.schedule == null) {
-			isModified = true;
-			LOGGER.debug("Billing report schedule: {}", schedulerConfiguration);
-		} else {
-			this.schedule.adjustStartTime();
-			if (!schedulerConfiguration.equals(this.schedule)) {
-				isModified = true;
-				LOGGER.debug("New billing report schedule has been loaded: {}", schedulerConfiguration);
-			}
-		}
-
-		try {
-			this.schedule = new SchedulerConfiguration();
-			this.schedule.setSchedule(schedulerConfiguration.getSchedule());
-			this.schedule.build();
-		} catch (Exception e) {
-			throw new InitializationException("Cannot configure billing scheduler. " + e.getLocalizedMessage(), e);
-		}
-
-		return isModified;
-	}
-
-	@Override
-	public void run() {
-		if (enabled) {
-			LOGGER.info("Billing scheduler has been started");
-			long startTimeMillis = schedule.getNextTime().getTimeInMillis();
-			long timeMillis;
-			LOGGER.info("Billing report will be loaded at {}", schedule.getNextTime().getTime());
-
-			try {
-				while (!Thread.currentThread().isInterrupted()) {
-					if (startTimeMillis <= System.currentTimeMillis()) {
-						try {
-							LOGGER.debug("Try to load billing report for schedule {}",
-									schedule.getNextTime().getTime());
-							load();
-						} catch (InitializationException | AdapterException | ParseException e) {
-							LOGGER.error("Error loading billing report: {}", e.getLocalizedMessage(), e);
-						}
-						startTimeMillis = schedule.getNextTime().getTimeInMillis();
-						LOGGER.info("Billing report will be loaded at {}", schedule.getNextTime().getTime());
-					} else {
-						schedule.adjustStartTime();
-						timeMillis = schedule.getNextTime().getTimeInMillis();
-						if (startTimeMillis != timeMillis) {
-							LOGGER.info("Billing report will be loaded at {}", schedule.getNextTime().getTime());
-							startTimeMillis = timeMillis;
-						}
-					}
-
-					try {
-						timeMillis = startTimeMillis - System.currentTimeMillis();
-						if (timeMillis > 0) {
-							timeMillis = Math.min(CHECK_TIMEOUT_MILLIS, timeMillis);
-							Thread.sleep(timeMillis);
-						}
-					} catch (InterruptedException e) {
-						LOGGER.warn("Billing scheduler interrupted", e);
-						Thread.currentThread().interrupt();
-					}
-				}
-			} catch (Exception e) {
-				LOGGER.error("Unhandled billing report error: {}", e.getLocalizedMessage(), e);
-			}
-			LOGGER.info("Scheduler has been stopped");
-		} else {
-			LOGGER.info("Billing scheduler is disabled");
-		}
-	}
-
-
-	/**
-	 * Runs billing scheduler for given configuration file.
-	 *
-	 * @param args the arguments of command line.
-	 * @throws InitializationException
-	 */
-	public static void startScheduler(String[] args) throws InitializationException {
-		if (ServiceUtils.printAppVersion(BillingTool.class, args)) {
-			return;
-		}
-
-		String confName = null;
-		for (int i = 0; i < args.length; i++) {
-			if (BillingTool.isKey("help", args[i])) {
-				i++;
-				Help.usage(i < args.length ? Arrays.copyOfRange(args, i, args.length) : null);
-				return;
-			} else if (BillingTool.isKey("conf", args[i])) {
-				i++;
-				if (i < args.length) {
-					confName = args[i];
-				} else {
-					throw new InitializationException("Missing the name of configuration file");
-				}
-			}
-		}
-
-		if (confName == null) {
-			Help.usage();
-			throw new InitializationException("Missing arguments");
-		}
-
-		BillingTool.setLoggerLevel();
-		try {
-			start(confName);
-		} catch (Exception e) {
-			throw new DlabException("Billing scheduler failed", e);
-		}
-	}
-}
diff --git a/services/billing-aws/src/main/java/com/epam/dlab/dao/BillingDAO.java b/services/billing-aws/src/main/java/com/epam/dlab/BillingService.java
similarity index 78%
rename from services/billing-aws/src/main/java/com/epam/dlab/dao/BillingDAO.java
rename to services/billing-aws/src/main/java/com/epam/dlab/BillingService.java
index f72fa99..9b4d6db 100644
--- a/services/billing-aws/src/main/java/com/epam/dlab/dao/BillingDAO.java
+++ b/services/billing-aws/src/main/java/com/epam/dlab/BillingService.java
@@ -17,15 +17,12 @@
  * under the License.
  */
 
-package com.epam.dlab.dao;
+package com.epam.dlab;
 
 import com.epam.dlab.dto.billing.BillingData;
 
 import java.util.List;
 
-public interface BillingDAO {
-
-    List<BillingData> getBillingReport(String dateStart, String dateEnd, String dlabId, List<String> products);
-
-    List<BillingData> getBillingReport(List<String> dlabIds);
+public interface BillingService {
+    List<BillingData> getBillingData();
 }
diff --git a/services/billing-aws/src/main/java/com/epam/dlab/BillingServiceImpl.java b/services/billing-aws/src/main/java/com/epam/dlab/BillingServiceImpl.java
new file mode 100644
index 0000000..8da6402
--- /dev/null
+++ b/services/billing-aws/src/main/java/com/epam/dlab/BillingServiceImpl.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.epam.dlab;
+
+import com.epam.dlab.configuration.BillingToolConfiguration;
+import com.epam.dlab.configuration.BillingToolConfigurationFactory;
+import com.epam.dlab.core.parser.ParserBase;
+import com.epam.dlab.dto.billing.BillingData;
+import com.epam.dlab.exceptions.DlabException;
+import com.epam.dlab.exceptions.InitializationException;
+import com.epam.dlab.util.ServiceUtils;
+import org.bson.Document;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import static com.epam.dlab.model.aws.ReportLine.FIELD_COST;
+import static com.epam.dlab.model.aws.ReportLine.FIELD_CURRENCY_CODE;
+import static com.epam.dlab.model.aws.ReportLine.FIELD_DLAB_ID;
+import static com.epam.dlab.model.aws.ReportLine.FIELD_PRODUCT;
+import static com.epam.dlab.model.aws.ReportLine.FIELD_RESOURCE_TYPE;
+import static com.epam.dlab.model.aws.ReportLine.FIELD_USAGE_DATE;
+
+@Service
+public class BillingServiceImpl implements BillingService {
+	private static final Logger LOGGER = LoggerFactory.getLogger(BillingServiceImpl.class);
+	private static BillingToolConfiguration configuration;
+
+	public List<BillingData> getBillingData() {
+		try {
+			ParserBase parser = configuration.build();
+
+			LOGGER.info("Try to load billing report for configuration: {}", configuration);
+			List<BillingData> billingData = parser.parse()
+					.stream()
+					.map(this::toBillingData)
+					.collect(Collectors.toList());
+
+			if (!parser.getStatistics().isEmpty()) {
+				LOGGER.info("Billing report parser statistics:");
+				for (int i = 0; i < parser.getStatistics().size(); i++) {
+					LOGGER.info("  {}", parser.getStatistics().get(i).toString());
+				}
+			}
+
+			return billingData;
+		} catch (Exception e) {
+			LOGGER.error("Something went wrong ", e);
+			return Collections.emptyList();
+		}
+	}
+
+	private BillingData toBillingData(Document billingData) {
+		return BillingData.builder()
+				.tag(billingData.getString(FIELD_DLAB_ID))
+				.usageDateFrom(Optional.ofNullable(billingData.getString("from")).map(LocalDate::parse).orElse(null))
+				.usageDateTo(Optional.ofNullable(billingData.getString("to")).map(LocalDate::parse).orElse(null))
+				.usageDate(billingData.getString(FIELD_USAGE_DATE))
+				.product(billingData.getString(FIELD_PRODUCT))
+				.usageType(billingData.getString(FIELD_RESOURCE_TYPE))
+				.cost(BigDecimal.valueOf(billingData.getDouble(FIELD_COST)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue())
+				.currency(billingData.getString(FIELD_CURRENCY_CODE))
+				.build();
+	}
+
+	public static void initialize(String filename) throws InitializationException {
+		LOGGER.debug("Billing report configuration file: {}", filename);
+		configuration = BillingToolConfigurationFactory.build(filename, BillingToolConfiguration.class);
+	}
+
+	public static void startApplication(String[] args) throws InitializationException {
+		if (ServiceUtils.printAppVersion(BillingTool.class, args)) {
+			return;
+		}
+
+		String confName = null;
+		for (int i = 0; i < args.length; i++) {
+			if (BillingTool.isKey("help", args[i])) {
+				i++;
+				Help.usage(i < args.length ? Arrays.copyOfRange(args, i, args.length) : null);
+				return;
+			} else if (BillingTool.isKey("conf", args[i])) {
+				i++;
+				if (i < args.length) {
+					confName = args[i];
+				} else {
+					throw new InitializationException("Missing the name of configuration file");
+				}
+			}
+		}
+
+		if (confName == null) {
+			Help.usage();
+			throw new InitializationException("Missing arguments");
+		}
+
+		BillingTool.setLoggerLevel();
+		try {
+			initialize(confName);
+		} catch (Exception e) {
+			throw new DlabException("Billing scheduler failed", e);
+		}
+	}
+}
diff --git a/services/billing-aws/src/main/java/com/epam/dlab/BillingTool.java b/services/billing-aws/src/main/java/com/epam/dlab/BillingTool.java
index cf2b8d6..cde9d4e 100644
--- a/services/billing-aws/src/main/java/com/epam/dlab/BillingTool.java
+++ b/services/billing-aws/src/main/java/com/epam/dlab/BillingTool.java
@@ -19,24 +19,22 @@
 
 package com.epam.dlab;
 
-import java.util.Arrays;
-
-import com.epam.dlab.exceptions.DlabException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.LoggerContext;
 import com.epam.dlab.configuration.BillingToolConfiguration;
 import com.epam.dlab.configuration.BillingToolConfigurationFactory;
 import com.epam.dlab.core.parser.ParserBase;
 import com.epam.dlab.exceptions.AdapterException;
+import com.epam.dlab.exceptions.DlabException;
 import com.epam.dlab.exceptions.InitializationException;
 import com.epam.dlab.exceptions.ParseException;
 import com.epam.dlab.util.ServiceUtils;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.LoggerContext;
+import java.util.Arrays;
 
 /** Provides billing parser features.
  */
@@ -110,14 +108,14 @@
 	 * @throws InitializationException
 	 */
 	public static void main(String[] args) throws InitializationException {
-		if (ServiceUtils.printAppVersion(BillingScheduler.class, args)) {
+		if (ServiceUtils.printAppVersion(BillingServiceImpl.class, args)) {
 			return;
 		}
 
 		String confName = null;
 		String json = null;
-		
-		for(int i = 0; i < args.length; i++) {
+
+		for (int i = 0; i < args.length; i++) {
 			if (isKey("help", args[i])) {
 				i++;
 				Help.usage(i < args.length ? Arrays.copyOfRange(args, i, args.length) : null);
diff --git a/services/billing-aws/src/main/java/com/epam/dlab/Help.java b/services/billing-aws/src/main/java/com/epam/dlab/Help.java
index 2a043c2..c2fe5c2 100644
--- a/services/billing-aws/src/main/java/com/epam/dlab/Help.java
+++ b/services/billing-aws/src/main/java/com/epam/dlab/Help.java
@@ -19,18 +19,17 @@
 
 package com.epam.dlab;
 
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.lang3.StringUtils;
-
 import com.epam.dlab.core.BillingUtils;
 import com.epam.dlab.core.ModuleType;
 import com.epam.dlab.exceptions.InitializationException;
 import com.fasterxml.jackson.annotation.JsonClassDescription;
 import com.fasterxml.jackson.annotation.JsonTypeName;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /** Print help for billing tool.
  */
@@ -47,12 +46,12 @@
 	private static void printHelp(String resourceName, Map<String, String> substitute) throws InitializationException {
 		List<String> list = BillingUtils.getResourceAsList("/" + Help.class.getName() + "." + resourceName + ".txt");
 		String help = StringUtils.join(list, System.lineSeparator());
-		
+
 		if (substitute == null) {
 			substitute = new HashMap<>();
 		}
-		substitute.put("classname", BillingScheduler.class.getName());
-		
+		substitute.put("classname", BillingServiceImpl.class.getName());
+
 		for (String key : substitute.keySet()) {
 			help = StringUtils.replace(help, "${" + key.toUpperCase() + "}", substitute.get(key));
 		}
diff --git a/services/billing-aws/src/main/java/com/epam/dlab/configuration/BillingToolConfiguration.java b/services/billing-aws/src/main/java/com/epam/dlab/configuration/BillingToolConfiguration.java
index 803d232..420b9e0 100644
--- a/services/billing-aws/src/main/java/com/epam/dlab/configuration/BillingToolConfiguration.java
+++ b/services/billing-aws/src/main/java/com/epam/dlab/configuration/BillingToolConfiguration.java
@@ -77,13 +77,6 @@
 	private boolean billingEnabled;
 
 	/**
-	 * Working data file name of modules.
-	 */
-	@Valid
-	@JsonProperty
-	private SchedulerConfiguration scheduler = null;
-
-	/**
 	 * Adapter for reading source data.
 	 */
 	@Valid
@@ -136,20 +129,6 @@
 	}
 
 	/**
-	 * Set the scheduler.
-	 */
-	public void setScheduler(SchedulerConfiguration scheduler) {
-		this.scheduler = scheduler;
-	}
-
-	/**
-	 * Return the scheduler.
-	 */
-	public SchedulerConfiguration getScheduler() {
-		return scheduler;
-	}
-
-	/**
 	 * Set the adapter for reading source data.
 	 */
 	public void setAdapterIn(ImmutableList<AdapterBase> adapter) {
@@ -272,14 +251,6 @@
 			f.setModuleData(moduleData);
 		}
 
-		if (scheduler != null) {
-			try {
-				scheduler.build();
-			} catch (Exception e) {
-				throw new InitializationException("Cannot configure billing scheduler. " + e.getLocalizedMessage(), e);
-			}
-		}
-
 		return parser.build(in, out, f);
 	}
 
@@ -295,7 +266,6 @@
 	public ToStringHelper toStringHelper(Object self) {
 		return MoreObjects.toStringHelper(self)
 				.add("moduleData", moduleData)
-				.add("scheduler", scheduler)
 				.add("adapterIn", adapterIn)
 				.add("adapterOut", adapterOut)
 				.add("filter", filter)
diff --git a/services/billing-aws/src/main/java/com/epam/dlab/configuration/SchedulerConfiguration.java b/services/billing-aws/src/main/java/com/epam/dlab/configuration/SchedulerConfiguration.java
deleted file mode 100644
index b0624d6..0000000
--- a/services/billing-aws/src/main/java/com/epam/dlab/configuration/SchedulerConfiguration.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.epam.dlab.configuration;
-
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.apache.commons.lang3.StringUtils;
-
-import com.epam.dlab.exceptions.ParseException;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-
-/** Provides schedule time configuration.
- */
-public class SchedulerConfiguration {
-	
-	/** User's schedule. */
-	@JsonProperty
-	private String schedule = "12, 13:30:23, 18:34, 08:50, 7:80";
-	
-	
-	/** Return the schedule of user.
-	 */
-	public String getSchedule() {
-		return schedule;
-	}
-	
-	/** Set the schedule of user.
-	 */
-	public void setSchedule(String schedule) {
-		this.schedule = schedule;
-	}
-	
-	
-	/** Schedule. */
-	private Map<String, Calendar> realSchedule = new TreeMap<>();
-	
-	/** Build the schedule from user' schedule.
-	 * @throws ParseException
-	 */
-	public void build() throws ParseException {
-		SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
-		String [] unitArray = schedule.split(",");
-		realSchedule.clear();
-		for (int i = 0; i < unitArray.length; i++) {
-			Calendar date = Calendar.getInstance();
-			int [] time = getTime(unitArray[i]);
-			try {
-				df.parse(StringUtils.join(time, ':'));
-			} catch (Exception e) {
-				throw new ParseException("Cannot parse date " + unitArray[i] + ". " + e.getLocalizedMessage(), e);
-			}
-			date.clear();
-			date.set(1, 1, 1, time[0], time[1], time[2]);
-			realSchedule.put(df.format(date.getTime()), date);
-		}
-		adjustStartTime();
-	}
-	
-	/** Return the schedule.
-	 */
-	public Map<String, Calendar> getRealSchedule() {
-		return realSchedule;
-	}
-	
-	/** Return time array of user' schedule time.
-	 * @param time the time in format HH:mm:ss.
-	 * @throws ParseException
-	 */
-	private int [] getTime(String time) throws ParseException {
-		String [] timeString = time.trim().split(":");
-		int [] timeInt = new int[3];
-		
-		for (int i = 0; i < timeInt.length; i++) {
-			if (i < timeString.length) {
-				try {
-					timeInt[i] = Integer.parseInt(timeString[i]);
-				} catch (Exception e) {
-					throw new ParseException("Cannot parse date " + time + ". " + e.getLocalizedMessage(), e);
-				}
-			} else {
-				timeInt[i] = 0;
-			}
-		}
-		
-		return timeInt;
-	}
-
-	/** Adjust the time in schedule for current time.
-	 */
-	public void adjustStartTime() {
-		Calendar now = Calendar.getInstance();
-		for(String key : realSchedule.keySet()) {
-			Calendar time = realSchedule.get(key);
-			if (time.before(now)) {
-				time.set(now.get(Calendar.YEAR),
-						now.get(Calendar.MONTH),
-						now.get(Calendar.DAY_OF_MONTH),
-						time.get(Calendar.HOUR_OF_DAY),
-						time.get(Calendar.MINUTE),
-						time.get(Calendar.SECOND));
-				if (time.before(now)) {
-					time.add(Calendar.DAY_OF_MONTH, 1);
-				}
-				realSchedule.put(key, time);
-			}
-		}
-	}
-	
-	/** Return the key of the next start time from the schedule.
-	 */
-	public String getNextTimeKey() {
-		long now = System.currentTimeMillis();
-		String nextKey = null;
-		long nextTime = -1;
-		
-		for(String key : realSchedule.keySet()) {
-			long time = realSchedule.get(key).getTimeInMillis();
-			if ((time >= now && time < nextTime) || nextTime == -1) {
-				nextTime = time;
-				nextKey = key;
-			}
-		}
-		return nextKey;
-	}
-	
-	/** Return the next start time from the schedule.
-	 */
-	public Calendar getNextTime() {
-		String key = getNextTimeKey();
-		return (key == null ? null : realSchedule.get(key));
-	}
-	
-	/** Return the key of the near start time from the schedule to the current time.
-	 */
-	public String getNearTimeKey() {
-		long now = System.currentTimeMillis();
-		String nextKey = null;
-		long nextTime = -1;
-		
-		for(String key : realSchedule.keySet()) {
-			long time = Math.abs(now - realSchedule.get(key).getTimeInMillis());
-			if (time < nextTime || nextTime == -1) {
-				nextTime = time;
-				nextKey = key;
-			}
-		}
-		return nextKey;
-	}
-	
-	/** Return the near start time from the schedule to the current time.
-	 */
-	public Calendar getNearTime() {
-		String key = getNearTimeKey();
-		return (key == null ? null : realSchedule.get(key));
-	}
-	
-	/** Returns a string representation of the object.
-	 * @param self the object to generate the string for (typically this), used only for its class name.
-	 */
-	public ToStringHelper toStringHelper(Object self) {
-		SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
-		ToStringHelper helper = MoreObjects.toStringHelper(self);
-		for(String key : realSchedule.keySet()) {
-			Calendar time = realSchedule.get(key);
-			helper.add(key, df.format(time.getTime()));
-		}
-    	return helper;
-    }
-    
-    @Override
-    public String toString() {
-    	return toStringHelper(this)
-    			.toString();
-    }
-
-	@Override
-	public boolean equals(Object o) {
-		if (this == o) return true;
-		if (!(o instanceof SchedulerConfiguration)) return false;
-
-		SchedulerConfiguration that = (SchedulerConfiguration) o;
-
-		return getRealSchedule() != null ? getRealSchedule().keySet().equals(that.getRealSchedule().keySet())
-				: that.getRealSchedule() == null;
-	}
-
-	@Override
-	public int hashCode() {
-		return getRealSchedule() != null ? getRealSchedule().keySet().hashCode() : 0;
-	}
-}
diff --git a/services/billing-aws/src/main/java/com/epam/dlab/controller/BillingController.java b/services/billing-aws/src/main/java/com/epam/dlab/controller/BillingController.java
index 8f70083..deabf44 100644
--- a/services/billing-aws/src/main/java/com/epam/dlab/controller/BillingController.java
+++ b/services/billing-aws/src/main/java/com/epam/dlab/controller/BillingController.java
@@ -19,12 +19,11 @@
 
 package com.epam.dlab.controller;
 
-import com.epam.dlab.dao.BillingDAO;
+import com.epam.dlab.BillingService;
 import com.epam.dlab.dto.billing.BillingData;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
@@ -32,22 +31,14 @@
 @RestController
 public class BillingController {
 
-    private final BillingDAO billingDAO;
+    private final BillingService billingService;
 
-    public BillingController(BillingDAO billingDAO) {
-        this.billingDAO = billingDAO;
+    public BillingController(BillingService billingService) {
+        this.billingService = billingService;
     }
 
     @GetMapping
-    public ResponseEntity<List<BillingData>> getBilling(@RequestParam List<String> dlabIds) {
-        return new ResponseEntity<>(billingDAO.getBillingReport(dlabIds), HttpStatus.OK);
-    }
-
-    @GetMapping("/report")
-    public ResponseEntity<List<BillingData>> getBilling(@RequestParam("date-start") String dateStart,
-                                                        @RequestParam("date-end") String dateEnd,
-                                                        @RequestParam("dlab-id") String dlabId,
-                                                        @RequestParam("product") List<String> products) {
-        return new ResponseEntity<>(billingDAO.getBillingReport(dateStart, dateEnd, dlabId, products), HttpStatus.OK);
+    public ResponseEntity<List<BillingData>> getBilling() {
+        return new ResponseEntity<>(billingService.getBillingData(), HttpStatus.OK);
     }
 }
diff --git a/services/billing-aws/src/main/java/com/epam/dlab/core/AdapterBase.java b/services/billing-aws/src/main/java/com/epam/dlab/core/AdapterBase.java
index 1569530..475404d 100644
--- a/services/billing-aws/src/main/java/com/epam/dlab/core/AdapterBase.java
+++ b/services/billing-aws/src/main/java/com/epam/dlab/core/AdapterBase.java
@@ -24,6 +24,7 @@
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.google.common.base.MoreObjects.ToStringHelper;
+import org.bson.Document;
 
 import java.util.List;
 
@@ -157,9 +158,10 @@
 	 * Write the row of data to adapter.
 	 *
 	 * @param row the row of common format.
+	 * @return
 	 * @throws AdapterException
 	 */
-	public abstract void writeRow(ReportLine row) throws AdapterException;
+	public abstract Document writeRow(ReportLine row) throws AdapterException;
 
 
 	@Override
diff --git a/services/billing-aws/src/main/java/com/epam/dlab/core/parser/ParserBase.java b/services/billing-aws/src/main/java/com/epam/dlab/core/parser/ParserBase.java
index f9f0eaa..bfd86bc 100644
--- a/services/billing-aws/src/main/java/com/epam/dlab/core/parser/ParserBase.java
+++ b/services/billing-aws/src/main/java/com/epam/dlab/core/parser/ParserBase.java
@@ -19,13 +19,6 @@
 
 package com.epam.dlab.core.parser;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.validation.constraints.NotNull;
-
-import org.apache.commons.lang3.StringUtils;
-
 import com.epam.dlab.core.AdapterBase;
 import com.epam.dlab.core.FilterBase;
 import com.epam.dlab.core.ModuleBase;
@@ -37,6 +30,12 @@
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.google.common.base.MoreObjects.ToStringHelper;
+import org.apache.commons.lang3.StringUtils;
+import org.bson.Document;
+
+import javax.validation.constraints.NotNull;
+import java.util.ArrayList;
+import java.util.List;
 
 /** Abstract module of parser.<br>
  * See description of {@link ModuleBase} how to create your own parser.
@@ -234,13 +233,16 @@
 	 * @throws InitializationException
 	 */
 	public abstract void initialize()  throws InitializationException;
-	
-	/** Parse the source data to common format and write it to output adapter.
+
+	/**
+	 * Parse the source data to common format and write it to output adapter.
+	 *
+	 * @return
 	 * @throws InitializationException
 	 * @throws AdapterException
 	 * @throws ParseException
 	 */
-	public abstract void parse() throws InitializationException, AdapterException, ParseException;
+	public abstract List<Document> parse() throws InitializationException, AdapterException, ParseException;
 	
 	/** Build parser from given modules.
 	 * @param adapterIn the adapter for reading source data.
diff --git a/services/billing-aws/src/main/java/com/epam/dlab/core/parser/ParserByLine.java b/services/billing-aws/src/main/java/com/epam/dlab/core/parser/ParserByLine.java
index 37f2070..d878cb9 100644
--- a/services/billing-aws/src/main/java/com/epam/dlab/core/parser/ParserByLine.java
+++ b/services/billing-aws/src/main/java/com/epam/dlab/core/parser/ParserByLine.java
@@ -27,10 +27,12 @@
 import com.epam.dlab.exceptions.ParseException;
 import com.epam.dlab.model.aws.ReportLine;
 import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.bson.Document;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -156,11 +158,13 @@
 	/**
 	 * Parse the source data to common format and write it to output adapter.
 	 *
+	 * @return list of billing data
 	 * @throws InitializationException
 	 * @throws AdapterException
 	 * @throws ParseException
 	 */
-	public void parse() throws InitializationException, AdapterException, ParseException {
+	public List<Document> parse() throws InitializationException, AdapterException, ParseException {
+		List<Document> billingData = new ArrayList<>();
 		try {
 			if (init()) {
 				String line;
@@ -211,14 +215,14 @@
 						if (getAggregate() != AggregateGranularity.NONE) {
 							getAggregator().append(reportLine);
 						} else {
-							getAdapterOut().writeRow(reportLine);
+							billingData.add(getAdapterOut().writeRow(reportLine));
 							getCurrentStatistics().incrRowWritten();
 						}
 					}
 
 					if (getAggregate() != AggregateGranularity.NONE) {
 						for (int i = 0; i < getAggregator().size(); i++) {
-							getAdapterOut().writeRow(getAggregator().get(i));
+							billingData.add(getAdapterOut().writeRow(getAggregator().get(i)));
 							getCurrentStatistics().incrRowWritten();
 						}
 					}
@@ -255,5 +259,6 @@
 		if (getCurrentStatistics() != null) {
 			getCurrentStatistics().stop();
 		}
+		return billingData;
 	}
 }
diff --git a/services/billing-aws/src/main/java/com/epam/dlab/dao/impl/BillingDAOImpl.java b/services/billing-aws/src/main/java/com/epam/dlab/dao/impl/BillingDAOImpl.java
deleted file mode 100644
index 4015538..0000000
--- a/services/billing-aws/src/main/java/com/epam/dlab/dao/impl/BillingDAOImpl.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package com.epam.dlab.dao.impl;
-
-import com.epam.dlab.dao.BillingDAO;
-import com.epam.dlab.dto.billing.BillingData;
-import com.epam.dlab.exceptions.DlabException;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.bson.Document;
-import org.springframework.data.mongodb.core.MongoTemplate;
-import org.springframework.data.mongodb.core.aggregation.Aggregation;
-import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
-import org.springframework.data.mongodb.core.aggregation.GroupOperation;
-import org.springframework.data.mongodb.core.aggregation.MatchOperation;
-import org.springframework.data.mongodb.core.query.Criteria;
-import org.springframework.stereotype.Component;
-
-import java.math.BigDecimal;
-import java.time.LocalDate;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-import static com.epam.dlab.model.aws.ReportLine.FIELD_COST;
-import static com.epam.dlab.model.aws.ReportLine.FIELD_CURRENCY_CODE;
-import static com.epam.dlab.model.aws.ReportLine.FIELD_DLAB_ID;
-import static com.epam.dlab.model.aws.ReportLine.FIELD_PRODUCT;
-import static com.epam.dlab.model.aws.ReportLine.FIELD_RESOURCE_TYPE;
-import static com.epam.dlab.model.aws.ReportLine.FIELD_USAGE_DATE;
-import static org.springframework.data.mongodb.core.aggregation.Aggregation.group;
-import static org.springframework.data.mongodb.core.aggregation.Aggregation.newAggregation;
-
-@Component
-@Slf4j
-public class BillingDAOImpl implements BillingDAO {
-    private final MongoTemplate mongoTemplate;
-
-    public BillingDAOImpl(MongoTemplate mongoTemplate) {
-        this.mongoTemplate = mongoTemplate;
-    }
-
-    @Override
-    public List<BillingData> getBillingReport(String dateStart, String dateEnd, String dlabId, List<String> products) {
-        try {
-            List<AggregationOperation> aggregationOperations = new ArrayList<>();
-            aggregationOperations.add(Aggregation.match(Criteria.where(FIELD_DLAB_ID).regex(dlabId, "i")));
-            if (!products.isEmpty()) {
-                aggregationOperations.add(Aggregation.match(Criteria.where(FIELD_PRODUCT).in(products)));
-            }
-            getMatchCriteria(dateStart, Criteria.where(FIELD_USAGE_DATE).gte(dateStart))
-                    .ifPresent(aggregationOperations::add);
-            getMatchCriteria(dateEnd, Criteria.where(FIELD_USAGE_DATE).lte(dateEnd))
-                    .ifPresent(aggregationOperations::add);
-            aggregationOperations.add(getGroupOperation());
-
-            Aggregation aggregation = newAggregation(aggregationOperations);
-
-            return mongoTemplate.aggregate(aggregation, "billing", Document.class).getMappedResults()
-                    .stream()
-                    .map(this::toBillingData)
-                    .collect(Collectors.toList());
-        } catch (Exception e) {
-            log.error("Cannot retrieve billing information ", e);
-            throw new DlabException("Cannot retrieve billing information", e);
-        }
-    }
-
-    @Override
-    public List<BillingData> getBillingReport(List<String> dlabIds) {
-        try {
-            GroupOperation groupOperation = getGroupOperation();
-            MatchOperation matchOperation = Aggregation.match(Criteria.where("dlab_id").in(dlabIds));
-            Aggregation aggregation = newAggregation(matchOperation, groupOperation);
-
-            return mongoTemplate.aggregate(aggregation, "billing", Document.class).getMappedResults()
-                    .stream()
-                    .map(this::toBillingData)
-                    .collect(Collectors.toList());
-        } catch (Exception e) {
-            log.error("Cannot retrieve billing information ", e);
-            throw new DlabException("Cannot retrieve billing information", e);
-        }
-    }
-
-    private GroupOperation getGroupOperation() {
-        return group(FIELD_PRODUCT, FIELD_CURRENCY_CODE, FIELD_RESOURCE_TYPE, FIELD_DLAB_ID)
-                .min(FIELD_USAGE_DATE).as("from")
-                .max(FIELD_USAGE_DATE).as("to")
-                .sum(FIELD_COST).as(FIELD_COST);
-    }
-
-    private Optional<MatchOperation> getMatchCriteria(String dateStart, Criteria criteria) {
-        return Optional.ofNullable(dateStart)
-                .filter(StringUtils::isNotEmpty)
-                .map(date -> Aggregation.match(criteria));
-    }
-
-    private BillingData toBillingData(Document billingData) {
-        return BillingData.builder()
-                .tag(billingData.getString(FIELD_DLAB_ID))
-                .usageDateFrom(Optional.ofNullable(billingData.getString("from")).map(LocalDate::parse).orElse(null))
-                .usageDateTo(Optional.ofNullable(billingData.getString("to")).map(LocalDate::parse).orElse(null))
-                .product(billingData.getString(FIELD_PRODUCT))
-                .usageType(billingData.getString(FIELD_RESOURCE_TYPE))
-                .cost(BigDecimal.valueOf(billingData.getDouble(FIELD_COST)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue())
-                .currency(billingData.getString(FIELD_CURRENCY_CODE))
-                .build();
-    }
-}
diff --git a/services/billing-aws/src/main/java/com/epam/dlab/module/AdapterConsole.java b/services/billing-aws/src/main/java/com/epam/dlab/module/AdapterConsole.java
index 59c866d..3bffa79 100644
--- a/services/billing-aws/src/main/java/com/epam/dlab/module/AdapterConsole.java
+++ b/services/billing-aws/src/main/java/com/epam/dlab/module/AdapterConsole.java
@@ -25,6 +25,7 @@
 import com.epam.dlab.model.aws.ReportLine;
 import com.fasterxml.jackson.annotation.JsonClassDescription;
 import com.fasterxml.jackson.annotation.JsonTypeName;
+import org.bson.Document;
 
 import java.util.List;
 
@@ -84,7 +85,8 @@
 	}
 
 	@Override
-	public void writeRow(ReportLine row) throws AdapterException {
+	public Document writeRow(ReportLine row) throws AdapterException {
 		System.out.println(CommonFormat.rowToString(row));
+		return null;
 	}
 }
diff --git a/services/billing-aws/src/main/java/com/epam/dlab/module/AdapterFile.java b/services/billing-aws/src/main/java/com/epam/dlab/module/AdapterFile.java
index 7fb38f3..dd256eb 100644
--- a/services/billing-aws/src/main/java/com/epam/dlab/module/AdapterFile.java
+++ b/services/billing-aws/src/main/java/com/epam/dlab/module/AdapterFile.java
@@ -19,15 +19,6 @@
 
 package com.epam.dlab.module;
 
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.List;
-
-import javax.validation.constraints.NotNull;
-
 import com.epam.dlab.core.AdapterBase;
 import com.epam.dlab.core.parser.CommonFormat;
 import com.epam.dlab.exceptions.AdapterException;
@@ -37,6 +28,15 @@
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonTypeName;
 import com.google.common.base.MoreObjects.ToStringHelper;
+import org.bson.Document;
+
+import javax.validation.constraints.NotNull;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.List;
 
 /** The adapter for file system.
  */
@@ -137,15 +137,16 @@
 			throw new AdapterException("Cannot write file " + file + ". " + e.getLocalizedMessage(), e);
 		}
 	}
-	
+
 	@Override
-	public void writeRow(ReportLine row) throws AdapterException {
+	public Document writeRow(ReportLine row) throws AdapterException {
 		try {
 			writer.write(CommonFormat.rowToString(row));
 			writer.write(System.lineSeparator());
 		} catch (IOException e) {
 			throw new AdapterException("Cannot write file " + file + ". " + e.getLocalizedMessage(), e);
 		}
+		return null;
 	}
 	
 	
diff --git a/services/billing-aws/src/main/java/com/epam/dlab/module/aws/AdapterS3File.java b/services/billing-aws/src/main/java/com/epam/dlab/module/aws/AdapterS3File.java
index 9dc7e07..0579063 100644
--- a/services/billing-aws/src/main/java/com/epam/dlab/module/aws/AdapterS3File.java
+++ b/services/billing-aws/src/main/java/com/epam/dlab/module/aws/AdapterS3File.java
@@ -33,6 +33,7 @@
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonTypeName;
 import com.google.common.base.MoreObjects.ToStringHelper;
+import org.bson.Document;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -308,7 +309,7 @@
 	}
 
 	@Override
-	public void writeRow(ReportLine row) throws AdapterException {
+	public Document writeRow(ReportLine row) throws AdapterException {
 		throw new AdapterException("Unimplemented method.");
 	}
 
diff --git a/services/billing-aws/src/main/java/com/epam/dlab/mongo/AdapterMongoDb.java b/services/billing-aws/src/main/java/com/epam/dlab/mongo/AdapterMongoDb.java
index 994522d..db92a80 100644
--- a/services/billing-aws/src/main/java/com/epam/dlab/mongo/AdapterMongoDb.java
+++ b/services/billing-aws/src/main/java/com/epam/dlab/mongo/AdapterMongoDb.java
@@ -219,7 +219,7 @@
 	}
 
 	@Override
-	public void writeRow(ReportLine row) throws AdapterException {
+	public Document writeRow(ReportLine row) throws AdapterException {
 		Document document;
 		try {
 			document = resourceTypeDAO.transform(row);
@@ -227,20 +227,21 @@
 			throw new AdapterException("Cannot transform report line. " + e.getLocalizedMessage(), e);
 		}
 
-		usageDateList.append(row.getUsageDate());
-		if (upsert) {
-			buffer.add(document);
-			if (buffer.size() >= bufferSize) {
-				connection.upsertRows(collection, buffer, usageDateList);
-			}
-		} else if (bufferSize > 0) {
-			buffer.add(document);
-			if (buffer.size() >= bufferSize) {
-				connection.insertRows(collection, buffer);
-			}
-		} else {
-			connection.insertOne(collection, document);
-		}
+//		usageDateList.append(row.getUsageDate());
+//		if (upsert) {
+//			buffer.add(document);
+//			if (buffer.size() >= bufferSize) {
+//				connection.upsertRows(collection, buffer, usageDateList);
+//			}
+//		} else if (bufferSize > 0) {
+//			buffer.add(document);
+//			if (buffer.size() >= bufferSize) {
+//				connection.insertRows(collection, buffer);
+//			}
+//		} else {
+//			connection.insertOne(collection, document);
+//		}
+		return document;
 	}
 
 	/**