Skip to content

Commit

Permalink
Merge pull request #6521 from hmislk/Issue#6520
Browse files Browse the repository at this point in the history
Issue#6520 Closed #6520
  • Loading branch information
DeshaniPubudu authored Jul 25, 2024
2 parents c608c90 + 8b71453 commit 5d1bfb6
Show file tree
Hide file tree
Showing 12 changed files with 2,362 additions and 113 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.divudi</groupId>

<artifactId>sethmademo</artifactId>
<artifactId>vfs</artifactId>
<version>3.0.0</version>
<packaging>war</packaging>
<name>sethmademo</name>
<name>vfs</name>

<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
Expand Down
61 changes: 52 additions & 9 deletions src/main/java/com/divudi/bean/optician/OpticianSaleController.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ public OpticianSaleController() {
BillItem editingBillItem;
Double qty;
Integer intQty;
private String strComment;
Stock stock;
Stock replacableStock;

Expand Down Expand Up @@ -790,9 +791,9 @@ public void handleSelectAction() {

getBillItem().getPharmaceuticalBillItem().setStock(stock);
calculateRates(billItem);
if (stock != null && stock.getItemBatch() != null) {
fillReplaceableStocksForAmp((Amp) stock.getItemBatch().getItem());
}
// if (stock != null && stock.getItemBatch() != null) {
// fillReplaceableStocksForAmp((Amp) stock.getItemBatch().getItem());
// }
}

public List<Item> completeRetailSaleItemsWithoutStocks(String qry) {
Expand Down Expand Up @@ -932,6 +933,7 @@ public void calculateBillItem() {
// billItem.setInwardChargeType(InwardChargeType.Medicine);
billItem.setItem(getStock().getItemBatch().getItem());
billItem.setQty(qty);
billItem.setDescreption(strComment);

//pharmaceutical Bill Item
billItem.getPharmaceuticalBillItem().setDoe(getStock().getItemBatch().getDateOfExpire());
Expand Down Expand Up @@ -971,23 +973,42 @@ public void calculateAllRates() {
}

public void calculateRates(BillItem bi) {
System.out.println("Entering calculateRates with BillItem: " + bi);
PharmaceuticalBillItem pharmBillItem = bi.getPharmaceuticalBillItem();
if (pharmBillItem != null && pharmBillItem.getStock() != null) {
ItemBatch itemBatch = pharmBillItem.getStock().getItemBatch();
if (itemBatch != null) {
bi.setRate(itemBatch.getRetailsaleRate());
System.out.println("ItemBatch found: " + itemBatch);
if (bi.getRate() == 0.0) {
bi.setRate(itemBatch.getRetailsaleRate());
System.out.println("Rate set from ItemBatch: " + bi.getRate());
} else {
System.out.println("Existing Rate: " + bi.getRate());
}
} else {
System.out.println("ItemBatch is null");
}
bi.setDiscountRate(calculateBillItemDiscountRate(bi));

// TODO - Configure Discounts
// bi.setDiscountRate(calculateBillItemDiscountRate(bi));
bi.setNetRate(bi.getRate() - bi.getDiscountRate());
System.out.println("NetRate calculated: " + bi.getNetRate());

bi.setGrossValue(bi.getRate() * bi.getQty());
System.out.println("GrossValue calculated: " + bi.getGrossValue());

bi.setDiscount(bi.getDiscountRate() * bi.getQty());
bi.setNetValue(bi.getGrossValue() - bi.getDiscount());
System.out.println("Discount calculated: " + bi.getDiscount());

bi.setNetValue(bi.getGrossValue() - bi.getDiscount());
System.out.println("NetValue calculated: " + bi.getNetValue());
} else {
System.out.println("PharmaceuticalBillItem or Stock is null");
}
}

public void calculateTotals() {
System.out.println("Entering calculateTotals");
getPreBill().setTotal(0);
double netTotal = 0.0, grossTotal = 0.0, discountTotal = 0.0;
int index = 0;
Expand All @@ -998,15 +1019,25 @@ public void calculateTotals() {
netTotal += b.getNetValue();
grossTotal += b.getGrossValue();
discountTotal += b.getDiscount();
// getPreBill().setTotal(getPreBill().getTotal() + b.getNetValue());
System.out.println("Processing BillItem: " + b);
System.out.println("Current NetValue: " + b.getNetValue());
}
}

getPreBill().setNetTotal(netTotal);
System.out.println("NetTotal set: " + netTotal);

getPreBill().setTotal(grossTotal);
System.out.println("Total set: " + grossTotal);

getPreBill().setGrantTotal(grossTotal);
System.out.println("GrantTotal set: " + grossTotal);

getPreBill().setDiscount(discountTotal);
System.out.println("DiscountTotal set: " + discountTotal);

setNetTotal(getPreBill().getNetTotal());
System.out.println("NetTotal updated: " + getNetTotal());
}

public double addBillItemSingleItem() {
Expand Down Expand Up @@ -1068,6 +1099,7 @@ public double addBillItemSingleItem() {
billItem.setInwardChargeType(InwardChargeType.Medicine);

billItem.setItem(getStock().getItemBatch().getItem());
billItem.setDescreption(strComment);
billItem.setBill(getPreBill());

billItem.setSearialNo(getPreBill().getBillItems().size() + 1);
Expand Down Expand Up @@ -2269,7 +2301,10 @@ public void handleStockSelect(SelectEvent event) {
return;
}
// getBillItem();
billItem.setRate(billItem.getPharmaceuticalBillItem().getStock().getItemBatch().getRetailsaleRate());
if (billItem.getRate() == 0.0) {
billItem.setRate(billItem.getPharmaceuticalBillItem().getStock().getItemBatch().getRetailsaleRate());
}

billItem.setInwardChargeType(InwardChargeType.Medicine);
billItem.setItem(getStock().getItemBatch().getItem());
//pharmaceutical Bill Item
Expand Down Expand Up @@ -2340,7 +2375,6 @@ public double calculateBillItemDiscountRate(BillItem bi) {
boolean discountAllowed = bi.getItem().isDiscountAllowed();

// MembershipScheme membershipScheme = membershipSchemeController.fetchPatientMembershipScheme(getPatient(), getSessionController().getApplicationPreference().isMembershipExpires());

//MEMBERSHIPSCHEME DISCOUNT
// if (membershipScheme != null && discountAllowed) {
// PaymentMethod tpm = getPaymentMethod();
Expand Down Expand Up @@ -2486,6 +2520,7 @@ private void clearBillItem() {
billItem = null;
editingBillItem = null;
qty = null;
strComment = null;
stock = null;
editingQty = null;
errorMessage = "";
Expand Down Expand Up @@ -2903,4 +2938,12 @@ public void setSelectedBillItems(List<BillItem> selectedBillItems) {
this.selectedBillItems = selectedBillItems;
}

public String getStrComment() {
return strComment;
}

public void setStrComment(String strComment) {
this.strComment = strComment;
}

}
37 changes: 21 additions & 16 deletions src/main/resources/META-INF/persistence.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="hmisPU" transaction-type="JTA">

<jta-data-source>jdbc/arogya</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="create-or-extend-tables"/>
</properties>
</persistence-unit>
<persistence-unit name="hmisAuditPU" transaction-type="JTA">
<jta-data-source>jdbc/arogyaAudit</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
</properties>
</persistence-unit>

<persistence version="2.2" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name="hmisPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/vfs</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level.sql" value="SEVERE"/>
<property name="eclipselink.logging.parameters" value="false"/>
<property name="javax.persistence.schema-generation.database.action" value="create-or-extend-tables"/>
</properties>
</persistence-unit>
<persistence-unit name="hmisAuditPU" transaction-type="JTA">
<jta-data-source>jdbc/vfsAudit</jta-data-source>
<class>com.divudi.entity.AuditEvent</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level.sql" value="SEVERE"/>
<property name="eclipselink.logging.parameters" value="false"/>
<property name="javax.persistence.schema-generation.database.action" value="create-or-extend-tables"/>
</properties>
</persistence-unit>
</persistence>
2 changes: 1 addition & 1 deletion src/main/webapp/WEB-INF/glassfish-web.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
<context-root>/sethmademo</context-root>
<context-root>/vfs</context-root>
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
Expand Down
Loading

0 comments on commit 5d1bfb6

Please sign in to comment.