Skip to content

Commit

Permalink
Feature #4980/change min max amount and price (#964)
Browse files Browse the repository at this point in the history
* Squash md, fix unit testing, min and max fields

pull request description md

Fix unit testing

Change min and max bag and order with only two fields

* Squash + deleted commented lines
Deleted commented lines

Squash md, fix unit testing, min and max fields

pull request description md

Fix unit testing

Change min and max bag and order with only two fields

* Deleted

* Squash coments and deleted
Comments

Deleted

* Squash changes
Fix unit test after that SetTariffLimitsDto has been changed

Fix some codes and changes dtos

* Squash code
Format code

Squash changes
Fix unit test after that SetTariffLimitsDto has been changed

Fix some codes and changes dtos

* Comments done

* Squash format and comments
Format

Comments done

* Fix conflicts

* Added unit test

* Deleted unused method

* Deleted unused method

* Added unit test

* Squash commits
Format code

Added unit test

Deleted unused method

Deleted unused method

Added unit test

* Coverage

* Squash
Coverage

Coverage

* Squash
Fix conflicts

Fix conflicts

* Squash
Added unit test

Squash
Fix conflicts

Fix conflicts

* format

* Squash
Fix

format

* Fix

* Format

* Delete unnecessary mock

* Delete unnecessary mock

* Squash commits about fix and format
Delete unnecessary mock

Delete unnecessary mock

Format

Fix

* Comments done

---------

Co-authored-by: Jose Castellanos <[email protected]>
  • Loading branch information
