Skip to content

Commit

Permalink
✨ (subtotal): Remove subtotal, not needed by product
Browse files Browse the repository at this point in the history
  • Loading branch information
d135-1r43 committed Dec 22, 2024
1 parent 5130b9b commit 5340ddd
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import jakarta.ws.rs.core.Response;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.media.Content;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.rest.client.inject.RestClient;
Expand All @@ -33,7 +34,7 @@ public TransactionRecordResource(TransactionRecordRepository repository, @RestCl
@GET
@Path("/all")
@Operation(summary = "Get all transaction records", operationId = "getAllTransactionRecords", description = "Fetches all transaction records with optional filters for bommel association")
@APIResponse(responseCode = "200", description = "List of transaction records, empty list if none are available", content = @Content(mediaType = MediaType.APPLICATION_JSON))
@APIResponse(responseCode = "200", description = "List of transaction records, empty list if none are available", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = TransactionRecord[].class)))
public List<TransactionRecord> getAll(@BeanParam AllParameters parameters) {
parameters.verifyOnlyOneIsActive();
Page page = new Page(parameters.getPageIndex(), parameters.getPageSize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ public class TransactionRecord {
@Column(nullable = false)
private BigDecimal total;

// Common optional columns
@Column(name = "sub_total")
private BigDecimal subTotal;

// invoice = invoice date
// receipt = transaction time
@Column(name = "transaction_time")
Expand Down Expand Up @@ -67,14 +63,6 @@ public void setTotal(BigDecimal total) {
this.total = total;
}

public BigDecimal getSubTotal() {
return subTotal;
}

public void setSubTotal(BigDecimal subTotal) {
this.subTotal = subTotal;
}

public Instant getTransactionTime() {
return transactionTime;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ public record InvoiceData(
Optional<String> purchaseOrderNumber,
Optional<String> invoiceId,
Optional<LocalDate> dueDate,
Optional<BigDecimal> subTotal,
Optional<BigDecimal> amountDue) implements TransactionRecordConverter {

public InvoiceData(BigDecimal total, LocalDate invoiceDate, String currencyCode) {
this(total, invoiceDate, currencyCode, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(),
Optional.empty(), Optional.empty(), Optional.empty());
Optional.empty(), Optional.empty());
}

@Override
Expand All @@ -39,7 +38,6 @@ public TransactionRecord convertToTransactionRecord() {
invoiceId().ifPresent(transactionRecord::setInvoiceId);
dueDate().ifPresent(
dueDate -> transactionRecord.setDueDate(dueDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
subTotal().ifPresent(transactionRecord::setSubTotal);
amountDue().ifPresent(transactionRecord::setAmountDue);

return transactionRecord;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@

public record ReceiptData(
BigDecimal total,
Optional<BigDecimal> subTotal,
Optional<String> storeName,
Optional<Address> storeAddress,
Optional<LocalDateTime> transactionTime) implements TransactionRecordConverter {

public ReceiptData(BigDecimal total) {
this(total, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
this(total, Optional.empty(), Optional.empty(), Optional.empty());
}

@Override
public TransactionRecord convertToTransactionRecord() {
TransactionRecord transactionRecord = new TransactionRecord(total());
// Optional
subTotal().ifPresent(transactionRecord::setSubTotal);
storeName().ifPresent(transactionRecord::setName);
storeAddress().ifPresent(address -> transactionRecord.setAddress(address.convertToJpa()));
transactionTime().ifPresent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ void shouldWriteFullInvoiceData() {
Optional.of("pruchaseOrderNumber"),
Optional.of("invoiceId"),
Optional.of(dueDate),
Optional.of(BigDecimal.valueOf(350)),
Optional.of(BigDecimal.valueOf(150)));

// when
Expand Down Expand Up @@ -112,7 +111,6 @@ void shouldWriteFullReceiptData() {

ReceiptData receiptData = new ReceiptData(
BigDecimal.valueOf(100),
Optional.of(BigDecimal.valueOf(75)),
Optional.of("StoreName"),
Optional.of(address),
Optional.of(transactionTime));
Expand Down

0 comments on commit 5340ddd

Please sign in to comment.