Skip to content

Commit

Permalink
Merge pull request #6 from Bahmni-HWC/GOK-366
Browse files Browse the repository at this point in the history
Add. e-Aushada Institute ID and Inward Number
  • Loading branch information
deeptirawat1510 authored Oct 9, 2023
2 parents 6557588 + 741fe9a commit 116c8c1
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ public class ItemStock extends BaseOpenmrsObject implements Comparable<ItemStock
private int quantity;
private Set<ItemStockDetail> details;
private String batchNumber;
private String inwardNumber;

public String getInwardNumber() {
return inwardNumber;
}

public void setInwardNumber(String inwardNumber) {
this.inwardNumber = inwardNumber;
}

public String getBatchNumber() {
return batchNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public ItemStockDetail(ItemStock stock, StockOperationTransaction tx) {
this.setCalculatedExpiration(tx.isCalculatedExpiration());
this.setCalculatedBatch(tx.isCalculatedBatch());
this.setQuantity(tx.getQuantity());
this.setInwardNumber(tx.getInwardNumber());
}

/**
Expand All @@ -76,6 +77,7 @@ public ItemStockDetail(ItemStockDetail base) {
setCalculatedBatch(base.isCalculatedBatch());
setCalculatedExpiration(base.isCalculatedExpiration());
setQuantity(base.getQuantity());
setInwardNumber(base.getInwardNumber());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ public class ItemStockDetailBase extends BaseOpenmrsObject {
private Boolean calculatedBatch;

private String batchNumber;
private String inwardNumber;
private Date inwardDate;

public Date getInwardDate() {
return inwardDate;
}

public void setInwardDate(Date inwardDate) {
this.inwardDate = inwardDate;
}

public String getInwardNumber() {
return inwardNumber;
}

public void setInwardNumber(String inwardNumber) {
this.inwardNumber = inwardNumber;
}

public String getBatchNumber() {
return batchNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public class StockOperation extends BaseInstanceCustomizableMetadata<IStockOpera
protected Department department;
private String cancelReason;
private String outwardId;
private String instituteId;
private Date inwardDate;

@Override
public Integer getId() {
Expand Down Expand Up @@ -175,6 +177,22 @@ public String getOutwardId() {
return outwardId;
}

public String getInstituteId() {
return instituteId;
}

public void setInstituteId(String instituteId) {
this.instituteId = instituteId;
}

public Date getInwardDate() {
return inwardDate;
}

public void setInwardDate(Date inwardDate) {
this.inwardDate = inwardDate;
}

public void setOutwardId(String outwardId) {
this.outwardId = outwardId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public abstract class TransactionBase extends BaseOpenmrsObject implements Compa
private Boolean sourceCalculatedBatch;
private String batchNumber;
private String outwardId;
private String instituteId;
private String inwardNumber;
private Date inwardDate;

private User creator;
private Date dateCreated = new Date();
Expand All @@ -55,6 +58,9 @@ protected TransactionBase(TransactionBase tx) {
calculatedBatch = tx.calculatedBatch;
batchNumber = tx.batchNumber;
outwardId = tx.outwardId;
instituteId = tx.instituteId;
inwardNumber = tx.inwardNumber;
inwardDate = tx.inwardDate;
}

protected TransactionBase(StockOperationItem item) {
Expand All @@ -65,6 +71,7 @@ protected TransactionBase(StockOperationItem item) {
this.calculatedBatch = item.isCalculatedBatch();
this.calculatedExpiration = item.isCalculatedExpiration();
this.batchNumber = item.getBatchNumber();
this.inwardNumber = item.getInwardNumber();
}

public Integer getId() {
Expand Down Expand Up @@ -171,6 +178,14 @@ public void setBatchNumber(String batchNumber) {
this.batchNumber = batchNumber;
}

public String getInwardNumber() {
return inwardNumber;
}

public void setInwardNumber(String inwardNumber) {
this.inwardNumber = inwardNumber;
}

@Override
public int compareTo(TransactionBase o) {
if (o == null) {
Expand Down
5 changes: 3 additions & 2 deletions api/src/main/resources/InvStockroom.hbm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<property name="calculatedExpiration" type="boolean" column="calculated_expiration" not-null="false" />
<property name="calculatedBatch" type="boolean" column="calculated_batch" not-null="false" />
<property name="batchNumber" type="java.lang.String" column="batch_number" />

<property name="inwardNumber" type="java.lang.String" column="inward_number" />

<property name="uuid" type="java.lang.String" column="uuid" length="38" unique="true" />
</class>
Expand Down Expand Up @@ -180,9 +180,10 @@
<property name="description" type="java.lang.String" column="description" />
<property name="operationNumber" type="java.lang.String" column="operation_number" not-null="true"/>
<property name="operationDate" type="java.util.Date" column="operation_date" not-null="true" />
<property name="inwardDate" type="java.util.Date" column="inward_date" />
<property name="operationOrder" type="int" column="operation_order" />
<property name="outwardId" type="java.lang.String" column="outward_id" />

<property name="instituteId" type="java.lang.String" column="institute_id" />
<many-to-one name="instanceType" class="IStockOperationType" not-null="true" lazy="false" column="operation_type_id" />

<!-- Access properties via the field so setter code is not run -->
Expand Down
27 changes: 27 additions & 0 deletions omod/src/main/resources/liquibase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,15 @@
ALTER TABLE inv_item_stock_detail ADD COLUMN batch_number VARCHAR(15) AFTER batch_operation_id;
</sql>
</changeSet>
<changeSet id="Adding-InwardNumber-GOK-366" author="Inventory">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">SELECT COUNT(*) FROM information_schema.columns WHERE table_name = 'inv_item_stock_detail' AND column_name = 'inward_number'</sqlCheck>
</preConditions>
<comment>Adding Inward Number column in inv_item_stock_detail table</comment>
<sql>
ALTER TABLE inv_item_stock_detail ADD COLUMN inward_number VARCHAR(15);
</sql>
</changeSet>
<changeSet id="Adding-OutwardId-colmnGOK-210" author="Inventory">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">SELECT COUNT(*) FROM information_schema.columns WHERE table_name = 'inv_stock_operation' AND column_name = 'outward_id'</sqlCheck>
Expand All @@ -1129,6 +1138,24 @@
ALTER TABLE inv_stock_operation ADD COLUMN outward_id VARCHAR(30);
</sql>
</changeSet>
<changeSet id="Adding-instituteId-colmnGOK-366" author="Inventory">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">SELECT COUNT(*) FROM information_schema.columns WHERE table_name = 'inv_stock_operation' AND column_name = 'institute_id'</sqlCheck>
</preConditions>
<comment>Adding InstituteId column in inv_stock_operation table</comment>
<sql>
ALTER TABLE inv_stock_operation ADD COLUMN institute_id VARCHAR(30);
</sql>
</changeSet>
<changeSet id="Adding-inward_date-colmn-GOK-366" author="Inventory">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">SELECT COUNT(*) FROM information_schema.columns WHERE table_name = 'inv_stock_operation' AND column_name = 'inward_date'</sqlCheck>
</preConditions>
<comment>Adding inward_date column in inv_stock_operation table</comment>
<sql>
ALTER TABLE inv_stock_operation ADD COLUMN inward_date DATETIME;
</sql>
</changeSet>
<changeSet id="GOK-131-add-eaushadha-item-attribute" author="Mohan">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">select count(*) from inv_item_attribute_type where name = 'eAushadhaID'</sqlCheck>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,12 @@ public void setBatchNumber(ItemStockDetailBase instance, String batchNumber) {
}
instance.setBatchNumber(batchNumber);
}

@PropertySetter("inwardNumber")
public void setInwardNumber(ItemStockDetailBase instance, String inwardNumber) {
if (inwardNumber == null || inwardNumber.trim().isEmpty()) {
throw new IllegalArgumentException("Could not parse '" + inwardNumber);
}
instance.setInwardNumber(inwardNumber);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public class StockOperationResource
private boolean submitRequired = false;
private boolean rollbackRequired = false;
private String outwardId;
private String instituteId;
private Date inwardDate;

public StockOperationResource() {
this.operationService = Context.getService(IStockOperationService.class);
Expand Down Expand Up @@ -100,6 +102,8 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
description.addProperty("operationOrder", Representation.DEFAULT);
description.addProperty("cancelReason", Representation.DEFAULT);
description.addProperty("outwardId", Representation.DEFAULT);
description.addProperty("instituteId", Representation.DEFAULT);
description.addProperty("inwardDate", Representation.DEFAULT);

if (!(rep instanceof RefRepresentation)) {
description.addProperty("source", Representation.REF);
Expand Down

0 comments on commit 116c8c1

Please sign in to comment.