Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client Finance View updated #63

Open
wants to merge 10 commits into
base: development
Choose a base branch
from
45 changes: 40 additions & 5 deletions src/main/frontend/themes/my-theme/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,16 @@ gltf-viewer::part(canvas) {
}

.property-card-img{
width: 330px !important;
width: 100% !important;
height: 162px;
border-radius: 10px;

}

.property-vertical-layout{
padding: 0;
gap: 0;
margin-bottom: 30px;
}

.horizontal-type-price{
Expand All @@ -431,8 +433,8 @@ gltf-viewer::part(canvas) {
}
.property-card-status{
position: relative;
top: 60px;
left: 190px;
top: 45px;
left: 225px;
width: 90px;
text-align: center;
}
Expand Down Expand Up @@ -535,10 +537,12 @@ vaadin-combo-box::part(label){
}

.finance-status{
padding: 5px;
border-radius: 5px;
padding: 3px;
width: 60px;
border-radius: 14px;
text-align: center;
font-size: 12px;
font-weight: 600;
}

.finance-close{
Expand All @@ -554,6 +558,37 @@ td{
font-size: 14px;
}

.upload-receipt-dialog{
width: 50%
}

.receipt-header{
text-align: center;
align-items: center;
margin-top: 20px;
padding: 0 25px;
}

.download-icon{
margin-left: 10px;
border: 1px solid black;
border-radius: 7px;
padding: 4px;
color: black;
width: 45px;
height: 30px;
}

.properties-details-div{
padding: 20px 60px;
}

.properties-location-map{
padding: 15px 0;
}






22 changes: 14 additions & 8 deletions src/main/java/ng/org/mirabilia/pms/domain/entities/Finance.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Setter
@Data
Expand All @@ -27,9 +29,6 @@ public class Finance {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne
private Phase phase;

@ManyToOne
private User owner;

Expand All @@ -49,21 +48,20 @@ public class Finance {
private BigDecimal outstandingAmount;

@ManyToOne
@JoinColumn(name = "invoice_id", nullable = false)
private Invoice invoice;

@ManyToOne(cascade = CascadeType.ALL)
@OneToOne(mappedBy = "finance", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
private PaymentReceipt receiptImage;


public Finance(){}

public Finance(Long id, Phase phase,
public Finance(Long id,
User owner, PropertyType type, FinanceStatus paymentStatus, PaymentMethod paymentMethod,
BigDecimal price, String paidBy,
LocalDate date, BigDecimal amountPaid,
BigDecimal outstandingAmount, Invoice invoice) {
this.id = id;
this.phase = phase;
this.owner = owner;
this.paymentStatus = paymentStatus;
this.paymentMethod = paymentMethod;
Expand All @@ -84,7 +82,15 @@ public String getAmountPaidFormattedToString(){
}

public BigDecimal updateOutstandingAmount() {
outstandingAmount = invoice.getPropertyPrice().subtract(this.amountPaid);
outstandingAmount = invoice.getPropertyPrice();
if (getPaymentStatus() == FinanceStatus.APPROVED) {
BigDecimal prev;
prev = invoice.getPropertyPrice().subtract(this.amountPaid);
outstandingAmount = prev.subtract(amountPaid);
return outstandingAmount;
} else if (getPaymentStatus() == FinanceStatus.PENDING) {
return outstandingAmount;
}
return outstandingAmount;
}

Expand Down
33 changes: 0 additions & 33 deletions src/main/java/ng/org/mirabilia/pms/domain/entities/GltfModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,5 @@ public class GltfModel {
@JoinColumn(name = "property_id")
private Property property;

// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public byte[] getData() {
// return data;
// }
//
// public void setData(byte[] data) {
// this.data = data;
// }
//
// public Property getProperty() {
// return property;
// }
//
// public void setProperty(Property property) {
// this.property = property;
// }
//


}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ public class Invoice {
@Column(nullable = false)
private PropertyType propertyType;

@OneToMany(mappedBy = "invoice", cascade = CascadeType.ALL, orphanRemoval = true)
private List<PaymentReceipt> paymentReceipt;


@OneToMany(mappedBy = "invoice", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Finance> finances;

public Long getId() {
return id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package ng.org.mirabilia.pms.domain.entities;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import ng.org.mirabilia.pms.domain.enums.FinanceStatus;
import ng.org.mirabilia.pms.domain.enums.PaymentMethod;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@Setter
@Getter
@Entity
public class PaymentReceipt {
@Id
Expand All @@ -14,50 +22,39 @@ public class PaymentReceipt {
@JoinColumn(name = "propertyId")
private Property property;

@ManyToOne
@JoinColumn(name = "userId")
private User user;

@Lob
private byte[] receiptImage;

private LocalDateTime localDateTime;
@ManyToOne(cascade = CascadeType.MERGE)
@JoinColumn(name = "invoice_id", nullable = false)
private Invoice invoice;

public PaymentReceipt() {
}
@OneToOne
@JoinColumn(name = "finance_id", nullable = false)
private Finance finance;

public PaymentReceipt(Long id, Property property, byte[] receiptImage, LocalDateTime localDateTime) {
this.id = id;
this.property = property;
this.receiptImage = receiptImage;
this.localDateTime = localDateTime;
}
private LocalDateTime localDateTime;

public Long getId() {
return id;
}
private FinanceStatus financeStatus;

public void setId(Long id) {
this.id = id;
}
private BigDecimal amountPaid;

public Property getProperty() {
return property;
}
private PaymentMethod paymentMethod;

public void setProperty(Property property) {
this.property = property;
}
private String paidBy;

public byte[] getReceiptImage() {
return receiptImage;
public PaymentReceipt() {
}

public void setReceiptImage(byte[] receiptImage) {
public PaymentReceipt(Long id, Property property, byte[] receiptImage, LocalDateTime localDateTime) {
this.id = id;
this.property = property;
this.receiptImage = receiptImage;
}

public LocalDateTime getLocalDateTime() {
return localDateTime;
}

public void setLocalDateTime(LocalDateTime localDateTime) {
this.localDateTime = localDateTime;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public class Property {

private Set<String> exteriorFlooringItems = new HashSet<>();

@OneToOne(mappedBy = "property", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@OneToOne(mappedBy = "property", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
private GltfModel model;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ng.org.mirabilia.pms.domain.enums;
import com.vaadin.flow.component.html.Span;
import com.vaadin.flow.dom.Style;

public class CreateStatusTag {

Expand All @@ -9,30 +10,34 @@ public Span createStatusTag(InvoiceStatus status) {
// Apply styles based on the status
switch (status) {
case PAID:
statusTag.getStyle().set("background", "#34A853"); // Green
statusTag.getStyle().set("color", "#FFFFFF");
statusTag.getStyle().set("color", "rgb(52 168 83)"); //Green
statusTag.getStyle().setBackground("rgb(52 168 83 / 22%)");
statusTag.getStyle().setBorder("2px solid rgb(52 168 83)");
break;
case UNPAID:
statusTag.getStyle().set("background", "#C5221F"); // Red
statusTag.getStyle().set("color", "#FFFFFF");
statusTag.getStyle().setBackground("rgba(236, 170, 96, 0.15)"); // Red
statusTag.getStyle().setBorder("2px solid rgba(236, 170, 96, 1)"); // Red
statusTag.getStyle().set("color", "rgba(236, 170, 96, 1)");
break;
case PARTIAL:
statusTag.getStyle().set("background", "#F4A74B"); // Orange
statusTag.getStyle().set("color", "#FFFFFF");
break;
case OVERDUE:
statusTag.getStyle().set("background", "#B0BEC5"); // Default (Gray)
statusTag.getStyle().set("color", "#000000");
statusTag.getStyle().set("background", "rgb(234 67 53)"); // Red
statusTag.getStyle().setBorder("2px solid rgb(234 67 53 / 22%)"); // Red
statusTag.getStyle().set("color", "rgb(234 67 53)");
break;
}

// Common styles for all tags
statusTag.getStyle().set("padding", "5px");
statusTag.getStyle().set("border-radius", "10px");
statusTag.getStyle().set("padding", "3px");
statusTag.getStyle().set("width", "60px");
statusTag.getStyle().set("border-radius", "14px");
statusTag.getStyle().set("font-size", "12px");
statusTag.getStyle().set("font-weight", "500");
statusTag.getStyle().set("display", "inline-block"); // Ensure it behaves like a tag

statusTag.getStyle().set("font-weight", "600");
statusTag.getStyle().set("display", "inline-block");// Ensure it behaves like a tag
statusTag.getStyle().setTextAlign(Style.TextAlign.CENTER);
return statusTag;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
package ng.org.mirabilia.pms.repositories;

import ng.org.mirabilia.pms.domain.entities.GltfModel;
import ng.org.mirabilia.pms.domain.entities.Property;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface GltfModelRepository extends JpaRepository<GltfModel, Long> {}
public interface GltfModelRepository extends JpaRepository<GltfModel, Long> {
public GltfModel findByPropertyId(Long propertyId);
@Modifying
@Query("DELETE FROM GltfModel g WHERE g.property.id = :propertyId")
void deleteByPropertyId(@Param("propertyId") Long propertyId);
@Modifying
@Query("DELETE FROM GltfModel g WHERE g.id = :id")
void deleteById(@Param("id") Long id);

}

This file was deleted.

Loading