JoseCaste and Jose Castellanos authored Feb 3, 2023
1 parent f8af69f commit 4aedf04
Show file tree
Hide file tree
Showing 30 changed files with 380 additions and 264 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ ToDo
- [ ] PR is reviewed manually again (to make sure you have 100% ready code)
- [ ] All reviewers agreed to merge the PR
- [ ] I've checked new feature as logged in and logged out user if needed
- [ ] PR meets all conventions
- [ ] PR meets all conventions
4 changes: 2 additions & 2 deletions core/src/test/java/greencity/ModelUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ public static ServiceDto getServiceDto() {

public static EditAmountOfBagDto getAmountOfSum() {
return EditAmountOfBagDto.builder()
.minAmountOfBigBags(1L)
.maxAmountOfBigBags(2L)
.min(1L)
.max(2L)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ void checkIfTariffExistsTest() throws Exception {
@Test
@SneakyThrows
void editInfoAboutTariff() {
var dto = EditPriceOfOrder.builder().maxPriceOfOrder(10000L).minPriceOfOrder(1000L).build();
var dto = EditPriceOfOrder.builder().max(10000L).min(1000L).build();
ObjectMapper objectMapper = new ObjectMapper();
String responseJSON = objectMapper.writeValueAsString(dto);
mockMvc.perform(patch(ubsLink + "/setLimitsBySumOfOrder/{tariffId}", 1L)
Expand Down
14 changes: 4 additions & 10 deletions dao/src/main/java/greencity/entity/order/TariffsInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,11 @@ public class TariffsInfo {
@Column(nullable = false)
private LocalDate createdAt;

@Column(name = "min_amount_of_big_bags")
private Long minAmountOfBigBags;
@Column(name = "min")
private Long min;

@Column(name = "max_amount_of_big_bags")
private Long maxAmountOfBigBags;

@Column(name = "min_price_of_order")
private Long minPriceOfOrder;

@Column(name = "max_price_of_order")
private Long maxPriceOfOrder;
@Column(name = "max")
private Long max;

@Column(name = "limit_description")
private String limitDescription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
<include file="db/changelog/logs/ch-fk_ubs_users_and_order_address-Safarov.xml"/>
<include file="db/changelog/logs/ch-update_big_order_table-view-Safarov.xml"/>
<include file="db/changelog/logs/ch-drop-column_address_id-in-ubs_user-Safarov.xml"/>
<include file="db/changelog/logs/сh-add-column-min-max-delete-min-max-amount-and-price-again.xml"/>
<include file="db/changelog/logs/ch-alter-table-service-add-columns-service-translations-drop-columns-Seti.xml"/>
<include file="db/changelog/logs/ch-drop-table-service-translations-Seti.xml"/>
<include file="/db/changelog/logs/ch-change-columns-createdby-editedby-in-table-bag-Seti.xml"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">

<changeSet id="Jose-10" author="José Castellanos">
<addColumn tableName="tariffs_info">
<column name="min" type="int8"/>
<column name="max" type="int8"/>
</addColumn>
</changeSet>

<changeSet id="Jose-11" author="José Castellanos">
<dropColumn tableName="tariffs_info">
<column name="min_amount_of_big_bags"/>
<column name="max_amount_of_big_bags"/>
<column name="min_price_of_order"/>
<column name="max_price_of_order"/>
</dropColumn>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public final class ErrorMessage {
public static final String MAX_BAG_VALUE_IS_INCORRECT = "Max bag value should be greater than min";
public static final String MAX_PRICE_VALUE_IS_INCORRECT = "Max price value should be greater than min";

public static final String MIN_MAX_VALUE_RESTRICTION = "Min and Max field must have different values";

/**
* Constructor.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package greencity.dto;

import greencity.dto.courier.CourierDto;
import greencity.enums.CourierLimit;
import lombok.*;
import java.util.List;

Expand All @@ -12,11 +13,9 @@
@Builder
public class TariffsForLocationDto {
private Long tariffInfoId;
private Long minAmountOfBigBags;
private Long maxAmountOfBigBags;
private Long minPriceOfOrder;
private Long maxPriceOfOrder;
private String courierLimit;
private Long min;
private Long max;
private CourierLimit courierLimit;
private RegionDto regionDto;
private List<LocationsDtos> locationsDtosList;
private CourierDto courierDto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
public class EditAmountOfBagDto {
@NotNull
@Min(1)
private Long minAmountOfBigBags;
private Long min;
@NotNull
@Min(1)
private Long maxAmountOfBigBags;
private Long max;
private Long locationId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
* {@inheritDoc}
*/
public class CourierInfoDto {
Long minAmountOfBigBags;
Long maxAmountOfBigBags;
Long minPriceOfOrder;
Long maxPriceOfOrder;
Long min;
Long max;
CourierLimit courierLimit;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package greencity.dto.order;

import lombok.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
Expand All @@ -13,9 +17,9 @@
public class EditPriceOfOrder {
@NotNull
@Min(0)
private Long minPriceOfOrder;
private Long min;
@NotNull
@Min(0)
private Long maxPriceOfOrder;
private Long max;
private Long locationId;
}
25 changes: 0 additions & 25 deletions service-api/src/main/java/greencity/dto/order/LimitsDto.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import greencity.dto.courier.CourierDto;
import greencity.dto.courier.ReceivingStationDto;
import greencity.dto.employee.EmployeeNameDto;
import greencity.enums.CourierLimit;
import greencity.enums.LocationStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -28,9 +29,7 @@ public class GetTariffsInfoDto {
private String limitDescription;
private EmployeeNameDto creator;
private LocalDate createdAt;
private String courierLimit;
private Long minAmountOfBags;
private Long maxAmountOfBags;
private Long minPriceOfOrder;
private Long maxPriceOfOrder;
private CourierLimit courierLimit;
private Long min;
private Long max;
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package greencity.dto.tariff;

import greencity.enums.CourierLimit;
import lombok.Builder;
import lombok.Data;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

@Builder
@Data
public class SetTariffLimitsDto {
@Min(0)
private Long minAmountOfBigBags;
@Min(0)
private Long maxAmountOfBigBags;
private Long min;

@Min(0)
private Long minPriceOfOrder;
@Min(0)
private Long maxPriceOfOrder;
private Long max;

@NotNull
private CourierLimit courierLimit;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import greencity.dto.courier.ReceivingStationDto;
import greencity.dto.employee.EmployeeNameDto;
import greencity.entity.order.TariffLocation;
import greencity.enums.CourierLimit;
import greencity.enums.LocationStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -25,10 +26,9 @@ public class TariffsInfoDto {
private List<ReceivingStationDto> receivingStations;
private CourierDto courier;
private String limitDescription;
private Long minAmountOfBags;
private Long maxAmountOfBags;
private Long minPriceOfOrder;
private Long maxPriceOfOrder;
private Long min;
private Long max;
private CourierLimit courierLimit;
private EmployeeNameDto creator;
private LocalDate createdAt;
}
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,6 @@ public interface UBSClientService {
*/
List<EventDto> getAllEventsForOrder(Long orderId, String email);

/**
* Methods for converting UserProfileDTO to PersonalDataDTO.
*
* @param userProfileDto {@link UserProfileDto}.
* @return {@link PersonalDataDto}.
* @author Liyubomy Pater.
*/
PersonalDataDto convertUserProfileDtoToPersonalDataDto(UserProfileDto userProfileDto);

/**
* Methods saves all entered by user data to database.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ public class CourierInfoDtoMapper extends AbstractConverter<TariffsInfo, Courier
protected CourierInfoDto convert(TariffsInfo courierLocation) {
return CourierInfoDto.builder()
.courierLimit(courierLocation.getCourierLimit())
.maxAmountOfBigBags(courierLocation.getMaxAmountOfBigBags())
.maxPriceOfOrder(courierLocation.getMaxPriceOfOrder())
.minAmountOfBigBags(courierLocation.getMinAmountOfBigBags())
.minPriceOfOrder(courierLocation.getMinPriceOfOrder())
.max(courierLocation.getMax())
.min(courierLocation.getMin())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ protected Employee convert(EmployeeDto dto) {
.tariffInfos(dto.getTariffs().stream()
.map(t -> TariffsInfo.builder()
.id(t.getId())
.minAmountOfBigBags(t.getMinAmountOfBags())
.maxAmountOfBigBags(t.getMaxAmountOfBags())
.minPriceOfOrder(t.getMinPriceOfOrder())
.maxPriceOfOrder(t.getMaxPriceOfOrder())
.min(t.getMin())
.max(t.getMax())
.courierLimit(t.getCourierLimit())
.courier(Courier.builder()
.id(t.getCourier().getCourierId())
.courierStatus(CourierStatus.ACTIVE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ public TariffsForLocationDto convert(TariffsInfo source) {
.nameUk(source.getCourier().getNameUk())
.courierStatus(source.getCourier().getCourierStatus().name())
.build())
.courierLimit(source.getCourierLimit().toString())
.maxPriceOfOrder(source.getMaxPriceOfOrder())
.minPriceOfOrder(source.getMinPriceOfOrder())
.maxAmountOfBigBags(source.getMaxAmountOfBigBags())
.minAmountOfBigBags(source.getMinAmountOfBigBags())
.courierLimit(source.getCourierLimit())
.max(source.getMax())
.min(source.getMin())
.limitDescription(source.getLimitDescription())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ protected GetTariffsInfoDto convert(TariffsInfo source) {
.nameUk(region.getUkrName()).build() : null;
return GetTariffsInfoDto.builder()
.cardId(source.getId())
.courierLimit(source.getCourierLimit().toString())
.maxAmountOfBags(source.getMaxAmountOfBigBags())
.minAmountOfBags(source.getMinAmountOfBigBags())
.maxPriceOfOrder(source.getMaxPriceOfOrder())
.minPriceOfOrder(source.getMinPriceOfOrder())
.courierLimit(source.getCourierLimit())
.max(source.getMax())
.min(source.getMin())
.regionDto(regionDto)
.createdAt(source.getCreatedAt())
.creator(EmployeeNameDto.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ public class TariffsInfoMapper extends AbstractConverter<TariffsInfo, TariffsInf
protected TariffsInfoDto convert(TariffsInfo tariffsInfo) {
return TariffsInfoDto.builder()
.id(tariffsInfo.getId())
.minAmountOfBags(tariffsInfo.getMinAmountOfBigBags())
.maxAmountOfBags(tariffsInfo.getMaxAmountOfBigBags())
.minPriceOfOrder(tariffsInfo.getMinPriceOfOrder())
.maxPriceOfOrder(tariffsInfo.getMaxPriceOfOrder())
.min(tariffsInfo.getMin())
.max(tariffsInfo.getMax())
.courierLimit(tariffsInfo.getCourierLimit())
.courier(CourierDto.builder()
.courierId(tariffsInfo.getCourier().getId())
.courierStatus(tariffsInfo.getCourier().getCourierStatus().name())
Expand Down
Loading

0 comments on commit 4aedf04

Please sign in to comment.