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

OP-1340 Force Lot's cost definition when LOTWITHCOST=yes and AUTOMATICLOT_IN=no #2066

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions bundle/language_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,7 @@ angal.medicalstock.multiplecharging.preparationdate
angal.medicalstock.multiplecharging.qtypacket = Qty/Packet
angal.medicalstock.multiplecharging.referencenumberabb = Reference No.
angal.medicalstock.multiplecharging.selectedlot = Selected Lot
angal.medicalstock.multiplecharging.selectedlotwithoutcostpleasespecify = Selected Lot {0} without cost, please specify...
mwithi marked this conversation as resolved.
Show resolved Hide resolved
angal.medicalstock.multiplecharging.supplier = Supplier
angal.medicalstock.multiplecharging.theinsertedreferencenumberalreadyexists.msg = The inserted reference number already exists.
angal.medicalstock.multiplecharging.totalcost = Total cost
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,12 @@ public class MovStockMultipleCharging extends JDialog {
};
private JComboBox comboBoxUnits = new JComboBox(qtyOption);
private int optionSelected = UNITS;
private List<Lot> updateLots = new ArrayList<Lot>();

private MovStockInsertingManager movStockInsertingManager = Context.getApplicationContext().getBean(MovStockInsertingManager.class);
private MedicalBrowsingManager medicalBrowsingManager = Context.getApplicationContext().getBean(MedicalBrowsingManager.class);
private MedicalDsrStockMovementTypeBrowserManager medicalDsrStockMovementTypeBrowserManager = Context.getApplicationContext()
.getBean(MedicalDsrStockMovementTypeBrowserManager.class);
.getBean(MedicalDsrStockMovementTypeBrowserManager.class);
private SupplierBrowserManager supplierBrowserManager = Context.getApplicationContext().getBean(SupplierBrowserManager.class);

