Skip to content

Commit

Permalink
[UBS] - The cost of the service and tariff service, as well as the or…
Browse files Browse the repository at this point in the history
…der cost, cannot be saved to the nearest kopeck #5935 (#1134)
  • Loading branch information
juseti authored Jun 12, 2023
1 parent 7b6b600 commit bb565d6
Show file tree
Hide file tree
Showing 58 changed files with 1,869 additions and 771 deletions.
1 change: 1 addition & 0 deletions GreenCityUBS
Submodule GreenCityUBS added at 7a7d89
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public ResponseEntity<TableParamsDto> getTableParameters(
* @param userUuid of {@link String}
* @author Oleh Kulbaba
*/
@ApiOperation("Get all parameters for building table of orders")
@ApiOperation("Get width of columns for order table")
@ApiResponses(value = {
@ApiResponse(code = 200, message = HttpStatuses.OK),
@ApiResponse(code = 401, message = HttpStatuses.UNAUTHORIZED),
Expand All @@ -106,7 +106,7 @@ public ResponseEntity<ColumnWidthDto> getTableColumnWidthForCurrentUser(
* @param columnWidthDto of {@link ColumnWidthDto}
* @author Oleh Kulbaba
*/
@ApiOperation("Get width of columns for order table")
@ApiOperation("Edit width of columns for order table")
@ApiResponses(value = {
@ApiResponse(code = 200, message = HttpStatuses.OK),
@ApiResponse(code = 401, message = HttpStatuses.UNAUTHORIZED),
Expand All @@ -127,7 +127,7 @@ public ResponseEntity<HttpStatus> saveTableColumnWidthForCurrentUser(
*
* @author Liubomyr Pater
*/
@ApiOperation(value = "Save width of columns for order table")
@ApiOperation(value = "Save changes in orders")
@ApiResponses(value = {
@ApiResponse(code = 200, message = HttpStatuses.OK, response = PageableDto.class),
@ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST),
Expand Down Expand Up @@ -209,7 +209,7 @@ public ResponseEntity<UserWithOrdersDto> getAllOrdersForUser(
* @param userId {@link Long}
* @author Roman Sulymka and Max Bohonko.
*/
@ApiOperation("Get users for the table")
@ApiOperation("Get user's violations")
@ApiResponses(value = {
@ApiResponse(code = 200, message = HttpStatuses.OK),
@ApiResponse(code = 401, message = HttpStatuses.UNAUTHORIZED),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import greencity.dto.order.ExportDetailsDto;
import greencity.dto.order.ExportDetailsDtoUpdate;
import greencity.dto.order.GroupedOrderDto;
import greencity.dto.order.NotTakenOrderReasonDto;
import greencity.dto.order.OrderCancellationReasonDto;
import greencity.dto.order.OrderDetailInfoDto;
import greencity.dto.order.OrderDetailStatusDto;
import greencity.dto.order.OrderDetailStatusRequestDto;
Expand All @@ -25,8 +27,6 @@
import greencity.dto.order.ReadAddressByOrderDto;
import greencity.dto.order.UpdateAllOrderPageDto;
import greencity.dto.order.UpdateOrderPageAdminDto;
import greencity.dto.order.NotTakenOrderReasonDto;
import greencity.dto.order.OrderCancellationReasonDto;
import greencity.dto.pageble.PageableDto;
import greencity.dto.payment.ManualPaymentRequestDto;
import greencity.dto.payment.ManualPaymentResponseDto;
Expand Down Expand Up @@ -54,12 +54,6 @@
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import java.security.Principal;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import javax.validation.Valid;
import javax.validation.constraints.Email;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus;
Expand All @@ -84,6 +78,13 @@
import org.springframework.web.server.ResponseStatusException;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;
import javax.validation.constraints.Email;
import java.security.Principal;
import java.util.List;
import java.util.Optional;
import java.util.Set;

@RestController
@RequestMapping("/ubs/management")
@RequiredArgsConstructor
Expand Down Expand Up @@ -387,7 +388,7 @@ public ResponseEntity<ReadAddressByOrderDto> getAddressByOrderId(
})
@GetMapping("/getPaymentInfo")
public ResponseEntity<PaymentTableInfoDto> paymentInfo(@RequestParam long orderId,
@RequestParam Long sumToPay) {
@RequestParam Double sumToPay) {
return ResponseEntity.status(HttpStatus.OK)
.body(ubsManagementService.getPaymentInfo(orderId, sumToPay));
}
Expand Down Expand Up @@ -690,7 +691,7 @@ public ResponseEntity<HttpStatus> deleteViolationFromOrder(@PathVariable Long or
})
@GetMapping("/return-overpayment-as-bonuses-info")
public ResponseEntity<PaymentTableInfoDto> returnOverpaymentAsBonusesInfo(@RequestParam Long orderId,
@RequestParam Long sumToPay) {
@RequestParam Double sumToPay) {
return ResponseEntity.status(HttpStatus.OK)
.body(ubsManagementService.returnOverpaymentInfo(orderId, sumToPay, 2L));
}
Expand All @@ -713,7 +714,7 @@ public ResponseEntity<PaymentTableInfoDto> returnOverpaymentAsBonusesInfo(@Reque
})
@GetMapping("/return-overpayment-as-money-info")
public ResponseEntity<PaymentTableInfoDto> returnOverpaymentAsMoneyInfo(@RequestParam Long orderId,
@RequestParam Long sumToPay) {
@RequestParam Double sumToPay) {
return ResponseEntity.status(HttpStatus.OK)
.body(ubsManagementService.returnOverpaymentInfo(orderId, sumToPay, 1L));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public ResponseEntity<HttpStatus> deleteTariffService(
@PreAuthorize("@preAuthorizer.hasAuthority('EDIT_DELETE_PRICE_CARD', authentication)")
@PutMapping("/editTariffService/{id}")
public ResponseEntity<GetTariffServiceDto> editTariffService(
@RequestBody TariffServiceDto dto,
@Valid @RequestBody TariffServiceDto dto,
@Valid @PathVariable Integer id,
@ApiIgnore @CurrentUserUuid String uuid) {
return ResponseEntity.status(HttpStatus.OK).body(superAdminService.editTariffService(dto, id, uuid));
Expand Down
12 changes: 6 additions & 6 deletions core/src/test/java/greencity/ModelUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ public static OrderCancellationReasonDto getCancellationDto() {
public static TariffServiceDto getTariffServiceDto() {
return TariffServiceDto.builder()
.capacity(120)
.commission(10)
.price(100)
.commission(10.)
.price(100.)
.name("Test")
.nameEng("a")
.description("Description")
Expand All @@ -323,7 +323,7 @@ public static ServiceDto getServiceDto() {
return ServiceDto.builder()
.name("Name")
.nameEng("NameEng")
.price(100)
.price(100.)
.description("Description")
.descriptionEng("DescriptionEng")
.build();
Expand All @@ -334,8 +334,8 @@ public static GetTariffServiceDto getGetTariffServiceDto() {
.id(1)
.name("Бавовняна сумка")
.capacity(120)
.price(120)
.commission(50)
.price(120.)
.commission(50.)
.description("Description")
.limitIncluded(true)
.build();
Expand All @@ -358,7 +358,7 @@ public static GetServiceDto getGetServiceDto() {
.id(1L)
.name("Name")
.nameEng("NameEng")
.price(100)
.price(100.)
.description("Description")
.descriptionEng("DescriptionEng")
.build();
Expand Down
19 changes: 14 additions & 5 deletions dao/src/main/java/greencity/entity/order/Bag.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import lombok.Builder;

import javax.persistence.*;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import java.time.LocalDate;

@Entity
Expand All @@ -26,22 +28,29 @@ public class Bag {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;

@Min(1)
@Max(999)
@Column(nullable = false)
private Integer capacity;

@Min(1)
@Max(99_999_999)
@Column(nullable = false)
private Integer price;
private Long price;

@Min(0)
@Max(99_999_999)
@Column(nullable = false)
private Integer commission;
private Long commission;

@Min(1)
@Column(nullable = false)
private Integer fullPrice;
private Long fullPrice;

@Column(nullable = false)
@Column(nullable = false, length = 30)
private String name;

@Column(nullable = false)
@Column(nullable = false, length = 30)
private String nameEng;

@Column(nullable = false)
Expand Down
29 changes: 23 additions & 6 deletions dao/src/main/java/greencity/entity/order/Service.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
package greencity.entity.order;

import greencity.entity.user.employee.Employee;
import lombok.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.persistence.*;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import java.time.LocalDate;

@Entity
Expand All @@ -20,13 +35,15 @@ public class Service {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Min(1)
@Max(99_999_999)
@Column(nullable = false)
private Integer price;
private Long price;

@Column(nullable = false)
@Column(nullable = false, length = 30)
private String name;

@Column(nullable = false)
@Column(nullable = false, length = 30)
private String nameEng;

@Column(nullable = false)
Expand All @@ -39,7 +56,7 @@ public class Service {
private LocalDate createdAt;

@ManyToOne
@JoinColumn(name = "created_by", nullable = false)
@JoinColumn(nullable = false, name = "created_by")
private Employee createdBy;

@Column
Expand Down
12 changes: 2 additions & 10 deletions dao/src/main/java/greencity/repository/BagRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public interface BagRepository extends JpaRepository<Bag, Integer> {
* @author Nazar Struk
* @author José Castellanos
*/
@Query(value = "SELECT name, b.capacity, b.price, obm.amount, (b.price * obm.amount) AS summ "
@Query(value = "SELECT name, b.capacity, (b.price/100.00) AS price, "
+ "obm.amount, ((b.price * obm.amount) / 100.00) AS summ "
+ "FROM bag b "
+ "JOIN order_bag_mapping obm on b.id = obm.bag_id "
+ "WHERE obm.ORDER_ID = :orderId", nativeQuery = true)
Expand All @@ -85,13 +86,4 @@ public interface BagRepository extends JpaRepository<Bag, Integer> {
* @author Safarov Renat
*/
List<Bag> findBagsByTariffsInfoId(Long tariffInfoId);

/**
* method, that returns {@link List} of {@link Bag} by Tariff id.
*
* @param tariffId {@link Long} - tariff id.
* @return {@link List}of{@link Bag}.
* @author Julia Seti
*/
List<Bag> getAllByTariffsInfoId(Long tariffId);
}
4 changes: 4 additions & 0 deletions dao/src/main/resources/db/changelog/db.changelog-master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,8 @@
<include file="db/changelog/logs/ch-add-table-notification-platforms-paybutton-Lenets.xml"/>
<include file="db/changelog/logs/ch-update_big_order_table_view-Lenets.xml"/>
<include file="db/changelog/logs/ch-add-view-employees_filters-view-Safarov.xml"/>
<include file="db/changelog/logs/ch-update-bag-price-commission-Seti.xml"/>
<include file="db/changelog/logs/ch-update-service-price-Seti.xml"/>
<include file="db/changelog/logs/ch-update_big_order_table_view-Seti.xml"/>
<include file="/db/changelog/logs/ch-modify-columns-name-name-eng-in-bag-and-service-tables.xml"/>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?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="Seti-12" author="Julia Seti">
<modifyDataType tableName="service" columnName="name" newDataType="VARCHAR(30)"/>
<modifyDataType tableName="service" columnName="name_eng" newDataType="VARCHAR(30)"/>
<modifyDataType tableName="bag" columnName="name" newDataType="VARCHAR(30)"/>
<modifyDataType tableName="bag" columnName="name_eng" newDataType="VARCHAR(30)"/>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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="Seti-9" author="Julia Seti">
<modifyDataType tableName="bag" columnName="price" newDataType="bigint"/>
<modifyDataType tableName="bag" columnName="commission" newDataType="bigint"/>
<modifyDataType tableName="bag" columnName="full_price" newDataType="bigint"/>

<update tableName="bag">
<column name="price" value="23000"/>
<column name="commission" value="5000"/>
<column name="full_price" value="28000"/>
<where>id=1</where>
</update>

<update tableName="bag">
<column name="price" value="11000"/>
<column name="full_price" value="11000"/>
<where>id=2</where>
</update>

<update tableName="bag">
<column name="price" value="22000"/>
<column name="full_price" value="22000"/>
<where>id=3</where>
</update>

<update tableName="bag">
<column name="price" value="23000"/>
<column name="commission" value="5000"/>
<column name="full_price" value="28000"/>
<where>id=4</where>
</update>

<update tableName="bag">
<column name="price" value="11000"/>
<column name="full_price" value="11000"/>
<where>id=5</where>
</update>

<update tableName="bag">
<column name="price" value="22000"/>
<column name="full_price" value="22000"/>
<where>id=6</where>
</update>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?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="Seti-10" author="Julia Seti">
<modifyDataType tableName="service" columnName="price" newDataType="bigint"/>

<update tableName="service">
<column name="price" value="5000"/>
<where>price=50</where>
</update>
</changeSet>
</databaseChangeLog>
Loading

0 comments on commit bb565d6

Please sign in to comment.