billing-report-agent/src/main/java/com/epam/pipeline/billingreportagent/service/impl/converter/StorageToBillingRequestConverter.java
Long calculateDailyCost(final Long sizeBytes, final BigDecimal monthlyPriceGb, final LocalDate date) {
        final BigDecimal sizeGb = BigDecimal.valueOf(sizeBytes)
            .divide(BigDecimal.valueOf(StoragePriceListLoader.BYTES_TO_GB),
                    StoragePriceListLoader.PRECISION,
                    ROUNDING_MODE);

        final int daysInMonth = YearMonth.of(date.getYear(), date.getMonthValue()).lengthOfMonth();

        final long hundredthsOfCentPrice = sizeGb.multiply(monthlyPriceGb)
            .divide(BigDecimal.valueOf(daysInMonth), ROUNDING_MODE)
            .scaleByPowerOfTen(2)
            .longValue();
        return hundredthsOfCentPrice == 0
               ? 1
               : hundredthsOfCentPrice;
    }
/**
     * Calculate daily spending on files storing in hundredths of a cent. The minimal result, possibly returned by this
     * function is 1, due to hundredths of cents granularity.
     *
     * @param sizeBytes      storage size
     * @param monthlyPriceGb price Gb/month in cents
     * @param date           billing date
     * @return daily cost
     */
Calculate daily spending on files storing in hundredths of a cent. The minimal result, possibly returned by this
function is 1, due to hundredths of cents granularity.

@param sizeBytes      storage size
@param monthlyPriceGb price Gb/month in cents
@param date           billing date
@return daily cost
Calculate daily spending on files storing in hundredths of a cent . The minimal result possibly returned by this function is 1 due to hundredths of cents granularity . @param sizeBytes storage size @param monthlyPriceGb price Gb / month in cents @param date billing date @return daily cost
Long calculateDailyCost(final Long sizeBytes, final BigDecimal monthlyPriceGb, final LocalDate date) {
        final BigDecimal sizeGb = BigDecimal.valueOf(sizeBytes)
            .divide(BigDecimal.valueOf(StoragePriceListLoader.BYTES_TO_GB),
                    StoragePriceListLoader.PRECISION,
                    ROUNDING_MODE);
        final int daysInMonth = YearMonth.of(date.getYear(), date.getMonthValue()).lengthOfMonth();
        final long hundredthsOfCentPrice = sizeGb.multiply(monthlyPriceGb)
            .divide(BigDecimal.valueOf(daysInMonth), ROUNDING_MODE)
            .scaleByPowerOfTen(2)
            .longValue();
        return hundredthsOfCentPrice == 0
               ? 1
               : hundredthsOfCentPrice;
    }
Long calculateDailyCost ( final Long sizeBytes , final BigDecimal monthlyPriceGb , final LocalDate date ) { final BigDecimal sizeGb = BigDecimal . valueOf ( sizeBytes ) . divide ( BigDecimal . valueOf ( StoragePriceListLoader . BYTES_TO_GB ) , StoragePriceListLoader . PRECISION , ROUNDING_MODE ) ; final int daysInMonth = YearMonth . of ( date . getYear ( ) , date . getMonthValue ( ) ) . lengthOfMonth ( ) ; final long hundredthsOfCentPrice = sizeGb . multiply ( monthlyPriceGb ) . divide ( BigDecimal . valueOf ( daysInMonth ) , ROUNDING_MODE ) . scaleByPowerOfTen ( 2 ) . longValue ( ) ; return hundredthsOfCentPrice == 0 ? 1 : hundredthsOfCentPrice ; }
Calculate daily spending on files storing in hundredths of a cent.
Calculate daily spending on files storing in hundredths of a cent .