private boolean isAutomaticLotIn() {
Expand Down Expand Up @@ -380,9 +381,9 @@ private JTextField getJTextFieldSearch() {

jTextFieldSearch.setColumns(10);
TextPrompt suggestion = new TextPrompt(
MessageBundle.getMessage("angal.medicalstock.typeacodeoradescriptionandpressenter"), //$NON-NLS-1$
jTextFieldSearch,
Show.FOCUS_LOST);
MessageBundle.getMessage("angal.medicalstock.typeacodeoradescriptionandpressenter"), //$NON-NLS-1$
jTextFieldSearch,
Show.FOCUS_LOST);

suggestion.setFont(new Font("Tahoma", Font.PLAIN, 14)); //$NON-NLS-1$
suggestion.setForeground(Color.GRAY);
Expand Down Expand Up @@ -412,11 +413,12 @@ private JTextField getJTextFieldSearch() {
// Lot (PreparationDate && ExpiringDate)
Lot lot;
boolean isNewLot = false;
boolean updateLot = false;
if (isAutomaticLotIn()) {
LocalDateTime preparationDate = TimeTools.getNow().truncatedTo(ChronoUnit.MINUTES);
LocalDateTime expiringDate = askExpiringDate();
lot = new Lot("", preparationDate, expiringDate); //$NON-NLS-1$
// Cost
// Lot Cost
BigDecimal cost = new BigDecimal(0);
if (GeneralData.LOTWITHCOST) {
cost = askCost(qty);
Expand All @@ -434,15 +436,16 @@ private JTextField getJTextFieldSearch() {
if (lot == null) {
return;
}
// Lot Cost
BigDecimal cost = new BigDecimal(0);
if (GeneralData.LOTWITHCOST) {
cost = askCost(qty);
if (cost.compareTo(new BigDecimal(0)) == 0) {
return;
}
}
// Lot Cost
BigDecimal cost = lot.getCost();
if ((cost == null || cost.equals(new BigDecimal(0))) && GeneralData.LOTWITHCOST) {
MessageDialog.warning(null, "angal.medicalstock.multiplecharging.selectedlotwithoutcostpleasespecify", lot.getCode());
cost = askCost(qty);
if (cost.compareTo(new BigDecimal(0)) == 0) {
return;
}
isNewLot = true;
updateLot = true;
lot.setCost(cost);
}
} while (lot == null);
Expand All @@ -455,7 +458,7 @@ private JTextField getJTextFieldSearch() {
String refNo = jTextFieldReference.getText().trim();

Movement movement = new Movement(med, (MovementType) jComboBoxChargeType.getSelectedItem(), null, lot, date, qty, new Supplier(), refNo);
model.addItem(movement, isNewLot);
model.addItem(movement, isNewLot, updateLot);

units.add(PACKETS);

Expand Down Expand Up @@ -499,8 +502,8 @@ protected BigDecimal askCost(int qty) {
double cost = 0.;
do {
String input = JOptionPane.showInputDialog(this,
MessageBundle.getMessage("angal.medicalstock.multiplecharging.unitcost"), //$NON-NLS-1$
0.);
MessageBundle.getMessage("angal.medicalstock.multiplecharging.unitcost"), //$NON-NLS-1$
0.);
if (input != null) {
try {
cost = Double.parseDouble(input);
Expand All @@ -523,8 +526,8 @@ protected BigDecimal askCost(int qty) {

protected double askTotalCost() {
String input = JOptionPane.showInputDialog(this,
MessageBundle.getMessage("angal.medicalstock.multiplecharging.totalcost"), //$NON-NLS-1$
0.);
MessageBundle.getMessage("angal.medicalstock.multiplecharging.totalcost"), //$NON-NLS-1$
0.);
double total = 0.;
if (input != null) {
try {
Expand Down Expand Up @@ -566,10 +569,10 @@ protected Lot askLot() {

do {
int ok = JOptionPane.showConfirmDialog(
this,
panel,
MessageBundle.getMessage("angal.medicalstock.multiplecharging.lotinformations"), //$NON-NLS-1$
JOptionPane.OK_CANCEL_OPTION);
this,
panel,
MessageBundle.getMessage("angal.medicalstock.multiplecharging.lotinformations"), //$NON-NLS-1$
JOptionPane.OK_CANCEL_OPTION);

if (ok == JOptionPane.OK_OPTION) {
String lotName = lotNameTextField.getText();
Expand Down Expand Up @@ -608,10 +611,10 @@ protected Medical chooseMedical(String text) {
panel.add(new JScrollPane(medTable));

int ok = JOptionPane.showConfirmDialog(
this,
panel,
MessageBundle.getMessage("angal.medicalstock.multiplecharging.chooseamedical"), //$NON-NLS-1$
JOptionPane.YES_NO_OPTION);
this,
panel,
MessageBundle.getMessage("angal.medicalstock.multiplecharging.chooseamedical"), //$NON-NLS-1$
JOptionPane.YES_NO_OPTION);

if (ok == JOptionPane.OK_OPTION) {
int row = medTable.getSelectedRow();
Expand Down Expand Up @@ -644,13 +647,13 @@ protected Lot chooseLot(Medical med) {
int row;
do {
int ok = JOptionPane.showOptionDialog(this,
panel,
MessageBundle.getMessage("angal.medicalstock.multiplecharging.existinglot"), //$NON-NLS-1$
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,
options[0]);
panel,
MessageBundle.getMessage("angal.medicalstock.multiplecharging.existinglot"), //$NON-NLS-1$
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,
options[0]);

if (ok == JOptionPane.YES_OPTION) {
row = lotTable.getSelectedRow();
Expand All @@ -676,8 +679,8 @@ protected LocalDateTime askExpiringDate() {
panel.add(expireDateChooser);

int ok = JOptionPane.showConfirmDialog(this, panel,
MessageBundle.getMessage("angal.medicalstock.multiplecharging.expiringdate"), //$NON-NLS-1$
JOptionPane.OK_CANCEL_OPTION);
MessageBundle.getMessage("angal.medicalstock.multiplecharging.expiringdate"), //$NON-NLS-1$
JOptionPane.OK_CANCEL_OPTION);

if (ok == JOptionPane.OK_OPTION) {
date = expireDateChooser.getLocalDateTime();
Expand All @@ -698,9 +701,9 @@ protected int askQuantity(Medical med) {
int qty = 0;
do {
String quantity = JOptionPane.showInputDialog(this,
message.toString(),
title.toString(),
JOptionPane.QUESTION_MESSAGE);
message.toString(),
title.toString(),
JOptionPane.QUESTION_MESSAGE);
if (quantity != null) {
try {
qty = Integer.parseInt(quantity);
Expand Down Expand Up @@ -764,9 +767,12 @@ public void removeItem(int row) {
fireTableDataChanged();
}

public void addItem(Movement movement, Boolean isNewLot) {
public void addItem(Movement movement, Boolean isNewLot, boolean updateLot) {
movements.add(movement);
newLots.add(isNewLot);
if (updateLot) {
updateLots.add(movement.getLot());
}
fireTableDataChanged();
}

Expand Down Expand Up @@ -922,6 +928,7 @@ private boolean save() {
boolean ok = true;
List<Movement> movements = model.getMovements();
try {
movStockInsertingManager.updateLot(updateLots);
movStockInsertingManager.newMultipleChargingMovements(movements, movements.get(0).getRefNo());
} catch (OHServiceException e) {
ok = false;
Expand Down
Loading