List of usage examples for java.sql Date Date
public Date(long date)
From source file:org.droidpres.activity.TransferActivity.java
private void deleteOldRecords() { Calendar cl = Calendar.getInstance(); cl.add(Calendar.DAY_OF_MONTH, -30); Date sqlDate = new Date(cl.getTime().getTime()); mDataBase.execSQL("delete from document where docstate = ? and docdate < ?", new Object[] { Const.DOCSTATE_SEND, sqlDate.toString() }); }
From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java
@Override public void insert(final Ligplaats ligplaats) throws DAOException { try {//from ww w.j av a 2s .c o m transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { jdbcTemplate.update(new PreparedStatementCreator() { @Override public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { PreparedStatement ps = connection .prepareStatement("insert into bag_ligplaats (" + "bag_ligplaats_id," + "aanduiding_record_inactief," + "aanduiding_record_correctie," + "officieel," + "ligplaats_status," + "ligplaats_geometrie," + "begindatum_tijdvak_geldigheid," + "einddatum_tijdvak_geldigheid," + "in_onderzoek," + "bron_documentdatum," + "bron_documentnummer," + "bag_nummeraanduiding_id" + ") values (?,?,?,?,?,?,?,?,?,?,?,?)"); ps.setLong(1, ligplaats.getIdentificatie()); ps.setInt(2, ligplaats.getAanduidingRecordInactief().ordinal()); ps.setLong(3, ligplaats.getAanduidingRecordCorrectie()); ps.setInt(4, ligplaats.getOfficieel().ordinal()); ps.setInt(5, ligplaats.getLigplaatsStatus().ordinal()); ps.setString(6, ligplaats.getLigplaatsGeometrie()); ps.setTimestamp(7, new Timestamp(ligplaats.getBegindatumTijdvakGeldigheid().getTime())); if (ligplaats.getEinddatumTijdvakGeldigheid() == null) ps.setNull(8, Types.TIMESTAMP); else ps.setTimestamp(8, new Timestamp(ligplaats.getEinddatumTijdvakGeldigheid().getTime())); ps.setInt(9, ligplaats.getInOnderzoek().ordinal()); ps.setDate(10, new Date(ligplaats.getDocumentdatum().getTime())); ps.setString(11, ligplaats.getDocumentnummer()); ps.setLong(12, ligplaats.getHoofdAdres()); return ps; } }); insertNevenadressen(TypeAdresseerbaarObject.LIGPLAATS, ligplaats); } }); } catch (DataAccessException e) { throw new DAOException("Error inserting ligplaats: " + ligplaats.getIdentificatie(), e); } }
From source file:org.ofbiz.common.CommonServices.java
public static Map<String, Object> runCustomTimePeriodConfiguration(DispatchContext ctx, Map<String, ? extends Object> context) { Delegator delegator = ctx.getDelegator(); LocalDispatcher dispatcher = ctx.getDispatcher(); GenericValue userLogin = (GenericValue) context.get("userLogin"); TimeZone timeZone = TimeZone.getDefault(); Locale locale = Locale.getDefault(); Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); int day = UtilDateTime.getDayOfMonth(nowTimestamp, timeZone, locale); Timestamp monthStart = UtilDateTime.getMonthStart(nowTimestamp); List<GenericValue> customTimePeriodConfigList = FastList.newInstance(); Map<String, Object> createResp = ServiceUtil.returnSuccess(); try {/*from w ww .j a v a 2 s .c o m*/ customTimePeriodConfigList = delegator.findList("CustomTimePeriodConfiguration", EntityCondition.makeCondition( EntityCondition.makeCondition("startDate", EntityOperator.EQUALS, new Long(day)), EntityOperator.OR, EntityCondition.makeCondition("createDate", EntityOperator.EQUALS, new Long(day))), null, null, null, true); for (GenericValue customTimePeriodConfig : customTimePeriodConfigList) { Map createCtx = FastMap.newInstance(); String organizationPartyId = customTimePeriodConfig.getString("organizationPartyId"); int startDate = (customTimePeriodConfig.getLong("startDate")).intValue(); int endDate = (customTimePeriodConfig.getLong("endDate")).intValue(); int intervalDays = (customTimePeriodConfig.getLong("intervalDays")).intValue(); createCtx.put("periodTypeId", customTimePeriodConfig.getString("periodTypeId")); createCtx.put("organizationPartyId", organizationPartyId); if (UtilValidate.isEmpty(organizationPartyId)) { createCtx.put("organizationPartyId", "Company"); } Date fromDate = new Date(UtilDateTime.addDaysToTimestamp(monthStart, startDate - 1).getTime()); Timestamp thruDateMonthStart = UtilDateTime .getMonthStart(UtilDateTime.addDaysToTimestamp(monthStart, intervalDays)); Date thruDate = new Date( UtilDateTime.addDaysToTimestamp(thruDateMonthStart, endDate - 1).getTime()); createCtx.put("fromDate", fromDate); List custTimePeriodList = delegator.findByAnd("CustomTimePeriod", createCtx); if (UtilValidate.isNotEmpty(custTimePeriodList)) { Debug.logInfo("Custom timeperiod already exists with values:[ periodTypeId :" + createCtx.get("periodTypeId") + ",organizationPartyId : " + createCtx.get("organizationPartyId") + " ,fromDate : " + createCtx.get("fromDate") + " ]", module); continue; } createCtx.put("userLogin", userLogin); if (intervalDays <= 30 && endDate == 30) { thruDate = new Date(UtilDateTime.getMonthEnd(monthStart, timeZone, locale).getTime()); } if (intervalDays > 30 && endDate == 30) { thruDate = new Date(UtilDateTime.getMonthEnd(thruDateMonthStart, timeZone, locale).getTime()); } createCtx.put("thruDate", thruDate); GenericValue periodType = delegator.findOne("PeriodType", UtilMisc.toMap("periodTypeId", customTimePeriodConfig.getString("periodTypeId")), true); String periodName = periodType.getString("description") + " [ " + UtilDateTime.toDateString(fromDate, "dd MMMM,yyyy") + "-" + UtilDateTime.toDateString(thruDate, "dd MMMM,yyyy") + " ]"; createCtx.put("periodName", periodName); createCtx.put("isClosed", "N"); int periodNum = (UtilDateTime.getYear(monthStart, timeZone, locale) * 12) + UtilDateTime.getMonth(monthStart, timeZone, locale); createCtx.put("periodNum", new Long(periodNum)); try { createResp = dispatcher.runSync("createCustomTimePeriod", createCtx); } catch (GenericServiceException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); } if (ServiceUtil.isError(createResp)) { return ServiceUtil.returnError(ServiceUtil.getErrorMessage(createResp)); } } } catch (GenericEntityException e) { // TODO: handle exception Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); } return ServiceUtil.returnSuccess(); }
From source file:com.taobao.android.apatch.ApkPatch.java
@SuppressWarnings("deprecation") protected Manifest getMeta() { Manifest manifest = new Manifest(); Attributes main = manifest.getMainAttributes(); main.putValue("Manifest-Version", "1.0"); main.putValue("Created-By", "1.0 (ApkPatch)"); main.putValue("Created-Time", new Date(System.currentTimeMillis()).toGMTString()); main.putValue("From-File", baseFiles.get(0).getName()); main.putValue("To-File", newFiles.get(0).getName()); main.putValue("Patch-Name", name); main.putValue(name + "-Patch-Classes", Formater.dotStringList(classes)); main.putValue(name + "-Prepare-Classes", Formater.dotStringList(prepareClasses)); main.putValue(name + "-Used-Methods", Formater.dotStringList(usedMethods)); main.putValue(name + "-Modified-Classes", Formater.dotStringList(modifiedClasses)); main.putValue(name + "-Used-Classes", Formater.dotStringList(usedClasses)); main.putValue(name + "-add-classes", Formater.dotStringList(addClasses)); return manifest; }
From source file:kx.c.java
Date rd() { int i = ri(); return new Date(i == ni ? nj : gl(k + 86400000L * i)); }
From source file:com.wso2telco.dep.reportingservice.northbound.NbHostObjectUtils.java
/** * Apply charges for payment api./*ww w . ja v a 2 s . com*/ * * @param opSubscription the op subscription * @param paymentRequestSet the payment request set * @param categoryEntry the category entry * @param appId the app id * @param apiId the api id * @param subId the sub id * @throws Exception */ private static void applyChargesForPaymentApi(BillingSubscription.OperatorSubscription opSubscription, Set<PaymentRequestDTO> paymentRequestSet, Map.Entry<CategoryCharge, BilledCharge> categoryEntry, int appId, int apiId, String subId) throws Exception { ChargeRate rate = opSubscription.getRate(); String billCategory = categoryEntry.getKey().getCategory(); String billSubCategory = categoryEntry.getKey().getSubcategory(); BigDecimal billRate = rate.getValue(); boolean CategoryBased = rate.getCategoryBasedVal(); TaxDAO taxDAO = new TaxDAO(); List<Tax> taxList = taxDAO.getTaxesForTaxList(rate.getTaxList()); Map<String, CommissionPercentagesDTO> commisionMap = null; BillingDAO billingDAO = new BillingDAO(); if (!CategoryBased) { commisionMap = billingDAO.getCommissionPercentages(subId, appId); } BigDecimal totalspcom = BigDecimal.ZERO; BigDecimal totalCharge = BigDecimal.ZERO; BigDecimal totaladscom = BigDecimal.ZERO; BigDecimal totalopcom = BigDecimal.ZERO; BigDecimal totalTax = BigDecimal.ZERO; // get this flag from rate card for (PaymentRequestDTO paymentRequest : paymentRequestSet) { totalCharge = totalCharge.add(paymentRequest.getAmount()); BigDecimal spcom = BigDecimal.ZERO; BigDecimal adscom = BigDecimal.ZERO; BigDecimal opcom = BigDecimal.ZERO; String category = paymentRequest.getCategory(); String subcategory = paymentRequest.getSubcategory(); String merchant = paymentRequest.getMerchant(); BigDecimal adscomPercnt = rate.getCommission().getAdsCommission().divide(new BigDecimal(100)); BigDecimal spcomPercnt = rate.getCommission().getSpCommission().divide(new BigDecimal(100)); BigDecimal opcomPercnt = rate.getCommission().getOpcoCommission().divide(new BigDecimal(100)); if (CategoryBased) { Object SubsRate = getRateSubcategory(rate, billCategory, billSubCategory); if (SubsRate != null) { RateCommission commisionRates = (RateCommission) SubsRate; adscomPercnt = commisionRates.getAdsCommission().divide(new BigDecimal(100)); spcomPercnt = commisionRates.getSpCommission().divide(new BigDecimal(100)); opcomPercnt = commisionRates.getOpcoCommission().divide(new BigDecimal(100)); } } else { if (commisionMap.containsKey(merchant)) { adscomPercnt = commisionMap.get(merchant).getAdsCommission().divide(new BigDecimal(100)); spcomPercnt = commisionMap.get(merchant).getSpCommission().divide(new BigDecimal(100)); opcomPercnt = commisionMap.get(merchant).getOpcoCommission().divide(new BigDecimal(100)); } else { throw new APIManagementException( "Payment Categoreis required for MERCHANT based charging are not specified in rate-card.xml"); } } spcom = paymentRequest.getAmount().multiply(spcomPercnt); totalspcom = totalspcom.add(spcom); opcom = paymentRequest.getAmount().multiply(opcomPercnt); totalopcom = totalopcom.add(opcom); adscom = paymentRequest.getAmount().multiply(adscomPercnt); totaladscom = totaladscom.add(adscom); Date date = new Date(paymentRequest.getDate().getTime()); BigDecimal totalReqTax = BigDecimal.ZERO; for (Tax tax : taxList) { // check if the date of payment request falls between this tax // validity period if (!date.before(tax.getEffective_from()) && !date.after(tax.getEffective_to())) { // totalTax += taxFraction x paymentAmount totalReqTax = totalReqTax.add(tax.getValue().multiply(paymentRequest.getAmount())); } } totalTax = totalTax.add(totalReqTax); if (!CategoryBased) { if (opSubscription.getMerchantCharges().containsKey(merchant)) { opSubscription.getMerchantCharges().get(merchant).addAdscom(adscom); opSubscription.getMerchantCharges().get(merchant).addOpcom(opcom); opSubscription.getMerchantCharges().get(merchant).addSpcom(spcom); opSubscription.getMerchantCharges().get(merchant).addPrice(spcom); opSubscription.getMerchantCharges().get(merchant).addTax(totalReqTax); opSubscription.getMerchantCharges().get(merchant).addCount(1); } else { BilledCharge billedCharge = new BilledCharge(0); billedCharge.addAdscom(adscom); billedCharge.addOpcom(opcom); billedCharge.addSpcom(spcom); billedCharge.addPrice(spcom); billedCharge.addTax(totalReqTax); billedCharge.addCount(1); opSubscription.getMerchantCharges().put(merchant, billedCharge); } } } // Get the percentage from the rate value // BigDecimal percentage = rate.getValue().divide(new BigDecimal(100)); // apply category wise charge percentage // BigDecimal price = totalCharge.multiply(percentage); // if (CategoryBased) { categoryEntry.getValue().addAdscom(totaladscom); categoryEntry.getValue().addOpcom(totalopcom); categoryEntry.getValue().addSpcom(totalspcom); categoryEntry.getValue().addPrice(totalspcom); categoryEntry.getValue().setTax(totalTax); // } }
From source file:eionet.meta.service.CSVVocabularyImportServiceTest.java
/** * In this test, two line CSV is imported. Rows are derived from base CSV. Just identifiers are updated. Purge operation is * tested./*from www.j ava 2s . c o m*/ * * @throws Exception */ @Test @Rollback public void testIfConceptsAddedAfterPurge() throws Exception { // get vocabulary folder VocabularyFolder vocabularyFolder = vocabularyService.getVocabularyFolder(TEST_VALID_VOCABULARY_ID); // get initial values of concepts with attributes List<VocabularyConcept> concepts = getVocabularyConceptsWithAttributes(vocabularyFolder); // get reader for CSV file Reader reader = getReaderFromResource("csv_import/csv_import_test_4.csv"); // import CSV into database vocabularyImportService.importCsvIntoVocabulary(reader, vocabularyFolder, true, false); Assert.assertFalse("Transaction rolled back (unexpected)", transactionManager.getTransaction(null).isRollbackOnly()); // manually create values of new concept for comparison concepts.remove(2);// remove last object // there is not much object just update, no need to iterate concepts.get(0).setIdentifier("csv_test_concept_1_after_purge"); concepts.get(0).setStatus(StandardGenericStatus.VALID); concepts.get(0).setAcceptedDate(new Date(System.currentTimeMillis())); concepts.get(0).setStatusModified(new Date(System.currentTimeMillis())); concepts.get(1).setIdentifier("csv_test_concept_2_after_purge"); concepts.get(1).setStatus(StandardGenericStatus.VALID); concepts.get(1).setAcceptedDate(new Date(System.currentTimeMillis())); concepts.get(1).setStatusModified(new Date(System.currentTimeMillis())); // get updated values of concepts with attributes List<VocabularyConcept> updatedConcepts = getVocabularyConceptsWithAttributes(vocabularyFolder); Assert.assertEquals("Updated Concepts does not include 2 vocabulary concepts", 2, updatedConcepts.size()); // concepts should be inserted in the same order as they are in csv file, get ids from updated beans concepts.get(0) .setId(findVocabularyConceptByIdentifier(updatedConcepts, concepts.get(0).getIdentifier()).getId()); concepts.get(1) .setId(findVocabularyConceptByIdentifier(updatedConcepts, concepts.get(1).getIdentifier()).getId()); // compare manually updated objects with queried ones (after import operation) ReflectionAssert.assertReflectionEquals(concepts, updatedConcepts, ReflectionComparatorMode.LENIENT_DATES, ReflectionComparatorMode.LENIENT_ORDER); }
From source file:dk.netarkivet.archive.arcrepositoryadmin.ReplicaCacheHelpers.java
/** * Method for updating the checksum status of a replicafileinfo instance. * Updates the following fields for the entry in the replicafileinfo: * <br/> checksum_status = OK./*from w w w .jav a 2s .co m*/ * <br/> upload_status = UPLOAD_COMLPETE. * <br/> checksum_checkdatetime = current time. * <br/><br/> * The file is required to exist in the replica. * * @param replicafileinfoId The id of the replicafileinfo. * @param con An open connection to the archive database */ protected static void updateReplicaFileInfoChecksumOk(long replicafileinfoId, Connection con) { PreparedStatement statement = null; try { // The SQL statement final String sql = "UPDATE replicafileinfo SET checksum_status = ?, " + "checksum_checkdatetime = ?, upload_status = ? " + "WHERE replicafileinfo_guid = ?"; Date now = new Date(Calendar.getInstance().getTimeInMillis()); // complete the SQL statement. statement = DBUtils.prepareStatement(con, sql, ChecksumStatus.OK.ordinal(), now, ReplicaStoreState.UPLOAD_COMPLETED.ordinal(), replicafileinfoId); // execute the SQL statement statement.executeUpdate(); con.commit(); } catch (Exception e) { String msg = "Problems updating the replicafileinfo."; log.warn(msg); throw new IOFailure(msg, e); } finally { DBUtils.closeStatementIfOpen(statement); } }
From source file:org.ednovo.gooru.domain.service.classplan.LearnguideServiceImpl.java
@Override public Learnguide copyCollection(String gooruContentId, String collectionTitle, User user, boolean isClassplan, String segmentIds, String targetCollectionId) throws Exception { logger.info("Copy Classplan Step 0: " + System.currentTimeMillis()); Learnguide sourceCollection = (Learnguide) this.getLearnguideRepository().findByContent(gooruContentId); String lesson = sourceCollection.getLesson(); Learnguide targetCollection = null;//from w ww.j a v a2 s . co m if (targetCollectionId == null) { targetCollection = new Learnguide(); targetCollection.setUser(user); targetCollection.setOrganization(user.getOrganization()); targetCollection.setContentType(sourceCollection.getContentType()); targetCollection.setCreatedOn(new Date(System.currentTimeMillis())); targetCollection.setLastModified(new Date(System.currentTimeMillis())); targetCollection.setGooruOid(UUID.randomUUID().toString()); targetCollection.setSharing(Sharing.PRIVATE.getSharing()); targetCollection.setType(sourceCollection.getType()); targetCollection.setNarration(sourceCollection.getNarration()); targetCollection.setAssessmentLink(sourceCollection.getAssessmentLink()); targetCollection.setAssessmentGooruOid(sourceCollection.getAssessmentGooruOid()); targetCollection.setCollectionLink(sourceCollection.getCollectionLink()); targetCollection.setCollectionGooruOid(sourceCollection.getCollectionGooruOid()); targetCollection.setVocabulary(sourceCollection.getVocabulary()); targetCollection.setMedium(sourceCollection.getMedium()); targetCollection.setDuration(targetCollection.getDuration()); targetCollection.setTitle(sourceCollection.getTitle()); targetCollection.setNotes(sourceCollection.getNotes()); targetCollection.setGoals(sourceCollection.getGoals()); targetCollection.setDistinguish(new Short("0")); targetCollection.setLicense(sourceCollection.getLicense()); targetCollection.setResourceType(sourceCollection.getResourceType()); targetCollection.setUrl(sourceCollection.getUrl()); targetCollection.setCreator(sourceCollection.getCreator()); targetCollection.setThumbnail(sourceCollection.getThumbnail()); targetCollection.setRequestPending(0); String newLesson = ""; if (collectionTitle != null) { newLesson = collectionTitle; } else { newLesson = "Copy - " + sourceCollection.getLesson(); } if (newLesson.length() > 256) { newLesson = newLesson.substring(0, 255); } targetCollection.setLesson(newLesson); targetCollection.setTitle(newLesson); Set<Code> taxonomy = new HashSet<Code>(); taxonomy.addAll(sourceCollection.getTaxonomySet()); targetCollection.setTaxonomySet(taxonomy); } else { targetCollection = (Learnguide) this.getLearnguideRepository().findByContent(targetCollectionId); } if (sourceCollection.getResourceSegments() != null) { Set<Segment> segments = new TreeSet<Segment>(); int sequence = 0; if ((targetCollectionId != null) && (targetCollection == null)) { throw new NotFoundException(generateErrorMessage(GL0056, TARGET_COLLECTION)); } if (targetCollection.getResourceSegments() != null) { sequence = targetCollection.getResourceSegments().size(); } for (Segment segment : sourceCollection.getResourceSegments()) { Segment newSegment = new Segment(); if (segmentIds != null) { String[] segmentIdsArr = segmentIds.split(","); for (String segmentId : segmentIdsArr) { if (segmentId.equals(segment.getSegmentId())) { sequence++; newSegment = copySegments(segment, sequence); } } } else { newSegment = copySegments(segment, segment.getSequence()); } if (newSegment.getSegmentId() != null) { segments.add(newSegment); } } if (targetCollectionId == null) { targetCollection.setResourceSegments(segments); } else { targetCollection.getResourceSegments().addAll(segments); } } // Step 3 - Retrieved the content classification object from database // and populate the new object this.getLearnguideRepository().save(targetCollection); // track copied collection source ContentAssociation contentAssociation = new ContentAssociation(); contentAssociation.setAssociateContent(targetCollection); contentAssociation.setContent(sourceCollection); contentAssociation.setModifiedDate(new Date(System.currentTimeMillis())); contentAssociation.setTypeOf(Constants.COPIED_COLLECTION); contentAssociation.setUser(user); this.getLearnguideRepository().save(contentAssociation); for (Segment segment : targetCollection.getResourceSegments()) { if (segment.getResourceInstances() != null) { CollectionServiceUtil.resetInstancesSequence(segment); for (ResourceInstance resourceInstance : segment.getResourceInstances()) { resourceService.saveResourceInstance(resourceInstance); } } } logger.info("Copy Classplan Step 2: " + System.currentTimeMillis()); this.getResourceManager().copyResourceRepository(sourceCollection, targetCollection); logger.info("Copy Classplan Step 3: " + System.currentTimeMillis()); indexProcessor.index(targetCollection.getGooruOid(), IndexProcessor.INDEX, COLLECTION); this.s3ResourceApiHandler.uploadS3Resource(targetCollection); if (logger.isInfoEnabled()) { logger.info(LogUtil.getApplicationLogStream(LEARN_GUIDE, "copying learnguide with contetnt Id as " + sourceCollection.getGooruOid())); } if (logger.isInfoEnabled()) { if (isClassplan) { logger.info(LogUtil.getActivityLogStream(CLASS_PLAN, user.toString(), sourceCollection.toString(), LogUtil.CLASSPLAN_COPY, lesson)); } else { logger.info(LogUtil.getActivityLogStream(CLASS_BOOK, user.toString(), sourceCollection.toString(), LogUtil.CLASSBOOK_COPY, lesson)); } } try { revisionHistoryService.createVersion(targetCollection, COPY_COLLECTION); } catch (Exception ex) { ex.printStackTrace(); } return targetCollection; }
From source file:com.wso2telco.dep.reportingservice.southbound.SbHostObjectUtils.java
/** * Apply charges for payment api./*w ww. j a v a 2 s .c o m*/ * * @param opSubscription the op subscription * @param paymentRequestSet the payment request set * @param categoryEntry the category entry * @param appId the app id * @param apiId the api id * @param subId the sub id * @throws Exception */ private static void applyChargesForPaymentApi(BillingSubscription.OperatorSubscription opSubscription, Set<PaymentRequestDTO> paymentRequestSet, Map.Entry<CategoryCharge, BilledCharge> categoryEntry, int appId, int apiId, String subId) throws Exception { ChargeRate rate = opSubscription.getRate(); String billCategory = categoryEntry.getKey().getCategory(); String billSubCategory = categoryEntry.getKey().getSubcategory(); BigDecimal billRate = rate.getValue(); boolean CategoryBased = rate.getCategoryBasedVal(); BillingDAO billingDAO = new BillingDAO(); TaxDAO taxDAO = new TaxDAO(); List<Tax> taxList = taxDAO.getTaxesForTaxList(rate.getTaxList()); Map<String, CommissionPercentagesDTO> commisionMap = null; if (!CategoryBased) { commisionMap = billingDAO.getCommissionPercentages(subId, appId); } BigDecimal totalspcom = BigDecimal.ZERO; BigDecimal totalCharge = BigDecimal.ZERO; BigDecimal totaladscom = BigDecimal.ZERO; BigDecimal totalopcom = BigDecimal.ZERO; BigDecimal totalTax = BigDecimal.ZERO; // get this flag from rate card for (PaymentRequestDTO paymentRequest : paymentRequestSet) { totalCharge = totalCharge.add(paymentRequest.getAmount()); BigDecimal spcom = BigDecimal.ZERO; BigDecimal adscom = BigDecimal.ZERO; BigDecimal opcom = BigDecimal.ZERO; String category = paymentRequest.getCategory(); String subcategory = paymentRequest.getSubcategory(); String merchant = paymentRequest.getMerchant(); BigDecimal adscomPercnt = rate.getCommission().getAdsCommission().divide(new BigDecimal(100)); BigDecimal spcomPercnt = rate.getCommission().getSpCommission().divide(new BigDecimal(100)); BigDecimal opcomPercnt = rate.getCommission().getOpcoCommission().divide(new BigDecimal(100)); if (CategoryBased) { Object SubsRate = getRateSubcategory(rate, billCategory, billSubCategory); if (SubsRate != null) { RateCommission commisionRates = (RateCommission) SubsRate; adscomPercnt = commisionRates.getAdsCommission().divide(new BigDecimal(100)); spcomPercnt = commisionRates.getSpCommission().divide(new BigDecimal(100)); opcomPercnt = commisionRates.getOpcoCommission().divide(new BigDecimal(100)); } } else { if (commisionMap.containsKey(merchant)) { adscomPercnt = commisionMap.get(merchant).getAdsCommission().divide(new BigDecimal(100)); spcomPercnt = commisionMap.get(merchant).getSpCommission().divide(new BigDecimal(100)); opcomPercnt = commisionMap.get(merchant).getOpcoCommission().divide(new BigDecimal(100)); } else { throw new APIManagementException( "Payment Categoreis required for MERCHANT based charging are not specified in rate-card.xml"); } } spcom = paymentRequest.getAmount().multiply(spcomPercnt); totalspcom = totalspcom.add(spcom); opcom = paymentRequest.getAmount().multiply(opcomPercnt); totalopcom = totalopcom.add(opcom); adscom = paymentRequest.getAmount().multiply(adscomPercnt); totaladscom = totaladscom.add(adscom); Date date = new Date(paymentRequest.getDate().getTime()); BigDecimal totalReqTax = BigDecimal.ZERO; for (Tax tax : taxList) { // check if the date of payment request falls between this tax // validity period if (!date.before(tax.getEffective_from()) && !date.after(tax.getEffective_to())) { totalReqTax = totalReqTax.add(tax.getValue().multiply(paymentRequest.getAmount())); } } totalTax = totalTax.add(totalReqTax); if (!CategoryBased) { if (opSubscription.getMerchantCharges().containsKey(merchant)) { opSubscription.getMerchantCharges().get(merchant).addAdscom(adscom); opSubscription.getMerchantCharges().get(merchant).addOpcom(opcom); opSubscription.getMerchantCharges().get(merchant).addSpcom(spcom); opSubscription.getMerchantCharges().get(merchant).addPrice(spcom); opSubscription.getMerchantCharges().get(merchant).addTax(totalReqTax); opSubscription.getMerchantCharges().get(merchant).addCount(1); } else { BilledCharge billedCharge = new BilledCharge(0); billedCharge.addAdscom(adscom); billedCharge.addOpcom(opcom); billedCharge.addSpcom(spcom); billedCharge.addPrice(spcom); billedCharge.addTax(totalReqTax); billedCharge.addCount(1); opSubscription.getMerchantCharges().put(merchant, billedCharge); } } } // Get the percentage from the rate value // apply category wise charge percentage categoryEntry.getValue().addAdscom(totaladscom); categoryEntry.getValue().addOpcom(totalopcom); categoryEntry.getValue().addSpcom(totalspcom); categoryEntry.getValue().addPrice(totalspcom); categoryEntry.getValue().setTax(totalTax); }