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

10138 staff stock adjustment not working #10151

Merged
merged 3 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ private void saveExpiryDateAdjustmentBill() {
getDeptAdjustmentPreBill().setInsId(getBillNumberBean().institutionBillNumberGenerator(getSessionController().getInstitution(), BillType.PharmacyAdjustment, BillClassType.BilledBill, BillNumberSuffix.NONE));
getDeptAdjustmentPreBill().setBillType(BillType.PharmacyAdjustmentExpiryDate);
getDeptAdjustmentPreBill().setBillTypeAtomic(BillTypeAtomic.PHARMACY_STOCK_EXPIRY_DATE_AJUSTMENT);

getDeptAdjustmentPreBill().setDepartment(getSessionController().getLoggedUser().getDepartment());
getDeptAdjustmentPreBill().setInstitution(getSessionController().getLoggedUser().getDepartment().getInstitution());
getDeptAdjustmentPreBill().setToDepartment(null);
Expand All @@ -519,26 +519,25 @@ private PharmaceuticalBillItem saveDeptAdjustmentBillItems() {
billItem = null;
BillItem tbi = getBillItem();

PharmaceuticalBillItem ph = getBillItem().getPharmaceuticalBillItem();

// PharmaceuticalBillItem ph = getBillItem().getPharmaceuticalBillItem();
tbi.setPharmaceuticalBillItem(null);
ph.setStock(stock);
getBillItem().getPharmaceuticalBillItem().setStock(stock);

tbi.setItem(getStock().getItemBatch().getItem());
tbi.setQty((double) qty);

//pharmaceutical Bill Item
ph.setDoe(getStock().getItemBatch().getDateOfExpire());
ph.setFreeQty(0.0f);
ph.setItemBatch(getStock().getItemBatch());
getBillItem().getPharmaceuticalBillItem().setDoe(getStock().getItemBatch().getDateOfExpire());
getBillItem().getPharmaceuticalBillItem().setFreeQty(0.0f);
getBillItem().getPharmaceuticalBillItem().setItemBatch(getStock().getItemBatch());

Stock fetchedStock = getStockFacade().find(stock.getId());
double stockQty = fetchedStock.getStock();
double changingQty;

changingQty = qty - stockQty;

ph.setQty(changingQty);
getBillItem().getPharmaceuticalBillItem().setQty(changingQty);

//Rates
//Values
Expand All @@ -551,28 +550,14 @@ private PharmaceuticalBillItem saveDeptAdjustmentBillItems() {
tbi.setSearialNo(getDeptAdjustmentPreBill().getBillItems().size() + 1);
tbi.setCreatedAt(Calendar.getInstance().getTime());
tbi.setCreater(getSessionController().getLoggedUser());

ph.setBillItem(null);

if (ph.getId() == null) {
getPharmaceuticalBillItemFacade().create(ph);
}

tbi.setPharmaceuticalBillItem(ph);

if (tbi.getId() == null) {
getBillItemFacade().create(tbi);
} else {
getBillItemFacade().edit(tbi);
}

ph.setBillItem(tbi);
getPharmaceuticalBillItemFacade().edit(ph);

getDeptAdjustmentPreBill().getBillItems().add(tbi);

getBillFacade().edit(getDeptAdjustmentPreBill());

return ph;

return getBillItem().getPharmaceuticalBillItem();
}

private PharmaceuticalBillItem saveDeptAdjustmentBillItems(Stock s) {
Expand Down Expand Up @@ -1107,19 +1092,13 @@ public void adjustStockForDepartment() {
}

public void adjustStaffStock() {
Date startTime = new Date();
Date fromDate = null;
Date toDate = null;

if (errorCheck()) {
return;
}

if (qty == null) {
JsfUtil.addErrorMessage("Add Quantity..");
return;
}

if ((comment == null) || (comment.trim().equals(""))) {
JsfUtil.addErrorMessage("Add the Comment..");
return;
Expand Down
53 changes: 21 additions & 32 deletions src/main/webapp/pharmacy/pharmacy_adjustment_staff.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
<p:panel>
<f:facet name="header">
<h:outputText styleClass="fa-solid fa-person-shelter"></h:outputText>
<h:outputLabel value="Staff Stock Adjustment" class="mx-4"></h:outputLabel>
<h:outputLabel value="Staff Stock Adjustment*" class="mx-4"></h:outputLabel>
</f:facet>

<div class="row">
<div class="col-md-6">
<p:panel>
<f:facet name="header">
<h:outputText styleClass="fa-solid fa-file-invoice"></h:outputText>
<h:outputLabel value="Item Details" class="mx-4"></h:outputLabel>
<h:outputLabel value="Item &amp; Staff Details" class="mx-4"></h:outputLabel>
</f:facet>

<div class="row">
<div class="col-md-3">
<h:outputLabel value="Item" ></h:outputLabel>
<h:outputLabel value="Select Item &amp; Staff" ></h:outputLabel>
</div>
<div class="col-md-6">
<p:autoComplete
Expand All @@ -50,8 +50,8 @@
commonController.dateAfterThreeMonthsCurrentDateTime > i.itemBatch.dateOfExpire ?'color: red; background-color: yellow;':''}" ></h:outputLabel>
</p:column>
<p:column headerText="Code" style="padding: 3px;" >
<h:outputText value="#{i.itemBatch.item.code}" ></h:outputText>
</p:column>
<h:outputText value="#{i.itemBatch.item.code}" ></h:outputText>
</p:column>
<p:column headerText="Rate">
<h:outputLabel value="#{i.itemBatch.retailsaleRate}" >
<f:convertNumber pattern="#,##0.00" ></f:convertNumber>
Expand Down Expand Up @@ -97,7 +97,7 @@
action="#{pharmacyAdjustmentController.adjustStaffStock()}"
class="w-1000 my-2 ui-button-warning"
icon="fa-solid fa-sliders">

</p:commandButton>
</div>
</p:panel>
Expand All @@ -109,25 +109,13 @@
<h:outputLabel value="Item Details" class="mx-4"></h:outputLabel>
</f:facet>
<div>
<div class="row">
<div class="col-md-3">
<h:outputLabel value="Stock ID"/>
</div>
<div class="col-md-2">
<h:outputLabel value=":"/>
</div>
<div class="col-md-7">
<h:outputLabel value="#{pharmacyAdjustmentController.stock.id}" ></h:outputLabel>
</div>
</div>

<div class="row">
<div class="col-md-3"><h:outputLabel value="Item ID"/></div>
<div class="row">
<div class="col-md-3"><h:outputLabel value="Staff Name"/></div>
<div class="col-md-2"><h:outputLabel value=":"/></div>
<div class="col-md-7"><h:outputLabel value="#{pharmacyAdjustmentController.stock.itemBatch.item.id}" ></h:outputLabel></div>
<div class="col-md-7"><h:outputLabel value="#{pharmacyAdjustmentController.stock.staff.person.nameWithTitle}" ></h:outputLabel></div>
</div>
<div class="row">
<div class="col-md-3"><h:outputLabel value="Name"/></div>
<div class="col-md-3"><h:outputLabel value="Item Name"/></div>
<div class="col-md-2"><h:outputLabel value=":"/></div>
<div class="col-md-7"><h:outputLabel value="#{pharmacyAdjustmentController.stock.itemBatch.item.name}" ></h:outputLabel></div>
</div>
Expand All @@ -136,14 +124,7 @@
<div class="col-md-2"><h:outputLabel value=":"/></div>
<div class="col-md-7"><h:outputLabel value="#{pharmacyAdjustmentController.stock.itemBatch.item.code}" ></h:outputLabel></div>
</div>
<div class="row">
<div class="col-md-3"> <h:outputLabel value="Retail Sale Rate"/></div>
<div class="col-md-2"><h:outputLabel value=":"/></div>
<div class="col-md-7"><h:outputLabel value="#{pharmacyAdjustmentController.stock.itemBatch.retailsaleRate}" >
<f:convertNumber pattern="#,##0.00" ></f:convertNumber>
</h:outputLabel></div>
</div>
<div class="row">
<div class="row">
<div class="col-md-3"><h:outputLabel value="Stocks"/></div>
<div class="col-md-2"><h:outputLabel value=":"/></div>
<div class="col-md-7"><h:outputLabel value="#{pharmacyAdjustmentController.stock.stock}" >
Expand All @@ -163,14 +144,22 @@
severity="#{commonController.currentDateTime > pharmacyAdjustmentController.stock.itemBatch.dateOfExpire ?'danger': commonController.dateAfterThreeMonthsCurrentDateTime > pharmacyAdjustmentController.stock.itemBatch.dateOfExpire ?'warning':''}" />
</h:outputLabel></div>
</div>
<div class="row">
<div class="col-md-3"> <h:outputLabel value="Retail Sale Rate"/></div>
<div class="col-md-2"><h:outputLabel value=":"/></div>
<div class="col-md-7"><h:outputLabel value="#{pharmacyAdjustmentController.stock.itemBatch.retailsaleRate}" >
<f:convertNumber pattern="#,##0.00" ></f:convertNumber>
</h:outputLabel></div>
</div>

</div>

</p:panel>
</div>
</div>
</p:panel>


</h:form>
</ui:define>
</ui:composition>
Expand Down