Skip to content

Commit

Permalink
Merge pull request #465 from udsm-dhis2-lab/feature/gepg_requestmodif…
Browse files Browse the repository at this point in the history
…ication

merge contains view of request and control number also payments if made
  • Loading branch information
josephatJ authored Oct 31, 2024
2 parents a8b02e2 + d2d06fb commit 16fe127
Show file tree
Hide file tree
Showing 26 changed files with 1,298 additions and 868 deletions.
3 changes: 2 additions & 1 deletion docker/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sh docker/build-local.sh
version=$(cat version)
branch=$(git branch | grep \* | cut -d ' ' -f2)
docker push udsmdhis2/icare-core:$branch-$version
docker push udsmdhis2/icare-core:local
# docker push udsmdhis2/icare-core:$branch-$version
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ public class ICareConfig {

public static final String PKCS12_PASSWORD = "iCare.GePG.settings.pkcs12Password";

public static final String GEPG_USERNAME = "iCare.GePG.settings.GepgUsername";

public static final String GEPG_PASSWORD = "iCare.GePG.settings.GepgPassword";

public static final String DEFAULT_PAYMENT_TYPE_VIA_CONTROL_NUMBER = "icare.billing.controlNumberBasedPaymentType.concept.uuid";

public static final String ALLOW_REMOTE_HISTORY = "iCare.interoperability.settings.allowRemoteHistory";
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package org.openmrs.module.icare.billing.Utils;

public enum PaymentStatus {
PAID, FAILED, UNPAID, REQUESTED
PAID, FAILED, UNPAID, REQUESTED, PENDING
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
* Home object for domain model class BlPayment.
Expand All @@ -37,7 +40,7 @@ public Payment save(Payment entity) {
session.persist(this.getType(), entity);
session.flush();

//this.sessionFactory.getCurrentSession().saveOrUpdate(entity);
// this.sessionFactory.getCurrentSession().saveOrUpdate(entity);
return entity;
}

Expand All @@ -51,11 +54,52 @@ public List<Payment> findByPatientUuid(String patientUuid) {

public String getReferenceNumberByRequestId(String requestId) {
DbSession session = this.getSession();
String queryStr = "SELECT p.referenceNumber FROM Payment p WHERE p.uuid = :requestId";
String queryStr = "SELECT p.referenceNumber FROM Payment p WHERE p.id = :requestId";
Query query = session.createQuery(queryStr);
query.setParameter("requestId", requestId);
String referenceNumber = (String) query.uniqueResult();
return referenceNumber;
}

//Get All Payments with its status
public List<Payment> getAllPayments() {
DbSession session = this.getSession();
String queryStr = "SELECT p FROM Payment p";
Query query = session.createQuery(queryStr);
return query.list();
}

public Payment getPaymentByRequestId(Integer requestId) {
DbSession session = this.getSession();
String queryStr = "SELECT p FROM Payment p WHERE p.id = :requestId";
Query query = session.createQuery(queryStr);
query.setParameter("requestId", requestId);
return (Payment) query.uniqueResult();
}

public int setReferenceNumberByPaymentId(Integer paymentId, String pyReference) {
DbSession session = this.getSession();
String queryStr = "UPDATE Payment p SET p.referenceNumber = :pyReference WHERE p.id = :paymentId";
Query query = session.createQuery(queryStr);
query.setParameter("pyReference", pyReference);
query.setParameter("paymentId", paymentId);

return query.executeUpdate();

}

public List<Payment> findByPaymentTypeId(Integer paymentTypeId) {
DbSession session = this.getSession();
String queryStr = "FROM Payment p WHERE p.paymentType.id = :paymentTypeId";
Query query = session.createQuery(queryStr);
query.setParameter("paymentTypeId", paymentTypeId);
return query.list();
}

public void updatePayment(Payment payment) {
DbSession session = getSession();
session.update(payment);
session.flush();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.openmrs.module.icare.billing.Utils.PaymentStatus;
import org.openmrs.module.icare.core.Item;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import javax.persistence.*;
import java.util.*;

Expand Down Expand Up @@ -42,10 +44,100 @@ public class Payment extends BaseOpenmrsData implements java.io.Serializable {
@Column(name = "status", nullable = true, length = 16)
private PaymentStatus status;

// new payments
@Column(name = "receipt_number", length = 255)
private String receiptNumber;

@Column(name = "bill_amount")
private Double billAmount;

@Column(name = "paid_amount")
private Double paidAmount;

@Column(name = "payment_date")
private Date paymentDate;

@Column(name = "payer_number", length = 255)
private String payerNumber;

@Column(name = "payer_name", length = 255)
private String payerName;

@Column(name = "psp_name", length = 255)
private String pspName;

@Column(name = "account_number", length = 255)
private String accountNumber;

public Payment() {

}

// Getters and Setters
public String getReceiptNumber() {
return receiptNumber;
}

public void setReceiptNumber(String receiptNumber) {
this.receiptNumber = receiptNumber;
}

public Double getBillAmount() {
return billAmount;
}

public void setBillAmount(Double billAmount) {
this.billAmount = billAmount;
}

public Double getPaidAmount() {
return paidAmount;
}

public void setPaidAmount(Double paidAmount) {
this.paidAmount = paidAmount;
}

public Date getPaymentDate() {
return paymentDate;
}

public void setPaymentDate(Date paymentDate) {
this.paymentDate = paymentDate;
}

public String getPayerNumber() {
return payerNumber;
}

public void setPayerNumber(String payerNumber) {
this.payerNumber = payerNumber;
}

public String getPayerName() {
return payerName;
}

public void setPayerName(String payerName) {
this.payerName = payerName;
}

public String getPspName() {
return pspName;
}

public void setPspName(String pspName) {
this.pspName = pspName;
}

public String getAccountNumber() {
return accountNumber;
}

public void setAccountNumber(String accountNumber) {
this.accountNumber = accountNumber;
}

public Invoice getInvoice() {
return this.invoice;
}
Expand Down Expand Up @@ -131,39 +223,52 @@ public Map<String, Object> toMap() {
Map<String, Object> paymentMap = new HashMap<String, Object>();
paymentMap.put("uuid", this.getUuid());
paymentMap.put("referenceNumber", this.getReferenceNumber());

Map<String, Object> creatorObject = new HashMap<String, Object>();

if (this.getCreator() != null) {
creatorObject.put("uuid", this.getCreator().getUuid());
creatorObject.put("display", this.getCreator().getDisplayString());
}

paymentMap.put("creator", creatorObject);

paymentMap.put("created", this.getDateCreated());

paymentMap.put("voided", this.getVoided());

/*Map<String, Object> invoiceMap = new HashMap<String, Object>();
invoiceMap.put("uuid", this.getInvoice().getUuid());
// paymentMap.put("invoice", invoiceMap);*/

/*
* Map<String, Object> invoiceMap = new HashMap<String, Object>();
* invoiceMap.put("uuid", this.getInvoice().getUuid());
* // paymentMap.put("invoice", invoiceMap);
*/
paymentMap.put("receivedBy", this.getReceivedBy());
Map<String, Object> paymentTypeMap = new HashMap<String, Object>();
paymentTypeMap.put("uuid", this.getPaymentType().getUuid());
paymentTypeMap.put("name", this.getPaymentType().getDisplayString());
paymentMap.put("paymentType", paymentTypeMap);

List<Map<String, Object>> invoiceItems = new ArrayList<Map<String, Object>>();
for (PaymentItem paymentItem : this.getItems()) {
invoiceItems.add(paymentItem.getMap());
}
paymentMap.put("items", invoiceItems);

Map<String,Object> visitMap = new HashMap<>();
visitMap.put("uuid",this.getInvoice().getVisit().getUuid());
paymentMap.put("visit",visitMap);

Map<String, Object> visitMap = new HashMap<>();
visitMap.put("uuid", this.getInvoice().getVisit().getUuid());
paymentMap.put("visit", visitMap);
// Include status in the map
paymentMap.put("status", this.getStatus() != null ? this.getStatus().name() : null);
// Adding new fields
paymentMap.put("receiptNumber", this.getReceiptNumber());
paymentMap.put("billAmount", this.getBillAmount());
paymentMap.put("paidAmount", this.getPaidAmount());
paymentMap.put("paymentDate", this.getPaymentDate());
paymentMap.put("payerNumber", this.getPayerNumber());
paymentMap.put("payerName", this.getPayerName());
paymentMap.put("pspName", this.getPspName());
paymentMap.put("accountNumber", this.getAccountNumber());

return paymentMap;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package org.openmrs.module.icare.billing.models;

import java.util.Date;
import java.util.UUID;

public class PaymentRequest {

private Integer paymentId; // Payment ID

private UUID uuid; // Unique identifier for the payment

private String invoiceId; // ID of the associated invoice

private String referenceNumber; // Reference number for the payment

private String receivedBy; // User or entity that received the payment

private Integer paymentTypeId; // ID of the payment type

private Date dateCreated; // Date the payment was created

private String status; // Current status of the payment

// Default constructor
public void Payment() {
}

// Constructor with parameters
public void Payment(Integer paymentId, UUID uuid, String invoiceId, String referenceNumber, String receivedBy,
Integer paymentTypeId, Date dateCreated, String status) {
this.paymentId = paymentId;
this.uuid = uuid;
this.invoiceId = invoiceId;
this.referenceNumber = referenceNumber;
this.receivedBy = receivedBy;
this.paymentTypeId = paymentTypeId;
this.dateCreated = dateCreated;
this.status = status;
}

// Getter and Setter for paymentId
public Integer getPaymentId() {
return paymentId;
}

public void setPaymentId(Integer paymentId) {
this.paymentId = paymentId;
}

// Getter and Setter for uuid
public UUID getUuid() {
return uuid;
}

public void setUuid(UUID uuid) {
this.uuid = uuid;
}

// Getter and Setter for invoiceId
public String getInvoiceId() {
return invoiceId;
}

public void setInvoiceId(String invoiceId) {
this.invoiceId = invoiceId;
}

// Getter and Setter for referenceNumber
public String getReferenceNumber() {
return referenceNumber;
}

public void setReferenceNumber(String referenceNumber) {
this.referenceNumber = referenceNumber;
}

// Getter and Setter for receivedBy
public String getReceivedBy() {
return receivedBy;
}

public void setReceivedBy(String receivedBy) {
this.receivedBy = receivedBy;
}

// Getter and Setter for paymentTypeId
public Integer getPaymentTypeId() {
return paymentTypeId;
}

public void setPaymentTypeId(Integer paymentTypeId) {
this.paymentTypeId = paymentTypeId;
}

// Getter and Setter for dateCreated
public Date getDateCreated() {
return dateCreated;
}

public void setDateCreated(Date dateCreated) {
this.dateCreated = dateCreated;
}

// Getter and Setter for status
public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}
}
Loading

0 comments on commit 16fe127

Please sign in to comment.