From ff77b2510469ed491b53ed0150445e9c395ac47c Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Wed, 28 Feb 2024 10:11:17 +0100 Subject: [PATCH 001/147] add Inventory Browser --- bundle/language_en.properties | 10 + .../gui/InventoryBrowser.java | 457 ++++++++++++++++++ .../isf/utils/jobjects/InventoryState.java | 55 +++ 3 files changed, 522 insertions(+) create mode 100644 src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java create mode 100644 src/main/java/org/isf/utils/jobjects/InventoryState.java diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 89746f971b..9041fc7603 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -427,6 +427,7 @@ angal.common.qty.txt angal.common.quantity.txt = Quantity angal.common.reminder.txt = Reminder angal.common.result.txt = Result +angal.common.reference = Reference angal.common.save = Save angal.common.save.btn = Save angal.common.save.btn.key = S @@ -440,6 +441,10 @@ angal.common.sex.label angal.common.sex.txt = Sex angal.common.sms.txt = SMS angal.common.status.txt = Status +angal.common.statecanceled = Canceled +angal.common.stateinprogress = In progress +angal.common.statevalidate = Validate +angal.common.status.txt = Status angal.common.stockcard.btn = StockCard angal.common.stockcard.btn.key = K angal.common.stockledger.btn = Stock Ledger @@ -474,6 +479,8 @@ angal.common.update.btn.key angal.common.user.col = User angal.common.userid = User angal.common.userid.label = User: +angal.common.view.btn = View +angal.common.view.btn.key = V angal.common.ward.txt = Ward angal.common.weight.txt = Weight angal.common.years.txt = Years @@ -661,6 +668,7 @@ angal.hospital.thevisitinghourvaluesmustbeintherange0to24.msg angal.hospital.visitduration.txt = Visit duration angal.hospital.visitendhour.txt = Visit end hour angal.hospital.visitstarthour.txt = Visit start hour +angal.inventory.inventorybrowser.title = Inventory Browser angal.lab.allnegative.txt = All negative. angal.lab.blood.txt = Blood angal.lab.cfs.txt = CFS @@ -1021,6 +1029,7 @@ angal.menu.btn.generaldata angal.menu.btn.groups = Groups angal.menu.btn.help = Help angal.menu.btn.hospital = Hospital +angal.menu.btn.inventory = Inventory angal.menu.btn.labbrowsing = Laboratory Browsing angal.menu.btn.laboratory = Laboratory angal.menu.btn.logfile = Logs @@ -1077,6 +1086,7 @@ angal.menu.generaldata angal.menu.groups = Groups angal.menu.help = Help angal.menu.hospital = Hospital +angal.menu.inventory = Inventory angal.menu.labbrowsing = LaboratoryBrowsing angal.menu.laboratory = Laboratory angal.menu.logfile = Logs diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java new file mode 100644 index 0000000000..b965998ed2 --- /dev/null +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -0,0 +1,457 @@ +/* + * Open Hospital (www.open-hospital.org) + * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * + * Open Hospital is a free and open source software for healthcare data management. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * https://www.gnu.org/licenses/gpl-3.0-standalone.html + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.isf.medicalinventory.gui; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.GregorianCalendar; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.border.EmptyBorder; +import javax.swing.table.DefaultTableModel; + +import org.isf.generaldata.MessageBundle; +import org.isf.utils.jobjects.GoodDateChooser; +import org.isf.utils.jobjects.InventoryState; +import org.isf.utils.jobjects.ModalJFrame; +import org.isf.utils.time.TimeTools; + +public class InventoryBrowser extends ModalJFrame { + + private GoodDateChooser jCalendarTo; + private GoodDateChooser jCalendarFrom; + private LocalDateTime dateFrom = TimeTools.getServerDateTime(); + private LocalDateTime dateTo = TimeTools.getServerDateTime(); + private JLabel jLabelTo; + private JLabel jLabelFrom; + private JPanel panelHeader; + private JPanel panelFooter; + private JPanel panelContent; + private JButton jButtonClose; + private JButton jButtonNew; + private JButton jButtonEdit; + private JButton jButtonPrint; + private JButton jButtonDelete; + private JButton jButtonView; + private JScrollPane scrollPaneInventory; + private JTable jTableInventory; + private String[] pColums = { MessageBundle.getMessage("angal.common.reference").toUpperCase(), + MessageBundle.getMessage("angal.common.date.txt").toUpperCase(), + MessageBundle.getMessage("angal.common.status.txt").toUpperCase(), + MessageBundle.getMessage("angal.common.user.col").toUpperCase() }; + private int[] pColumwidth = { 150, 150, 150, 200 }; + private JComboBox stateComboBox; + private JLabel stateLabel; + JButton next; + JButton previous; + JComboBox pagesCombo = new JComboBox(); + JLabel under = new JLabel("/ 0 Page"); + private static int PAGE_SIZE = 50; + private int START_INDEX = 0; + private int TOTAL_ROWS; + + public InventoryBrowser() { + initComponents(); + } + + private void initComponents() { + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setMinimumSize(new Dimension(850, 550)); + setLocationRelativeTo(null); // center + setTitle(MessageBundle.getMessage("angal.inventory.inventorybrowser.title")); + + panelHeader = getPanelHeader(); + getContentPane().add(panelHeader, BorderLayout.NORTH); + + panelContent = getPanelContent(); + getContentPane().add(panelContent, BorderLayout.CENTER); + + panelFooter = getPanelFooter(); + getContentPane().add(panelFooter, BorderLayout.SOUTH); + + ajustWidth(); + + pagesCombo.setEditable(true); + previous.setEnabled(false); + next.setEnabled(false); + next.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent ae) { + if (!previous.isEnabled()) + previous.setEnabled(true); + START_INDEX += PAGE_SIZE; + jTableInventory.setModel(new InventoryBrowsingModel(START_INDEX, PAGE_SIZE)); + if ((START_INDEX + PAGE_SIZE) > TOTAL_ROWS) { + next.setEnabled(false); + } + pagesCombo.setSelectedItem(START_INDEX / PAGE_SIZE + 1); + } + }); + + previous.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent ae) { + if (!next.isEnabled()) + next.setEnabled(true); + START_INDEX -= PAGE_SIZE; + jTableInventory.setModel(new InventoryBrowsingModel(START_INDEX, PAGE_SIZE)); + if (START_INDEX < PAGE_SIZE) { + previous.setEnabled(false); + } + pagesCombo.setSelectedItem(START_INDEX / PAGE_SIZE + 1); + } + }); + pagesCombo.addItemListener(new ItemListener() { + + public void itemStateChanged(ItemEvent itemEvent) { + int eventID = itemEvent.getStateChange(); + + if (eventID == ItemEvent.SELECTED) { + int page_number = (Integer) pagesCombo.getSelectedItem(); + START_INDEX = (page_number - 1) * PAGE_SIZE; + + if ((START_INDEX + PAGE_SIZE) > TOTAL_ROWS) { + next.setEnabled(false); + } else { + next.setEnabled(true); + } + if (page_number == 1) { + previous.setEnabled(false); + } else { + previous.setEnabled(true); + } + pagesCombo.setSelectedItem(START_INDEX / PAGE_SIZE + 1); + jTableInventory.setModel(new InventoryBrowsingModel(START_INDEX, PAGE_SIZE)); + + pagesCombo.setEnabled(true); + } + } + }); + } + + private JPanel getPanelHeader() { + if (panelHeader == null) { + panelHeader = new JPanel(); + panelHeader.setBorder(new EmptyBorder(5, 0, 0, 5)); + GridBagLayout gbl_panelHeader = new GridBagLayout(); + gbl_panelHeader.columnWidths = new int[] { 83, 97, 66, 99, 95, 136, 0 }; + gbl_panelHeader.rowHeights = new int[] { 32, 0 }; + gbl_panelHeader.columnWeights = new double[] { 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, Double.MIN_VALUE }; + gbl_panelHeader.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; + panelHeader.setLayout(gbl_panelHeader); + GridBagConstraints gbc_jLabelFrom = new GridBagConstraints(); + gbc_jLabelFrom.fill = GridBagConstraints.HORIZONTAL; + gbc_jLabelFrom.insets = new Insets(0, 0, 0, 5); + gbc_jLabelFrom.gridx = 0; + gbc_jLabelFrom.gridy = 0; + panelHeader.add(getJLabelFrom(), gbc_jLabelFrom); + GridBagConstraints gbc_jCalendarFrom = new GridBagConstraints(); + gbc_jCalendarFrom.fill = GridBagConstraints.HORIZONTAL; + gbc_jCalendarFrom.insets = new Insets(0, 0, 0, 5); + gbc_jCalendarFrom.gridx = 1; + gbc_jCalendarFrom.gridy = 0; + panelHeader.add(getJCalendarFrom(), gbc_jCalendarFrom); + GridBagConstraints gbc_jLabelTo = new GridBagConstraints(); + gbc_jLabelTo.fill = GridBagConstraints.HORIZONTAL; + gbc_jLabelTo.insets = new Insets(0, 0, 0, 5); + gbc_jLabelTo.gridx = 2; + gbc_jLabelTo.gridy = 0; + panelHeader.add(getJLabelTo(), gbc_jLabelTo); + GridBagConstraints gbc_jCalendarTo = new GridBagConstraints(); + gbc_jCalendarTo.fill = GridBagConstraints.HORIZONTAL; + gbc_jCalendarTo.insets = new Insets(0, 0, 0, 5); + gbc_jCalendarTo.gridx = 3; + gbc_jCalendarTo.gridy = 0; + panelHeader.add(getJCalendarTo(), gbc_jCalendarTo); + GridBagConstraints gbc_stateLabel = new GridBagConstraints(); + gbc_stateLabel.fill = GridBagConstraints.HORIZONTAL; + gbc_stateLabel.insets = new Insets(0, 0, 0, 5); + gbc_stateLabel.gridx = 4; + gbc_stateLabel.gridy = 0; + panelHeader.add(getStateLabel(), gbc_stateLabel); + GridBagConstraints gbc_comboBox = new GridBagConstraints(); + gbc_comboBox.fill = GridBagConstraints.HORIZONTAL; + gbc_comboBox.gridx = 5; + gbc_comboBox.gridy = 0; + panelHeader.add(getComboBox(), gbc_comboBox); + } + return panelHeader; + } + private JPanel getPanelContent() { + if (panelContent == null) { + panelContent = new JPanel(); + GridBagLayout gbl_panelContent = new GridBagLayout(); + gbl_panelContent.columnWidths = new int[] { 452, 0 }; + gbl_panelContent.rowHeights = new int[] { 402, 0 }; + gbl_panelContent.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; + gbl_panelContent.rowWeights = new double[] { 1.0, Double.MIN_VALUE }; + panelContent.setLayout(gbl_panelContent); + GridBagConstraints gbc_scrollPaneInventory = new GridBagConstraints(); + gbc_scrollPaneInventory.fill = GridBagConstraints.BOTH; + gbc_scrollPaneInventory.gridx = 0; + gbc_scrollPaneInventory.gridy = 0; + panelContent.add(getScrollPaneInventory(), gbc_scrollPaneInventory); + } + return panelContent; + } + private JPanel getPanelFooter() { + if (panelFooter == null) { + panelFooter = new JPanel(); + next = new JButton(MessageBundle.getMessage("angal.visit.nextarrow.btn")); + next.setMnemonic(MessageBundle.getMnemonic("angal.visit.nextarrow.btn.key")); + previous = new JButton(MessageBundle.getMessage("angal.visit.arrowprevious.btn")); + next.setMnemonic(MessageBundle.getMnemonic("angal.visit.arrowprevious.btn.key")); + + panelFooter.add(previous); + panelFooter.add(pagesCombo); + panelFooter.add(under); + panelFooter.add(next); + + panelFooter.add(getNewButton()); + panelFooter.add(getViewButton()); + panelFooter.add(getUpdateButton()); + panelFooter.add(getPrintButton()); + panelFooter.add(getDeleteButton()); + panelFooter.add(getCloseButton()); + } + return panelFooter; + } + private GoodDateChooser getJCalendarTo() { + if (jCalendarTo == null) { + jCalendarTo = new GoodDateChooser(LocalDate.now()); + jCalendarTo.addDateChangeListener(event -> { + LocalDate newDate = event.getNewDate(); + if (newDate != null) { + dateTo = newDate.atTime(LocalTime.MAX); + } + }); + } + return jCalendarTo; + } + + private GoodDateChooser getJCalendarFrom() { + if (jCalendarFrom == null) { + jCalendarFrom = new GoodDateChooser(LocalDate.now()); + jCalendarFrom.addDateChangeListener(event -> { + LocalDate newDate = event.getNewDate(); + if (newDate != null) { + dateFrom = newDate.atTime(LocalTime.MAX); } + }); + } + return jCalendarFrom; + } + + private JLabel getJLabelTo() { + if (jLabelTo == null) { + jLabelTo = new JLabel(); + jLabelTo.setHorizontalAlignment(SwingConstants.RIGHT); + jLabelTo.setText(MessageBundle.getMessage("angal.common.dateto.label")); //$NON-NLS-1$ + } + return jLabelTo; + } + private JLabel getJLabelFrom() { + if (jLabelFrom == null) { + jLabelFrom = new JLabel(); + jLabelFrom.setHorizontalAlignment(SwingConstants.RIGHT); + jLabelFrom.setText(MessageBundle.getMessage("angal.common.datefrom.label")); //$NON-NLS-1$ + } + return jLabelFrom; + } + + private JButton getNewButton() { + jButtonNew = new JButton(MessageBundle.getMessage("angal.common.new.btn")); + jButtonNew.setMnemonic(MessageBundle.getMnemonic("angal.common.new.btn.key")); + return jButtonNew; + } + + private JButton getViewButton() { + jButtonView = new JButton(MessageBundle.getMessage("angal.common.view.btn")); + jButtonView.setMnemonic(MessageBundle.getMnemonic("angal.common.view.btn.key")); + return jButtonView; + } + + private JButton getUpdateButton() { + jButtonEdit = new JButton(MessageBundle.getMessage("angal.common.edit.btn")); + jButtonEdit.setMnemonic(MessageBundle.getMnemonic("angal.common.edit.btn.key")); + return jButtonEdit; + } + + private JButton getPrintButton() { + jButtonPrint = new JButton(MessageBundle.getMessage("angal.common.print.btn")); + jButtonPrint.setMnemonic(MessageBundle.getMnemonic("angal.common.print.btn.key")); + return jButtonPrint; + } + private JButton getDeleteButton() { + jButtonDelete = new JButton(MessageBundle.getMessage("angal.common.delete.btn")); + jButtonDelete.setMnemonic(MessageBundle.getMnemonic("angal.common.delete.btn.key")); + return jButtonDelete; + } + + private JButton getCloseButton() { + jButtonClose = new JButton(MessageBundle.getMessage("angal.common.cancel.btn")); + jButtonClose.setMnemonic(MessageBundle.getMnemonic("angal.common.cancel.btn.key")); + jButtonClose.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + return jButtonClose; + } + + private JScrollPane getScrollPaneInventory() { + if (scrollPaneInventory == null) { + scrollPaneInventory = new JScrollPane(); + scrollPaneInventory.setViewportView(getJTableInventory()); + } + return scrollPaneInventory; + } + + private JTable getJTableInventory() { + if (jTableInventory == null) { + jTableInventory = new JTable(); + jTableInventory.setFillsViewportHeight(true); + jTableInventory.setModel(new InventoryBrowsingModel()); + } + return jTableInventory; + } + + class InventoryBrowsingModel extends DefaultTableModel { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public InventoryBrowsingModel() { + } + + public InventoryBrowsingModel(int start_index, int page_size) { + } + + public Class< ? > getColumnClass(int c) { + if (c == 0) { + return String.class; + } else if (c == 1) { + return String.class; + } else if (c == 2) { + return String.class; + } else if (c == 3) { + return String.class; + } + return null; + } + + public String getColumnName(int c) { + return pColums[c]; + } + + public int getColumnCount() { + return pColums.length; + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + return false; + } + + } + + public String formatDateTime(GregorianCalendar time) { + SimpleDateFormat format = new SimpleDateFormat("dd/MM/yy"); //$NON-NLS-1$ + return format.format(time.getTime()); + } + + private void ajustWidth() { + for (int i = 0; i < pColumwidth.length; i++) { + jTableInventory.getColumnModel().getColumn(i).setMinWidth(pColumwidth[i]); + } + } + + private JComboBox getComboBox() { + if (stateComboBox == null) { + stateComboBox = new JComboBox(); + stateComboBox.addItem(""); + for (InventoryState.State currentState : InventoryState.State.values()) { + stateComboBox.addItem(MessageBundle.getMessage(currentState.getLabel())); + } + stateComboBox.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); + TOTAL_ROWS = inventoryModel.getRowCount(); + START_INDEX = 0; + previous.setEnabled(false); + if (TOTAL_ROWS <= PAGE_SIZE) { + next.setEnabled(false); + } else { + next.setEnabled(true); + } + jTableInventory.setModel(new InventoryBrowsingModel(START_INDEX, PAGE_SIZE)); + initialiseCombo(TOTAL_ROWS); + } + }); + } + return stateComboBox; + } + + private JLabel getStateLabel() { + if (stateLabel == null) { + stateLabel = new JLabel(MessageBundle.getMessage("angal.common.status.txt")); + stateLabel.setHorizontalAlignment(SwingConstants.RIGHT); + } + return stateLabel; + } + + public void initialiseCombo(int total_rows) { + int j = 0; + + pagesCombo.removeAllItems(); + for (int i = 0; i < total_rows / PAGE_SIZE; i++) { + j = i + 1; + pagesCombo.addItem(j); + } + if (j * PAGE_SIZE < total_rows) { + pagesCombo.addItem(j + 1); + under.setText("/" + (total_rows / PAGE_SIZE + 1 + " Pages")); + } else { + under.setText("/" + total_rows / PAGE_SIZE + " Pages"); + } + } +} diff --git a/src/main/java/org/isf/utils/jobjects/InventoryState.java b/src/main/java/org/isf/utils/jobjects/InventoryState.java new file mode 100644 index 0000000000..0493adeb97 --- /dev/null +++ b/src/main/java/org/isf/utils/jobjects/InventoryState.java @@ -0,0 +1,55 @@ +/* + * Open Hospital (www.open-hospital.org) + * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * + * Open Hospital is a free and open source software for healthcare data management. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * https://www.gnu.org/licenses/gpl-3.0-standalone.html + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.isf.utils.jobjects; + + +public class InventoryState { + public InventoryState(){} + public enum State + { + PROGRESS ("1", "angal.common.statecanceled"), + CANCELED ("2", "angal.common.stateinprogress"), + VALIDATE ("3", "angal.common.statevalidate"); + + String code; + String label; + + private State(String code, String label){ + this.code=code; + this.label=label; + } + + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + public String getLabel() { + return label; + } + public void setLabel(String label) { + this.label = label; + } + } +} + From cbf837a2891bde9dd43b44e11f9f3837af9f66fa Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Wed, 28 Feb 2024 10:25:33 +0100 Subject: [PATCH 002/147] remove comment --- .../java/org/isf/medicalinventory/gui/InventoryBrowser.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index b965998ed2..da947a9b75 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -282,7 +282,7 @@ private JLabel getJLabelTo() { if (jLabelTo == null) { jLabelTo = new JLabel(); jLabelTo.setHorizontalAlignment(SwingConstants.RIGHT); - jLabelTo.setText(MessageBundle.getMessage("angal.common.dateto.label")); //$NON-NLS-1$ + jLabelTo.setText(MessageBundle.getMessage("angal.common.dateto.label")); } return jLabelTo; } @@ -290,7 +290,7 @@ private JLabel getJLabelFrom() { if (jLabelFrom == null) { jLabelFrom = new JLabel(); jLabelFrom.setHorizontalAlignment(SwingConstants.RIGHT); - jLabelFrom.setText(MessageBundle.getMessage("angal.common.datefrom.label")); //$NON-NLS-1$ + jLabelFrom.setText(MessageBundle.getMessage("angal.common.datefrom.label")); } return jLabelFrom; } From 618bca29bbf90e291c3a26a2c74e45173277da8f Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Wed, 28 Feb 2024 10:29:59 +0100 Subject: [PATCH 003/147] =?UTF-8?q?use=20best=20pratique=20on=20the=20code?= =?UTF-8?q?=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../isf/medicalinventory/gui/InventoryBrowser.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index da947a9b75..12aa3c85ba 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -111,9 +111,7 @@ private void initComponents() { pagesCombo.setEditable(true); previous.setEnabled(false); next.setEnabled(false); - next.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent ae) { + next.addActionListener(actionEvent -> { if (!previous.isEnabled()) previous.setEnabled(true); START_INDEX += PAGE_SIZE; @@ -122,12 +120,9 @@ public void actionPerformed(ActionEvent ae) { next.setEnabled(false); } pagesCombo.setSelectedItem(START_INDEX / PAGE_SIZE + 1); - } }); - previous.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent ae) { + previous.addActionListener(actionEvent -> { if (!next.isEnabled()) next.setEnabled(true); START_INDEX -= PAGE_SIZE; @@ -136,7 +131,6 @@ public void actionPerformed(ActionEvent ae) { previous.setEnabled(false); } pagesCombo.setSelectedItem(START_INDEX / PAGE_SIZE + 1); - } }); pagesCombo.addItemListener(new ItemListener() { @@ -327,10 +321,8 @@ private JButton getDeleteButton() { private JButton getCloseButton() { jButtonClose = new JButton(MessageBundle.getMessage("angal.common.cancel.btn")); jButtonClose.setMnemonic(MessageBundle.getMnemonic("angal.common.cancel.btn.key")); - jButtonClose.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + jButtonClose.addActionListener(actionEvent -> { dispose(); - } }); return jButtonClose; } From c2304b3e02405c725138231372d1d05b95bd276e Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Wed, 28 Feb 2024 11:17:05 +0100 Subject: [PATCH 004/147] applied the suggestion --- bundle/language_en.properties | 11 +++++------ .../isf/medicalinventory/gui/InventoryBrowser.java | 6 ++++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 9041fc7603..da2e40168b 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -427,7 +427,7 @@ angal.common.qty.txt angal.common.quantity.txt = Quantity angal.common.reminder.txt = Reminder angal.common.result.txt = Result -angal.common.reference = Reference +angal.common.reference.label = Reference angal.common.save = Save angal.common.save.btn = Save angal.common.save.btn.key = S @@ -440,11 +440,6 @@ angal.common.selectsex.txt angal.common.sex.label = Sex: angal.common.sex.txt = Sex angal.common.sms.txt = SMS -angal.common.status.txt = Status -angal.common.statecanceled = Canceled -angal.common.stateinprogress = In progress -angal.common.statevalidate = Validate -angal.common.status.txt = Status angal.common.stockcard.btn = StockCard angal.common.stockcard.btn.key = K angal.common.stockledger.btn = Stock Ledger @@ -669,6 +664,10 @@ angal.hospital.visitduration.txt angal.hospital.visitendhour.txt = Visit end hour angal.hospital.visitstarthour.txt = Visit start hour angal.inventory.inventorybrowser.title = Inventory Browser +angal.inventory.status.txt = Status +angal.inventory.statuscanceled = Canceled +angal.inventory.statusdraft = Draft +angal.inventory.statusvalidated = Validated angal.lab.allnegative.txt = All negative. angal.lab.blood.txt = Blood angal.lab.cfs.txt = CFS diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 12aa3c85ba..a1456acb31 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -112,8 +112,9 @@ private void initComponents() { previous.setEnabled(false); next.setEnabled(false); next.addActionListener(actionEvent -> { - if (!previous.isEnabled()) + if (!previous.isEnabled()) { previous.setEnabled(true); + } START_INDEX += PAGE_SIZE; jTableInventory.setModel(new InventoryBrowsingModel(START_INDEX, PAGE_SIZE)); if ((START_INDEX + PAGE_SIZE) > TOTAL_ROWS) { @@ -123,8 +124,9 @@ private void initComponents() { }); previous.addActionListener(actionEvent -> { - if (!next.isEnabled()) + if (!next.isEnabled()) { next.setEnabled(true); + } START_INDEX -= PAGE_SIZE; jTableInventory.setModel(new InventoryBrowsingModel(START_INDEX, PAGE_SIZE)); if (START_INDEX < PAGE_SIZE) { From cab1b340ccc9befc60ff5aa9e0af97665f1e9e40 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Wed, 28 Feb 2024 14:02:15 +0100 Subject: [PATCH 005/147] update the enum and apply changes --- bundle/language_en.properties | 6 ++-- .../gui/InventoryBrowser.java | 12 +++---- ...ventoryState.java => InventoryStatus.java} | 31 ++----------------- 3 files changed, 11 insertions(+), 38 deletions(-) rename src/main/java/org/isf/utils/jobjects/{InventoryState.java => InventoryStatus.java} (62%) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index da2e40168b..abb25f03c2 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -665,9 +665,9 @@ angal.hospital.visitendhour.txt angal.hospital.visitstarthour.txt = Visit start hour angal.inventory.inventorybrowser.title = Inventory Browser angal.inventory.status.txt = Status -angal.inventory.statuscanceled = Canceled -angal.inventory.statusdraft = Draft -angal.inventory.statusvalidated = Validated +angal.inventory.canceled = Canceled +angal.inventory.draft = Draft +angal.inventory.validated = Validated angal.lab.allnegative.txt = All negative. angal.lab.blood.txt = Blood angal.lab.cfs.txt = CFS diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index a1456acb31..98d23d4f0c 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -49,7 +49,7 @@ import org.isf.generaldata.MessageBundle; import org.isf.utils.jobjects.GoodDateChooser; -import org.isf.utils.jobjects.InventoryState; +import org.isf.utils.jobjects.InventoryStatus; import org.isf.utils.jobjects.ModalJFrame; import org.isf.utils.time.TimeTools; @@ -72,9 +72,9 @@ public class InventoryBrowser extends ModalJFrame { private JButton jButtonView; private JScrollPane scrollPaneInventory; private JTable jTableInventory; - private String[] pColums = { MessageBundle.getMessage("angal.common.reference").toUpperCase(), + private String[] pColums = { MessageBundle.getMessage("angal.common.reference.label").toUpperCase(), MessageBundle.getMessage("angal.common.date.txt").toUpperCase(), - MessageBundle.getMessage("angal.common.status.txt").toUpperCase(), + MessageBundle.getMessage("angal.inventory.status.txt").toUpperCase(), MessageBundle.getMessage("angal.common.user.col").toUpperCase() }; private int[] pColumwidth = { 150, 150, 150, 200 }; private JComboBox stateComboBox; @@ -402,8 +402,8 @@ private JComboBox getComboBox() { if (stateComboBox == null) { stateComboBox = new JComboBox(); stateComboBox.addItem(""); - for (InventoryState.State currentState : InventoryState.State.values()) { - stateComboBox.addItem(MessageBundle.getMessage(currentState.getLabel())); + for (InventoryStatus currentState : InventoryStatus.values()) { + stateComboBox.addItem(MessageBundle.getMessage("angal.inventory."+currentState)); } stateComboBox.addActionListener(new ActionListener() { @@ -427,7 +427,7 @@ public void actionPerformed(ActionEvent e) { private JLabel getStateLabel() { if (stateLabel == null) { - stateLabel = new JLabel(MessageBundle.getMessage("angal.common.status.txt")); + stateLabel = new JLabel(MessageBundle.getMessage("angal.inventory.status.txt")); stateLabel.setHorizontalAlignment(SwingConstants.RIGHT); } return stateLabel; diff --git a/src/main/java/org/isf/utils/jobjects/InventoryState.java b/src/main/java/org/isf/utils/jobjects/InventoryStatus.java similarity index 62% rename from src/main/java/org/isf/utils/jobjects/InventoryState.java rename to src/main/java/org/isf/utils/jobjects/InventoryStatus.java index 0493adeb97..5e57911a5e 100644 --- a/src/main/java/org/isf/utils/jobjects/InventoryState.java +++ b/src/main/java/org/isf/utils/jobjects/InventoryStatus.java @@ -22,34 +22,7 @@ package org.isf.utils.jobjects; -public class InventoryState { - public InventoryState(){} - public enum State - { - PROGRESS ("1", "angal.common.statecanceled"), - CANCELED ("2", "angal.common.stateinprogress"), - VALIDATE ("3", "angal.common.statevalidate"); - - String code; - String label; - - private State(String code, String label){ - this.code=code; - this.label=label; - } - - public String getCode() { - return code; - } - public void setCode(String code) { - this.code = code; - } - public String getLabel() { - return label; - } - public void setLabel(String label) { - this.label = label; - } - } +public enum InventoryStatus { + draft, validated, canceled; } From 5cc63d4812c47b0bfbcfa7f4cba5b17179849286 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Thu, 7 Mar 2024 14:38:32 +0100 Subject: [PATCH 006/147] add inventoryEdit Browser --- bundle/language_en.properties | 7 +- .../gui/InventoryBrowser.java | 54 +- .../medicalinventory/gui/InventoryEdit.java | 789 ++++++++++++++++++ 3 files changed, 848 insertions(+), 2 deletions(-) create mode 100644 src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java diff --git a/bundle/language_en.properties b/bundle/language_en.properties index abb25f03c2..5e39ff31a6 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -663,11 +663,16 @@ angal.hospital.thevisitinghourvaluesmustbeintherange0to24.msg angal.hospital.visitduration.txt = Visit duration angal.hospital.visitendhour.txt = Visit end hour angal.hospital.visitstarthour.txt = Visit start hour +angal.inventory.allproduct.txt = All products angal.inventory.inventorybrowser.title = Inventory Browser angal.inventory.status.txt = Status -angal.inventory.canceled = Canceled +angal.inventory.specificproduct.txt = Specific product +angal.inventory.canceled = Canceled +angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg = Can not create another inventory with status draft. angal.inventory.draft = Draft angal.inventory.validated = Validated +angal.inventoryrow.realqty.col = Real Qty +angal.inventoryrow.theorticqty.col = Theoritic Qty angal.lab.allnegative.txt = All negative. angal.lab.blood.txt = Blood angal.lab.cfs.txt = CFS diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 98d23d4f0c..072b072680 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -21,6 +21,7 @@ */ package org.isf.medicalinventory.gui; +import java.awt.AWTEvent; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.GridBagConstraints; @@ -34,7 +35,9 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; +import java.util.ArrayList; import java.util.GregorianCalendar; +import java.util.List; import javax.swing.JButton; import javax.swing.JComboBox; @@ -48,12 +51,18 @@ import javax.swing.table.DefaultTableModel; import org.isf.generaldata.MessageBundle; +import org.isf.medicalinventory.gui.InventoryEdit.InventoryListener; +import org.isf.medicalinventory.manager.MedicalInventoryManager; +import org.isf.medicalinventory.model.MedicalInventory; +import org.isf.utils.exception.OHServiceException; +import org.isf.utils.exception.gui.OHServiceExceptionUtil; import org.isf.utils.jobjects.GoodDateChooser; import org.isf.utils.jobjects.InventoryStatus; +import org.isf.utils.jobjects.MessageDialog; import org.isf.utils.jobjects.ModalJFrame; import org.isf.utils.time.TimeTools; -public class InventoryBrowser extends ModalJFrame { +public class InventoryBrowser extends ModalJFrame implements InventoryListener { private GoodDateChooser jCalendarTo; private GoodDateChooser jCalendarFrom; @@ -294,6 +303,25 @@ private JLabel getJLabelFrom() { private JButton getNewButton() { jButtonNew = new JButton(MessageBundle.getMessage("angal.common.new.btn")); jButtonNew.setMnemonic(MessageBundle.getMnemonic("angal.common.new.btn.key")); + jButtonNew.addActionListener(actionEvent -> { + MedicalInventoryManager manager = new MedicalInventoryManager(); + String status = InventoryStatus.draft.toString(); + List medicalInventories = new ArrayList<>(); + try { + medicalInventories = manager.getMedicalInventoryByStatus(status); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + if (medicalInventories.size() == 0) { + InventoryEdit inventoryEdit = new InventoryEdit(); + InventoryEdit.addInventoryListener(InventoryBrowser.this); + inventoryEdit.showAsModal(InventoryBrowser.this); + } else { + MessageDialog.error(null, "angal.inventory.cannotcreateanotherinventorywithotherinprogress"); + return; + } + + }); return jButtonNew; } @@ -448,4 +476,28 @@ public void initialiseCombo(int total_rows) { under.setText("/" + total_rows / PAGE_SIZE + " Pages"); } } + + @Override + public void InventoryUpdated(AWTEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void InventoryInserted(AWTEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void InventoryValidated(AWTEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void InventoryCancelled(AWTEvent e) { + // TODO Auto-generated method stub + + } } diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java new file mode 100644 index 0000000000..796fa3c991 --- /dev/null +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -0,0 +1,789 @@ +/* + * Open Hospital (www.open-hospital.org) + * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * + * Open Hospital is a free and open source software for healthcare data management. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * https://www.gnu.org/licenses/gpl-3.0-standalone.html + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.isf.medicalinventory.gui; + +import static org.isf.utils.Constants.DATE_TIME_FORMATTER; + +import java.awt.AWTEvent; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.text.DecimalFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.EventListener; +import java.util.List; + +import javax.swing.ButtonGroup; +import javax.swing.DefaultCellEditor; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.border.EmptyBorder; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.event.EventListenerList; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; + +import org.isf.generaldata.MessageBundle; +import org.isf.medicalinventory.manager.MedicalInventoryManager; +import org.isf.medicalinventory.manager.MedicalInventoryRowManager; +import org.isf.medicalinventory.model.MedicalInventory; +import org.isf.medicalinventory.model.MedicalInventoryRow; +import org.isf.utils.jobjects.GoodDateChooser; +import org.isf.utils.jobjects.ModalJFrame; +import org.isf.utils.jobjects.TextPrompt; +import org.isf.utils.jobjects.TextPrompt.Show; +import org.isf.utils.time.TimeTools; + +public class InventoryEdit extends ModalJFrame { + + /** + * + */ + private static final long serialVersionUID = 1L; + + private static EventListenerList InventoryListeners = new EventListenerList(); + + //public interface InventoryListener extends EventListener { + public interface InventoryListener extends java.util.EventListener { + public void InventoryUpdated(AWTEvent e); + + public void InventoryInserted(AWTEvent e); + + public void InventoryValidated(AWTEvent e); + + public void InventoryCancelled(AWTEvent e); + } + + public static void addInventoryListener(InventoryListener l) { + InventoryListeners.add(InventoryListener.class, l); + } + + public static void removeInventoryListener(InventoryListener listener) { + InventoryListeners.remove(InventoryListener.class, listener); + } + + private void fireInventoryInserted() { + AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { + /** + * + */ + private static final long serialVersionUID = 1L; + }; + + EventListener[] listeners = InventoryListeners.getListeners(InventoryListener.class); + for (int i = 0; i < listeners.length; i++) + ((InventoryListener) listeners[i]).InventoryInserted(event); + } + + private void fireInventoryUpdated() { + AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { + /** + * + */ + private static final long serialVersionUID = 1L; + }; + + EventListener[] listeners = InventoryListeners.getListeners(InventoryListener.class); + for (int i = 0; i < listeners.length; i++) + ((InventoryListener) listeners[i]).InventoryUpdated(event); + } + + private void fireInventoryValidated() { + AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { + /** + * + */ + private static final long serialVersionUID = 1L; + }; + EventListener[] listeners = InventoryListeners.getListeners(InventoryListener.class); + for (int i = 0; i < listeners.length; i++) + ((InventoryListener) listeners[i]).InventoryValidated(event); + } + + private void fireInventoryCancelled() { + AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { + + /** + * + */ + private static final long serialVersionUID = 1L; + }; + + EventListener[] listeners = InventoryListeners.getListeners(InventoryListener.class); + for (int i = 0; i < listeners.length; i++) + ((InventoryListener) listeners[i]).InventoryCancelled(event); + } + + + private GoodDateChooser jCalendarTo; + private GoodDateChooser jCalendarInventory; + private LocalDateTime dateInventory = TimeTools.getServerDateTime(); + private LocalDateTime dateTo = TimeTools.getServerDateTime(); + private JLabel jLabelTo; + private JPanel panelHeader; + private JPanel panelFooter; + private JPanel panelContent; + private JButton closeButton; + private JScrollPane scrollPaneInventory; + private JTable jTableInventoryRow; + private List inventoryRowList; + private List inventoryRowSearchList; + private String[] pColums = { MessageBundle.getMessage("angal.common.code.txt"), + MessageBundle.getMessage("angal.inventoryrow.medical"), + MessageBundle.getMessage("angal.wardpharmacy.lotnumber.col"), + MessageBundle.getMessage("angal.medicalstock.duedate.col"), + MessageBundle.getMessage("angal.inventoryrow.theorticqty.col"), + MessageBundle.getMessage("angal.inventoryrow.realqty.col") }; + private int[] pColumwidth = { 100, 300, 100, 100, 100, 100 }; + private boolean[] columnEditable = { false, false, false, false, false, true }; + private boolean[] columnEditableView = { false, false, false, false, false, false }; + private MedicalInventory inventory = null; + private MedicalInventoryManager inventoryManager = new MedicalInventoryManager(); + private JRadioButton specificRadio; + private JRadioButton allRadio; + private JTextField searchTextField; + private JLabel dateInventoryLabel; + private JTextField codeTextField; + private String code = null; + private String mode = null; + private JLabel referenceLabel; + private JTextField referenceTextField; + private JTextField jTetFieldEditor; + private JLabel loaderLabel; + + private JButton moreData; + private int MAX_COUNT = 30; + private int CURRENT_INDEX = 0; + private boolean MORE_DATA = true; + + public InventoryEdit() { + initComponents(); + mode = "new"; + } + + public InventoryEdit(MedicalInventory inventory, String modee) { + this.inventory = inventory; + mode = modee; + initComponents(); + if (mode.equals("view")) { + columnEditable = columnEditableView; + } + + } + + private void initComponents() { + //setSize(new Dimension(850, 580)); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setMinimumSize(new Dimension(850, 580)); + setLocationRelativeTo(null); // center + setTitle(MessageBundle.getMessage("angal.inventory.newedittitle")); + + getContentPane().setLayout(new BorderLayout()); + + panelHeader = getPanelHeader(); + + getContentPane().add(panelHeader, BorderLayout.NORTH); + + panelContent = getPanelContent(); + getContentPane().add(panelContent, BorderLayout.CENTER); + + panelFooter = getPanelFooter(); + getContentPane().add(panelFooter, BorderLayout.SOUTH); + + ajustWidth(); + + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + // to free memory + if (inventoryRowList != null) + inventoryRowList.clear(); + if (inventoryRowSearchList != null) + inventoryRowSearchList.clear(); + dispose(); + } + }); + } + + private JPanel getPanelHeader() { + if (panelHeader == null) { + panelHeader = new JPanel(); + panelHeader.setBorder(new EmptyBorder(5, 0, 5, 0)); + GridBagLayout gbl_panelHeader = new GridBagLayout(); + gbl_panelHeader.columnWidths = new int[] { 159, 191, 192, 218, 51, 0 }; + gbl_panelHeader.rowHeights = new int[] { 30, 30, 0 }; + gbl_panelHeader.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; + gbl_panelHeader.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; + panelHeader.setLayout(gbl_panelHeader); + GridBagConstraints gbc_dateInventoryLabel = new GridBagConstraints(); + gbc_dateInventoryLabel.insets = new Insets(0, 0, 5, 5); + gbc_dateInventoryLabel.gridx = 0; + gbc_dateInventoryLabel.gridy = 0; + panelHeader.add(getDateInventoryLabel(), gbc_dateInventoryLabel); + + GridBagConstraints gbc_jCalendarInventory = new GridBagConstraints(); + gbc_jCalendarInventory.fill = GridBagConstraints.HORIZONTAL; + gbc_jCalendarInventory.insets = new Insets(0, 0, 5, 5); + gbc_jCalendarInventory.gridx = 1; + gbc_jCalendarInventory.gridy = 0; + panelHeader.add(getJCalendarFrom(), gbc_jCalendarInventory); + GridBagConstraints gbc_referenceLabel = new GridBagConstraints(); + gbc_referenceLabel.anchor = GridBagConstraints.EAST; + gbc_referenceLabel.insets = new Insets(0, 0, 5, 5); + gbc_referenceLabel.gridx = 2; + gbc_referenceLabel.gridy = 0; + panelHeader.add(getReferenceLabel(), gbc_referenceLabel); + GridBagConstraints gbc_referenceTextField = new GridBagConstraints(); + gbc_referenceTextField.fill = GridBagConstraints.HORIZONTAL; + gbc_referenceTextField.insets = new Insets(0, 0, 5, 5); + gbc_referenceTextField.gridx = 3; + gbc_referenceTextField.gridy = 0; + panelHeader.add(getReferenceTextField(), gbc_referenceTextField); + GridBagConstraints gbc_loaderLabel = new GridBagConstraints(); + gbc_loaderLabel.insets = new Insets(0, 0, 5, 0); + gbc_loaderLabel.gridx = 4; + gbc_loaderLabel.gridy = 0; + panelHeader.add(getLoaderLabel(), gbc_loaderLabel); + GridBagConstraints gbc_specificRadio = new GridBagConstraints(); + gbc_specificRadio.anchor = GridBagConstraints.EAST; + gbc_specificRadio.insets = new Insets(0, 0, 0, 5); + gbc_specificRadio.gridx = 0; + gbc_specificRadio.gridy = 1; + panelHeader.add(getSpecificRadio(), gbc_specificRadio); + GridBagConstraints gbc_codeTextField = new GridBagConstraints(); + gbc_codeTextField.insets = new Insets(0, 0, 0, 5); + gbc_codeTextField.fill = GridBagConstraints.HORIZONTAL; + gbc_codeTextField.gridx = 1; + gbc_codeTextField.gridy = 1; + panelHeader.add(getCodeTextField(), gbc_codeTextField); + GridBagConstraints gbc_allRadio = new GridBagConstraints(); + gbc_allRadio.anchor = GridBagConstraints.EAST; + gbc_allRadio.insets = new Insets(0, 0, 0, 5); + gbc_allRadio.gridx = 2; + gbc_allRadio.gridy = 1; + panelHeader.add(getAllRadio(), gbc_allRadio); + GridBagConstraints gbc_searchTextField = new GridBagConstraints(); + gbc_searchTextField.insets = new Insets(0, 0, 0, 5); + gbc_searchTextField.fill = GridBagConstraints.HORIZONTAL; + gbc_searchTextField.gridx = 3; + gbc_searchTextField.gridy = 1; + JPanel panSearchTextField = new JPanel(); + panSearchTextField.setLayout(new FlowLayout(FlowLayout.LEFT)); + panSearchTextField.add(getSearchTextField()); + panSearchTextField.add(getMoreDataBtn()); + panelHeader.add(panSearchTextField, gbc_searchTextField); + // panelHeader.add(getJLabelTo()); + // panelHeader.add(getJCalendarTo()); + ButtonGroup group = new ButtonGroup(); + group.add(specificRadio); + group.add(allRadio); + + } + return panelHeader; + } + + private JPanel getPanelContent() { + if (panelContent == null) { + panelContent = new JPanel(); + GridBagLayout gbl_panelContent = new GridBagLayout(); + gbl_panelContent.columnWidths = new int[] { 452, 0 }; + gbl_panelContent.rowHeights = new int[] { 402, 0 }; + gbl_panelContent.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; + gbl_panelContent.rowWeights = new double[] { 1.0, Double.MIN_VALUE }; + panelContent.setLayout(gbl_panelContent); + GridBagConstraints gbc_scrollPaneInventory = new GridBagConstraints(); + gbc_scrollPaneInventory.fill = GridBagConstraints.BOTH; + gbc_scrollPaneInventory.gridx = 0; + gbc_scrollPaneInventory.gridy = 0; + panelContent.add(getScrollPaneInventory(), gbc_scrollPaneInventory); + } + return panelContent; + } + + private JPanel getPanelFooter() { + if (panelFooter == null) { + panelFooter = new JPanel(); + panelFooter.add(getCloseButton()); + } + return panelFooter; + } + + private GoodDateChooser getJCalendarFrom() { + if (jCalendarInventory == null) { + dateInventory = LocalDateTime.now(); + jCalendarInventory = new GoodDateChooser(LocalDate.now()); + if (inventory != null) { + jCalendarInventory.setDate(inventory.getInventoryDate().toLocalDate()); + } + jCalendarInventory.addPropertyChangeListener("date", new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + } + }); + } + return jCalendarInventory; + } + + private JLabel getJLabelTo() { + if (jLabelTo == null) { + jLabelTo = new JLabel(); + jLabelTo.setText(MessageBundle.getMessage("angal.billbrowser.to")); //$NON-NLS-1$ + } + return jLabelTo; + } + + private JButton getCloseButton() { + closeButton = new JButton(MessageBundle.getMessage("angal.inventory.close")); + closeButton.setMnemonic(KeyEvent.VK_C); + closeButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + dispose(); + } + + }); + return closeButton; + } + + private JScrollPane getScrollPaneInventory() { + if (scrollPaneInventory == null) { + scrollPaneInventory = new JScrollPane(); + scrollPaneInventory.setViewportView(getJTableInventoryRow()); + } + return scrollPaneInventory; + } + + private JTable getJTableInventoryRow() { + if (jTableInventoryRow == null) { + jTableInventoryRow = new JTable(); + jTetFieldEditor = new JTextField(); + + jTableInventoryRow.setFillsViewportHeight(true); + jTableInventoryRow.setModel(new InventoryRowModel()); + + + jTableInventoryRow.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + + @Override + public void valueChanged(ListSelectionEvent e) { + // TODO Auto-generated method stub + if(!e.getValueIsAdjusting()){ + jTableInventoryRow.editCellAt(jTableInventoryRow.getSelectedRow(), 5); + jTetFieldEditor.selectAll(); + } + + } + }); + jTableInventoryRow.addKeyListener(new KeyListener() { + + @Override + public void keyTyped(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + } + + @Override + public void keyPressed(KeyEvent e) {} + }); + DefaultCellEditor cellEditor=new DefaultCellEditor(jTetFieldEditor); + jTableInventoryRow.setDefaultEditor(Integer.class, cellEditor); +// jTableInventoryRow.setCellEditor(new DefaultCellEditor(jTetFieldEditor)); + + } + + return jTableInventoryRow; + } + + class InventoryRowModel extends DefaultTableModel { + + private static final long serialVersionUID = 1L; + + public InventoryRowModel() { + // + MedicalInventoryRowManager manager = new MedicalInventoryRowManager(); + if(inventoryRowList != null) { + inventoryRowSearchList = new ArrayList(); + inventoryRowSearchList.addAll(inventoryRowList); + } + } + + public Class getColumnClass(int c) { + if (c == 0) { + return String.class; + } else if (c == 1) { + return String.class; + } else if (c == 2) { + return String.class; + } else if (c == 3) { + return String.class; + } else if (c == 4) { + return Integer.class; + } else if (c == 5) { + return Integer.class; + } + return null; + } + + public int getRowCount() { + // if (inventoryRowList == null) + // return 0; + // return inventoryRowList.size(); + if (inventoryRowSearchList == null) + return 0; + return inventoryRowSearchList.size(); + } + + public String getColumnName(int c) { + return pColums[c]; + } + + public int getColumnCount() { + return pColums.length; + } + + public Object getValueAt(int r, int c) { + // MedicalInventoryRow medInvtRow = inventoryRowList.get(r); + MedicalInventoryRow medInvtRow = inventoryRowSearchList.get(r); + + if (c == -1) { + return medInvtRow; + } else if (c == 0) { + return medInvtRow.getMedical() == null ? "" : medInvtRow.getMedical().getCode(); + } else if (c == 1) { + return medInvtRow.getMedical() == null ? "" : medInvtRow.getMedical().getDescription();// date + } else if (c == 2) { + return medInvtRow.getLot() == null ? "" : medInvtRow.getLot().getCode(); + } else if (c == 3) { + return medInvtRow.getLot() == null ? "" : medInvtRow.getLot().getDueDate().format(DATE_TIME_FORMATTER); + } else if (c == 4) { + Double dblVal = medInvtRow.getTheoreticQty(); + return dblVal.intValue(); + } else if (c == 5) { + Double dblValue = medInvtRow.getRealQty(); + return dblValue.intValue(); + } + return null; + } + + @Override + public void setValueAt(Object value, int r, int c) { + if(r < inventoryRowSearchList.size()){ + MedicalInventoryRow invRow = inventoryRowSearchList.get(r); + if (c == 5) { + Integer intValue=0; + try{ + intValue=Integer.parseInt(value.toString()); + } + catch (NumberFormatException e) { + intValue=0; + } + + invRow.setRealqty(intValue); + inventoryRowSearchList.set(r, invRow); + } + } + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return columnEditable[columnIndex]; + } + + } + + class DecimalFormatRenderer extends DefaultTableCellRenderer { + /** + * + */ + private static final long serialVersionUID = 1L; + private final DecimalFormat formatter = new DecimalFormat("#,##0.00"); //$NON-NLS-1$ + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, + int row, int column) { + // First format the cell value as required + Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + cell.addFocusListener(new java.awt.event.FocusListener() + { + + @Override + public void focusGained(java.awt.event.FocusEvent e) { + } + + @Override + public void focusLost(java.awt.event.FocusEvent e) { + } + }); + + value = formatter.format((Number) value); + if (!columnEditable[column]) { + cell.setBackground(Color.LIGHT_GRAY); + } + return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + } + } + + + + public MedicalInventory getInventory() { + return inventory; + } + + public void setInventory(MedicalInventory inventory) { + this.inventory = inventory; + } + + private JRadioButton getSpecificRadio() { + if (specificRadio == null) { + specificRadio = new JRadioButton(MessageBundle.getMessage("angal.inventory.specificproduct.txt")); + if (inventory != null) { + specificRadio.setSelected(false); + } else { + specificRadio.setSelected(true); + } + specificRadio.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (specificRadio.isSelected()) { + codeTextField.setEnabled(true); + searchTextField.setEnabled(false); + moreData.setEnabled(false); + searchTextField.setText(""); + codeTextField.setText(""); + if (inventoryRowList != null) { + inventoryRowList.clear(); + } + if (inventoryRowSearchList != null) { + inventoryRowSearchList.clear(); + } + jTableInventoryRow.updateUI(); + ajustWidth(); + } + } + }); + } + return specificRadio; + } + + private JRadioButton getAllRadio() { + if (allRadio == null) { + allRadio = new JRadioButton(MessageBundle.getMessage("angal.inventory.allproduct.txt")); + if (inventory != null) { + allRadio.setSelected(true); + } else { + allRadio.setSelected(false); + } + allRadio.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (allRadio.isSelected()) { + codeTextField.setEnabled(false); + searchTextField.setText(""); + codeTextField.setText(""); + searchTextField.setEnabled(true); + if(inventory == null) { + moreData.setEnabled(true); + } + if (inventoryRowList != null) { + inventoryRowList.clear(); + } + if (inventoryRowSearchList != null) { + inventoryRowSearchList.clear(); + } + jTableInventoryRow.setModel(new InventoryRowModel()); + jTableInventoryRow.updateUI(); + code = null; + ajustWidth(); + } + } + }); + } + return allRadio; + } + + private JTextField getSearchTextField() { + if (searchTextField == null) { + searchTextField = new JTextField(); + searchTextField.setColumns(16); + TextPrompt suggestion = new TextPrompt( + MessageBundle + .getMessage("angal.common.search.txt"), //$NON-NLS-1$ + searchTextField, Show.FOCUS_LOST); + { + suggestion.setFont(new Font("Tahoma", Font.PLAIN, 12)); //$NON-NLS-1$ + suggestion.setForeground(Color.GRAY); + suggestion.setHorizontalAlignment(JLabel.CENTER); + suggestion.changeAlpha(0.5f); + suggestion.changeStyle(Font.BOLD + Font.ITALIC); + } + searchTextField.getDocument().addDocumentListener(new DocumentListener() { + @Override + public void insertUpdate(DocumentEvent e) { + filterInventoryRow(); + ajustWidth(); + } + + @Override + public void removeUpdate(DocumentEvent e) { + filterInventoryRow(); + ajustWidth(); + } + + @Override + public void changedUpdate(DocumentEvent e) { + filterInventoryRow(); + ajustWidth(); + } + }); + searchTextField.setEnabled(false); + if (inventory != null) { + searchTextField.setEnabled(true); + } else { + searchTextField.setEnabled(false); + } + } + return searchTextField; + } + + private JLabel getDateInventoryLabel() { + if (dateInventoryLabel == null) { + dateInventoryLabel = new JLabel(MessageBundle.getMessage("angal.inventory.date")); + } + return dateInventoryLabel; + } + + private JButton getMoreDataBtn() { + if(moreData == null) { + moreData = new JButton("..."); + moreData.setPreferredSize(new Dimension(20, 20)); + moreData.setEnabled(false); + } + return moreData; + } + + private JTextField getCodeTextField() { + if (codeTextField == null) { + codeTextField = new JTextField(); + if (inventory != null) { + codeTextField.setEnabled(false); + } else { + codeTextField.setEnabled(true); + } + codeTextField.setColumns(10); + TextPrompt suggestion = new TextPrompt( + MessageBundle + .getMessage("angal.common.code.txt"), + codeTextField, Show.FOCUS_LOST); + { + suggestion.setFont(new Font("Tahoma", Font.PLAIN, 12)); + suggestion.setForeground(Color.GRAY); + suggestion.setHorizontalAlignment(JLabel.CENTER); + suggestion.changeAlpha(0.5f); + suggestion.changeStyle(Font.BOLD + Font.ITALIC); + } + } + return codeTextField; + } + + private void filterInventoryRow() { + String s = searchTextField.getText(); + s.trim(); + inventoryRowSearchList = new ArrayList(); + for (MedicalInventoryRow invRow : inventoryRowList) { + if (!s.equals("")) { + String name = invRow.getSearchString(); + if (name.contains(s.toLowerCase())) + inventoryRowSearchList.add(invRow); + } else { + inventoryRowSearchList.add(invRow); + } + } + jTableInventoryRow.updateUI(); + searchTextField.requestFocus(); + } + + private void ajustWidth() { + for (int i = 0; i < pColumwidth.length; i++) { + jTableInventoryRow.getColumnModel().getColumn(i).setMinWidth(pColumwidth[i]); + //jTableInventoryRow.getColumnModel().getColumn(i).setMaxWidth(pColumwidth[i]); + } + } + + public EventListenerList getInventoryListeners() { + return InventoryListeners; + } + + public void setInventoryListeners(EventListenerList inventoryListeners) { + InventoryListeners = inventoryListeners; + } + + private JLabel getReferenceLabel() { + if (referenceLabel == null) { + referenceLabel = new JLabel(MessageBundle.getMessage("angal.inventory.reference")); + } + return referenceLabel; + } + + private JTextField getReferenceTextField() { + if (referenceTextField == null) { + referenceTextField = new JTextField(); + referenceTextField.setColumns(10); + if (inventory != null && !mode.equals("new")) { + referenceTextField.setText(inventory.getInventoryReference()); + referenceTextField.setEnabled(false); + } + } + return referenceTextField; + } + + private JLabel getLoaderLabel() { + if (loaderLabel == null) { + ImageIcon icon = new ImageIcon("rsc/icons/oh_loader.GIF"); + loaderLabel = new JLabel(""); + loaderLabel.setIcon(icon); + loaderLabel.setVisible(false); + } + return loaderLabel; + } +} From 51286f99e00fa47ef729466121e090fba6f238a8 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Thu, 7 Mar 2024 17:40:52 +0100 Subject: [PATCH 007/147] add window to manage inventory --- bundle/language_en.properties | 9 +- rsc/icons/oh_loader.gif | Bin 0 -> 3208 bytes .../gui/InventoryBrowser.java | 5 +- .../medicalinventory/gui/InventoryEdit.java | 140 +++--------------- 4 files changed, 29 insertions(+), 125 deletions(-) create mode 100644 rsc/icons/oh_loader.gif diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 5e39ff31a6..f2e6283116 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -664,15 +664,16 @@ angal.hospital.visitduration.txt angal.hospital.visitendhour.txt = Visit end hour angal.hospital.visitstarthour.txt = Visit start hour angal.inventory.allproduct.txt = All products +angal.inventory.canceled = Canceled +angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg = Can not create another inventory with status draft. +angal.inventory.draft = Draft angal.inventory.inventorybrowser.title = Inventory Browser +angal.inventory.neweditinventory.title = Edit an inventory angal.inventory.status.txt = Status angal.inventory.specificproduct.txt = Specific product -angal.inventory.canceled = Canceled -angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg = Can not create another inventory with status draft. -angal.inventory.draft = Draft +angal.inventoryrow.theorticqty.col = Theoritic Qty angal.inventory.validated = Validated angal.inventoryrow.realqty.col = Real Qty -angal.inventoryrow.theorticqty.col = Theoritic Qty angal.lab.allnegative.txt = All negative. angal.lab.blood.txt = Blood angal.lab.cfs.txt = CFS diff --git a/rsc/icons/oh_loader.gif b/rsc/icons/oh_loader.gif new file mode 100644 index 0000000000000000000000000000000000000000..3288d1035d70bb86517e2c233f1a904e41f06b29 GIT binary patch literal 3208 zcmc(iX;4#H9>pJdFE7h`I{IF)0|5<6L}(j=N}5%L009EB2nYfyF)E0PvIqo$u!IC; z4PgyY5|S9AEh38G)(9eq4TbH7_UHg@yWrlIJ$6smIADL7s^P;_O;ykRc9soXl`UC*LwQJXkii*0rx|*7rI2=x7WaRkx_~XZqFJ8R3c=2Kg zf@aSAv8+BJ8+^hyay>(QR@t*blbKzsf0}bscEqRc5Hd3o(-N5RyW=zWB*zQw6Zh>* z2CROCDAbu#D`)S|J_o(lL9Yn3l*+8RdiRD_>iNz$#_IAzCna&Wl5 zSF_(rRCDD!wi#i8oAm&jYtn2_@VB%2-H*G%bN#|(6R6N?wM)3u`PiGzwuX7qmTgyF zpE)h0kuoxQ9?=kW7Y!=R@DmhU9)vwT*EZWzJ zrt+=2tqFts72yIp?|gvdLhs8Hfku^Z(){gmN%Y=K#P|%fkvgUj~HfIp3CuXqCtYGtJ#me+n+-LmP( z*XNuk%!aH8bIE@_Bj46>M*dSro|7<6vZ7WUHh5YQzN$>IJFqCb|CT!wj~R2C2%=q{ zpt8rzY$aw?W?=Ustv{jo?Ow@ZRkLe<)NItY>Cyhle*wR59dTdF6(@{5^ zAQBOB*hNtc3bkY-8{Cm$nFS@elbTtSqrt7MB{h_4y+~`!mVa}?c&N>&?P}GqdMuhQ z&@TD5Czd((DcG_Su~dKKV)Pj$-qi1WHM8_vc^O4?^!oY|tmK~i!{fjd&@_1E(T~r7 z_REZy&hMT^ySJB3W7l$4YhR`M(J7S5S~+4Q&3HPa)z%zPpisOp$^ zTEe99ig2$5_qFr!$;7A6CJ}PJmRhli>w?LC}Y`#HLGy6 zMU4EhL~dKCN5Ut;U2jd*83ShBNiu zcJB0l9>1Modc?-oM<R4?}3g}UJ%@K);kriq>)e*rh%hdqM)5Q)*+O8 zXm;SEbs@koiYS!9YXIclSg+5m_s~yrW#kKMdiRszg(gCP5HPmP7L)vCf8@fxUh6qY z@Z#TmkjzAZX{rwE+q|K~F2v5{_@vt%>yT_a#fF03SFt{0RXvDAiaY~K9CgS1O>frXgAjBCS}mEd4mIWZ$=ovd5| zR?GRdU}d6+Q`+JRW)|=v7$)XNkn3yE`!nAiSCvOB1jKT zG<1aK3s<0b0m==egTD#8i(Of=1pGDTOCho0XpIOMQ&P87cVKY1W=C6kIg z9cH=@a&zbm2+`|{(_?YC9fdm?1TY~-pwlBn?>=(~1pDKbco6jloP;0-cqRiwV1A_S zEyV0Dj8Pwy!nekzaN>{)7rgZ&_QLxK{~1yRe865^yx>}+a!ECd>#MMwddow z@CU{l+Rt$xuXuf}?ga{3IAr?Raql^c@a%sI0U5m}HvJ5O1#I%_MMPt#BH>OqUZ{-k zt>4Xzz=%jT*FVW(uYkWyx}9Gw$HdN*qU?Bit#ji(Wi7p-u|_8?h^%szIS^s^fNM}b zgGy>|=cbEufpguY5_6w~&ZLv=Bo06UF9EYIY;Er-1VK)SyF&!|J{axiE1z^(hXwVq zsFS=K-#zC}CcOs^8W{KAt+kK)jYDgDYbCXv{{rwsgqtIU3<910$CJi)s?? z_t8k{>7*0~4l~LLF7$WXT5OSq5QCTbP_l!SN|{R}3D&eWA8~0ltWh1IL+ZBX4rRSt zWF6Om3WDMu4xK^1(BF`2cL}rUCzhHAB`@j5&R-yk_l*t;mPGY|u2^o|myvcOdrg0W z%=lX;f^Vkqfp?u7*4qQq%A3Mpf!xspWBSKS@O%r*TSM}?dl(@*%{0Jm_8;(h{R__M Bt { - MedicalInventoryManager manager = new MedicalInventoryManager(); String status = InventoryStatus.draft.toString(); List medicalInventories = new ArrayList<>(); try { - medicalInventories = manager.getMedicalInventoryByStatus(status); + medicalInventories = medicalInventoryManager.getMedicalInventory(); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 796fa3c991..e0ee1743c2 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -73,6 +73,7 @@ import org.isf.medicalinventory.manager.MedicalInventoryRowManager; import org.isf.medicalinventory.model.MedicalInventory; import org.isf.medicalinventory.model.MedicalInventoryRow; +import org.isf.menu.manager.Context; import org.isf.utils.jobjects.GoodDateChooser; import org.isf.utils.jobjects.ModalJFrame; import org.isf.utils.jobjects.TextPrompt; @@ -87,9 +88,7 @@ public class InventoryEdit extends ModalJFrame { private static final long serialVersionUID = 1L; private static EventListenerList InventoryListeners = new EventListenerList(); - - //public interface InventoryListener extends EventListener { - public interface InventoryListener extends java.util.EventListener { + public interface InventoryListener extends EventListener { public void InventoryUpdated(AWTEvent e); public void InventoryInserted(AWTEvent e); @@ -103,67 +102,9 @@ public static void addInventoryListener(InventoryListener l) { InventoryListeners.add(InventoryListener.class, l); } - public static void removeInventoryListener(InventoryListener listener) { - InventoryListeners.remove(InventoryListener.class, listener); - } - - private void fireInventoryInserted() { - AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { - /** - * - */ - private static final long serialVersionUID = 1L; - }; - - EventListener[] listeners = InventoryListeners.getListeners(InventoryListener.class); - for (int i = 0; i < listeners.length; i++) - ((InventoryListener) listeners[i]).InventoryInserted(event); - } - - private void fireInventoryUpdated() { - AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { - /** - * - */ - private static final long serialVersionUID = 1L; - }; - - EventListener[] listeners = InventoryListeners.getListeners(InventoryListener.class); - for (int i = 0; i < listeners.length; i++) - ((InventoryListener) listeners[i]).InventoryUpdated(event); - } - - private void fireInventoryValidated() { - AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { - /** - * - */ - private static final long serialVersionUID = 1L; - }; - EventListener[] listeners = InventoryListeners.getListeners(InventoryListener.class); - for (int i = 0; i < listeners.length; i++) - ((InventoryListener) listeners[i]).InventoryValidated(event); - } - - private void fireInventoryCancelled() { - AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { - - /** - * - */ - private static final long serialVersionUID = 1L; - }; - - EventListener[] listeners = InventoryListeners.getListeners(InventoryListener.class); - for (int i = 0; i < listeners.length; i++) - ((InventoryListener) listeners[i]).InventoryCancelled(event); - } - - private GoodDateChooser jCalendarTo; private GoodDateChooser jCalendarInventory; private LocalDateTime dateInventory = TimeTools.getServerDateTime(); - private LocalDateTime dateTo = TimeTools.getServerDateTime(); private JLabel jLabelTo; private JPanel panelHeader; private JPanel panelFooter; @@ -174,7 +115,7 @@ private void fireInventoryCancelled() { private List inventoryRowList; private List inventoryRowSearchList; private String[] pColums = { MessageBundle.getMessage("angal.common.code.txt"), - MessageBundle.getMessage("angal.inventoryrow.medical"), + MessageBundle.getMessage("angal.medicalstockward.patient.drug.col"), MessageBundle.getMessage("angal.wardpharmacy.lotnumber.col"), MessageBundle.getMessage("angal.medicalstock.duedate.col"), MessageBundle.getMessage("angal.inventoryrow.theorticqty.col"), @@ -183,7 +124,6 @@ private void fireInventoryCancelled() { private boolean[] columnEditable = { false, false, false, false, false, true }; private boolean[] columnEditableView = { false, false, false, false, false, false }; private MedicalInventory inventory = null; - private MedicalInventoryManager inventoryManager = new MedicalInventoryManager(); private JRadioButton specificRadio; private JRadioButton allRadio; private JTextField searchTextField; @@ -200,6 +140,8 @@ private void fireInventoryCancelled() { private int MAX_COUNT = 30; private int CURRENT_INDEX = 0; private boolean MORE_DATA = true; + private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); + private MedicalInventoryRowManager medicalInventoryRowManager = Context.getApplicationContext().getBean(MedicalInventoryRowManager.class); public InventoryEdit() { initComponents(); @@ -217,11 +159,10 @@ public InventoryEdit(MedicalInventory inventory, String modee) { } private void initComponents() { - //setSize(new Dimension(850, 580)); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setMinimumSize(new Dimension(850, 580)); - setLocationRelativeTo(null); // center - setTitle(MessageBundle.getMessage("angal.inventory.newedittitle")); + setLocationRelativeTo(null); + setTitle(MessageBundle.getMessage("angal.inventory.neweditinventory.title")); getContentPane().setLayout(new BorderLayout()); @@ -239,7 +180,6 @@ private void initComponents() { addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { - // to free memory if (inventoryRowList != null) inventoryRowList.clear(); if (inventoryRowSearchList != null) @@ -311,17 +251,14 @@ private JPanel getPanelHeader() { gbc_searchTextField.fill = GridBagConstraints.HORIZONTAL; gbc_searchTextField.gridx = 3; gbc_searchTextField.gridy = 1; - JPanel panSearchTextField = new JPanel(); - panSearchTextField.setLayout(new FlowLayout(FlowLayout.LEFT)); - panSearchTextField.add(getSearchTextField()); - panSearchTextField.add(getMoreDataBtn()); + JPanel panSearchTextField = new JPanel(); + panSearchTextField.setLayout(new FlowLayout(FlowLayout.LEFT)); + panSearchTextField.add(getSearchTextField()); + panSearchTextField.add(getMoreDataBtn()); panelHeader.add(panSearchTextField, gbc_searchTextField); - // panelHeader.add(getJLabelTo()); - // panelHeader.add(getJCalendarTo()); ButtonGroup group = new ButtonGroup(); group.add(specificRadio); group.add(allRadio); - } return panelHeader; } @@ -370,14 +307,14 @@ public void propertyChange(PropertyChangeEvent evt) { private JLabel getJLabelTo() { if (jLabelTo == null) { jLabelTo = new JLabel(); - jLabelTo.setText(MessageBundle.getMessage("angal.billbrowser.to")); //$NON-NLS-1$ + jLabelTo.setText(MessageBundle.getMessage("angal.common.to.txt")); //$NON-NLS-1$ } return jLabelTo; } private JButton getCloseButton() { - closeButton = new JButton(MessageBundle.getMessage("angal.inventory.close")); - closeButton.setMnemonic(KeyEvent.VK_C); + closeButton = new JButton(MessageBundle.getMessage("angal.common.close.btn")); + closeButton.setMnemonic(MessageBundle.getMnemonic("angal.common.close.btn.key")); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); @@ -399,16 +336,12 @@ private JTable getJTableInventoryRow() { if (jTableInventoryRow == null) { jTableInventoryRow = new JTable(); jTetFieldEditor = new JTextField(); - jTableInventoryRow.setFillsViewportHeight(true); jTableInventoryRow.setModel(new InventoryRowModel()); - - jTableInventoryRow.getSelectionModel().addListSelectionListener(new ListSelectionListener() { - + @Override public void valueChanged(ListSelectionEvent e) { - // TODO Auto-generated method stub if(!e.getValueIsAdjusting()){ jTableInventoryRow.editCellAt(jTableInventoryRow.getSelectedRow(), 5); jTetFieldEditor.selectAll(); @@ -431,10 +364,7 @@ public void keyPressed(KeyEvent e) {} }); DefaultCellEditor cellEditor=new DefaultCellEditor(jTetFieldEditor); jTableInventoryRow.setDefaultEditor(Integer.class, cellEditor); -// jTableInventoryRow.setCellEditor(new DefaultCellEditor(jTetFieldEditor)); - } - return jTableInventoryRow; } @@ -443,8 +373,6 @@ class InventoryRowModel extends DefaultTableModel { private static final long serialVersionUID = 1L; public InventoryRowModel() { - // - MedicalInventoryRowManager manager = new MedicalInventoryRowManager(); if(inventoryRowList != null) { inventoryRowSearchList = new ArrayList(); inventoryRowSearchList.addAll(inventoryRowList); @@ -469,9 +397,6 @@ public Class getColumnClass(int c) { } public int getRowCount() { - // if (inventoryRowList == null) - // return 0; - // return inventoryRowList.size(); if (inventoryRowSearchList == null) return 0; return inventoryRowSearchList.size(); @@ -486,15 +411,13 @@ public int getColumnCount() { } public Object getValueAt(int r, int c) { - // MedicalInventoryRow medInvtRow = inventoryRowList.get(r); MedicalInventoryRow medInvtRow = inventoryRowSearchList.get(r); - if (c == -1) { return medInvtRow; } else if (c == 0) { return medInvtRow.getMedical() == null ? "" : medInvtRow.getMedical().getCode(); } else if (c == 1) { - return medInvtRow.getMedical() == null ? "" : medInvtRow.getMedical().getDescription();// date + return medInvtRow.getMedical() == null ? "" : medInvtRow.getMedical().getDescription(); } else if (c == 2) { return medInvtRow.getLot() == null ? "" : medInvtRow.getLot().getCode(); } else if (c == 3) { @@ -544,7 +467,6 @@ class DecimalFormatRenderer extends DefaultTableCellRenderer { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - // First format the cell value as required Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); cell.addFocusListener(new java.awt.event.FocusListener() { @@ -648,10 +570,10 @@ private JTextField getSearchTextField() { searchTextField.setColumns(16); TextPrompt suggestion = new TextPrompt( MessageBundle - .getMessage("angal.common.search.txt"), //$NON-NLS-1$ + .getMessage("angal.common.search.txt"), searchTextField, Show.FOCUS_LOST); { - suggestion.setFont(new Font("Tahoma", Font.PLAIN, 12)); //$NON-NLS-1$ + suggestion.setFont(new Font("Tahoma", Font.PLAIN, 12)); suggestion.setForeground(Color.GRAY); suggestion.setHorizontalAlignment(JLabel.CENTER); suggestion.changeAlpha(0.5f); @@ -660,19 +582,16 @@ private JTextField getSearchTextField() { searchTextField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { - filterInventoryRow(); ajustWidth(); } @Override public void removeUpdate(DocumentEvent e) { - filterInventoryRow(); ajustWidth(); } @Override public void changedUpdate(DocumentEvent e) { - filterInventoryRow(); ajustWidth(); } }); @@ -688,7 +607,7 @@ public void changedUpdate(DocumentEvent e) { private JLabel getDateInventoryLabel() { if (dateInventoryLabel == null) { - dateInventoryLabel = new JLabel(MessageBundle.getMessage("angal.inventory.date")); + dateInventoryLabel = new JLabel(MessageBundle.getMessage("angal.common.date.txt")); } return dateInventoryLabel; } @@ -726,27 +645,10 @@ private JTextField getCodeTextField() { return codeTextField; } - private void filterInventoryRow() { - String s = searchTextField.getText(); - s.trim(); - inventoryRowSearchList = new ArrayList(); - for (MedicalInventoryRow invRow : inventoryRowList) { - if (!s.equals("")) { - String name = invRow.getSearchString(); - if (name.contains(s.toLowerCase())) - inventoryRowSearchList.add(invRow); - } else { - inventoryRowSearchList.add(invRow); - } - } - jTableInventoryRow.updateUI(); - searchTextField.requestFocus(); - } - + private void ajustWidth() { for (int i = 0; i < pColumwidth.length; i++) { jTableInventoryRow.getColumnModel().getColumn(i).setMinWidth(pColumwidth[i]); - //jTableInventoryRow.getColumnModel().getColumn(i).setMaxWidth(pColumwidth[i]); } } @@ -760,7 +662,7 @@ public void setInventoryListeners(EventListenerList inventoryListeners) { private JLabel getReferenceLabel() { if (referenceLabel == null) { - referenceLabel = new JLabel(MessageBundle.getMessage("angal.inventory.reference")); + referenceLabel = new JLabel(MessageBundle.getMessage("angal.common.reference.label")); } return referenceLabel; } From dfa13b7d8fe79adf323f8ce330b7093b01cc392e Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Thu, 7 Mar 2024 17:47:33 +0100 Subject: [PATCH 008/147] remove comment --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index e0ee1743c2..ec6038abd6 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -374,7 +374,7 @@ class InventoryRowModel extends DefaultTableModel { public InventoryRowModel() { if(inventoryRowList != null) { - inventoryRowSearchList = new ArrayList(); + inventoryRowSearchList = new ArrayList<>(); inventoryRowSearchList.addAll(inventoryRowList); } } @@ -463,7 +463,7 @@ class DecimalFormatRenderer extends DefaultTableCellRenderer { * */ private static final long serialVersionUID = 1L; - private final DecimalFormat formatter = new DecimalFormat("#,##0.00"); //$NON-NLS-1$ + private final DecimalFormat formatter = new DecimalFormat("#,##0.00"); public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { From f694ed5d15ec31a6dc1c5d200cd711456c98270f Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Thu, 7 Mar 2024 18:03:39 +0100 Subject: [PATCH 009/147] fix error --- .../java/org/isf/medicalinventory/gui/InventoryBrowser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 504b600e56..166573a415 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -309,7 +309,7 @@ private JButton getNewButton() { String status = InventoryStatus.draft.toString(); List medicalInventories = new ArrayList<>(); try { - medicalInventories = medicalInventoryManager.getMedicalInventory(); + medicalInventories = medicalInventoryManager.getMedicalInventoryByStatus(status); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } From c9873abd7157802a1b9b21b0d2dc966fbe12a05c Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Mon, 11 Mar 2024 17:53:59 +0100 Subject: [PATCH 010/147] add button and action to save inventory --- bundle/language_en.properties | 11 + .../medicalinventory/gui/InventoryEdit.java | 298 +++++++++++++++++- .../org/isf/utils/jobjects/InventoryType.java | 27 ++ 3 files changed, 329 insertions(+), 7 deletions(-) create mode 100644 src/main/java/org/isf/utils/jobjects/InventoryType.java diff --git a/bundle/language_en.properties b/bundle/language_en.properties index f2e6283116..91d8be23c5 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -668,11 +668,22 @@ angal.inventory.canceled angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg = Can not create another inventory with status draft. angal.inventory.draft = Draft angal.inventory.inventorybrowser.title = Inventory Browser +angal.inventory.mustenterareference.msg = You must enter a reference. angal.inventory.neweditinventory.title = Edit an inventory +angal.inventory.notdateinfuture.msg = Date in future is not allowed ! +angal.inventory.noproduct.msg = Product not found! +angal.inventory.referencealreadyused.msg = Reference is already used. +angal.inventoryoperation.save.succes.msg = Inventory saved. +angal.inventoryrowoperation.save.error.msg = Error during some products's recording +angal.inventoryoperation.save.error.msg = Inventory not saved angal.inventory.status.txt = Status angal.inventory.specificproduct.txt = Specific product angal.inventoryrow.theorticqty.col = Theoritic Qty +angal.inventoryrowoperation.update.error.msg = Inventory not updated +angal.inventoryoperation.update.succes.msg = Inventory updated angal.inventory.validated = Validated +angal.inventory.validate.btn = Validate +angal.inventory.validate.btn.key = V angal.inventoryrow.realqty.col = Real Qty angal.lab.allnegative.txt = All negative. angal.lab.blood.txt = Blood diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index ec6038abd6..828d1e3c80 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -46,6 +46,8 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.EventListener; +import java.util.GregorianCalendar; +import java.util.Iterator; import java.util.List; import javax.swing.ButtonGroup; @@ -54,6 +56,7 @@ import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JScrollPane; @@ -73,8 +76,20 @@ import org.isf.medicalinventory.manager.MedicalInventoryRowManager; import org.isf.medicalinventory.model.MedicalInventory; import org.isf.medicalinventory.model.MedicalInventoryRow; +import org.isf.medicals.manager.MedicalBrowsingManager; +import org.isf.medicals.model.Medical; +import org.isf.medicalstock.manager.MovStockInsertingManager; +import org.isf.medicalstock.model.Lot; +import org.isf.medicalstock.model.Movement; +import org.isf.medstockmovtype.model.MovementType; import org.isf.menu.manager.Context; +import org.isf.menu.manager.UserBrowsingManager; +import org.isf.utils.exception.OHServiceException; +import org.isf.utils.exception.gui.OHServiceExceptionUtil; import org.isf.utils.jobjects.GoodDateChooser; +import org.isf.utils.jobjects.InventoryStatus; +import org.isf.utils.jobjects.InventoryType; +import org.isf.utils.jobjects.MessageDialog; import org.isf.utils.jobjects.ModalJFrame; import org.isf.utils.jobjects.TextPrompt; import org.isf.utils.jobjects.TextPrompt.Show; @@ -101,6 +116,62 @@ public interface InventoryListener extends EventListener { public static void addInventoryListener(InventoryListener l) { InventoryListeners.add(InventoryListener.class, l); } + + public static void removeInventoryListener(InventoryListener listener) { + InventoryListeners.remove(InventoryListener.class, listener); + } + + private void fireInventoryInserted() { + AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { + /** + * + */ + private static final long serialVersionUID = 1L; + }; + + EventListener[] listeners = InventoryListeners.getListeners(InventoryListener.class); + for (int i = 0; i < listeners.length; i++) + ((InventoryListener) listeners[i]).InventoryInserted(event); + } + + private void fireInventoryUpdated() { + AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { + /** + * + */ + private static final long serialVersionUID = 1L; + }; + + EventListener[] listeners = InventoryListeners.getListeners(InventoryListener.class); + for (int i = 0; i < listeners.length; i++) + ((InventoryListener) listeners[i]).InventoryUpdated(event); + } + + private void fireInventoryValidated() { + AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { + /** + * + */ + private static final long serialVersionUID = 1L; + }; + EventListener[] listeners = InventoryListeners.getListeners(InventoryListener.class); + for (int i = 0; i < listeners.length; i++) + ((InventoryListener) listeners[i]).InventoryValidated(event); + } + + private void fireInventoryCancelled() { + AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { + + /** + * + */ + private static final long serialVersionUID = 1L; + }; + + EventListener[] listeners = InventoryListeners.getListeners(InventoryListener.class); + for (int i = 0; i < listeners.length; i++) + ((InventoryListener) listeners[i]).InventoryCancelled(event); + } private GoodDateChooser jCalendarTo; private GoodDateChooser jCalendarInventory; @@ -110,6 +181,8 @@ public static void addInventoryListener(InventoryListener l) { private JPanel panelFooter; private JPanel panelContent; private JButton closeButton; + private JButton saveButton; + private JButton validateButton; private JScrollPane scrollPaneInventory; private JTable jTableInventoryRow; private List inventoryRowList; @@ -284,6 +357,7 @@ private JPanel getPanelContent() { private JPanel getPanelFooter() { if (panelFooter == null) { panelFooter = new JPanel(); + panelFooter.add(getNewButton()); panelFooter.add(getCloseButton()); } return panelFooter; @@ -312,14 +386,186 @@ private JLabel getJLabelTo() { return jLabelTo; } + private JButton getNewButton() { + saveButton = new JButton(MessageBundle.getMessage("angal.common.save.btn")); + saveButton.setMnemonic(MessageBundle.getMnemonic("angal.common.save.btn.key")); + saveButton.addActionListener(actionEvent -> { + String State = InventoryStatus.draft.toString(); + String user = UserBrowsingManager.getCurrentUser(); + int checkResults = 0; + if (inventoryRowSearchList == null || inventoryRowSearchList.size() < 1) { + MessageDialog.error(null, "angal.inventory.noproduct.msg"); + return; + } + LocalDateTime now = LocalDateTime.now(); + if (dateInventory.isAfter(now)) { + MessageDialog.error(null, "angal.inventory.notdateinfuture.msg"); + return; + } + + if ((inventory == null) && (mode.equals("new"))) { + String reference = referenceTextField.getText().trim(); + if (reference.equals("")) { + MessageDialog.error(null, "angal.inventory.mustenterareference.msg"); + return; + } + if (medicalInventoryManager.referenceExists(reference)) { + MessageDialog.error(null, "angal.inventory.referencealreadyused.msg"); + return; + } + inventory = new MedicalInventory(); + inventory.setInventoryReference(reference); + inventory.setInventoryDate(dateInventory); + inventory.setStatus(State); + inventory.setUser(user); + inventory.setInventoryType(InventoryType.principal.toString()); + inventory.setWard(""); + MedicalInventory meInventory ; + try { + meInventory = medicalInventoryManager.newMedicalInventory(inventory); + if (meInventory != null) { + inventory.setId(meInventory.getId()); + MedicalInventoryRow currentInventoryRow ; + Double totalCost = 0.0; + for (Iterator iterator = inventoryRowSearchList.iterator(); iterator + .hasNext();) { + MedicalInventoryRow medicalInventoryRow = (MedicalInventoryRow) iterator.next(); + medicalInventoryRow.setInventory(inventory); + currentInventoryRow = medicalInventoryRowManager + .newMedicalInventoryRow(medicalInventoryRow); + if (currentInventoryRow == null) { + checkResults++; + } else { + medicalInventoryRow.setId(currentInventoryRow.getId()); + totalCost += medicalInventoryRow.getLot().getCost().doubleValue(); + } + } + + if (checkResults == 0) { + // enable validation + mode = "update"; + validateButton.setEnabled(true); + fireInventoryInserted(); + } else { + MessageDialog.error(null, "angal.inventoryrowoperation.save.error.msg"); + } + } else { + MessageDialog.error(null, "angal.inventoryoperation.save.error.msg"); + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } else if ((inventory != null) && (mode.equals("update"))) { + checkResults = 0; + boolean toUpdate = false; + MedicalInventory result = null; + if (!inventory.getInventoryDate().equals(dateInventory)) { + inventory.setInventoryDate(dateInventory); + toUpdate = true; + } + if (!inventory.getUser().equals(user)) { + inventory.setUser(user); + toUpdate = true; + } + if (toUpdate) { + try { + result = medicalInventoryManager.updateMedicalInventory(inventory); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + if (result != null) { + Double totalCost = 0.0; + try { + for (Iterator iterator = inventoryRowSearchList.iterator(); iterator + .hasNext();) { + MedicalInventoryRow medicalInventoryRow = (MedicalInventoryRow) iterator.next(); + MedicalInventoryRow updateMedicalInvRow = medicalInventoryRowManager.updateMedicalInventoryRow(medicalInventoryRow); + if (updateMedicalInvRow != null) { + checkResults++; + } + + totalCost += medicalInventoryRow.getLot().getCost().doubleValue(); + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + if (checkResults == 0) { + DecimalFormat formatter = new DecimalFormat("#,##0.00"); + MessageDialog.error(null, "angal.inventoryoperation.update.succes.msg"); + validateButton.setEnabled(true); + fireInventoryUpdated(); + } else { + MessageDialog.error(null, "angal.inventoryrowoperation.update.error.msg"); + } + } else { + MessageDialog.error(null, "angal.inventoryrowoperation.update.error.msg"); + } + } + }); + return saveButton; + } + + private JButton getValidateButton() { + validateButton = new JButton(MessageBundle.getMessage("angal.inventory.validate.btn")); + validateButton.setMnemonic(MessageBundle.getMnemonic("angal.inventory.validate.btn.key")); + if (inventory == null) { + validateButton.setEnabled(false); + } + /* + * validateButton.addActionListener(actionEvent -> { if (inventory == null) { JOptionPane.showMessageDialog(InventoryEdit.this, + * MessageBundle.getMessage("angal.inventorymustsavebeforevalidate"), MessageBundle.getMessage("angal.inventoryoperation.title"), + * JOptionPane.INFORMATION_MESSAGE); return; } if (inventory != null) { if (inventory.getState().equals(InventoryState.State.VALIDATE.getCode())) { + * JOptionPane.showMessageDialog(InventoryEdit.this, MessageBundle.getMessage("angal.inventoryalreadyvalidate"), + * MessageBundle.getMessage("angal.inventoryoperation.title"), JOptionPane.INFORMATION_MESSAGE); return; } } MovStockInsertingManager movManager = new + * MovStockInsertingManager(); MedicalInventoryManager invManager = new MedicalInventoryManager(); Medical medical = null; Double ajustQty = 0.0; + * + * int checkError = 0; String errorList = ""; Movement movement = null; MovementType dischargeType = new + * MedicaldsrstockmovTypeBrowserManager().getMovementType("discharge"); GregorianCalendar today = new GregorianCalendar(); String referenceNumber = ""; + * Lot currentLot = null; // ArrayList movList = new ArrayList(); for (Iterator iterator = + * inventoryRowSearchList.iterator(); iterator.hasNext();) { MedicalInventoryRow medicalInventoryRow = (MedicalInventoryRow) iterator.next(); if + * (medicalInventoryRow.getTheoreticqty() > medicalInventoryRow.getRealqty()) { ajustQty = medicalInventoryRow.getTheoreticqty() - + * medicalInventoryRow.getRealqty(); medical = medicalInventoryRow.getMedical(); currentLot = new Lot("", null, null); if (medicalInventoryRow.getLot() + * != null && !medicalInventoryRow.getLot().getCode().equals("")) { currentLot = medicalInventoryRow.getLot(); } referenceNumber = + * inventory.getInventoryReference(); movement = new Movement(medical, dischargeType, null, currentLot, today, ajustQty.intValue(), null, + * referenceNumber); + * + * if (!movManager.prepareDishargingMovementInventory(movement)) { checkError++; errorList = errorList + medical.getDescription() + " Lot: " + + * currentLot.getCode() + "\n"; } } else if (medicalInventoryRow.getTheoreticqty() < medicalInventoryRow.getRealqty()) { ajustQty = + * medicalInventoryRow.getRealqty() - medicalInventoryRow.getTheoreticqty(); medical = medicalInventoryRow.getMedical(); currentLot = new Lot("", null, + * null); if (medicalInventoryRow.getLot() != null && !medicalInventoryRow.getLot().getCode().equals("")) { currentLot = medicalInventoryRow.getLot(); } + * referenceNumber = inventory.getInventoryReference(); movement = new Movement(medical, dischargeType, null, currentLot, today, -(ajustQty.intValue()), + * null, referenceNumber); + * + * if (!movManager.prepareDishargingMovementInventory(movement)) { checkError++; errorList = errorList + medical.getDescription() + " Lot: " + + * currentLot.getCode() + "\n"; } } + * + * // If new lot has been inserted, create charge movement with theorical qty if (medicalInventoryRow.isNewLot() && + * !medicalInventoryRow.getLot().getCode().equals("")) { movement = new Movement(medicalInventoryRow.getMedical(), dischargeType, null, + * medicalInventoryRow.getLot(), today, -(medicalInventoryRow.getTheoreticqty()), null, inventory.getInventoryReference()); + * + * if (!movManager.prepareNewLotMovementInventory(movement)) { checkError++; errorList = errorList + medical.getDescription() + " Lot: " + + * currentLot.getCode() + "\n"; } } + * + * } // change state of inventory if (checkError == 0) { inventory.setState(InventoryState.State.VALIDATE.getCode()); if + * (invManager.updateMedicalInventory(inventory)) { JOptionPane.showMessageDialog(InventoryEdit.this, + * MessageBundle.getMessage("angal.inventoryvalidate.succes"), MessageBundle.getMessage("angal.inventoryoperation.title"), + * JOptionPane.INFORMATION_MESSAGE); fireInventoryValidated(); columnEditable = columnEditableView; jTableInventoryRow.updateUI(); + * saveButton.setEnabled(false); } else { JOptionPane.showMessageDialog(InventoryEdit.this, MessageBundle.getMessage("angal.inventoryvalidate.error"), + * MessageBundle.getMessage("angal.inventoryoperation.title"), JOptionPane.INFORMATION_MESSAGE); } } else { + * JOptionPane.showMessageDialog(InventoryEdit.this, MessageBundle.getMessage("angal.inventoryvalidate.ajustinventoryerror") + "\n" + errorList, + * MessageBundle.getMessage("angal.inventoryoperation.title"), JOptionPane.INFORMATION_MESSAGE); } + * + * }); + */ + return validateButton; + } + private JButton getCloseButton() { closeButton = new JButton(MessageBundle.getMessage("angal.common.close.btn")); closeButton.setMnemonic(MessageBundle.getMnemonic("angal.common.close.btn.key")); - closeButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + closeButton.addActionListener(actionEvent -> { dispose(); - } - }); return closeButton; } @@ -537,8 +783,7 @@ private JRadioButton getAllRadio() { } else { allRadio.setSelected(false); } - allRadio.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + allRadio.addActionListener(actionEvent -> { if (allRadio.isSelected()) { codeTextField.setEnabled(false); searchTextField.setText(""); @@ -558,7 +803,6 @@ public void actionPerformed(ActionEvent e) { code = null; ajustWidth(); } - } }); } return allRadio; @@ -618,6 +862,46 @@ private JButton getMoreDataBtn() { moreData.setPreferredSize(new Dimension(20, 20)); moreData.setEnabled(false); } + moreData.addActionListener(actionEvent -> { + if (MORE_DATA && inventory == null) { + List medicalList = new ArrayList(); + MedicalBrowsingManager medicalManager = new MedicalBrowsingManager(); + CURRENT_INDEX += MAX_COUNT; + try { + medicalList = medicalManager.getMedicals(); + } catch (OHServiceException e) { + e.printStackTrace(); + } + MovStockInsertingManager movBrowser = new MovStockInsertingManager(); + ArrayList lots; + MedicalInventoryRow inventoryRowTemp; + double quantityOutsideLot; + double cost; + Iterator medicalIterator = medicalList.iterator(); + Medical medical; + /* while (medicalIterator.hasNext()) { + medical = medicalIterator.next(); + lots = movBrowser.getLotByMedical(medical); + quantityOutsideLot = medical.getTotalQuantity() - getQtyInALot(lots); + if ((lots.size() == 0) || (quantityOutsideLot != 0)) { + inventoryRowTemp = new MedicalInventoryRow(0, quantityOutsideLot, quantityOutsideLot, null, + medical, new Lot("", null, null), 0.0, 0.0, false); + inventoryRowList.add(inventoryRowTemp); + } + for (Lot lot : lots) { + cost = lot.getCost() * lot.getQuantity(); + inventoryRowTemp = new MedicalInventoryRow(0, lot.getQuantity(), lot.getQuantity(), null, + medical, lot, lot.getCost(), cost, false); + inventoryRowList.add(inventoryRowTemp); + } + }*/ + inventoryRowSearchList = new ArrayList(); + inventoryRowSearchList.addAll(inventoryRowList); + if (medicalList.size() > 0) { + jTableInventoryRow.updateUI(); + } + } + }); return moreData; } diff --git a/src/main/java/org/isf/utils/jobjects/InventoryType.java b/src/main/java/org/isf/utils/jobjects/InventoryType.java new file mode 100644 index 0000000000..a2f7e992cb --- /dev/null +++ b/src/main/java/org/isf/utils/jobjects/InventoryType.java @@ -0,0 +1,27 @@ +/* + * Open Hospital (www.open-hospital.org) + * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * + * Open Hospital is a free and open source software for healthcare data management. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * https://www.gnu.org/licenses/gpl-3.0-standalone.html + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.isf.utils.jobjects; + + +public enum InventoryType { + principal, ward +} From 6fcd4fa91f6ce6eaf4c6f3f814e4ed173193de45 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Mon, 11 Mar 2024 17:58:17 +0100 Subject: [PATCH 011/147] Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java Co-authored-by: David B Malkovsky --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index ec6038abd6..e360191ce5 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -342,7 +342,7 @@ private JTable getJTableInventoryRow() { @Override public void valueChanged(ListSelectionEvent e) { - if(!e.getValueIsAdjusting()){ + if (!e.getValueIsAdjusting()) { jTableInventoryRow.editCellAt(jTableInventoryRow.getSelectedRow(), 5); jTetFieldEditor.selectAll(); } From a2c7fed60926cb1f1298a978706c9b3478fa5986 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Mon, 11 Mar 2024 17:58:27 +0100 Subject: [PATCH 012/147] Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java Co-authored-by: David B Malkovsky --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index e360191ce5..cb95148da2 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -439,7 +439,7 @@ public void setValueAt(Object value, int r, int c) { if (c == 5) { Integer intValue=0; try{ - intValue=Integer.parseInt(value.toString()); + intValue = Integer.parseInt(value.toString()); } catch (NumberFormatException e) { intValue=0; From bfa672b4e99a827eacaf0e14a93baf78a8a30520 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Mon, 11 Mar 2024 17:58:33 +0100 Subject: [PATCH 013/147] Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java Co-authored-by: David B Malkovsky --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index cb95148da2..1d94c7facb 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -442,7 +442,7 @@ public void setValueAt(Object value, int r, int c) { intValue = Integer.parseInt(value.toString()); } catch (NumberFormatException e) { - intValue=0; + intValue = 0; } invRow.setRealqty(intValue); From fcd24d8789b4208dc7e3b1629ae6f5d963bd3725 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Mon, 11 Mar 2024 17:59:12 +0100 Subject: [PATCH 014/147] Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java Co-authored-by: David B Malkovsky --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 1d94c7facb..2ced93f602 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -613,7 +613,7 @@ private JLabel getDateInventoryLabel() { } private JButton getMoreDataBtn() { - if(moreData == null) { + if (moreData == null) { moreData = new JButton("..."); moreData.setPreferredSize(new Dimension(20, 20)); moreData.setEnabled(false); From a23441fa70d3c95c4e8c33735f4248fd25cb8760 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:00:33 +0100 Subject: [PATCH 015/147] Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java Co-authored-by: David B Malkovsky --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 2ced93f602..5e56ecbbb5 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -544,7 +544,7 @@ public void actionPerformed(ActionEvent e) { searchTextField.setText(""); codeTextField.setText(""); searchTextField.setEnabled(true); - if(inventory == null) { + if (inventory == null) { moreData.setEnabled(true); } if (inventoryRowList != null) { From cbbec6412d56ae403c9d0416b18fcbacd9b7d71b Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Mon, 11 Mar 2024 18:08:25 +0100 Subject: [PATCH 016/147] update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java --- .../medicalinventory/gui/InventoryEdit.java | 49 +++++++------------ 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index ec6038abd6..3454c2aa70 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -137,9 +137,6 @@ public static void addInventoryListener(InventoryListener l) { private JLabel loaderLabel; private JButton moreData; - private int MAX_COUNT = 30; - private int CURRENT_INDEX = 0; - private boolean MORE_DATA = true; private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); private MedicalInventoryRowManager medicalInventoryRowManager = Context.getApplicationContext().getBean(MedicalInventoryRowManager.class); @@ -180,10 +177,12 @@ private void initComponents() { addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { - if (inventoryRowList != null) + if (inventoryRowList != null) { inventoryRowList.clear(); - if (inventoryRowSearchList != null) + } + if (inventoryRowSearchList != null) { inventoryRowSearchList.clear(); + } dispose(); } }); @@ -465,11 +464,9 @@ class DecimalFormatRenderer extends DefaultTableCellRenderer { private static final long serialVersionUID = 1L; private final DecimalFormat formatter = new DecimalFormat("#,##0.00"); - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, - int row, int column) { + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - cell.addFocusListener(new java.awt.event.FocusListener() - { + cell.addFocusListener(new java.awt.event.FocusListener() { @Override public void focusGained(java.awt.event.FocusEvent e) { @@ -568,17 +565,12 @@ private JTextField getSearchTextField() { if (searchTextField == null) { searchTextField = new JTextField(); searchTextField.setColumns(16); - TextPrompt suggestion = new TextPrompt( - MessageBundle - .getMessage("angal.common.search.txt"), - searchTextField, Show.FOCUS_LOST); - { - suggestion.setFont(new Font("Tahoma", Font.PLAIN, 12)); - suggestion.setForeground(Color.GRAY); - suggestion.setHorizontalAlignment(JLabel.CENTER); - suggestion.changeAlpha(0.5f); - suggestion.changeStyle(Font.BOLD + Font.ITALIC); - } + TextPrompt suggestion = new TextPrompt( MessageBundle.getMessage("angal.common.search.txt"), searchTextField, Show.FOCUS_LOST); + suggestion.setFont(new Font("Tahoma", Font.PLAIN, 12)); + suggestion.setForeground(Color.GRAY); + suggestion.setHorizontalAlignment(JLabel.CENTER); + suggestion.changeAlpha(0.5f); + suggestion.changeStyle(Font.BOLD + Font.ITALIC); searchTextField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { @@ -630,17 +622,12 @@ private JTextField getCodeTextField() { codeTextField.setEnabled(true); } codeTextField.setColumns(10); - TextPrompt suggestion = new TextPrompt( - MessageBundle - .getMessage("angal.common.code.txt"), - codeTextField, Show.FOCUS_LOST); - { - suggestion.setFont(new Font("Tahoma", Font.PLAIN, 12)); - suggestion.setForeground(Color.GRAY); - suggestion.setHorizontalAlignment(JLabel.CENTER); - suggestion.changeAlpha(0.5f); - suggestion.changeStyle(Font.BOLD + Font.ITALIC); - } + TextPrompt suggestion = new TextPrompt(MessageBundle.getMessage("angal.common.code.txt"), codeTextField, Show.FOCUS_LOST); + suggestion.setFont(new Font("Tahoma", Font.PLAIN, 12)); + suggestion.setForeground(Color.GRAY); + suggestion.setHorizontalAlignment(JLabel.CENTER); + suggestion.changeAlpha(0.5f); + suggestion.changeStyle(Font.BOLD + Font.ITALIC); } return codeTextField; } From 6d1ffcf51e64ccc7e32153bd37dcbc6e5cd2dd1a Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Mon, 11 Mar 2024 18:23:27 +0100 Subject: [PATCH 017/147] fix column to upper case --- .../org/isf/medicalinventory/gui/InventoryEdit.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 839ea8904d..757c921926 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -114,12 +114,12 @@ public static void addInventoryListener(InventoryListener l) { private JTable jTableInventoryRow; private List inventoryRowList; private List inventoryRowSearchList; - private String[] pColums = { MessageBundle.getMessage("angal.common.code.txt"), - MessageBundle.getMessage("angal.medicalstockward.patient.drug.col"), - MessageBundle.getMessage("angal.wardpharmacy.lotnumber.col"), - MessageBundle.getMessage("angal.medicalstock.duedate.col"), - MessageBundle.getMessage("angal.inventoryrow.theorticqty.col"), - MessageBundle.getMessage("angal.inventoryrow.realqty.col") }; + private String[] pColums = { MessageBundle.getMessage("angal.common.code.txt").toUpperCase(), + MessageBundle.getMessage("angal.medicalstockward.patient.drug.col").toUpperCase(), + MessageBundle.getMessage("angal.wardpharmacy.lotnumber.col").toUpperCase(), + MessageBundle.getMessage("angal.medicalstock.duedate.col").toUpperCase(), + MessageBundle.getMessage("angal.inventoryrow.theorticqty.col").toUpperCase(), + MessageBundle.getMessage("angal.inventoryrow.realqty.col").toUpperCase() }; private int[] pColumwidth = { 100, 300, 100, 100, 100, 100 }; private boolean[] columnEditable = { false, false, false, false, false, true }; private boolean[] columnEditableView = { false, false, false, false, false, false }; From 3b318a93b8ea5f05373cd52d5ba3d6cfdd5b39d5 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Mon, 11 Mar 2024 18:32:00 +0100 Subject: [PATCH 018/147] update message error --- .../java/org/isf/medicalinventory/gui/InventoryBrowser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 166573a415..9a39cf4322 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -318,7 +318,7 @@ private JButton getNewButton() { InventoryEdit.addInventoryListener(InventoryBrowser.this); inventoryEdit.showAsModal(InventoryBrowser.this); } else { - MessageDialog.error(null, "angal.inventory.cannotcreateanotherinventorywithotherinprogress"); + MessageDialog.error(null, "angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg"); return; } From a1125cc89eec76455cc5e988b10d6bdbb8f742a3 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Tue, 12 Mar 2024 08:42:26 +0100 Subject: [PATCH 019/147] remove the method that are not use yet --- .../gui/InventoryBrowser.java | 41 ++++++++----------- .../medicalinventory/gui/InventoryEdit.java | 6 --- 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 9a39cf4322..d19ee34bb0 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -31,6 +31,8 @@ import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.LocalDateTime; @@ -97,6 +99,7 @@ public class InventoryBrowser extends ModalJFrame implements InventoryListener { private int START_INDEX = 0; private int TOTAL_ROWS; private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); + private List inventoryList; public InventoryBrowser() { initComponents(); @@ -118,7 +121,14 @@ private void initComponents() { getContentPane().add(panelFooter, BorderLayout.SOUTH); ajustWidth(); - + addWindowListener(new WindowAdapter(){ + public void windowClosing(WindowEvent e) { + if(inventoryList!=null){ + inventoryList.clear(); + } + dispose(); + } + }); pagesCombo.setEditable(true); previous.setEnabled(false); next.setEnabled(false); @@ -434,9 +444,7 @@ private JComboBox getComboBox() { for (InventoryStatus currentState : InventoryStatus.values()) { stateComboBox.addItem(MessageBundle.getMessage("angal.inventory."+currentState)); } - stateComboBox.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { + stateComboBox.addActionListener(actionEvent -> { InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); TOTAL_ROWS = inventoryModel.getRowCount(); START_INDEX = 0; @@ -448,7 +456,6 @@ public void actionPerformed(ActionEvent e) { } jTableInventory.setModel(new InventoryBrowsingModel(START_INDEX, PAGE_SIZE)); initialiseCombo(TOTAL_ROWS); - } }); } return stateComboBox; @@ -478,27 +485,11 @@ public void initialiseCombo(int total_rows) { } } - @Override - public void InventoryUpdated(AWTEvent e) { - // TODO Auto-generated method stub - - } - - @Override - public void InventoryInserted(AWTEvent e) { - // TODO Auto-generated method stub - - } - - @Override - public void InventoryValidated(AWTEvent e) { - // TODO Auto-generated method stub - - } - @Override public void InventoryCancelled(AWTEvent e) { - // TODO Auto-generated method stub - + if (inventoryList!=null) { + inventoryList.clear(); + } + jTableInventory.setModel(new InventoryBrowsingModel()); } } diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 757c921926..dc081ab83c 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -89,12 +89,6 @@ public class InventoryEdit extends ModalJFrame { private static EventListenerList InventoryListeners = new EventListenerList(); public interface InventoryListener extends EventListener { - public void InventoryUpdated(AWTEvent e); - - public void InventoryInserted(AWTEvent e); - - public void InventoryValidated(AWTEvent e); - public void InventoryCancelled(AWTEvent e); } From 830a2de6a5c6bd60781da7f5ebb1e36cd47f7e70 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Tue, 12 Mar 2024 09:20:33 +0100 Subject: [PATCH 020/147] change column drugs by products --- bundle/language_en.properties | 1 + src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index f2e6283116..beb8428bfc 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -669,6 +669,7 @@ angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg angal.inventory.draft = Draft angal.inventory.inventorybrowser.title = Inventory Browser angal.inventory.neweditinventory.title = Edit an inventory +angal.inventory.product.col = Products angal.inventory.status.txt = Status angal.inventory.specificproduct.txt = Specific product angal.inventoryrow.theorticqty.col = Theoritic Qty diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index dc081ab83c..a1451162d5 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -109,7 +109,7 @@ public static void addInventoryListener(InventoryListener l) { private List inventoryRowList; private List inventoryRowSearchList; private String[] pColums = { MessageBundle.getMessage("angal.common.code.txt").toUpperCase(), - MessageBundle.getMessage("angal.medicalstockward.patient.drug.col").toUpperCase(), + MessageBundle.getMessage("angal.inventory.product.col").toUpperCase(), MessageBundle.getMessage("angal.wardpharmacy.lotnumber.col").toUpperCase(), MessageBundle.getMessage("angal.medicalstock.duedate.col").toUpperCase(), MessageBundle.getMessage("angal.inventoryrow.theorticqty.col").toUpperCase(), From b91f5496ad5ac2e2df3ffce5a0f9385abd12a2a0 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Tue, 12 Mar 2024 16:26:58 +0100 Subject: [PATCH 021/147] update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java --- .../medicalinventory/gui/InventoryEdit.java | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 828d1e3c80..00bff737b9 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -215,6 +215,8 @@ private void fireInventoryCancelled() { private boolean MORE_DATA = true; private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); private MedicalInventoryRowManager medicalInventoryRowManager = Context.getApplicationContext().getBean(MedicalInventoryRowManager.class); + private MedicalBrowsingManager medicalBrowsingManager = Context.getApplicationContext().getBean(MedicalBrowsingManager.class); + private MovStockInsertingManager movStockInsertingManager = Context.getApplicationContext().getBean(MovStockInsertingManager.class); public InventoryEdit() { initComponents(); @@ -865,36 +867,38 @@ private JButton getMoreDataBtn() { moreData.addActionListener(actionEvent -> { if (MORE_DATA && inventory == null) { List medicalList = new ArrayList(); - MedicalBrowsingManager medicalManager = new MedicalBrowsingManager(); CURRENT_INDEX += MAX_COUNT; try { - medicalList = medicalManager.getMedicals(); + medicalList = medicalBrowsingManager.getMedicals(); } catch (OHServiceException e) { e.printStackTrace(); } - MovStockInsertingManager movBrowser = new MovStockInsertingManager(); - ArrayList lots; - MedicalInventoryRow inventoryRowTemp; - double quantityOutsideLot; - double cost; + List lots = null; + MedicalInventoryRow inventoryRowTemp = null; + double quantityOutsideLot = 0.0; + double cost = 0.0; Iterator medicalIterator = medicalList.iterator(); Medical medical; - /* while (medicalIterator.hasNext()) { + while (medicalIterator.hasNext()) { medical = medicalIterator.next(); - lots = movBrowser.getLotByMedical(medical); + try { + lots = movStockInsertingManager.getLotByMedical(medical); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } quantityOutsideLot = medical.getTotalQuantity() - getQtyInALot(lots); if ((lots.size() == 0) || (quantityOutsideLot != 0)) { inventoryRowTemp = new MedicalInventoryRow(0, quantityOutsideLot, quantityOutsideLot, null, - medical, new Lot("", null, null), 0.0, 0.0, false); + medical, new Lot("", null, null)); inventoryRowList.add(inventoryRowTemp); } for (Lot lot : lots) { - cost = lot.getCost() * lot.getQuantity(); - inventoryRowTemp = new MedicalInventoryRow(0, lot.getQuantity(), lot.getQuantity(), null, - medical, lot, lot.getCost(), cost, false); + cost = lot.getCost().doubleValue() * lot.getOverallQuantity(); + inventoryRowTemp = new MedicalInventoryRow(0, lot.getOverallQuantity(), lot.getOverallQuantity(), null, + medical, lot); inventoryRowList.add(inventoryRowTemp); } - }*/ + } inventoryRowSearchList = new ArrayList(); inventoryRowSearchList.addAll(inventoryRowList); if (medicalList.size() > 0) { @@ -905,6 +909,14 @@ private JButton getMoreDataBtn() { return moreData; } + private double getQtyInALot(List lots) { + double qty = 0.0; + for (Iterator iterator = lots.iterator(); iterator.hasNext();) { + Lot lot = (Lot) iterator.next(); + qty += lot.getOverallQuantity(); + } + return qty; + } private JTextField getCodeTextField() { if (codeTextField == null) { codeTextField = new JTextField(); From 5cc9a38c1a2b65a0ff40bfdf9555041ab6501d7d Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Tue, 12 Mar 2024 16:31:24 +0100 Subject: [PATCH 022/147] update the extension of oh_loader --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index a1451162d5..60c2100023 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -662,7 +662,7 @@ private JTextField getReferenceTextField() { private JLabel getLoaderLabel() { if (loaderLabel == null) { - ImageIcon icon = new ImageIcon("rsc/icons/oh_loader.GIF"); + ImageIcon icon = new ImageIcon("rsc/icons/oh_loader.gif"); loaderLabel = new JLabel(""); loaderLabel.setIcon(icon); loaderLabel.setVisible(false); From f8eeefd18b5b59c3a73d5c172f946c7d53109d15 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Tue, 12 Mar 2024 18:00:25 +0100 Subject: [PATCH 023/147] remove loader icon --- rsc/icons/oh_loader.gif | Bin 3208 -> 0 bytes .../medicalinventory/gui/InventoryEdit.java | 17 ----------------- 2 files changed, 17 deletions(-) delete mode 100644 rsc/icons/oh_loader.gif diff --git a/rsc/icons/oh_loader.gif b/rsc/icons/oh_loader.gif deleted file mode 100644 index 3288d1035d70bb86517e2c233f1a904e41f06b29..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3208 zcmc(iX;4#H9>pJdFE7h`I{IF)0|5<6L}(j=N}5%L009EB2nYfyF)E0PvIqo$u!IC; z4PgyY5|S9AEh38G)(9eq4TbH7_UHg@yWrlIJ$6smIADL7s^P;_O;ykRc9soXl`UC*LwQJXkii*0rx|*7rI2=x7WaRkx_~XZqFJ8R3c=2Kg zf@aSAv8+BJ8+^hyay>(QR@t*blbKzsf0}bscEqRc5Hd3o(-N5RyW=zWB*zQw6Zh>* z2CROCDAbu#D`)S|J_o(lL9Yn3l*+8RdiRD_>iNz$#_IAzCna&Wl5 zSF_(rRCDD!wi#i8oAm&jYtn2_@VB%2-H*G%bN#|(6R6N?wM)3u`PiGzwuX7qmTgyF zpE)h0kuoxQ9?=kW7Y!=R@DmhU9)vwT*EZWzJ zrt+=2tqFts72yIp?|gvdLhs8Hfku^Z(){gmN%Y=K#P|%fkvgUj~HfIp3CuXqCtYGtJ#me+n+-LmP( z*XNuk%!aH8bIE@_Bj46>M*dSro|7<6vZ7WUHh5YQzN$>IJFqCb|CT!wj~R2C2%=q{ zpt8rzY$aw?W?=Ustv{jo?Ow@ZRkLe<)NItY>Cyhle*wR59dTdF6(@{5^ zAQBOB*hNtc3bkY-8{Cm$nFS@elbTtSqrt7MB{h_4y+~`!mVa}?c&N>&?P}GqdMuhQ z&@TD5Czd((DcG_Su~dKKV)Pj$-qi1WHM8_vc^O4?^!oY|tmK~i!{fjd&@_1E(T~r7 z_REZy&hMT^ySJB3W7l$4YhR`M(J7S5S~+4Q&3HPa)z%zPpisOp$^ zTEe99ig2$5_qFr!$;7A6CJ}PJmRhli>w?LC}Y`#HLGy6 zMU4EhL~dKCN5Ut;U2jd*83ShBNiu zcJB0l9>1Modc?-oM<R4?}3g}UJ%@K);kriq>)e*rh%hdqM)5Q)*+O8 zXm;SEbs@koiYS!9YXIclSg+5m_s~yrW#kKMdiRszg(gCP5HPmP7L)vCf8@fxUh6qY z@Z#TmkjzAZX{rwE+q|K~F2v5{_@vt%>yT_a#fF03SFt{0RXvDAiaY~K9CgS1O>frXgAjBCS}mEd4mIWZ$=ovd5| zR?GRdU}d6+Q`+JRW)|=v7$)XNkn3yE`!nAiSCvOB1jKT zG<1aK3s<0b0m==egTD#8i(Of=1pGDTOCho0XpIOMQ&P87cVKY1W=C6kIg z9cH=@a&zbm2+`|{(_?YC9fdm?1TY~-pwlBn?>=(~1pDKbco6jloP;0-cqRiwV1A_S zEyV0Dj8Pwy!nekzaN>{)7rgZ&_QLxK{~1yRe865^yx>}+a!ECd>#MMwddow z@CU{l+Rt$xuXuf}?ga{3IAr?Raql^c@a%sI0U5m}HvJ5O1#I%_MMPt#BH>OqUZ{-k zt>4Xzz=%jT*FVW(uYkWyx}9Gw$HdN*qU?Bit#ji(Wi7p-u|_8?h^%szIS^s^fNM}b zgGy>|=cbEufpguY5_6w~&ZLv=Bo06UF9EYIY;Er-1VK)SyF&!|J{axiE1z^(hXwVq zsFS=K-#zC}CcOs^8W{KAt+kK)jYDgDYbCXv{{rwsgqtIU3<910$CJi)s?? z_t8k{>7*0~4l~LLF7$WXT5OSq5QCTbP_l!SN|{R}3D&eWA8~0ltWh1IL+ZBX4rRSt zWF6Om3WDMu4xK^1(BF`2cL}rUCzhHAB`@j5&R-yk_l*t;mPGY|u2^o|myvcOdrg0W z%=lX;f^Vkqfp?u7*4qQq%A3Mpf!xspWBSKS@O%r*TSM}?dl(@*%{0Jm_8;(h{R__M Bt Date: Wed, 13 Mar 2024 09:13:00 +0100 Subject: [PATCH 024/147] update bundle/language_en.properties --- bundle/language_en.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index beb8428bfc..e61ad1c029 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -1093,6 +1093,8 @@ angal.menu.groups angal.menu.help = Help angal.menu.hospital = Hospital angal.menu.inventory = Inventory +angal.menu.inventory.btn = Inventory +angal.menu.inventory.btn.key = I angal.menu.labbrowsing = LaboratoryBrowsing angal.menu.laboratory = Laboratory angal.menu.logfile = Logs From ed93ab55f0f475c54f64b67b8e50aa08ac2a3afb Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Wed, 13 Mar 2024 10:22:10 +0100 Subject: [PATCH 025/147] remove non use key in bundler --- bundle/language_en.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index e61ad1c029..90a638a2e9 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -1035,7 +1035,6 @@ angal.menu.btn.generaldata angal.menu.btn.groups = Groups angal.menu.btn.help = Help angal.menu.btn.hospital = Hospital -angal.menu.btn.inventory = Inventory angal.menu.btn.labbrowsing = Laboratory Browsing angal.menu.btn.laboratory = Laboratory angal.menu.btn.logfile = Logs From 2680fa5d8912922b6334806216ea0034fc5ce0dd Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Wed, 13 Mar 2024 10:33:18 +0100 Subject: [PATCH 026/147] remove non use key in bundler --- bundle/language_en.properties | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 90a638a2e9..beb8428bfc 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -1035,6 +1035,7 @@ angal.menu.btn.generaldata angal.menu.btn.groups = Groups angal.menu.btn.help = Help angal.menu.btn.hospital = Hospital +angal.menu.btn.inventory = Inventory angal.menu.btn.labbrowsing = Laboratory Browsing angal.menu.btn.laboratory = Laboratory angal.menu.btn.logfile = Logs @@ -1092,8 +1093,6 @@ angal.menu.groups angal.menu.help = Help angal.menu.hospital = Hospital angal.menu.inventory = Inventory -angal.menu.inventory.btn = Inventory -angal.menu.inventory.btn.key = I angal.menu.labbrowsing = LaboratoryBrowsing angal.menu.laboratory = Laboratory angal.menu.logfile = Logs From 9414d8c99a099aa402cab847e80d17cc26557840 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Wed, 13 Mar 2024 12:06:06 +0100 Subject: [PATCH 027/147] update bundle/language_en.properties --- bundle/language_en.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index beb8428bfc..7cd02ffb67 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -1739,6 +1739,7 @@ angal.visit.addvisit1.btn.key angal.visit.addvisit2.btn = Add Visit angal.visit.addvisit2.btn.key = V angal.visit.arrowprevious.btn = <-Prev. +angal.visit.arrowprevious.btn.key = P angal.visit.avisitcannotbescheduledforadatethatispast.msg = A visit cannot be scheduled for a date that is past. angal.visit.changepatient = Change Patient angal.visit.durationinminutes = Duration (Min) From ab7611078149edb8118dbe488c3151aa6afbcb26 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Fri, 15 Mar 2024 15:48:49 +0100 Subject: [PATCH 028/147] continue with add inventory --- bundle/language_en.properties | 2 + .../medicalinventory/gui/InventoryEdit.java | 52 ++++-- .../medicalinventory/gui/MedicalPicker.java | 161 ++++++++---------- 3 files changed, 115 insertions(+), 100 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 9454b49028..44ea168bcb 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -675,6 +675,7 @@ angal.inventory.noproduct.msg angal.inventory.referencealreadyused.msg = Reference is already used. angal.inventoryoperation.save.succes.msg = Inventory saved. angal.inventoryrowoperation.save.error.msg = Error during some products's recording +angal.inventoryrow.doyoureallywanttodeletethisinventoryrow.msg = Do you really want to delete this inventory row? angal.inventoryoperation.save.error.msg = Inventory not saved angal.inventory.product.col = Products angal.inventory.status.txt = Status @@ -863,6 +864,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.selectmedical.title = Choose a medical angal.medicalstock.multiplecharging.supplier = Supplier angal.medicalstock.multiplecharging.theinsertedreferencenumberalreadyexists.msg = The inserted reference number already exists. angal.medicalstock.multiplecharging.totalcost = Total cost diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index da9f28e427..6c6217b0b2 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -34,6 +34,8 @@ import java.awt.GridBagLayout; import java.awt.Image; import java.awt.Insets; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; @@ -57,6 +59,7 @@ import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JScrollPane; @@ -154,6 +157,7 @@ private void fireInventoryCancelled() { private JPanel panelFooter; private JPanel panelContent; private JButton closeButton; + private JButton deleteButton; private JButton saveButton; private JButton validateButton; private JScrollPane scrollPaneInventory; @@ -331,6 +335,7 @@ private JPanel getPanelFooter() { if (panelFooter == null) { panelFooter = new JPanel(); panelFooter.add(getNewButton()); + panelFooter.add(getDeleteButton()); panelFooter.add(getCloseButton()); } return panelFooter; @@ -393,7 +398,6 @@ private JButton getNewButton() { inventory.setStatus(State); inventory.setUser(user); inventory.setInventoryType(InventoryType.principal.toString()); - inventory.setWard(""); MedicalInventory meInventory; try { meInventory = medicalInventoryManager.newMedicalInventory(inventory); @@ -401,12 +405,10 @@ private JButton getNewButton() { inventory.setId(meInventory.getId()); MedicalInventoryRow currentInventoryRow; Double totalCost = 0.0; - for (Iterator iterator = inventoryRowSearchList.iterator(); iterator - .hasNext();) { + for (Iterator iterator = inventoryRowSearchList.iterator(); iterator.hasNext();) { MedicalInventoryRow medicalInventoryRow = (MedicalInventoryRow) iterator.next(); medicalInventoryRow.setInventory(inventory); - currentInventoryRow = medicalInventoryRowManager - .newMedicalInventoryRow(medicalInventoryRow); + currentInventoryRow = medicalInventoryRowManager.newMedicalInventoryRow(medicalInventoryRow); if (currentInventoryRow == null) { checkResults++; } else { @@ -534,7 +536,34 @@ private JButton getValidateButton() { */ return validateButton; } - + private JButton getDeleteButton() { + deleteButton = new JButton(MessageBundle.getMessage("angal.common.delete.btn")); + deleteButton.setMnemonic(MessageBundle.getMnemonic("angal.common.delete.btn.key")); + deleteButton.addActionListener(actionEvent -> { + if (jTableInventoryRow.getSelectedRowCount() > 1 ) { + MessageDialog.error(this, "angal.medicalstock.pleaseselectonlyonemovement.msg"); + return; + } + int selectedRow = jTableInventoryRow.getSelectedRow(); + if (selectedRow == -1) { + MessageDialog.error(this, "angal.medicalstock.pleaseselectonlyonemovement.msg"); + return; + } + MedicalInventoryRow selectedInventory = (MedicalInventoryRow)jTableInventoryRow.getValueAt(selectedRow, -1); + int delete = MessageDialog.yesNo(null, "angal.inventoryrow.doyoureallywanttodeletethisinventoryrow.msg"); + if (delete == JOptionPane.YES_OPTION) { + if (selectedInventory.getInventory() == null) { + inventoryRowSearchList.remove(selectedRow); + } else { + + } + } else { + return; + } + jTableInventoryRow.updateUI(); + }); + return deleteButton; + } private JButton getCloseButton() { closeButton = new JButton(MessageBundle.getMessage("angal.common.close.btn")); closeButton.setMnemonic(MessageBundle.getMnemonic("angal.common.close.btn.key")); @@ -696,14 +725,14 @@ class DecimalFormatRenderer extends DefaultTableCellRenderer { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - cell.addFocusListener(new java.awt.event.FocusListener() { + cell.addFocusListener(new FocusListener() { @Override - public void focusGained(java.awt.event.FocusEvent e) { + public void focusGained(FocusEvent e) { } @Override - public void focusLost(java.awt.event.FocusEvent e) { + public void focusLost(FocusEvent e) { } }); @@ -981,8 +1010,7 @@ private void addInventoryRow(String code) throws OHServiceException { } else if (mode.equals("update")) { if (medical != null) { String medicalCode = medical.getProdCode(); - inventoryRowsList = medicalInventoryRowManager - .getMedicalInventoryRowByInventoryId(inventory.getId()).stream().filter(medRow -> medRow.getMedical().getProdCode().equals(medicalCode)).toList(); + inventoryRowsList = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()).stream().filter(medRow -> medRow.getMedical().getProdCode().equals(medicalCode)).toList(); } } if (inventoryRowSearchList == null) { @@ -1044,7 +1072,7 @@ private Medical chooseMedical(String text) throws OHServiceException { Collections.sort(medList); Medical med = null; if (!medList.isEmpty()) { - MedicalPicker framas = new MedicalPicker(new StockMedModel(medList)); + MedicalPicker framas = new MedicalPicker(new StockMedModel(medList), medList); framas.setSize(300, 400); JDialog dialog = new JDialog(); dialog.setLocationRelativeTo(null); diff --git a/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java b/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java index a8b6fee874..a9bf27fc49 100644 --- a/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java +++ b/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java @@ -1,11 +1,13 @@ package org.isf.medicalinventory.gui; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.FlowLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.Rectangle; +import java.awt.event.ActionEvent; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; @@ -13,9 +15,16 @@ import java.awt.event.MouseMotionListener; import java.util.ArrayList; import java.util.Collection; +import java.util.List; +import javax.swing.JButton; import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.table.TableColumn; @@ -25,7 +34,7 @@ import org.isf.medicals.model.Medical; import org.isf.utils.jobjects.OhDefaultCellRenderer; -public class MedicalPicker extends javax.swing.JPanel { +public class MedicalPicker extends JPanel { OhDefaultCellRenderer cellRenderer = new OhDefaultCellRenderer(); /** @@ -35,18 +44,45 @@ public class MedicalPicker extends javax.swing.JPanel { private Collection medicalMapValues = new ArrayList(); private String searchCode; + private JButton jButtonSelect; + private JButton jButtonQuit; + private JLabel jLabelImage; + private JPanel jPanel1; + private JPanel jPanel2; + private JPanel jPanel3; + private JScrollPane jScrollPane1; + private JTable jTableData; + private JTextField jTextFieldFind; + private int selectedRow = -1; + private JDialog parentFrame; - public MedicalPicker(StockMedModel model) { - initComponents(model); + private int getSelectedRow() { + return selectedRow; + } + + public Medical getSelectedMedical() { + StockMedModel model = (StockMedModel) jTableData.getModel(); + return model.getMedicalAtRow(this.getSelectedRow()); + } + + private void setSelectedRow(int selectedRow) { + this.selectedRow = selectedRow; } + - public MedicalPicker(StockMedModel model, Collection medicalMapValues, String searchCode) { - this.searchCode = searchCode; - initComponents(model); - this.medicalMapValues = medicalMapValues; - + + public JDialog getParentFrame() { + return parentFrame; } + public void setParentFrame(JDialog parentFrame) { + this.parentFrame = parentFrame; + } + + public MedicalPicker(StockMedModel model, List medicals) { + initComponents(model); + this.medicalMapValues = medicals; + } /** * This method is called from within the constructor to initialize the form. @@ -55,12 +91,12 @@ public MedicalPicker(StockMedModel model, Collection medicalMapValues, */ private void initComponents(TableModel model) { - jPanel3 = new javax.swing.JPanel(); - jPanel1 = new javax.swing.JPanel(); + jPanel3 = new JPanel(); + jPanel1 = new JPanel(); - jPanel3.setBackground(new java.awt.Color(240, 240, 240)); + jPanel3.setBackground(new Color(240, 240, 240)); - jPanel1.setBackground(new java.awt.Color(240, 240, 240)); + jPanel1.setBackground(new Color(240, 240, 240)); setLayout(new BorderLayout(10, 10)); add(jPanel1, BorderLayout.CENTER); @@ -70,8 +106,8 @@ private void initComponents(TableModel model) { gbl_jPanel1.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_jPanel1.rowWeights = new double[] { 1.0, Double.MIN_VALUE }; jPanel1.setLayout(gbl_jPanel1); - jScrollPane1 = new javax.swing.JScrollPane(); - jTableData = new javax.swing.JTable(); + jScrollPane1 = new JScrollPane(); + jTableData = new JTable(); jTableData.setDefaultRenderer(Object.class, cellRenderer); jTableData.setDefaultRenderer(Double.class, cellRenderer); @@ -101,14 +137,14 @@ public void mouseExited(MouseEvent e) { }); jTableData.setModel(model); - jTableData.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); + jTableData.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTableData.setShowVerticalLines(false); - jTableData.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { + jTableData.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent evt) { jTableDataMouseClicked(evt); } - public void mousePressed(java.awt.event.MouseEvent evt) { + public void mousePressed(MouseEvent evt) { if (evt.getClickCount() == 2) { validateSelection(); } @@ -140,26 +176,23 @@ public void keyPressed(KeyEvent e) { gbl_jPanel3.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; jPanel3.setLayout(gbl_jPanel3); - jLabelImage = new javax.swing.JLabel(); + jLabelImage = new JLabel(); - jLabelImage.setText(MessageBundle.getMessage("aangal.common.search.txt")); + jLabelImage.setText(MessageBundle.getMessage("angal.common.search.txt")); GridBagConstraints gbc_jLabelImage = new GridBagConstraints(); gbc_jLabelImage.anchor = GridBagConstraints.WEST; gbc_jLabelImage.insets = new Insets(0, 15, 0, 5); gbc_jLabelImage.gridx = 0; gbc_jLabelImage.gridy = 0; jPanel3.add(jLabelImage, gbc_jLabelImage); - jTextFieldFind = new javax.swing.JTextField(); - + jTextFieldFind = new JTextField(); jTextFieldFind.setText(searchCode); - jTextFieldFind.setName("textRecherche"); GridBagConstraints gbc_jTextFieldFind = new GridBagConstraints(); gbc_jTextFieldFind.insets = new Insets(0, 0, 0, 15); gbc_jTextFieldFind.fill = GridBagConstraints.HORIZONTAL; gbc_jTextFieldFind.gridx = 1; gbc_jTextFieldFind.gridy = 0; jPanel3.add(jTextFieldFind, gbc_jTextFieldFind); - jTextFieldFind.getDocument().addDocumentListener(new DocumentListener() { @Override @@ -169,11 +202,10 @@ public void insertUpdate(DocumentEvent e) { for (Medical aMed : medicalMapValues) { medList.add(aMed); } - StockMedModel model = new StockMedModel(medList); jTableData.setModel(model); TableColumn column; - for(int i = 0; i < 3; i++) { + for(int i = 0; i < 2; i++) { column = jTableData.getColumnModel().getColumn(i); if(i == 1) { column.setPreferredWidth(375); @@ -210,7 +242,6 @@ public void changedUpdate(DocumentEvent e) { jTextFieldFind.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_ENTER) { validateSelection(); } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { @@ -220,49 +251,39 @@ public void keyPressed(KeyEvent e) { if (jTableData.getRowCount() > selectedRow) { jTableData.setRowSelectionInterval(selectedRow, selectedRow); jTableData.scrollRectToVisible(new Rectangle(jTableData.getCellRect(selectedRow, 0, true))); - } } - jTableData.updateUI(); } else if (e.getKeyCode() == KeyEvent.VK_UP) { int selectedRow = jTableData.getSelectedRow(); if (jTableData.getRowCount() > 0 && selectedRow > 0) { selectedRow--; - jTableData.setRowSelectionInterval(selectedRow, selectedRow); - jTableData.scrollRectToVisible(new Rectangle(jTableData.getCellRect(selectedRow, 0, true))); - } - jTableData.updateUI(); } + jTableData.updateUI(); super.keyPressed(e); } }); - jPanel2 = new javax.swing.JPanel(); - jButtonSelect = new javax.swing.JButton(); - jButtonQuit = new javax.swing.JButton(); - - jPanel2.setBackground(new java.awt.Color(240, 240, 240)); - + jPanel2 = new JPanel(); + jButtonSelect = new JButton(); + jButtonQuit = new JButton(); + jPanel2.setBackground(new Color(240, 240, 240)); jButtonSelect.setText(MessageBundle.getMessage("angal.common.select.btn")); jButtonSelect.setMnemonic(MessageBundle.getMnemonic("angal.common.select.btn.key")); - jButtonSelect.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { + jButtonSelect.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent evt) { jButtonSelectMouseClicked(evt); } }); - jButtonSelect.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButtonSelectActionPerformed(evt); - } + jButtonSelect.addActionListener( actionEvent -> { + jButtonSelectActionPerformed(actionEvent); }); - jButtonQuit.setText(MessageBundle.getMessage("angal.common.cancel.btn")); jButtonQuit.setMnemonic(MessageBundle.getMnemonic("angal.common.cancel.btn.key")); - jButtonQuit.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent evt) { + jButtonQuit.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent evt) { jButtonQuitMouseClicked(evt); } }); @@ -277,7 +298,7 @@ public void mouseClicked(java.awt.event.MouseEvent evt) { } - private void jTableDataMouseClicked(java.awt.event.MouseEvent evt) { + private void jTableDataMouseClicked(MouseEvent evt) { } @@ -288,55 +309,19 @@ private void validateSelection() { } - private void jButtonSelectActionPerformed(java.awt.event.ActionEvent evt) { + private void jButtonSelectActionPerformed(ActionEvent evt) { } - private void jButtonSelectMouseClicked(java.awt.event.MouseEvent evt) { + private void jButtonSelectMouseClicked(MouseEvent evt) { this.setSelectedRow(this.jTableData.getSelectedRow()); this.setVisible(false); this.getParentFrame().dispose(); } - private void jButtonQuitMouseClicked(java.awt.event.MouseEvent evt) { + private void jButtonQuitMouseClicked(MouseEvent evt) { this.setVisible(false); this.getParentFrame().dispose(); } - - private int selectedRow = -1; - - private int getSelectedRow() { - return selectedRow; - } - - public Medical getSelectedMedical() { - StockMedModel model = (StockMedModel) jTableData.getModel(); - return model.getMedicalAtRow(this.getSelectedRow()); - } - - private void setSelectedRow(int selectedRow) { - this.selectedRow = selectedRow; - } - - private JDialog parentFrame; - - public JDialog getParentFrame() { - return parentFrame; - } - - public void setParentFrame(JDialog parentFrame) { - this.parentFrame = parentFrame; - } - - private javax.swing.JButton jButtonSelect; - private javax.swing.JButton jButtonQuit; - private javax.swing.JLabel jLabelImage; - private javax.swing.JPanel jPanel1; - private javax.swing.JPanel jPanel2; - private javax.swing.JPanel jPanel3; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JTable jTableData; - private javax.swing.JTextField jTextFieldFind; - } From b79775c9cdcae821e7d17349d083bd25e535c385 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Fri, 15 Mar 2024 16:21:05 +0100 Subject: [PATCH 029/147] change the button name and remove the key --- bundle/language_en.properties | 2 ++ .../java/org/isf/medicalinventory/gui/InventoryBrowser.java | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 7cd02ffb67..96e79b2a24 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -669,6 +669,8 @@ angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg angal.inventory.draft = Draft angal.inventory.inventorybrowser.title = Inventory Browser angal.inventory.neweditinventory.title = Edit an inventory +angal.inventory.nextarrow.btn = > +angal.inventory.arrowprevious.btn = < angal.inventory.product.col = Products angal.inventory.status.txt = Status angal.inventory.specificproduct.txt = Specific product diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index d19ee34bb0..967cd365f1 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -251,10 +251,8 @@ private JPanel getPanelContent() { private JPanel getPanelFooter() { if (panelFooter == null) { panelFooter = new JPanel(); - next = new JButton(MessageBundle.getMessage("angal.visit.nextarrow.btn")); - next.setMnemonic(MessageBundle.getMnemonic("angal.visit.nextarrow.btn.key")); - previous = new JButton(MessageBundle.getMessage("angal.visit.arrowprevious.btn")); - next.setMnemonic(MessageBundle.getMnemonic("angal.visit.arrowprevious.btn.key")); + next = new JButton(MessageBundle.getMessage("angal.inventory.nextarrow.btn")); + previous = new JButton(MessageBundle.getMessage("angal.inventory.arrowprevious.btn")); panelFooter.add(previous); panelFooter.add(pagesCombo); From f0a1e78683ade7a13433ab3e7b5d67677a0319d7 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Fri, 15 Mar 2024 16:52:03 +0100 Subject: [PATCH 030/147] set Mnemonic on next and previous button and remove non use key on bundler --- bundle/language_en.properties | 1 - .../isf/medicalinventory/gui/InventoryBrowser.java | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 96e79b2a24..c676eac516 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -1741,7 +1741,6 @@ angal.visit.addvisit1.btn.key angal.visit.addvisit2.btn = Add Visit angal.visit.addvisit2.btn.key = V angal.visit.arrowprevious.btn = <-Prev. -angal.visit.arrowprevious.btn.key = P angal.visit.avisitcannotbescheduledforadatethatispast.msg = A visit cannot be scheduled for a date that is past. angal.visit.changepatient = Change Patient angal.visit.durationinminutes = Duration (Min) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 967cd365f1..087f133ce1 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -27,10 +27,9 @@ import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.text.SimpleDateFormat; @@ -53,6 +52,7 @@ import javax.swing.table.DefaultTableModel; import org.isf.generaldata.MessageBundle; +import org.isf.medicalinventory.gui.InventoryBrowser.InventoryBrowsingModel; import org.isf.medicalinventory.gui.InventoryEdit.InventoryListener; import org.isf.medicalinventory.manager.MedicalInventoryManager; import org.isf.medicalinventory.model.MedicalInventory; @@ -252,7 +252,9 @@ private JPanel getPanelFooter() { if (panelFooter == null) { panelFooter = new JPanel(); next = new JButton(MessageBundle.getMessage("angal.inventory.nextarrow.btn")); + next.setMnemonic(KeyEvent.VK_RIGHT); previous = new JButton(MessageBundle.getMessage("angal.inventory.arrowprevious.btn")); + next.setMnemonic(KeyEvent.VK_LEFT); panelFooter.add(previous); panelFooter.add(pagesCombo); @@ -490,4 +492,12 @@ public void InventoryCancelled(AWTEvent e) { } jTableInventory.setModel(new InventoryBrowsingModel()); } + + @Override + public void InventoryInserted(AWTEvent e) { + if(inventoryList!=null) { + inventoryList.clear(); + } + jTableInventory.setModel(new InventoryBrowsingModel()); + } } From d4f11a976aaf8a17c2fce5f19a35d663310f789e Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Fri, 15 Mar 2024 17:28:50 +0100 Subject: [PATCH 031/147] fix error --- .../org/isf/medicalinventory/gui/InventoryBrowser.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 087f133ce1..addb1ef782 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -492,12 +492,4 @@ public void InventoryCancelled(AWTEvent e) { } jTableInventory.setModel(new InventoryBrowsingModel()); } - - @Override - public void InventoryInserted(AWTEvent e) { - if(inventoryList!=null) { - inventoryList.clear(); - } - jTableInventory.setModel(new InventoryBrowsingModel()); - } } From 0d4a196a6025595336c832906af1817467092074 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Mon, 18 Mar 2024 18:25:00 +0100 Subject: [PATCH 032/147] add fetch inventory --- .../gui/InventoryBrowser.java | 91 ++++++++++++++++--- .../medicalinventory/gui/InventoryEdit.java | 55 ++++------- 2 files changed, 99 insertions(+), 47 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 087f133ce1..77aed854e2 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -35,7 +35,6 @@ import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.LocalTime; import java.util.ArrayList; import java.util.GregorianCalendar; import java.util.List; @@ -52,7 +51,6 @@ import javax.swing.table.DefaultTableModel; import org.isf.generaldata.MessageBundle; -import org.isf.medicalinventory.gui.InventoryBrowser.InventoryBrowsingModel; import org.isf.medicalinventory.gui.InventoryEdit.InventoryListener; import org.isf.medicalinventory.manager.MedicalInventoryManager; import org.isf.medicalinventory.model.MedicalInventory; @@ -61,9 +59,13 @@ import org.isf.utils.exception.gui.OHServiceExceptionUtil; import org.isf.utils.jobjects.GoodDateChooser; import org.isf.utils.jobjects.InventoryStatus; +import org.isf.utils.jobjects.InventoryType; import org.isf.utils.jobjects.MessageDialog; import org.isf.utils.jobjects.ModalJFrame; import org.isf.utils.time.TimeTools; +import org.springframework.data.domain.Page; + +import static org.isf.utils.Constants.DATE_TIME_FORMATTER; public class InventoryBrowser extends ModalJFrame implements InventoryListener { @@ -123,9 +125,6 @@ private void initComponents() { ajustWidth(); addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e) { - if(inventoryList!=null){ - inventoryList.clear(); - } dispose(); } }); @@ -274,10 +273,21 @@ private GoodDateChooser getJCalendarTo() { if (jCalendarTo == null) { jCalendarTo = new GoodDateChooser(LocalDate.now()); jCalendarTo.addDateChangeListener(event -> { - LocalDate newDate = event.getNewDate(); - if (newDate != null) { - dateTo = newDate.atTime(LocalTime.MAX); + dateTo = jCalendarTo.getDateStartOfDay(); + if (inventoryList != null) { + inventoryList.clear(); } + InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); + TOTAL_ROWS = inventoryModel.getRowCount(); + START_INDEX = 0; + previous.setEnabled(false); + if (TOTAL_ROWS <= PAGE_SIZE){ + next.setEnabled(false); + } else { + next.setEnabled(true); + } + jTableInventory.setModel(new InventoryBrowsingModel(START_INDEX, PAGE_SIZE)); + initialiseCombo(TOTAL_ROWS); }); } return jCalendarTo; @@ -287,9 +297,21 @@ private GoodDateChooser getJCalendarFrom() { if (jCalendarFrom == null) { jCalendarFrom = new GoodDateChooser(LocalDate.now()); jCalendarFrom.addDateChangeListener(event -> { - LocalDate newDate = event.getNewDate(); - if (newDate != null) { - dateFrom = newDate.atTime(LocalTime.MAX); } + dateFrom = jCalendarFrom.getDateStartOfDay(); + if (inventoryList != null) { + inventoryList.clear(); + } + InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); + TOTAL_ROWS = inventoryModel.getRowCount(); + START_INDEX = 0; + previous.setEnabled(false); + if (TOTAL_ROWS <= PAGE_SIZE){ + next.setEnabled(false); + } else { + next.setEnabled(true); + } + jTableInventory.setModel(new InventoryBrowsingModel(START_INDEX, PAGE_SIZE)); + initialiseCombo(TOTAL_ROWS); }); } return jCalendarFrom; @@ -393,9 +415,26 @@ class InventoryBrowsingModel extends DefaultTableModel { private static final long serialVersionUID = 1L; public InventoryBrowsingModel() { + String state = stateComboBox.getSelectedIndex() > 0 ? stateComboBox.getSelectedItem().toString().toLowerCase(): null; + String type = InventoryType.principal.toString(); + try { + inventoryList = medicalInventoryManager.getMedicalInventoryByParams(dateFrom, dateTo, state, type); + System.out.println(inventoryList.size()+" size "); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } } - + public InventoryBrowsingModel(int start_index, int page_size) { + String state = stateComboBox.getSelectedIndex() > 0 ? stateComboBox.getSelectedItem().toString().toLowerCase() : null; + String type = InventoryType.principal.toString(); + + try { + Page medInventorypage = medicalInventoryManager.getMedicalInventoryByParamsPageable(dateFrom, dateTo, state, type, start_index, page_size); + inventoryList = medInventorypage.getContent(); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } } public Class< ? > getColumnClass(int c) { @@ -411,6 +450,12 @@ public InventoryBrowsingModel(int start_index, int page_size) { return null; } + public int getRowCount() { + if (inventoryList == null) + return 0; + return inventoryList.size(); + } + public String getColumnName(int c) { return pColums[c]; } @@ -419,6 +464,22 @@ public int getColumnCount() { return pColums.length; } + public Object getValueAt(int r, int c) { + MedicalInventory medInvt = inventoryList.get(r); + if (c == -1) { + return medInvt; + } else if (c == 0) { + return medInvt.getInventoryReference(); + } else if (c == 1) { + return medInvt.getInventoryDate().format(DATE_TIME_FORMATTER); + } else if (c == 2) { + return medInvt.getStatus(); + } else if (c == 3) { + return medInvt.getUser(); + } + return null; + } + @Override public boolean isCellEditable(int arg0, int arg1) { return false; @@ -500,4 +561,10 @@ public void InventoryInserted(AWTEvent e) { } jTableInventory.setModel(new InventoryBrowsingModel()); } + + @Override + public void InventoryUpdated(AWTEvent e) { + if(inventoryList!=null) inventoryList.clear(); + jTableInventory.setModel(new InventoryBrowsingModel()); + } } diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 6c6217b0b2..e95d92e4bb 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -32,7 +32,6 @@ import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; -import java.awt.Image; import java.awt.Insets; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; @@ -106,9 +105,11 @@ public class InventoryEdit extends ModalJFrame { private static EventListenerList InventoryListeners = new EventListenerList(); - public interface InventoryListener extends java.util.EventListener { + public interface InventoryListener extends EventListener { public void InventoryInserted(AWTEvent e); + + public void InventoryUpdated(AWTEvent e); public void InventoryCancelled(AWTEvent e); } @@ -134,10 +135,9 @@ private void fireInventoryInserted() { for (int i = 0; i < listeners.length; i++) ((InventoryListener) listeners[i]).InventoryInserted(event); } - - private void fireInventoryCancelled() { + + private void fireInventoryUpdated() { AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { - /** * */ @@ -146,10 +146,9 @@ private void fireInventoryCancelled() { EventListener[] listeners = InventoryListeners.getListeners(InventoryListener.class); for (int i = 0; i < listeners.length; i++) - ((InventoryListener) listeners[i]).InventoryCancelled(event); + ((InventoryListener) listeners[i]).InventoryUpdated(event); } - private GoodDateChooser jCalendarTo; private GoodDateChooser jCalendarInventory; private LocalDateTime dateInventory = TimeTools.getServerDateTime(); private JLabel jLabelTo; @@ -185,8 +184,6 @@ private void fireInventoryCancelled() { private JTextField referenceTextField; private JTextField jTetFieldEditor; private JButton moreData; - private int MAX_COUNT = 30; - private int CURRENT_INDEX = 0; private boolean MORE_DATA = true; private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); private MedicalInventoryRowManager medicalInventoryRowManager = Context.getApplicationContext().getBean(MedicalInventoryRowManager.class); @@ -203,6 +200,8 @@ public InventoryEdit(MedicalInventory inventory, String modee) { mode = modee; initComponents(); if (mode.equals("view")) { + validateButton.setVisible(false); + saveButton.setVisible(false); columnEditable = columnEditableView; } @@ -402,21 +401,15 @@ private JButton getNewButton() { try { meInventory = medicalInventoryManager.newMedicalInventory(inventory); if (meInventory != null) { - inventory.setId(meInventory.getId()); MedicalInventoryRow currentInventoryRow; - Double totalCost = 0.0; for (Iterator iterator = inventoryRowSearchList.iterator(); iterator.hasNext();) { MedicalInventoryRow medicalInventoryRow = (MedicalInventoryRow) iterator.next(); - medicalInventoryRow.setInventory(inventory); + medicalInventoryRow.setInventory(meInventory); currentInventoryRow = medicalInventoryRowManager.newMedicalInventoryRow(medicalInventoryRow); if (currentInventoryRow == null) { checkResults++; - } else { - medicalInventoryRow.setId(currentInventoryRow.getId()); - totalCost += medicalInventoryRow.getLot().getCost().doubleValue(); } } - if (checkResults == 0) { // enable validation mode = "update"; @@ -434,7 +427,7 @@ private JButton getNewButton() { } else if ((inventory != null) && (mode.equals("update"))) { checkResults = 0; boolean toUpdate = false; - MedicalInventory result = null; + MedicalInventory medIventory = null; if (!inventory.getInventoryDate().equals(dateInventory)) { inventory.setInventoryDate(dateInventory); toUpdate = true; @@ -445,13 +438,12 @@ private JButton getNewButton() { } if (toUpdate) { try { - result = medicalInventoryManager.updateMedicalInventory(inventory); + medIventory = medicalInventoryManager.updateMedicalInventory(inventory); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } } - if (result != null) { - Double totalCost = 0.0; + if (medIventory != null) { try { for (Iterator iterator = inventoryRowSearchList.iterator(); iterator .hasNext();) { @@ -460,17 +452,14 @@ private JButton getNewButton() { if (updateMedicalInvRow != null) { checkResults++; } - - totalCost += medicalInventoryRow.getLot().getCost().doubleValue(); } } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } if (checkResults == 0) { - DecimalFormat formatter = new DecimalFormat("#,##0.00"); MessageDialog.error(null, "angal.inventoryoperation.update.succes.msg"); validateButton.setEnabled(true); - // fireInventoryUpdated(); + fireInventoryUpdated(); } else { MessageDialog.error(null, "angal.inventoryrowoperation.update.error.msg"); } @@ -870,7 +859,6 @@ private JButton getMoreDataBtn() { moreData.addActionListener(actionEvent -> { if (MORE_DATA && inventory == null) { List medicalList = new ArrayList(); - CURRENT_INDEX += MAX_COUNT; try { medicalList = medicalBrowsingManager.getMedicals(); } catch (OHServiceException e) { @@ -912,7 +900,7 @@ private double getQtyInALot(List lots) { double qty = 0.0; for (Iterator iterator = lots.iterator(); iterator.hasNext();) { Lot lot = (Lot) iterator.next(); - qty += lot.getOverallQuantity(); + qty = qty + lot.getOverallQuantity(); } return qty; } @@ -969,8 +957,9 @@ private void addInventoryRow(String code) throws OHServiceException { } } } - if (!found) + if (!found) { medicalList.add(medical); + } } else { medical = chooseMedical(code); if (medical != null) { @@ -996,9 +985,8 @@ private void addInventoryRow(String code) throws OHServiceException { for (Iterator iterator = medicalList.iterator(); iterator.hasNext();) { medical = (Medical) iterator.next(); lots = movStockInsertingManager.getLotByMedical(medical); - quantityOutsideLot = medical.getTotalQuantity() - getQtyInALot(lots); - if ((lots.size() == 0) || (quantityOutsideLot != 0)) { - inventoryRowTemp = new MedicalInventoryRow(0, quantityOutsideLot, quantityOutsideLot, null, medical, new Lot("", null, null)); + if (lots.size() == 0) { + inventoryRowTemp = new MedicalInventoryRow(0, 0.0, 0.0, null, medical, new Lot("", null, null)); inventoryRowsList.add(inventoryRowTemp); } for (Iterator iterator2 = lots.iterator(); iterator2.hasNext();) { @@ -1013,10 +1001,6 @@ private void addInventoryRow(String code) throws OHServiceException { inventoryRowsList = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()).stream().filter(medRow -> medRow.getMedical().getProdCode().equals(medicalCode)).toList(); } } - if (inventoryRowSearchList == null) { - inventoryRowSearchList = new ArrayList(); - } - for (MedicalInventoryRow inventoryRow : inventoryRowsList) { boolean found = false; for (MedicalInventoryRow row : inventoryRowSearchList) { @@ -1024,8 +1008,9 @@ private void addInventoryRow(String code) throws OHServiceException { found = true; } } - if (!found) + if (!found) { inventoryRowSearchList.add(inventoryRow); + } } jTableInventoryRow.updateUI(); } From 16ab685a5852121d8da69416e4ee045a7ba5887e Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Tue, 19 Mar 2024 08:23:14 +0100 Subject: [PATCH 033/147] update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java --- bundle/language_en.properties | 2 - .../medicalinventory/gui/InventoryEdit.java | 100 ------------------ 2 files changed, 102 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 7eb849fa4d..cbc3916f32 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -683,8 +683,6 @@ angal.inventory.product.col angal.inventory.status.txt = Status angal.inventory.specificproduct.txt = Specific product angal.inventoryrow.theorticqty.col = Theoritic Qty -angal.inventoryrowoperation.update.error.msg = Inventory not updated -angal.inventoryoperation.update.succes.msg = Inventory updated angal.inventory.validated = Validated angal.inventory.validate.btn = Validate angal.inventory.validate.btn.key = V diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index e95d92e4bb..56cbf217e2 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -158,7 +158,6 @@ private void fireInventoryUpdated() { private JButton closeButton; private JButton deleteButton; private JButton saveButton; - private JButton validateButton; private JScrollPane scrollPaneInventory; private JTable jTableInventoryRow; private List inventoryRowList; @@ -200,7 +199,6 @@ public InventoryEdit(MedicalInventory inventory, String modee) { mode = modee; initComponents(); if (mode.equals("view")) { - validateButton.setVisible(false); saveButton.setVisible(false); columnEditable = columnEditableView; } @@ -413,7 +411,6 @@ private JButton getNewButton() { if (checkResults == 0) { // enable validation mode = "update"; - validateButton.setEnabled(true); fireInventoryInserted(); } else { MessageDialog.error(null, "angal.inventoryrowoperation.save.error.msg"); @@ -424,107 +421,10 @@ private JButton getNewButton() { } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } - } else if ((inventory != null) && (mode.equals("update"))) { - checkResults = 0; - boolean toUpdate = false; - MedicalInventory medIventory = null; - if (!inventory.getInventoryDate().equals(dateInventory)) { - inventory.setInventoryDate(dateInventory); - toUpdate = true; - } - if (!inventory.getUser().equals(user)) { - inventory.setUser(user); - toUpdate = true; - } - if (toUpdate) { - try { - medIventory = medicalInventoryManager.updateMedicalInventory(inventory); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - if (medIventory != null) { - try { - for (Iterator iterator = inventoryRowSearchList.iterator(); iterator - .hasNext();) { - MedicalInventoryRow medicalInventoryRow = (MedicalInventoryRow) iterator.next(); - MedicalInventoryRow updateMedicalInvRow = medicalInventoryRowManager.updateMedicalInventoryRow(medicalInventoryRow); - if (updateMedicalInvRow != null) { - checkResults++; - } - } - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - if (checkResults == 0) { - MessageDialog.error(null, "angal.inventoryoperation.update.succes.msg"); - validateButton.setEnabled(true); - fireInventoryUpdated(); - } else { - MessageDialog.error(null, "angal.inventoryrowoperation.update.error.msg"); - } - } else { - MessageDialog.error(null, "angal.inventoryrowoperation.update.error.msg"); - } } }); return saveButton; } - - private JButton getValidateButton() { - validateButton = new JButton(MessageBundle.getMessage("angal.inventory.validate.btn")); - validateButton.setMnemonic(MessageBundle.getMnemonic("angal.inventory.validate.btn.key")); - if (inventory == null) { - validateButton.setEnabled(false); - } - /* - * validateButton.addActionListener(actionEvent -> { if (inventory == null) { JOptionPane.showMessageDialog(InventoryEdit.this, - * MessageBundle.getMessage("angal.inventorymustsavebeforevalidate"), MessageBundle.getMessage("angal.inventoryoperation.title"), - * JOptionPane.INFORMATION_MESSAGE); return; } if (inventory != null) { if (inventory.getState().equals(InventoryState.State.VALIDATE.getCode())) { - * JOptionPane.showMessageDialog(InventoryEdit.this, MessageBundle.getMessage("angal.inventoryalreadyvalidate"), - * MessageBundle.getMessage("angal.inventoryoperation.title"), JOptionPane.INFORMATION_MESSAGE); return; } } MovStockInsertingManager movManager = new - * MovStockInsertingManager(); MedicalInventoryManager invManager = new MedicalInventoryManager(); Medical medical = null; Double ajustQty = 0.0; - * - * int checkError = 0; String errorList = ""; Movement movement = null; MovementType dischargeType = new - * MedicaldsrstockmovTypeBrowserManager().getMovementType("discharge"); GregorianCalendar today = new GregorianCalendar(); String referenceNumber = ""; - * Lot currentLot = null; // ArrayList movList = new ArrayList(); for (Iterator iterator = - * inventoryRowSearchList.iterator(); iterator.hasNext();) { MedicalInventoryRow medicalInventoryRow = (MedicalInventoryRow) iterator.next(); if - * (medicalInventoryRow.getTheoreticqty() > medicalInventoryRow.getRealqty()) { ajustQty = medicalInventoryRow.getTheoreticqty() - - * medicalInventoryRow.getRealqty(); medical = medicalInventoryRow.getMedical(); currentLot = new Lot("", null, null); if (medicalInventoryRow.getLot() - * != null && !medicalInventoryRow.getLot().getCode().equals("")) { currentLot = medicalInventoryRow.getLot(); } referenceNumber = - * inventory.getInventoryReference(); movement = new Movement(medical, dischargeType, null, currentLot, today, ajustQty.intValue(), null, - * referenceNumber); - * - * if (!movManager.prepareDishargingMovementInventory(movement)) { checkError++; errorList = errorList + medical.getDescription() + " Lot: " + - * currentLot.getCode() + "\n"; } } else if (medicalInventoryRow.getTheoreticqty() < medicalInventoryRow.getRealqty()) { ajustQty = - * medicalInventoryRow.getRealqty() - medicalInventoryRow.getTheoreticqty(); medical = medicalInventoryRow.getMedical(); currentLot = new Lot("", null, - * null); if (medicalInventoryRow.getLot() != null && !medicalInventoryRow.getLot().getCode().equals("")) { currentLot = medicalInventoryRow.getLot(); } - * referenceNumber = inventory.getInventoryReference(); movement = new Movement(medical, dischargeType, null, currentLot, today, -(ajustQty.intValue()), - * null, referenceNumber); - * - * if (!movManager.prepareDishargingMovementInventory(movement)) { checkError++; errorList = errorList + medical.getDescription() + " Lot: " + - * currentLot.getCode() + "\n"; } } - * - * // If new lot has been inserted, create charge movement with theorical qty if (medicalInventoryRow.isNewLot() && - * !medicalInventoryRow.getLot().getCode().equals("")) { movement = new Movement(medicalInventoryRow.getMedical(), dischargeType, null, - * medicalInventoryRow.getLot(), today, -(medicalInventoryRow.getTheoreticqty()), null, inventory.getInventoryReference()); - * - * if (!movManager.prepareNewLotMovementInventory(movement)) { checkError++; errorList = errorList + medical.getDescription() + " Lot: " + - * currentLot.getCode() + "\n"; } } - * - * } // change state of inventory if (checkError == 0) { inventory.setState(InventoryState.State.VALIDATE.getCode()); if - * (invManager.updateMedicalInventory(inventory)) { JOptionPane.showMessageDialog(InventoryEdit.this, - * MessageBundle.getMessage("angal.inventoryvalidate.succes"), MessageBundle.getMessage("angal.inventoryoperation.title"), - * JOptionPane.INFORMATION_MESSAGE); fireInventoryValidated(); columnEditable = columnEditableView; jTableInventoryRow.updateUI(); - * saveButton.setEnabled(false); } else { JOptionPane.showMessageDialog(InventoryEdit.this, MessageBundle.getMessage("angal.inventoryvalidate.error"), - * MessageBundle.getMessage("angal.inventoryoperation.title"), JOptionPane.INFORMATION_MESSAGE); } } else { - * JOptionPane.showMessageDialog(InventoryEdit.this, MessageBundle.getMessage("angal.inventoryvalidate.ajustinventoryerror") + "\n" + errorList, - * MessageBundle.getMessage("angal.inventoryoperation.title"), JOptionPane.INFORMATION_MESSAGE); } - * - * }); - */ - return validateButton; - } private JButton getDeleteButton() { deleteButton = new JButton(MessageBundle.getMessage("angal.common.delete.btn")); deleteButton.setMnemonic(MessageBundle.getMnemonic("angal.common.delete.btn.key")); From 93c849c3bef70080e5efa83779e1009c392724da Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Wed, 20 Mar 2024 11:28:52 +0100 Subject: [PATCH 034/147] add method to store inventory --- bundle/language_en.properties | 12 +- .../gui/InventoryBrowser.java | 6 +- .../medicalinventory/gui/InventoryEdit.java | 184 ++++++++++++------ 3 files changed, 132 insertions(+), 70 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index cbc3916f32..28f20b4c06 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -663,9 +663,11 @@ angal.hospital.thevisitinghourvaluesmustbeintherange0to24.msg angal.hospital.visitduration.txt = Visit duration angal.hospital.visitendhour.txt = Visit end hour angal.hospital.visitstarthour.txt = Visit start hour +angal.inventory.addlotcodebeforeenterthecost = Add lot code before enter the cost. angal.inventory.allproduct.txt = All products angal.inventory.canceled = Canceled angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg = Can not create another inventory with status draft. +angal.inventory.cannotsavelot = Can't save lot. Please verify lot informations and retry. angal.inventory.draft = Draft angal.inventory.inventorybrowser.title = Inventory Browser angal.inventory.mustenterareference.msg = You must enter a reference. @@ -673,16 +675,22 @@ angal.inventory.neweditinventory.title angal.inventory.notdateinfuture.msg = Date in future is not allowed ! angal.inventory.noproduct.msg = Product not found! angal.inventory.referencealreadyused.msg = Reference is already used. -angal.inventoryoperation.save.succes.msg = Inventory saved. -angal.inventoryrowoperation.save.error.msg = Error during some products's recording +angal.inventory.savesucces.msg = Inventory saved. +angal.inventory.error.msg = Error during some products's recording +angal.inventoryrow.cannotchangethepriceofproductwithoutlot.msg = You can not update the unit price of product without lot. angal.inventoryrow.doyoureallywanttodeletethisinventoryrow.msg = Do you really want to delete this inventory row? +angal.inventoryrow.pleaseselectonlyoneinventoryrow.msg = Please select only one inventory row. angal.inventoryoperation.save.error.msg = Inventory not saved angal.inventory.nextarrow.btn = > angal.inventory.arrowprevious.btn = < angal.inventory.product.col = Products +angal.inventory.savelotwithnullprice = Save lot with null price ? +angal.inventory.selectmedical = Select Medical angal.inventory.status.txt = Status angal.inventory.specificproduct.txt = Specific product angal.inventoryrow.theorticqty.col = Theoritic Qty +angal.inventory.totalprice = Total price +angal.inventoryrow.unitprice.col = Unit price angal.inventory.validated = Validated angal.inventory.validate.btn = Validate angal.inventory.validate.btn.key = V diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 77aed854e2..389198255b 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -298,9 +298,6 @@ private GoodDateChooser getJCalendarFrom() { jCalendarFrom = new GoodDateChooser(LocalDate.now()); jCalendarFrom.addDateChangeListener(event -> { dateFrom = jCalendarFrom.getDateStartOfDay(); - if (inventoryList != null) { - inventoryList.clear(); - } InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); TOTAL_ROWS = inventoryModel.getRowCount(); START_INDEX = 0; @@ -415,17 +412,18 @@ class InventoryBrowsingModel extends DefaultTableModel { private static final long serialVersionUID = 1L; public InventoryBrowsingModel() { + inventoryList = new ArrayList<>(); String state = stateComboBox.getSelectedIndex() > 0 ? stateComboBox.getSelectedItem().toString().toLowerCase(): null; String type = InventoryType.principal.toString(); try { inventoryList = medicalInventoryManager.getMedicalInventoryByParams(dateFrom, dateTo, state, type); - System.out.println(inventoryList.size()+" size "); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } } public InventoryBrowsingModel(int start_index, int page_size) { + inventoryList = new ArrayList<>(); String state = stateComboBox.getSelectedIndex() > 0 ? stateComboBox.getSelectedItem().toString().toLowerCase() : null; String type = InventoryType.principal.toString(); diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 56cbf217e2..6df7e97fcd 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -37,11 +37,11 @@ import java.awt.event.FocusListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.math.BigDecimal; import java.text.DecimalFormat; import java.time.LocalDate; import java.time.LocalDateTime; @@ -70,8 +70,11 @@ import javax.swing.event.EventListenerList; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; import org.isf.generaldata.MessageBundle; import org.isf.medicalinventory.manager.MedicalInventoryManager; @@ -108,7 +111,7 @@ public class InventoryEdit extends ModalJFrame { public interface InventoryListener extends EventListener { public void InventoryInserted(AWTEvent e); - + public void InventoryUpdated(AWTEvent e); public void InventoryCancelled(AWTEvent e); @@ -135,9 +138,10 @@ private void fireInventoryInserted() { for (int i = 0; i < listeners.length; i++) ((InventoryListener) listeners[i]).InventoryInserted(event); } - + private void fireInventoryUpdated() { AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { + /** * */ @@ -151,7 +155,6 @@ private void fireInventoryUpdated() { private GoodDateChooser jCalendarInventory; private LocalDateTime dateInventory = TimeTools.getServerDateTime(); - private JLabel jLabelTo; private JPanel panelHeader; private JPanel panelFooter; private JPanel panelContent; @@ -167,10 +170,12 @@ private void fireInventoryUpdated() { MessageBundle.getMessage("angal.wardpharmacy.lotnumber.col").toUpperCase(), MessageBundle.getMessage("angal.medicalstock.duedate.col").toUpperCase(), MessageBundle.getMessage("angal.inventoryrow.theorticqty.col").toUpperCase(), - MessageBundle.getMessage("angal.inventoryrow.realqty.col").toUpperCase() }; - private int[] pColumwidth = { 100, 300, 100, 100, 100, 100 }; - private boolean[] columnEditable = { false, false, false, false, false, true }; - private boolean[] columnEditableView = { false, false, false, false, false, false }; + MessageBundle.getMessage("angal.inventoryrow.realqty.col").toUpperCase(), + MessageBundle.getMessage("angal.inventoryrow.unitprice.col").toUpperCase(), + MessageBundle.getMessage("angal.inventory.totalprice").toUpperCase() }; + private int[] pColumwidth = { 100, 200, 100, 100, 100, 80, 80, 80 }; + private boolean[] columnEditable = { false, false, false, false, false, true, true, false }; + private boolean[] columnEditableView = { false, false, false, false, false, false, false, false }; private MedicalInventory inventory = null; private JRadioButton specificRadio; private JRadioButton allRadio; @@ -209,7 +214,7 @@ private void initComponents() { inventoryRowList = new ArrayList<>(); inventoryRowSearchList = new ArrayList<>(); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - setMinimumSize(new Dimension(850, 580)); + setMinimumSize(new Dimension(950, 580)); setLocationRelativeTo(null); setTitle(MessageBundle.getMessage("angal.inventory.neweditinventory.title")); @@ -354,14 +359,6 @@ public void propertyChange(PropertyChangeEvent evt) { return jCalendarInventory; } - private JLabel getJLabelTo() { - if (jLabelTo == null) { - jLabelTo = new JLabel(); - jLabelTo.setText(MessageBundle.getMessage("angal.common.to.txt")); //$NON-NLS-1$ - } - return jLabelTo; - } - private JButton getNewButton() { saveButton = new JButton(MessageBundle.getMessage("angal.common.save.btn")); saveButton.setMnemonic(MessageBundle.getMnemonic("angal.common.save.btn.key")); @@ -403,6 +400,10 @@ private JButton getNewButton() { for (Iterator iterator = inventoryRowSearchList.iterator(); iterator.hasNext();) { MedicalInventoryRow medicalInventoryRow = (MedicalInventoryRow) iterator.next(); medicalInventoryRow.setInventory(meInventory); + Lot lot = medicalInventoryRow.getLot(); + if (lot != null && lot.getCode().equals("")) { + medicalInventoryRow.setLot(null); + } currentInventoryRow = medicalInventoryRowManager.newMedicalInventoryRow(medicalInventoryRow); if (currentInventoryRow == null) { checkResults++; @@ -411,12 +412,14 @@ private JButton getNewButton() { if (checkResults == 0) { // enable validation mode = "update"; - fireInventoryInserted(); + MessageDialog.info(this, "angal.inventory.savesucces.msg"); + fireInventoryUpdated(); + closeButton.doClick(); } else { - MessageDialog.error(null, "angal.inventoryrowoperation.save.error.msg"); + MessageDialog.error(null, "angal.inventory.error.msg"); } } else { - MessageDialog.error(null, "angal.inventoryoperation.save.error.msg"); + MessageDialog.error(null, "angal.inventory.error.msg"); } } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); @@ -429,22 +432,22 @@ private JButton getDeleteButton() { deleteButton = new JButton(MessageBundle.getMessage("angal.common.delete.btn")); deleteButton.setMnemonic(MessageBundle.getMnemonic("angal.common.delete.btn.key")); deleteButton.addActionListener(actionEvent -> { - if (jTableInventoryRow.getSelectedRowCount() > 1 ) { - MessageDialog.error(this, "angal.medicalstock.pleaseselectonlyonemovement.msg"); + if (jTableInventoryRow.getSelectedRowCount() > 1) { + MessageDialog.error(this, "angal.inventoryrow.pleaseselectonlyoneinventoryrow.msg"); return; } int selectedRow = jTableInventoryRow.getSelectedRow(); if (selectedRow == -1) { - MessageDialog.error(this, "angal.medicalstock.pleaseselectonlyonemovement.msg"); + MessageDialog.error(this, "angal.inventoryrow.pleaseselectonlyoneinventoryrow.msg"); return; } - MedicalInventoryRow selectedInventory = (MedicalInventoryRow)jTableInventoryRow.getValueAt(selectedRow, -1); + MedicalInventoryRow selectedInventory = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRow, -1); int delete = MessageDialog.yesNo(null, "angal.inventoryrow.doyoureallywanttodeletethisinventoryrow.msg"); if (delete == JOptionPane.YES_OPTION) { if (selectedInventory.getInventory() == null) { inventoryRowSearchList.remove(selectedRow); } else { - + } } else { return; @@ -487,18 +490,35 @@ public void valueChanged(ListSelectionEvent e) { } }); - jTableInventoryRow.addKeyListener(new KeyListener() { - - @Override - public void keyTyped(KeyEvent e) { - } + jTableInventoryRow.getModel().addTableModelListener(new TableModelListener() { @Override - public void keyReleased(KeyEvent e) { - } + public void tableChanged(TableModelEvent e) { + + if (e.getType() == TableModelEvent.UPDATE) { + int row = e.getFirstRow(); + int column = e.getColumn(); + TableModel model = (TableModel) e.getSource(); + Object data = model.getValueAt(row, column); + + if (column == 2) { + Object data2 = model.getValueAt(row, 3); + if (!data.toString().equals("") && data2.toString().equals("")) { + jTableInventoryRow.setSurrendersFocusOnKeystroke(true); + jTableInventoryRow.getEditorComponent().requestFocus(); + return; + } + } - @Override - public void keyPressed(KeyEvent e) { + if (column == 3) { + Object data2 = model.getValueAt(row, 2); + if (!data.toString().equals("") && data2.toString().equals("")) { + jTableInventoryRow.setSurrendersFocusOnKeystroke(true); + jTableInventoryRow.getEditorComponent().requestFocus(); + return; + } + } + } } }); DefaultCellEditor cellEditor = new DefaultCellEditor(jTetFieldEditor); @@ -531,6 +551,10 @@ public InventoryRowModel() { return Integer.class; } else if (c == 5) { return Integer.class; + } else if (c == 6) { + return Integer.class; + } else if (c == 7) { + return Integer.class; } return null; } @@ -575,6 +599,20 @@ public Object getValueAt(int r, int c) { } else if (c == 5) { Double dblValue = medInvtRow.getRealQty(); return dblValue.intValue(); + } else if (c == 6) { + if (medInvtRow.getLot() != null) { + if (medInvtRow.getLot().getCost() != null) { + return medInvtRow.getLot().getCost(); + } + } + return 0.0; + } else if (c == 7) { + if (medInvtRow.getLot() != null) { + if (medInvtRow.getLot().getCost() != null) { + return medInvtRow.getRealQty() * medInvtRow.getLot().getCost().doubleValue(); + } + } + return 0.0; } return null; } @@ -593,8 +631,34 @@ public void setValueAt(Object value, int r, int c) { invRow.setRealqty(intValue); inventoryRowSearchList.set(r, invRow); + jTableInventoryRow.updateUI(); + } + if (c == 6) { + Double doubleValue = 0.0; + try { + doubleValue = Double.parseDouble(value.toString()); + } catch (NumberFormatException e) { + doubleValue = 0.0; + } + Lot lot = invRow.getLot(); + if (lot != null) { + if (lot.getCode().equals("")) { + MessageDialog.error(null, "angal.inventoryrow.cannotchangethepriceofproductwithoutlot.msg"); + } else { + lot.setCost(new BigDecimal(doubleValue)); + try { + Lot saveLot = movStockInsertingManager.updateLot(lot); + invRow.setLot(saveLot); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + } + inventoryRowSearchList.set(r, invRow); + jTableInventoryRow.updateUI(); } } + } @Override @@ -766,7 +830,6 @@ private JButton getMoreDataBtn() { } List lots = null; MedicalInventoryRow inventoryRowTemp = null; - double quantityOutsideLot = 0.0; Iterator medicalIterator = medicalList.iterator(); Medical medical; while (medicalIterator.hasNext()) { @@ -776,14 +839,14 @@ private JButton getMoreDataBtn() { } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } - quantityOutsideLot = medical.getTotalQuantity() - getQtyInALot(lots); - if ((lots.size() == 0) || (quantityOutsideLot != 0)) { - inventoryRowTemp = new MedicalInventoryRow(0, quantityOutsideLot, quantityOutsideLot, null, medical, new Lot("", null, null)); - inventoryRowList.add(inventoryRowTemp); - } - for (Lot lot : lots) { - inventoryRowTemp = new MedicalInventoryRow(0, lot.getOverallQuantity(), lot.getOverallQuantity(), null, medical, lot); + if (lots.size() == 0) { + inventoryRowTemp = new MedicalInventoryRow(0, 0.0, 0.0, null, medical, new Lot("", null, null)); inventoryRowList.add(inventoryRowTemp); + } else { + for (Lot lot : lots) { + inventoryRowTemp = new MedicalInventoryRow(0, lot.getOverallQuantity(), lot.getOverallQuantity(), null, medical, lot); + inventoryRowList.add(inventoryRowTemp); + } } } inventoryRowSearchList = new ArrayList(); @@ -795,15 +858,7 @@ private JButton getMoreDataBtn() { }); return moreData; } - - private double getQtyInALot(List lots) { - double qty = 0.0; - for (Iterator iterator = lots.iterator(); iterator.hasNext();) { - Lot lot = (Lot) iterator.next(); - qty = qty + lot.getOverallQuantity(); - } - return qty; - } + private JTextField getCodeTextField() { if (codeTextField == null) { codeTextField = new JTextField(); @@ -879,32 +934,33 @@ private void addInventoryRow(String code) throws OHServiceException { } else { medicalList = medicalBrowsingManager.getMedicals(); } - - double quantityOutsideLot = 0.0; if (mode.equals("new")) { - for (Iterator iterator = medicalList.iterator(); iterator.hasNext();) { + for (Iterator iterator = medicalList.iterator(); iterator.hasNext();) { medical = (Medical) iterator.next(); lots = movStockInsertingManager.getLotByMedical(medical); if (lots.size() == 0) { inventoryRowTemp = new MedicalInventoryRow(0, 0.0, 0.0, null, medical, new Lot("", null, null)); inventoryRowsList.add(inventoryRowTemp); - } - for (Iterator iterator2 = lots.iterator(); iterator2.hasNext();) { - Lot lot = (Lot) iterator2.next(); - inventoryRowTemp = new MedicalInventoryRow(0, lot.getMainStoreQuantity(), lot.getMainStoreQuantity(), null, medical, lot); - inventoryRowsList.add(inventoryRowTemp); + } else { + for (Iterator iterator2 = lots.iterator(); iterator2.hasNext();) { + Lot lot = (Lot) iterator2.next(); + inventoryRowTemp = new MedicalInventoryRow(0, lot.getOverallQuantity(), lot.getOverallQuantity(), null, medical, lot); + inventoryRowsList.add(inventoryRowTemp); + } } } } else if (mode.equals("update")) { if (medical != null) { String medicalCode = medical.getProdCode(); - inventoryRowsList = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()).stream().filter(medRow -> medRow.getMedical().getProdCode().equals(medicalCode)).toList(); + inventoryRowsList = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()).stream() + .filter(medRow -> medRow.getMedical().getProdCode().equals(medicalCode)).toList(); } } for (MedicalInventoryRow inventoryRow : inventoryRowsList) { boolean found = false; for (MedicalInventoryRow row : inventoryRowSearchList) { - if (row.getMedical().getCode().equals(inventoryRow.getMedical().getCode()) && (row.getLot().getCode().equals(inventoryRow.getLot().getCode()))) { + if (row.getMedical().getCode().equals(inventoryRow.getMedical().getCode()) + && (row.getLot().getCode().equals(inventoryRow.getLot().getCode()))) { found = true; } } @@ -935,7 +991,7 @@ private void filterInventoryRow() { private Medical chooseMedical(String text) throws OHServiceException { HashMap medicalMap; List medicals = medicalBrowsingManager.getMedicals(); - if(mode.equals("update")){ + if (mode.equals("update")) { medicals.clear(); List inventoryRowListTemp = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()); for (MedicalInventoryRow medicalInventoryRow : inventoryRowListTemp) { @@ -964,7 +1020,7 @@ private Medical chooseMedical(String text) throws OHServiceException { dialog.setSize(600, 350); dialog.setLocationRelativeTo(null); dialog.setModal(true); - dialog.setTitle(MessageBundle.getMessage("angal.medicalstock.multiplecharging.selectmedical")); + dialog.setTitle(MessageBundle.getMessage("angal.inventory.selectmedical")); framas.setParentFrame(dialog); dialog.setContentPane(framas); dialog.setVisible(true); @@ -974,7 +1030,7 @@ private Medical chooseMedical(String text) throws OHServiceException { } return null; } - + private void ajustWidth() { for (int i = 0; i < pColumwidth.length; i++) { jTableInventoryRow.getColumnModel().getColumn(i).setMinWidth(pColumwidth[i]); From 3b7536e66a9e43d59948d87d3c55b57920f1b4fe Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Wed, 20 Mar 2024 11:54:21 +0100 Subject: [PATCH 035/147] update bundle file --- bundle/language_en.properties | 5 +++-- .../java/org/isf/medicalinventory/gui/InventoryBrowser.java | 4 ++-- .../java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 28f20b4c06..203844e22c 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -427,7 +427,6 @@ angal.common.qty.txt angal.common.quantity.txt = Quantity angal.common.reminder.txt = Reminder angal.common.result.txt = Result -angal.common.reference.label = Reference angal.common.save = Save angal.common.save.btn = Save angal.common.save.btn.key = S @@ -674,6 +673,7 @@ angal.inventory.mustenterareference.msg angal.inventory.neweditinventory.title = Edit an inventory angal.inventory.notdateinfuture.msg = Date in future is not allowed ! angal.inventory.noproduct.msg = Product not found! +angal.inventory.reference.label = Reference angal.inventory.referencealreadyused.msg = Reference is already used. angal.inventory.savesucces.msg = Inventory saved. angal.inventory.error.msg = Error during some products's recording @@ -694,6 +694,8 @@ angal.inventoryrow.unitprice.col angal.inventory.validated = Validated angal.inventory.validate.btn = Validate angal.inventory.validate.btn.key = V +angal.inventory.view.btn = View +angal.inventory.view.btn.key = E angal.inventoryrow.realqty.col = Real Qty angal.lab.allnegative.txt = All negative. angal.lab.blood.txt = Blood @@ -821,7 +823,6 @@ angal.medicals.type angal.medicals.withlot = With lots angal.medicalstock.charge.btn = Charge angal.medicalstock.charge.btn.key = H -angal.medicalstock.chooseamedical.msg = Choose a medical. angal.medicalstock.choosealot.msg = Choose a lot. angal.medicalstock.chooseavalidduedate.msg = Choose a valid due date. angal.medicalstock.chooseavalidmovementdate.msg = Choose a valid movement date. diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 389198255b..6e458599c6 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -356,8 +356,8 @@ private JButton getNewButton() { } private JButton getViewButton() { - jButtonView = new JButton(MessageBundle.getMessage("angal.common.view.btn")); - jButtonView.setMnemonic(MessageBundle.getMnemonic("angal.common.view.btn.key")); + jButtonView = new JButton(MessageBundle.getMessage("angal.inventory.view.btn")); + jButtonView.setMnemonic(MessageBundle.getMnemonic("angal.inventory.view.btn.key")); return jButtonView; } diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 6df7e97fcd..b6ff699cc3 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1047,7 +1047,7 @@ public void setInventoryListeners(EventListenerList inventoryListeners) { private JLabel getReferenceLabel() { if (referenceLabel == null) { - referenceLabel = new JLabel(MessageBundle.getMessage("angal.common.reference.label")); + referenceLabel = new JLabel(MessageBundle.getMessage("angal.inventory.reference.label")); } return referenceLabel; } From d3536407005a6b7f693dea1376b63ae98387680b Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Wed, 20 Mar 2024 12:00:34 +0100 Subject: [PATCH 036/147] update bundler --- bundle/language_en.properties | 3 ++- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 203844e22c..8820ec4f98 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -427,6 +427,7 @@ angal.common.qty.txt angal.common.quantity.txt = Quantity angal.common.reminder.txt = Reminder angal.common.result.txt = Result +angal.common.reference.label = Reference angal.common.save = Save angal.common.save.btn = Save angal.common.save.btn.key = S @@ -673,7 +674,6 @@ angal.inventory.mustenterareference.msg angal.inventory.neweditinventory.title = Edit an inventory angal.inventory.notdateinfuture.msg = Date in future is not allowed ! angal.inventory.noproduct.msg = Product not found! -angal.inventory.reference.label = Reference angal.inventory.referencealreadyused.msg = Reference is already used. angal.inventory.savesucces.msg = Inventory saved. angal.inventory.error.msg = Error during some products's recording @@ -823,6 +823,7 @@ angal.medicals.type angal.medicals.withlot = With lots angal.medicalstock.charge.btn = Charge angal.medicalstock.charge.btn.key = H +angal.medicalstock.chooseamedical.msg = Choose a medical. angal.medicalstock.choosealot.msg = Choose a lot. angal.medicalstock.chooseavalidduedate.msg = Choose a valid due date. angal.medicalstock.chooseavalidmovementdate.msg = Choose a valid movement date. diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index b6ff699cc3..4c6e22ff7f 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1047,7 +1047,7 @@ public void setInventoryListeners(EventListenerList inventoryListeners) { private JLabel getReferenceLabel() { if (referenceLabel == null) { - referenceLabel = new JLabel(MessageBundle.getMessage("angal.inventory.reference.label")); + referenceLabel = new JLabel(MessageBundle.getMessage("aangal.common.reference.label")); } return referenceLabel; } From b402c5659eb3a7473b6880b7059d384b4b8be607 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:51:41 +0100 Subject: [PATCH 037/147] Update bundle/language_en.properties Co-authored-by: David B Malkovsky --- bundle/language_en.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 8820ec4f98..1d98a4fbff 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -663,7 +663,7 @@ angal.hospital.thevisitinghourvaluesmustbeintherange0to24.msg angal.hospital.visitduration.txt = Visit duration angal.hospital.visitendhour.txt = Visit end hour angal.hospital.visitstarthour.txt = Visit start hour -angal.inventory.addlotcodebeforeenterthecost = Add lot code before enter the cost. +angal.inventory.addlotcodebeforeenteringthecost.msg = Add lot code before entering the cost. angal.inventory.allproduct.txt = All products angal.inventory.canceled = Canceled angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg = Can not create another inventory with status draft. From d6f2f34262c00ed0b6e39698d1aea4db5b8c7818 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:51:50 +0100 Subject: [PATCH 038/147] Update bundle/language_en.properties Co-authored-by: David B Malkovsky --- bundle/language_en.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 1d98a4fbff..8734d3d0d4 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -667,7 +667,7 @@ angal.inventory.addlotcodebeforeenteringthecost.msg angal.inventory.allproduct.txt = All products angal.inventory.canceled = Canceled angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg = Can not create another inventory with status draft. -angal.inventory.cannotsavelot = Can't save lot. Please verify lot informations and retry. +angal.inventory.cannotsavelot.msg = Cannot save the lot. Please verify lot information and retry. angal.inventory.draft = Draft angal.inventory.inventorybrowser.title = Inventory Browser angal.inventory.mustenterareference.msg = You must enter a reference. From a511620cc8034302a1b702833733ca050aa63ecb Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:51:58 +0100 Subject: [PATCH 039/147] Update bundle/language_en.properties Co-authored-by: David B Malkovsky --- bundle/language_en.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 8734d3d0d4..7eac4e273c 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -672,7 +672,7 @@ angal.inventory.draft angal.inventory.inventorybrowser.title = Inventory Browser angal.inventory.mustenterareference.msg = You must enter a reference. angal.inventory.neweditinventory.title = Edit an inventory -angal.inventory.notdateinfuture.msg = Date in future is not allowed ! +angal.inventory.notdateinfuture.msg = A date in the future is not allowed. angal.inventory.noproduct.msg = Product not found! angal.inventory.referencealreadyused.msg = Reference is already used. angal.inventory.savesucces.msg = Inventory saved. From cf73fffe582af19a634fda76b6e5274caf7b7d53 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:52:10 +0100 Subject: [PATCH 040/147] Update bundle/language_en.properties Co-authored-by: David B Malkovsky --- bundle/language_en.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 7eac4e273c..105f7d5a75 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -673,7 +673,7 @@ angal.inventory.inventorybrowser.title angal.inventory.mustenterareference.msg = You must enter a reference. angal.inventory.neweditinventory.title = Edit an inventory angal.inventory.notdateinfuture.msg = A date in the future is not allowed. -angal.inventory.noproduct.msg = Product not found! +angal.inventory.noproduct.msg = Product is not found/ angal.inventory.referencealreadyused.msg = Reference is already used. angal.inventory.savesucces.msg = Inventory saved. angal.inventory.error.msg = Error during some products's recording From b22e613ddf33e0da0294cdd0619ad74e9c39573a Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:52:18 +0100 Subject: [PATCH 041/147] Update bundle/language_en.properties Co-authored-by: David B Malkovsky --- bundle/language_en.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 105f7d5a75..78c4a347af 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -677,7 +677,7 @@ angal.inventory.noproduct.msg angal.inventory.referencealreadyused.msg = Reference is already used. angal.inventory.savesucces.msg = Inventory saved. angal.inventory.error.msg = Error during some products's recording -angal.inventoryrow.cannotchangethepriceofproductwithoutlot.msg = You can not update the unit price of product without lot. +angal.inventoryrow.cannotchangethepriceofproductwithoutlot.msg = You cannot update the unit price of a product without a lot. angal.inventoryrow.doyoureallywanttodeletethisinventoryrow.msg = Do you really want to delete this inventory row? angal.inventoryrow.pleaseselectonlyoneinventoryrow.msg = Please select only one inventory row. angal.inventoryoperation.save.error.msg = Inventory not saved From 9f37e114043b8777e3613719e15fd72c8917b880 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:52:26 +0100 Subject: [PATCH 042/147] Update bundle/language_en.properties Co-authored-by: David B Malkovsky --- bundle/language_en.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 78c4a347af..1e349cc426 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -680,7 +680,7 @@ angal.inventory.error.msg angal.inventoryrow.cannotchangethepriceofproductwithoutlot.msg = You cannot update the unit price of a product without a lot. angal.inventoryrow.doyoureallywanttodeletethisinventoryrow.msg = Do you really want to delete this inventory row? angal.inventoryrow.pleaseselectonlyoneinventoryrow.msg = Please select only one inventory row. -angal.inventoryoperation.save.error.msg = Inventory not saved +angal.inventoryoperation.save.error.msg = Inventory not saved. angal.inventory.nextarrow.btn = > angal.inventory.arrowprevious.btn = < angal.inventory.product.col = Products From 961819d02d23d863bcfeb9b04be61da02a947654 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:52:44 +0100 Subject: [PATCH 043/147] Update bundle/language_en.properties Co-authored-by: David B Malkovsky --- bundle/language_en.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 1e349cc426..02a538a522 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -684,7 +684,7 @@ angal.inventoryoperation.save.error.msg angal.inventory.nextarrow.btn = > angal.inventory.arrowprevious.btn = < angal.inventory.product.col = Products -angal.inventory.savelotwithnullprice = Save lot with null price ? +angal.inventory.savelotwithnullprice.msg = Save the lot without a price? angal.inventory.selectmedical = Select Medical angal.inventory.status.txt = Status angal.inventory.specificproduct.txt = Specific product From 9d45a8e060d428d5b9969e0fc4b583d422b1df62 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:52:55 +0100 Subject: [PATCH 044/147] Update bundle/language_en.properties Co-authored-by: David B Malkovsky --- bundle/language_en.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 02a538a522..ccb9d4b0d4 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -685,7 +685,7 @@ angal.inventory.nextarrow.btn angal.inventory.arrowprevious.btn = < angal.inventory.product.col = Products angal.inventory.savelotwithnullprice.msg = Save the lot without a price? -angal.inventory.selectmedical = Select Medical +angal.inventory.selectmedical.msg = Select a medical. angal.inventory.status.txt = Status angal.inventory.specificproduct.txt = Specific product angal.inventoryrow.theorticqty.col = Theoritic Qty From 0c0f26fc30b808a7430cd948b651b40ca6f808b5 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:53:03 +0100 Subject: [PATCH 045/147] Update bundle/language_en.properties Co-authored-by: David B Malkovsky --- bundle/language_en.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index ccb9d4b0d4..9e1566acad 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -874,7 +874,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.selectmedical.title = Choose a medical +angal.medicalstock.multiplecharging.selectmedical.title = Choose a Medical angal.medicalstock.multiplecharging.supplier = Supplier angal.medicalstock.multiplecharging.theinsertedreferencenumberalreadyexists.msg = The inserted reference number already exists. angal.medicalstock.multiplecharging.totalcost = Total cost From 1d092039c1a1edfe3d3213f2fd1495f09965bf90 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:53:10 +0100 Subject: [PATCH 046/147] Update src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java Co-authored-by: David B Malkovsky --- .../java/org/isf/medicalinventory/gui/InventoryBrowser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 6e458599c6..7e494e86c6 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -281,7 +281,7 @@ private GoodDateChooser getJCalendarTo() { TOTAL_ROWS = inventoryModel.getRowCount(); START_INDEX = 0; previous.setEnabled(false); - if (TOTAL_ROWS <= PAGE_SIZE){ + if (TOTAL_ROWS <= PAGE_SIZE) { next.setEnabled(false); } else { next.setEnabled(true); From 6bccd50e3eed31d6b18f6df0552c3708ee43d7b3 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:53:48 +0100 Subject: [PATCH 047/147] Update src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java Co-authored-by: David B Malkovsky --- .../java/org/isf/medicalinventory/gui/InventoryBrowser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 7e494e86c6..07093b3f3d 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -302,7 +302,7 @@ private GoodDateChooser getJCalendarFrom() { TOTAL_ROWS = inventoryModel.getRowCount(); START_INDEX = 0; previous.setEnabled(false); - if (TOTAL_ROWS <= PAGE_SIZE){ + if (TOTAL_ROWS <= PAGE_SIZE) { next.setEnabled(false); } else { next.setEnabled(true); From 0e6b9e63c434711b40c82472ae65ac82a2bf8af7 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:54:45 +0100 Subject: [PATCH 048/147] Update src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java Co-authored-by: David B Malkovsky --- .../java/org/isf/medicalinventory/gui/InventoryBrowser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 07093b3f3d..84b7af6f58 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -554,7 +554,7 @@ public void InventoryCancelled(AWTEvent e) { @Override public void InventoryInserted(AWTEvent e) { - if(inventoryList!=null) { + if (inventoryList != null) { inventoryList.clear(); } jTableInventory.setModel(new InventoryBrowsingModel()); From fb639817fd4f0830130bb258960c322c4d217b85 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Wed, 20 Mar 2024 14:15:03 +0100 Subject: [PATCH 049/147] update bundler, update variable and add licence --- bundle/language_en.properties | 2 - .../gui/InventoryBrowser.java | 66 +++++++++---------- .../medicalinventory/gui/InventoryEdit.java | 19 +----- .../medicalinventory/gui/MedicalPicker.java | 21 ++++++ .../medicalinventory/gui/StockMedModel.java | 21 ++++++ 5 files changed, 78 insertions(+), 51 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 8820ec4f98..28f20b4c06 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -694,8 +694,6 @@ angal.inventoryrow.unitprice.col angal.inventory.validated = Validated angal.inventory.validate.btn = Validate angal.inventory.validate.btn.key = V -angal.inventory.view.btn = View -angal.inventory.view.btn.key = E angal.inventoryrow.realqty.col = Real Qty angal.lab.allnegative.txt = All negative. angal.lab.blood.txt = Blood diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 6e458599c6..8c3fad6751 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -98,8 +98,8 @@ public class InventoryBrowser extends ModalJFrame implements InventoryListener { JComboBox pagesCombo = new JComboBox(); JLabel under = new JLabel("/ 0 Page"); private static int PAGE_SIZE = 50; - private int START_INDEX = 0; - private int TOTAL_ROWS; + private int startIndex = 0; + private int totalRows; private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); private List inventoryList; @@ -135,24 +135,24 @@ public void windowClosing(WindowEvent e) { if (!previous.isEnabled()) { previous.setEnabled(true); } - START_INDEX += PAGE_SIZE; - jTableInventory.setModel(new InventoryBrowsingModel(START_INDEX, PAGE_SIZE)); - if ((START_INDEX + PAGE_SIZE) > TOTAL_ROWS) { + startIndex += PAGE_SIZE; + jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); + if ((startIndex + PAGE_SIZE) > totalRows) { next.setEnabled(false); } - pagesCombo.setSelectedItem(START_INDEX / PAGE_SIZE + 1); + pagesCombo.setSelectedItem(startIndex / PAGE_SIZE + 1); }); previous.addActionListener(actionEvent -> { if (!next.isEnabled()) { next.setEnabled(true); } - START_INDEX -= PAGE_SIZE; - jTableInventory.setModel(new InventoryBrowsingModel(START_INDEX, PAGE_SIZE)); - if (START_INDEX < PAGE_SIZE) { + startIndex -= PAGE_SIZE; + jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); + if (startIndex < PAGE_SIZE) { previous.setEnabled(false); } - pagesCombo.setSelectedItem(START_INDEX / PAGE_SIZE + 1); + pagesCombo.setSelectedItem(startIndex / PAGE_SIZE + 1); }); pagesCombo.addItemListener(new ItemListener() { @@ -161,9 +161,9 @@ public void itemStateChanged(ItemEvent itemEvent) { if (eventID == ItemEvent.SELECTED) { int page_number = (Integer) pagesCombo.getSelectedItem(); - START_INDEX = (page_number - 1) * PAGE_SIZE; + startIndex = (page_number - 1) * PAGE_SIZE; - if ((START_INDEX + PAGE_SIZE) > TOTAL_ROWS) { + if ((startIndex + PAGE_SIZE) > totalRows) { next.setEnabled(false); } else { next.setEnabled(true); @@ -173,8 +173,8 @@ public void itemStateChanged(ItemEvent itemEvent) { } else { previous.setEnabled(true); } - pagesCombo.setSelectedItem(START_INDEX / PAGE_SIZE + 1); - jTableInventory.setModel(new InventoryBrowsingModel(START_INDEX, PAGE_SIZE)); + pagesCombo.setSelectedItem(startIndex / PAGE_SIZE + 1); + jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); pagesCombo.setEnabled(true); } @@ -278,16 +278,16 @@ private GoodDateChooser getJCalendarTo() { inventoryList.clear(); } InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); - TOTAL_ROWS = inventoryModel.getRowCount(); - START_INDEX = 0; + totalRows = inventoryModel.getRowCount(); + startIndex = 0; previous.setEnabled(false); - if (TOTAL_ROWS <= PAGE_SIZE){ + if (totalRows <= PAGE_SIZE){ next.setEnabled(false); } else { next.setEnabled(true); } - jTableInventory.setModel(new InventoryBrowsingModel(START_INDEX, PAGE_SIZE)); - initialiseCombo(TOTAL_ROWS); + jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); + initialiseCombo(totalRows); }); } return jCalendarTo; @@ -299,16 +299,16 @@ private GoodDateChooser getJCalendarFrom() { jCalendarFrom.addDateChangeListener(event -> { dateFrom = jCalendarFrom.getDateStartOfDay(); InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); - TOTAL_ROWS = inventoryModel.getRowCount(); - START_INDEX = 0; + totalRows = inventoryModel.getRowCount(); + startIndex = 0; previous.setEnabled(false); - if (TOTAL_ROWS <= PAGE_SIZE){ + if (totalRows <= PAGE_SIZE){ next.setEnabled(false); } else { next.setEnabled(true); } - jTableInventory.setModel(new InventoryBrowsingModel(START_INDEX, PAGE_SIZE)); - initialiseCombo(TOTAL_ROWS); + jTableInventory.setModel(new InventoryBrowsingModel(startIndex , PAGE_SIZE)); + initialiseCombo(totalRows); }); } return jCalendarFrom; @@ -356,8 +356,8 @@ private JButton getNewButton() { } private JButton getViewButton() { - jButtonView = new JButton(MessageBundle.getMessage("angal.inventory.view.btn")); - jButtonView.setMnemonic(MessageBundle.getMnemonic("angal.inventory.view.btn.key")); + jButtonView = new JButton(MessageBundle.getMessage("angal.common.view.btn")); + jButtonView.setMnemonic(MessageBundle.getMnemonic("angal.common.view.btn.key")); return jButtonView; } @@ -422,13 +422,13 @@ public InventoryBrowsingModel() { } } - public InventoryBrowsingModel(int start_index, int page_size) { + public InventoryBrowsingModel(int startIndex, int pageSize) { inventoryList = new ArrayList<>(); String state = stateComboBox.getSelectedIndex() > 0 ? stateComboBox.getSelectedItem().toString().toLowerCase() : null; String type = InventoryType.principal.toString(); try { - Page medInventorypage = medicalInventoryManager.getMedicalInventoryByParamsPageable(dateFrom, dateTo, state, type, start_index, page_size); + Page medInventorypage = medicalInventoryManager.getMedicalInventoryByParamsPageable(dateFrom, dateTo, state, type, startIndex, pageSize); inventoryList = medInventorypage.getContent(); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); @@ -505,16 +505,16 @@ private JComboBox getComboBox() { } stateComboBox.addActionListener(actionEvent -> { InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); - TOTAL_ROWS = inventoryModel.getRowCount(); - START_INDEX = 0; + totalRows = inventoryModel.getRowCount(); + startIndex = 0; previous.setEnabled(false); - if (TOTAL_ROWS <= PAGE_SIZE) { + if (totalRows <= PAGE_SIZE) { next.setEnabled(false); } else { next.setEnabled(true); } - jTableInventory.setModel(new InventoryBrowsingModel(START_INDEX, PAGE_SIZE)); - initialiseCombo(TOTAL_ROWS); + jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); + initialiseCombo(totalRows); }); } return stateComboBox; diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 4c6e22ff7f..08a537797d 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -51,6 +51,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; import javax.swing.ButtonGroup; import javax.swing.DefaultCellEditor; @@ -125,20 +126,6 @@ public static void removeInventoryListener(InventoryListener listener) { InventoryListeners.remove(InventoryListener.class, listener); } - private void fireInventoryInserted() { - AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { - - /** - * - */ - private static final long serialVersionUID = 1L; - }; - - EventListener[] listeners = InventoryListeners.getListeners(InventoryListener.class); - for (int i = 0; i < listeners.length; i++) - ((InventoryListener) listeners[i]).InventoryInserted(event); - } - private void fireInventoryUpdated() { AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { @@ -188,7 +175,7 @@ private void fireInventoryUpdated() { private JTextField referenceTextField; private JTextField jTetFieldEditor; private JButton moreData; - private boolean MORE_DATA = true; + private static boolean MORE_DATA = true; private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); private MedicalInventoryRowManager medicalInventoryRowManager = Context.getApplicationContext().getBean(MedicalInventoryRowManager.class); private MedicalBrowsingManager medicalBrowsingManager = Context.getApplicationContext().getBean(MedicalBrowsingManager.class); @@ -989,7 +976,7 @@ private void filterInventoryRow() { } private Medical chooseMedical(String text) throws OHServiceException { - HashMap medicalMap; + Map medicalMap; List medicals = medicalBrowsingManager.getMedicals(); if (mode.equals("update")) { medicals.clear(); diff --git a/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java b/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java index a9bf27fc49..e07f8b7565 100644 --- a/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java +++ b/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java @@ -1,3 +1,24 @@ +/* + * Open Hospital (www.open-hospital.org) + * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * + * Open Hospital is a free and open source software for healthcare data management. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * https://www.gnu.org/licenses/gpl-3.0-standalone.html + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.isf.medicalinventory.gui; import java.awt.BorderLayout; diff --git a/src/main/java/org/isf/medicalinventory/gui/StockMedModel.java b/src/main/java/org/isf/medicalinventory/gui/StockMedModel.java index 1bdf3f0287..ed28ae3c87 100644 --- a/src/main/java/org/isf/medicalinventory/gui/StockMedModel.java +++ b/src/main/java/org/isf/medicalinventory/gui/StockMedModel.java @@ -1,3 +1,24 @@ +/* + * Open Hospital (www.open-hospital.org) + * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * + * Open Hospital is a free and open source software for healthcare data management. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * https://www.gnu.org/licenses/gpl-3.0-standalone.html + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.isf.medicalinventory.gui; import java.util.ArrayList; From 99f7e5fa80263cc40c44604ca1f7666ea322b43e Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Wed, 20 Mar 2024 14:42:03 +0100 Subject: [PATCH 050/147] update InventoryEdit --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 08a537797d..a1d83ac29e 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1007,7 +1007,7 @@ private Medical chooseMedical(String text) throws OHServiceException { dialog.setSize(600, 350); dialog.setLocationRelativeTo(null); dialog.setModal(true); - dialog.setTitle(MessageBundle.getMessage("angal.inventory.selectmedical")); + dialog.setTitle(MessageBundle.getMessage("angal.medicalstock.multiplecharging.selectmedical.title")); framas.setParentFrame(dialog); dialog.setContentPane(framas); dialog.setVisible(true); From b74f7c671d25e1ae23abd5b4b280dc456ee9e81b Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Wed, 20 Mar 2024 16:20:26 +0100 Subject: [PATCH 051/147] update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index a1d83ac29e..a7bf48ac56 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1034,7 +1034,7 @@ public void setInventoryListeners(EventListenerList inventoryListeners) { private JLabel getReferenceLabel() { if (referenceLabel == null) { - referenceLabel = new JLabel(MessageBundle.getMessage("aangal.common.reference.label")); + referenceLabel = new JLabel(MessageBundle.getMessage("angal.common.reference.label")); } return referenceLabel; } From 13e0f477d0d31256388b0aebb92feb24fec91476 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Thu, 21 Mar 2024 08:06:48 +0100 Subject: [PATCH 052/147] format the code --- .../gui/InventoryBrowser.java | 19 ++++++++----------- .../medicalinventory/gui/InventoryEdit.java | 17 ++--------------- .../medicalinventory/gui/MedicalPicker.java | 11 ++--------- .../medicalinventory/gui/StockMedModel.java | 19 +++++++++---------- 4 files changed, 21 insertions(+), 45 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 6be4345274..02367ea11b 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -273,15 +273,12 @@ private GoodDateChooser getJCalendarTo() { if (jCalendarTo == null) { jCalendarTo = new GoodDateChooser(LocalDate.now()); jCalendarTo.addDateChangeListener(event -> { - dateTo = jCalendarTo.getDateStartOfDay(); - if (inventoryList != null) { - inventoryList.clear(); - } + dateTo = jCalendarTo.getDateEndOfDay(); InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); totalRows = inventoryModel.getRowCount(); startIndex = 0; previous.setEnabled(false); - if (totalRows <= PAGE_SIZE){ + if (totalRows <= PAGE_SIZE) { next.setEnabled(false); } else { next.setEnabled(true); @@ -302,7 +299,7 @@ private GoodDateChooser getJCalendarFrom() { totalRows = inventoryModel.getRowCount(); startIndex = 0; previous.setEnabled(false); - if (totalRows <= PAGE_SIZE){ + if (totalRows <= PAGE_SIZE) { next.setEnabled(false); } else { next.setEnabled(true); @@ -406,9 +403,6 @@ private JTable getJTableInventory() { class InventoryBrowsingModel extends DefaultTableModel { - /** - * - */ private static final long serialVersionUID = 1L; public InventoryBrowsingModel() { @@ -449,8 +443,9 @@ public InventoryBrowsingModel(int startIndex, int pageSize) { } public int getRowCount() { - if (inventoryList == null) + if (inventoryList == null) { return 0; + } return inventoryList.size(); } @@ -562,7 +557,9 @@ public void InventoryInserted(AWTEvent e) { @Override public void InventoryUpdated(AWTEvent e) { - if(inventoryList!=null) inventoryList.clear(); + if(inventoryList != null) { + inventoryList.clear(); + } jTableInventory.setModel(new InventoryBrowsingModel()); } } diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index a7bf48ac56..c4fb5bc910 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -102,9 +102,6 @@ public class InventoryEdit extends ModalJFrame { - /** - * - */ private static final long serialVersionUID = 1L; private static EventListenerList InventoryListeners = new EventListenerList(); @@ -128,10 +125,6 @@ public static void removeInventoryListener(InventoryListener listener) { private void fireInventoryUpdated() { AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { - - /** - * - */ private static final long serialVersionUID = 1L; }; @@ -332,15 +325,12 @@ private JPanel getPanelFooter() { private GoodDateChooser getJCalendarFrom() { if (jCalendarInventory == null) { - dateInventory = LocalDateTime.now(); jCalendarInventory = new GoodDateChooser(LocalDate.now()); if (inventory != null) { jCalendarInventory.setDate(inventory.getInventoryDate().toLocalDate()); } - jCalendarInventory.addPropertyChangeListener("date", new PropertyChangeListener() { - - public void propertyChange(PropertyChangeEvent evt) { - } + jCalendarInventory.addDateChangeListener(event -> { + dateInventory = jCalendarInventory.getDateStartOfDay(); }); } return jCalendarInventory; @@ -657,9 +647,6 @@ public boolean isCellEditable(int rowIndex, int columnIndex) { class DecimalFormatRenderer extends DefaultTableCellRenderer { - /** - * - */ private static final long serialVersionUID = 1L; private final DecimalFormat formatter = new DecimalFormat("#,##0.00"); diff --git a/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java b/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java index e07f8b7565..e4509c2d33 100644 --- a/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java +++ b/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java @@ -58,11 +58,7 @@ public class MedicalPicker extends JPanel { OhDefaultCellRenderer cellRenderer = new OhDefaultCellRenderer(); - /** - * - */ private static final long serialVersionUID = 1L; - private Collection medicalMapValues = new ArrayList(); private String searchCode; private JButton jButtonSelect; @@ -146,9 +142,7 @@ public void mouseMoved(MouseEvent e) { } @Override - public void mouseDragged(MouseEvent e) { - - } + public void mouseDragged(MouseEvent e) {} }); jTableData.addMouseListener(new MouseAdapter() { @Override @@ -228,7 +222,7 @@ public void insertUpdate(DocumentEvent e) { TableColumn column; for(int i = 0; i < 2; i++) { column = jTableData.getColumnModel().getColumn(i); - if(i == 1) { + if (i == 1) { column.setPreferredWidth(375); } else { column.setPreferredWidth(100); @@ -327,7 +321,6 @@ private void validateSelection() { this.setSelectedRow(this.jTableData.getSelectedRow()); this.setVisible(false); this.getParentFrame().dispose(); - } private void jButtonSelectActionPerformed(ActionEvent evt) { diff --git a/src/main/java/org/isf/medicalinventory/gui/StockMedModel.java b/src/main/java/org/isf/medicalinventory/gui/StockMedModel.java index ed28ae3c87..771664a2bf 100644 --- a/src/main/java/org/isf/medicalinventory/gui/StockMedModel.java +++ b/src/main/java/org/isf/medicalinventory/gui/StockMedModel.java @@ -31,9 +31,7 @@ import org.isf.utils.db.NormalizeString; public class StockMedModel extends DefaultTableModel { - /** - * - */ + private static final long serialVersionUID = 1L; private ArrayList medList; private ArrayList initList=new ArrayList(); @@ -43,8 +41,9 @@ public StockMedModel(ArrayList meds) { initList.addAll(medList); } public int getRowCount() { - if (medList == null) + if (medList == null) { return 0; + } return medList.size(); } @@ -55,7 +54,7 @@ public String getColumnName(int c) { if (c == 1) { return MessageBundle.getMessage("angal.common.description.txt").toUpperCase(); } - return ""; //$NON-NLS-1$ + return ""; } public int getColumnCount() { @@ -74,20 +73,20 @@ public Object getValueAt(int r, int c) { return null; } - public void filter(String searchValue){ + public void filter(String searchValue) { medList.clear(); for (Iterator iterator = initList.iterator(); iterator.hasNext();) { Medical med = (Medical) iterator.next(); - if(med.getProdCode().trim().equalsIgnoreCase(searchValue.trim())){ + if (med.getProdCode().trim().equalsIgnoreCase(searchValue.trim())) { medList.add(med); } - else if(NormalizeString.normalizeContains(med.getProdCode().toLowerCase().trim()+med.getDescription().toLowerCase(), searchValue.toLowerCase().trim())){ + else if (NormalizeString.normalizeContains(med.getProdCode().toLowerCase().trim()+med.getDescription().toLowerCase(), searchValue.toLowerCase().trim())) { medList.add(med); } } } - public Medical getMedicalAtRow(int row){ - if(medList.size()>row && row>=0){ + public Medical getMedicalAtRow(int row) { + if (medList.size() > row && row >= 0) { return medList.get(row); } return null; From 3ee5ac973e2b350328419025b6244b41b5066860 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Mon, 25 Mar 2024 11:57:10 +0100 Subject: [PATCH 053/147] update enum InventoryType: change principal to main --- .../java/org/isf/medicalinventory/gui/InventoryBrowser.java | 4 ++-- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- src/main/java/org/isf/utils/jobjects/InventoryType.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 02367ea11b..a4083f31a6 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -408,7 +408,7 @@ class InventoryBrowsingModel extends DefaultTableModel { public InventoryBrowsingModel() { inventoryList = new ArrayList<>(); String state = stateComboBox.getSelectedIndex() > 0 ? stateComboBox.getSelectedItem().toString().toLowerCase(): null; - String type = InventoryType.principal.toString(); + String type = InventoryType.main.toString(); try { inventoryList = medicalInventoryManager.getMedicalInventoryByParams(dateFrom, dateTo, state, type); } catch (OHServiceException e) { @@ -419,7 +419,7 @@ public InventoryBrowsingModel() { public InventoryBrowsingModel(int startIndex, int pageSize) { inventoryList = new ArrayList<>(); String state = stateComboBox.getSelectedIndex() > 0 ? stateComboBox.getSelectedItem().toString().toLowerCase() : null; - String type = InventoryType.principal.toString(); + String type = InventoryType.main.toString(); try { Page medInventorypage = medicalInventoryManager.getMedicalInventoryByParamsPageable(dateFrom, dateTo, state, type, startIndex, pageSize); diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index c4fb5bc910..6417647745 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -368,7 +368,7 @@ private JButton getNewButton() { inventory.setInventoryDate(dateInventory); inventory.setStatus(State); inventory.setUser(user); - inventory.setInventoryType(InventoryType.principal.toString()); + inventory.setInventoryType(InventoryType.main.toString()); MedicalInventory meInventory; try { meInventory = medicalInventoryManager.newMedicalInventory(inventory); diff --git a/src/main/java/org/isf/utils/jobjects/InventoryType.java b/src/main/java/org/isf/utils/jobjects/InventoryType.java index a2f7e992cb..7edb00d6c1 100644 --- a/src/main/java/org/isf/utils/jobjects/InventoryType.java +++ b/src/main/java/org/isf/utils/jobjects/InventoryType.java @@ -23,5 +23,5 @@ public enum InventoryType { - principal, ward + main, ward } From e050dedfac781366c97f03e8b383fdc7992bc019 Mon Sep 17 00:00:00 2001 From: mwithi Date: Tue, 23 Apr 2024 19:16:12 +0200 Subject: [PATCH 054/147] Replace deprecated method --- .../gui/InventoryBrowser.java | 110 +++++++++--------- 1 file changed, 56 insertions(+), 54 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index a4083f31a6..ed93285787 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -21,6 +21,8 @@ */ package org.isf.medicalinventory.gui; +import static org.isf.utils.Constants.DATE_TIME_FORMATTER; + import java.awt.AWTEvent; import java.awt.BorderLayout; import java.awt.Dimension; @@ -65,14 +67,12 @@ import org.isf.utils.time.TimeTools; import org.springframework.data.domain.Page; -import static org.isf.utils.Constants.DATE_TIME_FORMATTER; - public class InventoryBrowser extends ModalJFrame implements InventoryListener { private GoodDateChooser jCalendarTo; private GoodDateChooser jCalendarFrom; - private LocalDateTime dateFrom = TimeTools.getServerDateTime(); - private LocalDateTime dateTo = TimeTools.getServerDateTime(); + private LocalDateTime dateFrom = TimeTools.getNow(); + private LocalDateTime dateTo = TimeTools.getNow(); private JLabel jLabelTo; private JLabel jLabelFrom; private JPanel panelHeader; @@ -123,36 +123,37 @@ private void initComponents() { getContentPane().add(panelFooter, BorderLayout.SOUTH); ajustWidth(); - addWindowListener(new WindowAdapter(){ + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { dispose(); - } + } }); pagesCombo.setEditable(true); previous.setEnabled(false); next.setEnabled(false); next.addActionListener(actionEvent -> { - if (!previous.isEnabled()) { - previous.setEnabled(true); - } - startIndex += PAGE_SIZE; - jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); - if ((startIndex + PAGE_SIZE) > totalRows) { - next.setEnabled(false); - } - pagesCombo.setSelectedItem(startIndex / PAGE_SIZE + 1); + if (!previous.isEnabled()) { + previous.setEnabled(true); + } + startIndex += PAGE_SIZE; + jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); + if ((startIndex + PAGE_SIZE) > totalRows) { + next.setEnabled(false); + } + pagesCombo.setSelectedItem(startIndex / PAGE_SIZE + 1); }); previous.addActionListener(actionEvent -> { - if (!next.isEnabled()) { - next.setEnabled(true); - } - startIndex -= PAGE_SIZE; - jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); - if (startIndex < PAGE_SIZE) { - previous.setEnabled(false); - } - pagesCombo.setSelectedItem(startIndex / PAGE_SIZE + 1); + if (!next.isEnabled()) { + next.setEnabled(true); + } + startIndex -= PAGE_SIZE; + jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); + if (startIndex < PAGE_SIZE) { + previous.setEnabled(false); + } + pagesCombo.setSelectedItem(startIndex / PAGE_SIZE + 1); }); pagesCombo.addItemListener(new ItemListener() { @@ -297,14 +298,14 @@ private GoodDateChooser getJCalendarFrom() { dateFrom = jCalendarFrom.getDateStartOfDay(); InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); totalRows = inventoryModel.getRowCount(); - startIndex = 0; + startIndex = 0; previous.setEnabled(false); if (totalRows <= PAGE_SIZE) { next.setEnabled(false); } else { next.setEnabled(true); } - jTableInventory.setModel(new InventoryBrowsingModel(startIndex , PAGE_SIZE)); + jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); initialiseCombo(totalRows); }); } @@ -342,12 +343,12 @@ private JButton getNewButton() { if (medicalInventories.size() == 0) { InventoryEdit inventoryEdit = new InventoryEdit(); InventoryEdit.addInventoryListener(InventoryBrowser.this); - inventoryEdit.showAsModal(InventoryBrowser.this); + inventoryEdit.showAsModal(InventoryBrowser.this); } else { MessageDialog.error(null, "angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg"); return; } - + }); return jButtonNew; } @@ -379,7 +380,7 @@ private JButton getCloseButton() { jButtonClose = new JButton(MessageBundle.getMessage("angal.common.cancel.btn")); jButtonClose.setMnemonic(MessageBundle.getMnemonic("angal.common.cancel.btn.key")); jButtonClose.addActionListener(actionEvent -> { - dispose(); + dispose(); }); return jButtonClose; } @@ -407,26 +408,27 @@ class InventoryBrowsingModel extends DefaultTableModel { public InventoryBrowsingModel() { inventoryList = new ArrayList<>(); - String state = stateComboBox.getSelectedIndex() > 0 ? stateComboBox.getSelectedItem().toString().toLowerCase(): null; + String state = stateComboBox.getSelectedIndex() > 0 ? stateComboBox.getSelectedItem().toString().toLowerCase() : null; String type = InventoryType.main.toString(); try { inventoryList = medicalInventoryManager.getMedicalInventoryByParams(dateFrom, dateTo, state, type); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); - } + } } - + public InventoryBrowsingModel(int startIndex, int pageSize) { inventoryList = new ArrayList<>(); String state = stateComboBox.getSelectedIndex() > 0 ? stateComboBox.getSelectedItem().toString().toLowerCase() : null; String type = InventoryType.main.toString(); - + try { - Page medInventorypage = medicalInventoryManager.getMedicalInventoryByParamsPageable(dateFrom, dateTo, state, type, startIndex, pageSize); + Page medInventorypage = medicalInventoryManager.getMedicalInventoryByParamsPageable(dateFrom, dateTo, state, type, startIndex, + pageSize); inventoryList = medInventorypage.getContent(); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); - } + } } public Class< ? > getColumnClass(int c) { @@ -448,7 +450,7 @@ public int getRowCount() { } return inventoryList.size(); } - + public String getColumnName(int c) { return pColums[c]; } @@ -469,10 +471,10 @@ public Object getValueAt(int r, int c) { return medInvt.getStatus(); } else if (c == 3) { return medInvt.getUser(); - } + } return null; } - + @Override public boolean isCellEditable(int arg0, int arg1) { return false; @@ -496,20 +498,20 @@ private JComboBox getComboBox() { stateComboBox = new JComboBox(); stateComboBox.addItem(""); for (InventoryStatus currentState : InventoryStatus.values()) { - stateComboBox.addItem(MessageBundle.getMessage("angal.inventory."+currentState)); + stateComboBox.addItem(MessageBundle.getMessage("angal.inventory." + currentState)); } stateComboBox.addActionListener(actionEvent -> { - InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); - totalRows = inventoryModel.getRowCount(); - startIndex = 0; - previous.setEnabled(false); - if (totalRows <= PAGE_SIZE) { - next.setEnabled(false); - } else { - next.setEnabled(true); - } - jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); - initialiseCombo(totalRows); + InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); + totalRows = inventoryModel.getRowCount(); + startIndex = 0; + previous.setEnabled(false); + if (totalRows <= PAGE_SIZE) { + next.setEnabled(false); + } else { + next.setEnabled(true); + } + jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); + initialiseCombo(totalRows); }); } return stateComboBox; @@ -541,10 +543,10 @@ public void initialiseCombo(int total_rows) { @Override public void InventoryCancelled(AWTEvent e) { - if (inventoryList!=null) { + if (inventoryList != null) { inventoryList.clear(); } - jTableInventory.setModel(new InventoryBrowsingModel()); + jTableInventory.setModel(new InventoryBrowsingModel()); } @Override @@ -554,10 +556,10 @@ public void InventoryInserted(AWTEvent e) { } jTableInventory.setModel(new InventoryBrowsingModel()); } - + @Override public void InventoryUpdated(AWTEvent e) { - if(inventoryList != null) { + if (inventoryList != null) { inventoryList.clear(); } jTableInventory.setModel(new InventoryBrowsingModel()); From 2eacd8a327daba4a6c778809b0eb4e840d59c54f Mon Sep 17 00:00:00 2001 From: mwithi Date: Thu, 25 Apr 2024 10:04:39 +0200 Subject: [PATCH 055/147] Replace deprecated method --- .../java/org/isf/medicalinventory/gui/InventoryEdit.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 6417647745..9464b39558 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -39,8 +39,6 @@ import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.math.BigDecimal; import java.text.DecimalFormat; import java.time.LocalDate; @@ -125,6 +123,7 @@ public static void removeInventoryListener(InventoryListener listener) { private void fireInventoryUpdated() { AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { + private static final long serialVersionUID = 1L; }; @@ -134,7 +133,7 @@ private void fireInventoryUpdated() { } private GoodDateChooser jCalendarInventory; - private LocalDateTime dateInventory = TimeTools.getServerDateTime(); + private LocalDateTime dateInventory = TimeTools.getNow(); private JPanel panelHeader; private JPanel panelFooter; private JPanel panelContent; @@ -832,7 +831,7 @@ private JButton getMoreDataBtn() { }); return moreData; } - + private JTextField getCodeTextField() { if (codeTextField == null) { codeTextField = new JTextField(); From 7022b041fc35136634fa6306767bae601c6ef2c2 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Wed, 24 Jul 2024 20:46:03 +0100 Subject: [PATCH 056/147] OP-1185 | Update Inventory (#1975) * start with update issue * update src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java * start with update inventory * add method to update medical inventory * use the good Message Dialog * update bundle/language_en.properties * apply changes * update src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java * add possibility to view inventory * update bundle/language_en.properties * update inventory: apply check if is AUTOMATICLOT_IN is set to yes before save * remove .dist file * update .gitignore * revert .dist file * hidden column Lot code when AUTOMATICLOT_IN is set to yes and Prise column when LOTWITHCOST is set to no * restore MovStockMultipleDischarging.java * fix null pointer exception * add new field' * fix bug * update InventoryEdit.java * add posibility to add many medical * remove .factorypath * add logic of view button * add check of same lot for same medical * add posibility to delete multiple inventory row * fix error index out of bounds * update delete Inventory row * update variable name * update action to edit due date * add method to generate lot code * remove method generateLotCode() * update InventoryEdit * add new column and button to store lot informations * add logic on lot button * add status in inventory row form * fix index out of bound exception * add all products in inventoryrow * OP-1278 resource bundle addition (#2015) * update InventoryEdit.java * update InventoryEdit.java * fix error on bundle file * Chore: update Intellij settings to match Eclipse (#2019) * update InventoryEdit.java * Hibernate renamed org.hibernate.type to org.hibernate.orm.jdbc.bind (#2021) * fix bug * add validation on close button * add listener on comboBox of supplier, destination, charge, discharge * update InventoryEdit.java * fix bug related to close button * fixed bug on InventoryEdit and InventoryBrowser * update InventoryEdit.java * update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java * fix the check of inventory properties during update mode * change the method that fetch lot * disable futur date on calendar * update InventoryEdit.java * update bundle * remove InventoryStatus and Inventory type to medicalinventory package and update methods * use MainStoreQuantity instead of OverAllQuantity in inventory row * hidden total prise when LOTWITHCOST=no * remove useless code * update InventoryEdit * use only on try block in save button * fix nullpointeur exception and error data has been update by someonelse * fix error * fix error after pull * update InventoryEdit.java --------- Co-authored-by: ArnaudFonzam Co-authored-by: David B Malkovsky Co-authored-by: Alessandro Domanico --- .../OpenHospital-code-style-configuration.xml | 24 +- bundle/language_en.properties | 63 +- pom.xml | 4 +- rsc/log4j2-spring.properties.dist | 2 +- .../gui/InventoryBrowser.java | 140 +- .../medicalinventory/gui/InventoryEdit.java | 1601 ++++++++++++----- .../gui/MovStockMultipleCharging.java | 2 +- .../gui/MovStockMultipleDischarging.java | 2 +- .../isf/utils/jobjects/InventoryStatus.java | 28 - .../org/isf/utils/jobjects/InventoryType.java | 27 - .../org/isf/utils/jobjects/ModalJFrame.java | 2 +- 11 files changed, 1350 insertions(+), 545 deletions(-) delete mode 100644 src/main/java/org/isf/utils/jobjects/InventoryStatus.java delete mode 100644 src/main/java/org/isf/utils/jobjects/InventoryType.java diff --git a/.ide-settings/idea/OpenHospital-code-style-configuration.xml b/.ide-settings/idea/OpenHospital-code-style-configuration.xml index 6f1e2f5576..87a358cd6c 100644 --- a/.ide-settings/idea/OpenHospital-code-style-configuration.xml +++ b/.ide-settings/idea/OpenHospital-code-style-configuration.xml @@ -1,6 +1,8 @@ \ No newline at end of file diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 04bec2c004..6ae75bb420 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -8,6 +8,7 @@ angal.admission.admissionanddischarge.title angal.admission.admissiondate.border = Admission Date * angal.admission.admissiondate.txt = Admission Date * angal.admission.admissiondatecannotbeempty.msg = Admission date cannot be empty. +angal.admission.admissionpatientcannotbeempty.msg = Admission patient cannot be empty. angal.admission.admissionstatus.border = Admission Status angal.admission.admissiontype.border = Admission Type * angal.admission.admissionwardcannotbeempty.msg = Admission ward cannot be empty. @@ -663,38 +664,74 @@ angal.hospital.thevisitinghourvaluesmustbeintherange0to24.msg angal.hospital.visitduration.txt = Visit duration angal.hospital.visitendhour.txt = Visit end hour angal.hospital.visitstarthour.txt = Visit start hour -angal.inventory.addlotcodebeforeenteringthecost.msg = Add lot code before entering the cost. angal.inventory.allproduct.txt = All products angal.inventory.canceled = Canceled -angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg = Can not create another inventory with status draft. -angal.inventory.cannotsavelot.msg = Cannot save the lot. Please verify lot information and retry. +angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg = Cannot create another inventory with status draft. +angal.inventory.cannotsavelot.msg = Cannot save the lot. Please verify lot information and retry. +angal.inventory.cannotsaveinventorywithoutproducts.msg = Cannot save inventory without products. +angal.inventory.cancelednoteditable.msg = A canceled inventory can not be modified. +angal.inventory.chargetype.label = Charge Type +angal.inventory.clean.btn = Clean Table +angal.inventory.clean.btn.key = T +angal.inventory.destination.label = Destination +angal.inventory.dischargetype.label = Discharge Type angal.inventory.draft = Draft angal.inventory.inventorybrowser.title = Inventory Browser +angal.inventory.id.col = Id angal.inventory.mustenterareference.msg = You must enter a reference. -angal.inventory.neweditinventory.title = Edit an inventory +angal.inventory.newinventory.title = New inventory +angal.inventory.editinventory.title = Edit inventory +angal.inventory.noteditable.msg = A validated inventory cannot be modified. angal.inventory.notdateinfuture.msg = A date in the future is not allowed. -angal.inventory.noproduct.msg = Product is not found/ +angal.inventory.noproduct.msg = Product is not found. angal.inventory.referencealreadyused.msg = Reference is already used. -angal.inventory.savesucces.msg = Inventory saved. -angal.inventory.error.msg = Error during some products's recording -angal.inventoryrow.cannotchangethepriceofproductwithoutlot.msg = You cannot update the unit price of a product without a lot. -angal.inventoryrow.doyoureallywanttodeletethisinventoryrow.msg = Do you really want to delete this inventory row? +angal.inventory.savesuccess.msg = Inventory saved. +angal.inventory.status.label = Status: +angal.inventory.new.col = New +angal.inventory.lot.btn = Lot +angal.inventory.lot.btn.key = L +angal.inventory.supplier.label = Supplier +angal.inventoryrow.addnotyetlistedproducts.title = Add products +angal.inventoryrow.doyoureallywanttodeletethisinventoryrow.msg = Do you really want to delete this/those inventory(ies) row(s)? +angal.inventoryrow.doyoureallywanttocleanthistable.msg = Do you really want to clean this table? +angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg = Do you want to add all not yet listed products? +angal.inventoryrow.doyouwanttocontinueediting.msg = Do you want to continue editing? +angal.inventoryrow.doyouwanttosavethechanges.msg = Do you want to save the changes? +angal.inventoryrow.notfound.msg = Inventory not found. +angal.inventoryrow.invalidquantity.msg = Invalid quantity. +angal.inventory.pleaseinsertavalidinventorydate.msg = Please insert a valid inventory date. angal.inventoryrow.pleaseselectonlyoneinventoryrow.msg = Please select only one inventory row. +angal.inventoryrow.pleaseselectatleastoneinventoryrow.msg = Please select at least one inventory row. +angal.inventoryrow.pleaseselectoneinventoryrow.msg = Please select one inventory row. +angal.inventoryrow.thislotcodealreadyexists.msg = This lot code already exists. Please change it. +angal.inventory.inventoryisalreadysaved.msg = This inventory is already saved. Please enter at least one inventory row before continue. +angal.inventory.pleaseselectonlyoneinventory.msg = Please select only one inventory. +angal.inventory.pleaseinsertinventory.msg = Please add and inventory in this inventory row. +angal.inventory.pleaseselectinventory.msg = Please select inventory. angal.inventoryoperation.save.error.msg = Inventory not saved. angal.inventory.nextarrow.btn = > angal.inventory.arrowprevious.btn = < angal.inventory.product.col = Products +angal.inventory.productalreadyexist.msg = {0} already exist in the list. do you still like to add it? angal.inventory.savelotwithnullprice.msg = Save the lot without a price? angal.inventory.selectmedical.msg = Select a medical. angal.inventory.status.txt = Status angal.inventory.specificproduct.txt = Specific product -angal.inventoryrow.theorticqty.col = Theoritic Qty +angal.inventoryrow.theoreticqty.col = Theoretic Qty angal.inventory.totalprice = Total price angal.inventoryrow.unitprice.col = Unit price +angal.inventory.update.error.msg = Inventory not updated. +angal.inventory.update.success.msg = Inventory updated. angal.inventory.validated = Validated +angal.inventory.done = Done angal.inventory.validate.btn = Validate angal.inventory.validate.btn.key = V +angal.inventory.validatednoteditable.msg = A validated inventory cannot be modified. +angal.inventory.viewinventory.title = View Inventory +angal.inventory.youhavealreadyaddedallproduct.msg = You have already added all the products. angal.inventoryrow.realqty.col = Real Qty +angal.invetory.allmedicalisalreadypresent.msg = All medical is already present in this list. +angal.invetory.allmedicaladdedsuccessfully.msg = All medical are added successfully. angal.lab.allnegative.txt = All negative. angal.lab.blood.txt = Blood angal.lab.cfs.txt = CFS @@ -1343,10 +1380,10 @@ angal.operationrow.not.found.msg angal.operationrowedit.operation = Operation angal.operationrowedit.remark = Remarks angal.operationrowedit.saveerror = Error occurs during processing -angal.operationrowedit.savesucces = Operation Saved! +angal.operationrowedit.savesuccess = Operation Saved. angal.operationrowedit.unitetrans = Trans Unit angal.operationrowedit.updateerror = Error occurs during processing -angal.operationrowedit.updatesucces = Operation updated +angal.operationrowedit.updatesuccess = Operation updated. angal.operationrowedit.warningdateafter = You must choose a date after OPD'S date! angal.operationrowedit.warningdateope = You must choose an operation and a date angal.operationrowlist.add.btn = Add @@ -1857,7 +1894,7 @@ angal.xmpp.isnowoffline.txt angal.xmpp.isnowonline.txt = is now online angal.xmpp.me.txt = me angal.xmpp.sendfile.txt = Send File -angal.xmpp.thefiletransferofbetweenyouandendedsuccesfully.fmt.msg = the file transfer of {0} between you and {1} ended successfully +angal.xmpp.thefiletransferofbetweenyouandendedsuccessfully.fmt.msg = the file transfer of {0} between you and {1} ended successfully angal.xmpp.userinfo.fmt.txt = User: {0}\nInfo: {1} angal.xmpp.usersinfo.border = User's Info angal.xmpp.wantstosharewithyouthisreport.fmt.msg = \n*** {0} wants to share with you this report: {1}\n diff --git a/pom.xml b/pom.xml index bc86661580..ad543da9e9 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.2.5 + 3.3.0 org.apache.maven.plugins @@ -212,7 +212,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.4.1 + 3.4.2 diff --git a/rsc/log4j2-spring.properties.dist b/rsc/log4j2-spring.properties.dist index a16a10a803..5afd7c08ad 100755 --- a/rsc/log4j2-spring.properties.dist +++ b/rsc/log4j2-spring.properties.dist @@ -54,5 +54,5 @@ appender.jdbc.columnConfigs[2].isUnicode = false ##logger.hibernate-SQL.name=org.hibernate.SQL ##logger.hibernate-SQL.level=DEBUG ## -##logger.hibernate-type.name=org.hibernate.type +##logger.hibernate-type.name=org.hibernate.orm.jdbc.bind ##logger.hibernate-type.level=TRACE diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index ed93285787..991dd21598 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -50,18 +50,20 @@ import javax.swing.JTable; import javax.swing.SwingConstants; import javax.swing.border.EmptyBorder; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableModel; import org.isf.generaldata.MessageBundle; import org.isf.medicalinventory.gui.InventoryEdit.InventoryListener; import org.isf.medicalinventory.manager.MedicalInventoryManager; +import org.isf.medicalinventory.model.InventoryStatus; +import org.isf.medicalinventory.model.InventoryType; import org.isf.medicalinventory.model.MedicalInventory; import org.isf.menu.manager.Context; import org.isf.utils.exception.OHServiceException; import org.isf.utils.exception.gui.OHServiceExceptionUtil; import org.isf.utils.jobjects.GoodDateChooser; -import org.isf.utils.jobjects.InventoryStatus; -import org.isf.utils.jobjects.InventoryType; import org.isf.utils.jobjects.MessageDialog; import org.isf.utils.jobjects.ModalJFrame; import org.isf.utils.time.TimeTools; @@ -91,8 +93,8 @@ public class InventoryBrowser extends ModalJFrame implements InventoryListener { MessageBundle.getMessage("angal.inventory.status.txt").toUpperCase(), MessageBundle.getMessage("angal.common.user.col").toUpperCase() }; private int[] pColumwidth = { 150, 150, 150, 200 }; - private JComboBox stateComboBox; - private JLabel stateLabel; + private JComboBox statusComboBox; + private JLabel statusLabel; JButton next; JButton previous; JComboBox pagesCombo = new JComboBox(); @@ -262,8 +264,8 @@ private JPanel getPanelFooter() { panelFooter.add(next); panelFooter.add(getNewButton()); - panelFooter.add(getViewButton()); panelFooter.add(getUpdateButton()); + panelFooter.add(getViewButton()); panelFooter.add(getPrintButton()); panelFooter.add(getDeleteButton()); panelFooter.add(getCloseButton()); @@ -272,7 +274,7 @@ private JPanel getPanelFooter() { } private GoodDateChooser getJCalendarTo() { if (jCalendarTo == null) { - jCalendarTo = new GoodDateChooser(LocalDate.now()); + jCalendarTo = new GoodDateChooser(LocalDate.now(), false, false); jCalendarTo.addDateChangeListener(event -> { dateTo = jCalendarTo.getDateEndOfDay(); InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); @@ -293,7 +295,7 @@ private GoodDateChooser getJCalendarTo() { private GoodDateChooser getJCalendarFrom() { if (jCalendarFrom == null) { - jCalendarFrom = new GoodDateChooser(LocalDate.now()); + jCalendarFrom = new GoodDateChooser(LocalDate.now(), false, false); jCalendarFrom.addDateChangeListener(event -> { dateFrom = jCalendarFrom.getDateStartOfDay(); InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); @@ -353,32 +355,79 @@ private JButton getNewButton() { return jButtonNew; } - private JButton getViewButton() { - jButtonView = new JButton(MessageBundle.getMessage("angal.common.view.btn")); - jButtonView.setMnemonic(MessageBundle.getMnemonic("angal.common.view.btn.key")); - return jButtonView; - } - private JButton getUpdateButton() { jButtonEdit = new JButton(MessageBundle.getMessage("angal.common.edit.btn")); jButtonEdit.setMnemonic(MessageBundle.getMnemonic("angal.common.edit.btn.key")); + jButtonEdit.setEnabled(false); + jButtonEdit.addActionListener(actionEvent -> { + MedicalInventory inventory = new MedicalInventory(); + if (jTableInventory.getSelectedRowCount() > 1) { + MessageDialog.error(this, "angal.inventory.pleaseselectonlyoneinventory.msg"); + return; + } + int selectedRow = jTableInventory.getSelectedRow(); + if (selectedRow == -1) { + MessageDialog.error(this, "angal.inventory.pleaseselectinventory.msg"); + return; + } + inventory = inventoryList.get(selectedRow); + if (inventory.getStatus().equals(InventoryStatus.validated.toString())) { + MessageDialog.error(null, "angal.inventory.validatednoteditable.msg"); + return; + } + if (inventory.getStatus().equals(InventoryStatus.canceled.toString())) { + MessageDialog.error(null, "angal.inventory.cancelednoteditable.msg"); + return; + } + InventoryEdit inventoryEdit = new InventoryEdit(inventory,"update"); + InventoryEdit.addInventoryListener(InventoryBrowser.this); + inventoryEdit.showAsModal(InventoryBrowser.this); + }); return jButtonEdit; } + private JButton getViewButton() { + jButtonView = new JButton(MessageBundle.getMessage("angal.common.view.btn")); + jButtonView.setMnemonic(MessageBundle.getMnemonic("angal.common.view.btn.key")); + jButtonView.setEnabled(false); + jButtonView.addActionListener(actionEvent -> { + MedicalInventory inventory = new MedicalInventory(); + if (jTableInventory.getSelectedRowCount() > 1) { + MessageDialog.error(this, "angal.inventory.pleaseselectonlyoneinventory.msg"); + return; + } + int selectedRow = jTableInventory.getSelectedRow(); + if (selectedRow == -1) { + MessageDialog.error(this, "angal.inventory.pleaseselectinventory.msg"); + return; + } + if(selectedRow > -1) { + inventory = inventoryList.get(selectedRow); + InventoryEdit inventoryEdit = new InventoryEdit(inventory,"view"); + InventoryEdit.addInventoryListener(InventoryBrowser.this); + inventoryEdit.showAsModal(InventoryBrowser.this); + } + }); + return jButtonView; + } + private JButton getPrintButton() { jButtonPrint = new JButton(MessageBundle.getMessage("angal.common.print.btn")); jButtonPrint.setMnemonic(MessageBundle.getMnemonic("angal.common.print.btn.key")); + jButtonPrint.setEnabled(false); return jButtonPrint; } + private JButton getDeleteButton() { jButtonDelete = new JButton(MessageBundle.getMessage("angal.common.delete.btn")); jButtonDelete.setMnemonic(MessageBundle.getMnemonic("angal.common.delete.btn.key")); + jButtonDelete.setEnabled(false); return jButtonDelete; } private JButton getCloseButton() { - jButtonClose = new JButton(MessageBundle.getMessage("angal.common.cancel.btn")); - jButtonClose.setMnemonic(MessageBundle.getMnemonic("angal.common.cancel.btn.key")); + jButtonClose = new JButton(MessageBundle.getMessage("angal.common.close.btn")); + jButtonClose.setMnemonic(MessageBundle.getMnemonic("angal.common.close.btn.key")); jButtonClose.addActionListener(actionEvent -> { dispose(); }); @@ -398,17 +447,38 @@ private JTable getJTableInventory() { jTableInventory = new JTable(); jTableInventory.setFillsViewportHeight(true); jTableInventory.setModel(new InventoryBrowsingModel()); + jTableInventory.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + + @Override + public void valueChanged(ListSelectionEvent e) { + if (e.getValueIsAdjusting()) { + int[] selectedRows = jTableInventory.getSelectedRows(); + if (selectedRows.length == 1) { + jButtonEdit.setEnabled(true); + jButtonView.setEnabled(true); + jButtonPrint.setEnabled(true); + jButtonDelete.setEnabled(true); + } else { + jButtonEdit.setEnabled(false); + jButtonView.setEnabled(false); + jButtonPrint.setEnabled(false); + jButtonDelete.setEnabled(false); + } + } + + } + }); } return jTableInventory; } - + class InventoryBrowsingModel extends DefaultTableModel { private static final long serialVersionUID = 1L; public InventoryBrowsingModel() { inventoryList = new ArrayList<>(); - String state = stateComboBox.getSelectedIndex() > 0 ? stateComboBox.getSelectedItem().toString().toLowerCase() : null; + String state = statusComboBox.getSelectedIndex() > 0 ? statusComboBox.getSelectedItem().toString().toLowerCase() : null; String type = InventoryType.main.toString(); try { inventoryList = medicalInventoryManager.getMedicalInventoryByParams(dateFrom, dateTo, state, type); @@ -419,9 +489,8 @@ public InventoryBrowsingModel() { public InventoryBrowsingModel(int startIndex, int pageSize) { inventoryList = new ArrayList<>(); - String state = stateComboBox.getSelectedIndex() > 0 ? stateComboBox.getSelectedItem().toString().toLowerCase() : null; + String state = statusComboBox.getSelectedIndex() > 0 ? statusComboBox.getSelectedItem().toString().toLowerCase() : null; String type = InventoryType.main.toString(); - try { Page medInventorypage = medicalInventoryManager.getMedicalInventoryByParamsPageable(dateFrom, dateTo, state, type, startIndex, pageSize); @@ -493,14 +562,14 @@ private void ajustWidth() { } } - private JComboBox getComboBox() { - if (stateComboBox == null) { - stateComboBox = new JComboBox(); - stateComboBox.addItem(""); - for (InventoryStatus currentState : InventoryStatus.values()) { - stateComboBox.addItem(MessageBundle.getMessage("angal.inventory." + currentState)); + private JComboBox getComboBox() { + if (statusComboBox == null) { + statusComboBox = new JComboBox(); + statusComboBox.addItem(""); + for (InventoryStatus currentStatus : InventoryStatus.values()) { + statusComboBox.addItem(MessageBundle.getMessage("angal.inventory." + currentStatus)); } - stateComboBox.addActionListener(actionEvent -> { + statusComboBox.addActionListener(actionEvent -> { InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); totalRows = inventoryModel.getRowCount(); startIndex = 0; @@ -514,15 +583,15 @@ private JComboBox getComboBox() { initialiseCombo(totalRows); }); } - return stateComboBox; + return statusComboBox; } private JLabel getStateLabel() { - if (stateLabel == null) { - stateLabel = new JLabel(MessageBundle.getMessage("angal.inventory.status.txt")); - stateLabel.setHorizontalAlignment(SwingConstants.RIGHT); + if (statusLabel == null) { + statusLabel = new JLabel(MessageBundle.getMessage("angal.inventory.status.txt")); + statusLabel.setHorizontalAlignment(SwingConstants.RIGHT); } - return stateLabel; + return statusLabel; } public void initialiseCombo(int total_rows) { @@ -543,25 +612,16 @@ public void initialiseCombo(int total_rows) { @Override public void InventoryCancelled(AWTEvent e) { - if (inventoryList != null) { - inventoryList.clear(); - } jTableInventory.setModel(new InventoryBrowsingModel()); } @Override public void InventoryInserted(AWTEvent e) { - if (inventoryList != null) { - inventoryList.clear(); - } jTableInventory.setModel(new InventoryBrowsingModel()); } @Override public void InventoryUpdated(AWTEvent e) { - if (inventoryList != null) { - inventoryList.clear(); - } jTableInventory.setModel(new InventoryBrowsingModel()); } } diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 9464b39558..40ba793a28 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -28,21 +28,19 @@ import java.awt.Color; import java.awt.Component; import java.awt.Dimension; -import java.awt.FlowLayout; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; +import java.awt.GridLayout; import java.awt.Insets; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.math.BigDecimal; -import java.text.DecimalFormat; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Collections; import java.util.EventListener; @@ -50,10 +48,12 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import javax.swing.ButtonGroup; import javax.swing.DefaultCellEditor; import javax.swing.JButton; +import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; @@ -63,40 +63,45 @@ import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; +import javax.swing.SwingConstants; import javax.swing.border.EmptyBorder; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; import javax.swing.event.EventListenerList; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; -import javax.swing.table.TableModel; +import org.isf.generaldata.GeneralData; import org.isf.generaldata.MessageBundle; import org.isf.medicalinventory.manager.MedicalInventoryManager; import org.isf.medicalinventory.manager.MedicalInventoryRowManager; +import org.isf.medicalinventory.model.InventoryStatus; +import org.isf.medicalinventory.model.InventoryType; import org.isf.medicalinventory.model.MedicalInventory; import org.isf.medicalinventory.model.MedicalInventoryRow; import org.isf.medicals.manager.MedicalBrowsingManager; import org.isf.medicals.model.Medical; import org.isf.medicalstock.manager.MovStockInsertingManager; import org.isf.medicalstock.model.Lot; +import org.isf.medstockmovtype.manager.MedicalDsrStockMovementTypeBrowserManager; +import org.isf.medstockmovtype.model.MovementType; import org.isf.menu.manager.Context; import org.isf.menu.manager.UserBrowsingManager; +import org.isf.supplier.manager.SupplierBrowserManager; +import org.isf.supplier.model.Supplier; import org.isf.utils.db.NormalizeString; import org.isf.utils.exception.OHServiceException; import org.isf.utils.exception.gui.OHServiceExceptionUtil; import org.isf.utils.jobjects.GoodDateChooser; -import org.isf.utils.jobjects.InventoryStatus; -import org.isf.utils.jobjects.InventoryType; +import org.isf.utils.jobjects.GoodDateTimeSpinnerChooser; import org.isf.utils.jobjects.MessageDialog; import org.isf.utils.jobjects.ModalJFrame; +import org.isf.utils.jobjects.RequestFocusListener; import org.isf.utils.jobjects.TextPrompt; import org.isf.utils.jobjects.TextPrompt.Show; import org.isf.utils.time.TimeTools; +import org.isf.ward.manager.WardBrowserManager; +import org.isf.ward.model.Ward; public class InventoryEdit extends ModalJFrame { @@ -121,17 +126,31 @@ public static void removeInventoryListener(InventoryListener listener) { InventoryListeners.remove(InventoryListener.class, listener); } - private void fireInventoryUpdated() { + private void fireInventoryInserted() { AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { - private static final long serialVersionUID = 1L; }; + + EventListener[] listeners = InventoryListeners.getListeners(InventoryListener.class); + for (int i = 0; i < listeners.length; i++) { + ((InventoryListener) listeners[i]).InventoryInserted(event); + } + jTableInventoryRow.updateUI(); + } + private void fireInventoryUpdated() { + AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { + private static final long serialVersionUID = 1L; + }; + EventListener[] listeners = InventoryListeners.getListeners(InventoryListener.class); - for (int i = 0; i < listeners.length; i++) + for (int i = 0; i < listeners.length; i++) { ((InventoryListener) listeners[i]).InventoryUpdated(event); + } + jTableInventoryRow.updateUI(); + } - + private GoodDateChooser jCalendarInventory; private LocalDateTime dateInventory = TimeTools.getNow(); private JPanel panelHeader; @@ -140,63 +159,94 @@ private void fireInventoryUpdated() { private JButton closeButton; private JButton deleteButton; private JButton saveButton; + private JButton resetButton; + private JButton lotButton; private JScrollPane scrollPaneInventory; private JTable jTableInventoryRow; private List inventoryRowList; - private List inventoryRowSearchList; - private String[] pColums = { MessageBundle.getMessage("angal.common.code.txt").toUpperCase(), + private List inventoryRowSearchList = new ArrayList<>(); + private List inventoryRowListAdded = new ArrayList<>(); + private List lotsSaved = new ArrayList<>(); + private HashMap lotsDeleted = new HashMap<>(); + List inventoryRowsToDelete = new ArrayList<>(); + private String[] pColums = { MessageBundle.getMessage("angal.inventory.id.col").toUpperCase(), + MessageBundle.getMessage("angal.common.code.txt").toUpperCase(), MessageBundle.getMessage("angal.inventory.product.col").toUpperCase(), + MessageBundle.getMessage("angal.inventory.new.col").toUpperCase(), MessageBundle.getMessage("angal.wardpharmacy.lotnumber.col").toUpperCase(), MessageBundle.getMessage("angal.medicalstock.duedate.col").toUpperCase(), - MessageBundle.getMessage("angal.inventoryrow.theorticqty.col").toUpperCase(), + MessageBundle.getMessage("angal.inventoryrow.theoreticqty.col").toUpperCase(), MessageBundle.getMessage("angal.inventoryrow.realqty.col").toUpperCase(), MessageBundle.getMessage("angal.inventoryrow.unitprice.col").toUpperCase(), MessageBundle.getMessage("angal.inventory.totalprice").toUpperCase() }; - private int[] pColumwidth = { 100, 200, 100, 100, 100, 80, 80, 80 }; - private boolean[] columnEditable = { false, false, false, false, false, true, true, false }; - private boolean[] columnEditableView = { false, false, false, false, false, false, false, false }; + private int[] pColumwidth = { 50, 50, 200, 100, 100, 100, 100, 80, 80, 80 }; + private boolean[] columnEditable = { false, false, false, false, false, false, false, true, false, false }; + private boolean[] columnEditableView = { false, false, false, false, false, false, false, false, false, false }; + private boolean[] pColumnVisible = { false, true, true, true, !GeneralData.AUTOMATICLOT_IN, true, true, true, GeneralData.LOTWITHCOST, GeneralData.LOTWITHCOST }; private MedicalInventory inventory = null; private JRadioButton specificRadio; private JRadioButton allRadio; - private JTextField searchTextField; private JLabel dateInventoryLabel; private JTextField codeTextField; private String code = null; private String mode = null; private JLabel referenceLabel; + private JLabel statusLabel; + private JLabel chargeTypeLabel; + private JLabel dischargeTypeLabel; + private JLabel supplierLabel; + private JLabel destinationLabel; private JTextField referenceTextField; private JTextField jTetFieldEditor; - private JButton moreData; - private static boolean MORE_DATA = true; + private JComboBox chargeCombo; + private JComboBox dischargeCombo; + private JComboBox supplierCombo; + private JComboBox destinationCombo; + private MovementType chargeType = null; + private MovementType dischargeType = null; + private Supplier supplier = null; + private Ward destination = null; + private boolean selectAll = false; + private String newReference = null; private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); private MedicalInventoryRowManager medicalInventoryRowManager = Context.getApplicationContext().getBean(MedicalInventoryRowManager.class); private MedicalBrowsingManager medicalBrowsingManager = Context.getApplicationContext().getBean(MedicalBrowsingManager.class); private MovStockInsertingManager movStockInsertingManager = Context.getApplicationContext().getBean(MovStockInsertingManager.class); + private MedicalDsrStockMovementTypeBrowserManager movTypeManager = Context.getApplicationContext().getBean(MedicalDsrStockMovementTypeBrowserManager.class); + private SupplierBrowserManager supplierManager = Context.getApplicationContext().getBean(SupplierBrowserManager.class); + private WardBrowserManager wardManager = Context.getApplicationContext().getBean(WardBrowserManager.class); + public InventoryEdit() { - initComponents(); mode = "new"; + initComponents(); } - - public InventoryEdit(MedicalInventory inventory, String modee) { + + private boolean isAutomaticLotIn() { + return GeneralData.AUTOMATICLOT_IN; + } + + public InventoryEdit(MedicalInventory inventory, String mod) { this.inventory = inventory; - mode = modee; + mode = mod; initComponents(); - if (mode.equals("view")) { - saveButton.setVisible(false); - columnEditable = columnEditableView; - } - } private void initComponents() { inventoryRowList = new ArrayList<>(); inventoryRowSearchList = new ArrayList<>(); - setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - setMinimumSize(new Dimension(950, 580)); + setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + setMinimumSize(new Dimension(1000, 600)); setLocationRelativeTo(null); - setTitle(MessageBundle.getMessage("angal.inventory.neweditinventory.title")); - + if (mode.equals("new")) { + setTitle(MessageBundle.getMessage("angal.inventory.newinventory.title")); + } + if (mode.equals("view")) { + setTitle(MessageBundle.getMessage("angal.inventory.viewinventory.title")); + } + if (mode.equals("update")) { + setTitle(MessageBundle.getMessage("angal.inventory.editinventory.title")); + } getContentPane().setLayout(new BorderLayout()); panelHeader = getPanelHeader(); @@ -209,20 +259,42 @@ private void initComponents() { panelFooter = getPanelFooter(); getContentPane().add(panelFooter, BorderLayout.SOUTH); - ajustWidth(); - addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { - if (inventoryRowList != null) { - inventoryRowList.clear(); - } - if (inventoryRowSearchList != null) { - inventoryRowSearchList.clear(); - } - dispose(); + closeButton.doClick(); } }); + if (mode.equals("view")) { + saveButton.setVisible(false); + deleteButton.setVisible(false); + columnEditable = columnEditableView; + codeTextField.setEditable(false); + resetButton.setVisible(false); + referenceTextField.setEditable(false); + jCalendarInventory.setEnabled(false); + specificRadio.setEnabled(false); + allRadio.setEnabled(false); + chargeCombo.setEnabled(false); + dischargeCombo.setEnabled(false); + supplierCombo.setEnabled(false); + destinationCombo.setEnabled(false); + lotButton.setVisible(false); + } else { + saveButton.setVisible(true); + deleteButton.setVisible(true); + codeTextField.setEditable(true); + resetButton.setVisible(true); + referenceTextField.setEditable(true); + jCalendarInventory.setEnabled(true); + specificRadio.setEnabled(true); + allRadio.setEnabled(true); + chargeCombo.setEnabled(true); + dischargeCombo.setEnabled(true); + supplierCombo.setEnabled(true); + destinationCombo.setEnabled(true); + lotButton.setVisible(true); + } } private JPanel getPanelHeader() { @@ -259,37 +331,79 @@ private JPanel getPanelHeader() { gbc_referenceTextField.gridx = 3; gbc_referenceTextField.gridy = 0; panelHeader.add(getReferenceTextField(), gbc_referenceTextField); + GridBagConstraints gbc_chargeLabel = new GridBagConstraints(); + gbc_chargeLabel.insets = new Insets(0, 0, 5, 5); + gbc_chargeLabel.gridx = 0; + gbc_chargeLabel.gridy = 1; + panelHeader.add(getChargeLabel(), gbc_chargeLabel); + GridBagConstraints gbc_jComboCharge = new GridBagConstraints(); + gbc_jComboCharge.fill = GridBagConstraints.HORIZONTAL; + gbc_jComboCharge.insets = new Insets(0, 0, 5, 5); + gbc_jComboCharge.gridx = 1; + gbc_jComboCharge.gridy = 1; + panelHeader.add(getJComboCharge(), gbc_jComboCharge); + GridBagConstraints gbc_supplierLabel = new GridBagConstraints(); + gbc_supplierLabel.anchor = GridBagConstraints.EAST; + gbc_supplierLabel.insets = new Insets(0, 0, 5, 5); + gbc_supplierLabel.gridx = 2; + gbc_supplierLabel.gridy = 1; + panelHeader.add(getSupplierLabel(), gbc_supplierLabel); + GridBagConstraints gbc_supplierCombo = new GridBagConstraints(); + gbc_supplierCombo.fill = GridBagConstraints.HORIZONTAL; + gbc_supplierCombo.insets = new Insets(0, 0, 5, 5); + gbc_supplierCombo.gridx = 3; + gbc_supplierCombo.gridy = 1; + panelHeader.add(getJComboSupplier(), gbc_supplierCombo); + GridBagConstraints gbc_dischargeLabel = new GridBagConstraints(); + gbc_dischargeLabel.insets = new Insets(0, 0, 5, 5); + gbc_dischargeLabel.gridx = 0; + gbc_dischargeLabel.gridy = 2; + panelHeader.add(getDischargeLabel(), gbc_dischargeLabel); + GridBagConstraints gbc_dichargeCombo = new GridBagConstraints(); + gbc_dichargeCombo.fill = GridBagConstraints.HORIZONTAL; + gbc_dichargeCombo.insets = new Insets(0, 0, 5, 5); + gbc_dichargeCombo.gridx = 1; + gbc_dichargeCombo.gridy = 2; + panelHeader.add(getJComboDischarge(), gbc_dichargeCombo); + GridBagConstraints gbc_destinationLabel = new GridBagConstraints(); + gbc_destinationLabel.anchor = GridBagConstraints.EAST; + gbc_destinationLabel.insets = new Insets(0, 0, 5, 5); + gbc_destinationLabel.gridx = 2; + gbc_destinationLabel.gridy = 2; + panelHeader.add(getDestinationLabel(), gbc_destinationLabel); + GridBagConstraints gbc_destinationCombo = new GridBagConstraints(); + gbc_destinationCombo.fill = GridBagConstraints.HORIZONTAL; + gbc_destinationCombo.insets = new Insets(0, 0, 5, 5); + gbc_destinationCombo.gridx = 3; + gbc_destinationCombo.gridy = 2; + panelHeader.add(getJComboDestination(), gbc_destinationCombo); GridBagConstraints gbc_specificRadio = new GridBagConstraints(); gbc_specificRadio.anchor = GridBagConstraints.EAST; gbc_specificRadio.insets = new Insets(0, 0, 0, 5); gbc_specificRadio.gridx = 0; - gbc_specificRadio.gridy = 1; + gbc_specificRadio.gridy = 3; panelHeader.add(getSpecificRadio(), gbc_specificRadio); GridBagConstraints gbc_codeTextField = new GridBagConstraints(); gbc_codeTextField.insets = new Insets(0, 0, 0, 5); gbc_codeTextField.fill = GridBagConstraints.HORIZONTAL; gbc_codeTextField.gridx = 1; - gbc_codeTextField.gridy = 1; + gbc_codeTextField.gridy = 3; panelHeader.add(getCodeTextField(), gbc_codeTextField); GridBagConstraints gbc_allRadio = new GridBagConstraints(); gbc_allRadio.anchor = GridBagConstraints.EAST; gbc_allRadio.insets = new Insets(0, 0, 0, 5); gbc_allRadio.gridx = 2; - gbc_allRadio.gridy = 1; + gbc_allRadio.gridy = 3; panelHeader.add(getAllRadio(), gbc_allRadio); - GridBagConstraints gbc_searchTextField = new GridBagConstraints(); - gbc_searchTextField.insets = new Insets(0, 0, 0, 5); - gbc_searchTextField.fill = GridBagConstraints.HORIZONTAL; - gbc_searchTextField.gridx = 3; - gbc_searchTextField.gridy = 1; - JPanel panSearchTextField = new JPanel(); - panSearchTextField.setLayout(new FlowLayout(FlowLayout.LEFT)); - panSearchTextField.add(getSearchTextField()); - panSearchTextField.add(getMoreDataBtn()); - panelHeader.add(panSearchTextField, gbc_searchTextField); ButtonGroup group = new ButtonGroup(); group.add(specificRadio); group.add(allRadio); + GridBagConstraints gbc_statusLabel = new GridBagConstraints(); + gbc_statusLabel.anchor = GridBagConstraints.EAST; + gbc_statusLabel.insets = new Insets(0, 0, 5, 5); + gbc_statusLabel.gridx = 3; + gbc_statusLabel.gridy = 3; + panelHeader.add(getStatusLabel(), gbc_statusLabel); } return panelHeader; } @@ -315,8 +429,10 @@ private JPanel getPanelContent() { private JPanel getPanelFooter() { if (panelFooter == null) { panelFooter = new JPanel(); - panelFooter.add(getNewButton()); + panelFooter.add(getSaveButton()); panelFooter.add(getDeleteButton()); + panelFooter.add(getLotButton()); + panelFooter.add(getCleanTableButton()); panelFooter.add(getCloseButton()); } return panelFooter; @@ -324,82 +440,300 @@ private JPanel getPanelFooter() { private GoodDateChooser getJCalendarFrom() { if (jCalendarInventory == null) { - jCalendarInventory = new GoodDateChooser(LocalDate.now()); + jCalendarInventory = new GoodDateChooser(LocalDate.now(), false, false); if (inventory != null) { jCalendarInventory.setDate(inventory.getInventoryDate().toLocalDate()); + dateInventory = inventory.getInventoryDate(); } jCalendarInventory.addDateChangeListener(event -> { - dateInventory = jCalendarInventory.getDateStartOfDay(); + dateInventory = jCalendarInventory.getDate().atStartOfDay(); }); } return jCalendarInventory; } - private JButton getNewButton() { + private JButton getSaveButton() { saveButton = new JButton(MessageBundle.getMessage("angal.common.save.btn")); saveButton.setMnemonic(MessageBundle.getMnemonic("angal.common.save.btn.key")); saveButton.addActionListener(actionEvent -> { - String State = InventoryStatus.draft.toString(); + String state = InventoryStatus.draft.toString(); String user = UserBrowsingManager.getCurrentUser(); - int checkResults = 0; - if (inventoryRowSearchList == null || inventoryRowSearchList.size() < 1) { - MessageDialog.error(null, "angal.inventory.noproduct.msg"); + if (inventoryRowSearchList == null || inventoryRowSearchList.isEmpty()) { + MessageDialog.error(null, "angal.inventory.cannotsaveinventorywithoutproducts.msg"); return; } - LocalDateTime now = LocalDateTime.now(); - if (dateInventory.isAfter(now)) { - MessageDialog.error(null, "angal.inventory.notdateinfuture.msg"); - return; - } - - if ((inventory == null) && (mode.equals("new"))) { - String reference = referenceTextField.getText().trim(); - if (reference.equals("")) { - MessageDialog.error(null, "angal.inventory.mustenterareference.msg"); - return; - } - if (medicalInventoryManager.referenceExists(reference)) { - MessageDialog.error(null, "angal.inventory.referencealreadyused.msg"); - return; + try { + if (!lotsDeleted.isEmpty() || !inventoryRowsToDelete.isEmpty()) { + for (Map.Entry entry : lotsDeleted.entrySet()) { + MedicalInventoryRow invRow = null; + invRow = medicalInventoryRowManager.getMedicalInventoryRowById(entry.getKey()); + if (invRow != null ) { + invRow.setLot(null); + medicalInventoryRowManager.updateMedicalInventoryRow(invRow); + movStockInsertingManager.deleteLot(entry.getValue()); + } + + } + medicalInventoryRowManager.deleteMedicalInventoryRows(inventoryRowsToDelete); } - inventory = new MedicalInventory(); - inventory.setInventoryReference(reference); - inventory.setInventoryDate(dateInventory); - inventory.setStatus(State); - inventory.setUser(user); - inventory.setInventoryType(InventoryType.main.toString()); - MedicalInventory meInventory; - try { - meInventory = medicalInventoryManager.newMedicalInventory(inventory); - if (meInventory != null) { - MedicalInventoryRow currentInventoryRow; - for (Iterator iterator = inventoryRowSearchList.iterator(); iterator.hasNext();) { - MedicalInventoryRow medicalInventoryRow = (MedicalInventoryRow) iterator.next(); - medicalInventoryRow.setInventory(meInventory); - Lot lot = medicalInventoryRow.getLot(); - if (lot != null && lot.getCode().equals("")) { - medicalInventoryRow.setLot(null); - } - currentInventoryRow = medicalInventoryRowManager.newMedicalInventoryRow(medicalInventoryRow); - if (currentInventoryRow == null) { - checkResults++; + if ((inventory == null) && (mode.equals("new"))) { + newReference = referenceTextField.getText().trim(); + boolean refExist = false; + refExist = medicalInventoryManager.referenceExists(newReference); + if (refExist) { + MessageDialog.error(null, "angal.inventory.referencealreadyused.msg"); + return; + } + inventory = new MedicalInventory(); + inventory.setInventoryReference(newReference); + inventory.setInventoryDate(dateInventory); + inventory.setStatus(state); + inventory.setUser(user); + inventory.setInventoryType(InventoryType.main.toString()); + if (chargeType != null) { + inventory.setChargeType(chargeType.getCode()); + } else { + inventory.setChargeType(null); + } + if (dischargeType != null) { + inventory.setDischargeType(dischargeType.getCode()); + } else { + inventory.setDischargeType(null); + } + if (supplier != null) { + inventory.setSupplier(supplier.getSupId()); + } else { + inventory.setSupplier(null); + } + if (destination != null) { + inventory.setDestination(destination.getCode()); + } else { + inventory.setDestination(null); + } + inventory = medicalInventoryManager.newMedicalInventory(inventory); + for (Iterator iterator = inventoryRowSearchList.iterator(); iterator.hasNext();) { + MedicalInventoryRow medicalInventoryRow = (MedicalInventoryRow) iterator.next(); + medicalInventoryRow.setInventory(inventory); + Lot lot = medicalInventoryRow.getLot(); + String lotCode; + Medical medical = medicalInventoryRow.getMedical(); + if (lot != null) { + lotCode = lot.getCode(); + Lot lotExist = null; + lotExist = movStockInsertingManager.getLot(lotCode); + if (lotExist != null) { + Lot lotStore = null; + lotStore = movStockInsertingManager.updateLot(lot); + medicalInventoryRow.setLot(lotStore); + } else { + if (lot.getDueDate() != null) { + Lot lotStore = null; + lotStore = movStockInsertingManager.storeLot(lotCode, lot, medical); + medicalInventoryRow.setLot(lotStore); + medicalInventoryRow.setNewLot(true); + } else { + medicalInventoryRow.setLot(null); + } } + } else { + medicalInventoryRow.setLot(null); } - if (checkResults == 0) { - // enable validation - mode = "update"; - MessageDialog.info(this, "angal.inventory.savesucces.msg"); - fireInventoryUpdated(); - closeButton.doClick(); + medicalInventoryRowManager.newMedicalInventoryRow(medicalInventoryRow); + } + // enable validation + mode = "update"; + MessageDialog.info(this, "angal.inventory.savesuccess.msg"); + fireInventoryInserted(); + resetVariable(); + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttocontinueediting.msg"); + if (info != JOptionPane.YES_OPTION) { + dispose(); + } + } else if ((inventory != null) && (mode.equals("update"))) { + String lastCharge = inventory.getChargeType(); + String lastDischarge = inventory.getDischargeType(); + Integer lastSupplier = inventory.getSupplier(); + String lastDestination = inventory.getDestination(); + String lastReference = inventory.getInventoryReference(); + newReference = referenceTextField.getText().trim(); + MedicalInventory existingInventory = medicalInventoryManager.getInventoryByReference(newReference); + if (existingInventory != null && existingInventory.getId() != inventory.getId()) { + MessageDialog.error(null, "angal.inventory.referencealreadyused.msg"); + return; + } + if (inventoryRowListAdded.isEmpty() && lotsSaved.isEmpty() && lotsDeleted.isEmpty()) { + if ((destination != null && !destination.getCode().equals(lastDestination)) || (chargeType != null && !chargeType.getCode().equals(lastCharge)) || (dischargeType != null && !dischargeType.getCode().equals(lastDischarge)) || (supplier != null && !supplier.getSupId().equals(lastSupplier)) || (destination == null && lastDestination != null) || (chargeType == null && lastCharge != null) || (dischargeType == null && lastDischarge != null) || (supplier == null && lastSupplier != null) || !lastReference.equals(newReference)) { + if (!inventory.getInventoryDate().equals(dateInventory)) { + inventory.setInventoryDate(dateInventory); + } + if (!inventory.getUser().equals(user)) { + inventory.setUser(user); + } + if (!lastReference.equals(newReference)) { + inventory.setInventoryReference(newReference); + } + MovementType charge = (MovementType) chargeCombo.getSelectedItem(); + if (charge != null) { + inventory.setChargeType(charge.getCode()); + } else { + inventory.setChargeType(null); + } + MovementType discharge = (MovementType) dischargeCombo.getSelectedItem(); + if (discharge != null) { + inventory.setDischargeType(discharge.getCode()); + } else { + inventory.setDischargeType(null); + } + Supplier supplier = (Supplier) supplierCombo.getSelectedItem(); + if (supplier != null) { + inventory.setSupplier(supplier.getSupId()); + } else { + inventory.setSupplier(null); + } + Ward destination = (Ward) destinationCombo.getSelectedItem(); + if (destination != null) { + inventory.setDestination(destination.getCode()); + } else { + inventory.setDestination(null); + } + inventory = medicalInventoryManager.updateMedicalInventory(inventory); + if (inventory != null) { + MessageDialog.info(null, "angal.inventory.update.success.msg"); + resetVariable(); + fireInventoryUpdated(); + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttocontinueediting.msg"); + if (info != JOptionPane.YES_OPTION) { + dispose(); + } + } else { + MessageDialog.error(null, "angal.inventory.update.error.msg"); + return; + } } else { - MessageDialog.error(null, "angal.inventory.error.msg"); + if (!inventoryRowsToDelete.isEmpty()) { + MessageDialog.info(null, "angal.inventory.update.success.msg"); + resetVariable(); + fireInventoryUpdated(); + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttocontinueediting.msg"); + if (info != JOptionPane.YES_OPTION) { + dispose(); + } + } else { + MessageDialog.info(null, "angal.inventory.inventoryisalreadysaved.msg"); + return; + } + } + return; + } + if (!inventory.getInventoryDate().equals(dateInventory)) { + inventory.setInventoryDate(dateInventory); + } + if (!inventory.getUser().equals(user)) { + inventory.setUser(user); + } + if (!lastReference.equals(newReference)) { + inventory.setInventoryReference(newReference); + } + MovementType charge = (MovementType) chargeCombo.getSelectedItem(); + if (charge != null) { + inventory.setChargeType(charge.getCode()); + } else { + inventory.setChargeType(null); + } + MovementType discharge = (MovementType) dischargeCombo.getSelectedItem(); + if (discharge != null) { + inventory.setDischargeType(discharge.getCode()); + } else { + inventory.setDischargeType(null); + } + Supplier supplier = (Supplier) supplierCombo.getSelectedItem(); + if (supplier != null) { + inventory.setSupplier(supplier.getSupId()); } else { - MessageDialog.error(null, "angal.inventory.error.msg"); + inventory.setSupplier(null); + } + Ward destination = (Ward) destinationCombo.getSelectedItem(); + if (destination != null) { + inventory.setDestination(destination.getCode()); + } else { + inventory.setDestination(null); + } + inventory = medicalInventoryManager.updateMedicalInventory(inventory); + for (Iterator iterator = inventoryRowSearchList.iterator(); iterator.hasNext();) { + MedicalInventoryRow medicalInventoryRow = iterator.next(); + Medical medical = medicalInventoryRow.getMedical(); + Lot lot = medicalInventoryRow.getLot(); + String lotCode; + medicalInventoryRow.setInventory(inventory); + int id = medicalInventoryRow.getId(); + if (id == 0) { + if (lot != null) { + lotCode = lot.getCode(); + boolean isExist = false; + Lot lotExist = movStockInsertingManager.getLot(lotCode); + if (lotExist != null) { + isExist = true; + } + if (!isExist) { + if (lot.getDueDate() != null) { + Lot lotStore = movStockInsertingManager.storeLot(lotCode, lot, medical); + medicalInventoryRow.setLot(lotStore); + medicalInventoryRow.setNewLot(true); + } else { + medicalInventoryRow.setLot(null); + } + } else { + Lot lotStore = movStockInsertingManager.updateLot(lot); + medicalInventoryRow.setLot(lotStore); + } + } + medicalInventoryRowManager.newMedicalInventoryRow(medicalInventoryRow); + } else { + lot = medicalInventoryRow.getLot(); + double reatQty = medicalInventoryRow.getRealQty(); + medicalInventoryRow = medicalInventoryRowManager.getMedicalInventoryRowById(id); + medicalInventoryRow.setRealqty(reatQty); + if (lot != null) { + lotCode = lot.getCode(); + Lot lotExist = movStockInsertingManager.getLot(lotCode); + if (lotExist != null) { + Lot lotStore; + lotExist.setDueDate(lot.getDueDate()); + lotExist.setPreparationDate(lot.getPreparationDate()); + lotExist.setCost(lot.getCost()); + lotStore = movStockInsertingManager.updateLot(lotExist); + medicalInventoryRow.setLot(lotStore); + } else { + if (lot.getDueDate() != null) { + Lot lotStore = movStockInsertingManager.storeLot(lotCode, lot, medical); + medicalInventoryRow.setLot(lotStore); + medicalInventoryRow.setNewLot(true); + } else { + medicalInventoryRow.setLot(null); + } + } + } else { + medicalInventoryRow.setLot(null); + } + if (medicalInventoryRow.getId() == 0) { + medicalInventoryRowManager.newMedicalInventoryRow(medicalInventoryRow); + } else { + medicalInventoryRowManager.updateMedicalInventoryRow(medicalInventoryRow); + } + } + } + MessageDialog.info(null, "angal.inventory.update.success.msg"); + resetVariable(); + fireInventoryUpdated(); + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttocontinueediting.msg"); + if (info != JOptionPane.YES_OPTION) { + dispose(); } - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + return; } }); return saveButton; @@ -408,93 +742,205 @@ private JButton getDeleteButton() { deleteButton = new JButton(MessageBundle.getMessage("angal.common.delete.btn")); deleteButton.setMnemonic(MessageBundle.getMnemonic("angal.common.delete.btn.key")); deleteButton.addActionListener(actionEvent -> { - if (jTableInventoryRow.getSelectedRowCount() > 1) { - MessageDialog.error(this, "angal.inventoryrow.pleaseselectonlyoneinventoryrow.msg"); - return; - } - int selectedRow = jTableInventoryRow.getSelectedRow(); - if (selectedRow == -1) { - MessageDialog.error(this, "angal.inventoryrow.pleaseselectonlyoneinventoryrow.msg"); + int[] selectedRows = jTableInventoryRow.getSelectedRows(); + if (selectedRows.length == 0) { + MessageDialog.error(this, "angal.inventoryrow.pleaseselectatleastoneinventoryrow.msg"); return; } - MedicalInventoryRow selectedInventory = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRow, -1); int delete = MessageDialog.yesNo(null, "angal.inventoryrow.doyoureallywanttodeletethisinventoryrow.msg"); if (delete == JOptionPane.YES_OPTION) { - if (selectedInventory.getInventory() == null) { - inventoryRowSearchList.remove(selectedRow); + if (inventory == null) { + for (int i = selectedRows.length - 1; i >= 0; i--) { + MedicalInventoryRow selectedInventoryRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRows[i], -1); + inventoryRowSearchList.remove(selectedInventoryRow); + } } else { - + for (int i = selectedRows.length - 1; i >= 0; i--) { + MedicalInventoryRow inventoryRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRows[i], -1); + inventoryRowSearchList.remove(inventoryRow); + if (inventoryRow.getId() != 0) { + inventoryRowsToDelete.add(inventoryRow); + } + } } + jTableInventoryRow.clearSelection(); } else { return; } - jTableInventoryRow.updateUI(); + fireInventoryUpdated(); }); return deleteButton; } + + private JButton getLotButton() { + lotButton = new JButton(MessageBundle.getMessage("angal.inventory.lot.btn")); + lotButton.setMnemonic(MessageBundle.getMnemonic("angal.inventory.lot.btn.key")); + lotButton.addActionListener(actionEvent -> { + int selectedRow = jTableInventoryRow.getSelectedRow(); + if (selectedRow == -1) { + MessageDialog.error(this, "angal.inventoryrow.pleaseselectoneinventoryrow.msg"); + return; + } + MedicalInventoryRow selectedInventoryRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRow, -1); + Lot lotToUpdate = selectedInventoryRow.getLot() != null ? selectedInventoryRow.getLot() : null; + Lot lot = new Lot(); + try { + lot = this.getLot(lotToUpdate); + String lotCode = lotToUpdate != null ? lotToUpdate.getCode():""; + if (lot != null && !lot.getCode().equals(lotCode)) { + Lot lotDelete = movStockInsertingManager.getLot(lotCode); + if (lotDelete != null) { + lotsDeleted.put(selectedInventoryRow.getId(), lotDelete); + } + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + return; + } + if (lot != null) { + code = lot.getCode(); + if (selectedInventoryRow.getLot() == null) { + List invRows = inventoryRowSearchList.stream().filter(inv -> inv.getLot() != null && inv.getLot().getCode().equals(code)).collect(Collectors.toList()); + if (invRows.size() == 0 || code.equals("")) { + selectedInventoryRow.setNewLot(true); + selectedInventoryRow.setLot(lot); + lotsSaved.add(lot); + } else { + MessageDialog.error(this, "angal.inventoryrow.thislotcodealreadyexists.msg"); + lotButton.doClick(); + } + } else { + List invRows = inventoryRowSearchList.stream().filter(inv -> inv.getMedical().getCode().equals(selectedInventoryRow.getMedical().getCode())).collect(Collectors.toList()); + invRows = invRows.stream().filter(inv -> inv.getLot() != null && inv.getLot().getCode().equals(code)).collect(Collectors.toList()); + if (invRows.size() == 0 || code.equals("")) { + selectedInventoryRow.setNewLot(true); + selectedInventoryRow.setLot(lot); + lotsSaved.add(lot); + } else { + MessageDialog.error(this, "angal.inventoryrow.thislotcodealreadyexists.msg"); + lotButton.doClick(); + } + } + inventoryRowSearchList.set(selectedRow, selectedInventoryRow); + jTableInventoryRow.updateUI(); + } + }); + lotButton.setEnabled(false); + return lotButton; + } + private JButton getCloseButton() { closeButton = new JButton(MessageBundle.getMessage("angal.common.close.btn")); closeButton.setMnemonic(MessageBundle.getMnemonic("angal.common.close.btn.key")); closeButton.addActionListener(actionEvent -> { - dispose(); + String lastCharge = null; + String lastDischarge = null; + Integer lastSupplier = null; + String lastDestination = null; + String lastReference = null; + newReference = referenceTextField.getText().trim(); + LocalDateTime lastDate = dateInventory; + if (inventory != null) { + lastCharge = inventory.getChargeType(); + lastDischarge = inventory.getDischargeType(); + lastSupplier = inventory.getSupplier(); + lastDestination = inventory.getDestination(); + lastReference = inventory.getInventoryReference(); + lastDate = inventory.getInventoryDate(); + } + if (!lotsSaved.isEmpty() || !inventoryRowListAdded.isEmpty() || !lotsDeleted.isEmpty() || !inventoryRowsToDelete.isEmpty() || (destination != null && !destination.getCode().equals(lastDestination)) || (chargeType != null && !chargeType.getCode().equals(lastCharge)) || (dischargeType != null && !dischargeType.getCode().equals(lastDischarge)) || (supplier != null && !supplier.getSupId().equals(lastSupplier)) ||(destination == null && lastDestination != null) || (chargeType == null && lastCharge != null) || (dischargeType == null && lastDischarge != null) || (supplier == null && lastSupplier != null) || !lastReference.equals(newReference) || !lastDate.toLocalDate().equals(dateInventory.toLocalDate())) { + int reset = MessageDialog.yesNoCancel(null, "angal.inventoryrow.doyouwanttosavethechanges.msg"); + if (reset == JOptionPane.YES_OPTION) { + this.saveButton.doClick(); + } + if (reset == JOptionPane.NO_OPTION) { + resetVariable(); + dispose(); + } else { + resetVariable(); + return; + } + } else { + resetVariable(); + dispose(); + } }); return closeButton; } + + private JButton getCleanTableButton() { + resetButton = new JButton(MessageBundle.getMessage("angal.inventory.clean.btn")); + resetButton.setMnemonic(MessageBundle.getMnemonic("angal.inventory.clean.btn.key")); + resetButton.addActionListener(actionEvent -> { + int reset = MessageDialog.yesNo(null, "angal.inventoryrow.doyoureallywanttocleanthistable.msg"); + if (reset == JOptionPane.YES_OPTION) { + if (inventory != null) { + for (MedicalInventoryRow invRow : inventoryRowSearchList) { + if (invRow.getId() != 0) { + inventoryRowsToDelete.add(invRow); + } + } + } + selectAll = false; + specificRadio.setSelected(true); + codeTextField.setEnabled(true); + inventoryRowSearchList.clear(); + fireInventoryUpdated(); + } + }); + return resetButton; + } private JScrollPane getScrollPaneInventory() { if (scrollPaneInventory == null) { scrollPaneInventory = new JScrollPane(); - scrollPaneInventory.setViewportView(getJTableInventoryRow()); + try { + scrollPaneInventory.setViewportView(getJTableInventoryRow()); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } } return scrollPaneInventory; } - - private JTable getJTableInventoryRow() { + + private JTable getJTableInventoryRow() throws OHServiceException { if (jTableInventoryRow == null) { jTableInventoryRow = new JTable(); jTetFieldEditor = new JTextField(); jTableInventoryRow.setFillsViewportHeight(true); jTableInventoryRow.setModel(new InventoryRowModel()); + for (int i = 0; i < pColumnVisible.length; i++) { + jTableInventoryRow.getColumnModel().getColumn(i).setCellRenderer(new EnabledTableCellRenderer()); + jTableInventoryRow.getColumnModel().getColumn(i).setPreferredWidth(pColumwidth[i]); + if (i == 0 || !pColumnVisible[i]) { + jTableInventoryRow.getColumnModel().getColumn(i).setMinWidth(0); + jTableInventoryRow.getColumnModel().getColumn(i).setMaxWidth(0); + jTableInventoryRow.getColumnModel().getColumn(i).setPreferredWidth(0); + } + } + DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer(); + centerRenderer.setHorizontalAlignment(JLabel.CENTER); + jTableInventoryRow.getColumnModel().getColumn(3).setCellRenderer(centerRenderer); jTableInventoryRow.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { - if (!e.getValueIsAdjusting()) { - jTableInventoryRow.editCellAt(jTableInventoryRow.getSelectedRow(), 5); + if (e.getValueIsAdjusting()) { + jTableInventoryRow.editCellAt(jTableInventoryRow.getSelectedRow(), jTableInventoryRow.getSelectedColumn()); jTetFieldEditor.selectAll(); - } - - } - }); - jTableInventoryRow.getModel().addTableModelListener(new TableModelListener() { - - @Override - public void tableChanged(TableModelEvent e) { - - if (e.getType() == TableModelEvent.UPDATE) { - int row = e.getFirstRow(); - int column = e.getColumn(); - TableModel model = (TableModel) e.getSource(); - Object data = model.getValueAt(row, column); - - if (column == 2) { - Object data2 = model.getValueAt(row, 3); - if (!data.toString().equals("") && data2.toString().equals("")) { - jTableInventoryRow.setSurrendersFocusOnKeystroke(true); - jTableInventoryRow.getEditorComponent().requestFocus(); - return; - } - } - - if (column == 3) { - Object data2 = model.getValueAt(row, 2); - if (!data.toString().equals("") && data2.toString().equals("")) { - jTableInventoryRow.setSurrendersFocusOnKeystroke(true); - jTableInventoryRow.getEditorComponent().requestFocus(); - return; - } + int[] selectedRows = jTableInventoryRow.getSelectedRows(); + if (selectedRows.length == 1) { + MedicalInventoryRow medInvRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRows[0], -1); + if (medInvRow.getLot() == null || medInvRow.isNewLot()) { + lotButton.setEnabled(true); + } else { + lotButton.setEnabled(false); + } + } else { + lotButton.setEnabled(false); } } + } }); DefaultCellEditor cellEditor = new DefaultCellEditor(jTetFieldEditor); @@ -503,20 +949,54 @@ public void tableChanged(TableModelEvent e) { return jTableInventoryRow; } + class EnabledTableCellRenderer extends DefaultTableCellRenderer { + + private static final long serialVersionUID = 1L; + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + return cell; + } + } class InventoryRowModel extends DefaultTableModel { private static final long serialVersionUID = 1L; + + public InventoryRowModel(boolean add) throws OHServiceException { + inventoryRowList = loadNewInventoryTable(null, inventory, add); + if (!inventoryRowList.isEmpty()) { + for (MedicalInventoryRow invRow : inventoryRowList) { + addMedInRowInInventorySearchList(invRow); + } + selectAll = true; + MessageDialog.info(null, "angal.invetory.allmedicaladdedsuccessfully.msg"); + } else { + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } - public InventoryRowModel() { - if (inventoryRowList != null) { - inventoryRowSearchList = new ArrayList<>(); - inventoryRowSearchList.addAll(inventoryRowList); + public InventoryRowModel() throws OHServiceException { + if (inventory != null) { + inventoryRowList = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()); + } else { + if (allRadio.isSelected()) { + inventoryRowList = loadNewInventoryTable(null, inventory, false); + } + } + if (!inventoryRowList.isEmpty()) { + for (MedicalInventoryRow invRow : inventoryRowList) { + addMedInRowInInventorySearchList(invRow); + if (invRow.getId() == 0) { + inventoryRowListAdded.add(invRow); + } + } } } public Class< ? > getColumnClass(int c) { if (c == 0) { - return String.class; + return Integer.class; } else if (c == 1) { return String.class; } else if (c == 2) { @@ -524,20 +1004,25 @@ public InventoryRowModel() { } else if (c == 3) { return String.class; } else if (c == 4) { - return Integer.class; + return String.class; } else if (c == 5) { - return Integer.class; + return String.class; } else if (c == 6) { return Integer.class; } else if (c == 7) { return Integer.class; + } else if (c == 8) { + return Integer.class; + } else if (c == 9) { + return Integer.class; } return null; } public int getRowCount() { - if (inventoryRowSearchList == null) + if (inventoryRowSearchList == null) { return 0; + } return inventoryRowSearchList.size(); } @@ -554,41 +1039,49 @@ public Object getValueAt(int r, int c) { if (c == -1) { return medInvtRow; } else if (c == 0) { - return medInvtRow.getMedical() == null ? "" : medInvtRow.getMedical().getProdCode(); + return medInvtRow.getId(); } else if (c == 1) { - return medInvtRow.getMedical() == null ? "" : medInvtRow.getMedical().getDescription(); + return medInvtRow.getMedical() == null ? "" : medInvtRow.getMedical().getProdCode(); } else if (c == 2) { + return medInvtRow.getMedical() == null ? "" : medInvtRow.getMedical().getDescription(); + } else if (c == 3) { + if (medInvtRow.getLot() == null || medInvtRow.isNewLot()) { + return "N"; + } + return ""; + } else if (c == 4) { if (medInvtRow.getLot() == null) { return ""; } - return medInvtRow.getLot().getCode(); - } else if (c == 3) { + return medInvtRow.getLot().getCode().equals("") ? "AUTO" : medInvtRow.getLot().getCode(); + } else if (c == 5) { if (medInvtRow.getLot() != null) { if (medInvtRow.getLot().getDueDate() != null) { return medInvtRow.getLot().getDueDate().format(DATE_TIME_FORMATTER); } } return ""; - } else if (c == 4) { + } else if (c == 6) { Double dblVal = medInvtRow.getTheoreticQty(); return dblVal.intValue(); - } else if (c == 5) { + } else if (c == 7) { Double dblValue = medInvtRow.getRealQty(); return dblValue.intValue(); - } else if (c == 6) { + } else if (c == 8) { if (medInvtRow.getLot() != null) { if (medInvtRow.getLot().getCost() != null) { + medInvtRow.setTotal(medInvtRow.getRealQty() * medInvtRow.getLot().getCost().doubleValue()); return medInvtRow.getLot().getCost(); } } - return 0.0; - } else if (c == 7) { + return 0; + } else if (c == 9) { if (medInvtRow.getLot() != null) { if (medInvtRow.getLot().getCost() != null) { - return medInvtRow.getRealQty() * medInvtRow.getLot().getCost().doubleValue(); + return medInvtRow.getTotal(); } } - return 0.0; + return 0; } return null; } @@ -597,41 +1090,27 @@ public Object getValueAt(int r, int c) { public void setValueAt(Object value, int r, int c) { if (r < inventoryRowSearchList.size()) { MedicalInventoryRow invRow = inventoryRowSearchList.get(r); - if (c == 5) { + if (c == 7) { Integer intValue = 0; - try { - intValue = Integer.parseInt(value.toString()); - } catch (NumberFormatException e) { - intValue = 0; + if (value != null) { + try { + intValue = Integer.parseInt(value.toString()); + } catch (NumberFormatException e) { + intValue = 0; + return; + } } - - invRow.setRealqty(intValue); - inventoryRowSearchList.set(r, invRow); - jTableInventoryRow.updateUI(); - } - if (c == 6) { - Double doubleValue = 0.0; - try { - doubleValue = Double.parseDouble(value.toString()); - } catch (NumberFormatException e) { - doubleValue = 0.0; + if (intValue < 0) { + MessageDialog.error(null, "angal.inventoryrow.invalidquantity.msg"); + return; } - Lot lot = invRow.getLot(); - if (lot != null) { - if (lot.getCode().equals("")) { - MessageDialog.error(null, "angal.inventoryrow.cannotchangethepriceofproductwithoutlot.msg"); - } else { - lot.setCost(new BigDecimal(doubleValue)); - try { - Lot saveLot = movStockInsertingManager.updateLot(lot); - invRow.setLot(saveLot); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } + invRow.setRealqty(intValue); + if (invRow.getLot() != null && invRow.getLot().getCost() != null) { + double total = invRow.getRealQty() * invRow.getLot().getCost().doubleValue(); + invRow.setTotal(total); } + inventoryRowListAdded.add(invRow); inventoryRowSearchList.set(r, invRow); - jTableInventoryRow.updateUI(); } } @@ -641,33 +1120,164 @@ public void setValueAt(Object value, int r, int c) { public boolean isCellEditable(int rowIndex, int columnIndex) { return columnEditable[columnIndex]; } - } - - class DecimalFormatRenderer extends DefaultTableCellRenderer { - - private static final long serialVersionUID = 1L; - private final DecimalFormat formatter = new DecimalFormat("#,##0.00"); - - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - cell.addFocusListener(new FocusListener() { - - @Override - public void focusGained(FocusEvent e) { + + private void ajustWith() { + for (int i = 0; i < jTableInventoryRow.getColumnModel().getColumnCount(); i++) { + jTableInventoryRow.getColumnModel().getColumn(i).setPreferredWidth(pColumwidth[i]); + if (i == 0 || !pColumnVisible[i]) { + jTableInventoryRow.getColumnModel().getColumn(i).setMinWidth(0); + jTableInventoryRow.getColumnModel().getColumn(i).setMaxWidth(0); + jTableInventoryRow.getColumnModel().getColumn(i).setPreferredWidth(0); + } + } + DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer(); + centerRenderer.setHorizontalAlignment(JLabel.CENTER); + jTableInventoryRow.getColumnModel().getColumn(3).setCellRenderer(centerRenderer); + } + private Lot getLot(Lot lotToUpdate) throws OHServiceException { + Lot lot = null; + if (isAutomaticLotIn()) { + LocalDateTime preparationDate = TimeTools.getNow().truncatedTo(ChronoUnit.MINUTES); + LocalDateTime expiringDate = askExpiringDate(); + lot = new Lot("", preparationDate, expiringDate); + // Cost + BigDecimal cost = new BigDecimal(0); + if (GeneralData.LOTWITHCOST) { + cost = askCost(2, cost); + if (cost.compareTo(new BigDecimal(0)) == 0) { + return null; } - - @Override - public void focusLost(FocusEvent e) { + } + lot.setCost(cost); + } else { + lot = askLot(lotToUpdate); + } + return lot; + } + + private Lot askLot(Lot lotToUpdate) { + LocalDateTime preparationDate; + LocalDateTime expiringDate; + Lot lot = null; + + JTextField lotNameTextField = new JTextField(15); + lotNameTextField.addAncestorListener(new RequestFocusListener()); + TextPrompt suggestion = new TextPrompt(MessageBundle.getMessage("angal.medicalstock.multiplecharging.lotid"), lotNameTextField); + suggestion.setFont(new Font("Tahoma", Font.PLAIN, 14)); + suggestion.setForeground(Color.GRAY); + suggestion.setHorizontalAlignment(SwingConstants.CENTER); + suggestion.changeAlpha(0.5f); + suggestion.changeStyle(Font.BOLD + Font.ITALIC); + LocalDate now = LocalDate.now(); + GoodDateChooser preparationDateChooser = new GoodDateChooser(now); + GoodDateChooser expireDateChooser = new GoodDateChooser(now); + if (lotToUpdate != null) { + lotNameTextField.setText(lotToUpdate.getCode()); + preparationDateChooser = new GoodDateChooser(lotToUpdate.getPreparationDate().toLocalDate()); + expireDateChooser = new GoodDateChooser(lotToUpdate.getDueDate().toLocalDate()); + } + JPanel panel = new JPanel(new GridLayout(3, 2)); + panel.add(new JLabel(MessageBundle.getMessage("angal.medicalstock.multiplecharging.lotnumberabb"))); + panel.add(lotNameTextField); + panel.add(new JLabel(MessageBundle.getMessage("angal.medicalstock.multiplecharging.preparationdate"))); + panel.add(preparationDateChooser); + panel.add(new JLabel(MessageBundle.getMessage("angal.medicalstock.multiplecharging.expiringdate"))); + panel.add(expireDateChooser); + do { + int ok = JOptionPane.showConfirmDialog( + this, + panel, + MessageBundle.getMessage("angal.medicalstock.multiplecharging.lotinformations"), + JOptionPane.OK_CANCEL_OPTION); + + if (ok == JOptionPane.OK_OPTION) { + String lotName = lotNameTextField.getText(); + if (expireDateChooser.getDate().isBefore(preparationDateChooser.getDate())) { + MessageDialog.error(this, "angal.medicalstock.multiplecharging.expirydatebeforepreparationdate"); + } else { + expiringDate = expireDateChooser.getDateEndOfDay(); + preparationDate = preparationDateChooser.getDateStartOfDay(); + lot = new Lot(lotName, preparationDate, expiringDate); + BigDecimal cost = new BigDecimal(0); + if (GeneralData.LOTWITHCOST) { + if (lotToUpdate != null) { + cost = askCost(2, lotToUpdate.getCost()); + } else { + cost = askCost(2, cost); + } + + if (cost.compareTo(new BigDecimal(0)) == 0) { + return null; + } else { + lot.setCost(cost); + } + } } - }); - - value = formatter.format((Number) value); - if (!columnEditable[column]) { - cell.setBackground(Color.LIGHT_GRAY); + } else { + return null; + } + } while (lot == null); + return lot; + } + private BigDecimal askCost(int qty, BigDecimal lastCost) { + double cost = 0.; + do { + String input = JOptionPane.showInputDialog(this, + MessageBundle.getMessage("angal.medicalstock.multiplecharging.unitcost"), + lastCost); + if (input != null) { + try { + cost = Double.parseDouble(input); + if (cost < 0) { + throw new NumberFormatException(); + } else if (cost == 0.) { + double total = askTotalCost(); + cost = total / qty; + } + } catch (NumberFormatException nfe) { + MessageDialog.error(this, "angal.medicalstock.multiplecharging.pleaseinsertavalidvalue"); + } + } else { + return BigDecimal.valueOf(cost); } - return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + } while (cost == 0.); + return BigDecimal.valueOf(cost); + } + + protected LocalDateTime askExpiringDate() { + LocalDateTime date = TimeTools.getNow(); + GoodDateTimeSpinnerChooser expireDateChooser = new GoodDateTimeSpinnerChooser(date); + JPanel panel = new JPanel(new GridLayout(1, 2)); + panel.add(new JLabel(MessageBundle.getMessage("angal.medicalstock.multiplecharging.expiringdate"))); + panel.add(expireDateChooser); + + int ok = JOptionPane.showConfirmDialog(this, panel, + MessageBundle.getMessage("angal.medicalstock.multiplecharging.expiringdate"), + JOptionPane.OK_CANCEL_OPTION); + + if (ok == JOptionPane.OK_OPTION) { + date = expireDateChooser.getLocalDateTime(); } + return date; + } + + protected double askTotalCost() { + String input = JOptionPane.showInputDialog(this, + MessageBundle.getMessage("angal.medicalstock.multiplecharging.totalcost"), + 0.); + double total = 0.; + if (input != null) { + try { + total = Double.parseDouble(input); + if (total < 0) { + throw new NumberFormatException(); + } + } catch (NumberFormatException nfe) { + MessageDialog.error(this, "angal.medicalstock.multiplecharging.pleaseinsertavalidvalue"); + } + } + return total; } public MedicalInventory getInventory() { @@ -681,26 +1291,11 @@ public void setInventory(MedicalInventory inventory) { private JRadioButton getSpecificRadio() { if (specificRadio == null) { specificRadio = new JRadioButton(MessageBundle.getMessage("angal.inventory.specificproduct.txt")); - if (inventory != null) { - specificRadio.setSelected(false); - } else { - specificRadio.setSelected(true); - } specificRadio.addActionListener(actionEvent -> { if (specificRadio.isSelected()) { codeTextField.setEnabled(true); - searchTextField.setEnabled(false); - moreData.setEnabled(false); - searchTextField.setText(""); codeTextField.setText(""); - if (inventoryRowList != null) { - inventoryRowList.clear(); - } - if (inventoryRowSearchList != null) { - inventoryRowSearchList.clear(); - } - jTableInventoryRow.updateUI(); - ajustWidth(); + allRadio.setSelected(false); } }); } @@ -712,126 +1307,66 @@ private JRadioButton getAllRadio() { allRadio = new JRadioButton(MessageBundle.getMessage("angal.inventory.allproduct.txt")); if (inventory != null) { allRadio.setSelected(true); + specificRadio.setSelected(false); } else { allRadio.setSelected(false); + specificRadio.setSelected(true); } allRadio.addActionListener(actionEvent -> { - if (allRadio.isSelected()) { - codeTextField.setEnabled(false); - searchTextField.setText(""); - codeTextField.setText(""); - searchTextField.setEnabled(true); - if (inventory == null) { - moreData.setEnabled(true); - } - if (inventoryRowList != null) { - inventoryRowList.clear(); - } - if (inventoryRowSearchList != null) { - inventoryRowSearchList.clear(); + if (!selectAll) { + if (allRadio.isSelected()) { + codeTextField.setEnabled(false); + codeTextField.setText(""); + if (inventoryRowSearchList.size() > 0) { + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); + if (info == JOptionPane.YES_OPTION) { + try { + allRadio.setSelected(true); + jTableInventoryRow.setModel(new InventoryRowModel(true)); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } else { + allRadio.setSelected(false); + specificRadio.setSelected(true); + selectAll = false; + } + + } else { + if (mode.equals("update")) { + try { + allRadio.setSelected(true); + jTableInventoryRow.setModel(new InventoryRowModel(true)); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } else { + try { + jTableInventoryRow.setModel(new InventoryRowModel()); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + } + fireInventoryUpdated(); + code = null; + ajustWith(); } - jTableInventoryRow.setModel(new InventoryRowModel()); - jTableInventoryRow.updateUI(); - code = null; - ajustWidth(); + } else { + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); } }); } return allRadio; } - private JTextField getSearchTextField() { - if (searchTextField == null) { - searchTextField = new JTextField(); - searchTextField.setColumns(16); - TextPrompt suggestion = new TextPrompt(MessageBundle.getMessage("angal.common.search.txt"), searchTextField, Show.FOCUS_LOST); - suggestion.setFont(new Font("Tahoma", Font.PLAIN, 12)); - suggestion.setForeground(Color.GRAY); - suggestion.setHorizontalAlignment(JLabel.CENTER); - suggestion.changeAlpha(0.5f); - suggestion.changeStyle(Font.BOLD + Font.ITALIC); - searchTextField.getDocument().addDocumentListener(new DocumentListener() { - - @Override - public void insertUpdate(DocumentEvent e) { - filterInventoryRow(); - ajustWidth(); - } - - @Override - public void removeUpdate(DocumentEvent e) { - filterInventoryRow(); - ajustWidth(); - } - - @Override - public void changedUpdate(DocumentEvent e) { - filterInventoryRow(); - ajustWidth(); - } - }); - searchTextField.setEnabled(false); - if (inventory != null) { - searchTextField.setEnabled(true); - } else { - searchTextField.setEnabled(false); - } - } - return searchTextField; - } - private JLabel getDateInventoryLabel() { if (dateInventoryLabel == null) { dateInventoryLabel = new JLabel(MessageBundle.getMessage("angal.common.date.txt")); } return dateInventoryLabel; } - - private JButton getMoreDataBtn() { - if (moreData == null) { - moreData = new JButton("..."); - moreData.setPreferredSize(new Dimension(20, 20)); - moreData.setEnabled(false); - } - moreData.addActionListener(actionEvent -> { - if (MORE_DATA && inventory == null) { - List medicalList = new ArrayList(); - try { - medicalList = medicalBrowsingManager.getMedicals(); - } catch (OHServiceException e) { - e.printStackTrace(); - } - List lots = null; - MedicalInventoryRow inventoryRowTemp = null; - Iterator medicalIterator = medicalList.iterator(); - Medical medical; - while (medicalIterator.hasNext()) { - medical = medicalIterator.next(); - try { - lots = movStockInsertingManager.getLotByMedical(medical); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - if (lots.size() == 0) { - inventoryRowTemp = new MedicalInventoryRow(0, 0.0, 0.0, null, medical, new Lot("", null, null)); - inventoryRowList.add(inventoryRowTemp); - } else { - for (Lot lot : lots) { - inventoryRowTemp = new MedicalInventoryRow(0, lot.getOverallQuantity(), lot.getOverallQuantity(), null, medical, lot); - inventoryRowList.add(inventoryRowTemp); - } - } - } - inventoryRowSearchList = new ArrayList(); - inventoryRowSearchList.addAll(inventoryRowList); - if (medicalList.size() > 0) { - jTableInventoryRow.updateUI(); - } - } - }); - return moreData; - } - + private JTextField getCodeTextField() { if (codeTextField == null) { codeTextField = new JTextField(); @@ -860,7 +1395,6 @@ public void keyPressed(KeyEvent e) { OHServiceExceptionUtil.showMessages(e1); } codeTextField.setText(""); - ajustWidth(); } } }); @@ -868,109 +1402,122 @@ public void keyPressed(KeyEvent e) { return codeTextField; } - private void addInventoryRow(String code) throws OHServiceException { - List inventoryRowsList = new ArrayList(); - List medicalList = new ArrayList(); + private List loadNewInventoryTable(String code, MedicalInventory inventory, boolean add) throws OHServiceException { + List inventoryRowsList = new ArrayList<>(); + if (inventory != null) { + int id = inventory.getId(); + inventoryRowsList = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(id); + if (add) { + inventoryRowsList = getMedicalInventoryRows(code); + } + } else { + inventoryRowsList = getMedicalInventoryRows(code); + } + return inventoryRowsList; + } + + private List getMedicalInventoryRows(String code) throws OHServiceException { + List inventoryRowsList = new ArrayList<>(); + List medicalList = new ArrayList<>(); List lots = null; Medical medical = null; MedicalInventoryRow inventoryRowTemp = null; if (code != null) { medical = medicalBrowsingManager.getMedicalByMedicalCode(code); if (medical != null) { - boolean found = false; - if (inventoryRowSearchList != null) { - for (MedicalInventoryRow row : inventoryRowSearchList) { - if (row.getMedical().getCode().equals(medical.getCode())) { - found = true; - } - } - } - if (!found) { - medicalList.add(medical); - } + medicalList.add(medical); } else { medical = chooseMedical(code); if (medical != null) { - boolean found = false; - if (inventoryRowSearchList != null) { - for (MedicalInventoryRow row : inventoryRowSearchList) { - if (row.getMedical().getCode().equals(medical.getCode())) { - found = true; - } - } - } - if (!found) { - medicalList.add(medical); - } + medicalList.add(medical); } } } else { medicalList = medicalBrowsingManager.getMedicals(); } - if (mode.equals("new")) { - for (Iterator iterator = medicalList.iterator(); iterator.hasNext();) { - medical = (Medical) iterator.next(); - lots = movStockInsertingManager.getLotByMedical(medical); - if (lots.size() == 0) { - inventoryRowTemp = new MedicalInventoryRow(0, 0.0, 0.0, null, medical, new Lot("", null, null)); + for (Iterator iterator = medicalList.iterator(); iterator.hasNext();) { + Medical med = (Medical) iterator.next(); + lots = movStockInsertingManager.getLotByMedical(med, false); + double actualQty = med.getInitialqty() + med.getInqty() - med.getOutqty(); + if (lots.size() == 0) { + inventoryRowTemp = new MedicalInventoryRow(0, actualQty, actualQty, null, med, null); + if (!existInInventorySearchList(inventoryRowTemp)) { inventoryRowsList.add(inventoryRowTemp); - } else { - for (Iterator iterator2 = lots.iterator(); iterator2.hasNext();) { - Lot lot = (Lot) iterator2.next(); - inventoryRowTemp = new MedicalInventoryRow(0, lot.getOverallQuantity(), lot.getOverallQuantity(), null, medical, lot); + } + } else { + for (Iterator iterator2 = lots.iterator(); iterator2.hasNext();) { + Lot lot = (Lot) iterator2.next(); + inventoryRowTemp = new MedicalInventoryRow(0, lot.getMainStoreQuantity(), lot.getMainStoreQuantity(), null, med, lot); + if (!existInInventorySearchList(inventoryRowTemp)) { inventoryRowsList.add(inventoryRowTemp); } } } - } else if (mode.equals("update")) { + } + return inventoryRowsList; + } + private void addInventoryRow(String code) throws OHServiceException { + List inventoryRowsList = new ArrayList(); + List medicalList = new ArrayList(); + List lots = null; + Medical medical = null; + MedicalInventoryRow inventoryRowTemp = null; + if (code != null) { + medical = medicalBrowsingManager.getMedicalByMedicalCode(code); if (medical != null) { - String medicalCode = medical.getProdCode(); - inventoryRowsList = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()).stream() - .filter(medRow -> medRow.getMedical().getProdCode().equals(medicalCode)).toList(); + medicalList.add(medical); + } else { + medical = chooseMedical(code); + if (medical != null) { + medicalList.add(medical); + } } + } else { + medicalList = medicalBrowsingManager.getMedicals(); } - for (MedicalInventoryRow inventoryRow : inventoryRowsList) { - boolean found = false; - for (MedicalInventoryRow row : inventoryRowSearchList) { - if (row.getMedical().getCode().equals(inventoryRow.getMedical().getCode()) - && (row.getLot().getCode().equals(inventoryRow.getLot().getCode()))) { - found = true; + int numberOfMedicalWithoutSameLotAdded = 0; + Medical medicalWithLot = null; + for (Iterator iterator = medicalList.iterator(); iterator.hasNext();) { + Medical med = (Medical) iterator.next(); + lots = movStockInsertingManager.getLotByMedical(med, false); + if (lots.size() == 0) { + inventoryRowTemp = new MedicalInventoryRow(0, 0.0, 0.0, null, med, null); + if (!existInInventorySearchList(inventoryRowTemp)) { + inventoryRowsList.add(inventoryRowTemp); + } else { + int info = MessageDialog.yesNo(null, "angal.inventory.productalreadyexist.msg", med.getDescription()); + if (info == JOptionPane.YES_OPTION) { + inventoryRowsList.add(inventoryRowTemp); + } + } + } else { + medicalWithLot = med; + for (Iterator iterator2 = lots.iterator(); iterator2.hasNext();) { + Lot lot = (Lot) iterator2.next(); + inventoryRowTemp = new MedicalInventoryRow(0, lot.getMainStoreQuantity(), lot.getMainStoreQuantity(), null, med, lot); + if (!existInInventorySearchList(inventoryRowTemp)) { + inventoryRowsList.add(inventoryRowTemp); + numberOfMedicalWithoutSameLotAdded = numberOfMedicalWithoutSameLotAdded + 1; + } } - } - if (!found) { - inventoryRowSearchList.add(inventoryRow); } } - jTableInventoryRow.updateUI(); - } - - private void filterInventoryRow() { - String s = searchTextField.getText(); - s.trim(); - inventoryRowSearchList = new ArrayList(); - for (MedicalInventoryRow invRow : inventoryRowList) { - if (!s.equals("")) { - String name = invRow.getSearchString(); - if (name.contains(s.toLowerCase())) - inventoryRowSearchList.add(invRow); - } else { - inventoryRowSearchList.add(invRow); + if (medicalWithLot != null && numberOfMedicalWithoutSameLotAdded == 0) { + int info = MessageDialog.yesNo(null, "angal.inventory.productalreadyexist.msg", medicalWithLot.getDescription()); + if (info == JOptionPane.YES_OPTION) { + inventoryRowTemp = new MedicalInventoryRow(0, 0.0, 0.0, null, medicalWithLot, null); + inventoryRowsList.add(inventoryRowTemp); } } + for (MedicalInventoryRow inventoryRow : inventoryRowsList) { + addMedInRowInInventorySearchList(inventoryRow); + } jTableInventoryRow.updateUI(); - searchTextField.requestFocus(); } private Medical chooseMedical(String text) throws OHServiceException { Map medicalMap; List medicals = medicalBrowsingManager.getMedicals(); - if (mode.equals("update")) { - medicals.clear(); - List inventoryRowListTemp = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()); - for (MedicalInventoryRow medicalInventoryRow : inventoryRowListTemp) { - medicals.add(medicalInventoryRow.getMedical()); - } - } medicalMap = new HashMap(); for (Medical med : medicals) { String key = med.getProdCode().toLowerCase(); @@ -1004,12 +1551,6 @@ private Medical chooseMedical(String text) throws OHServiceException { return null; } - private void ajustWidth() { - for (int i = 0; i < pColumwidth.length; i++) { - jTableInventoryRow.getColumnModel().getColumn(i).setMinWidth(pColumwidth[i]); - } - } - public EventListenerList getInventoryListeners() { return InventoryListeners; } @@ -1024,16 +1565,216 @@ private JLabel getReferenceLabel() { } return referenceLabel; } + + private JLabel getStatusLabel() { + if (statusLabel == null) { + String currentStatus = inventory == null ? "draft" : inventory.getStatus(); + statusLabel = new JLabel(MessageBundle.getMessage("angal.inventory.status.label")+" "+MessageBundle.getMessage("angal.inventory."+currentStatus)); + statusLabel.setHorizontalAlignment(SwingConstants.RIGHT); + } + return statusLabel; + } + private JLabel getChargeLabel() { + if (chargeTypeLabel == null) { + chargeTypeLabel = new JLabel(MessageBundle.getMessage("angal.inventory.chargetype.label")); + } + return chargeTypeLabel; + } + + private JLabel getSupplierLabel() { + if (supplierLabel == null) { + supplierLabel = new JLabel(MessageBundle.getMessage("angal.inventory.supplier.label")); + } + return supplierLabel; + } + + private JLabel getDischargeLabel() { + if (dischargeTypeLabel == null) { + dischargeTypeLabel = new JLabel(MessageBundle.getMessage("angal.inventory.dischargetype.label")); + } + return dischargeTypeLabel; + } + + private JLabel getDestinationLabel() { + if (destinationLabel == null) { + destinationLabel = new JLabel(MessageBundle.getMessage("angal.inventory.destination.label")); + } + return destinationLabel; + } + + private JComboBox getJComboCharge() { + MovementType movementSelected = null; + if (chargeCombo == null) { + chargeCombo = new JComboBox(); + try { + List movementTypes = movTypeManager.getMedicalDsrStockMovementType(); + chargeCombo.addItem(null); + for (MovementType movType: movementTypes) { + if (movType.getType().equals("+")) { + chargeCombo.addItem(movType); + if (inventory != null && movType.getCode().equals(inventory.getChargeType())) { + movementSelected = movType; + } + } + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + if (inventory != null) { + chargeCombo.setSelectedItem(movementSelected); + chargeType = movementSelected; + } + chargeCombo.addActionListener(actionEvent -> { + chargeType = (MovementType) chargeCombo.getSelectedItem(); + }); + } + return chargeCombo; + } + + private JComboBox getJComboDischarge() { + MovementType movementSelected = null; + if (dischargeCombo == null) { + dischargeCombo = new JComboBox(); + try { + List movementTypes = movTypeManager.getMedicalDsrStockMovementType(); + dischargeCombo.addItem(null); + for (MovementType movType: movementTypes) { + if(movType.getType().equals("-")) { + dischargeCombo.addItem(movType); + if (inventory != null && movType.getCode().equals(inventory.getDischargeType())) { + movementSelected = movType; + } + } + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + if (inventory != null) { + dischargeCombo.setSelectedItem(movementSelected); + dischargeType = movementSelected; + } + dischargeCombo.addActionListener(actionEvent -> { + dischargeType = (MovementType) dischargeCombo.getSelectedItem(); + }); + } + return dischargeCombo; + } + + private JComboBox getJComboSupplier() { + Supplier supplierSelected = null; + if (supplierCombo == null) { + supplierCombo = new JComboBox(); + try { + List suppliers = supplierManager.getList(); + supplierCombo.addItem(null); + for (Supplier supplier: suppliers) { + supplierCombo.addItem(supplier); + if (inventory != null && supplier.getSupId() == inventory.getSupplier()) { + supplierSelected = supplier; + } + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + if (inventory != null) { + supplierCombo.setSelectedItem(supplierSelected); + supplier = supplierSelected; + } + supplierCombo.addActionListener(actionEvent -> { + supplier = (Supplier) supplierCombo.getSelectedItem(); + }); + } + return supplierCombo; + } + + private JComboBox getJComboDestination() { + Ward destinationSelected = null; + if (destinationCombo == null) { + destinationCombo = new JComboBox(); + try { + List wards = wardManager.getWards(); + destinationCombo.addItem(null); + for (Ward ward: wards) { + destinationCombo.addItem(ward); + if (inventory != null && ward.getCode().equals(inventory.getDestination()) ) { + destinationSelected = ward; + } + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + if (inventory != null) { + destinationCombo.setSelectedItem(destinationSelected); + destination = destinationSelected; + } + destinationCombo.addActionListener(actionEvent -> { + destination = (Ward) destinationCombo.getSelectedItem(); + }); + } + return destinationCombo; + } + private JTextField getReferenceTextField() { if (referenceTextField == null) { referenceTextField = new JTextField(); referenceTextField.setColumns(10); if (inventory != null && !mode.equals("new")) { referenceTextField.setText(inventory.getInventoryReference()); - referenceTextField.setEnabled(false); } } return referenceTextField; } + + private int getPosition (MedicalInventoryRow inventoryRow) { + int position = -1; + int i = 0; + for (MedicalInventoryRow invR: inventoryRowSearchList) { + if (invR.getMedical().getCode().equals(inventoryRow.getMedical().getCode())) { + position = i; + } + i = i + 1; + } + return position; + } + + private boolean existInInventorySearchList(MedicalInventoryRow inventoryRow) { + boolean found = false; + List invRows = inventoryRowSearchList.stream().filter(inv -> inv.getMedical().getCode().equals(inventoryRow.getMedical().getCode())).collect(Collectors.toList()); + if (invRows.size() > 0) { + for (MedicalInventoryRow invR: invRows) { + if (inventoryRow.getLot() != null && invR.getLot() != null) { + if (inventoryRow.getLot().getCode().equals(invR.getLot().getCode())) { + found = true; + break; + } + } else { + if (invR.getLot() == null && inventoryRow.getLot() == null) { + found = true; + break; + } + } + } + } + + return found; + } + private void addMedInRowInInventorySearchList(MedicalInventoryRow inventoryRow) { + int position = getPosition(inventoryRow); + if (position == -1) { + position = inventoryRowSearchList.size(); + inventoryRowSearchList.add(position, inventoryRow); + } else { + inventoryRowSearchList.add(position + 1, inventoryRow); + } + if (inventoryRow.getId() == 0) { + inventoryRowListAdded.add(inventoryRow); + } + } + private void resetVariable() { + inventoryRowsToDelete.clear(); + lotsDeleted.clear(); + inventoryRowListAdded.clear(); + lotsSaved.clear(); + } } diff --git a/src/main/java/org/isf/medicalstock/gui/MovStockMultipleCharging.java b/src/main/java/org/isf/medicalstock/gui/MovStockMultipleCharging.java index ffd32a2181..96e1c91427 100644 --- a/src/main/java/org/isf/medicalstock/gui/MovStockMultipleCharging.java +++ b/src/main/java/org/isf/medicalstock/gui/MovStockMultipleCharging.java @@ -625,7 +625,7 @@ protected Medical chooseMedical(String text) { protected Lot chooseLot(Medical med) { List lots; try { - lots = movStockInsertingManager.getLotByMedical(med); + lots = movStockInsertingManager.getLotByMedical(med, true); } catch (OHServiceException e) { lots = new ArrayList<>(); OHServiceExceptionUtil.showMessages(e); diff --git a/src/main/java/org/isf/medicalstock/gui/MovStockMultipleDischarging.java b/src/main/java/org/isf/medicalstock/gui/MovStockMultipleDischarging.java index e073e185c3..e285526429 100644 --- a/src/main/java/org/isf/medicalstock/gui/MovStockMultipleDischarging.java +++ b/src/main/java/org/isf/medicalstock/gui/MovStockMultipleDischarging.java @@ -287,7 +287,7 @@ private JTextField getJTextFieldSearch() { // Lot (PreparationDate && ExpiringDate) List lots; try { - lots = movStockInsertingManager.getLotByMedical(med); + lots = movStockInsertingManager.getLotByMedical(med, true); } catch (OHServiceException e1) { lots = null; OHServiceExceptionUtil.showMessages(e1); diff --git a/src/main/java/org/isf/utils/jobjects/InventoryStatus.java b/src/main/java/org/isf/utils/jobjects/InventoryStatus.java deleted file mode 100644 index 5e57911a5e..0000000000 --- a/src/main/java/org/isf/utils/jobjects/InventoryStatus.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) - * - * Open Hospital is a free and open source software for healthcare data management. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * https://www.gnu.org/licenses/gpl-3.0-standalone.html - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.isf.utils.jobjects; - - -public enum InventoryStatus { - draft, validated, canceled; -} - diff --git a/src/main/java/org/isf/utils/jobjects/InventoryType.java b/src/main/java/org/isf/utils/jobjects/InventoryType.java deleted file mode 100644 index 7edb00d6c1..0000000000 --- a/src/main/java/org/isf/utils/jobjects/InventoryType.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) - * - * Open Hospital is a free and open source software for healthcare data management. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * https://www.gnu.org/licenses/gpl-3.0-standalone.html - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.isf.utils.jobjects; - - -public enum InventoryType { - main, ward -} diff --git a/src/main/java/org/isf/utils/jobjects/ModalJFrame.java b/src/main/java/org/isf/utils/jobjects/ModalJFrame.java index c6c01cad28..e87ff3677c 100644 --- a/src/main/java/org/isf/utils/jobjects/ModalJFrame.java +++ b/src/main/java/org/isf/utils/jobjects/ModalJFrame.java @@ -1,6 +1,6 @@ /* * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2023 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) * * Open Hospital is a free and open source software for healthcare data management. * From db8149d7b3b941a1a1abb66d31508ccfa0a99ccd Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Thu, 25 Jul 2024 16:37:22 +0100 Subject: [PATCH 057/147] OP-1186 View Inventory (#2028) * fixed one bug --- bundle/language_en.properties | 2 +- .../org/isf/medicalinventory/gui/InventoryBrowser.java | 1 - .../java/org/isf/medicalinventory/gui/InventoryEdit.java | 9 ++++----- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 5a12d786c0..d70652b141 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -706,7 +706,7 @@ angal.inventoryrow.pleaseselectoneinventoryrow.msg angal.inventoryrow.thislotcodealreadyexists.msg = This lot code already exists. Please change it. angal.inventory.inventoryisalreadysaved.msg = This inventory is already saved. Please enter at least one inventory row before continue. angal.inventory.pleaseselectonlyoneinventory.msg = Please select only one inventory. -angal.inventory.pleaseinsertinventory.msg = Please add and inventory in this inventory row. +angal.inventory.pleaseinsertinventory.msg = Please add and inventory in this inventory row. angal.inventory.pleaseselectinventory.msg = Please select inventory. angal.inventoryoperation.save.error.msg = Inventory not saved. angal.inventory.nextarrow.btn = > diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 991dd21598..5ee9e0f88f 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -354,7 +354,6 @@ private JButton getNewButton() { }); return jButtonNew; } - private JButton getUpdateButton() { jButtonEdit = new JButton(MessageBundle.getMessage("angal.common.edit.btn")); jButtonEdit.setMnemonic(MessageBundle.getMnemonic("angal.common.edit.btn.key")); diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 40ba793a28..6a875d3f1f 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -147,8 +147,7 @@ private void fireInventoryUpdated() { for (int i = 0; i < listeners.length; i++) { ((InventoryListener) listeners[i]).InventoryUpdated(event); } - jTableInventoryRow.updateUI(); - + jTableInventoryRow.updateUI(); } private GoodDateChooser jCalendarInventory; @@ -215,7 +214,6 @@ private void fireInventoryUpdated() { private MedicalDsrStockMovementTypeBrowserManager movTypeManager = Context.getApplicationContext().getBean(MedicalDsrStockMovementTypeBrowserManager.class); private SupplierBrowserManager supplierManager = Context.getApplicationContext().getBean(SupplierBrowserManager.class); private WardBrowserManager wardManager = Context.getApplicationContext().getBean(WardBrowserManager.class); - public InventoryEdit() { mode = "new"; @@ -476,7 +474,7 @@ private JButton getSaveButton() { } medicalInventoryRowManager.deleteMedicalInventoryRows(inventoryRowsToDelete); } - if ((inventory == null) && (mode.equals("new"))) { + if (mode.equals("new")) { newReference = referenceTextField.getText().trim(); boolean refExist = false; refExist = medicalInventoryManager.referenceExists(newReference); @@ -549,7 +547,7 @@ private JButton getSaveButton() { if (info != JOptionPane.YES_OPTION) { dispose(); } - } else if ((inventory != null) && (mode.equals("update"))) { + } else if (mode.equals("update")) { String lastCharge = inventory.getChargeType(); String lastDischarge = inventory.getDischargeType(); Integer lastSupplier = inventory.getSupplier(); @@ -992,6 +990,7 @@ public InventoryRowModel() throws OHServiceException { } } } + } public Class< ? > getColumnClass(int c) { From e6ba796f7551f48937c317901b17a8b592f31155 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Fri, 9 Aug 2024 15:02:22 +0100 Subject: [PATCH 058/147] add color to the status label --- .../gui/InventoryBrowser.java | 4 -- .../medicalinventory/gui/InventoryEdit.java | 38 ++++++++++++++----- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 5ee9e0f88f..5be50a1aad 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -370,10 +370,6 @@ private JButton getUpdateButton() { return; } inventory = inventoryList.get(selectedRow); - if (inventory.getStatus().equals(InventoryStatus.validated.toString())) { - MessageDialog.error(null, "angal.inventory.validatednoteditable.msg"); - return; - } if (inventory.getStatus().equals(InventoryStatus.canceled.toString())) { MessageDialog.error(null, "angal.inventory.cancelednoteditable.msg"); return; diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 6a875d3f1f..ebfc7f2119 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -207,6 +207,7 @@ private void fireInventoryUpdated() { private Ward destination = null; private boolean selectAll = false; private String newReference = null; + private static final Dimension STATUS_DIMENSION = new Dimension(220, 20); private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); private MedicalInventoryRowManager medicalInventoryRowManager = Context.getApplicationContext().getBean(MedicalInventoryRowManager.class); private MedicalBrowsingManager medicalBrowsingManager = Context.getApplicationContext().getBean(MedicalBrowsingManager.class); @@ -329,6 +330,12 @@ private JPanel getPanelHeader() { gbc_referenceTextField.gridx = 3; gbc_referenceTextField.gridy = 0; panelHeader.add(getReferenceTextField(), gbc_referenceTextField); + GridBagConstraints gbc_statusLabel = new GridBagConstraints(); + gbc_statusLabel.anchor = GridBagConstraints.WEST; + gbc_statusLabel.insets = new Insets(0, 0, 5, 5); + gbc_statusLabel.gridx = 4; + gbc_statusLabel.gridy = 0; + panelHeader.add(getStatusLabel(), gbc_statusLabel); GridBagConstraints gbc_chargeLabel = new GridBagConstraints(); gbc_chargeLabel.insets = new Insets(0, 0, 5, 5); gbc_chargeLabel.gridx = 0; @@ -396,12 +403,6 @@ private JPanel getPanelHeader() { ButtonGroup group = new ButtonGroup(); group.add(specificRadio); group.add(allRadio); - GridBagConstraints gbc_statusLabel = new GridBagConstraints(); - gbc_statusLabel.anchor = GridBagConstraints.EAST; - gbc_statusLabel.insets = new Insets(0, 0, 5, 5); - gbc_statusLabel.gridx = 3; - gbc_statusLabel.gridy = 3; - panelHeader.add(getStatusLabel(), gbc_statusLabel); } return panelHeader; } @@ -1567,9 +1568,28 @@ private JLabel getReferenceLabel() { private JLabel getStatusLabel() { if (statusLabel == null) { - String currentStatus = inventory == null ? "draft" : inventory.getStatus(); - statusLabel = new JLabel(MessageBundle.getMessage("angal.inventory.status.label")+" "+MessageBundle.getMessage("angal.inventory."+currentStatus)); - statusLabel.setHorizontalAlignment(SwingConstants.RIGHT); + if (inventory == null) { + statusLabel = new JLabel(InventoryStatus.draft.toString()); + statusLabel.setForeground(Color.WHITE); + } else { + String currentStatus = inventory.getStatus().toUpperCase(); + statusLabel = new JLabel(currentStatus); + if (currentStatus.equalsIgnoreCase(InventoryStatus.draft.toString())) { + statusLabel.setForeground(Color.WHITE); + } + if (currentStatus.equalsIgnoreCase(InventoryStatus.validated.toString())) { + statusLabel.setForeground(Color.BLUE); + } + if (currentStatus.equalsIgnoreCase(InventoryStatus.canceled.toString())) { + statusLabel.setForeground(Color.RED); + } + if (currentStatus.equalsIgnoreCase(InventoryStatus.canceled.toString())) { + statusLabel.setForeground(Color.GREEN); + } + } + statusLabel.setPreferredSize(STATUS_DIMENSION); // improve Layouts avoiding fixed dimensions + statusLabel.setHorizontalAlignment(SwingConstants.CENTER); + statusLabel.setFont(new Font(statusLabel.getFont().getName(), Font.BOLD, statusLabel.getFont().getSize() + 8)); } return statusLabel; } From 4d61dcfadedcbddfb20e5c318ff85e9ea0ae2b99 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Fri, 9 Aug 2024 15:10:30 +0100 Subject: [PATCH 059/147] src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index ebfc7f2119..beff46b9e5 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1583,7 +1583,7 @@ private JLabel getStatusLabel() { if (currentStatus.equalsIgnoreCase(InventoryStatus.canceled.toString())) { statusLabel.setForeground(Color.RED); } - if (currentStatus.equalsIgnoreCase(InventoryStatus.canceled.toString())) { + if (currentStatus.equalsIgnoreCase(InventoryStatus.done.toString())) { statusLabel.setForeground(Color.GREEN); } } From 3c6d4b34da85bee82c8d57b44819e80011dc9d9d Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Tue, 20 Aug 2024 09:01:23 +0100 Subject: [PATCH 060/147] Make JTable sortable in edit inventory --- .../java/org/isf/medicalinventory/gui/InventoryEdit.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 6a875d3f1f..6ea9d82fac 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -70,6 +70,8 @@ import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; import org.isf.generaldata.GeneralData; import org.isf.generaldata.MessageBundle; @@ -906,7 +908,8 @@ private JTable getJTableInventoryRow() throws OHServiceException { jTableInventoryRow = new JTable(); jTetFieldEditor = new JTextField(); jTableInventoryRow.setFillsViewportHeight(true); - jTableInventoryRow.setModel(new InventoryRowModel()); + DefaultTableModel model = new InventoryRowModel(); + jTableInventoryRow.setModel(model); for (int i = 0; i < pColumnVisible.length; i++) { jTableInventoryRow.getColumnModel().getColumn(i).setCellRenderer(new EnabledTableCellRenderer()); jTableInventoryRow.getColumnModel().getColumn(i).setPreferredWidth(pColumwidth[i]); @@ -941,6 +944,8 @@ public void valueChanged(ListSelectionEvent e) { } }); + TableRowSorter sorter = new TableRowSorter<>(model); + jTableInventoryRow.setRowSorter(sorter); DefaultCellEditor cellEditor = new DefaultCellEditor(jTetFieldEditor); jTableInventoryRow.setDefaultEditor(Integer.class, cellEditor); } From 4c8ebcf9ddd476b7aec52e7458f1ae84f9db548a Mon Sep 17 00:00:00 2001 From: loique70 Date: Wed, 21 Aug 2024 15:26:02 +0200 Subject: [PATCH 061/147] Add printing method --- bundle/language_en.properties | 4 + rpt_base/Inventory.jasper | Bin 0 -> 40480 bytes rpt_base/Inventory.jrxml | 438 ++++++++++++++++++ rpt_base/Inventory.properties | 25 + rpt_base/Inventory_en.properties | 25 + .../gui/InventoryBrowser.java | 3 - .../medicalinventory/gui/InventoryEdit.java | 51 +- 7 files changed, 540 insertions(+), 6 deletions(-) create mode 100644 rpt_base/Inventory.jasper create mode 100644 rpt_base/Inventory.jrxml create mode 100644 rpt_base/Inventory.properties create mode 100644 rpt_base/Inventory_en.properties diff --git a/bundle/language_en.properties b/bundle/language_en.properties index d70652b141..15afaa0230 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -1902,3 +1902,7 @@ angal.xmpp.usersinfo.border angal.xmpp.wantstosharewithyouthisreport.fmt.msg = \n*** {0} wants to share with you this report: {1}\n angal.xmpp.wouldliketosend.fmt.msg = {0} would like to send: \n{1} angal.xmpp.youhaverejectedthefiletransfer.txt = You have rejected the file transfer. +angal.inventory.pleasesavebeforprinting = Please save the inventory before printing. +angal.inventory.print.success.msg = Inventory printed successfully. +angal.inventory.printing.error.msg = Error occurred while printing the inventory. +angal.inventorywardedit.askforrealquantityempty = Do you want to print the real quantity? \ No newline at end of file diff --git a/rpt_base/Inventory.jasper b/rpt_base/Inventory.jasper new file mode 100644 index 0000000000000000000000000000000000000000..c053b57786306f3b75f5473b40cff9b7691c2a95 GIT binary patch literal 40480 zcmeHw3!GddE4X%ZllNis7b4?-T0o|&Gclb#3DJqekhlb-1_nI=8m zo$fP}2_neLsHm{=RD6J-C=W%&1OZuGud<@90$061TouIY3a+dQUUt2%-v3us=hc0> z`!oiB_qV^Dq)+!bRo_=%RsFxOs=j)h2Y$nJfU_+wW!7xgf5LvN8976_OP0XM-%bOqN53Q zYlzK}(fXp3YItgVJU*kbW)V3NO&)3wYngcR5F*Z!5i?zhXf}IQO{jhndfKv@fnr(6e1?G^S?!$(T;n7|%xHT0)gHK~|Sg$2B2n zC#z3o;%X8Fj&u=}<{aXOCLnb!-EbK@5r9I~`ZHh+@iP=b&uXofO6%Mjk4~t`z7*A9 zH3>cqf{!Q%s{TsjnJ6Uw>;Ut|AZ}LGvKnhSP&B38gOoEwCGIhGJUW%o z!rHNfsZ(J?KRIc6dpMIN8z z`W99-jWr3yn9|}2=n={7B_)|c&2ohZu|_C|M!>O^Q~hK#o|Ku@SShj0QmITrD<$XZ zBnN`b>TCStV!*_A;#|6Rk3-b)}OUFc2MWrHz&fWCuylOXWQB(FoE%`anmUSrJKrx~|el z@nxaRwd_VFoi7PAB4;KaofsRbwGGmxF+W56q-9YBtMFNo&#k z?jAJbqWos1GbuD+T3pTcM$;NwTY`AN8Xfcv8C9FgBzaMz0%u#4F%-{|Hr8fIW`Qsn z%p0-JV;Z$}jYhDnu8yJ-aFyYuU|r5I*m`hE28yTfGeMujnR)w4@K{8aQ~6-)`T%53~H zl|aVW(Mq}+fMZG;e^+E!Td`bGLA2Qlf|$@>Gk9fKBNu>5x{dHGfD@Jp(u{oqWH^lV%G4OH7K=?VzO9zE)jJ`>xrug zixMp?u0*p&Q>nw~R~!zh(`urVHLBCF(7aC&iBGDXtZ4!Tnn}cyha>3Vs9GnRWj;aB zFq;qc(*XCe3F?USPpg@6=wXP>izde=QW@&3nW{zkoEu^bZOP^ZH$fwtUNWpbkis_CpH3*vPz}=Ppn5g+>HwS#yF9u(_7t3`z#QJD7*{rR@7I zy%GkZk_ve}-QYE-j;m18vE1}R>@*`zB$Y~N@pO(vs0t&7-C)WLH^sA^(3ZozDVRzm zG*ln&o(p3IrfM_^Vd_kX5GC0T{se-{`B(LiO`xn-z}G*Lo#snuCrOkt3#adb-w(|RuHJ`9^>FPLCbQxB;b6bvUIqo%Pr zmXhP0d;%;~Bz_rqL=*l5h67}WiS>dITjUTV0llfH;pL6NE<0a|XiIXu+$c$nZ7GMH zK_^*O10ktIjD%i;?8dV}zoI?{bZUa3= zuPH`J$Y=HO>`)T@JAjE7Ig+TM-<>H8{z~;uLn0!Ixt?g`D2zCxcxPK4$zpZUEhUzc zkDh-rpHpe#3Rq+4l!+e7MAH)*TUE4JcMp;>^Qa_X8l{vROT{oul&t7cPY&8LDKTJ^ zd6=c&%M7#^O_AebP;!vc&w;(x;$!*fTaXtZ)7VftjlEW$xd|Eg(b#79tPCp74h?zH zUVx=d%v12wiz#@J8Qsc-KrRgog2|pZjP$+KF5GA z8dPI&3$Kdar;Hxe+Tkonk*%3$9hss_Ivt1RXsmdRVQ6a^&+1g*X6x(`;1)vw3_evZ z06o|eVikwgV-l~Glc^ZjQ7Bg}{g!}PUAmTg5nJM<9ts2-$PEE8u7M%6JR;L;G#O@UZQBTxm6%}^S(N9Mi+W+Pw?WA!9d6#3GNMyMEdc6 zK=LozEhb~vmQw%@?CbjA)f1h58lQ;a0Uw`G0X+WUiZ^bbysq8DJiA!~x;k03^@lp+ zT6Q<9pG+BdGwCn?d?BtF)Ft-acnXN9K6kc{x{$H0wpV&v|B2Os_8 ztKc`R^Goxg62*6GCCMnENj1Ac^#HYSYz{X`7%GX(Ob8doAt6Uh&L`QwLwB zJw`P>k>NAE@ZAolA$q4?N@j`D=+mtWS`?Z|tC+nWQj7Iq)#|d7i!7LYs*AOKs9fq2 z@y3KwfpzB(3{wod-bgX{18Id^xFrZ%oJ86n&XjwXDU}W&165_zb!lWEM@DREp$yGM zYuLs!pnPiKHM4J6KjmRnJ*;{>nn+JX(VlXB3o*|aEb$W29j6AAw`ignrOutY75=yJ z%%M>pU1OdDJ@Dv_^E;CH65*iu3ksG@QJOacd#IQxG;Cb_q=H4QprxaNIu8-Xt@Xub zh}RGq6Q0H}rJ*P5$`xWOe4?g5a)l6MnAfUse<;}PlmU?|o;Kyt$W)jz<#vdLObwEk z&V8;ZoiS&5+&e;$Y=mpC$S;lSiWX(zM7iP@ZD=f2Xmse!Wa~n#X`K3xR1rapWW?|e zmXuG%*q-DLQZ|5=>zkN8qERLZ3XN$-k4Ow13{5EIr?w0?3>vbl+z#5rXvm86{Nos| zQ-Tn7mVDN!QU_2zY|x^kVOU8+ml4q`pYa-;54$O$E6_iXofaM{_!l+ZoPWLp$ccGh|GqL*+U#eUfT#*GPdo;5 zGBz=lJPb3`QOfyaa_J%xR9YoTtT7iJe3Ld}b^;r@A>%Vg7EeaA`E*c?CX5hn>*h{D z`M98kXLl_gbRp>E{_p)XzUS^C-iJX6C@8w36>U)^Q*h49EI&`D$Uc>VbQ5@H(p4I( z?7|>IpbS@zzdo2}4K^A8YcB~f4lM3=qISxm@*8D8ab#B@xN}#8r_hquKRyV`P52b) zAFm@RNr$@iA3KG-!Mm?r@XAMguRgl1>Z(oi-roHQ*^8vOdt@h&e)kidAQ=!}5$7gC z1R5>V^+e1s$3@79GZ{t8vB82=P}$l9Yrvs5#qMyqR5I%+z4VUr;&8StloddLPg(Ig zMO=Dzlvf|R>1^H<-MS$)X$=ht+%sSb6tFGclW)B0g?0rC_R+ zRdUog4!hSE#MJ#)zjE;9#{V4dz4lWbf&2IL=VOZGxQ8xp76VTZF~2-oE(Qdt0|u-C z?lEAca*qK?m5YH#|0)bDaKJ!K_Y|#jGFvLw5I6`6l__pkHWY-w-CK^Wx!}3~`=JAG z-!lJUEr7reDJT5$Y`G8+qz(|U2DpcSmC8K?Bvmd1p8cyJu+RYljgbizOLs1s ziYBp4i3qQR##R)ap1`mf-b?N+IiEBI<*MkuaL+Oaqa*W*!j&+}Ll@~XtzUZIWL7AQ45L3HxSyD0Uj}GnbmrDwEZ4hc*C|LN;Cn!`@Yp}7L5ny;&=wsqc{^g1=>H#|n2 zD)TV3sHeduUt6>Gyn?3nh8sIKxBUE)cMtvNzuYwZbpL1d$`p1(R`Gx^Zmvdb%3_Ev zE(^-Eq>?n>lG*}XTT&a9YfGwA$*k)mHf4ccBJ?fQih~KaR9WWeY;msDtk76(Z+Ccb zq^rL>V6Y(~^rPWRqF>i)%-b~-8Hofgwhz;18`XRe$}P%dK8P>QKGb0Qc2vrE*`rk}9`)xnk&bQ&fwW7}Zb7rBVujg-%a?D-i=?N*YYmDH1z)jd#fpx$jt+WM5DVu(!>P?S zT`}C6TV|`*br5eyFx))4eBp~XhQiw(`+oen%TyRz#tuN0K>fAVBg-z;7DXwpdTx6gIyyRMfMvUsdjj!dsY;$ z?hEC>C`a|J)m_+2^1e$Jzkc5x17AxIU7h;k{Q*p~NwZGLziHj4)iDacOqW~Tg4Ch9 ztpV<<+e+oWx+PU^bx#|WBb2AOGi<3*<+X;oSG2dch#L=6}@DwIM}J?iUL$KsRG zL=WF@)3Ur{`KmUt_eOFBZVRWs%C{P_t}=?rHHNnW!C;&U( znYYtm7+ZeCV0fP1qc#S^Vqm4ORQRwg%sE7Kk~6Rdp(JRpA5U=YdYY(PRV-}|A7CZAq)$s{_^_mcYbC6IlsE$J*^9Fdh(%XmhAwk^SJv_qdxgQ5xJJT z`R8}u^Tt)jH)EldzL12w1wteT&zL?LI9D$dhAxAG;Q_YBl0YKkfBDN_3YCcnvJEyj z^AU~m1Rh2P{e9s9|6rgmQXqp5YDYeG<$^WG_uh2zlErWMKSFf`!fy4_=-w$`IGW4~ z4c+7S(aIH)i97wTre9Y}(DUD1UaNhuWB~ag6_KoPN2^|xe=;uL5FxJT7A2{mvd%5q z0^GNALK4BweLE+qOnU?@7S$QU??Nkvuxh)&tZ{WX*tatj;O65SyxedB@1je=IB)Ap zZ7OB@vtYflufIUwb)iPw_2BBgJd>%1Yp5z`rvv(l^xG84#P6u0+II zYQ}u2ao=)Xb_o;y#pgkDI^QPx&jR{igV1jt{pa&y`&I$C-~WQ=$gLloZoD}Dz|kK+ z(tl40xO3OQ-LR9PKo6hqJQc8ionX%|zb+T{g46-_)&Tdgw^F%>y`(Z>Px<*NFZN&S zHBOIS6m^h`G+w6D8mk@*4D=5QXA4cLuP`v@5%>a>s+SkWo1Rnwa4GQR74W?Z{v}N- zWI`Gcg8OFI@eKZb0bE`C(p`UAyQA`R%eH@}HMV6p+<1=dgr}YhMWxfgGnsGypFy&; zHMYiLK3&*<>v*MuiUw)qH)qG6zk2A5y>A3RQ~&bh6C3;fqXhg(&fgQGQviFSUNMGGl6Q96O|w zha#9qpjEE4e-v){lKa-VGaQT2W@8Qp3kA&uTa>@K;B<(#6T9K0Z{9SI5I8{RQJDK9 zTT4wTV2VI&ri489t=l9_!Mzxpi}RJm>$oAK>d2IuIaYdO>O~X{QZ-^9DKG6#9Ec%y z=3}>5V|FYPPh+RPW}f4Kyc&ZDa$OcXgLuWbqSPbPl0w=6LWQ*hOP{Bs zIClkSu7Js^;zhK3aIcID9;X*Tm7Jivpy)&!b$QxpUz7tZ`JA256@_6QNMN(bJdnVq zXWP%7>TCUdTAv82hH9-THoUM*PI3;WVpU_MY)lpPg1uT)P^dl=uw}rGXfHt3Ptz=` z`$d>E2W1`7mY5O7yruO>0y8H#Zl{v+$rS@)$W2N(=z#X((^Ks8x9gDoFcF-GfY~_u z!-gSqI|{biz=&|O?%7P^cVm)<+CI-#mjvYQcS&G%AiLo2=wh@cmAg~N%!`wkM^7=2 ziaRfY$!W|jW042YDm1tVT21Sg zB9qY=+gZ<&0*Cs${O|=>vMMYncLat~*oLjz2^UDh!GOr-Nas*rx1GZx6IgoFDf$?8 zPI~Sl!QQ~gFu4vaQZ$=9=-7oIdI#@GV zpy9{zC2mG*{4tywlojqq-clCqE9fMZU9=R^Qe`EQs0!eqvT|gqji}JB2?N@~;Fn0H zKCU<9!B`o>%`(VP;Zl`crPpi_8k^k9NVdtK4&#`Jsd9?nHUVc%(gKehTP&R3{M#m;q@QDn}oGiwQMLOlK z%@`zMCw>fGokM__9)`1U_(>W#xC=)?%F`&bsc}$gQ?YoeEk=_nvfo3$qcNQFrDkRf z&%ZH~gT}h5=J~IEeZj$JDwwAS+xB34gb~9*iP{8Uj*}r`GiiNt=cpIrVtRyCkokF5 zV@e18cn*6lhax>|H`C4k#GcaB1V0hW?SO<2B*7Jba>1RkgKTxFF&d}UH;>tm0p#oI z1cM?yR11S0pI~?W>d_7N=v~wb6q(yCt|l8ZBb5&OxiBozQis)KSWRPKk8ZSvK?zy# zc7Ey*&R(Fl7RT$r%fKUIpgQ+}C59M`V3?w4N+ui#p@-t5iNF!jezjNzQfquG&yKa9 zJ=uQt{*|kI{;b7Eg|4_z8P7 zsL3CKVI4NCh{_KGgg?zfD?KMJj{4{_6O=2Q9sCvf=b1GcqH!l26*G=AK`UetSPJ1{ zIe5@YCdF7{@KQ6@GfORFyJZEU*tVf!oElH!pq!{!@0~YJwGJWccyU^DMD90Hz%n;3 z&Mg?!Nn}pS_1Ms~0lEKOO(f>jpFo;zzOOpGKO714LL0!a^osDjx^Q4Arx3YzQ9G_U zwBw7&k!^OrWgnnr9l5pbbA}{W(NO?70@`e)>L8PxNupLVCG5p-^n#>kuOV6b{y#kV zxxIdr3DyD+4brqY^>F!2tLM+|=$j>dq(6f7Lqr|s+})5HrRFKS)Mj<{hlYClBnX;w+}uJp;WwB@{%>@`?r$s>M?w zGSq5YF}D;~t0JCr2PLc66WCA8!=$rCT}zyK&RNV3487#I8uSOn3~>JXBP6DLg-@5# zk-+k_U}MRUb%6k5)+Iv~8#q=AE*UzPkfIct$i3szGk(|i#s$+WxBu#z&t2K~Vu6X= zicQ4ifAEy@=Wz8kJe3wn>~pv_A@wypIKNqL7~vuoTElQ#-Tj-V_BE`(q%T2mFr1dol15OvAKk*k*{5-*oNkT z|Is5?leo(a)s<@qX%hEuxk~1(!Pm#K|Jd}!w=o^~(6S`TAgBU+vbKPp5i%9~OaDy#F zqSov?1sCXmQRc{=Y)4_h6y7d$&1=KIY_|&OgPP>=&6H)JvDXbC$v8Rl*<`vjd4wcdB; zb{}m*#YQvn5cZ`&+-mGYbJ*Zj)Z#EW1o>Z2L0A>uc7D7{`@?5H@}*gyd+@1W{P3k6 zx4i`hhgO4E@XK$@g_R(6fR#1CJ*=!$?qMaVa$)sb*RX0fU}d&Q)nYQ$07-relsE6H zr$-PpTOnh$?`38O2mY6$vk=_>!cUv$uV5orw1kj#FNha!q{F6Jf5??PC+BTd4*V)R z{e5z)y4m?E^5z;*?PgT{)iub!;r8j!n_a{0V;!j2-9D9bd1*_x&v(9q@`SJ1+$mOk z{r+w5fA8KeR>kTLo_M~0#h*fV6d12m&L{EgZl4xiNaaT;mMZ#KB(V=wY(na8pSmo) zpka&--6IeX0P@<06Yu)jAJ!h-`O9CtHrVv-XG7Q`Q)rvklhlnMry#?=mD=4y;Ybh* zRJ!TGDOkl{c@`Ln%aStHU6SUjyDh-Ay4$E+tGiBRsyp%{96*&zEGp>E0aRKsM2V%L-V)x<$s1R?Z{ChvX4mg(cAk+!!Zy{VTnVWod4df73|M5dB~OeU3y zVD9CVzLSYCh^a!S7cNmyD-JkTbKjn1dHamt?aOY6**ZvWz6^&KCa2ff*3v6a&66-q zLOG-NR=mxLzg3%%dK0B6TP=BG*!-lZV6tE%YDGFFDs# zNTY;-vrSry!)2xAAaHlalm9`HtZ4{+Rr1H_k#R)YaJ`JtmCrNPm+qw#rcg48Och)UfL* zElKJC7{Rk#z*wo=14dGrJsPgzm2Z<8L|?o+hy`!5(yRsnp>}&vZ`cFbr-3~%*YoO3 ziAEo#u*2;ruD|kRSI{jAt`?G6u3WgX zOvvS+uH=`a!!?)>>1x9mcn%3Y&zD$K=01Ok4!zg!RqQU?%N1KfkaO648|k}4Mj_v@AC3IvS~ zAh2wo(0SQ`V0gE#vw62lzj=k0F7@#j#?v5`de;tJ6ffS>#@FXz)Lrx)BG{#iH#fBH z9@Ka1O{U`sI&nQJxYGC=dtm2|Wl~xAYDT-TGg3xCemvVSQlJe1SS^|#vH)97lEf-6 z6mMwc74P|h+y=n-Hh|fb<_uX_=YR~`?%0dNrUeozlf`mL+U#Jib~U$8=4Gi~Qc(a^ z4UTQnA6XXL&Jo8vn|!!*+xR{J&w(;Y&LxhaJ$b_f=pWQ8p- z!>kA2DR^h3A%(F~2Du)mLm5Uan-LV&R&?lU$+g%EudrDL6WXzW42%1m1N0O&Pv8B| z^-Zo(RZ6^x*^-{VSRRF3y^WS^U!bsxmQ{Nd@rIr{R>2lEU=iT_TJ$YXYk-rrntq+$ zz-q*=Ga8sz{PH!hTJdXn1FI9i&T3%w;@3G1tU>&0X<)O&uhs_E$eM`Xng%vo{Az1p zbHuNX1~|>!wqa*gl6T=eVY@jux?b&!p@Ni^1U+sqnBc{jqweYgAVm}Dd%Z3z-|H8}m zAw`Q8)Uf^TEC^+Rm$8=}KxxV?EME3DNRgueUN(Y6_~K!46jlw3DtwN{O*!e{M+K_W zIN*UBiuo-;hw=wZ0yASOw&kai*%~$u{@!g;_G=ip@@) zQ}G1$#MZGMmS|v;EC~?+2kvNtQnxrrP{Y!SIKn~fs}hXrSc+vDSe5}wHIxUnAF`DK zmE3Vv$Kq_7wEHLwj1`A6eAQkrgRyPOaXt~*I~v&K?42+g(R5l(!t$rg0E_M|%uBAj^ZpNh)UUm(X#kbbyW!J$NJFhq)Z9Lw<-oxIDxLFO2kF5+OD{HYD z+^@$g0=9VB2LN6R{~5;nqQ~S(w&f4g08$2wHXAZacWt%RUZqI_lURY`TWsg~B&k^Ec8`$lVR>9;)za zalomUeOh5v{D`%~;^tDA?-+ts+e#JpW=rYVZ24{7!z z%>kr&5%{CUm;BdA{wUz)w@VHOZB<#vi*G+T41;Erjp06qd{p92CHz!;5`_=kdcLak zF2OnYo<|T$e`n!ym$;{A#Xjs_N%xc)kG&2wEybq?pR3I0h4?5kZRKgit-)s{K5+ec z#_>6V&rSF|)O@J-UeCP8SbTr$!))aVcKAt_dW0Q0$)=iTPO!^Puq%4+RbH3ji*4ao zBOF9a#6u(UQ#^9>wI|rSC8PI=h)Z)Keq2O+e_q5hb0SWOh#$<0xJ*R+CiLN9CU5R# zRn0dV!fX+wAIc+Lk(0(8a9DkU-Hhx%#k|co-pgj0PkQfVzr)?xoaUAj?6%4~MVxbp z{bTHo{mmac$v%N7YdMQMPq0slyz}y74@( z^$wHlDVAhUvkYLFWpALrv6RgyK6W|a`A#K>UcgoCYUNt?Zou%k@*uk&FnquAUG{gL zYIY;w_#sanyA_bU&C|;604zU>|66naOKI-^A8qbqB{f&ZD5<&moN_hS#;Ks@DlKsM zwz7MaHg>Plj-lUr_LQ=LJ*{kJuPf)XHYepDN8IM>gJ7r=3bKw#~V}hC z=kb{Q;m3`K90elgSB!@X%$Uy@4;PvbUp5{tG9D^?HkMb?Vw8gOF&kzna9^jp5>Qqf u$(_cNdky(gx{QaXn-8@a%JMZ@fl5%5hu~JnsakRZZZ{5W8talXS^p1{)zpXp literal 0 HcmV?d00001 diff --git a/rpt_base/Inventory.jrxml b/rpt_base/Inventory.jrxml new file mode 100644 index 0000000000..f0680c3b09 --- /dev/null +++ b/rpt_base/Inventory.jrxml @@ -0,0 +1,438 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="133" splitType="Stretch"> + <rectangle radius="0"> + <reportElement key="rectangle-1" mode="Opaque" x="0" y="1" width="535" height="48" forecolor="#00CCCC" backcolor="#000099" uuid="60b6da4f-23fc-4c9b-978c-8956b205640a"/> + </rectangle> + <textField> + <reportElement key="staticText" x="5" y="5" width="471" height="40" forecolor="#FFFFFF" backcolor="#FFFFFF" uuid="e4f3520f-cbd2-4cf3-b680-dff52d7747e6"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Justified" verticalAlignment="Top" rotation="None"> + <font fontName="DejaVu Sans" size="24" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{Inventory}]]></textFieldExpression> + </textField> + <image hAlign="Right" vAlign="Middle" onErrorType="Icon"> + <reportElement key="image-1" x="476" y="5" width="56" height="40" uuid="c5e0caf3-fc70-4ce6-bce3-7ee2452e1f76"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <imageExpression><![CDATA[$P{PATH_LOGO} + "logo_report.png"]]></imageExpression> + </image> + <textField textAdjust="StretchHeight" isBlankWhenNull="false"> + <reportElement key="textField-4" x="0" y="49" width="535" height="22" uuid="7b49f1fa-6ea9-4403-bc27-6d8fe8bb8621"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font fontName="DejaVu Sans" size="12" isBold="true"/> + </textElement> + <textFieldExpression><![CDATA[$P{Hospital}]]></textFieldExpression> + </textField> + <textField textAdjust="StretchHeight" isBlankWhenNull="false"> + <reportElement key="textField-5" x="0" y="71" width="535" height="17" uuid="530e5c8b-7fb7-4349-be8d-0c5a89067ef4"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font fontName="DejaVu Sans" size="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false"/> + </textElement> + <textFieldExpression><![CDATA[$P{Address} + " - " + $P{City}]]></textFieldExpression> + </textField> + <textField textAdjust="StretchHeight" isBlankWhenNull="false"> + <reportElement key="textField-6" x="0" y="88" width="535" height="17" uuid="51cf5a07-e70f-41cd-bc53-63a3b44480c1"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font fontName="DejaVu Sans" size="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false"/> + </textElement> + <textFieldExpression><![CDATA[$P{Email}]]></textFieldExpression> + </textField> + <textField textAdjust="StretchHeight" isBlankWhenNull="false"> + <reportElement key="textField-7" x="0" y="105" width="535" height="17" uuid="1005a0e2-f795-4838-853f-541e27cb0b6d"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle"> + <font fontName="DejaVu Sans" size="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false"/> + </textElement> + <textFieldExpression><![CDATA[$P{Telephone}]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rpt_base/Inventory.properties b/rpt_base/Inventory.properties new file mode 100644 index 0000000000..6ad2960d81 --- /dev/null +++ b/rpt_base/Inventory.properties @@ -0,0 +1,25 @@ +#Generated by Eclipse Messages Editor (Eclipse Babel) + +Inventory = Inventory + +Code = Code + +Status = Status + +Reference = Reference + +InventoryDate = Inventory Date + +PrincipalWardInventory = PRINCIPAL WARD INVENTORY + +Designation = Designation + +WardCode = Ward Code + +DueDate = Due Date + +TheoryQuantity = Theory Quantity + +RealQuantity = R. Quantity + + diff --git a/rpt_base/Inventory_en.properties b/rpt_base/Inventory_en.properties new file mode 100644 index 0000000000..6ad2960d81 --- /dev/null +++ b/rpt_base/Inventory_en.properties @@ -0,0 +1,25 @@ +#Generated by Eclipse Messages Editor (Eclipse Babel) + +Inventory = Inventory + +Code = Code + +Status = Status + +Reference = Reference + +InventoryDate = Inventory Date + +PrincipalWardInventory = PRINCIPAL WARD INVENTORY + +Designation = Designation + +WardCode = Ward Code + +DueDate = Due Date + +TheoryQuantity = Theory Quantity + +RealQuantity = R. Quantity + + diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 5ee9e0f88f..de94e3cbb8 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -266,7 +266,6 @@ private JPanel getPanelFooter() { panelFooter.add(getNewButton()); panelFooter.add(getUpdateButton()); panelFooter.add(getViewButton()); - panelFooter.add(getPrintButton()); panelFooter.add(getDeleteButton()); panelFooter.add(getCloseButton()); } @@ -455,12 +454,10 @@ public void valueChanged(ListSelectionEvent e) { if (selectedRows.length == 1) { jButtonEdit.setEnabled(true); jButtonView.setEnabled(true); - jButtonPrint.setEnabled(true); jButtonDelete.setEnabled(true); } else { jButtonEdit.setEnabled(false); jButtonView.setEnabled(false); - jButtonPrint.setEnabled(false); jButtonDelete.setEnabled(false); } } diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 6a875d3f1f..0277b7bce5 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -87,6 +87,8 @@ import org.isf.medstockmovtype.model.MovementType; import org.isf.menu.manager.Context; import org.isf.menu.manager.UserBrowsingManager; +import org.isf.stat.dto.JasperReportResultDto; +import org.isf.stat.manager.JasperReportsManager; import org.isf.supplier.manager.SupplierBrowserManager; import org.isf.supplier.model.Supplier; import org.isf.utils.db.NormalizeString; @@ -102,6 +104,8 @@ import org.isf.utils.time.TimeTools; import org.isf.ward.manager.WardBrowserManager; import org.isf.ward.model.Ward; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class InventoryEdit extends ModalJFrame { @@ -156,6 +160,7 @@ private void fireInventoryUpdated() { private JPanel panelFooter; private JPanel panelContent; private JButton closeButton; + private JButton printButton; private JButton deleteButton; private JButton saveButton; private JButton resetButton; @@ -214,7 +219,8 @@ private void fireInventoryUpdated() { private MedicalDsrStockMovementTypeBrowserManager movTypeManager = Context.getApplicationContext().getBean(MedicalDsrStockMovementTypeBrowserManager.class); private SupplierBrowserManager supplierManager = Context.getApplicationContext().getBean(SupplierBrowserManager.class); private WardBrowserManager wardManager = Context.getApplicationContext().getBean(WardBrowserManager.class); - + private JasperReportsManager jasperReportsManager = Context.getApplicationContext().getBean(JasperReportsManager.class); + public InventoryEdit() { mode = "new"; initComponents(); @@ -278,6 +284,7 @@ public void windowClosing(WindowEvent e) { supplierCombo.setEnabled(false); destinationCombo.setEnabled(false); lotButton.setVisible(false); + printButton.setVisible(true); } else { saveButton.setVisible(true); deleteButton.setVisible(true); @@ -292,6 +299,7 @@ public void windowClosing(WindowEvent e) { supplierCombo.setEnabled(true); destinationCombo.setEnabled(true); lotButton.setVisible(true); + printButton.setVisible(false); } } @@ -431,6 +439,7 @@ private JPanel getPanelFooter() { panelFooter.add(getDeleteButton()); panelFooter.add(getLotButton()); panelFooter.add(getCleanTableButton()); + panelFooter.add(getPrintButton()); panelFooter.add(getCloseButton()); } return panelFooter; @@ -865,8 +874,44 @@ private JButton getCloseButton() { }); return closeButton; } - - private JButton getCleanTableButton() { + + private JButton getPrintButton() { + printButton = new JButton(MessageBundle.getMessage("angal.common.print.btn")); + printButton.setMnemonic(MessageBundle.getMnemonic("angal.common.print.btn.key")); + printButton.setEnabled(true); + + printButton.addActionListener(e -> { + if (inventory == null || inventory.getId() <= 0) { + MessageDialog.info(this, "angal.inventory.pleasesavebeforprinting"); + return; + } + + if (InventoryStatus.done.name().equals(inventory.getStatus())) { + int printQtyReal = 0; + int response = MessageDialog.yesNo(this, "angal.inventorywardedit.askforrealquantityempty"); + if (response == JOptionPane.YES_OPTION) { + printQtyReal = 1; + } + + try { + JasperReportResultDto reportResult = jasperReportsManager.getInventoryReportPdf(inventory, "Inventory", printQtyReal); + if (reportResult != null) { + MessageDialog.info(this, "angal.inventory.print.success.msg"); + } else { + MessageDialog.error(this, "angal.inventory.printing.error.msg"); + } + } catch (OHServiceException ex) { + MessageDialog.error(this, "angal.inventory.printing.error.msg"); + } + } else { + MessageDialog.info(this, "angal.inventory.pleasesavebeforprinting"); + } + }); + + return printButton; + } + + private JButton getCleanTableButton() { resetButton = new JButton(MessageBundle.getMessage("angal.inventory.clean.btn")); resetButton.setMnemonic(MessageBundle.getMnemonic("angal.inventory.clean.btn.key")); resetButton.addActionListener(actionEvent -> { From 37c3d89861e3a9b497aa4e3423b7ae7f8df5576f Mon Sep 17 00:00:00 2001 From: mwithi Date: Wed, 4 Sep 2024 22:44:40 +0200 Subject: [PATCH 062/147] OP-1303 Fix layout --- .../medicalinventory/gui/InventoryEdit.java | 193 ++++++++++-------- 1 file changed, 106 insertions(+), 87 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index beff46b9e5..3cc7accd25 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -128,9 +128,10 @@ public static void removeInventoryListener(InventoryListener listener) { private void fireInventoryInserted() { AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { + private static final long serialVersionUID = 1L; }; - + EventListener[] listeners = InventoryListeners.getListeners(InventoryListener.class); for (int i = 0; i < listeners.length; i++) { ((InventoryListener) listeners[i]).InventoryInserted(event); @@ -140,16 +141,17 @@ private void fireInventoryInserted() { private void fireInventoryUpdated() { AWTEvent event = new AWTEvent(new Object(), AWTEvent.RESERVED_ID_MAX + 1) { + private static final long serialVersionUID = 1L; }; - + EventListener[] listeners = InventoryListeners.getListeners(InventoryListener.class); for (int i = 0; i < listeners.length; i++) { ((InventoryListener) listeners[i]).InventoryUpdated(event); } - jTableInventoryRow.updateUI(); + jTableInventoryRow.updateUI(); } - + private GoodDateChooser jCalendarInventory; private LocalDateTime dateInventory = TimeTools.getNow(); private JPanel panelHeader; @@ -181,7 +183,8 @@ private void fireInventoryUpdated() { private int[] pColumwidth = { 50, 50, 200, 100, 100, 100, 100, 80, 80, 80 }; private boolean[] columnEditable = { false, false, false, false, false, false, false, true, false, false }; private boolean[] columnEditableView = { false, false, false, false, false, false, false, false, false, false }; - private boolean[] pColumnVisible = { false, true, true, true, !GeneralData.AUTOMATICLOT_IN, true, true, true, GeneralData.LOTWITHCOST, GeneralData.LOTWITHCOST }; + private boolean[] pColumnVisible = { false, true, true, true, !GeneralData.AUTOMATICLOT_IN, true, true, true, GeneralData.LOTWITHCOST, + GeneralData.LOTWITHCOST }; private MedicalInventory inventory = null; private JRadioButton specificRadio; private JRadioButton allRadio; @@ -207,7 +210,6 @@ private void fireInventoryUpdated() { private Ward destination = null; private boolean selectAll = false; private String newReference = null; - private static final Dimension STATUS_DIMENSION = new Dimension(220, 20); private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); private MedicalInventoryRowManager medicalInventoryRowManager = Context.getApplicationContext().getBean(MedicalInventoryRowManager.class); private MedicalBrowsingManager medicalBrowsingManager = Context.getApplicationContext().getBean(MedicalBrowsingManager.class); @@ -215,16 +217,16 @@ private void fireInventoryUpdated() { private MedicalDsrStockMovementTypeBrowserManager movTypeManager = Context.getApplicationContext().getBean(MedicalDsrStockMovementTypeBrowserManager.class); private SupplierBrowserManager supplierManager = Context.getApplicationContext().getBean(SupplierBrowserManager.class); private WardBrowserManager wardManager = Context.getApplicationContext().getBean(WardBrowserManager.class); - + public InventoryEdit() { mode = "new"; initComponents(); } - + private boolean isAutomaticLotIn() { return GeneralData.AUTOMATICLOT_IN; } - + public InventoryEdit(MedicalInventory inventory, String mod) { this.inventory = inventory; mode = mod; @@ -239,10 +241,10 @@ private void initComponents() { setLocationRelativeTo(null); if (mode.equals("new")) { setTitle(MessageBundle.getMessage("angal.inventory.newinventory.title")); - } + } if (mode.equals("view")) { setTitle(MessageBundle.getMessage("angal.inventory.viewinventory.title")); - } + } if (mode.equals("update")) { setTitle(MessageBundle.getMessage("angal.inventory.editinventory.title")); } @@ -301,17 +303,17 @@ private JPanel getPanelHeader() { panelHeader = new JPanel(); panelHeader.setBorder(new EmptyBorder(5, 0, 5, 0)); GridBagLayout gbl_panelHeader = new GridBagLayout(); - gbl_panelHeader.columnWidths = new int[] { 159, 191, 192, 218, 51, 0 }; - gbl_panelHeader.rowHeights = new int[] { 30, 30, 0 }; + gbl_panelHeader.columnWidths = new int[] { 159, 191, 192, 218, 218, 0 }; + gbl_panelHeader.rowHeights = new int[] { 30, 30, 30, 30, 0 }; gbl_panelHeader.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; - gbl_panelHeader.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; + gbl_panelHeader.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; panelHeader.setLayout(gbl_panelHeader); GridBagConstraints gbc_dateInventoryLabel = new GridBagConstraints(); + gbc_dateInventoryLabel.anchor = GridBagConstraints.EAST; gbc_dateInventoryLabel.insets = new Insets(0, 0, 5, 5); gbc_dateInventoryLabel.gridx = 0; gbc_dateInventoryLabel.gridy = 0; panelHeader.add(getDateInventoryLabel(), gbc_dateInventoryLabel); - GridBagConstraints gbc_jCalendarInventory = new GridBagConstraints(); gbc_jCalendarInventory.fill = GridBagConstraints.HORIZONTAL; gbc_jCalendarInventory.insets = new Insets(0, 0, 5, 5); @@ -331,12 +333,14 @@ private JPanel getPanelHeader() { gbc_referenceTextField.gridy = 0; panelHeader.add(getReferenceTextField(), gbc_referenceTextField); GridBagConstraints gbc_statusLabel = new GridBagConstraints(); - gbc_statusLabel.anchor = GridBagConstraints.WEST; + gbc_statusLabel.anchor = GridBagConstraints.CENTER; gbc_statusLabel.insets = new Insets(0, 0, 5, 5); gbc_statusLabel.gridx = 4; gbc_statusLabel.gridy = 0; + gbc_statusLabel.gridheight = 3; panelHeader.add(getStatusLabel(), gbc_statusLabel); GridBagConstraints gbc_chargeLabel = new GridBagConstraints(); + gbc_chargeLabel.anchor = GridBagConstraints.EAST; gbc_chargeLabel.insets = new Insets(0, 0, 5, 5); gbc_chargeLabel.gridx = 0; gbc_chargeLabel.gridy = 1; @@ -360,6 +364,7 @@ private JPanel getPanelHeader() { gbc_supplierCombo.gridy = 1; panelHeader.add(getJComboSupplier(), gbc_supplierCombo); GridBagConstraints gbc_dischargeLabel = new GridBagConstraints(); + gbc_dischargeLabel.anchor = GridBagConstraints.EAST; gbc_dischargeLabel.insets = new Insets(0, 0, 5, 5); gbc_dischargeLabel.gridx = 0; gbc_dischargeLabel.gridy = 2; @@ -466,19 +471,19 @@ private JButton getSaveButton() { for (Map.Entry entry : lotsDeleted.entrySet()) { MedicalInventoryRow invRow = null; invRow = medicalInventoryRowManager.getMedicalInventoryRowById(entry.getKey()); - if (invRow != null ) { + if (invRow != null) { invRow.setLot(null); medicalInventoryRowManager.updateMedicalInventoryRow(invRow); movStockInsertingManager.deleteLot(entry.getValue()); } - - } + + } medicalInventoryRowManager.deleteMedicalInventoryRows(inventoryRowsToDelete); } if (mode.equals("new")) { newReference = referenceTextField.getText().trim(); boolean refExist = false; - refExist = medicalInventoryManager.referenceExists(newReference); + refExist = medicalInventoryManager.referenceExists(newReference); if (refExist) { MessageDialog.error(null, "angal.inventory.referencealreadyused.msg"); return; @@ -546,7 +551,7 @@ private JButton getSaveButton() { resetVariable(); int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttocontinueediting.msg"); if (info != JOptionPane.YES_OPTION) { - dispose(); + dispose(); } } else if (mode.equals("update")) { String lastCharge = inventory.getChargeType(); @@ -555,13 +560,18 @@ private JButton getSaveButton() { String lastDestination = inventory.getDestination(); String lastReference = inventory.getInventoryReference(); newReference = referenceTextField.getText().trim(); - MedicalInventory existingInventory = medicalInventoryManager.getInventoryByReference(newReference); + MedicalInventory existingInventory = medicalInventoryManager.getInventoryByReference(newReference); if (existingInventory != null && existingInventory.getId() != inventory.getId()) { MessageDialog.error(null, "angal.inventory.referencealreadyused.msg"); return; } if (inventoryRowListAdded.isEmpty() && lotsSaved.isEmpty() && lotsDeleted.isEmpty()) { - if ((destination != null && !destination.getCode().equals(lastDestination)) || (chargeType != null && !chargeType.getCode().equals(lastCharge)) || (dischargeType != null && !dischargeType.getCode().equals(lastDischarge)) || (supplier != null && !supplier.getSupId().equals(lastSupplier)) || (destination == null && lastDestination != null) || (chargeType == null && lastCharge != null) || (dischargeType == null && lastDischarge != null) || (supplier == null && lastSupplier != null) || !lastReference.equals(newReference)) { + if ((destination != null && !destination.getCode().equals(lastDestination)) + || (chargeType != null && !chargeType.getCode().equals(lastCharge)) + || (dischargeType != null && !dischargeType.getCode().equals(lastDischarge)) + || (supplier != null && !supplier.getSupId().equals(lastSupplier)) || (destination == null && lastDestination != null) + || (chargeType == null && lastCharge != null) || (dischargeType == null && lastDischarge != null) + || (supplier == null && lastSupplier != null) || !lastReference.equals(newReference)) { if (!inventory.getInventoryDate().equals(dateInventory)) { inventory.setInventoryDate(dateInventory); } @@ -602,7 +612,7 @@ private JButton getSaveButton() { fireInventoryUpdated(); int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttocontinueediting.msg"); if (info != JOptionPane.YES_OPTION) { - dispose(); + dispose(); } } else { MessageDialog.error(null, "angal.inventory.update.error.msg"); @@ -615,13 +625,13 @@ private JButton getSaveButton() { fireInventoryUpdated(); int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttocontinueediting.msg"); if (info != JOptionPane.YES_OPTION) { - dispose(); + dispose(); } } else { MessageDialog.info(null, "angal.inventory.inventoryisalreadysaved.msg"); return; } - + } return; } @@ -727,7 +737,7 @@ private JButton getSaveButton() { fireInventoryUpdated(); int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttocontinueediting.msg"); if (info != JOptionPane.YES_OPTION) { - dispose(); + dispose(); } } } catch (OHServiceException e) { @@ -752,7 +762,7 @@ private JButton getDeleteButton() { for (int i = selectedRows.length - 1; i >= 0; i--) { MedicalInventoryRow selectedInventoryRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRows[i], -1); inventoryRowSearchList.remove(selectedInventoryRow); - } + } } else { for (int i = selectedRows.length - 1; i >= 0; i--) { MedicalInventoryRow inventoryRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRows[i], -1); @@ -770,7 +780,7 @@ private JButton getDeleteButton() { }); return deleteButton; } - + private JButton getLotButton() { lotButton = new JButton(MessageBundle.getMessage("angal.inventory.lot.btn")); lotButton.setMnemonic(MessageBundle.getMnemonic("angal.inventory.lot.btn.key")); @@ -785,21 +795,22 @@ private JButton getLotButton() { Lot lot = new Lot(); try { lot = this.getLot(lotToUpdate); - String lotCode = lotToUpdate != null ? lotToUpdate.getCode():""; + String lotCode = lotToUpdate != null ? lotToUpdate.getCode() : ""; if (lot != null && !lot.getCode().equals(lotCode)) { Lot lotDelete = movStockInsertingManager.getLot(lotCode); if (lotDelete != null) { lotsDeleted.put(selectedInventoryRow.getId(), lotDelete); - } + } } } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); return; - } + } if (lot != null) { - code = lot.getCode(); + code = lot.getCode(); if (selectedInventoryRow.getLot() == null) { - List invRows = inventoryRowSearchList.stream().filter(inv -> inv.getLot() != null && inv.getLot().getCode().equals(code)).collect(Collectors.toList()); + List invRows = inventoryRowSearchList.stream() + .filter(inv -> inv.getLot() != null && inv.getLot().getCode().equals(code)).collect(Collectors.toList()); if (invRows.size() == 0 || code.equals("")) { selectedInventoryRow.setNewLot(true); selectedInventoryRow.setLot(lot); @@ -809,7 +820,8 @@ private JButton getLotButton() { lotButton.doClick(); } } else { - List invRows = inventoryRowSearchList.stream().filter(inv -> inv.getMedical().getCode().equals(selectedInventoryRow.getMedical().getCode())).collect(Collectors.toList()); + List invRows = inventoryRowSearchList.stream() + .filter(inv -> inv.getMedical().getCode().equals(selectedInventoryRow.getMedical().getCode())).collect(Collectors.toList()); invRows = invRows.stream().filter(inv -> inv.getLot() != null && inv.getLot().getCode().equals(code)).collect(Collectors.toList()); if (invRows.size() == 0 || code.equals("")) { selectedInventoryRow.setNewLot(true); @@ -827,7 +839,7 @@ private JButton getLotButton() { lotButton.setEnabled(false); return lotButton; } - + private JButton getCloseButton() { closeButton = new JButton(MessageBundle.getMessage("angal.common.close.btn")); closeButton.setMnemonic(MessageBundle.getMnemonic("angal.common.close.btn.key")); @@ -847,7 +859,14 @@ private JButton getCloseButton() { lastReference = inventory.getInventoryReference(); lastDate = inventory.getInventoryDate(); } - if (!lotsSaved.isEmpty() || !inventoryRowListAdded.isEmpty() || !lotsDeleted.isEmpty() || !inventoryRowsToDelete.isEmpty() || (destination != null && !destination.getCode().equals(lastDestination)) || (chargeType != null && !chargeType.getCode().equals(lastCharge)) || (dischargeType != null && !dischargeType.getCode().equals(lastDischarge)) || (supplier != null && !supplier.getSupId().equals(lastSupplier)) ||(destination == null && lastDestination != null) || (chargeType == null && lastCharge != null) || (dischargeType == null && lastDischarge != null) || (supplier == null && lastSupplier != null) || !lastReference.equals(newReference) || !lastDate.toLocalDate().equals(dateInventory.toLocalDate())) { + if (!lotsSaved.isEmpty() || !inventoryRowListAdded.isEmpty() || !lotsDeleted.isEmpty() || !inventoryRowsToDelete.isEmpty() + || (destination != null && !destination.getCode().equals(lastDestination)) + || (chargeType != null && !chargeType.getCode().equals(lastCharge)) + || (dischargeType != null && !dischargeType.getCode().equals(lastDischarge)) + || (supplier != null && !supplier.getSupId().equals(lastSupplier)) || (destination == null && lastDestination != null) + || (chargeType == null && lastCharge != null) || (dischargeType == null && lastDischarge != null) + || (supplier == null && lastSupplier != null) || !lastReference.equals(newReference) + || !lastDate.toLocalDate().equals(dateInventory.toLocalDate())) { int reset = MessageDialog.yesNoCancel(null, "angal.inventoryrow.doyouwanttosavethechanges.msg"); if (reset == JOptionPane.YES_OPTION) { this.saveButton.doClick(); @@ -866,7 +885,7 @@ private JButton getCloseButton() { }); return closeButton; } - + private JButton getCleanTableButton() { resetButton = new JButton(MessageBundle.getMessage("angal.inventory.clean.btn")); resetButton.setMnemonic(MessageBundle.getMnemonic("angal.inventory.clean.btn.key")); @@ -901,7 +920,7 @@ private JScrollPane getScrollPaneInventory() { } return scrollPaneInventory; } - + private JTable getJTableInventoryRow() throws OHServiceException { if (jTableInventoryRow == null) { jTableInventoryRow = new JTable(); @@ -918,8 +937,8 @@ private JTable getJTableInventoryRow() throws OHServiceException { } } DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer(); - centerRenderer.setHorizontalAlignment(JLabel.CENTER); - jTableInventoryRow.getColumnModel().getColumn(3).setCellRenderer(centerRenderer); + centerRenderer.setHorizontalAlignment(JLabel.CENTER); + jTableInventoryRow.getColumnModel().getColumn(3).setCellRenderer(centerRenderer); jTableInventoryRow.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override @@ -932,9 +951,9 @@ public void valueChanged(ListSelectionEvent e) { MedicalInventoryRow medInvRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRows[0], -1); if (medInvRow.getLot() == null || medInvRow.isNewLot()) { lotButton.setEnabled(true); - } else { - lotButton.setEnabled(false); - } + } else { + lotButton.setEnabled(false); + } } else { lotButton.setEnabled(false); } @@ -958,10 +977,11 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole return cell; } } + class InventoryRowModel extends DefaultTableModel { private static final long serialVersionUID = 1L; - + public InventoryRowModel(boolean add) throws OHServiceException { inventoryRowList = loadNewInventoryTable(null, inventory, add); if (!inventoryRowList.isEmpty()) { @@ -991,7 +1011,7 @@ public InventoryRowModel() throws OHServiceException { } } } - + } public Class< ? > getColumnClass(int c) { @@ -1101,7 +1121,7 @@ public void setValueAt(Object value, int r, int c) { } } if (intValue < 0) { - MessageDialog.error(null, "angal.inventoryrow.invalidquantity.msg"); + MessageDialog.error(null, "angal.inventoryrow.invalidquantity.msg"); return; } invRow.setRealqty(intValue); @@ -1121,7 +1141,7 @@ public boolean isCellEditable(int rowIndex, int columnIndex) { return columnEditable[columnIndex]; } } - + private void ajustWith() { for (int i = 0; i < jTableInventoryRow.getColumnModel().getColumnCount(); i++) { jTableInventoryRow.getColumnModel().getColumn(i).setPreferredWidth(pColumwidth[i]); @@ -1132,8 +1152,8 @@ private void ajustWith() { } } DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer(); - centerRenderer.setHorizontalAlignment(JLabel.CENTER); - jTableInventoryRow.getColumnModel().getColumn(3).setCellRenderer(centerRenderer); + centerRenderer.setHorizontalAlignment(JLabel.CENTER); + jTableInventoryRow.getColumnModel().getColumn(3).setCellRenderer(centerRenderer); } private Lot getLot(Lot lotToUpdate) throws OHServiceException { Lot lot = null; @@ -1155,7 +1175,7 @@ private Lot getLot(Lot lotToUpdate) throws OHServiceException { } return lot; } - + private Lot askLot(Lot lotToUpdate) { LocalDateTime preparationDate; LocalDateTime expiringDate; @@ -1206,7 +1226,7 @@ private Lot askLot(Lot lotToUpdate) { } else { cost = askCost(2, cost); } - + if (cost.compareTo(new BigDecimal(0)) == 0) { return null; } else { @@ -1244,7 +1264,7 @@ private BigDecimal askCost(int qty, BigDecimal lastCost) { } while (cost == 0.); return BigDecimal.valueOf(cost); } - + protected LocalDateTime askExpiringDate() { LocalDateTime date = TimeTools.getNow(); GoodDateTimeSpinnerChooser expireDateChooser = new GoodDateTimeSpinnerChooser(date); @@ -1261,7 +1281,7 @@ protected LocalDateTime askExpiringDate() { } return date; } - + protected double askTotalCost() { String input = JOptionPane.showInputDialog(this, MessageBundle.getMessage("angal.medicalstock.multiplecharging.totalcost"), @@ -1331,7 +1351,7 @@ private JRadioButton getAllRadio() { specificRadio.setSelected(true); selectAll = false; } - + } else { if (mode.equals("update")) { try { @@ -1345,7 +1365,7 @@ private JRadioButton getAllRadio() { jTableInventoryRow.setModel(new InventoryRowModel()); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); - } + } } } fireInventoryUpdated(); @@ -1366,7 +1386,7 @@ private JLabel getDateInventoryLabel() { } return dateInventoryLabel; } - + private JTextField getCodeTextField() { if (codeTextField == null) { codeTextField = new JTextField(); @@ -1402,7 +1422,7 @@ public void keyPressed(KeyEvent e) { return codeTextField; } - private List loadNewInventoryTable(String code, MedicalInventory inventory, boolean add) throws OHServiceException { + private List loadNewInventoryTable(String code, MedicalInventory inventory, boolean add) throws OHServiceException { List inventoryRowsList = new ArrayList<>(); if (inventory != null) { int id = inventory.getId(); @@ -1415,7 +1435,7 @@ private List loadNewInventoryTable(String code, MedicalInve } return inventoryRowsList; } - + private List getMedicalInventoryRows(String code) throws OHServiceException { List inventoryRowsList = new ArrayList<>(); List medicalList = new ArrayList<>(); @@ -1476,7 +1496,7 @@ private void addInventoryRow(String code) throws OHServiceException { medicalList = medicalBrowsingManager.getMedicals(); } int numberOfMedicalWithoutSameLotAdded = 0; - Medical medicalWithLot = null; + Medical medicalWithLot = null; for (Iterator iterator = medicalList.iterator(); iterator.hasNext();) { Medical med = (Medical) iterator.next(); lots = movStockInsertingManager.getLotByMedical(med, false); @@ -1565,7 +1585,7 @@ private JLabel getReferenceLabel() { } return referenceLabel; } - + private JLabel getStatusLabel() { if (statusLabel == null) { if (inventory == null) { @@ -1575,7 +1595,7 @@ private JLabel getStatusLabel() { String currentStatus = inventory.getStatus().toUpperCase(); statusLabel = new JLabel(currentStatus); if (currentStatus.equalsIgnoreCase(InventoryStatus.draft.toString())) { - statusLabel.setForeground(Color.WHITE); + statusLabel.setForeground(Color.GRAY); } if (currentStatus.equalsIgnoreCase(InventoryStatus.validated.toString())) { statusLabel.setForeground(Color.BLUE); @@ -1587,8 +1607,6 @@ private JLabel getStatusLabel() { statusLabel.setForeground(Color.GREEN); } } - statusLabel.setPreferredSize(STATUS_DIMENSION); // improve Layouts avoiding fixed dimensions - statusLabel.setHorizontalAlignment(SwingConstants.CENTER); statusLabel.setFont(new Font(statusLabel.getFont().getName(), Font.BOLD, statusLabel.getFont().getSize() + 8)); } return statusLabel; @@ -1600,36 +1618,36 @@ private JLabel getChargeLabel() { } return chargeTypeLabel; } - + private JLabel getSupplierLabel() { if (supplierLabel == null) { supplierLabel = new JLabel(MessageBundle.getMessage("angal.inventory.supplier.label")); } return supplierLabel; } - + private JLabel getDischargeLabel() { if (dischargeTypeLabel == null) { dischargeTypeLabel = new JLabel(MessageBundle.getMessage("angal.inventory.dischargetype.label")); } return dischargeTypeLabel; } - + private JLabel getDestinationLabel() { if (destinationLabel == null) { destinationLabel = new JLabel(MessageBundle.getMessage("angal.inventory.destination.label")); } return destinationLabel; } - + private JComboBox getJComboCharge() { MovementType movementSelected = null; if (chargeCombo == null) { chargeCombo = new JComboBox(); try { - List movementTypes = movTypeManager.getMedicalDsrStockMovementType(); + List movementTypes = movTypeManager.getMedicalDsrStockMovementType(); chargeCombo.addItem(null); - for (MovementType movType: movementTypes) { + for (MovementType movType : movementTypes) { if (movType.getType().equals("+")) { chargeCombo.addItem(movType); if (inventory != null && movType.getCode().equals(inventory.getChargeType())) { @@ -1650,7 +1668,7 @@ private JComboBox getJComboCharge() { } return chargeCombo; } - + private JComboBox getJComboDischarge() { MovementType movementSelected = null; if (dischargeCombo == null) { @@ -1658,13 +1676,13 @@ private JComboBox getJComboDischarge() { try { List movementTypes = movTypeManager.getMedicalDsrStockMovementType(); dischargeCombo.addItem(null); - for (MovementType movType: movementTypes) { - if(movType.getType().equals("-")) { + for (MovementType movType : movementTypes) { + if (movType.getType().equals("-")) { dischargeCombo.addItem(movType); if (inventory != null && movType.getCode().equals(inventory.getDischargeType())) { movementSelected = movType; } - } + } } } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); @@ -1679,7 +1697,7 @@ private JComboBox getJComboDischarge() { } return dischargeCombo; } - + private JComboBox getJComboSupplier() { Supplier supplierSelected = null; if (supplierCombo == null) { @@ -1687,7 +1705,7 @@ private JComboBox getJComboSupplier() { try { List suppliers = supplierManager.getList(); supplierCombo.addItem(null); - for (Supplier supplier: suppliers) { + for (Supplier supplier : suppliers) { supplierCombo.addItem(supplier); if (inventory != null && supplier.getSupId() == inventory.getSupplier()) { supplierSelected = supplier; @@ -1706,7 +1724,7 @@ private JComboBox getJComboSupplier() { } return supplierCombo; } - + private JComboBox getJComboDestination() { Ward destinationSelected = null; if (destinationCombo == null) { @@ -1714,9 +1732,9 @@ private JComboBox getJComboDestination() { try { List wards = wardManager.getWards(); destinationCombo.addItem(null); - for (Ward ward: wards) { + for (Ward ward : wards) { destinationCombo.addItem(ward); - if (inventory != null && ward.getCode().equals(inventory.getDestination()) ) { + if (inventory != null && ward.getCode().equals(inventory.getDestination())) { destinationSelected = ward; } } @@ -1733,7 +1751,7 @@ private JComboBox getJComboDestination() { } return destinationCombo; } - + private JTextField getReferenceTextField() { if (referenceTextField == null) { referenceTextField = new JTextField(); @@ -1744,11 +1762,11 @@ private JTextField getReferenceTextField() { } return referenceTextField; } - - private int getPosition (MedicalInventoryRow inventoryRow) { + + private int getPosition(MedicalInventoryRow inventoryRow) { int position = -1; int i = 0; - for (MedicalInventoryRow invR: inventoryRowSearchList) { + for (MedicalInventoryRow invR : inventoryRowSearchList) { if (invR.getMedical().getCode().equals(inventoryRow.getMedical().getCode())) { position = i; } @@ -1756,12 +1774,13 @@ private int getPosition (MedicalInventoryRow inventoryRow) { } return position; } - + private boolean existInInventorySearchList(MedicalInventoryRow inventoryRow) { boolean found = false; - List invRows = inventoryRowSearchList.stream().filter(inv -> inv.getMedical().getCode().equals(inventoryRow.getMedical().getCode())).collect(Collectors.toList()); + List invRows = inventoryRowSearchList.stream() + .filter(inv -> inv.getMedical().getCode().equals(inventoryRow.getMedical().getCode())).collect(Collectors.toList()); if (invRows.size() > 0) { - for (MedicalInventoryRow invR: invRows) { + for (MedicalInventoryRow invR : invRows) { if (inventoryRow.getLot() != null && invR.getLot() != null) { if (inventoryRow.getLot().getCode().equals(invR.getLot().getCode())) { found = true; @@ -1775,7 +1794,7 @@ private boolean existInInventorySearchList(MedicalInventoryRow inventoryRow) { } } } - + return found; } private void addMedInRowInInventorySearchList(MedicalInventoryRow inventoryRow) { From 1240d899557b09952d9c7bdf82370cf43759e93f Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Thu, 5 Sep 2024 10:28:17 +0100 Subject: [PATCH 063/147] Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java Co-authored-by: Alessandro Domanico --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 3cc7accd25..11f8e7d090 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1590,7 +1590,7 @@ private JLabel getStatusLabel() { if (statusLabel == null) { if (inventory == null) { statusLabel = new JLabel(InventoryStatus.draft.toString()); - statusLabel.setForeground(Color.WHITE); + statusLabel.setForeground(Color.GRAY); } else { String currentStatus = inventory.getStatus().toUpperCase(); statusLabel = new JLabel(currentStatus); From 5e759bd6d423ca333d5e14b91dad19df885003af Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:18:56 +0100 Subject: [PATCH 064/147] OP-1188 | Delete Inventory (#2048) * add logic to delete inventory * add import * extract inventory.getStatus() * set status on UpperCamel case when create new Inventory * Update src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java * add missiong bundle --------- Co-authored-by: ArnaudFonzam Co-authored-by: Alessandro Domanico --- bundle/language_en.properties | 5 +++ .../gui/InventoryBrowser.java | 33 ++++++++++++++++++- .../medicalinventory/gui/InventoryEdit.java | 5 +-- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 139bb87133..32e9ffcbc0 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -673,6 +673,11 @@ angal.inventory.cancelednoteditable.msg angal.inventory.chargetype.label = Charge Type angal.inventory.clean.btn = Clean Table angal.inventory.clean.btn.key = T +angal.inventory.deletion.confirm.msg = Do you really want to delete this inventory? +angal.inventory.deletion.confirm.title = Confirm Deletion +angal.inventory.deletion.success.msg = The inventory has been successfully marked as deleted. +angal.inventory.deletion.error.msg = Deletion is only allowed for inventories with 'draft' or 'validated' status. +angal.inventory.notfound.msg = Inventory not found. angal.inventory.destination.label = Destination angal.inventory.dischargetype.label = Discharge Type angal.inventory.draft = Draft diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 5be50a1aad..874f155127 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -45,6 +45,7 @@ import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; @@ -412,14 +413,44 @@ private JButton getPrintButton() { jButtonPrint.setEnabled(false); return jButtonPrint; } - + private JButton getDeleteButton() { jButtonDelete = new JButton(MessageBundle.getMessage("angal.common.delete.btn")); jButtonDelete.setMnemonic(MessageBundle.getMnemonic("angal.common.delete.btn.key")); jButtonDelete.setEnabled(false); + + jButtonDelete.addActionListener(actionEvent -> { + if (jTableInventory.getSelectedRowCount() > 1) { + MessageDialog.error(this, "angal.inventory.pleaseselectonlyoneinventory.msg"); + return; + } + int selectedRow = jTableInventory.getSelectedRow(); + if (selectedRow == -1) { + MessageDialog.error(this, "angal.inventory.pleaseselectinventory.msg"); + return; + } + MedicalInventory inventory = inventoryList.get(selectedRow); + String currentStatus = inventory.getStatus(); + if (currentStatus.equalsIgnoreCase(InventoryStatus.validated.toString()) || currentStatus.equalsIgnoreCase(InventoryStatus.draft.toString())) { + int response = MessageDialog.yesNo(this, "angal.inventory.deletion.confirm.msg"); + if (response == JOptionPane.YES_OPTION) { + try { + medicalInventoryManager.deleteInventory(inventory); + MessageDialog.info(this, "angal.inventory.deletion.success.msg"); + jTableInventory.setModel(new InventoryBrowsingModel()); + } catch (OHServiceException e) { + MessageDialog.error(this, "angal.inventory.deletion.error.msg"); + } + } + } else { + MessageDialog.error(this, "angal.inventory.deletion.error.msg"); + } + }); return jButtonDelete; } + + private JButton getCloseButton() { jButtonClose = new JButton(MessageBundle.getMessage("angal.common.close.btn")); jButtonClose.setMnemonic(MessageBundle.getMnemonic("angal.common.close.btn.key")); diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 11f8e7d090..19dd1411f7 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1589,7 +1589,8 @@ private JLabel getReferenceLabel() { private JLabel getStatusLabel() { if (statusLabel == null) { if (inventory == null) { - statusLabel = new JLabel(InventoryStatus.draft.toString()); + String currentStatus = InventoryStatus.draft.toString().toUpperCase(); + statusLabel = new JLabel(currentStatus); statusLabel.setForeground(Color.GRAY); } else { String currentStatus = inventory.getStatus().toUpperCase(); @@ -1815,4 +1816,4 @@ private void resetVariable() { inventoryRowListAdded.clear(); lotsSaved.clear(); } -} +} \ No newline at end of file From b876d428a24e0f2efc0e4b2a9abd68343f63dc21 Mon Sep 17 00:00:00 2001 From: ArnaudFonzam Date: Fri, 13 Sep 2024 11:41:55 +0100 Subject: [PATCH 065/147] fix bug on column unit price and total price --- .../medicalinventory/gui/InventoryEdit.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 6ea9d82fac..9d02fc5801 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1012,13 +1012,13 @@ public InventoryRowModel() throws OHServiceException { } else if (c == 5) { return String.class; } else if (c == 6) { - return Integer.class; + return Double.class; } else if (c == 7) { - return Integer.class; + return Double.class; } else if (c == 8) { - return Integer.class; + return BigDecimal.class; } else if (c == 9) { - return Integer.class; + return Double.class; } return null; } @@ -1078,14 +1078,14 @@ public Object getValueAt(int r, int c) { return medInvtRow.getLot().getCost(); } } - return 0; + return new BigDecimal("0.00"); } else if (c == 9) { if (medInvtRow.getLot() != null) { if (medInvtRow.getLot().getCost() != null) { return medInvtRow.getTotal(); } } - return 0; + return 0.0; } return null; } @@ -1095,12 +1095,12 @@ public void setValueAt(Object value, int r, int c) { if (r < inventoryRowSearchList.size()) { MedicalInventoryRow invRow = inventoryRowSearchList.get(r); if (c == 7) { - Integer intValue = 0; + Double intValue = 0.0; if (value != null) { try { - intValue = Integer.parseInt(value.toString()); + intValue = Double.parseDouble(value.toString()); } catch (NumberFormatException e) { - intValue = 0; + intValue = 0.0; return; } } From 4635ebe24dd7debcb15d5c670610c28f0ab62ca8 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Date: Fri, 4 Oct 2024 08:07:09 +0100 Subject: [PATCH 066/147] OP-1189 | validate Inventory (#2030) * add validate action * Update bundle/language_en.properties * update logique and apply the new * update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java * update bundle to add new message * Rename one field * Remove useless field and format code * Remove deprecated field * Fix exception after focus out on real qty * Update one label * update logic of validate Inventory * update InventoryEdit * update validate method * update InventoryEdit * update validate inventory' * update Inventory Edit * update InventoryEdit.java * git fix error Index out of bound * update Inventory * apply suggestion * fix error on update Cost of lot * OP-1344: dialog method takes bundle key and not the final text (#2060) * Add bundles * Refactor validation method and change errors severity * create new inventory during validation phase if we have new charge movement created after the creation date of inventory --------- Co-authored-by: ArnaudFonzam Co-authored-by: David B Malkovsky Co-authored-by: Alessandro Domanico --- bundle/language_en.properties | 22 +- .../gui/InventoryBrowser.java | 12 +- .../medicalinventory/gui/InventoryEdit.java | 267 +++++++++++++----- .../isf/stat/gui/report/DisplayReport.java | 3 +- 4 files changed, 226 insertions(+), 78 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index a893a6e316..3d4d02c47f 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -666,13 +666,16 @@ angal.hospital.visitendhour.txt angal.hospital.visitstarthour.txt = Visit start hour angal.inventory.allproduct.txt = All products angal.inventory.canceled = Canceled -angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg = Cannot create another inventory with status draft. +angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg = Cannot create another inventory with status draft, Because you already have an inventory with status draft or validated. angal.inventory.cannotsavelot.msg = Cannot save the lot. Please verify lot information and retry. angal.inventory.cannotsaveinventorywithoutproducts.msg = Cannot save inventory without products. angal.inventory.cancelednoteditable.msg = A canceled inventory can not be modified. angal.inventory.chargetype.label = Charge Type angal.inventory.clean.btn = Clean Table angal.inventory.clean.btn.key = T +angal.inventory.choosedischargetypebeforevalidation.msg = Please choose the discharge type and save the inventory before validation. +angal.inventory.choosechargetypebeforevalidation.msg = Please choose the charge type and save the inventory before validation. +angal.inventory.choosesupplierbeforevalidation.msg = Please choose the supplier and save the inventory before validation. angal.inventory.deletion.confirm.msg = Do you really want to delete this inventory? angal.inventory.deletion.confirm.title = Confirm Deletion angal.inventory.deletion.success.msg = The inventory has been successfully marked as deleted. @@ -685,6 +688,10 @@ angal.inventory.inventorybrowser.title angal.inventory.id.col = Id angal.inventory.mustenterareference.msg = You must enter a reference. angal.inventory.newinventory.title = New inventory +angal.inventory.newlotshavebeenaddedforsomemedical.fmt.msg = New lot(s) have been found by new movement(s) in main store for: {0} +angal.inventory.newlotshavebeenaddedforsomemedical.detail.fmt.msg = {0} lot: {1} qty: {2} +angal.inventory.newmedicalshavebeenfound.fmt.msg = New medical(s) have been found by new movement(s) in main store for: {0} +angal.inventory.newmedicalshavebeenfound.detail.fmt.msg = {0} lot: {1} qty: {2} angal.inventory.editinventory.title = Edit inventory angal.inventory.noteditable.msg = A validated inventory cannot be modified. angal.inventory.notdateinfuture.msg = A date in the future is not allowed. @@ -692,7 +699,7 @@ angal.inventory.noproduct.msg angal.inventory.referencealreadyused.msg = Reference is already used. angal.inventory.savesuccess.msg = Inventory saved. angal.inventory.status.label = Status: -angal.inventory.new.col = New +angal.inventory.newlot.col = New lot angal.inventory.lot.btn = Lot angal.inventory.lot.btn.key = L angal.inventory.supplier.label = Supplier @@ -702,6 +709,7 @@ angal.inventoryrow.doyoureallywanttocleanthistable.msg angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg = Do you want to add all not yet listed products? angal.inventoryrow.doyouwanttocontinueediting.msg = Do you want to continue editing? angal.inventoryrow.doyouwanttosavethechanges.msg = Do you want to save the changes? +angal.inventoryrow.doyoureallywanttovalidatethisinventory.msg = Do you really want to validate this inventory? angal.inventoryrow.notfound.msg = Inventory not found. angal.inventoryrow.invalidquantity.msg = Invalid quantity. angal.inventory.pleaseinsertavalidinventorydate.msg = Please insert a valid inventory date. @@ -731,10 +739,16 @@ angal.inventory.validated angal.inventory.done = Done angal.inventory.validate.btn = Validate angal.inventory.validate.btn.key = V -angal.inventory.validatednoteditable.msg = A validated inventory cannot be modified. +angal.inventory.inventorymustsavebeforevalidation.msg = Inventory must be saved before validation. +angal.inventory.validate.success.msg = The inventory has been successfully validated. +angal.inventory.theoreticalqtyhavebeenupdatedforsomemedical.fmt.msg = Theoretical(s) quantity(ies) have been updated by new movement(s) in main store for: {0} +angal.inventory.theoreticalqtyhavebeenupdatedforsomemedical.detail.fmt.msg = {0} lot: {1} qty: {2} -> {3} ({4}) +angal.inventory.validate.error.msg = Error during inventory validation. +angal.inventory.allinventoryrowshouldhavelotbeforevalidation.msg = All the inventory rows should have lots before validation. angal.inventory.viewinventory.title = View Inventory angal.inventory.youhavealreadyaddedallproduct.msg = You have already added all the products. angal.inventoryrow.realqty.col = Real Qty +angal.inventory.newinvenotryrowtoadd.msg = New lot(s) have been detected in the main Store for these medical(s): {0} do you want to add them to this inventory? angal.invetory.allmedicalisalreadypresent.msg = All medical is already present in this list. angal.invetory.allmedicaladdedsuccessfully.msg = All medical are added successfully. angal.lab.allnegative.txt = All negative. @@ -1210,7 +1224,7 @@ angal.messagedialog.info.title angal.messagedialog.plain.title = Note angal.messagedialog.question.title = Question angal.messagedialog.warning.title = Warning -angal.movement.tostring.fmt.txt = Medical:{0}Lot:{1}Quantity:{2} +angal.movement.tostring.fmt.txt = Medical:{0} Lot:{1} Type:{2} Quantity:{3} angal.newbill.abillwithanoutstandingbalancecannotbeclosed.msg = A bill with an outstanding balance cannot be closed. angal.newbill.associateapatientwiththisbill.tooltip = Associate a patient with this bill. angal.newbill.balance.txt = Balance diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 874f155127..943f7c3b3c 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -336,14 +336,18 @@ private JButton getNewButton() { jButtonNew = new JButton(MessageBundle.getMessage("angal.common.new.btn")); jButtonNew.setMnemonic(MessageBundle.getMnemonic("angal.common.new.btn.key")); jButtonNew.addActionListener(actionEvent -> { - String status = InventoryStatus.draft.toString(); - List medicalInventories = new ArrayList<>(); + String draft = InventoryStatus.draft.toString(); + String validated = InventoryStatus.validated.toString(); + String inventoryType = InventoryType.main.toString(); + List draftMedicalInventories = new ArrayList<>(); + List validMedicalInventories = new ArrayList<>(); try { - medicalInventories = medicalInventoryManager.getMedicalInventoryByStatus(status); + draftMedicalInventories = medicalInventoryManager.getMedicalInventoryByStatusAndInventoryType(draft, inventoryType); + validMedicalInventories = medicalInventoryManager.getMedicalInventoryByStatusAndInventoryType(validated, inventoryType); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } - if (medicalInventories.size() == 0) { + if (draftMedicalInventories.size() == 0 && validMedicalInventories.size() == 0) { InventoryEdit inventoryEdit = new InventoryEdit(); InventoryEdit.addInventoryListener(InventoryBrowser.this); inventoryEdit.showAsModal(InventoryBrowser.this); diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 20b71a763b..5bf4304b22 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -64,6 +64,7 @@ import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; import javax.swing.border.EmptyBorder; import javax.swing.event.EventListenerList; import javax.swing.event.ListSelectionEvent; @@ -120,8 +121,8 @@ public interface InventoryListener extends EventListener { public void InventoryCancelled(AWTEvent e); } - public static void addInventoryListener(InventoryListener l) { - InventoryListeners.add(InventoryListener.class, l); + public static void addInventoryListener(InventoryListener listener) { + InventoryListeners.add(InventoryListener.class, listener); } public static void removeInventoryListener(InventoryListener listener) { @@ -138,7 +139,9 @@ private void fireInventoryInserted() { for (int i = 0; i < listeners.length; i++) { ((InventoryListener) listeners[i]).InventoryInserted(event); } - jTableInventoryRow.updateUI(); + if (jTableInventoryRow != null) { + jTableInventoryRow.updateUI(); + } } private void fireInventoryUpdated() { @@ -151,7 +154,9 @@ private void fireInventoryUpdated() { for (int i = 0; i < listeners.length; i++) { ((InventoryListener) listeners[i]).InventoryUpdated(event); } - jTableInventoryRow.updateUI(); + if (jTableInventoryRow != null) { + jTableInventoryRow.updateUI(); + } } private GoodDateChooser jCalendarInventory; @@ -164,8 +169,10 @@ private void fireInventoryUpdated() { private JButton saveButton; private JButton resetButton; private JButton lotButton; + private JButton validateButton; private JScrollPane scrollPaneInventory; private JTable jTableInventoryRow; + private DefaultTableModel model; private List inventoryRowList; private List inventoryRowSearchList = new ArrayList<>(); private List inventoryRowListAdded = new ArrayList<>(); @@ -175,7 +182,7 @@ private void fireInventoryUpdated() { private String[] pColums = { MessageBundle.getMessage("angal.inventory.id.col").toUpperCase(), MessageBundle.getMessage("angal.common.code.txt").toUpperCase(), MessageBundle.getMessage("angal.inventory.product.col").toUpperCase(), - MessageBundle.getMessage("angal.inventory.new.col").toUpperCase(), + MessageBundle.getMessage("angal.inventory.newlot.col").toUpperCase(), MessageBundle.getMessage("angal.wardpharmacy.lotnumber.col").toUpperCase(), MessageBundle.getMessage("angal.medicalstock.duedate.col").toUpperCase(), MessageBundle.getMessage("angal.inventoryrow.theoreticqty.col").toUpperCase(), @@ -201,7 +208,8 @@ private void fireInventoryUpdated() { private JLabel supplierLabel; private JLabel destinationLabel; private JTextField referenceTextField; - private JTextField jTetFieldEditor; + private JTextField jTextFieldEditor; + private TableRowSorter sorter; private JComboBox chargeCombo; private JComboBox dischargeCombo; private JComboBox supplierCombo; @@ -228,6 +236,10 @@ public InventoryEdit() { private boolean isAutomaticLotIn() { return GeneralData.AUTOMATICLOT_IN; } + + private boolean isLotWithCost() { + return GeneralData.LOTWITHCOST; + } public InventoryEdit(MedicalInventory inventory, String mod) { this.inventory = inventory; @@ -270,6 +282,7 @@ public void windowClosing(WindowEvent e) { }); if (mode.equals("view")) { saveButton.setVisible(false); + validateButton.setVisible(false); deleteButton.setVisible(false); columnEditable = columnEditableView; codeTextField.setEditable(false); @@ -285,6 +298,7 @@ public void windowClosing(WindowEvent e) { lotButton.setVisible(false); } else { saveButton.setVisible(true); + validateButton.setVisible(true); deleteButton.setVisible(true); codeTextField.setEditable(true); resetButton.setVisible(true); @@ -436,6 +450,7 @@ private JPanel getPanelFooter() { if (panelFooter == null) { panelFooter = new JPanel(); panelFooter.add(getSaveButton()); + panelFooter.add(getValidateButton()); panelFooter.add(getDeleteButton()); panelFooter.add(getLotButton()); panelFooter.add(getCleanTableButton()); @@ -546,8 +561,8 @@ private JButton getSaveButton() { } medicalInventoryRowManager.newMedicalInventoryRow(medicalInventoryRow); } - // enable validation mode = "update"; + validateButton.setEnabled(true); MessageDialog.info(this, "angal.inventory.savesuccess.msg"); fireInventoryInserted(); resetVariable(); @@ -760,25 +775,34 @@ private JButton getDeleteButton() { } int delete = MessageDialog.yesNo(null, "angal.inventoryrow.doyoureallywanttodeletethisinventoryrow.msg"); if (delete == JOptionPane.YES_OPTION) { + if (selectedRows.length == inventoryRowSearchList.size()) { + resetButton.doClick(); + return; + } if (inventory == null) { for (int i = selectedRows.length - 1; i >= 0; i--) { MedicalInventoryRow selectedInventoryRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRows[i], -1); inventoryRowSearchList.remove(selectedInventoryRow); + model.fireTableDataChanged(); + jTableInventoryRow.setModel(model); } + } else { for (int i = selectedRows.length - 1; i >= 0; i--) { MedicalInventoryRow inventoryRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRows[i], -1); inventoryRowSearchList.remove(inventoryRow); + model.fireTableDataChanged(); + jTableInventoryRow.setModel(model); if (inventoryRow.getId() != 0) { inventoryRowsToDelete.add(inventoryRow); } } } jTableInventoryRow.clearSelection(); + adjustWidth(); } else { return; } - fireInventoryUpdated(); }); return deleteButton; } @@ -818,8 +842,15 @@ private JButton getLotButton() { selectedInventoryRow.setLot(lot); lotsSaved.add(lot); } else { - MessageDialog.error(this, "angal.inventoryrow.thislotcodealreadyexists.msg"); - lotButton.doClick(); + if (lotToUpdate != null && code.equals(lotToUpdate.getCode())) { + if (!isLotWithCost()) { + selectedInventoryRow.setLot(lot); + lotsSaved.add(lot); + } + } else { + MessageDialog.error(this, "angal.inventoryrow.thislotcodealreadyexists.msg"); + lotButton.doClick(); + } } } else { List invRows = inventoryRowSearchList.stream() @@ -830,8 +861,13 @@ private JButton getLotButton() { selectedInventoryRow.setLot(lot); lotsSaved.add(lot); } else { - MessageDialog.error(this, "angal.inventoryrow.thislotcodealreadyexists.msg"); - lotButton.doClick(); + if (lotToUpdate != null && code.equals(lotToUpdate.getCode())) { + selectedInventoryRow.setLot(lot); + lotsSaved.add(lot); + } else { + MessageDialog.error(this, "angal.inventoryrow.thislotcodealreadyexists.msg"); + lotButton.doClick(); + } } } inventoryRowSearchList.set(selectedRow, selectedInventoryRow); @@ -867,7 +903,7 @@ private JButton getCloseButton() { || (dischargeType != null && !dischargeType.getCode().equals(lastDischarge)) || (supplier != null && !supplier.getSupId().equals(lastSupplier)) || (destination == null && lastDestination != null) || (chargeType == null && lastCharge != null) || (dischargeType == null && lastDischarge != null) - || (supplier == null && lastSupplier != null) || !lastReference.equals(newReference) + || (supplier == null && lastSupplier != null) || (lastReference != null && !lastReference.equals(newReference)) || !lastDate.toLocalDate().equals(dateInventory.toLocalDate())) { int reset = MessageDialog.yesNoCancel(null, "angal.inventoryrow.doyouwanttosavethechanges.msg"); if (reset == JOptionPane.YES_OPTION) { @@ -904,13 +940,94 @@ private JButton getCleanTableButton() { selectAll = false; specificRadio.setSelected(true); codeTextField.setEnabled(true); - inventoryRowSearchList.clear(); - fireInventoryUpdated(); + inventoryRowSearchList = new ArrayList<>(); + DefaultTableModel model = (DefaultTableModel) jTableInventoryRow.getModel(); + model.setRowCount(0); + model.setColumnCount(0); + jTableInventoryRow.updateUI(); + adjustWidth(); } }); return resetButton; } + private JButton getValidateButton() { + validateButton = new JButton(MessageBundle.getMessage("angal.inventory.validate.btn")); + validateButton.setMnemonic(MessageBundle.getMnemonic("angal.inventory.validate.btn.key")); + if (inventory == null) { + validateButton.setEnabled(false); + } + validateButton.addActionListener(actionEvent -> { + if (inventory == null) { + MessageDialog.error(null, "angal.inventory.inventorymustsavebeforevalidation.msg"); + return; + } + List invRowWithoutLot = inventoryRowSearchList.stream().filter(invRow -> invRow.getLot() == null).collect(Collectors.toList()); + if (invRowWithoutLot.size() > 0) { + MessageDialog.error(null, "angal.inventory.allinventoryrowshouldhavelotbeforevalidation.msg"); + return; + } + int reset = MessageDialog.yesNo(null, "angal.inventoryrow.doyoureallywanttovalidatethisinventory.msg"); + if (reset == JOptionPane.YES_OPTION) { + String dischargeCode = inventory.getDischargeType(); + String chargeCode = inventory.getChargeType(); + Integer supplierId = inventory.getSupplier(); + String wardCode = inventory.getDestination(); + if (chargeCode == null || chargeCode.equals("")) { + MessageDialog.error(null, "angal.inventory.choosechargetypebeforevalidation.msg"); + return; + } + if (dischargeCode == null || dischargeCode.equals("")) { + MessageDialog.error(null, "angal.inventory.choosedischargetypebeforevalidation.msg"); + return; + } + if (supplierId == null || supplierId == 0) { + MessageDialog.error(null, "angal.inventory.choosesupplierbeforevalidation.msg"); + return; + } + if (wardCode == null || wardCode.equals("")) { + MessageDialog.error(null, "angal.inventory.choosesupplierbeforevalidation.msg"); + return; + } + // validate inventory + int inventoryRowsSize = inventoryRowSearchList.size(); + try { + medicalInventoryManager.validateMedicalInventoryRow(inventory, inventoryRowSearchList); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + try { + jTableInventoryRow.setModel(new InventoryRowModel()); + adjustWidth(); + } catch (OHServiceException e1) { + OHServiceExceptionUtil.showMessages(e); + } + return; + } + String status = InventoryStatus.validated.toString(); + inventory.setStatus(status); + try { + inventory = medicalInventoryManager.updateMedicalInventory(inventory); + if (inventory != null) { + List invRows = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()); + MessageDialog.info(null, "angal.inventory.validate.success.msg"); + if (invRows.size() > inventoryRowsSize) { + MessageDialog.error(null, "angal.inventory.theoreticalqtyhavebeenupdatedforsomemedical.msg"); + } + fireInventoryUpdated(); + statusLabel.setText(status.toUpperCase()); + statusLabel.setForeground(Color.BLUE); + } else { + MessageDialog.info(null, "angal.inventory.validate.error.msg"); + return; + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + return; + } + } + }); + return validateButton; + } private JScrollPane getScrollPaneInventory() { if (scrollPaneInventory == null) { scrollPaneInventory = new JScrollPane(); @@ -926,9 +1043,9 @@ private JScrollPane getScrollPaneInventory() { private JTable getJTableInventoryRow() throws OHServiceException { if (jTableInventoryRow == null) { jTableInventoryRow = new JTable(); - jTetFieldEditor = new JTextField(); + jTextFieldEditor = new JTextField(); jTableInventoryRow.setFillsViewportHeight(true); - DefaultTableModel model = new InventoryRowModel(); + model = new InventoryRowModel(); jTableInventoryRow.setModel(model); for (int i = 0; i < pColumnVisible.length; i++) { jTableInventoryRow.getColumnModel().getColumn(i).setCellRenderer(new EnabledTableCellRenderer()); @@ -948,7 +1065,6 @@ private JTable getJTableInventoryRow() throws OHServiceException { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { jTableInventoryRow.editCellAt(jTableInventoryRow.getSelectedRow(), jTableInventoryRow.getSelectedColumn()); - jTetFieldEditor.selectAll(); int[] selectedRows = jTableInventoryRow.getSelectedRows(); if (selectedRows.length == 1) { MedicalInventoryRow medInvRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRows[0], -1); @@ -961,12 +1077,11 @@ public void valueChanged(ListSelectionEvent e) { lotButton.setEnabled(false); } } - } }); - TableRowSorter sorter = new TableRowSorter<>(model); + sorter = new TableRowSorter<>(model); jTableInventoryRow.setRowSorter(sorter); - DefaultCellEditor cellEditor = new DefaultCellEditor(jTetFieldEditor); + DefaultCellEditor cellEditor = new DefaultCellEditor(jTextFieldEditor); jTableInventoryRow.setDefaultEditor(Integer.class, cellEditor); } return jTableInventoryRow; @@ -1001,6 +1116,9 @@ public InventoryRowModel(boolean add) throws OHServiceException { } public InventoryRowModel() throws OHServiceException { + if (!inventoryRowSearchList.isEmpty()) { + inventoryRowSearchList.clear(); + } if (inventory != null) { inventoryRowList = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()); } else { @@ -1060,53 +1178,55 @@ public int getColumnCount() { } public Object getValueAt(int r, int c) { - MedicalInventoryRow medInvtRow = inventoryRowSearchList.get(r); - if (c == -1) { - return medInvtRow; - } else if (c == 0) { - return medInvtRow.getId(); - } else if (c == 1) { - return medInvtRow.getMedical() == null ? "" : medInvtRow.getMedical().getProdCode(); - } else if (c == 2) { - return medInvtRow.getMedical() == null ? "" : medInvtRow.getMedical().getDescription(); - } else if (c == 3) { - if (medInvtRow.getLot() == null || medInvtRow.isNewLot()) { - return "N"; - } - return ""; - } else if (c == 4) { - if (medInvtRow.getLot() == null) { + if (r < inventoryRowSearchList.size()) { + MedicalInventoryRow medInvtRow = inventoryRowSearchList.get(r); + if (c == -1) { + return medInvtRow; + } else if (c == 0) { + return medInvtRow.getId(); + } else if (c == 1) { + return medInvtRow.getMedical() == null ? "" : medInvtRow.getMedical().getProdCode(); + } else if (c == 2) { + return medInvtRow.getMedical() == null ? "" : medInvtRow.getMedical().getDescription(); + } else if (c == 3) { + if (medInvtRow.getLot() == null || medInvtRow.isNewLot()) { + return "N"; + } return ""; - } - return medInvtRow.getLot().getCode().equals("") ? "AUTO" : medInvtRow.getLot().getCode(); - } else if (c == 5) { - if (medInvtRow.getLot() != null) { - if (medInvtRow.getLot().getDueDate() != null) { - return medInvtRow.getLot().getDueDate().format(DATE_TIME_FORMATTER); + } else if (c == 4) { + if (medInvtRow.getLot() == null) { + return ""; } - } - return ""; - } else if (c == 6) { - Double dblVal = medInvtRow.getTheoreticQty(); - return dblVal.intValue(); - } else if (c == 7) { - Double dblValue = medInvtRow.getRealQty(); - return dblValue.intValue(); - } else if (c == 8) { - if (medInvtRow.getLot() != null) { - if (medInvtRow.getLot().getCost() != null) { - medInvtRow.setTotal(medInvtRow.getRealQty() * medInvtRow.getLot().getCost().doubleValue()); - return medInvtRow.getLot().getCost(); + return medInvtRow.getLot().getCode().equals("") ? "AUTO" : medInvtRow.getLot().getCode(); + } else if (c == 5) { + if (medInvtRow.getLot() != null) { + if (medInvtRow.getLot().getDueDate() != null) { + return medInvtRow.getLot().getDueDate().format(DATE_TIME_FORMATTER); + } } - } - return new BigDecimal("0.00"); - } else if (c == 9) { - if (medInvtRow.getLot() != null) { - if (medInvtRow.getLot().getCost() != null) { - return medInvtRow.getTotal(); + return ""; + } else if (c == 6) { + Double dblVal = medInvtRow.getTheoreticQty(); + return dblVal.intValue(); + } else if (c == 7) { + Double dblValue = medInvtRow.getRealQty(); + return dblValue.intValue(); + } else if (c == 8) { + if (medInvtRow.getLot() != null) { + if (medInvtRow.getLot().getCost() != null) { + medInvtRow.setTotal(medInvtRow.getRealQty() * medInvtRow.getLot().getCost().doubleValue()); + return medInvtRow.getLot().getCost(); + } + } + return new BigDecimal("0.00"); + } else if (c == 9) { + if (medInvtRow.getLot() != null) { + if (medInvtRow.getLot().getCost() != null) { + return medInvtRow.getTotal(); + } } + return 0.0; } - return 0.0; } return null; } @@ -1136,6 +1256,9 @@ public void setValueAt(Object value, int r, int c) { } inventoryRowListAdded.add(invRow); inventoryRowSearchList.set(r, invRow); + SwingUtilities.invokeLater(() -> { + jTableInventoryRow.updateUI(); + }); } } @@ -1147,7 +1270,7 @@ public boolean isCellEditable(int rowIndex, int columnIndex) { } } - private void ajustWith() { + private void adjustWidth() { for (int i = 0; i < jTableInventoryRow.getColumnModel().getColumnCount(); i++) { jTableInventoryRow.getColumnModel().getColumn(i).setPreferredWidth(pColumwidth[i]); if (i == 0 || !pColumnVisible[i]) { @@ -1160,6 +1283,7 @@ private void ajustWith() { centerRenderer.setHorizontalAlignment(JLabel.CENTER); jTableInventoryRow.getColumnModel().getColumn(3).setCellRenderer(centerRenderer); } + private Lot getLot(Lot lotToUpdate) throws OHServiceException { Lot lot = null; if (isAutomaticLotIn()) { @@ -1168,7 +1292,7 @@ private Lot getLot(Lot lotToUpdate) throws OHServiceException { lot = new Lot("", preparationDate, expiringDate); // Cost BigDecimal cost = new BigDecimal(0); - if (GeneralData.LOTWITHCOST) { + if (isLotWithCost()) { cost = askCost(2, cost); if (cost.compareTo(new BigDecimal(0)) == 0) { return null; @@ -1225,7 +1349,7 @@ private Lot askLot(Lot lotToUpdate) { preparationDate = preparationDateChooser.getDateStartOfDay(); lot = new Lot(lotName, preparationDate, expiringDate); BigDecimal cost = new BigDecimal(0); - if (GeneralData.LOTWITHCOST) { + if (isLotWithCost()) { if (lotToUpdate != null) { cost = askCost(2, lotToUpdate.getCost()); } else { @@ -1362,6 +1486,7 @@ private JRadioButton getAllRadio() { try { allRadio.setSelected(true); jTableInventoryRow.setModel(new InventoryRowModel(true)); + } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } @@ -1373,9 +1498,12 @@ private JRadioButton getAllRadio() { } } } + if (inventory != null && !inventory.getStatus().equals(InventoryStatus.draft.toString())) { + inventory.setStatus(InventoryStatus.draft.toString()); + } fireInventoryUpdated(); code = null; - ajustWith(); + adjustWidth(); } } else { MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); @@ -1419,6 +1547,9 @@ public void keyPressed(KeyEvent e) { } catch (OHServiceException e1) { OHServiceExceptionUtil.showMessages(e1); } + if (inventory != null && !inventory.getStatus().equals(InventoryStatus.draft.toString())) { + inventory.setStatus(InventoryStatus.draft.toString()); + } codeTextField.setText(""); } } @@ -1463,7 +1594,7 @@ private List getMedicalInventoryRows(String code) throws OH for (Iterator iterator = medicalList.iterator(); iterator.hasNext();) { Medical med = (Medical) iterator.next(); lots = movStockInsertingManager.getLotByMedical(med, false); - double actualQty = med.getInitialqty() + med.getInqty() - med.getOutqty(); + double actualQty = med.getInqty() - med.getOutqty(); if (lots.size() == 0) { inventoryRowTemp = new MedicalInventoryRow(0, actualQty, actualQty, null, med, null); if (!existInInventorySearchList(inventoryRowTemp)) { diff --git a/src/main/java/org/isf/stat/gui/report/DisplayReport.java b/src/main/java/org/isf/stat/gui/report/DisplayReport.java index 644dd800b7..6bfde5c442 100644 --- a/src/main/java/org/isf/stat/gui/report/DisplayReport.java +++ b/src/main/java/org/isf/stat/gui/report/DisplayReport.java @@ -25,7 +25,6 @@ import java.util.Locale; import org.isf.generaldata.GeneralData; -import org.isf.generaldata.MessageBundle; import org.isf.stat.dto.JasperReportResultDto; import org.isf.utils.jobjects.MessageDialog; @@ -35,7 +34,7 @@ public class DisplayReport { protected void showReport(JasperReportResultDto jasperReportResultDto) throws IOException { if (jasperReportResultDto.getJasperPrint().getPages().isEmpty()) { - MessageDialog.info(null, MessageBundle.getMessage("angal.common.documenthasnopages.msg")); + MessageDialog.info(null, "angal.common.documenthasnopages.msg"); return; } if (GeneralData.INTERNALVIEWER) { From e03c429caea31ff8f5e3a4f3af59a58709af0dea Mon Sep 17 00:00:00 2001 From: mwithi Date: Fri, 4 Oct 2024 09:30:24 +0200 Subject: [PATCH 067/147] OP-1302 Revert --- .../org/isf/medicalinventory/gui/InventoryEdit.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 5bf4304b22..606480124a 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -71,8 +71,6 @@ import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; -import javax.swing.table.TableModel; -import javax.swing.table.TableRowSorter; import org.isf.generaldata.GeneralData; import org.isf.generaldata.MessageBundle; @@ -209,7 +207,6 @@ private void fireInventoryUpdated() { private JLabel destinationLabel; private JTextField referenceTextField; private JTextField jTextFieldEditor; - private TableRowSorter sorter; private JComboBox chargeCombo; private JComboBox dischargeCombo; private JComboBox supplierCombo; @@ -236,7 +233,7 @@ public InventoryEdit() { private boolean isAutomaticLotIn() { return GeneralData.AUTOMATICLOT_IN; } - + private boolean isLotWithCost() { return GeneralData.LOTWITHCOST; } @@ -786,7 +783,7 @@ private JButton getDeleteButton() { model.fireTableDataChanged(); jTableInventoryRow.setModel(model); } - + } else { for (int i = selectedRows.length - 1; i >= 0; i--) { MedicalInventoryRow inventoryRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRows[i], -1); @@ -992,7 +989,7 @@ private JButton getValidateButton() { // validate inventory int inventoryRowsSize = inventoryRowSearchList.size(); try { - medicalInventoryManager.validateMedicalInventoryRow(inventory, inventoryRowSearchList); + medicalInventoryManager.validateMedicalInventoryRow(inventory, inventoryRowSearchList); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); try { @@ -1079,8 +1076,6 @@ public void valueChanged(ListSelectionEvent e) { } } }); - sorter = new TableRowSorter<>(model); - jTableInventoryRow.setRowSorter(sorter); DefaultCellEditor cellEditor = new DefaultCellEditor(jTextFieldEditor); jTableInventoryRow.setDefaultEditor(Integer.class, cellEditor); } @@ -1486,7 +1481,7 @@ private JRadioButton getAllRadio() { try { allRadio.setSelected(true); jTableInventoryRow.setModel(new InventoryRowModel(true)); - + } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } From 0c95df3e9780945caf040a424fee583b57200da0 Mon Sep 17 00:00:00 2001 From: JantBogard Date: Mon, 4 Nov 2024 11:26:53 +0100 Subject: [PATCH 068/147] fix overlapped fields --- bundle/language_en.properties | 8 +++--- rpt_base/Inventory.jasper | Bin 40480 -> 40967 bytes rpt_base/Inventory.jrxml | 17 +++++++++--- .../medicalinventory/gui/InventoryEdit.java | 22 ++++----------- .../GenericReportPharmaceuticalInventory.java | 25 ++++++++++++++++++ 5 files changed, 46 insertions(+), 26 deletions(-) create mode 100644 src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 15afaa0230..e1ece8b61a 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -665,6 +665,7 @@ angal.hospital.visitduration.txt angal.hospital.visitendhour.txt = Visit end hour angal.hospital.visitstarthour.txt = Visit start hour angal.inventory.allproduct.txt = All products +angal.inventory.askforrealquantityempty = Do you want to print without the real quantity? angal.inventory.canceled = Canceled angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg = Cannot create another inventory with status draft. angal.inventory.cannotsavelot.msg = Cannot save the lot. Please verify lot information and retry. @@ -691,6 +692,7 @@ angal.inventory.new.col angal.inventory.lot.btn = Lot angal.inventory.lot.btn.key = L angal.inventory.supplier.label = Supplier +angal.inventory.pleasesavebeforprinting = Please save the inventory before printing. angal.inventoryrow.addnotyetlistedproducts.title = Add products angal.inventoryrow.doyoureallywanttodeletethisinventoryrow.msg = Do you really want to delete this/those inventory(ies) row(s)? angal.inventoryrow.doyoureallywanttocleanthistable.msg = Do you really want to clean this table? @@ -1901,8 +1903,4 @@ angal.xmpp.userinfo.fmt.txt angal.xmpp.usersinfo.border = User's Info angal.xmpp.wantstosharewithyouthisreport.fmt.msg = \n*** {0} wants to share with you this report: {1}\n angal.xmpp.wouldliketosend.fmt.msg = {0} would like to send: \n{1} -angal.xmpp.youhaverejectedthefiletransfer.txt = You have rejected the file transfer. -angal.inventory.pleasesavebeforprinting = Please save the inventory before printing. -angal.inventory.print.success.msg = Inventory printed successfully. -angal.inventory.printing.error.msg = Error occurred while printing the inventory. -angal.inventorywardedit.askforrealquantityempty = Do you want to print the real quantity? \ No newline at end of file +angal.xmpp.youhaverejectedthefiletransfer.txt = You have rejected the file transfer. \ No newline at end of file diff --git a/rpt_base/Inventory.jasper b/rpt_base/Inventory.jasper index c053b57786306f3b75f5473b40cff9b7691c2a95..6a7b63b6afbc0fe0a355092c61ca31e37c38cf77 100644 GIT binary patch delta 5615 zcma)93v3j}8Q#4IcLoP+YWsYConLo8{5bo}%f!aUrZJHEr4UGJ8{2E&**Z-J)O$i{=DpDh*POyShB@J}`nZ2F4 z^+J2n&FuXDKl6RxJpP?Md&%(KdBZP1HE&!wBM3qo{)_m(UJwkn*gbQv!LV`$^;$nz zL)-#t9kiqMVQZ`_DY`a|*w&K{xQ~zv1xhW*izTP65pl;@TKcdN2AIvf4V7en2CAF( zr%9{OiMq4el*icBtjna&>70NeQ!{cO9@vflCKPmLp>jt#bn0}tp<1fVN1l8Odc(0k zKI)QV13cbw*q9~Rd{_{$QNpN84hstAZwBYN{BErb9|rm!mhm|F4;37P3P8RpNTBOBJ12(yX1|5e)V-*e2+O60P85w<>tiZ9(mBYc`wcWe~fp z6-(pH-108E<62{dn-*YGp?{Y4V;ahei56HTVKyREqjPx$C|c%CAsa43jIXH!olf_l z<+9&H=S$^XxcWh5HZ+!M3(!*)Y49i&7Nez#M-p~}XvZW)dm>2)OJO~%D9_`7CalKO zo_%zJQq*(QhgZUle&yMRV>s0MN)`3%N-KJ{lA9aR3$R`-ERADxQ;fc@EQupGRPCh5 z8&u>rjC>ZoPzA{7qbfoY1m}8H=o?-u>hhTUjw}{!5lvV#psjGDt_6P7J!)9(yc+VZ;d0Bi8C}<5bP105fiK>eU}mTvZY={0ywtJ0ZMh;nd2GgOv262w{6lA}?I^gNNPlU25%ihg zo&!}%O`4hDlP3z8QbUg4rkWkf;OKbG7=DcXtA=D=ba%%hcorVr4OLR@98}(88R!?a zmGHP!yA>+f!t-@jnk^_uYn^hkIS-RFUpEi^VCTNHa|9kO^--wk*k<%veKj;;*ZjMl zP39LcnP2EkChy=TlQ%Q;UpJ7%@@c~)VEA@D=THx|VI4Wt0Fz8|AAVopn50IMzbQK_ zx+0N10J(L!QAst$=wcH-PEF>7gKWseLm4tPdrJwm0zAy!#U?e={imrOTVr**OO0z+ z&WOT9L~wPrpxZ5ZvAO1^wW1ii+VOqSl00R?hb$QlJ<%JLh3tXQsAohP5BnqIp+VU* zE>HLZAoxlM~qUP5fJh4NE$d03QmlUDPr8ZL-K+9!_q)tY-oBsBBYK; zlagmb4g@`WrSaibDQvb}e+Ml+u_>B7WyR}}0&4;b{x?}LhXd38AT+M?jX%kPSOwNU zW9xw@n=5LdaZMIdzbVO5qfZLU{)lHJ;*+Mq@gd*$FMQ)B-`Ms6-};De{FQIqh&QIg zSWh{AZ{?hxUl)`1#|)Ww46?8;FgEEQlS7f2eZDZ+w1zve@`IJ8jQfHxwT!cjfLR&M z^v+_mq9dKTMaC3h8lvG3hifLab+hhysQsS=yf zw|hFX)LdcQi{r%wE=??wpnE;!wUCe|^KHfhFghvPD6d|6%kw)+sf$|qcZAZ1I+V2L zcc${;N>=kba}+CGHX%fAmEtY9TN>NY=|~2sfQ0)_A4#|s5(w&%IIetRvl&4bErMFU z)TP6hcQC%ZmGM=qdVGU%zSe;t(4HIsu0I{v&l0uqdEG>9_d(>no;)<{D}}DBQ?||c zLr_MFIju74(ox1cm@?kVlqps{Wpi<5uo6jwkn7RD!E&gk2J^-9=*NS#$*{vCck!+e4}s^Z(4)N(!#)#y)*4BrLNUvl|Ix#$>Q)-KAe)pR<~l+kTn@} z$^Lds0{crV`9LA(bwWpu1u64FQMv;E_5Q12&gw8)zg& zg;pbV>1gB~Oe1eqHRdQ*rV-eYRBEc=4sh(<$Tky@`f@TKE6Sc~!XJPz4?qup1mP`5 zGVXIzKUb-DfsYgkZvj{y>e8XkI~aA|s#0G=t>}++C204|DS-XM43PV5hU^sYv0~Kz z47swBnUsMJDd_uKpf4q$LtQ#_cn71yTU9!lij~bIotzNrJxabxAf5c^C|TKSM}gp;mA7}N8YM(ELW^rj;FXC4Gd1INAT6-JwWc>aUkrNT}Ai; zgp=ZREn(`?Aa($T{^m>%BB^e9%Xp0^*UXYmAlu)b#fj+k|;VHZ`RUciNEcy}6Z z#R^Z}u!*R%kMB z624}8$B^aa{o-EK_41+U^J>RO2-XV3Us8?hnem!x{01?8h9iX&sxgfjUsa9i%=ngS l%wWc=PSt8-Rz^3I8d3Kvqc$_>7I&*1a^T5qMoX{k`Y)fsfCm5o delta 4987 zcma)Qx_Us&lQO-QBfP^YRbj8U1Yt%_*WMp`viwXABXT2RA>P3zPeTB@p2N4N8wbA8V7 z?M0fUoOAF0dG7iD&f{~AZ+<(c{o$f^{>!W-sk4frILMzy{_+(?wI+Ye>ejT>S?IQZ zM7m_tqCe(1Xj;Cak|g{@uz{j-Z!*u3tzwqLIbgwuW?VP0i@Se?-F5d4dbd0Xoy+dk zFOyf6U82vNDBZ6aN8UpQZo-kF##e(6?DU1PTWIk^o!;@ihp|JGAIhC*9BPz&#*`W51=@^` zW7n^HtYVop@Xm7G#tlUkttM7#KIHqnaI}KX=@r(Y-G3`|yCBR3Y!!6)4Bty=cq!AD z=H}2`G2OYqTEsc+cY`yy-pD}eswQY%p9mTm)`e`aD8%a;3(>mX7vgn|h2*-%Ncvwx ze8R5EO-8eg#O&|X?8!=_Szee=_`R?V?hD&JqR1(nY|1!UmX{@cweN+~b4@N^F^`K0 z{#DgOF!XOrwc$6U%p{bRaN1iAv(=G8x`dai>F?7AC!BSVs{R{3e6eO1>7J_h;LSoy zIXqJ9z{~jZ04&rl&R7Ymn?S1WOh`;C6i?W}Tj#@D{5E#fb+7^z^8LeB`KxsuBu8?M z)pOT7^>%oyUaE~6LEDJYmgR}s1mI46W!iat!#d_%z@6`<%l^p*bcW9wC?rm}EW)j? zMeNWWk*znQ^=6|r%ag6IMYy$h<)G0zL{`OFIJJ`QILW%Ikz4mR7K+uN_MmN#!FEZ8 zoL>F`_@a?}SFhTNvzuDgX_%yYb=s*~ox;JV*x>Sp%Lt@5dSFS0EL=ZXU9A^8>1`@g zjZ;1Om)$PYrn`P2Uc9sSD zALxb^54Go7Chg>&X(t{kvuGm&NzcOzn(K3ILdo4fe6VkLVk9xu(K||Ew9k{pJL;`V zzfzRR6j?M1a^7Y?J=%A$qqD3+`w_JfmVTGKlbxmiSKigm?G@Uc3B|g7!{&`Ntrh6UKFCh0|TI$P94&1NdZdz@+%-s)e947j&m z?4f(hu@@(Se0%rmeCdT;Vu>RgZFU;jSjdD;4hS|`6>LnUY&+9zH+zQ=v8xZcj`uw% z_MqjU`5t5w_&F=CfIo`xv^i{qXCV`KIUwL=RlqZq!XHk zB>UYUVxAwQn7cme)F==zbh{-}Gm~ud1$|}bU>#7m+0`jIm9CqE%qYTywZw=)V z;LAhw9ZUxP5P@m)z7d#(On~Kp0G3q&tgA-g_tUW0bKpmYUqoPa1gkq=7lth(OHh!3 z@wdoAn_EU;7BT^r0|Ho91+cCffp3`tpBs%MU(wh+c2~!0v*{~q1H}8vpfXXQ7Q>o^ zbl_Q?gg)cIJCkT2Ns)cUa5K?_gH(<`fE}(TYk*|4#v{*Fod{O3&`;;8Kf?lSt|Yxk zPG@r^YBp2Jo^)tdkF+V1FHJOAk>bWL{dvWs6N+vBfp~vkZ3IqKx*;^>C2!_f55$Yo zQ-+?A2d4hS(K|3kn~ZZB(OJj@T@DCzSrzC^g%6^YP<7}S+P-?oPb&HGA-cp}GXc09 zq%Rhz_cM zM`+rdF+#JD3A7v#(6TC^b=3%c=C05ejw1B)H;=07M{w&mF4{VhWskpGLN5P#>e%cD z&6!wPfB}F<`xd$@F!LK9ZH0la04m`3Sbms68{fXgr}rh9ULLg9T0e zkz69;fA3E4Jd*<>&o;~+Ce4C5KRJ=|yl_Okq2=Q4iI)(TK7nch0 jN|381Lj8h^E+#_za|cSSw~3+J&SRxCb{qckT - - + + - + + + + + + + + + + @@ -12,7 +21,7 @@ - + diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 0277b7bce5..b33271c206 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -87,7 +87,7 @@ import org.isf.medstockmovtype.model.MovementType; import org.isf.menu.manager.Context; import org.isf.menu.manager.UserBrowsingManager; -import org.isf.stat.dto.JasperReportResultDto; +import org.isf.stat.gui.report.GenericReportPharmaceuticalInventory; import org.isf.stat.manager.JasperReportsManager; import org.isf.supplier.manager.SupplierBrowserManager; import org.isf.supplier.model.Supplier; @@ -104,8 +104,6 @@ import org.isf.utils.time.TimeTools; import org.isf.ward.manager.WardBrowserManager; import org.isf.ward.model.Ward; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class InventoryEdit extends ModalJFrame { @@ -881,28 +879,18 @@ private JButton getPrintButton() { printButton.setEnabled(true); printButton.addActionListener(e -> { - if (inventory == null || inventory.getId() <= 0) { + if (inventory == null || inventory.getId() == 0 || inventory.getId() <= 0) { MessageDialog.info(this, "angal.inventory.pleasesavebeforprinting"); return; } - if (InventoryStatus.done.name().equals(inventory.getStatus())) { + if (!InventoryStatus.done.name().equals(inventory.getStatus())) { int printQtyReal = 0; - int response = MessageDialog.yesNo(this, "angal.inventorywardedit.askforrealquantityempty"); + int response = MessageDialog.yesNo(this, "angal.inventory.askforrealquantityempty"); if (response == JOptionPane.YES_OPTION) { printQtyReal = 1; } - - try { - JasperReportResultDto reportResult = jasperReportsManager.getInventoryReportPdf(inventory, "Inventory", printQtyReal); - if (reportResult != null) { - MessageDialog.info(this, "angal.inventory.print.success.msg"); - } else { - MessageDialog.error(this, "angal.inventory.printing.error.msg"); - } - } catch (OHServiceException ex) { - MessageDialog.error(this, "angal.inventory.printing.error.msg"); - } + new GenericReportPharmaceuticalInventory(inventory, "Inventory", printQtyReal); } else { MessageDialog.info(this, "angal.inventory.pleasesavebeforprinting"); } diff --git a/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java b/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java new file mode 100644 index 0000000000..d38455eb62 --- /dev/null +++ b/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java @@ -0,0 +1,25 @@ +package org.isf.stat.gui.report; + +import org.isf.medicalinventory.model.MedicalInventory; +import org.isf.menu.manager.Context; +import org.isf.stat.dto.JasperReportResultDto; +import org.isf.stat.manager.JasperReportsManager; +import org.isf.utils.jobjects.MessageDialog; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class GenericReportPharmaceuticalInventory extends DisplayReport { + + private static final Logger LOGGER = LoggerFactory.getLogger(GenericReportPharmaceuticalInventory.class); + private JasperReportsManager jasperReportsManager = Context.getApplicationContext().getBean(JasperReportsManager.class); + + public GenericReportPharmaceuticalInventory(MedicalInventory medicalInventory, String jasperFileName, int printQtyReal) { + try { + JasperReportResultDto jasperReportResultDto = jasperReportsManager.getInventoryReportPdf(medicalInventory, jasperFileName, printQtyReal); + showReport(jasperReportResultDto); + } catch (Exception e) { + LOGGER.error("", e); + MessageDialog.error(null, "angal.inventory.printing.error.msg"); + } + } +} From bd21db696cfbc8ee8541a916c908c2acc1530a06 Mon Sep 17 00:00:00 2001 From: JantBogard Date: Thu, 7 Nov 2024 16:57:29 +0100 Subject: [PATCH 069/147] clean code and apply request change --- bundle/language_en.properties | 4 +- .../gui/InventoryBrowser.java | 8 - .../medicalinventory/gui/InventoryEdit.java | 182 ++++++------------ .../GenericReportPharmaceuticalInventory.java | 21 ++ 4 files changed, 86 insertions(+), 129 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index d85bb95b55..db8e1c5c57 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -665,7 +665,7 @@ angal.hospital.visitduration.txt angal.hospital.visitendhour.txt = Visit end hour angal.hospital.visitstarthour.txt = Visit start hour angal.inventory.allproduct.txt = All products -angal.inventory.askforrealquantityempty = Do you want to print without the real quantity? +angal.inventory.askforrealquantityempty.msg = Do you want to print without the real quantity? angal.inventory.canceled = Canceled angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg = Cannot create another inventory with status draft, Because you already have an inventory with status draft or validated. angal.inventory.cannotsavelot.msg = Cannot save the lot. Please verify lot information and retry. @@ -704,7 +704,7 @@ angal.inventory.newlot.col angal.inventory.lot.btn = Lot angal.inventory.lot.btn.key = L angal.inventory.supplier.label = Supplier -angal.inventory.pleasesavebeforprinting = Please save the inventory before printing. +angal.inventory.pleasesavebeforprinting.msg = Please save the inventory before printing. angal.inventoryrow.addnotyetlistedproducts.title = Add products angal.inventoryrow.doyoureallywanttodeletethisinventoryrow.msg = Do you really want to delete this/those inventory(ies) row(s)? angal.inventoryrow.doyoureallywanttocleanthistable.msg = Do you really want to clean this table? diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 39ce934de6..0a98490b5d 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -84,7 +84,6 @@ public class InventoryBrowser extends ModalJFrame implements InventoryListener { private JButton jButtonClose; private JButton jButtonNew; private JButton jButtonEdit; - private JButton jButtonPrint; private JButton jButtonDelete; private JButton jButtonView; private JScrollPane scrollPaneInventory; @@ -409,13 +408,6 @@ private JButton getViewButton() { }); return jButtonView; } - - private JButton getPrintButton() { - jButtonPrint = new JButton(MessageBundle.getMessage("angal.common.print.btn")); - jButtonPrint.setMnemonic(MessageBundle.getMnemonic("angal.common.print.btn.key")); - jButtonPrint.setEnabled(false); - return jButtonPrint; - } private JButton getDeleteButton() { jButtonDelete = new JButton(MessageBundle.getMessage("angal.common.delete.btn")); diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index f8596496c5..6d203a7a2a 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -193,8 +193,7 @@ private void fireInventoryUpdated() { private int[] pColumwidth = { 50, 50, 200, 100, 100, 100, 100, 80, 80, 80 }; private boolean[] columnEditable = { false, false, false, false, false, false, false, true, false, false }; private boolean[] columnEditableView = { false, false, false, false, false, false, false, false, false, false }; - private boolean[] pColumnVisible = { false, true, true, true, !GeneralData.AUTOMATICLOT_IN, true, true, true, - GeneralData.LOTWITHCOST, + private boolean[] pColumnVisible = { false, true, true, true, !GeneralData.AUTOMATICLOT_IN, true, true, true, GeneralData.LOTWITHCOST, GeneralData.LOTWITHCOST }; private MedicalInventory inventory = null; private JRadioButton specificRadio; @@ -221,21 +220,14 @@ private void fireInventoryUpdated() { private Ward destination = null; private boolean selectAll = false; private String newReference = null; - private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext() - .getBean(MedicalInventoryManager.class); - private MedicalInventoryRowManager medicalInventoryRowManager = Context.getApplicationContext() - .getBean(MedicalInventoryRowManager.class); - private MedicalBrowsingManager medicalBrowsingManager = Context.getApplicationContext() - .getBean(MedicalBrowsingManager.class); - private MovStockInsertingManager movStockInsertingManager = Context.getApplicationContext() - .getBean(MovStockInsertingManager.class); - private MedicalDsrStockMovementTypeBrowserManager movTypeManager = Context.getApplicationContext() - .getBean(MedicalDsrStockMovementTypeBrowserManager.class); - private SupplierBrowserManager supplierManager = Context.getApplicationContext() - .getBean(SupplierBrowserManager.class); + private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); + private MedicalInventoryRowManager medicalInventoryRowManager = Context.getApplicationContext().getBean(MedicalInventoryRowManager.class); + private MedicalBrowsingManager medicalBrowsingManager = Context.getApplicationContext().getBean(MedicalBrowsingManager.class); + private MovStockInsertingManager movStockInsertingManager = Context.getApplicationContext().getBean(MovStockInsertingManager.class); + private MedicalDsrStockMovementTypeBrowserManager movTypeManager = Context.getApplicationContext().getBean(MedicalDsrStockMovementTypeBrowserManager.class); + private SupplierBrowserManager supplierManager = Context.getApplicationContext().getBean(SupplierBrowserManager.class); private WardBrowserManager wardManager = Context.getApplicationContext().getBean(WardBrowserManager.class); - private JasperReportsManager jasperReportsManager = Context.getApplicationContext() - .getBean(JasperReportsManager.class); + private JasperReportsManager jasperReportsManager = Context.getApplicationContext().getBean(JasperReportsManager.class); public InventoryEdit() { mode = "new"; @@ -544,8 +536,7 @@ private JButton getSaveButton() { inventory.setDestination(null); } inventory = medicalInventoryManager.newMedicalInventory(inventory); - for (Iterator iterator = inventoryRowSearchList.iterator(); iterator - .hasNext();) { + for (Iterator iterator = inventoryRowSearchList.iterator(); iterator.hasNext();) { MedicalInventoryRow medicalInventoryRow = (MedicalInventoryRow) iterator.next(); medicalInventoryRow.setInventory(inventory); Lot lot = medicalInventoryRow.getLot(); @@ -597,13 +588,11 @@ private JButton getSaveButton() { } if (inventoryRowListAdded.isEmpty() && lotsSaved.isEmpty() && lotsDeleted.isEmpty()) { if ((destination != null && !destination.getCode().equals(lastDestination)) - || (chargeType != null && !chargeType.getCode().equals(lastCharge)) - || (dischargeType != null && !dischargeType.getCode().equals(lastDischarge)) - || (supplier != null && !supplier.getSupId().equals(lastSupplier)) - || (destination == null && lastDestination != null) - || (chargeType == null && lastCharge != null) - || (dischargeType == null && lastDischarge != null) - || (supplier == null && lastSupplier != null) || !lastReference.equals(newReference)) { + || (chargeType != null && !chargeType.getCode().equals(lastCharge)) + || (dischargeType != null && !dischargeType.getCode().equals(lastDischarge)) + || (supplier != null && !supplier.getSupId().equals(lastSupplier)) || (destination == null && lastDestination != null) + || (chargeType == null && lastCharge != null) || (dischargeType == null && lastDischarge != null) + || (supplier == null && lastSupplier != null) || !lastReference.equals(newReference)) { if (!inventory.getInventoryDate().equals(dateInventory)) { inventory.setInventoryDate(dateInventory); } @@ -642,8 +631,7 @@ private JButton getSaveButton() { MessageDialog.info(null, "angal.inventory.update.success.msg"); resetVariable(); fireInventoryUpdated(); - int info = MessageDialog.yesNo(null, - "angal.inventoryrow.doyouwanttocontinueediting.msg"); + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttocontinueediting.msg"); if (info != JOptionPane.YES_OPTION) { dispose(); } @@ -656,8 +644,7 @@ private JButton getSaveButton() { MessageDialog.info(null, "angal.inventory.update.success.msg"); resetVariable(); fireInventoryUpdated(); - int info = MessageDialog.yesNo(null, - "angal.inventoryrow.doyouwanttocontinueediting.msg"); + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttocontinueediting.msg"); if (info != JOptionPane.YES_OPTION) { dispose(); } @@ -703,8 +690,7 @@ private JButton getSaveButton() { inventory.setDestination(null); } inventory = medicalInventoryManager.updateMedicalInventory(inventory); - for (Iterator iterator = inventoryRowSearchList.iterator(); iterator - .hasNext();) { + for (Iterator iterator = inventoryRowSearchList.iterator(); iterator.hasNext();) { MedicalInventoryRow medicalInventoryRow = iterator.next(); Medical medical = medicalInventoryRow.getMedical(); Lot lot = medicalInventoryRow.getLot(); @@ -782,7 +768,6 @@ private JButton getSaveButton() { }); return saveButton; } - private JButton getDeleteButton() { deleteButton = new JButton(MessageBundle.getMessage("angal.common.delete.btn")); deleteButton.setMnemonic(MessageBundle.getMnemonic("angal.common.delete.btn.key")); @@ -800,8 +785,7 @@ private JButton getDeleteButton() { } if (inventory == null) { for (int i = selectedRows.length - 1; i >= 0; i--) { - MedicalInventoryRow selectedInventoryRow = (MedicalInventoryRow) jTableInventoryRow - .getValueAt(selectedRows[i], -1); + MedicalInventoryRow selectedInventoryRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRows[i], -1); inventoryRowSearchList.remove(selectedInventoryRow); model.fireTableDataChanged(); jTableInventoryRow.setModel(model); @@ -809,8 +793,7 @@ private JButton getDeleteButton() { } else { for (int i = selectedRows.length - 1; i >= 0; i--) { - MedicalInventoryRow inventoryRow = (MedicalInventoryRow) jTableInventoryRow - .getValueAt(selectedRows[i], -1); + MedicalInventoryRow inventoryRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRows[i], -1); inventoryRowSearchList.remove(inventoryRow); model.fireTableDataChanged(); jTableInventoryRow.setModel(model); @@ -837,8 +820,7 @@ private JButton getLotButton() { MessageDialog.error(this, "angal.inventoryrow.pleaseselectoneinventoryrow.msg"); return; } - MedicalInventoryRow selectedInventoryRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRow, - -1); + MedicalInventoryRow selectedInventoryRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRow, -1); Lot lotToUpdate = selectedInventoryRow.getLot() != null ? selectedInventoryRow.getLot() : null; Lot lot = new Lot(); try { @@ -858,8 +840,7 @@ private JButton getLotButton() { code = lot.getCode(); if (selectedInventoryRow.getLot() == null) { List invRows = inventoryRowSearchList.stream() - .filter(inv -> inv.getLot() != null && inv.getLot().getCode().equals(code)) - .collect(Collectors.toList()); + .filter(inv -> inv.getLot() != null && inv.getLot().getCode().equals(code)).collect(Collectors.toList()); if (invRows.size() == 0 || code.equals("")) { selectedInventoryRow.setNewLot(true); selectedInventoryRow.setLot(lot); @@ -877,12 +858,8 @@ private JButton getLotButton() { } } else { List invRows = inventoryRowSearchList.stream() - .filter(inv -> inv.getMedical().getCode() - .equals(selectedInventoryRow.getMedical().getCode())) - .collect(Collectors.toList()); - invRows = invRows.stream() - .filter(inv -> inv.getLot() != null && inv.getLot().getCode().equals(code)) - .collect(Collectors.toList()); + .filter(inv -> inv.getMedical().getCode().equals(selectedInventoryRow.getMedical().getCode())).collect(Collectors.toList()); + invRows = invRows.stream().filter(inv -> inv.getLot() != null && inv.getLot().getCode().equals(code)).collect(Collectors.toList()); if (invRows.size() == 0 || code.equals("")) { selectedInventoryRow.setNewLot(true); selectedInventoryRow.setLot(lot); @@ -924,17 +901,14 @@ private JButton getCloseButton() { lastReference = inventory.getInventoryReference(); lastDate = inventory.getInventoryDate(); } - if (!lotsSaved.isEmpty() || !inventoryRowListAdded.isEmpty() || !lotsDeleted.isEmpty() - || !inventoryRowsToDelete.isEmpty() - || (destination != null && !destination.getCode().equals(lastDestination)) - || (chargeType != null && !chargeType.getCode().equals(lastCharge)) - || (dischargeType != null && !dischargeType.getCode().equals(lastDischarge)) - || (supplier != null && !supplier.getSupId().equals(lastSupplier)) - || (destination == null && lastDestination != null) - || (chargeType == null && lastCharge != null) || (dischargeType == null && lastDischarge != null) - || (supplier == null && lastSupplier != null) - || (lastReference != null && !lastReference.equals(newReference)) - || !lastDate.toLocalDate().equals(dateInventory.toLocalDate())) { + if (!lotsSaved.isEmpty() || !inventoryRowListAdded.isEmpty() || !lotsDeleted.isEmpty() || !inventoryRowsToDelete.isEmpty() + || (destination != null && !destination.getCode().equals(lastDestination)) + || (chargeType != null && !chargeType.getCode().equals(lastCharge)) + || (dischargeType != null && !dischargeType.getCode().equals(lastDischarge)) + || (supplier != null && !supplier.getSupId().equals(lastSupplier)) || (destination == null && lastDestination != null) + || (chargeType == null && lastCharge != null) || (dischargeType == null && lastDischarge != null) + || (supplier == null && lastSupplier != null) || (lastReference != null && !lastReference.equals(newReference)) + || !lastDate.toLocalDate().equals(dateInventory.toLocalDate())) { int reset = MessageDialog.yesNoCancel(null, "angal.inventoryrow.doyouwanttosavethechanges.msg"); if (reset == JOptionPane.YES_OPTION) { this.saveButton.doClick(); @@ -960,21 +934,12 @@ private JButton getPrintButton() { printButton.setEnabled(true); printButton.addActionListener(e -> { - if (inventory == null || inventory.getId() == 0 || inventory.getId() <= 0) { - MessageDialog.info(this, "angal.inventory.pleasesavebeforprinting"); - return; - } - - if (!InventoryStatus.done.name().equals(inventory.getStatus())) { - int printQtyReal = 0; - int response = MessageDialog.yesNo(this, "angal.inventory.askforrealquantityempty"); - if (response == JOptionPane.YES_OPTION) { - printQtyReal = 1; - } - new GenericReportPharmaceuticalInventory(inventory, "Inventory", printQtyReal); - } else { - MessageDialog.info(this, "angal.inventory.pleasesavebeforprinting"); + int printQtyReal = 0; + int response = MessageDialog.yesNo(this, "angal.inventory.askforrealquantityempty"); + if (response == JOptionPane.YES_OPTION) { + printQtyReal = 1; } + new GenericReportPharmaceuticalInventory(inventory, "Inventory", printQtyReal); }); return printButton; @@ -1018,8 +983,7 @@ private JButton getValidateButton() { MessageDialog.error(null, "angal.inventory.inventorymustsavebeforevalidation.msg"); return; } - List invRowWithoutLot = inventoryRowSearchList.stream() - .filter(invRow -> invRow.getLot() == null).collect(Collectors.toList()); + List invRowWithoutLot = inventoryRowSearchList.stream().filter(invRow -> invRow.getLot() == null).collect(Collectors.toList()); if (invRowWithoutLot.size() > 0) { MessageDialog.error(null, "angal.inventory.allinventoryrowshouldhavelotbeforevalidation.msg"); return; @@ -1065,12 +1029,10 @@ private JButton getValidateButton() { try { inventory = medicalInventoryManager.updateMedicalInventory(inventory); if (inventory != null) { - List invRows = medicalInventoryRowManager - .getMedicalInventoryRowByInventoryId(inventory.getId()); + List invRows = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()); MessageDialog.info(null, "angal.inventory.validate.success.msg"); if (invRows.size() > inventoryRowsSize) { - MessageDialog.error(null, - "angal.inventory.theoreticalqtyhavebeenupdatedforsomemedical.msg"); + MessageDialog.error(null, "angal.inventory.theoreticalqtyhavebeenupdatedforsomemedical.msg"); } fireInventoryUpdated(); statusLabel.setText(status.toUpperCase()); @@ -1087,7 +1049,6 @@ private JButton getValidateButton() { }); return validateButton; } - private JScrollPane getScrollPaneInventory() { if (scrollPaneInventory == null) { scrollPaneInventory = new JScrollPane(); @@ -1124,12 +1085,10 @@ private JTable getJTableInventoryRow() throws OHServiceException { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { - jTableInventoryRow.editCellAt(jTableInventoryRow.getSelectedRow(), - jTableInventoryRow.getSelectedColumn()); + jTableInventoryRow.editCellAt(jTableInventoryRow.getSelectedRow(), jTableInventoryRow.getSelectedColumn()); int[] selectedRows = jTableInventoryRow.getSelectedRows(); if (selectedRows.length == 1) { - MedicalInventoryRow medInvRow = (MedicalInventoryRow) jTableInventoryRow - .getValueAt(selectedRows[0], -1); + MedicalInventoryRow medInvRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRows[0], -1); if (medInvRow.getLot() == null || medInvRow.isNewLot()) { lotButton.setEnabled(true); } else { @@ -1152,8 +1111,7 @@ class EnabledTableCellRenderer extends DefaultTableCellRenderer { private static final long serialVersionUID = 1L; @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, - int row, int column) { + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); return cell; } @@ -1198,7 +1156,7 @@ public InventoryRowModel() throws OHServiceException { } - public Class getColumnClass(int c) { + public Class< ? > getColumnClass(int c) { if (c == 0) { return Integer.class; } else if (c == 1) { @@ -1373,8 +1331,7 @@ private Lot askLot(Lot lotToUpdate) { JTextField lotNameTextField = new JTextField(15); lotNameTextField.addAncestorListener(new RequestFocusListener()); - TextPrompt suggestion = new TextPrompt(MessageBundle.getMessage("angal.medicalstock.multiplecharging.lotid"), - lotNameTextField); + TextPrompt suggestion = new TextPrompt(MessageBundle.getMessage("angal.medicalstock.multiplecharging.lotid"), lotNameTextField); suggestion.setFont(new Font("Tahoma", Font.PLAIN, 14)); suggestion.setForeground(Color.GRAY); suggestion.setHorizontalAlignment(SwingConstants.CENTER); @@ -1397,10 +1354,10 @@ private Lot askLot(Lot lotToUpdate) { panel.add(expireDateChooser); do { int ok = JOptionPane.showConfirmDialog( - this, - panel, - MessageBundle.getMessage("angal.medicalstock.multiplecharging.lotinformations"), - JOptionPane.OK_CANCEL_OPTION); + this, + panel, + MessageBundle.getMessage("angal.medicalstock.multiplecharging.lotinformations"), + JOptionPane.OK_CANCEL_OPTION); if (ok == JOptionPane.OK_OPTION) { String lotName = lotNameTextField.getText(); @@ -1431,13 +1388,12 @@ private Lot askLot(Lot lotToUpdate) { } while (lot == null); return lot; } - private BigDecimal askCost(int qty, BigDecimal lastCost) { double cost = 0.; do { String input = JOptionPane.showInputDialog(this, - MessageBundle.getMessage("angal.medicalstock.multiplecharging.unitcost"), - lastCost); + MessageBundle.getMessage("angal.medicalstock.multiplecharging.unitcost"), + lastCost); if (input != null) { try { cost = Double.parseDouble(input); @@ -1465,8 +1421,8 @@ protected LocalDateTime askExpiringDate() { panel.add(expireDateChooser); int ok = JOptionPane.showConfirmDialog(this, panel, - MessageBundle.getMessage("angal.medicalstock.multiplecharging.expiringdate"), - JOptionPane.OK_CANCEL_OPTION); + MessageBundle.getMessage("angal.medicalstock.multiplecharging.expiringdate"), + JOptionPane.OK_CANCEL_OPTION); if (ok == JOptionPane.OK_OPTION) { date = expireDateChooser.getLocalDateTime(); @@ -1476,8 +1432,8 @@ protected LocalDateTime askExpiringDate() { protected double askTotalCost() { String input = JOptionPane.showInputDialog(this, - MessageBundle.getMessage("angal.medicalstock.multiplecharging.totalcost"), - 0.); + MessageBundle.getMessage("angal.medicalstock.multiplecharging.totalcost"), + 0.); double total = 0.; if (input != null) { try { @@ -1530,8 +1486,7 @@ private JRadioButton getAllRadio() { codeTextField.setEnabled(false); codeTextField.setText(""); if (inventoryRowSearchList.size() > 0) { - int info = MessageDialog.yesNo(null, - "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); if (info == JOptionPane.YES_OPTION) { try { allRadio.setSelected(true); @@ -1593,8 +1548,7 @@ private JTextField getCodeTextField() { codeTextField.setEnabled(true); } codeTextField.setColumns(10); - TextPrompt suggestion = new TextPrompt(MessageBundle.getMessage("angal.common.code.txt"), codeTextField, - Show.FOCUS_LOST); + TextPrompt suggestion = new TextPrompt(MessageBundle.getMessage("angal.common.code.txt"), codeTextField, Show.FOCUS_LOST); suggestion.setFont(new Font("Tahoma", Font.PLAIN, 12)); suggestion.setForeground(Color.GRAY); suggestion.setHorizontalAlignment(JLabel.CENTER); @@ -1623,8 +1577,7 @@ public void keyPressed(KeyEvent e) { return codeTextField; } - private List loadNewInventoryTable(String code, MedicalInventory inventory, boolean add) - throws OHServiceException { + private List loadNewInventoryTable(String code, MedicalInventory inventory, boolean add) throws OHServiceException { List inventoryRowsList = new ArrayList<>(); if (inventory != null) { int id = inventory.getId(); @@ -1669,8 +1622,7 @@ private List getMedicalInventoryRows(String code) throws OH } else { for (Iterator iterator2 = lots.iterator(); iterator2.hasNext();) { Lot lot = (Lot) iterator2.next(); - inventoryRowTemp = new MedicalInventoryRow(0, lot.getMainStoreQuantity(), - lot.getMainStoreQuantity(), null, med, lot); + inventoryRowTemp = new MedicalInventoryRow(0, lot.getMainStoreQuantity(), lot.getMainStoreQuantity(), null, med, lot); if (!existInInventorySearchList(inventoryRowTemp)) { inventoryRowsList.add(inventoryRowTemp); } @@ -1679,7 +1631,6 @@ private List getMedicalInventoryRows(String code) throws OH } return inventoryRowsList; } - private void addInventoryRow(String code) throws OHServiceException { List inventoryRowsList = new ArrayList(); List medicalList = new ArrayList(); @@ -1709,8 +1660,7 @@ private void addInventoryRow(String code) throws OHServiceException { if (!existInInventorySearchList(inventoryRowTemp)) { inventoryRowsList.add(inventoryRowTemp); } else { - int info = MessageDialog.yesNo(null, "angal.inventory.productalreadyexist.msg", - med.getDescription()); + int info = MessageDialog.yesNo(null, "angal.inventory.productalreadyexist.msg", med.getDescription()); if (info == JOptionPane.YES_OPTION) { inventoryRowsList.add(inventoryRowTemp); } @@ -1719,8 +1669,7 @@ private void addInventoryRow(String code) throws OHServiceException { medicalWithLot = med; for (Iterator iterator2 = lots.iterator(); iterator2.hasNext();) { Lot lot = (Lot) iterator2.next(); - inventoryRowTemp = new MedicalInventoryRow(0, lot.getMainStoreQuantity(), - lot.getMainStoreQuantity(), null, med, lot); + inventoryRowTemp = new MedicalInventoryRow(0, lot.getMainStoreQuantity(), lot.getMainStoreQuantity(), null, med, lot); if (!existInInventorySearchList(inventoryRowTemp)) { inventoryRowsList.add(inventoryRowTemp); numberOfMedicalWithoutSameLotAdded = numberOfMedicalWithoutSameLotAdded + 1; @@ -1729,8 +1678,7 @@ private void addInventoryRow(String code) throws OHServiceException { } } if (medicalWithLot != null && numberOfMedicalWithoutSameLotAdded == 0) { - int info = MessageDialog.yesNo(null, "angal.inventory.productalreadyexist.msg", - medicalWithLot.getDescription()); + int info = MessageDialog.yesNo(null, "angal.inventory.productalreadyexist.msg", medicalWithLot.getDescription()); if (info == JOptionPane.YES_OPTION) { inventoryRowTemp = new MedicalInventoryRow(0, 0.0, 0.0, null, medicalWithLot, null); inventoryRowsList.add(inventoryRowTemp); @@ -1815,8 +1763,7 @@ private JLabel getStatusLabel() { statusLabel.setForeground(Color.GREEN); } } - statusLabel - .setFont(new Font(statusLabel.getFont().getName(), Font.BOLD, statusLabel.getFont().getSize() + 8)); + statusLabel.setFont(new Font(statusLabel.getFont().getName(), Font.BOLD, statusLabel.getFont().getSize() + 8)); } return statusLabel; } @@ -1987,8 +1934,7 @@ private int getPosition(MedicalInventoryRow inventoryRow) { private boolean existInInventorySearchList(MedicalInventoryRow inventoryRow) { boolean found = false; List invRows = inventoryRowSearchList.stream() - .filter(inv -> inv.getMedical().getCode().equals(inventoryRow.getMedical().getCode())) - .collect(Collectors.toList()); + .filter(inv -> inv.getMedical().getCode().equals(inventoryRow.getMedical().getCode())).collect(Collectors.toList()); if (invRows.size() > 0) { for (MedicalInventoryRow invR : invRows) { if (inventoryRow.getLot() != null && invR.getLot() != null) { @@ -2007,7 +1953,6 @@ private boolean existInInventorySearchList(MedicalInventoryRow inventoryRow) { return found; } - private void addMedInRowInInventorySearchList(MedicalInventoryRow inventoryRow) { int position = getPosition(inventoryRow); if (position == -1) { @@ -2020,7 +1965,6 @@ private void addMedInRowInInventorySearchList(MedicalInventoryRow inventoryRow) inventoryRowListAdded.add(inventoryRow); } } - private void resetVariable() { inventoryRowsToDelete.clear(); lotsDeleted.clear(); diff --git a/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java b/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java index d38455eb62..5caa9443ff 100644 --- a/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java +++ b/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java @@ -1,3 +1,24 @@ +/* + * Open Hospital (www.open-hospital.org) + * Copyright © 2006-2023 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * + * Open Hospital is a free and open source software for healthcare data management. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * https://www.gnu.org/licenses/gpl-3.0-standalone.html + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.isf.stat.gui.report; import org.isf.medicalinventory.model.MedicalInventory; From 8590b0d8fbd9e6c0d8f3a5312cf8fafffd45d1c5 Mon Sep 17 00:00:00 2001 From: JantBogard Date: Fri, 8 Nov 2024 09:47:24 +0100 Subject: [PATCH 070/147] Applying suggestion changing --- bundle/language_en.properties | 1 - rpt_base/Inventory.jasper | Bin 40967 -> 39869 bytes rpt_base/Inventory.jrxml | 129 ++++++------------ rpt_base/Inventory.properties | 4 +- rpt_base/Inventory_en.properties | 4 +- .../medicalinventory/gui/InventoryEdit.java | 2 +- .../GenericReportPharmaceuticalInventory.java | 2 +- 7 files changed, 49 insertions(+), 93 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index db8e1c5c57..f83dc048c0 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -704,7 +704,6 @@ angal.inventory.newlot.col angal.inventory.lot.btn = Lot angal.inventory.lot.btn.key = L angal.inventory.supplier.label = Supplier -angal.inventory.pleasesavebeforprinting.msg = Please save the inventory before printing. angal.inventoryrow.addnotyetlistedproducts.title = Add products angal.inventoryrow.doyoureallywanttodeletethisinventoryrow.msg = Do you really want to delete this/those inventory(ies) row(s)? angal.inventoryrow.doyoureallywanttocleanthistable.msg = Do you really want to clean this table? diff --git a/rpt_base/Inventory.jasper b/rpt_base/Inventory.jasper index 6a7b63b6afbc0fe0a355092c61ca31e37c38cf77..0416e0ffaa1ec6ec0da45f52393672c7d4d2063f 100644 GIT binary patch literal 39869 zcmeHw34B}CmG^z}rr65nYy=1q2@uCgY=?vpvOr{8P88$?NzUT5b!6)~7Lg?(Jtq!r zL)l8{GSIS>r7bN`%1&FFP(nL&`h75^d;7KhN>`x2PTQH%1?HpEk51=*?!9l5o}QjN zX@B#Z-zf2u-n;jld+xdCoO|xM%X|3OtgcvKEm>7-D~`2Ynk?qkLP5>v3RoIrp#FA$|Q@$%h*xon<}t1ZnTXgiy$!8 ziLX)uS4G(3fp~bZyMH(yjzvPz;a%ZaJksAcJQ(SYu)s)8({dBN$pR`Fp}J%yC$e3+ z$*dM3O6V@0PmY2#BXxH=rHv1zRAn*u2Q1jOs&jgeBvwh5;0=Y$1D{8D|pKD1wV^lL_CG076EIFCc;@Xjn zsx5&vHBuO2L$V!YJ#Q9M?+C)IIqb*HbYY<@|mPYINGb>5GE@jA<))!8Y#YH z$~?PnO2(X5oiV#@I?Zb~m1petH^X?($De|~S&aD>@n5((1AjF;@g$BP{BAx&udvFa zHu=ux1B*prC4#g)C<^8gPz98KdbUY2%C{(JUlPCi70L z^N2=$-7F(nHdlu$1zcq~7YrFhkGIYv-@_So0$ss&SZg$|&VL_F#^`uDlPaiLlB5Nw zmTJkVvDL0Lfu)w*o2T-Sgn87pw~LTA#hB|<8!pY+T3bIjA*klf{@Us8Mq2;7AJr>-A3{(l0+h!xgnm2g%e#nP|Dh> zrIdC&R$RodGc@=%i5T}kn)&rK%Hmip%D=QEX9LgK0Iqeo(PHsj66%!JlU6epC0gXJ zL^DTnxr6X44o1~OYNnITQV+pGbDtoQo=`j4>~S!(kV$6`Cg9+xS|^)nK0(qDTLAUb zAnv2%Mi?$Mo6NxACmCJM&(1ic4ee5GBQxlT9Ukv&9fvIz!`XVFc0gh+4miKBMc-Z z6zY1qfh(qtsZi3<((4f&*o>T*+pXj z2UTF_PD5R!i4wX?z0P7cg+Z;x;Fgk1>$Rl&IBb@kF_EmM9#9Kl3Bdn=VFBm-MK-pP4QWq{hM%BWfz8>X{%^G*&yPCdSd_92l2*1N0bPQ;Ld^ z&zjQ3!7Thc2oq;HifEwUojDBts(GhTkr8ZeA{aReBg|m$9LpogRu66|p_F*^`jh#b z%oA3KHHJ=w4<%SB9LkkrqGz1GsB<ZdN;4AfGFyX|PL<8%E_t(U;O)gw-9UKtY5lQ}{aq>7qe32DgZ+ z=ssogu-1-XL5^(AeCx;*F6p5(G)H6ZEry}3Wjw1x0h`U)BY|5C0x zSj0ls(1Wp(ei_M}TpK<@d?PYxz_QWJAK`SGowd!*InZ0*74A!fV<2^|Ig;rV zZrE3Yg?D`Cu0OuwW6BV#J4B(DsXQMwQPsQ}OtMetT}9dC5j8=+MT~PGnbP~Gb}~jh z@Hqf&W$rpo=9r>LQ;9MZrE*8%6@o$PMTwielPHY2c5Rd88N&``^(P+Um6IL-DAkvU^ zK-KCdUzV;ARWR|?yLE$TT=I^1ze1(J(DMg|RfdV5MLGBbX^=cbC`h(Ah%`qWDGxML zDIJguG?mfT)g=QpGIC2}MLI{w;>IOJ4d!Z#EIb0cqa{4A0fX+=%e~7&%JR#u2#eVjKfI!Dk(8 zPfES<^?>ElB&JDdI3?ww8C}2dk&Sk)7Lc|0)dmb%4X))jG6F?WUT6&CQYsL{&XmtO zRq}M?!+@3?iNgjMl8TIe`HYLe0$2qpcOm{uTwwb*xalUh{kpSU)$;d7y1S!c*&%br zqZAb3YKwRg<-rZnZX)hQm84izU;plDD2nMrm@-foVZL+U$&Z#JLC)MUm;;ep0^lTay6XyutpOLSNeIqY{kHOFX7$cDkt zf{p9e1RK|7LMhj;u`r5Aap(F12d?{fCkv@^#UW&sSU!MOTjtL4bro6u&{eI=X9|39$rEt?jc@q_Jen>NSqA=3EeZU>HwR0ob* z6Kou}CfGPG6G}OL_p~^^$bsW?6XPlz6@>6EnM`Ie>wCn45*zSGio1A892{H3s<2E+yWHVCw0vU|LjNft;<{s=L=c=6wvoD#!Ao4sn zXTsvVY^T_EdbBL8TI)tL9GbCohOd30;2`~$wE+D}KUlo0g0#+-C&jPL-bE)kqf>lo=kTsQi)MNA1!#Dh4Y}LOnc*oO8_2L&W zllzL4sa?A86Rt1t0^ygtPD4@6+R7S2QpV@12^ZXQKjK}(-Tk}!j9A=49@3%Yr4V8G zon9k5a+QiGgd#h>eXMQ-A#Hf-XIJyo`4TPU$AFC1OI6K}A)a`Zcs^6S>iRMtsfr6)o8fH+F7p zdFf5>9Q@Ni-8A%k{{wns3Rg*330~}gFh|@u1=~fe5b^gm9w$-mTXglD8`e$wSX~dR zA4_KP<4HvD`N$*6e4}96X<`D9LiRj{E&}&7ouqEYil4Ehi1#m_e5e|$3Wg*eY+Kt=Q6O#} zS+?lK8>8_pC%%#Xc46nECr2R8CV}9WWz!W10qP(S)&%bYVTJN85E80XAeI?TKcAc?-$G5!FBeR=$pxrGlUozKH@Owcdy`A3(kADoR5lPbkGq*) zVl;W3q4G+L`02y^H(wrbiFSm>ghqx9ZCF6UM>;JlgIl)-*9I>NE?XAd6wIoJgWc+A zdLo(W;mi43mUS#!*(R3uORSKo*;1xrVeC4AI2ni=Rt8rA(@L-MWttR+5EpsM7L#&r zwYS{*q<)=Ltj4t-xc)20J21R2)4-C7y^R+u(O&o(37pVLVL4LVfXpPz=jR zDpc?h?Xvr>Sh)JST{rDHZSm`&JE)BS*sWfg+%*}DC$mM-0^bh>X*9}*FBfa9E=Ds* zMByv^!nyZ~xN^b=1eh2;n>9hjxN7h``p`nTp6KP5qXLXi`dAns!3d9iXdyub)Szym z40P9v1n+&0phQ4f3F9M8PIuWoVpA8+f-bxYivDt4xPbHSstUsY z&`*7r-THTjX6;EoeE0`X_TNi9@F4uP(Qwa6ll@OoLB~p1n;tMh4L=@ z63Uc)s?Y75?GNZ8OONj2ZJ>O(M9#Pf9zZ}g79Qx2iD(GTtS&bs&SwZx{j$o^rWYkl zkSOaD{6+}Z)3V(1$gsd))zE?_l%YqC*YXNtAqYuwS+8-;%O8DX&9>S{mu~$;YiiR@ z1R0%sjW2Pc2*tC!lI6X@H&HB2%s24#szmC&fyKdd88cq@!c~K3?0P-&iKbspeEz(? zf2$(?)QXQ2u_wdif0wZF%h#tX_5##F?5zpj#oh|#UF;>4lh}V$^9))mRakP-mWB0FS?hQxXji=yV)w;)Z6quH1EMm6- zZx~OIdS+V6MXSn*S=%tVaVUwi9B_^UkgRlP(azW|nHM-tuOL-?P_3~GU8e!b?`fyK z77k*`XB365C=9byLN;Aysf29$w*2I|zSiI8_34v(sMcz?!G=Y(I0jR(>ai#>rHXdJ z{tsdln$Hy2X^0)cUWlgW^F`hlztIetbx2!fz8bTt)@{yaO>l%qE!C4N2FQ>bAFz3v z_V?0L>>al2ko|xH?6JmNA$_n3!JM(e@_iT)Zq}9mha__zh5A0_-#h|P9Nr^$Qvp-q-rY{b%YDyJQ-} zcms>s){T6_J%Uz{g^9d|_8DTdpYKQ!2Nqx_5hl^G1%IL3iNw{k#Ed(NeaXgSPnvB| zSH8ZLtWVb5r8z4LyMuj&um{H4&r*rhg?E}dq);!bv01`d#UvlLXY5Icb|wLZxpOlQ z;^YQesEnCv4&|FKQ7(`uF<1}vhOy}*KHM7;gJ>=&8k=dxf1p8j=!H8&@qus*TW83L zjynCw(Z>FsTYmGgh0%Rw7uF1o`a908+>{yYCqXUYUWiZ{I&58p$?C^6W zd~awEsym1PhoOqtd~2E&8H%w3H%nl|_Cmw){=ryR*b44mC4M?gocG0ctU5{Yu2^Is z5e?f&a$Uc>GZq@brZ1fGVsyrK)H5Z)(f+Ow0s@w*3Jc1^g3%ndcB*#3g%U6p7S$Z? z9PGowaw~>YOu^E-PT^zNG3m8SM0&%+Lli%-P|kH+->e`OfMlE`vMCPT8}5mOqun-8%QiFWA?=0M_e7%5b}Ox}CPccFSSAIR z*^WvV>RpjoVlWhq3{3+q+^}>(o22u%O3}`b#D^o>`!LNljOb3J4}0_Mx@u82xi?MH zB}dHu9l2sYjeX+QN;-G^zWEZSA(X;NBt;Q?lub|tq_&IJLt13AO8&Yq4nLX>O*0ZI zv};@!?J86$B3#gv);sb@Y8u4NG{Df{LY1nNCmGjl02&)-r%~)|13Hea=abW6zim#; zTBJohN^G$Rfm5`HIShbjFKcTr6i3@JZHB$K?IL&x&uAc&*Z~dS-fu0$xvjx6k_Sdd zu>|*e zDVk!Deh>Xlrf_l)?QcBIIsarft+ipa=aNe2u4B=>CC!X(aX!_f&Y z*sKTIxzlH!Cx^kk3r4>8N-x?iBbLSCxI9^v78i^nBQ2dnD@_?wEymOt{Gqyr7ryYt zh5Nr*!+bs1ga-32`U#wGr;WpsU_*auDu2;75;n+!AJ;kb3*zCs4f7fK^pr|VR(&6| z-rT4$rGuWnA5RApJ!>}7%?IFMkR1+*HgCJMkV?|Lj_+10EF#G!);p~?H(76Px8B@h zy}3ib;fE=C9e4700aa22bg=5v*r2tl+EARs>U*>7C&=-|odSW&K*WMz+eg?(fAQ4% zd-ah>4VumCzDyI1S&>?Y?NS(hYPo}IHm>Fozrkop!`PEL>UMr$4Yuu*ONEnJzyzKV z@rZf*EIGuO6QfZ@Qws5L6pm<+=6i>Qo6=$#FRu=+I6KvT_C)*HdsnOshT=h6n)Sw5 z|F@d|q5@PwM8Gdog6jF07@u#h{v zKX_>_oefsVus_(}7nFt3N)?p8mEYpWN-Dqscz-aL)nPd01Vd{XB?#%iQ=yrhW(Ad1 z-73GSFobmqs*YNc6WkgM%2CW?SW;o@C%M)3J%%XgqF{dvu3WHlZ_r?7Fj*X>p%$j< zaYB(fQpWg;Tl>h3AIA|gk9_Os!FhB3A#pt1hat3xLb*t;5rrE0`PFax;OgVuy4=!{ zT&}*mCFY|eF{Rcuo{9rN(5|DCIQS1CAsn`q&W;xN;cPT^EgxxPGXN}^%FmHQ*wg|m z17sdfiRdy5l*{ZL!cyf&Va+l~s|7^AfiG?3x5>b|de zgKw7biT(uEW)XCpWA_4XaLqSuuFdS~j}G?s$q98nUGMuUR_zc0PK48Bs_!4*Hkbhs zM(tHI&60J_8Kl>GN6;Y}JfIKAd1!{{s>rJ!3A0Uv)_E_73sxDS_1+OkLK}&hGJ-^8 zzTm`IdS)TB!FwsrWcs}$(D^AvL9{GyXh=f6cq&MST5WNQK615knILgcvYLy-dkOhm z(plFCB1c|wjIRSiKgB0wp@^91FJE+q!f1zRg>_=qbs&sc*NN5Ca#OV9XS-|H71TCw#PS3i11--{LI>uc%>$=i8J>OsC92hAsAElAB; zAQG3>>B^S?b&xM>f_M3{LV1@j3FRbTt={BI`2yEU>H>p?eEqc-K8dv^PHT#6h6*&H z67V``%Pd!&N@nz3yMHkB_$|-;a$D!hUAOy?*t1K%_VNou-6MZnIggW^^GkHPaxOp}>vgFA3L;Ja|5H0S<+|*F0QC!9?qCiYE62#O5v-O$+OhE9~c7osy zT9RP4nJ8hL()ABlN9nBL8If|v4u)(c>((WxgF*|OmL{GyI`0ZC z%PJL)xALmWi>q+VaS)Cf#>A70JUC5L>7^34Dr}xD7mZWxqG34$U<2VJTxEU0bqzbu z+Sj`OvhOXu?8}N8&Hoi7;|`Jxez|qJk|97HB*U8E-PBv5yi10JDwT{|^){k!SIL-b zNQUUc>13>#hNYlMO+z{wX@3AW7jiEg?1g>))5zKsJacQ1Hr`@uop@L|Z#{P2Ic%D9 zwKxocIR5FWC{`P(>dsdQ^X0&x%5 z=s%Bp@B_m6TeBzxEJet=$;^+Jh+&g(DC#MUQu2Z!2Yj`ip}ua>mZsC=^0JZAtoqwV zP=6!b(xGobGyEg#0HGw@@&f0!>>I!G74Xv*ZgJlpaoc;Z-}R}wRO9|*FZ3^eBYJ10 zal#LYJbSpMMJH1E9@tVxe-=tgh6q+7^>9mLkoVh2*CZ9&hF8^O1*U{BnPorCd21nYmgxmfWFFW@iT7gzJoz#%R#O;_Co zsDrv&6TGXt70SE1ODI#_Q6Cw2dC8)J-U2T(4Aqwd2J|Sl$v+*VY}Vgk;?C=&d4$%O z2tA`+5J9(H5O~ku$bb4hI@m}NOrn~sTD`{ zs--WyvAi%OL}ee*bU6Hv~i{WV^|L-elt8@*2l?>HHx zoiSa>(Q&?B-ts~dqGO$xSLw{LNQn1&-hNZ8Bs2Z`>qDsI4Jf&Y31pS?oSxvQw%O(r zS&)Y}^27}+vYhF@WP}PoA9Kn2D@aT!(AWjl#YaC;*#zTs*mj&7y$0Ke$;%&7uVMOk zFQDscNRt6rQ~6xmr(Zt$Qn+pDq5u8U=U;szAN_fSE~^$h_xap~uqDzGnS<#@!-mP= z9^6-RL7U;h%qNdHlRJr-3{Nuy zwR6yT;!-os4oZTScTlzj&mEKv%5w*$LwTItva6H>H)|u<5x|*=b~?XmJ2{K41KxUZ z8aQtsJ)C6>g$;L&J6-(Lgc_1*%TT!Tp{h@>n7H8=C*FDHTO+^wWA=e=F1`SD*#5sw zkC^ajrN1y@QoE7_hF{K_uD}RT2Z6CBco!Hely`xVP^L%2UC7$Aqz2I!*)#YOrWugW zOe@f2SOMwDzzUd)q;*t;#~7Q~&oG{=d%;HAZ@1esOWRjI-{te~3k+RffAqEZtT(;q zisN08%5JW`?N7p#Vr_`zfM2#uR}KWIgB(~Byvu0;# zf{tfeLXfT~1eH%tz4oHS87scrG%=^{?w4M_Wd}T|N~7YFZ!W0%d<{~qm2m%V* z$caDJxfEN1cOejz2z1_sKth!Yf!=oXP4u~U8?zjQz_KSrM`jlUBc^q&Ev8ldH6pZ7 z$b7{+`P2@Mi61Z2;;Z2>)^>d%2DU!qod|6^WBL}ziF`Ukr^hD+RvL9G78G-E|RUl0L@5e>O!D;ha!lTOEBj z>`)-03PmhVq#Y#YR#$URYFU+s)cNw~2?SQ~tpN2GH>_R1cHQXMhOzV4 ztLrZ~Z~eI=YdhABotH|g=Z&4OZd`Zn`5o&wrp`;QS4UGLYt_;9$>hj}^BY*L!s90G z#j$p=??ntkitTFl0G0r>(}CW2!Iz{pS5WBnuJZVVVYzQhsq)r$i38i%GRDT<%?dV? z8;EE(mx34Z84rxb?~#J; z)4}BWEwn)TLWR||tlXuD*UdDt8g@zmN3$)M0pIe}079$v^y~BhYY@NA2r$3+6%4Q$ z;@7eOYZSlE3a}>e>zn`!h+i!MHdFj+4dBi3vkBko0Jh!mUu^+4SN!S-AXGk2VYBIk zba8HVf)0;>IE>=Gz_|(RNyH>`T2oj@i`cwDJAc~g90B*+mAe{I=6M0Oft|0gMymDz zwPaCY&83(`-U|Y3laZIVQISw=39zm7*iR_H%A%iLq!_+h6AQ7f2G)tzH@5r zg~4XLNn2s($O8G!l>U)Rv4eE;O3PLh`KWS!7s;Qq%b^I(s4GER;vx^nmW(q&+ z1zm>nkdpXWKNw&A6u{4hQ3zkED^3?{U`d6~%y{9GF8pXf^$>sMIfQFLOT>Zy5R>rK zsEV@=a@k@78-wzj8;a-+#)nBX{cIdewe3%AV3)!ynR&(5qRz>51{;kVSr5wu*aXXh z1c(C94KhO5(;rHhS0ca0N#8A@62&4l8L0DA|!5*62SqP)_I zODg>AYA8!^P0-J-g)w$sV?x?^U4XrdU5~s)4V{mT2YQ9d2-@st@4?w$oBZs35MGPO z-++dU=qp%+cDx@aZu!|wsI*XlMz)7#8rZEc`DXjd4GxX$7WTmayPe&^t%KgOFs+dW zc9$*@w8ppHb_A@SeHi3)G_pI{p$7I*FyBPYPxz;ldjjlUYVdk-RIHzUTw!(m)V)Tw zpJj--4^aC&Skf#G=0z|@Zx%m$81{nBQA6AnM|Dub(*gE5 z0+m&Cu(A@Of?NBH)mBy@>|jvjRh?#@8LOW7$bh`Te{GW=V? zmb2CDEaX2Mz1TTyGoEbYM4ijlNz&GXv|3=A)4J+7Ti?3+INR8|<~ZAImekDC*MVW{ z(PN*7YHk1wdPRxhlVB-)OLnAnRr7_PW!rr08P-EpT-Ch8ygd!KJI&iAxQ&{(OL5z0 z-kyou0rPe_Ze!-{*|<%Zw<}Ci&jBkKyAUK^1a@p=YtXrFVV&$^*2RXBC+FduU3`<&8y+JpFh5~=jTvTpWKaZk_O z{uti7#NnPZ^Rd?;O-u0CgTE`y=auj%vTWsf!*Wlu%Z{_j=BZ=s@?-31@BPYaGJUZv{VJpb=rr-r$ow47+c=6hK5o0-4co*Z=p^R%vT=xJnmq^y=Q+G2?s-;#SQgpq z@HdvQDJ96>2Jw8m5`hhP*uHyHZr#GH?I`Xm4{EycDx6;~U zWm-#5rlqw2sGzka$f30od8yWZwyM_3996Zp98;;*+Avkt+W!TueHL2#Jhb-9(Auv< zYrlcJ{{yZ44z%|B(ApQEwLgZ|{sdb4GPL$*(Ar->Ykvu?{WY}q6=?16p;fO!YhQ=f z{sCJ12DJ81zNn)3#uT3~t4bY@HHrdzD8xQZ-p}C zYgOLjizvg;+EHk23R*i3txZE~C!n=iXl(&nTZGmghSpwjvb2_h*LWqNb}}Q^wt)UA zJklRTF$;Jo9j}Y!ukGGkC9;p>28(#Ngkx+UDDaW5x2WSm7>zYsLJe}K!2@G+VaF}Yr zk00T6(<|3FfwR}JBI;t5zgQdZB}Wl8e=-PYLJ`hKOPEFQNUKT*J3E(Q9>gK|wb{Tv zlYZ6SN0*%OaF+S-I^*Fy{_tbS$qL59`R2o`jfY$cYI)B08xI$nIX_}NTx33c#CUj$ z`S67Ca51>xe2|671s>n@#sT(g1M{i8xF=CBg>RqWGI6^3@O)a{rhG!H&Zc@!=)yYg&%eATL z{mHc2ww*s58{LFS__jTbQhhBk3uvfbXPK=jqhQzll#+|tU3?}Wn4>U(tFt4WUeQbiECY)t|ybx z)GS5JMW-ev;@Km8>S07z_pm18(XOO6PS3Wf@r0TUrV~04wYLi2xL;)}IAyh@YhhdRD8o%%sk(?(n#p?#oaO z#*R#?5mqx2A3d-?i(*JAQ1zD^&qN{dXM34H0daGxmeW}CUe}bi4^qw$mAEI=vG`O< zi)u$ws>aSJLCB+ltTLf$@nlMhGfUh>^^7hr#YIE}pN6qab|S9z#7DJE_K1ma6nS!j z>swUSG*&MZV@gY=phqOPpOj<@HOmzu!s?(L8Ue>vPPG&9WLjocW2MA0OQk#wt(2TA z(;NsgtFtXY+Zj(yq0G*5%`LCieiNOtRyjm%vP#er>}6W@CR$}ut4k*}U?5zkRGSl} zO-S}6tgJ?g&spqcl{rEOfOTdmVCnd%$_WkUIoZpqHFaV#71xMIdnq2mWW^)}>bgQB z#g~OL*RGqgVAho`m|ZrV<~f_5WbC&$!+6ibpMt+S#(WF-FWj7pzq0Lk62%XGH;MfuH|%x2JlX-PHL8=urzYYE~3Yjn^DvZ^+fP4l8g1J~d>WpAnT^+6xaFyYuU|n=F=|OH7^CdXj3& zqC^Yam1x#TCUXG&iUSe#kecdbb?PBlXx=A?B`4HQRzHpc&8Cv+12J@PRIQWEGM^x5 z51SA5(*XC;aq5WlA5ybp(8CCu7f+9lXR_2;GgXW7IXA)<*pe*>t~aINm@M7M@@P<- zxh5sa@7>geZ26Y$Kn;*6?S~Y6k&*cz&s~A&3ycWVvgQTvWpgdTS(FTVcQ6lYO4;{q zdL<0RB^B~|iot789aEvCqxtDY*hxm5SSFLwl9PE7p(>0Rc7rK1T%XK!LR${-reG?S z(olW8doGL>n5ywKgsCwhLX>1X_!9^&@2e)`8nVkx34-Uy+X8`VG@v+`xOgguUW|v< zn?Nt3iv}vo&YFR`NE0P=ms*`gZVH23jiFmgnAUSi_fgm^d%=X$nz~=jqF^`y88wZ~ zv6LL|k(cDCyq}fK4J5`w6C-LOq3V$UDjKUDP-Ek0a`unQxB+^M zUQ>dSkk4w9xuG=rcK{PFawJhjzdJJ+{FUmRMnpsub1l)xQ5bPX@y@n9lEvzwTS_b? zA3gtMKBp#$D`1VGQ#QUo8=oB4*b3KT-9AXl%%hTklPIP1XeNPSqGUyndh*bg&4>Y; z%)>1GUS^=(HARk#LCHZ%KL_?&OO6(zudyINrm?nk8au5#^Aj@gqp=O%Ss7HE9U5}i zUVx=dEKu-M+!Q>_jBe!uAeROP;dDAd11wY9|X!W^zdy>{7=Kqw<_+OX)7mDh`vQAk36${2c+h zXi$y8ExamvpE7<}YlpKSL$+p~b!3Vz>7gVvM`P|ahM}!xJgZZIo2|1)fLjCsF!)rt z0Q6vEgq0mok4U_hPh=8YN1ZQBT`Bfl!^S(N9Mi+W+Px!*&!B8X^3-1gK$NKSq zK=OC(7L&1S%PRl}_BDO*>WNN2jZehzfR9h80G{|z*_$7nxVqiPeA`(7U7Z}-`u&|r zEw`Q3PGpR`>B%qr;BAegN3S{b^#d0uRz$R7f0HrtHVH-*MB`<@4GSzLSbOV{~m1QhIG40#5(IcB_0(f9ghQ}*58`N;2o z34VKYev^EtMDe{^Nis@kQq68qEkG?Cn*;HL-YB(`1>)Y$0jMZ*S8TGuT)M5=-wRr60A`2#;O1HKTl}lYB z-k4A-unH|)Agz!Gw*+B}lSmuHnR4$krP2XppsI|zE{zQ2$cQa1l%ct3 z4cmAIlzSFjIs1k+Q$AMF!z#z(smbv;+EcD?5#}3(B|cen$EgA3Et+UXsdJ}pg8ywS zyMKg7*O+f_4?KEf{ElS4NH{3|gn}hgG|8KR9aPK|8Z|CKQbAWMXz8e+&Lf0zYkje4 z;x$CZgr~8G($JIjr$Eg2E6%ocrMhx#@ zN%>@q?MeP1Wi4pAzKPi*8fB88(3l4Fh{Vvr(1cQcYRhoLpdq`;?VwGJKu)9=9K&#( z5`?g`V+Mnu1S#%pjs?52cHkpDtQp>CU+I;7H&qm_n@^cX;1 z?`F+-Q?8FGYy$yN&Ne`op?@GdEj(24cQxIdf1v}&iFsfDt{JGb+0QZoQ4waoWCG@7 zbbKm(0A{G8l=H{r(nTbwv~rSIV;(&CCT+~@1lDmw#%GQ!o{R?b>7W`<86n)(&7Fes zaY2jE?pi$PLePob|MbJ;j=P3<9|k3$py*sH+M-IP;GCCPe!fnTeJTa%Ch$#9R%ooe z3xf!OGF&A>!rSNB$0ZX;rY7U+;?gtmlCD|2%`by5@>LL&z_xt|Ab_h8I}+Lnm3e0v+4dTWiTrS3C$$STZPpp ziI`tLK2ul;QU_RB1H8k^O646^k}4lo9~U+6*knY^gj$U<4KlbL(ypSX&eVcWpef>b!6N{}1ea z`^NdFzPRW-kiDL{?-HU3igJ(@BIrP;g^&XetB)C zND!nBNU#QYM}n2gI}#*SJ`!I0vyiaR0SN)>X?wwe_cb&$&IB~@;fpKX96p__I-xJM zgKNk5y;CgGa-TM!AxJwVW?y^<&(u1%&WWXqzm;amlA{F^H05qGquW20Oz~B8G|fQ2 zrMT|iNG@&=sx+s>A$`2*{j!?!%oVfxdNw>udAuFb>8dsI%TV6$@z>r zRpw!6QA>kOzP6_I?4qXih8sIKH2?Ub_YD2lzuvUx+5S)Kl_~6otl|M-+&qogltmC- zTpDL+NhN8aCA9^3wxl*H&z4lDl3CYBY)YeEBJ?fQikCZXsj|$`*`j=_S*Ee--tOq& za94kK$Y4W6=tsksM8B@mn7?Z%HXI9GXdkA}HmZ3alA~d|QnZ>k5If>lFhslR<%X9p zOU%~mS!)hwyer4fPk6n3R>s`OzvB;=e zihZ|`gC{#9E#6Av@=Nzjt5=XZRIfF_d-YnWyjQQJ%CBCo7<%2fR`1D1^_KC{y9`=f z6^RXpyN83~fugaR&70F$VRrt~r5g((>8a=lfPybuwQN~OTSo^yDvE_Oq2c4eg6WFk z*4#2%y}E;VJA&cnk);b>zA+L#_wjEfzn$Iw(1`)V2+7MY!!regAawwPHNZO;RZ0w>kaqqj13OQwuSn!0yo?>d_iot!I5eQYLAJyW$x8| zKC1iqLe;lccX2PtdoNn_#(lRBd}(s%ip=Nk4`G^(Ja70=@^4x9X?2XkFNbDY-GbDi zx~&1;tJ_NDy}Bh;esv!*Do2!$yEAODQRUT!x|g-LH;Wq|mXGk&H5X_{Xh38{S=fg4 zSG;@QyrOCI=BCw6=Qk}~+O)CBun+YTH-jN;%K~H!(yEn+xT2<13hRrdkX8>jb*rPv ziFm4q@3(1Q+Oc#+o7j6JxdOMv(_hiF60)u^ipevEHvz*Hf5M03ZVthRI-nK|pH+Nt zf7dHodU*7?cXS+GcH7s!AO3|M!%_yw#LH6AbgC$uozhBD-}K@3zOscIA>rDLP^kGKb~Og z8k(qE;g(H4*3}maigaz0zm@$1!3%~kETH-;=(peT#ocHA{Dx~<8gF{~;pdiY0lo9M z`!SA{cijEvHS5eU20 zi{m?|nxgS^PH5V)2TKN!A5sy?3U{>XMfpeL@)Z%{ zd2UgX3M%W|qAkFCJ0~O&?7X*glFGD4z@n?p7=9O8F@#myMP`jFqv5`-kq|c@U*YA3 z3wXOO1>?M}E48VV>0?>BQ{LC#Cz0;n_%6-2j?~v)O50PKmZFj3HG5e(a550w8XE2! z>g^1PO-q*{Vl_2mO_{N#rMm1ACj5)fgXVRouz!PK&o952DeMKQ1MIB<-eGU0@(z1R zWx}5F^Fvn_bN___sxHb=50({-JeC`9n)Kf2t+1aXZ|2j_ri6mJ3Ct z6X2OFwExc`S!y4vEauaL{kQb>T!yDdU$|oE)SYjJKUMqc#8d0~{<8%9NzUKm!cG9} zeG9=zT;|LW_L8&^_O<}eu(wfphP_VZ0DIpY9g9?8MPN_GX!_dMB9?~J=uVzwb|+`xhL^kV0Wf^X4d384b+U(Ht5z?TUw5(vhp_==P|angvZHEm z5<8^R`(v0#pjEE4e-v){lKa-VGaQT2W@8Qp3kA&uTa>@K;IyB%6MNyLZ{9SI5ZFuS zQJDK9TS`qSV2VI&ri489t=l9_(Y+WO-1*Alb=;6qad1k_9x1&s^#Y0psp_zgl$UlV z4#W^U^RZj3E;pJ@PGYCNW}f4Kyc$LaqbGvTmh36?nShHaHot59;XyRm7JhE&vl}Wx;*W)FUkRye9lhjio!4tB(Ui+ z4d4~jOfHSnJ=(a10*aHlEV5~vTN2Ctk8S0Qitt{5_iOwo!5c_C`P}DO46z0y&Jcv_P zX!Shif(6x1$#TAAiQ##$Hx$G9P{X~!0W0TOrpE^wWT$T29*hoz2C>bJI?+)l!CX;b zJyDcLKOZwj6g~;v@ zTpETdVxzoiR;2UAPTU}g;oA!iNBf5cyFylS_bl;~oT9ufwsX}*igpc#2V#+sO(fU# z^ar~`gI4DAO+fG#Gm@b*pX@x042F6Kuv;{QeM)-6 zgZU*hgV-LHazbQn6uLLu6AneXZKRehq0~a!6RqqCN1*N2q+Csi>{4PO61vQGRywG6 zh6iIq!AN+|4A`O@mdt8XbXHzI+j-&WaCmDUX4Qt_-wF3&AFW+iEy^ahluEheh}pj_ zlbcN9Ob2Twi!}ULzQoOFRWN~5gL1;%$Xm*yeFdGQyo;7XTB@u>5)~mFR5lZts$(j& zYutdgF!;q%QA9>+lX^oQPRu~KSq2#@T&j|Lda~de3_@d*`wWt;H>jgHCSqzP#c!K{ zvnFYQN1iPfPH*z|Foywf{nEDfY;Lq2GicZ+-!9yT=oStHW80wNTl=kv6sd(xJPxB{ zlLCAqBcQQGSg}Z_+_f2lB<#dbz^k(#5YxkO77jm20|$5EC`fr4WiB%YDs3u}%(NwF zQbqQA=yyDUQ@&_h^2yHer_xES4Wm7mP&zYl8$Xf^=N*=a$9K%RN5j54ake6kIdS1; zJ$%w#KJ)BH4DMYx@(qD{(ryv4X%U+U@^Ss8C z4tn}+JROSlv~HlAe?|v`>~K)jdE3R=M4V=FeE(vl{jT-q2iBYKSZ`jm-h9t`^L_n> zAAII@+{yg~$QeFzU8S*6aAm2XIH%S32-;73|PQrhK(UOL-CpFaV{BS88u|ZuboT3D05|0Rf#N54> z7-Gzc(Ws&+*=Q(&j%X9j_YRA0O0#7OcvaK#GZO7*Othb|d-;l{V6@2=X1y`St*iJi z8j!9+I4xCL<+Msgf2c1(sHv{5Zt5BA?`>*s-j^94o=_8XzD^>C@v$5fW;2KPHC>!Z zrkjdH*w@tG*CZ38g)vBdGrz@;6_kJj@xG=^TBqTX6Adktlq978PKl;6nw3;$b+i1Y z#NgJ+syb^aPSfV5COL}v4c2ei+DT#Ae*-V*f~NjKbmf{lcQ+Y@*%Z%>(ohRi^*Bwe zI;*y2?>4ZxN2jeBvqgj5CB8^=ON7`6!4@;)0x09gT&0p$%YIdf|UTT{y6mGsRrHsJo^(bk`Qre1$p6l3l&#)iirypBg5) zTnBsP?`gA@s)I~&!jPKXjIbA2Zzl>8&&n#0EPeZV@^gEGC=)FC9vY<84>XYB6Y6EN zz0o&F`dEJq%fyH}%DHNea>7?ipi4lmIKF%WOVk858Tk53FMJYfO`H}!*$fqALMG7bpoLGaX7rj}FYbBx zmZx9c(z#;ihknq#wU`;bh8uX&xKhiWtV@AsW=jPO3YYL+GxXI*ZaDVU#sB!q3wydp z{<=87g)qr4*9(j2-Hr-U2RmvF@Q!mUm3N#=Dkq#@?+xdcHBYBap){9Vb>Q?>LcECQgJ&zE5Dp@i-j! z4PW&JR%Dxt6P6n31m)4>WIRP@;uuaK-ua?+$9^n3-e@jQE^skPz!G|jYzS@C0i(>3 zJ=u=pfGNH!?8?{o{H*?EzyHe@*I&DIU;oWEz;v7tz&uNU;g_$@6flC+0Wj78?|`vV zc?XQ7$_LC>WgYP^-e$;pzyqo`a{=XS2Y^%?6JRcwaGEaDQ=JhsPO?M8vfF<>@grUZ z+ewaAZ9jc)%f5r(TXOL0iW=cMV3?8`**M75hy^*0nD|AyPALvMBsw~uw8Vt4zLpTSF8x_!R!4U{K*&E|$c_iY-tz3^t^C|FS(5896ROy5yr-!fp>I#B-aZtKg|QB)o5PATad-uI`e`RCnY@IDpDq zd3Hq&cyj<%8>%liYoJB3O+xA%CDT=yK=e9!AEvb~RO({#zR7Jj2Hp*7dkNNCdiNGK zbVTBp9KlRvCLPLVGuasCUQXz%w+MciDs+0U76rB79BVcIC0Ul23UQSA29_rGzanL899=US7X7 z+kz19^UeJxtYl&O^;Zs2%IlGG4inibFLQc=L)q%hCo&-qZ}Ey6Tx2>keK8Rwem3T` z_16}eDA3qBrQxF=FK&`?IcQywvDe*bHP{ABqJAG*USag_%FjU4Rh1+I&|3U_=OoWO~0?hll>dIVICl-(M`qABL#+b$EuJKM6 zBexpIv}Gu~mSiF%7Ibx^&$X48z7egv=(@{}cZI#8-~?<) zF29}-!7tZ}D)j7}m!uAe5Ikp!2rHF$L`bT9L|m&^o~X9+D_wCAFmND;wZMVC6yInS zYWax{t(Lv`h$U9v>xq$$>t0n>3Mm&BMM`nk*%Q&xyB_I&_m?jCr#)5wS|9x8UlS?! z5mNZ&o|z&=kUAj68sNRLu~K%XG){!M_&WjtzdSip5C~ES5Lg4egTPAV9R!jp9|TY8 zmFEcrbq*k~?2^%W*@0kqx30E%w@SZYhn6n&WoY3&4N|Fh?a)Q><8^#|eI7>LuCI#0 zW^BBmqiy@3zA1BJGMS=-_2YsoKl~cw*3oPx2Vc!d7dF7k2*{7`T#OVFh>X>ug&~dD zS(GML1)+EmC$D(l59L+_W^6@Z(_~?t1F~$hV=oSSCP=7k4$CEJPm8(v*4!mqkfmBl zMFCVbIGsy>WLa!GN1Wzu^5N2*%l85J_I5t-`hx$c^v7P3%cL8>{p=qfdkQ7Dmi=uN z^C@h*;bR|O*DjSYkvSS$9@EF|uCmNOWvibI$14$jFAX zH>^vj8{+H7&RRdVc69yNsM@h^?3^lAu5b@Z(G9|Mh&SF8C}quL6?!?eJkViS?j%!~ z`|4=P0~_m7##ZA^3bwZ!jA(zEg4cK&50d)I^Ke383ml%KgjI!|;t*oYO(|@VL$L59 zE3DBBvz~9L;MJgp6vloi(JGbYjNa(!e$vvXvYFFEbjBpNmST8 z{g4N)Z*q;QQsRZ%mh|++@+joWb7{%;c?v6QUa?aVFJh`;Wo%)9&13Vc(YHJ)04HlD z{W>MUs>H8T1I#aeH3e9;__Z{^YQ(S81FTm3Iy1lm;#YHk%@V&_0<4bJ6TejfYy{%J z+5&8j_|*}>*mSPK>LXb4B3`E%qvI?9hf%y$JTrk^l9+N%Y6|OU7TZZ^gK9gSY~X&o zVrLD~To+*L+1U!Kp==LOP39EVkk3iPJtx368gY3Y<%q?(0k)YQ`-ugLGUsRKD@I?f zmIYZ?73)N8^6fCXbOF}QLMZ0_Dnvh1Cdl{7^p9MOJ*}HoST@JVM^$VqvI+B3O8soA z<7Z*2NT`gT?NDsnJN&E{av91)O5$hzC;;P;p&fp90cyc`F4V%$qKf^zPd^({EdC2W z+l3S@T2RGyd$S;v1zyH}wil%-x3Kux+aN`r0{Gc565)%7#ffKCEUxf58ZYIfgC7;B z9>O^u+)&JK4m*@TU=o@hRdM=4CY`HdV^Dr`ixa*7{4hb&&&E-xwjGmI>|&TDGp^X| z)H#(*Ve4}Z>tU$?n_y{(061_*81MC`hE#l@hG(NU6kgTl5 zYH+^}Z-Ut9XYU7iEs(zf6&co>7NH$~gEPSV>?UMds6Y+7kfo~FtuXm!{mLyDHS8Al z!2tUZ`!Kf-ddQ*)h*FSn+~j8uz+TWffqwQ7v;qElH6#tg9Wo#8Y9r4dVD|RN^geP0LP-n3%i)@RJJ)F?L(|9U{(| z#Qt%1`|gI19%mm%lvd8-j$`Z-BJaHX*dqv8QNUb20rQ)QO~XAXbVO`F#_oNZA(c-x z+^^?@WqFJT^J571Lyxo1>^{yu3r^cha%y(tRI77Z^)SHdg&Gc3)XWm&*7$KFJLV=KMCLGeSqlwzFXO6d=ImSeV=EK z_#S6Zu+Kr7^Vy<5u)C|+=PQ=1YHm(fvE-kieq~im!MmA0PjF9Gu}pRI95l_DviT!) z6~9kArRKC#5RZM~|1|f1mF6BR&|G>lBh3Xt5zWnG4$YO!^ELO2B{f&ZD5<%Hobol- z#;LgGeg&HQ3^e!a(A;l8bH9bV=b*XYf#!Y}n)?DY_eE&#kD$3PL34is&HX7f_f=@_ zYtY`l>3s3-*-@{_G!v2-%U!L z?^dP3_pmb8_jzT3?{Q_xiPGH1{!erNS84A5j5hc2lA0@Hl+@fpPWhT^<5X00m1a16 zTiD%78@pF&$Ix#Ldq!Eyo>exmHaiTPr9NBm!p>`s@*f!_>Lhki%LNfE|x$%!5`4;J{)v;`dc72F}Cu?CADM2^9yX{N3G$40v7#9UhbQ{%SGe#`ezmA^tl@)fXL z)CzkXz8d^hgF}@))K9l&Xf?9wd=8LxGD9479HLzC!%=LRtC_&ba9Ag`L#1~MF`vlM zHba0~B;kDUg_#8Rx~g>Sv~wEfF(HEcH3s)t^sAf>LN9;9cvxpX{Ac6gT>kJ^B;)1A z!+GYzj~Nd+3d(uRFB%UU&6v*_4;PpZ%`#nRJXH8>EU%x|P)8qu)b{yC=+9hYQ{u^uvY^wkO diff --git a/rpt_base/Inventory.jrxml b/rpt_base/Inventory.jrxml index e15c13778c..1a887aa6d8 100644 --- a/rpt_base/Inventory.jrxml +++ b/rpt_base/Inventory.jrxml @@ -130,16 +130,10 @@ - + - - - - - - - - + + @@ -186,81 +180,45 @@ - - - - - - - - - - + + + + - - - - - - - - - - + + + + - - - - - - - - - - + + + + - - - - - - - - - - + + + + - - - - - - - - - - + + + + - + - - - - - - - - - - + + + + @@ -270,66 +228,65 @@ - + - + + - + + - + - + - + - + - + - - + + - - - - - + + + diff --git a/rpt_base/Inventory.properties b/rpt_base/Inventory.properties index 6ad2960d81..6202d31391 100644 --- a/rpt_base/Inventory.properties +++ b/rpt_base/Inventory.properties @@ -18,8 +18,8 @@ WardCode = Ward Code DueDate = Due Date -TheoryQuantity = Theory Quantity +TheoreticQuantity = Theoretic Quantity -RealQuantity = R. Quantity +RealQuantity = Real Quantity diff --git a/rpt_base/Inventory_en.properties b/rpt_base/Inventory_en.properties index 6ad2960d81..6202d31391 100644 --- a/rpt_base/Inventory_en.properties +++ b/rpt_base/Inventory_en.properties @@ -18,8 +18,8 @@ WardCode = Ward Code DueDate = Due Date -TheoryQuantity = Theory Quantity +TheoreticQuantity = Theoretic Quantity -RealQuantity = R. Quantity +RealQuantity = Real Quantity diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 6d203a7a2a..a9c3afcdc4 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -935,7 +935,7 @@ private JButton getPrintButton() { printButton.addActionListener(e -> { int printQtyReal = 0; - int response = MessageDialog.yesNo(this, "angal.inventory.askforrealquantityempty"); + int response = MessageDialog.yesNo(this, "angal.inventory.askforrealquantityempty.msg"); if (response == JOptionPane.YES_OPTION) { printQtyReal = 1; } diff --git a/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java b/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java index 5caa9443ff..5c8dda7918 100644 --- a/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java +++ b/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java @@ -1,6 +1,6 @@ /* * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2023 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) * * Open Hospital is a free and open source software for healthcare data management. * From 6155fc0895e754ff4b59c01665bd1af724bd5101 Mon Sep 17 00:00:00 2001 From: JantBogard Date: Tue, 12 Nov 2024 10:13:15 +0100 Subject: [PATCH 071/147] Applying suggestion for change --- rpt_base/Inventory.jasper | Bin 39869 -> 39863 bytes rpt_base/Inventory.jrxml | 10 +++++----- rpt_base/Inventory.properties | 4 ++-- rpt_base/Inventory_en.properties | 4 ++-- .../medicalinventory/gui/InventoryEdit.java | 6 +++--- .../GenericReportPharmaceuticalInventory.java | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/rpt_base/Inventory.jasper b/rpt_base/Inventory.jasper index 0416e0ffaa1ec6ec0da45f52393672c7d4d2063f..367887dabed9085922612b0438b5dcce6d6a562e 100644 GIT binary patch delta 318 zcmdnHooV}arVW!7IM{viOPuplQYSO2ifrDX5GKSPl$w|mSW>x}*O*rt&QbK+!opa% z`C3pR<7SVL9fG1FzKNN6!6o@csh)Xdsd+#~rKihg@w6=IxTB~3?b^q{z+l3#pPhk; zk--bDB0j}DIWaZW(8MSy(ZtNqFwNY;$k@QZ!on!oJk7wu&^XE1AlW=I+0-!EBFV_Y zEXgo2H96VL(!#{l(8R(b#ekiGWwK(M+GN(IM{uXTYvN>vbN;oaG2w7qb;oUf2TC2V JdD;whW&oBaXRH7K delta 320 zcmdnKooVlOrVW!7I61--i&C8PQ&K0Xifmr55GKSPSW+33nwYbh$Cy_d#+l6MBR+Yx z2mfX_zdjbmqRm%>3K=)MhU^p+7YiuL%uCKJNX!8lrjn%u_9ljm!;9 zEK*DpO;VFnk_=OmO%fB6%*@#tSQr^}CO>48nQYg@KAExU5zJ|uUo~+u!#TfN)0l9% TX>)1EZGHzzU9x$?40UDz0(oi; diff --git a/rpt_base/Inventory.jrxml b/rpt_base/Inventory.jrxml index 1a887aa6d8..6ad492fef2 100644 --- a/rpt_base/Inventory.jrxml +++ b/rpt_base/Inventory.jrxml @@ -25,7 +25,7 @@ - + @@ -34,7 +34,7 @@ FROM ((`oh_medicaldsrinventoryrow` join `oh_medicaldsrinventory` ON MINVTR_INVT_ID=MINVT_ID) join `oh_medicaldsr` on MINVTR_MDSR_ID=MDSR_ID) left join `oh_medicaldsrlot` on MINVTR_LT_ID_A=LT_ID_A - where MINVTR_INVT_ID = $P{inventoryId} ORDER BY MDSR_DESC asc]]> + where MINVTR_INVT_ID = $P{inventoryId} ORDER BY MDSR_DESC asc]]> @@ -135,7 +135,7 @@ - + @@ -199,7 +199,7 @@ - + @@ -282,7 +282,7 @@ - + diff --git a/rpt_base/Inventory.properties b/rpt_base/Inventory.properties index 6202d31391..32fe3f6bf9 100644 --- a/rpt_base/Inventory.properties +++ b/rpt_base/Inventory.properties @@ -10,11 +10,11 @@ Reference = Reference InventoryDate = Inventory Date -PrincipalWardInventory = PRINCIPAL WARD INVENTORY +MainStoreInventoryID = MAIN STORE INVENTORY ID Designation = Designation -WardCode = Ward Code +LotCode= Lot Code DueDate = Due Date diff --git a/rpt_base/Inventory_en.properties b/rpt_base/Inventory_en.properties index 6202d31391..32fe3f6bf9 100644 --- a/rpt_base/Inventory_en.properties +++ b/rpt_base/Inventory_en.properties @@ -10,11 +10,11 @@ Reference = Reference InventoryDate = Inventory Date -PrincipalWardInventory = PRINCIPAL WARD INVENTORY +MainStoreInventoryID = MAIN STORE INVENTORY ID Designation = Designation -WardCode = Ward Code +LotCode= Lot Code DueDate = Due Date diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index a9c3afcdc4..64eb0b88eb 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -934,12 +934,12 @@ private JButton getPrintButton() { printButton.setEnabled(true); printButton.addActionListener(e -> { - int printQtyReal = 0; + int printRealQty = 0; int response = MessageDialog.yesNo(this, "angal.inventory.askforrealquantityempty.msg"); if (response == JOptionPane.YES_OPTION) { - printQtyReal = 1; + printRealQty = 1; } - new GenericReportPharmaceuticalInventory(inventory, "Inventory", printQtyReal); + new GenericReportPharmaceuticalInventory(inventory, "Inventory", printRealQty); }); return printButton; diff --git a/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java b/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java index 5c8dda7918..d8a96fff68 100644 --- a/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java +++ b/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java @@ -34,9 +34,9 @@ public class GenericReportPharmaceuticalInventory extends DisplayReport { private static final Logger LOGGER = LoggerFactory.getLogger(GenericReportPharmaceuticalInventory.class); private JasperReportsManager jasperReportsManager = Context.getApplicationContext().getBean(JasperReportsManager.class); - public GenericReportPharmaceuticalInventory(MedicalInventory medicalInventory, String jasperFileName, int printQtyReal) { + public GenericReportPharmaceuticalInventory(MedicalInventory medicalInventory, String jasperFileName, int printRealQty) { try { - JasperReportResultDto jasperReportResultDto = jasperReportsManager.getInventoryReportPdf(medicalInventory, jasperFileName, printQtyReal); + JasperReportResultDto jasperReportResultDto = jasperReportsManager.getInventoryReportPdf(medicalInventory, jasperFileName, printRealQty); showReport(jasperReportResultDto); } catch (Exception e) { LOGGER.error("", e); From d901d8112db33a3db6001f1525ef385f980d7ec4 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud Date: Tue, 19 Nov 2024 22:04:55 +0100 Subject: [PATCH 072/147] OP-1305 | Confirm Inventory (#2070) * add confirm inventory feature * update bundle/language_en.properties * revert changes * format the code * Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java * update button order * apply suggestion * Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java * remove unused imports * add possibilty to update prise of existing lot * Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java * add check of existing reference on stock movement * add another condition to enable lot button * fix error on bundler * Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java * add check of reference number on validateInventory * reset param of settings.properties.dist * update InventoryEdit * revert code * remove non used import * update inventory during validation * fix bugs * fix bugs on InventoryBrowser * add TimeTools to date properties * add missng bundle key * apply suggestion * update InventoryEdit * revert settings.properties.dist * update InventoryEdit * update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java * updat InventoryEdit.java * add method the know if all medical are in inventory * add logic to select and deselect specific and all radio button * update the logic when saving inventory * update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java * Update bundle/language_en.properties * fix bug during save action * fix bug * charge Iterator by ListIterator * Update bundle/language_en.properties * Update src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java * Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java * remove empty comment * fix conflit after merge --------- Co-authored-by: ArnaudFonzam Co-authored-by: FOFOU FONZAM Gui Arnaud <101590821+ArnaudFonzam@users.noreply.github.com> Co-authored-by: Alessandro Domanico Co-authored-by: David B Malkovsky --- bundle/language_en.properties | 16 +- .../gui/InventoryBrowser.java | 21 +- .../medicalinventory/gui/InventoryEdit.java | 625 ++++++++++-------- .../isf/medicalstock/gui/MovStockBrowser.java | 28 +- 4 files changed, 391 insertions(+), 299 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 944147802b..83ac31c727 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -672,16 +672,21 @@ angal.hospital.visitstarthour.txt angal.inventory.allproduct.txt = All products angal.inventory.askforrealquantityempty.msg = Do you want to print without the real quantity? angal.inventory.canceled = Canceled +angal.inventory.confirm.btn = Confirm +angal.inventory.confirm.btn.key = O +angal.inventory.confirm.success.msg = Inventory confirmation complete. All stock has been accurately verified and updated in the system. angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg = Cannot create another inventory with status draft, Because you already have an inventory with status draft or validated. angal.inventory.cannotsavelot.msg = Cannot save the lot. Please verify lot information and retry. angal.inventory.cannotsaveinventorywithoutproducts.msg = Cannot save inventory without products. angal.inventory.cancelednoteditable.msg = A canceled inventory can not be modified. +angal.inventory.donenoteditable.msg = A confirm inventory can not be modified. angal.inventory.chargetype.label = Charge Type angal.inventory.clean.btn = Clean Table angal.inventory.clean.btn.key = T angal.inventory.choosedischargetypebeforevalidation.msg = Please choose the discharge type and save the inventory before validation. angal.inventory.choosechargetypebeforevalidation.msg = Please choose the charge type and save the inventory before validation. angal.inventory.choosesupplierbeforevalidation.msg = Please choose the supplier and save the inventory before validation. +angal.inventory.choosedestinationbeforevalidation.msg = Please choose the ward destination and save the inventory before validation. angal.inventory.deletion.confirm.msg = Do you really want to delete this inventory? angal.inventory.deletion.confirm.title = Confirm Deletion angal.inventory.deletion.success.msg = The inventory has been successfully marked as deleted. @@ -712,10 +717,12 @@ angal.inventory.supplier.label angal.inventoryrow.addnotyetlistedproducts.title = Add products angal.inventoryrow.doyoureallywanttodeletethisinventoryrow.msg = Do you really want to delete this/those inventory(ies) row(s)? angal.inventoryrow.doyoureallywanttocleanthistable.msg = Do you really want to clean this table? +angal.inventory.doyouwanttoactualizetheinventory.msg = Do you want to actualize this inventory? angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg = Do you want to add all not yet listed products? angal.inventoryrow.doyouwanttocontinueediting.msg = Do you want to continue editing? angal.inventoryrow.doyouwanttosavethechanges.msg = Do you want to save the changes? angal.inventoryrow.doyoureallywanttovalidatethisinventory.msg = Do you really want to validate this inventory? +angal.inventory.doyoureallywanttoconfirmthisinventory.msg = Do you really want to confirm this inventory? angal.inventoryrow.notfound.msg = Inventory not found. angal.inventoryrow.invalidquantity.msg = Invalid quantity. angal.inventory.pleaseinsertavalidinventorydate.msg = Please insert a valid inventory date. @@ -723,7 +730,6 @@ angal.inventoryrow.pleaseselectonlyoneinventoryrow.msg angal.inventoryrow.pleaseselectatleastoneinventoryrow.msg = Please select at least one inventory row. angal.inventoryrow.pleaseselectoneinventoryrow.msg = Please select one inventory row. angal.inventoryrow.thislotcodealreadyexists.msg = This lot code already exists. Please change it. -angal.inventory.inventoryisalreadysaved.msg = This inventory is already saved. Please enter at least one inventory row before continue. angal.inventory.pleaseselectonlyoneinventory.msg = Please select only one inventory. angal.inventory.pleaseinsertinventory.msg = Please add and inventory in this inventory row. angal.inventory.pleaseselectinventory.msg = Please select inventory. @@ -739,8 +745,11 @@ angal.inventory.specificproduct.txt angal.inventoryrow.theoreticqty.col = Theoretic Qty angal.inventory.totalprice = Total price angal.inventoryrow.unitprice.col = Unit price +angal.inventory.pleasevalidateinventoryagainsbeforeconfirmation.msg = Please validate this inventory again before confirmation. angal.inventory.update.error.msg = Inventory not updated. angal.inventory.update.success.msg = Inventory updated. +angal.inventory.doyouwanttoupdatethisinventory.msg = Do you want to update this inventory? +angal.inventory.nothinghasbeenaddedonthisinventory.msg = Nothing has been added to this inventory. angal.inventory.validated = Validated angal.inventory.done = Done angal.inventory.validate.btn = Validate @@ -749,7 +758,6 @@ angal.inventory.inventorymustsavebeforevalidation.msg angal.inventory.validate.success.msg = The inventory has been successfully validated. angal.inventory.theoreticalqtyhavebeenupdatedforsomemedical.fmt.msg = Theoretical(s) quantity(ies) have been updated by new movement(s) in main store for: {0} angal.inventory.theoreticalqtyhavebeenupdatedforsomemedical.detail.fmt.msg = {0} lot: {1} qty: {2} -> {3} ({4}) -angal.inventory.validate.error.msg = Error during inventory validation. angal.inventory.allinventoryrowshouldhavelotbeforevalidation.msg = All the inventory rows should have lots before validation. angal.inventory.viewinventory.title = View Inventory angal.inventory.youhavealreadyaddedallproduct.msg = You have already added all the products. @@ -900,7 +908,8 @@ angal.medicalstock.cost.col angal.medicalstock.deletemovementsuccess.msg = Last movement successfully deleted. angal.medicalstock.discharge.btn = Discharge angal.medicalstock.discharge.btn.key = R -angal.medicalstock.notpossibletodeletethismovementthemedicalhasbeenusedafterbeenreceivedinward.fmt.msg = Not possible to delete this movement: the medical {0} has already been used after been received in ward {1}. +angal.medicalstock.notpossibletodeletethismovementthemedicalhasbeenusedafterbeenreceivedinward.fmt.msg = Not possible to delete this movement: the medical {0} has been used after it was received in ward {1}. +angal.medicalstock.notpossibletodeletethismovementbecauseitisrelatedtoaninventory.msg = Not possible to delete this movement because it is related to an inventory. angal.medicalstock.duedate = Due date angal.medicalstock.duedate.col = Due Date angal.medicalstock.duedatefromcannotbelaterthanduedateto = Due Date From cannot be later than Due Date To @@ -1901,6 +1910,7 @@ angal.ward.newward.title angal.ward.nurses.col = Nurses angal.ward.nursesedit = Number of nurses * angal.ward.opd.txt = OPD +angal.ward.opdwardmusthaveopdservicechecked.msg = OPD ward must have OPD service checked. angal.ward.pleasecheckinadmissionpatients.msg = Please check in admission / patients. angal.ward.requiredfields = * Required fields angal.ward.theemailmustbevalid.msg = The email must be valid. diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 0a98490b5d..5871cedd4a 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -72,6 +72,7 @@ public class InventoryBrowser extends ModalJFrame implements InventoryListener { + private static final long serialVersionUID = 1L; private GoodDateChooser jCalendarTo; private GoodDateChooser jCalendarFrom; private LocalDateTime dateFrom = TimeTools.getNow(); @@ -97,7 +98,7 @@ public class InventoryBrowser extends ModalJFrame implements InventoryListener { private JLabel statusLabel; JButton next; JButton previous; - JComboBox pagesCombo = new JComboBox(); + JComboBox pagesCombo = new JComboBox<>(); JLabel under = new JLabel("/ 0 Page"); private static int PAGE_SIZE = 50; private int startIndex = 0; @@ -377,6 +378,11 @@ private JButton getUpdateButton() { MessageDialog.error(null, "angal.inventory.cancelednoteditable.msg"); return; } + + if (inventory.getStatus().equals(InventoryStatus.done.toString())) { + MessageDialog.error(null, "angal.inventory.donenoteditable.msg"); + return; + } InventoryEdit inventoryEdit = new InventoryEdit(inventory,"update"); InventoryEdit.addInventoryListener(InventoryBrowser.this); inventoryEdit.showAsModal(InventoryBrowser.this); @@ -475,7 +481,18 @@ public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { int[] selectedRows = jTableInventory.getSelectedRows(); if (selectedRows.length == 1) { - jButtonEdit.setEnabled(true); + int selectedRow = jTableInventory.getSelectedRow(); + MedicalInventory inventory = inventoryList.get(selectedRow); + if (inventory.getStatus().equals(InventoryStatus.canceled.toString()) || + inventory.getStatus().equals(InventoryStatus.done.toString())) { + jButtonEdit.setEnabled(false); + jButtonDelete.setEnabled(false); + } else { + jButtonEdit.setEnabled(true); + jButtonDelete.setEnabled(true); + + } + jButtonView.setEnabled(true); jButtonView.setEnabled(true); jButtonDelete.setEnabled(true); } else { diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 64eb0b88eb..27ce3940e6 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -45,9 +45,11 @@ import java.util.Collections; import java.util.EventListener; import java.util.HashMap; -import java.util.Iterator; +import java.util.HashSet; import java.util.List; +import java.util.ListIterator; import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; import javax.swing.ButtonGroup; @@ -171,6 +173,7 @@ private void fireInventoryUpdated() { private JButton resetButton; private JButton lotButton; private JButton validateButton; + private JButton confirmButton; private JScrollPane scrollPaneInventory; private JTable jTableInventoryRow; private DefaultTableModel model; @@ -218,7 +221,6 @@ private void fireInventoryUpdated() { private MovementType dischargeType = null; private Supplier supplier = null; private Ward destination = null; - private boolean selectAll = false; private String newReference = null; private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); private MedicalInventoryRowManager medicalInventoryRowManager = Context.getApplicationContext().getBean(MedicalInventoryRowManager.class); @@ -284,6 +286,7 @@ public void windowClosing(WindowEvent e) { if (mode.equals("view")) { saveButton.setVisible(false); validateButton.setVisible(false); + confirmButton.setVisible(false); deleteButton.setVisible(false); columnEditable = columnEditableView; codeTextField.setEditable(false); @@ -313,6 +316,11 @@ public void windowClosing(WindowEvent e) { supplierCombo.setEnabled(true); destinationCombo.setEnabled(true); lotButton.setVisible(true); + if (inventory != null && inventory.getStatus().equals(InventoryStatus.validated.toString())) { + confirmButton.setEnabled(true); + } else { + confirmButton.setEnabled(false); + } printButton.setVisible(false); } } @@ -453,10 +461,11 @@ private JPanel getPanelFooter() { if (panelFooter == null) { panelFooter = new JPanel(); panelFooter.add(getSaveButton()); - panelFooter.add(getValidateButton()); - panelFooter.add(getDeleteButton()); panelFooter.add(getLotButton()); + panelFooter.add(getDeleteButton()); panelFooter.add(getCleanTableButton()); + panelFooter.add(getValidateButton()); + panelFooter.add(getConfirmButton()); panelFooter.add(getPrintButton()); panelFooter.add(getCloseButton()); } @@ -481,7 +490,7 @@ private JButton getSaveButton() { saveButton = new JButton(MessageBundle.getMessage("angal.common.save.btn")); saveButton.setMnemonic(MessageBundle.getMnemonic("angal.common.save.btn.key")); saveButton.addActionListener(actionEvent -> { - String state = InventoryStatus.draft.toString(); + String status = InventoryStatus.draft.toString(); String user = UserBrowsingManager.getCurrentUser(); if (inventoryRowSearchList == null || inventoryRowSearchList.isEmpty()) { MessageDialog.error(null, "angal.inventory.cannotsaveinventorywithoutproducts.msg"); @@ -490,8 +499,7 @@ private JButton getSaveButton() { try { if (!lotsDeleted.isEmpty() || !inventoryRowsToDelete.isEmpty()) { for (Map.Entry entry : lotsDeleted.entrySet()) { - MedicalInventoryRow invRow = null; - invRow = medicalInventoryRowManager.getMedicalInventoryRowById(entry.getKey()); + MedicalInventoryRow invRow = medicalInventoryRowManager.getMedicalInventoryRowById(entry.getKey()); if (invRow != null) { invRow.setLot(null); medicalInventoryRowManager.updateMedicalInventoryRow(invRow); @@ -501,43 +509,30 @@ private JButton getSaveButton() { } medicalInventoryRowManager.deleteMedicalInventoryRows(inventoryRowsToDelete); } + ListIterator inventoryRowSearchListIterator = inventoryRowSearchList.listIterator(); + List newMedicalInventoryRows = new ArrayList<>(); if (mode.equals("new")) { newReference = referenceTextField.getText().trim(); boolean refExist = false; refExist = medicalInventoryManager.referenceExists(newReference); - if (refExist) { + boolean referenceExistonMovementStock = movStockInsertingManager.refNoExists(newReference); + if (refExist || referenceExistonMovementStock) { MessageDialog.error(null, "angal.inventory.referencealreadyused.msg"); return; } inventory = new MedicalInventory(); inventory.setInventoryReference(newReference); inventory.setInventoryDate(dateInventory); - inventory.setStatus(state); + inventory.setStatus(status); inventory.setUser(user); inventory.setInventoryType(InventoryType.main.toString()); - if (chargeType != null) { - inventory.setChargeType(chargeType.getCode()); - } else { - inventory.setChargeType(null); - } - if (dischargeType != null) { - inventory.setDischargeType(dischargeType.getCode()); - } else { - inventory.setDischargeType(null); - } - if (supplier != null) { - inventory.setSupplier(supplier.getSupId()); - } else { - inventory.setSupplier(null); - } - if (destination != null) { - inventory.setDestination(destination.getCode()); - } else { - inventory.setDestination(null); - } + inventory.setChargeType(chargeType == null ? null : chargeType.getCode()); + inventory.setDischargeType(dischargeType == null ? null : dischargeType.getCode()); + inventory.setSupplier(supplier == null ? null : supplier.getSupId()); + inventory.setDestination(destination == null ? null : destination.getCode()); inventory = medicalInventoryManager.newMedicalInventory(inventory); - for (Iterator iterator = inventoryRowSearchList.iterator(); iterator.hasNext();) { - MedicalInventoryRow medicalInventoryRow = (MedicalInventoryRow) iterator.next(); + while (inventoryRowSearchListIterator.hasNext()) { + MedicalInventoryRow medicalInventoryRow = inventoryRowSearchListIterator.next(); medicalInventoryRow.setInventory(inventory); Lot lot = medicalInventoryRow.getLot(); String lotCode; @@ -563,99 +558,29 @@ private JButton getSaveButton() { } else { medicalInventoryRow.setLot(null); } - medicalInventoryRowManager.newMedicalInventoryRow(medicalInventoryRow); + medicalInventoryRow = medicalInventoryRowManager.newMedicalInventoryRow(medicalInventoryRow); + newMedicalInventoryRows.add(medicalInventoryRow); } mode = "update"; - validateButton.setEnabled(true); MessageDialog.info(this, "angal.inventory.savesuccess.msg"); fireInventoryInserted(); + validateButton.setEnabled(true); resetVariable(); - int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttocontinueediting.msg"); - if (info != JOptionPane.YES_OPTION) { - dispose(); - } } else if (mode.equals("update")) { String lastCharge = inventory.getChargeType(); String lastDischarge = inventory.getDischargeType(); Integer lastSupplier = inventory.getSupplier(); + inventory.setStatus(status); String lastDestination = inventory.getDestination(); String lastReference = inventory.getInventoryReference(); newReference = referenceTextField.getText().trim(); + LocalDateTime lastDate = inventory.getInventoryDate(); MedicalInventory existingInventory = medicalInventoryManager.getInventoryByReference(newReference); - if (existingInventory != null && existingInventory.getId() != inventory.getId()) { + boolean referenceExistonMovementStock = movStockInsertingManager.refNoExists(newReference); + if ((existingInventory != null && existingInventory.getId() != inventory.getId()) || referenceExistonMovementStock) { MessageDialog.error(null, "angal.inventory.referencealreadyused.msg"); return; } - if (inventoryRowListAdded.isEmpty() && lotsSaved.isEmpty() && lotsDeleted.isEmpty()) { - if ((destination != null && !destination.getCode().equals(lastDestination)) - || (chargeType != null && !chargeType.getCode().equals(lastCharge)) - || (dischargeType != null && !dischargeType.getCode().equals(lastDischarge)) - || (supplier != null && !supplier.getSupId().equals(lastSupplier)) || (destination == null && lastDestination != null) - || (chargeType == null && lastCharge != null) || (dischargeType == null && lastDischarge != null) - || (supplier == null && lastSupplier != null) || !lastReference.equals(newReference)) { - if (!inventory.getInventoryDate().equals(dateInventory)) { - inventory.setInventoryDate(dateInventory); - } - if (!inventory.getUser().equals(user)) { - inventory.setUser(user); - } - if (!lastReference.equals(newReference)) { - inventory.setInventoryReference(newReference); - } - MovementType charge = (MovementType) chargeCombo.getSelectedItem(); - if (charge != null) { - inventory.setChargeType(charge.getCode()); - } else { - inventory.setChargeType(null); - } - MovementType discharge = (MovementType) dischargeCombo.getSelectedItem(); - if (discharge != null) { - inventory.setDischargeType(discharge.getCode()); - } else { - inventory.setDischargeType(null); - } - Supplier supplier = (Supplier) supplierCombo.getSelectedItem(); - if (supplier != null) { - inventory.setSupplier(supplier.getSupId()); - } else { - inventory.setSupplier(null); - } - Ward destination = (Ward) destinationCombo.getSelectedItem(); - if (destination != null) { - inventory.setDestination(destination.getCode()); - } else { - inventory.setDestination(null); - } - inventory = medicalInventoryManager.updateMedicalInventory(inventory); - if (inventory != null) { - MessageDialog.info(null, "angal.inventory.update.success.msg"); - resetVariable(); - fireInventoryUpdated(); - int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttocontinueediting.msg"); - if (info != JOptionPane.YES_OPTION) { - dispose(); - } - } else { - MessageDialog.error(null, "angal.inventory.update.error.msg"); - return; - } - } else { - if (!inventoryRowsToDelete.isEmpty()) { - MessageDialog.info(null, "angal.inventory.update.success.msg"); - resetVariable(); - fireInventoryUpdated(); - int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttocontinueediting.msg"); - if (info != JOptionPane.YES_OPTION) { - dispose(); - } - } else { - MessageDialog.info(null, "angal.inventory.inventoryisalreadysaved.msg"); - return; - } - - } - return; - } if (!inventory.getInventoryDate().equals(dateInventory)) { inventory.setInventoryDate(dateInventory); } @@ -666,101 +591,126 @@ private JButton getSaveButton() { inventory.setInventoryReference(newReference); } MovementType charge = (MovementType) chargeCombo.getSelectedItem(); - if (charge != null) { - inventory.setChargeType(charge.getCode()); - } else { - inventory.setChargeType(null); - } MovementType discharge = (MovementType) dischargeCombo.getSelectedItem(); - if (discharge != null) { - inventory.setDischargeType(discharge.getCode()); - } else { - inventory.setDischargeType(null); - } Supplier supplier = (Supplier) supplierCombo.getSelectedItem(); - if (supplier != null) { - inventory.setSupplier(supplier.getSupId()); - } else { - inventory.setSupplier(null); - } Ward destination = (Ward) destinationCombo.getSelectedItem(); - if (destination != null) { - inventory.setDestination(destination.getCode()); - } else { - inventory.setDestination(null); - } - inventory = medicalInventoryManager.updateMedicalInventory(inventory); - for (Iterator iterator = inventoryRowSearchList.iterator(); iterator.hasNext();) { - MedicalInventoryRow medicalInventoryRow = iterator.next(); - Medical medical = medicalInventoryRow.getMedical(); - Lot lot = medicalInventoryRow.getLot(); - String lotCode; - medicalInventoryRow.setInventory(inventory); - int id = medicalInventoryRow.getId(); - if (id == 0) { - if (lot != null) { - lotCode = lot.getCode(); - boolean isExist = false; - Lot lotExist = movStockInsertingManager.getLot(lotCode); - if (lotExist != null) { - isExist = true; - } - if (!isExist) { - if (lot.getDueDate() != null) { - Lot lotStore = movStockInsertingManager.storeLot(lotCode, lot, medical); - medicalInventoryRow.setLot(lotStore); - medicalInventoryRow.setNewLot(true); + inventory.setChargeType(charge == null ? null : charge.getCode()); + inventory.setDischargeType(discharge == null ? null : discharge.getCode()); + inventory.setSupplier(supplier == null ? null : supplier.getSupId()); + inventory.setDestination(destination == null ? null : destination.getCode()); + if (inventoryRowListAdded.isEmpty() && lotsSaved.isEmpty() && lotsDeleted.isEmpty()) { + if (checkParameters(lastDestination, lastCharge, lastDischarge, lastSupplier, lastReference, lastDate)) { + int response = MessageDialog.yesNo(null, "angal.inventory.doyouwanttoupdatethisinventory.msg"); + if (response == JOptionPane.YES_OPTION) { + inventory = medicalInventoryManager.updateMedicalInventory(inventory, true); + if (inventory != null) { + MessageDialog.info(null, "angal.inventory.update.success.msg"); + statusLabel.setText(status.toUpperCase()); + statusLabel.setForeground(Color.GRAY); + fireInventoryUpdated(); + validateButton.setEnabled(true); + if (confirmButton.isEnabled()) { + confirmButton.setEnabled(false); + } + if (areAllMedicalsInInventory()) { + allRadio.setSelected(true); + specificRadio.setSelected(false); + codeTextField.setEnabled(false); } else { - medicalInventoryRow.setLot(null); + specificRadio.setSelected(true); + codeTextField.setEnabled(true); + allRadio.setSelected(false); } + resetVariable(); } else { - Lot lotStore = movStockInsertingManager.updateLot(lot); - medicalInventoryRow.setLot(lotStore); + MessageDialog.error(null, "angal.inventory.update.error.msg"); + return; } } - medicalInventoryRowManager.newMedicalInventoryRow(medicalInventoryRow); } else { - lot = medicalInventoryRow.getLot(); - double reatQty = medicalInventoryRow.getRealQty(); - medicalInventoryRow = medicalInventoryRowManager.getMedicalInventoryRowById(id); - medicalInventoryRow.setRealqty(reatQty); + if (!inventoryRowsToDelete.isEmpty()) { + MessageDialog.info(null, "angal.inventory.update.success.msg"); + statusLabel.setText(status.toUpperCase()); + statusLabel.setForeground(Color.GRAY); + fireInventoryUpdated(); + validateButton.setEnabled(true); + if (confirmButton.isEnabled()) { + confirmButton.setEnabled(false); + } + if (areAllMedicalsInInventory()) { + allRadio.setSelected(true); + specificRadio.setSelected(false); + codeTextField.setEnabled(false); + } else { + specificRadio.setSelected(true); + codeTextField.setEnabled(true); + allRadio.setSelected(false); + } + resetVariable(); + } else { + MessageDialog.info(null, "angal.inventory.nothinghasbeenaddedonthisinventory.msg"); + } + } + return; + } + int response = MessageDialog.yesNo(null, "angal.inventory.doyouwanttoupdatethisinventory.msg"); + if (response == JOptionPane.YES_OPTION) { + inventory = medicalInventoryManager.updateMedicalInventory(inventory, true); + while (inventoryRowSearchListIterator.hasNext()) { + MedicalInventoryRow medicalInventoryRow = inventoryRowSearchListIterator.next(); + Medical medical = medicalInventoryRow.getMedical(); + Lot lot = medicalInventoryRow.getLot(); + String lotCode; if (lot != null) { lotCode = lot.getCode(); Lot lotExist = movStockInsertingManager.getLot(lotCode); if (lotExist != null) { - Lot lotStore; - lotExist.setDueDate(lot.getDueDate()); - lotExist.setPreparationDate(lot.getPreparationDate()); - lotExist.setCost(lot.getCost()); - lotStore = movStockInsertingManager.updateLot(lotExist); - medicalInventoryRow.setLot(lotStore); + lot.setMedical(medical); + lot = movStockInsertingManager.updateLot(lot); + medicalInventoryRow.setLot(lot); } else { - if (lot.getDueDate() != null) { - Lot lotStore = movStockInsertingManager.storeLot(lotCode, lot, medical); - medicalInventoryRow.setLot(lotStore); - medicalInventoryRow.setNewLot(true); + int idInvRow = medicalInventoryRow.getId(); + MedicalInventoryRow invRow = medicalInventoryRowManager.getMedicalInventoryRowById(idInvRow); + if (invRow.getLock() != medicalInventoryRow.getLock()) { + Lot newLot = movStockInsertingManager.storeLot(lotCode, lot, medical); + invRow.setLot(newLot); + invRow.setNewLot(true); + invRow.setRealqty(medicalInventoryRow.getRealQty()); + medicalInventoryRow = invRow; } else { - medicalInventoryRow.setLot(null); + Lot newLot = movStockInsertingManager.storeLot(lotCode, lot, medical); + medicalInventoryRow.setLot(newLot); + medicalInventoryRow.setNewLot(true); } + } - } else { - medicalInventoryRow.setLot(null); } - if (medicalInventoryRow.getId() == 0) { - medicalInventoryRowManager.newMedicalInventoryRow(medicalInventoryRow); + medicalInventoryRow.setInventory(inventory); + int id = medicalInventoryRow.getId(); + if (id == 0) { + medicalInventoryRow = medicalInventoryRowManager.newMedicalInventoryRow(medicalInventoryRow); } else { - medicalInventoryRowManager.updateMedicalInventoryRow(medicalInventoryRow); + medicalInventoryRow = medicalInventoryRowManager.updateMedicalInventoryRow(medicalInventoryRow); } + newMedicalInventoryRows.add(medicalInventoryRow); + } + MessageDialog.info(null, "angal.inventory.update.success.msg"); + statusLabel.setText(status.toUpperCase()); + statusLabel.setForeground(Color.GRAY); + resetVariable(); + fireInventoryUpdated(); + validateButton.setEnabled(true); + if (areAllMedicalsInInventory()) { + allRadio.setSelected(true); + specificRadio.setSelected(false); + } else { + specificRadio.setSelected(true); + allRadio.setSelected(false); } - } - MessageDialog.info(null, "angal.inventory.update.success.msg"); - resetVariable(); - fireInventoryUpdated(); - int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttocontinueediting.msg"); - if (info != JOptionPane.YES_OPTION) { - dispose(); } } + inventoryRowSearchList = newMedicalInventoryRows; + jTableInventoryRow.updateUI(); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); return; @@ -795,11 +745,9 @@ private JButton getDeleteButton() { for (int i = selectedRows.length - 1; i >= 0; i--) { MedicalInventoryRow inventoryRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRows[i], -1); inventoryRowSearchList.remove(inventoryRow); + inventoryRowsToDelete.add(inventoryRow); model.fireTableDataChanged(); jTableInventoryRow.setModel(model); - if (inventoryRow.getId() != 0) { - inventoryRowsToDelete.add(inventoryRow); - } } } jTableInventoryRow.clearSelection(); @@ -821,17 +769,30 @@ private JButton getLotButton() { return; } MedicalInventoryRow selectedInventoryRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRow, -1); - Lot lotToUpdate = selectedInventoryRow.getLot() != null ? selectedInventoryRow.getLot() : null; + Lot lotToUpdate = selectedInventoryRow.getLot(); Lot lot = new Lot(); try { - lot = this.getLot(lotToUpdate); - String lotCode = lotToUpdate != null ? lotToUpdate.getCode() : ""; - if (lot != null && !lot.getCode().equals(lotCode)) { - Lot lotDelete = movStockInsertingManager.getLot(lotCode); - if (lotDelete != null) { - lotsDeleted.put(selectedInventoryRow.getId(), lotDelete); + if (lotToUpdate != null && !selectedInventoryRow.isNewLot()) { + BigDecimal cost = BigDecimal.ZERO; + if (isLotWithCost()) { + cost = askCost(2, cost); + if (cost.compareTo(BigDecimal.ZERO) == 0) { + return; + } + } + lotToUpdate.setCost(cost); + lot = lotToUpdate; + } else { + lot = this.getLot(lotToUpdate); + String lotCode = lotToUpdate != null ? lotToUpdate.getCode() : ""; + if (lot != null && !lot.getCode().equals(lotCode)) { + Lot lotDelete = movStockInsertingManager.getLot(lotCode); + if (lotDelete != null) { + lotsDeleted.put(selectedInventoryRow.getId(), lotDelete); + } } } + } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); return; @@ -847,10 +808,8 @@ private JButton getLotButton() { lotsSaved.add(lot); } else { if (lotToUpdate != null && code.equals(lotToUpdate.getCode())) { - if (!isLotWithCost()) { - selectedInventoryRow.setLot(lot); - lotsSaved.add(lot); - } + selectedInventoryRow.setLot(lot); + lotsSaved.add(lot); } else { MessageDialog.error(this, "angal.inventoryrow.thislotcodealreadyexists.msg"); lotButton.doClick(); @@ -901,24 +860,13 @@ private JButton getCloseButton() { lastReference = inventory.getInventoryReference(); lastDate = inventory.getInventoryDate(); } - if (!lotsSaved.isEmpty() || !inventoryRowListAdded.isEmpty() || !lotsDeleted.isEmpty() || !inventoryRowsToDelete.isEmpty() - || (destination != null && !destination.getCode().equals(lastDestination)) - || (chargeType != null && !chargeType.getCode().equals(lastCharge)) - || (dischargeType != null && !dischargeType.getCode().equals(lastDischarge)) - || (supplier != null && !supplier.getSupId().equals(lastSupplier)) || (destination == null && lastDestination != null) - || (chargeType == null && lastCharge != null) || (dischargeType == null && lastDischarge != null) - || (supplier == null && lastSupplier != null) || (lastReference != null && !lastReference.equals(newReference)) - || !lastDate.toLocalDate().equals(dateInventory.toLocalDate())) { + if (checkParameters(lastDestination, lastCharge, lastDischarge, lastSupplier, lastReference, lastDate)) { int reset = MessageDialog.yesNoCancel(null, "angal.inventoryrow.doyouwanttosavethechanges.msg"); if (reset == JOptionPane.YES_OPTION) { this.saveButton.doClick(); - } - if (reset == JOptionPane.NO_OPTION) { - resetVariable(); - dispose(); } else { resetVariable(); - return; + dispose(); } } else { resetVariable(); @@ -951,14 +899,18 @@ private JButton getCleanTableButton() { resetButton.addActionListener(actionEvent -> { int reset = MessageDialog.yesNo(null, "angal.inventoryrow.doyoureallywanttocleanthistable.msg"); if (reset == JOptionPane.YES_OPTION) { - if (inventory != null) { - for (MedicalInventoryRow invRow : inventoryRowSearchList) { - if (invRow.getId() != 0) { - inventoryRowsToDelete.add(invRow); - } + try { + if (inventory != null) { + List invRows = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()); + medicalInventoryRowManager.deleteMedicalInventoryRows(invRows); + inventoryRowSearchList.clear(); + } else { + inventoryRowSearchList.clear(); } + + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); } - selectAll = false; specificRadio.setSelected(true); codeTextField.setEnabled(true); inventoryRowSearchList = new ArrayList<>(); @@ -990,65 +942,122 @@ private JButton getValidateButton() { } int reset = MessageDialog.yesNo(null, "angal.inventoryrow.doyoureallywanttovalidatethisinventory.msg"); if (reset == JOptionPane.YES_OPTION) { - String dischargeCode = inventory.getDischargeType(); String chargeCode = inventory.getChargeType(); + String dischargeCode = inventory.getDischargeType(); Integer supplierId = inventory.getSupplier(); String wardCode = inventory.getDestination(); - if (chargeCode == null || chargeCode.equals("")) { - MessageDialog.error(null, "angal.inventory.choosechargetypebeforevalidation.msg"); - return; - } - if (dischargeCode == null || dischargeCode.equals("")) { - MessageDialog.error(null, "angal.inventory.choosedischargetypebeforevalidation.msg"); - return; + String lastReference = inventory.getInventoryReference(); + LocalDateTime lastDate = inventory.getInventoryDate(); + if (checkParameters(wardCode, chargeCode, dischargeCode, supplierId, lastReference, lastDate) || !lotsSaved.isEmpty() + || !inventoryRowListAdded.isEmpty() || !inventoryRowsToDelete.isEmpty()) { + saveButton.doClick(); + chargeCode = inventory.getChargeType(); + dischargeCode = inventory.getDischargeType(); + supplierId = inventory.getSupplier(); + wardCode = inventory.getDestination(); + lastReference = inventory.getInventoryReference(); + lastDate = inventory.getInventoryDate(); } - if (supplierId == null || supplierId == 0) { - MessageDialog.error(null, "angal.inventory.choosesupplierbeforevalidation.msg"); - return; - } - if (wardCode == null || wardCode.equals("")) { - MessageDialog.error(null, "angal.inventory.choosesupplierbeforevalidation.msg"); + String errorMessage = this.checkParamsValues(chargeCode, dischargeCode, supplierId, wardCode); + if (errorMessage != null) { + MessageDialog.error(null, errorMessage); return; } // validate inventory - int inventoryRowsSize = inventoryRowSearchList.size(); try { medicalInventoryManager.validateMedicalInventoryRow(inventory, inventoryRowSearchList); + String status = InventoryStatus.validated.toString(); + inventory.setStatus(status); + inventory = medicalInventoryManager.updateMedicalInventory(inventory, true); + MessageDialog.info(null, "angal.inventory.validate.success.msg"); + statusLabel.setText(status.toUpperCase()); + statusLabel.setForeground(Color.BLUE); + confirmButton.setEnabled(true); + fireInventoryUpdated(); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); - try { - jTableInventoryRow.setModel(new InventoryRowModel()); - adjustWidth(); - } catch (OHServiceException e1) { - OHServiceExceptionUtil.showMessages(e); + int result = MessageDialog.yesNo(null, "angal.inventory.doyouwanttoactualizetheinventory.msg"); + if (result == JOptionPane.YES_OPTION) { + try { + String status = InventoryStatus.validated.toString(); + inventory.setStatus(status); + medicalInventoryManager.actualizeMedicalInventoryRow(inventory); + statusLabel.setText(status.toUpperCase()); + statusLabel.setForeground(Color.BLUE); + confirmButton.setEnabled(true); + jTableInventoryRow.setModel(new InventoryRowModel()); + fireInventoryUpdated(); + adjustWidth(); + } catch (OHServiceException e1) { + OHServiceExceptionUtil.showMessages(e); + } } + } + } + }); + return validateButton; + } + + private JButton getConfirmButton() { + confirmButton = new JButton(MessageBundle.getMessage("angal.inventory.confirm.btn")); + confirmButton.setMnemonic(MessageBundle.getMnemonic("angal.inventory.confirm.btn.key")); + if (inventory == null) { + confirmButton.setEnabled(false); + } + confirmButton.addActionListener(actionEvent -> { + if (inventory == null) { + MessageDialog.error(null, "angal.inventory.inventorymustsavebeforevalidation.msg"); + return; + } + List invRowWithoutLot = inventoryRowSearchList.stream().filter(invRow -> invRow.getLot() == null).collect(Collectors.toList()); + if (invRowWithoutLot.size() > 0) { + MessageDialog.error(null, "angal.inventory.allinventoryrowshouldhavelotbeforevalidation.msg"); + return; + } + int confirm = MessageDialog.yesNo(null, "angal.inventory.doyoureallywanttoconfirmthisinventory.msg"); + if (confirm == JOptionPane.YES_OPTION) { + String dischargeCode = inventory.getDischargeType(); + String chargeCode = inventory.getChargeType(); + Integer supplierId = inventory.getSupplier(); + String wardCode = inventory.getDestination(); + String errorMessage = this.checkParamsValues(chargeCode, dischargeCode, supplierId, wardCode); + if (errorMessage != null) { + MessageDialog.error(null, errorMessage); return; } - String status = InventoryStatus.validated.toString(); - inventory.setStatus(status); + // confirm inventory try { - inventory = medicalInventoryManager.updateMedicalInventory(inventory); - if (inventory != null) { - List invRows = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()); - MessageDialog.info(null, "angal.inventory.validate.success.msg"); - if (invRows.size() > inventoryRowsSize) { - MessageDialog.error(null, "angal.inventory.theoreticalqtyhavebeenupdatedforsomemedical.msg"); - } - fireInventoryUpdated(); - statusLabel.setText(status.toUpperCase()); - statusLabel.setForeground(Color.BLUE); - } else { - MessageDialog.info(null, "angal.inventory.validate.error.msg"); - return; - } + medicalInventoryManager.confirmMedicalInventoryRow(inventory, inventoryRowSearchList); + MessageDialog.info(null, "angal.inventory.confirm.success.msg"); + fireInventoryUpdated(); + closeButton.doClick(); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); + MessageDialog.info(null, "angal.inventory.pleasevalidateinventoryagainsbeforeconfirmation.msg"); + confirmButton.setEnabled(false); return; } } }); - return validateButton; + return confirmButton; } + + private String checkParamsValues(String chargeCode, String dischargeCode, Integer supplierId, String wardCode) { + if (chargeCode == null || chargeCode.isEmpty()) { + return "angal.inventory.choosechargetypebeforevalidation.msg"; + } + if (dischargeCode == null || dischargeCode.isEmpty()) { + return "angal.inventory.choosedischargetypebeforevalidation.msg"; + } + if (supplierId == null || supplierId == 0) { + return "angal.inventory.choosesupplierbeforevalidation.msg"; + } + if (wardCode == null || wardCode.isEmpty()) { + return "angal.inventory.choosedestinationbeforevalidation.msg"; + } + return null; + } + private JScrollPane getScrollPaneInventory() { if (scrollPaneInventory == null) { scrollPaneInventory = new JScrollPane(); @@ -1085,14 +1094,30 @@ private JTable getJTableInventoryRow() throws OHServiceException { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { - jTableInventoryRow.editCellAt(jTableInventoryRow.getSelectedRow(), jTableInventoryRow.getSelectedColumn()); - int[] selectedRows = jTableInventoryRow.getSelectedRows(); - if (selectedRows.length == 1) { - MedicalInventoryRow medInvRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRows[0], -1); - if (medInvRow.getLot() == null || medInvRow.isNewLot()) { + int selectedRow = jTableInventoryRow.getSelectedRow(); + if (selectedRow != -1) { + MedicalInventoryRow medInvRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRow, -1); + Lot lot = medInvRow.getLot(); + if (lot == null) { lotButton.setEnabled(true); } else { - lotButton.setEnabled(false); + BigDecimal cost = lot.getCost() != null ? lot.getCost() : BigDecimal.ZERO; + if (lot != null) { + if (isLotWithCost()) { + if (cost.doubleValue() == 0.00 || medInvRow.isNewLot()) { + lotButton.setEnabled(true); + } else { + lotButton.setEnabled(false); + } + } else { + if (medInvRow.isNewLot()) { + lotButton.setEnabled(true); + } else { + lotButton.setEnabled(false); + } + } + + } } } else { lotButton.setEnabled(false); @@ -1127,11 +1152,18 @@ public InventoryRowModel(boolean add) throws OHServiceException { for (MedicalInventoryRow invRow : inventoryRowList) { addMedInRowInInventorySearchList(invRow); } - selectAll = true; - MessageDialog.info(null, "angal.invetory.allmedicaladdedsuccessfully.msg"); } else { MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); } + if (areAllMedicalsInInventory()) { + allRadio.setSelected(true); + specificRadio.setSelected(false); + codeTextField.setEnabled(false); + } else { + specificRadio.setSelected(true); + codeTextField.setEnabled(true); + allRadio.setSelected(false); + } } public InventoryRowModel() throws OHServiceException { @@ -1153,7 +1185,15 @@ public InventoryRowModel() throws OHServiceException { } } } - + if (areAllMedicalsInInventory()) { + allRadio.setSelected(true); + specificRadio.setSelected(false); + codeTextField.setEnabled(false); + } else { + specificRadio.setSelected(true); + codeTextField.setEnabled(true); + allRadio.setSelected(false); + } } public Class< ? > getColumnClass(int c) { @@ -1473,16 +1513,9 @@ private JRadioButton getSpecificRadio() { private JRadioButton getAllRadio() { if (allRadio == null) { allRadio = new JRadioButton(MessageBundle.getMessage("angal.inventory.allproduct.txt")); - if (inventory != null) { - allRadio.setSelected(true); - specificRadio.setSelected(false); - } else { - allRadio.setSelected(false); - specificRadio.setSelected(true); - } allRadio.addActionListener(actionEvent -> { - if (!selectAll) { - if (allRadio.isSelected()) { + try { + if (!areAllMedicalsInInventory()) { codeTextField.setEnabled(false); codeTextField.setText(""); if (inventoryRowSearchList.size() > 0) { @@ -1497,7 +1530,6 @@ private JRadioButton getAllRadio() { } else { allRadio.setSelected(false); specificRadio.setSelected(true); - selectAll = false; } } else { @@ -1519,13 +1551,16 @@ private JRadioButton getAllRadio() { } if (inventory != null && !inventory.getStatus().equals(InventoryStatus.draft.toString())) { inventory.setStatus(InventoryStatus.draft.toString()); - } + } fireInventoryUpdated(); code = null; adjustWidth(); + MessageDialog.info(null, "angal.invetory.allmedicaladdedsuccessfully.msg"); + } else { + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); } - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); } }); } @@ -1610,8 +1645,9 @@ private List getMedicalInventoryRows(String code) throws OH } else { medicalList = medicalBrowsingManager.getMedicals(); } - for (Iterator iterator = medicalList.iterator(); iterator.hasNext();) { - Medical med = (Medical) iterator.next(); + ListIterator medicalListIterator = medicalList.listIterator(); + while (medicalListIterator.hasNext()) { + Medical med = medicalListIterator.next(); lots = movStockInsertingManager.getLotByMedical(med, false); double actualQty = med.getInqty() - med.getOutqty(); if (lots.size() == 0) { @@ -1620,8 +1656,9 @@ private List getMedicalInventoryRows(String code) throws OH inventoryRowsList.add(inventoryRowTemp); } } else { - for (Iterator iterator2 = lots.iterator(); iterator2.hasNext();) { - Lot lot = (Lot) iterator2.next(); + ListIterator lotListIterator = lots.listIterator(); + while (lotListIterator.hasNext()) { + Lot lot = lotListIterator.next(); inventoryRowTemp = new MedicalInventoryRow(0, lot.getMainStoreQuantity(), lot.getMainStoreQuantity(), null, med, lot); if (!existInInventorySearchList(inventoryRowTemp)) { inventoryRowsList.add(inventoryRowTemp); @@ -1652,8 +1689,9 @@ private void addInventoryRow(String code) throws OHServiceException { } int numberOfMedicalWithoutSameLotAdded = 0; Medical medicalWithLot = null; - for (Iterator iterator = medicalList.iterator(); iterator.hasNext();) { - Medical med = (Medical) iterator.next(); + ListIterator medicalListIterator = medicalList.listIterator(); + while (medicalListIterator.hasNext()) { + Medical med = medicalListIterator.next(); lots = movStockInsertingManager.getLotByMedical(med, false); if (lots.size() == 0) { inventoryRowTemp = new MedicalInventoryRow(0, 0.0, 0.0, null, med, null); @@ -1667,8 +1705,9 @@ private void addInventoryRow(String code) throws OHServiceException { } } else { medicalWithLot = med; - for (Iterator iterator2 = lots.iterator(); iterator2.hasNext();) { - Lot lot = (Lot) iterator2.next(); + ListIterator lotListIterator = lots.listIterator(); + while (lotListIterator.hasNext()) { + Lot lot = lotListIterator.next(); inventoryRowTemp = new MedicalInventoryRow(0, lot.getMainStoreQuantity(), lot.getMainStoreQuantity(), null, med, lot); if (!existInInventorySearchList(inventoryRowTemp)) { inventoryRowsList.add(inventoryRowTemp); @@ -1971,4 +2010,30 @@ private void resetVariable() { inventoryRowListAdded.clear(); lotsSaved.clear(); } + + private boolean checkParameters(String wardCode, String chargeCode, String dischargeCode, Integer suplierId, String reference, LocalDateTime date) { + if (!lotsSaved.isEmpty() || !inventoryRowListAdded.isEmpty() || !lotsDeleted.isEmpty() || !inventoryRowsToDelete.isEmpty() + || (destination != null && !destination.getCode().equals(wardCode)) + || (chargeType != null && !chargeType.getCode().equals(chargeCode)) + || (dischargeType != null && !dischargeType.getCode().equals(dischargeCode)) + || (supplier != null && !supplier.getSupId().equals(suplierId)) || (destination == null && wardCode != null) + || (chargeType == null && chargeCode != null) || (dischargeType == null && dischargeCode != null) + || (supplier == null && suplierId != null) || (reference != null && !reference.equals(newReference)) + || !date.toLocalDate().equals(dateInventory.toLocalDate())) { + return true; + } + return false; + } + + private boolean areAllMedicalsInInventory() throws OHServiceException { + List medicals = medicalBrowsingManager.getMedicals(); + Set inventorySet = new HashSet<>(); + for (MedicalInventoryRow row : inventoryRowSearchList) { + inventorySet.add(row.getMedical()); + } + if (medicals.size() == inventorySet.size()) { + return true; + } + return false; + } } \ No newline at end of file diff --git a/src/main/java/org/isf/medicalstock/gui/MovStockBrowser.java b/src/main/java/org/isf/medicalstock/gui/MovStockBrowser.java index 99ab7dc533..48c6ea1c9a 100644 --- a/src/main/java/org/isf/medicalstock/gui/MovStockBrowser.java +++ b/src/main/java/org/isf/medicalstock/gui/MovStockBrowser.java @@ -696,8 +696,8 @@ private JComboBox getMovementTypeBox() { } private JTable getMovTable() { - LocalDateTime now = TimeTools.getNow(); - LocalDateTime old = now.minusWeeks(1); + LocalDateTime now = TimeTools.getBeginningOfNextDay(TimeTools.getNow()); + LocalDateTime old = TimeTools.getBeginningOfDay(now.minusWeeks(1)); model = new MovBrowserModel(null, null, null, null, old, now, null, null, null, null); movTable = new JTable(model); @@ -892,21 +892,21 @@ private JButton getFilterButton() { if (!isAutomaticLot()) { model = new MovBrowserModel(medicalSelected, medicalTypeSelected, wardSelected, movementTypeSelected, - movDateFrom.getDateStartOfDay(), - movDateTo.getDateStartOfDay(), - lotPrepFrom.getDateStartOfDay(), - lotPrepTo.getDateStartOfDay(), - lotDueFrom.getDateStartOfDay(), - lotDueTo.getDateStartOfDay()); + TimeTools.getBeginningOfDay(movDateFrom.getDateStartOfDay()), + TimeTools.getBeginningOfNextDay(movDateTo.getDateStartOfDay()), + TimeTools.getBeginningOfDay(lotPrepFrom.getDateStartOfDay()), + TimeTools.getBeginningOfNextDay(lotPrepTo.getDateStartOfDay()), + TimeTools.getBeginningOfDay(lotDueFrom.getDateStartOfDay()), + TimeTools.getBeginningOfNextDay(lotDueTo.getDateStartOfDay())); } else { model = new MovBrowserModel(medicalSelected, medicalTypeSelected, wardSelected, movementTypeSelected, - movDateFrom.getDateStartOfDay(), - movDateTo.getDateStartOfDay(), + TimeTools.getBeginningOfDay(movDateFrom.getDateStartOfDay()), + TimeTools.getBeginningOfNextDay(movDateTo.getDateStartOfDay()), null, null, - lotDueFrom.getDateStartOfDay(), - lotDueTo.getDateStartOfDay()); + TimeTools.getBeginningOfDay(lotDueFrom.getDateStartOfDay()), + TimeTools.getBeginningOfNextDay(lotDueTo.getDateStartOfDay())); } if (moves != null) @@ -1147,8 +1147,8 @@ class MovBrowserModel extends DefaultTableModel { private static final long serialVersionUID = 1L; public MovBrowserModel() { - LocalDateTime now = TimeTools.getNow(); - LocalDateTime old = now.minusWeeks(1); + LocalDateTime now = TimeTools.getBeginningOfNextDay(TimeTools.getNow()); + LocalDateTime old = TimeTools.getBeginningOfDay(now.minusWeeks(1)); new MovBrowserModel(null, null, null, null, old, now, null, null, null, null); updateTotals(); From 25137d02d17b6d4eb90de40dbd1887722bced6cd Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Thu, 21 Nov 2024 16:55:32 +0100 Subject: [PATCH 073/147] Enhance product selections in edit inventory --- bundle/language_en.properties | 10 +- .../medicalinventory/gui/InventoryEdit.java | 608 +++++++++++++++--- 2 files changed, 526 insertions(+), 92 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 83ac31c727..25cf66d2ef 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -669,7 +669,7 @@ angal.hospital.thevisitinghourvaluesmustbeintherange0to24.msg angal.hospital.visitduration.txt = Visit duration angal.hospital.visitendhour.txt = Visit end hour angal.hospital.visitstarthour.txt = Visit start hour -angal.inventory.allproduct.txt = All products +angal.inventory.addproduct.label = Add products angal.inventory.askforrealquantityempty.msg = Do you want to print without the real quantity? angal.inventory.canceled = Canceled angal.inventory.confirm.btn = Confirm @@ -734,6 +734,12 @@ angal.inventory.pleaseselectonlyoneinventory.msg angal.inventory.pleaseinsertinventory.msg = Please add and inventory in this inventory row. angal.inventory.pleaseselectinventory.msg = Please select inventory. angal.inventoryoperation.save.error.msg = Inventory not saved. +angal.inventoryrow.lotinformation.title = Lot Information +angal.inventoryrow.medicaltype.txt = Medical Type +angal.inventory.medicalwithmovementonly.btn = With movement only +angal.inventory.medicalwithmovementonly.btn.key = W +angal.inventory.medicalwithonlynonzeroqty.btn = Only non zero quantyties +angal.inventory.medicalwithonlynonzeroqty.btn.key = O angal.inventory.nextarrow.btn = > angal.inventory.arrowprevious.btn = < angal.inventory.product.col = Products @@ -746,12 +752,14 @@ angal.inventoryrow.theoreticqty.col angal.inventory.totalprice = Total price angal.inventoryrow.unitprice.col = Unit price angal.inventory.pleasevalidateinventoryagainsbeforeconfirmation.msg = Please validate this inventory again before confirmation. +angal.invetory.tablehasbeenupdated.msg = Table has been updated. angal.inventory.update.error.msg = Inventory not updated. angal.inventory.update.success.msg = Inventory updated. angal.inventory.doyouwanttoupdatethisinventory.msg = Do you want to update this inventory? angal.inventory.nothinghasbeenaddedonthisinventory.msg = Nothing has been added to this inventory. angal.inventory.validated = Validated angal.inventory.done = Done +angal.invetory.notdataforthatfilter.msg = No data available for that filter. angal.inventory.validate.btn = Validate angal.inventory.validate.btn.key = V angal.inventory.inventorymustsavebeforevalidation.msg = Inventory must be saved before validation. diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 27ce3940e6..88cae00c1e 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -28,6 +28,7 @@ import java.awt.Color; import java.awt.Component; import java.awt.Dimension; +import java.awt.FlowLayout; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; @@ -52,6 +53,7 @@ import java.util.Set; import java.util.stream.Collectors; +import javax.swing.BorderFactory; import javax.swing.ButtonGroup; import javax.swing.DefaultCellEditor; import javax.swing.JButton; @@ -84,14 +86,17 @@ import org.isf.medicalinventory.model.MedicalInventoryRow; import org.isf.medicals.manager.MedicalBrowsingManager; import org.isf.medicals.model.Medical; +import org.isf.medicalstock.manager.MovBrowserManager; import org.isf.medicalstock.manager.MovStockInsertingManager; import org.isf.medicalstock.model.Lot; +import org.isf.medicalstock.model.Movement; import org.isf.medstockmovtype.manager.MedicalDsrStockMovementTypeBrowserManager; import org.isf.medstockmovtype.model.MovementType; +import org.isf.medtype.manager.MedicalTypeBrowserManager; +import org.isf.medtype.model.MedicalType; import org.isf.menu.manager.Context; import org.isf.menu.manager.UserBrowsingManager; import org.isf.stat.gui.report.GenericReportPharmaceuticalInventory; -import org.isf.stat.manager.JasperReportsManager; import org.isf.supplier.manager.SupplierBrowserManager; import org.isf.supplier.model.Supplier; import org.isf.utils.db.NormalizeString; @@ -200,7 +205,6 @@ private void fireInventoryUpdated() { GeneralData.LOTWITHCOST }; private MedicalInventory inventory = null; private JRadioButton specificRadio; - private JRadioButton allRadio; private JLabel dateInventoryLabel; private JTextField codeTextField; private String code = null; @@ -210,6 +214,7 @@ private void fireInventoryUpdated() { private JLabel chargeTypeLabel; private JLabel dischargeTypeLabel; private JLabel supplierLabel; + private JLabel addProductLabel; private JLabel destinationLabel; private JTextField referenceTextField; private JTextField jTextFieldEditor; @@ -222,6 +227,16 @@ private void fireInventoryUpdated() { private Supplier supplier = null; private Ward destination = null; private String newReference = null; + private JButton selectButton; + private JFrame frame; + private JPanel mainPanel; + private JRadioButton radioButtonAll; + private JRadioButton radioOnlyNonZero; + private JRadioButton radioWithMovement; + private JButton jButtonCancel; + private JButton jButtonOk; + private MedicalType medicalTypeSelected; + private JComboBox medicalTypeComboBox; private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); private MedicalInventoryRowManager medicalInventoryRowManager = Context.getApplicationContext().getBean(MedicalInventoryRowManager.class); private MedicalBrowsingManager medicalBrowsingManager = Context.getApplicationContext().getBean(MedicalBrowsingManager.class); @@ -229,8 +244,9 @@ private void fireInventoryUpdated() { private MedicalDsrStockMovementTypeBrowserManager movTypeManager = Context.getApplicationContext().getBean(MedicalDsrStockMovementTypeBrowserManager.class); private SupplierBrowserManager supplierManager = Context.getApplicationContext().getBean(SupplierBrowserManager.class); private WardBrowserManager wardManager = Context.getApplicationContext().getBean(WardBrowserManager.class); - private JasperReportsManager jasperReportsManager = Context.getApplicationContext().getBean(JasperReportsManager.class); - + private MedicalTypeBrowserManager medicalTypeManager = Context.getApplicationContext().getBean(MedicalTypeBrowserManager.class); + private MovBrowserManager movBrowserManager = Context.getApplicationContext().getBean(MovBrowserManager.class); + public InventoryEdit() { mode = "new"; initComponents(); @@ -294,7 +310,6 @@ public void windowClosing(WindowEvent e) { referenceTextField.setEditable(false); jCalendarInventory.setEnabled(false); specificRadio.setEnabled(false); - allRadio.setEnabled(false); chargeCombo.setEnabled(false); dischargeCombo.setEnabled(false); supplierCombo.setEnabled(false); @@ -310,7 +325,6 @@ public void windowClosing(WindowEvent e) { referenceTextField.setEditable(true); jCalendarInventory.setEnabled(true); specificRadio.setEnabled(true); - allRadio.setEnabled(true); chargeCombo.setEnabled(true); dischargeCombo.setEnabled(true); supplierCombo.setEnabled(true); @@ -426,15 +440,18 @@ private JPanel getPanelHeader() { gbc_codeTextField.gridx = 1; gbc_codeTextField.gridy = 3; panelHeader.add(getCodeTextField(), gbc_codeTextField); - GridBagConstraints gbc_allRadio = new GridBagConstraints(); - gbc_allRadio.anchor = GridBagConstraints.EAST; - gbc_allRadio.insets = new Insets(0, 0, 0, 5); - gbc_allRadio.gridx = 2; - gbc_allRadio.gridy = 3; - panelHeader.add(getAllRadio(), gbc_allRadio); - ButtonGroup group = new ButtonGroup(); - group.add(specificRadio); - group.add(allRadio); + GridBagConstraints gbc_addProduct = new GridBagConstraints(); + gbc_addProduct.anchor = GridBagConstraints.EAST; + gbc_addProduct.insets = new Insets(0, 0, 0, 5); + gbc_addProduct.gridx = 2; + gbc_addProduct.gridy = 3; + panelHeader.add(getAddProductLabel(), gbc_addProduct); + GridBagConstraints gbc_selectButton = new GridBagConstraints(); + gbc_selectButton.anchor = GridBagConstraints.WEST; + gbc_selectButton.insets = new Insets(0, 0, 0, 5); + gbc_selectButton.gridx = 3; + gbc_selectButton.gridy = 3; + panelHeader.add(getSelectedButton(), gbc_selectButton); } return panelHeader; } @@ -486,6 +503,52 @@ private GoodDateChooser getJCalendarFrom() { return jCalendarInventory; } + private JButton getSelectedButton() { + if (selectButton == null) { + selectButton = new JButton(MessageBundle.getMessage("angal.common.select.btn")); + selectButton.setMnemonic(MessageBundle.getMnemonic("angal.common.select.btn.key")); + selectButton.addActionListener(actionEvent -> { + specificRadio.setSelected(false); + mainPanel = new JPanel(); + mainPanel.setLayout(new BorderLayout(10, 10)); + + JPanel leftPanel = new JPanel(); + leftPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 20)); + leftPanel.setLayout(new GridLayout(3,1)); + leftPanel.add(new JLabel(MessageBundle.getMessage("angal.inventoryrow.medicaltype.txt"))); + leftPanel.add(getJComboMedicalType()); + + ButtonGroup radioGroup = new ButtonGroup(); + radioGroup.add(radioButtonAll); + radioGroup.add(radioOnlyNonZero); + radioGroup.add(radioWithMovement); + + JPanel rightPanel = new JPanel(); + rightPanel.setLayout(new GridLayout(3, 1, 5, 5)); + rightPanel.add(getAllRadioButton()); + rightPanel.add(getMedicalWithNonZeroQuatityRadioButton()); + rightPanel.add(getMedicalWithMovementRadioButton()); + + JPanel bottomPanel = new JPanel(); + bottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); + bottomPanel.add(getOkButton()); + bottomPanel.add(getCancelButton()); + + mainPanel.add(leftPanel, BorderLayout.WEST); + mainPanel.add(rightPanel, BorderLayout.EAST); + mainPanel.add(bottomPanel, BorderLayout.SOUTH); + + frame = new JFrame(); + frame.add(mainPanel); + frame.setSize(450, 200); + frame.setTitle(MessageBundle.getMessage("angal.inventoryrow.lotinformation.title")); + frame.setLocationRelativeTo(null); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setVisible(true); + }); + } + return selectButton; + } private JButton getSaveButton() { saveButton = new JButton(MessageBundle.getMessage("angal.common.save.btn")); saveButton.setMnemonic(MessageBundle.getMnemonic("angal.common.save.btn.key")); @@ -613,13 +676,11 @@ private JButton getSaveButton() { confirmButton.setEnabled(false); } if (areAllMedicalsInInventory()) { - allRadio.setSelected(true); specificRadio.setSelected(false); codeTextField.setEnabled(false); } else { specificRadio.setSelected(true); codeTextField.setEnabled(true); - allRadio.setSelected(false); } resetVariable(); } else { @@ -638,13 +699,11 @@ private JButton getSaveButton() { confirmButton.setEnabled(false); } if (areAllMedicalsInInventory()) { - allRadio.setSelected(true); specificRadio.setSelected(false); codeTextField.setEnabled(false); } else { specificRadio.setSelected(true); codeTextField.setEnabled(true); - allRadio.setSelected(false); } resetVariable(); } else { @@ -701,11 +760,9 @@ private JButton getSaveButton() { fireInventoryUpdated(); validateButton.setEnabled(true); if (areAllMedicalsInInventory()) { - allRadio.setSelected(true); specificRadio.setSelected(false); } else { specificRadio.setSelected(true); - allRadio.setSelected(false); } } } @@ -965,8 +1022,8 @@ private JButton getValidateButton() { } // validate inventory try { - medicalInventoryManager.validateMedicalInventoryRow(inventory, inventoryRowSearchList); String status = InventoryStatus.validated.toString(); + medicalInventoryManager.validateMedicalInventoryRow(inventory, inventoryRowSearchList); inventory.setStatus(status); inventory = medicalInventoryManager.updateMedicalInventory(inventory, true); MessageDialog.info(null, "angal.inventory.validate.success.msg"); @@ -1116,7 +1173,6 @@ public void valueChanged(ListSelectionEvent e) { lotButton.setEnabled(false); } } - } } } else { @@ -1147,35 +1203,29 @@ class InventoryRowModel extends DefaultTableModel { private static final long serialVersionUID = 1L; public InventoryRowModel(boolean add) throws OHServiceException { + inventoryRowList.clear(); inventoryRowList = loadNewInventoryTable(null, inventory, add); if (!inventoryRowList.isEmpty()) { for (MedicalInventoryRow invRow : inventoryRowList) { addMedInRowInInventorySearchList(invRow); } - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); } if (areAllMedicalsInInventory()) { - allRadio.setSelected(true); specificRadio.setSelected(false); codeTextField.setEnabled(false); } else { specificRadio.setSelected(true); codeTextField.setEnabled(true); - allRadio.setSelected(false); } } public InventoryRowModel() throws OHServiceException { + inventoryRowList.clear(); if (!inventoryRowSearchList.isEmpty()) { inventoryRowSearchList.clear(); } if (inventory != null) { inventoryRowList = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()); - } else { - if (allRadio.isSelected()) { - inventoryRowList = loadNewInventoryTable(null, inventory, false); - } } if (!inventoryRowList.isEmpty()) { for (MedicalInventoryRow invRow : inventoryRowList) { @@ -1186,13 +1236,66 @@ public InventoryRowModel() throws OHServiceException { } } if (areAllMedicalsInInventory()) { - allRadio.setSelected(true); specificRadio.setSelected(false); codeTextField.setEnabled(false); } else { specificRadio.setSelected(true); codeTextField.setEnabled(true); - allRadio.setSelected(false); + } + } + + public InventoryRowModel(MedicalType medType) throws OHServiceException { + inventoryRowList.clear(); + inventoryRowList = loadNewInventoryTable(medType); + if (!inventoryRowList.isEmpty()) { + for (MedicalInventoryRow invRow : inventoryRowList) { + addMedInRowInInventorySearchList(invRow); + } + } + if (areAllMedicalsInInventory()) { + specificRadio.setSelected(false); + codeTextField.setEnabled(false); + } else { + specificRadio.setSelected(true); + codeTextField.setEnabled(true); + } + } + + public InventoryRowModel(boolean withZeroQty, MedicalType medType) throws OHServiceException { + inventoryRowList.clear(); + inventoryRowList = loadNewInventoryTable(withZeroQty, medType); + if (!inventoryRowList.isEmpty()) { + for (MedicalInventoryRow invRow : inventoryRowList) { + addMedInRowInInventorySearchList(invRow); + } + } else { + MessageDialog.info(null, "angal.invetory.notdataforthatfilter.msg"); + } + if (areAllMedicalsInInventory()) { + specificRadio.setSelected(false); + codeTextField.setEnabled(false); + } else { + specificRadio.setSelected(true); + codeTextField.setEnabled(true); + } + } + + public InventoryRowModel(MedicalType medType, boolean withMovement) throws OHServiceException { + inventoryRowList.clear(); + inventoryRowList = loadNewInventoryTable(medType, withMovement); + if (!inventoryRowList.isEmpty()) { + for (MedicalInventoryRow invRow : inventoryRowList) { + addMedInRowInInventorySearchList(invRow); + } + } else { + MessageDialog.info(null, "angal.invetory.notdataforthatfilter.msg"); + } + if (areAllMedicalsInInventory()) { + specificRadio.setSelected(false); + codeTextField.setEnabled(false); + } else { + specificRadio.setSelected(true); + codeTextField.setEnabled(true); } } @@ -1503,70 +1606,12 @@ private JRadioButton getSpecificRadio() { if (specificRadio.isSelected()) { codeTextField.setEnabled(true); codeTextField.setText(""); - allRadio.setSelected(false); } }); } return specificRadio; } - private JRadioButton getAllRadio() { - if (allRadio == null) { - allRadio = new JRadioButton(MessageBundle.getMessage("angal.inventory.allproduct.txt")); - allRadio.addActionListener(actionEvent -> { - try { - if (!areAllMedicalsInInventory()) { - codeTextField.setEnabled(false); - codeTextField.setText(""); - if (inventoryRowSearchList.size() > 0) { - int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); - if (info == JOptionPane.YES_OPTION) { - try { - allRadio.setSelected(true); - jTableInventoryRow.setModel(new InventoryRowModel(true)); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } else { - allRadio.setSelected(false); - specificRadio.setSelected(true); - } - - } else { - if (mode.equals("update")) { - try { - allRadio.setSelected(true); - jTableInventoryRow.setModel(new InventoryRowModel(true)); - - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } else { - try { - jTableInventoryRow.setModel(new InventoryRowModel()); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - } - if (inventory != null && !inventory.getStatus().equals(InventoryStatus.draft.toString())) { - inventory.setStatus(InventoryStatus.draft.toString()); - } - fireInventoryUpdated(); - code = null; - adjustWidth(); - MessageDialog.info(null, "angal.invetory.allmedicaladdedsuccessfully.msg"); - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - }); - } - return allRadio; - } - private JLabel getDateInventoryLabel() { if (dateInventoryLabel == null) { dateInventoryLabel = new JLabel(MessageBundle.getMessage("angal.common.date.txt")); @@ -1625,6 +1670,10 @@ private List loadNewInventoryTable(String code, MedicalInve } return inventoryRowsList; } + + private List loadNewInventoryTable(MedicalType medicalType) throws OHServiceException { + return getMedicalInventoryRowsByMedicalType(medicalType); + } private List getMedicalInventoryRows(String code) throws OHServiceException { List inventoryRowsList = new ArrayList<>(); @@ -1668,6 +1717,76 @@ private List getMedicalInventoryRows(String code) throws OH } return inventoryRowsList; } + + private List getMedicalInventoryRowsByMedicalType(MedicalType medType) throws OHServiceException { + List inventoryRowsList = new ArrayList<>(); + String medTypeDescription = medType.getDescription(); + List medicalList = medicalBrowsingManager.getMedicals(medTypeDescription, false); + List lots = null; + MedicalInventoryRow inventoryRowTemp = null; + ListIterator medicalListIterator = medicalList.listIterator(); + while (medicalListIterator.hasNext()) { + Medical med = medicalListIterator.next(); + lots = movStockInsertingManager.getLotByMedical(med, false); + double actualQty = med.getInqty() - med.getOutqty(); + if (lots.size() == 0) { + inventoryRowTemp = new MedicalInventoryRow(0, actualQty, actualQty, null, med, null); + if (!existInInventorySearchList(inventoryRowTemp)) { + inventoryRowsList.add(inventoryRowTemp); + } + } else { + ListIterator lotListIterator = lots.listIterator(); + while (lotListIterator.hasNext()) { + Lot lot = lotListIterator.next(); + inventoryRowTemp = new MedicalInventoryRow(0, lot.getMainStoreQuantity(), lot.getMainStoreQuantity(), null, med, lot); + if (!existInInventorySearchList(inventoryRowTemp)) { + inventoryRowsList.add(inventoryRowTemp); + } + } + } + } + return inventoryRowsList; + } + + private List getMedicalInventoryRowsWithMovement() throws OHServiceException { + List inventoryRowsList = new ArrayList<>(); + List medicalListWithMovement = new ArrayList<>(); + List lots = null; + MedicalInventoryRow inventoryRowTemp = null; + List medicalList = medicalBrowsingManager.getMedicals(); + ListIterator medicalListIterator = medicalList.listIterator(); + while (medicalListIterator.hasNext()) { + Medical med = medicalListIterator.next(); + Integer medicalCodde = med.getCode(); + List movements = movBrowserManager.getMovements(medicalCodde, null, null, null, null, null, null, null, null, null); + if (movements.size() > 0) { + medicalListWithMovement.add(med); + } + } + medicalListIterator = medicalListWithMovement.listIterator(); + while (medicalListIterator.hasNext()) { + Medical med = medicalListIterator.next(); + lots = movStockInsertingManager.getLotByMedical(med, false); + double actualQty = med.getInqty() - med.getOutqty(); + if (lots.size() == 0) { + inventoryRowTemp = new MedicalInventoryRow(0, actualQty, actualQty, null, med, null); + if (!existInInventorySearchList(inventoryRowTemp)) { + inventoryRowsList.add(inventoryRowTemp); + } + } else { + ListIterator lotListIterator = lots.listIterator(); + while (lotListIterator.hasNext()) { + Lot lot = lotListIterator.next(); + inventoryRowTemp = new MedicalInventoryRow(0, lot.getMainStoreQuantity(), lot.getMainStoreQuantity(), null, med, lot); + if (!existInInventorySearchList(inventoryRowTemp)) { + inventoryRowsList.add(inventoryRowTemp); + } + } + } + } + return inventoryRowsList; + } + private void addInventoryRow(String code) throws OHServiceException { List inventoryRowsList = new ArrayList(); List medicalList = new ArrayList(); @@ -1820,6 +1939,13 @@ private JLabel getSupplierLabel() { } return supplierLabel; } + + private JLabel getAddProductLabel() { + if (addProductLabel == null) { + addProductLabel = new JLabel(MessageBundle.getMessage("angal.inventory.addproduct.label")); + } + return addProductLabel; + } private JLabel getDischargeLabel() { if (dischargeTypeLabel == null) { @@ -2025,6 +2151,306 @@ private boolean checkParameters(String wardCode, String chargeCode, String disch return false; } + private JComboBox getJComboMedicalType() { + if (medicalTypeComboBox == null) { + medicalTypeComboBox = new JComboBox(); + try { + List medicalTypes = medicalTypeManager.getMedicalType(); + MedicalType medicalType = new MedicalType(MessageBundle.getMessage("angal.common.all.txt"), MessageBundle.getMessage("angal.common.all.txt")); + medicalTypeComboBox.addItem(medicalType); + for (MedicalType medType: medicalTypes) { + medicalTypeComboBox.addItem(medType); + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + + medicalTypeComboBox.addActionListener(actionEvent -> { + medicalTypeSelected = (MedicalType) medicalTypeComboBox.getSelectedItem(); + }); + } + return medicalTypeComboBox; + } + + private JRadioButton getAllRadioButton() { + if (radioButtonAll == null) { + radioButtonAll = new JRadioButton(MessageBundle.getMessage("angal.common.all.btn")); + radioButtonAll.setMnemonic(MessageBundle.getMnemonic("angal.common.all.btn.key")); + radioButtonAll.setSelected(true); + } + radioButtonAll.addActionListener(actionEvent -> { + if (radioButtonAll.isSelected()) { + radioOnlyNonZero.setSelected(false); + radioWithMovement.setSelected(false); + } + }); + return radioButtonAll; + } + + private JRadioButton getMedicalWithNonZeroQuatityRadioButton() { + if (radioOnlyNonZero == null) { + radioOnlyNonZero = new JRadioButton(MessageBundle.getMessage("angal.inventory.medicalwithonlynonzeroqty.btn")); + radioOnlyNonZero.setMnemonic(MessageBundle.getMnemonic("angal.inventory.medicalwithonlynonzeroqty.btn.key")); + } + radioOnlyNonZero.addActionListener(actionEvent -> { + if (radioOnlyNonZero.isSelected()) { + radioButtonAll.setSelected(false); + radioWithMovement.setSelected(false); + } + }); + return radioOnlyNonZero; + } + + private JRadioButton getMedicalWithMovementRadioButton() { + if (radioWithMovement == null) { + radioWithMovement = new JRadioButton(MessageBundle.getMessage("angal.inventory.medicalwithmovementonly.btn")); + radioWithMovement.setMnemonic(MessageBundle.getMnemonic("angal.inventory.medicalwithmovementonly.btn.key")); + } + radioWithMovement.addActionListener(actionEvent -> { + if (radioWithMovement.isSelected()) { + radioButtonAll.setSelected(false); + radioOnlyNonZero.setSelected(false); + } + }); + return radioWithMovement; + } + + private JButton getCancelButton() { + if (jButtonCancel == null) { + jButtonCancel = new JButton(MessageBundle.getMessage("angal.common.cancel.btn")); + jButtonCancel.setMnemonic(MessageBundle.getMnemonic("angal.common.cancel.btn.key")); + } + jButtonCancel.addActionListener(actionEvent -> { + frame.dispose(); + }); + return jButtonCancel; + } + private List loadNewInventoryTable(boolean withNonZeroQty, MedicalType medicalTypeSelected) throws OHServiceException { + List inventoryRowsList = getMedicalInventoryRows(null); + if (withNonZeroQty) { + inventoryRowsList = inventoryRowsList.stream().filter(inv -> inv.getTheoreticQty() > 0).collect(Collectors.toList()); + } + if (medicalTypeSelected != null) { + inventoryRowsList = inventoryRowsList.stream().filter(inv -> inv.getMedical().getType().getDescription().equals(medicalTypeSelected.getDescription())).collect(Collectors.toList()); + } + return inventoryRowsList; + } + + private List loadNewInventoryTable(MedicalType medicalTypeSelected, boolean withMovement) throws OHServiceException { + List inventoryRowsList = getMedicalInventoryRowsWithMovement(); + if (medicalTypeSelected != null) { + inventoryRowsList = inventoryRowsList.stream().filter(inv -> inv.getMedical().getType().getDescription().equals(medicalTypeSelected.getDescription())).collect(Collectors.toList()); + } + return inventoryRowsList; + } + + private JButton getOkButton() { + if (jButtonOk == null) { + jButtonOk = new JButton(MessageBundle.getMessage("angal.common.ok.btn")); + jButtonOk.setMnemonic(MessageBundle.getMnemonic("angal.common.ok.btn.key")); + jButtonOk.addActionListener(actionEvent -> { + try { + medicalTypeSelected = (MedicalType) medicalTypeComboBox.getSelectedItem(); + if (radioButtonAll.isSelected()) { + if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { + if (!areAllMedicalsInInventory()) { + codeTextField.setEnabled(false); + codeTextField.setText(""); + if (inventoryRowSearchList.size() > 0) { + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); + if (info == JOptionPane.YES_OPTION) { + try { + jTableInventoryRow.setModel(new InventoryRowModel(true)); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } else { + specificRadio.setSelected(true); + } + + } else { + try { + jTableInventoryRow.setModel(new InventoryRowModel(true)); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + fireInventoryUpdated(); + code = null; + adjustWidth(); + jButtonCancel.doClick(); + MessageDialog.info(null, "angal.invetory.allmedicaladdedsuccessfully.msg"); + } else { + jButtonCancel.doClick(); + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } else { + if (!areAllMedicalsInInventory()) { + codeTextField.setEnabled(false); + codeTextField.setText(""); + if (inventoryRowSearchList.size() > 0) { + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); + if (info == JOptionPane.YES_OPTION) { + try { + jTableInventoryRow.setModel(new InventoryRowModel(medicalTypeSelected)); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } else { + specificRadio.setSelected(true); + } + + } else { + try { + jTableInventoryRow.setModel(new InventoryRowModel(medicalTypeSelected)); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + fireInventoryUpdated(); + code = null; + adjustWidth(); + jButtonCancel.doClick(); + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } else { + jButtonCancel.doClick(); + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } + } + if (radioOnlyNonZero.isSelected()) { + if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { + if (!areAllMedicalsInInventory()) { + codeTextField.setEnabled(false); + codeTextField.setText(""); + if (inventoryRowSearchList.size() > 0) { + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); + if (info == JOptionPane.YES_OPTION) { + jTableInventoryRow.setModel(new InventoryRowModel(true, null)); + } else { + specificRadio.setSelected(true); + } + + } else { + try { + jTableInventoryRow.setModel(new InventoryRowModel(true, null)); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + fireInventoryUpdated(); + code = null; + adjustWidth(); + jButtonCancel.doClick(); + if (inventoryRowList.size() > 0) { + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } + } else { + jButtonCancel.doClick(); + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } else { + if (!areAllMedicalsInInventory()) { + codeTextField.setEnabled(false); + codeTextField.setText(""); + if (inventoryRowSearchList.size() > 0) { + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); + if (info == JOptionPane.YES_OPTION) { + jTableInventoryRow.setModel(new InventoryRowModel(true, medicalTypeSelected)); + } else { + specificRadio.setSelected(true); + } + + } else { + try { + jTableInventoryRow.setModel(new InventoryRowModel(true, medicalTypeSelected)); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + fireInventoryUpdated(); + code = null; + adjustWidth(); + jButtonCancel.doClick(); + if (inventoryRowList.size() > 0) { + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } + } else { + jButtonCancel.doClick(); + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } + } + if (radioWithMovement.isSelected()) { + if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { + if (!areAllMedicalsInInventory()) { + codeTextField.setEnabled(false); + codeTextField.setText(""); + if (inventoryRowSearchList.size() > 0) { + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); + if (info == JOptionPane.YES_OPTION) { + jTableInventoryRow.setModel(new InventoryRowModel(null, true)); + } else { + specificRadio.setSelected(true); + } + + } else { + try { + jTableInventoryRow.setModel(new InventoryRowModel(null, true)); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + fireInventoryUpdated(); + code = null; + adjustWidth(); + jButtonCancel.doClick(); + if (inventoryRowList.size() > 0) { + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } + } else { + jButtonCancel.doClick(); + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } else { + if (!areAllMedicalsInInventory()) { + codeTextField.setEnabled(false); + codeTextField.setText(""); + if (inventoryRowSearchList.size() > 0) { + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); + if (info == JOptionPane.YES_OPTION) { + jTableInventoryRow.setModel(new InventoryRowModel(medicalTypeSelected, true)); + } else { + specificRadio.setSelected(true); + } + + } else { + try { + jTableInventoryRow.setModel(new InventoryRowModel(medicalTypeSelected, true)); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + fireInventoryUpdated(); + code = null; + adjustWidth(); + jButtonCancel.doClick(); + if (inventoryRowList.size() > 0) { + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } + } else { + jButtonCancel.doClick(); + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + }); + } + return jButtonOk; + } private boolean areAllMedicalsInInventory() throws OHServiceException { List medicals = medicalBrowsingManager.getMedicals(); Set inventorySet = new HashSet<>(); From c5bbd622c04ff8ebf7a54ec34813f001aa57e2f6 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud Date: Fri, 22 Nov 2024 11:02:05 +0100 Subject: [PATCH 074/147] Update InventoryEdit.java --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 88cae00c1e..5fd92d30b9 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -2462,4 +2462,4 @@ private boolean areAllMedicalsInInventory() throws OHServiceException { } return false; } -} \ No newline at end of file +} From 8ef6594bafa913695f124e4a1b0196894f9e3445 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud Date: Fri, 22 Nov 2024 12:02:29 +0100 Subject: [PATCH 075/147] Update InventoryEdit.java --- .../java/org/isf/medicalinventory/gui/InventoryEdit.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 5fd92d30b9..44adab227a 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -282,17 +282,12 @@ private void initComponents() { setTitle(MessageBundle.getMessage("angal.inventory.editinventory.title")); } getContentPane().setLayout(new BorderLayout()); - panelHeader = getPanelHeader(); - getContentPane().add(panelHeader, BorderLayout.NORTH); - panelContent = getPanelContent(); getContentPane().add(panelContent, BorderLayout.CENTER); - panelFooter = getPanelFooter(); getContentPane().add(panelFooter, BorderLayout.SOUTH); - addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { From f1a23baa50b74ef2365b6b82519d23a2bd2f5dc0 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Fri, 22 Nov 2024 15:14:32 +0100 Subject: [PATCH 076/147] update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java --- .../isf/medicalinventory/gui/InventoryEdit.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 5fd92d30b9..9c5f789a7d 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -73,6 +73,8 @@ import javax.swing.event.EventListenerList; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; @@ -1183,9 +1185,23 @@ public void valueChanged(ListSelectionEvent e) { }); DefaultCellEditor cellEditor = new DefaultCellEditor(jTextFieldEditor); jTableInventoryRow.setDefaultEditor(Integer.class, cellEditor); + model.addTableModelListener(new TableModelListener() { + @Override + public void tableChanged(TableModelEvent e) { + updateListFromModel(); + } + }); } return jTableInventoryRow; } + private void updateListFromModel() { + for (int i = 0; i < model.getRowCount(); i++) { + jTableInventoryRow.convertRowIndexToView(i); + } + for (int i = 0; i < model.getColumnCount(); i++) { + jTableInventoryRow.convertColumnIndexToView(i); + } + } class EnabledTableCellRenderer extends DefaultTableCellRenderer { From bc8e472c7b1b423e064d095413b8ac7feee48e07 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Fri, 22 Nov 2024 15:52:10 +0100 Subject: [PATCH 077/147] update InventoryEdit --- .../isf/medicalinventory/gui/InventoryEdit.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 66d4561673..e65325aab4 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1180,23 +1180,9 @@ public void valueChanged(ListSelectionEvent e) { }); DefaultCellEditor cellEditor = new DefaultCellEditor(jTextFieldEditor); jTableInventoryRow.setDefaultEditor(Integer.class, cellEditor); - model.addTableModelListener(new TableModelListener() { - @Override - public void tableChanged(TableModelEvent e) { - updateListFromModel(); - } - }); } return jTableInventoryRow; } - private void updateListFromModel() { - for (int i = 0; i < model.getRowCount(); i++) { - jTableInventoryRow.convertRowIndexToView(i); - } - for (int i = 0; i < model.getColumnCount(); i++) { - jTableInventoryRow.convertColumnIndexToView(i); - } - } class EnabledTableCellRenderer extends DefaultTableCellRenderer { From 64f1251fe12f184d779052fede4d171de11075fa Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud Date: Tue, 26 Nov 2024 07:35:50 +0100 Subject: [PATCH 078/147] Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java Co-authored-by: David B Malkovsky --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index e65325aab4..651faa3af5 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -540,7 +540,7 @@ private JButton getSelectedButton() { frame.setSize(450, 200); frame.setTitle(MessageBundle.getMessage("angal.inventoryrow.lotinformation.title")); frame.setLocationRelativeTo(null); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setVisible(true); }); } From 2ab4948f23a972c043ab98063ff40870929594b2 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud Date: Tue, 26 Nov 2024 07:36:18 +0100 Subject: [PATCH 079/147] Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java Co-authored-by: David B Malkovsky --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 651faa3af5..7f959a8522 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1786,7 +1786,7 @@ private List getMedicalInventoryRowsWithMovement() throws O private void addInventoryRow(String code) throws OHServiceException { List inventoryRowsList = new ArrayList(); - List medicalList = new ArrayList(); + List medicalList = new ArrayList<>(); List lots = null; Medical medical = null; MedicalInventoryRow inventoryRowTemp = null; From 3521d3342db5954add21f3e26a91c156431410c0 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud Date: Tue, 26 Nov 2024 07:36:39 +0100 Subject: [PATCH 080/147] Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java Co-authored-by: David B Malkovsky --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 7f959a8522..1715fc2c3d 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1785,7 +1785,7 @@ private List getMedicalInventoryRowsWithMovement() throws O } private void addInventoryRow(String code) throws OHServiceException { - List inventoryRowsList = new ArrayList(); + List inventoryRowsList = new ArrayList<>(); List medicalList = new ArrayList<>(); List lots = null; Medical medical = null; From 0e5957f036f95acddab18022977a46cd7bba7107 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud Date: Tue, 26 Nov 2024 07:51:30 +0100 Subject: [PATCH 081/147] Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java Co-authored-by: David B Malkovsky --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 1715fc2c3d..6a0a68051f 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -2150,7 +2150,7 @@ private boolean checkParameters(String wardCode, String chargeCode, String disch private JComboBox getJComboMedicalType() { if (medicalTypeComboBox == null) { - medicalTypeComboBox = new JComboBox(); + medicalTypeComboBox = new JComboBox<>(); try { List medicalTypes = medicalTypeManager.getMedicalType(); MedicalType medicalType = new MedicalType(MessageBundle.getMessage("angal.common.all.txt"), MessageBundle.getMessage("angal.common.all.txt")); From ccbcb2c29c5b40c7b4628c2e414606cf20d1911a Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Tue, 26 Nov 2024 07:53:08 +0100 Subject: [PATCH 082/147] apply suggestion --- .../medicalinventory/gui/InventoryEdit.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index e65325aab4..10f9f362ef 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -73,8 +73,6 @@ import javax.swing.event.EventListenerList; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; @@ -239,6 +237,7 @@ private void fireInventoryUpdated() { private JButton jButtonOk; private MedicalType medicalTypeSelected; private JComboBox medicalTypeComboBox; + private List medicals = new ArrayList<>(); private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); private MedicalInventoryRowManager medicalInventoryRowManager = Context.getApplicationContext().getBean(MedicalInventoryRowManager.class); private MedicalBrowsingManager medicalBrowsingManager = Context.getApplicationContext().getBean(MedicalBrowsingManager.class); @@ -271,6 +270,11 @@ public InventoryEdit(MedicalInventory inventory, String mod) { private void initComponents() { inventoryRowList = new ArrayList<>(); inventoryRowSearchList = new ArrayList<>(); + try { + medicals = medicalBrowsingManager.getMedicals(); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setMinimumSize(new Dimension(1000, 600)); setLocationRelativeTo(null); @@ -1801,7 +1805,7 @@ private void addInventoryRow(String code) throws OHServiceException { } } } else { - medicalList = medicalBrowsingManager.getMedicals(); + medicalList = medicals; } int numberOfMedicalWithoutSameLotAdded = 0; Medical medicalWithLot = null; @@ -1847,7 +1851,6 @@ private void addInventoryRow(String code) throws OHServiceException { private Medical chooseMedical(String text) throws OHServiceException { Map medicalMap; - List medicals = medicalBrowsingManager.getMedicals(); medicalMap = new HashMap(); for (Medical med : medicals) { String key = med.getProdCode().toLowerCase(); @@ -2253,7 +2256,7 @@ private JButton getOkButton() { if (!areAllMedicalsInInventory()) { codeTextField.setEnabled(false); codeTextField.setText(""); - if (inventoryRowSearchList.size() > 0) { + if (!inventoryRowSearchList.isEmpty()) { int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); if (info == JOptionPane.YES_OPTION) { try { @@ -2285,7 +2288,7 @@ private JButton getOkButton() { if (!areAllMedicalsInInventory()) { codeTextField.setEnabled(false); codeTextField.setText(""); - if (inventoryRowSearchList.size() > 0) { + if (!inventoryRowSearchList.isEmpty()) { int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); if (info == JOptionPane.YES_OPTION) { try { @@ -2320,7 +2323,7 @@ private JButton getOkButton() { if (!areAllMedicalsInInventory()) { codeTextField.setEnabled(false); codeTextField.setText(""); - if (inventoryRowSearchList.size() > 0) { + if (!inventoryRowSearchList.isEmpty()) { int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); if (info == JOptionPane.YES_OPTION) { jTableInventoryRow.setModel(new InventoryRowModel(true, null)); @@ -2339,7 +2342,7 @@ private JButton getOkButton() { code = null; adjustWidth(); jButtonCancel.doClick(); - if (inventoryRowList.size() > 0) { + if (!inventoryRowList.isEmpty()) { MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); } } else { @@ -2350,7 +2353,7 @@ private JButton getOkButton() { if (!areAllMedicalsInInventory()) { codeTextField.setEnabled(false); codeTextField.setText(""); - if (inventoryRowSearchList.size() > 0) { + if (!inventoryRowSearchList.isEmpty()) { int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); if (info == JOptionPane.YES_OPTION) { jTableInventoryRow.setModel(new InventoryRowModel(true, medicalTypeSelected)); @@ -2369,7 +2372,7 @@ private JButton getOkButton() { code = null; adjustWidth(); jButtonCancel.doClick(); - if (inventoryRowList.size() > 0) { + if (!inventoryRowList.isEmpty()) { MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); } } else { @@ -2383,7 +2386,7 @@ private JButton getOkButton() { if (!areAllMedicalsInInventory()) { codeTextField.setEnabled(false); codeTextField.setText(""); - if (inventoryRowSearchList.size() > 0) { + if (!inventoryRowSearchList.isEmpty()) { int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); if (info == JOptionPane.YES_OPTION) { jTableInventoryRow.setModel(new InventoryRowModel(null, true)); @@ -2402,7 +2405,7 @@ private JButton getOkButton() { code = null; adjustWidth(); jButtonCancel.doClick(); - if (inventoryRowList.size() > 0) { + if (!inventoryRowList.isEmpty()) { MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); } } else { @@ -2413,7 +2416,7 @@ private JButton getOkButton() { if (!areAllMedicalsInInventory()) { codeTextField.setEnabled(false); codeTextField.setText(""); - if (inventoryRowSearchList.size() > 0) { + if (!inventoryRowSearchList.isEmpty()) { int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); if (info == JOptionPane.YES_OPTION) { jTableInventoryRow.setModel(new InventoryRowModel(medicalTypeSelected, true)); @@ -2432,7 +2435,7 @@ private JButton getOkButton() { code = null; adjustWidth(); jButtonCancel.doClick(); - if (inventoryRowList.size() > 0) { + if (!inventoryRowList.isEmpty()) { MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); } } else { @@ -2449,7 +2452,6 @@ private JButton getOkButton() { return jButtonOk; } private boolean areAllMedicalsInInventory() throws OHServiceException { - List medicals = medicalBrowsingManager.getMedicals(); Set inventorySet = new HashSet<>(); for (MedicalInventoryRow row : inventoryRowSearchList) { inventorySet.add(row.getMedical()); From 5bcb4691de7df0c1cf6342447aee6d9686d6be4c Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Tue, 26 Nov 2024 09:57:57 +0100 Subject: [PATCH 083/147] apply suggestion --- .../medicalinventory/gui/InventoryEdit.java | 623 +++++++++--------- 1 file changed, 314 insertions(+), 309 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index eb3187288b..d0402ca859 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -69,6 +69,7 @@ import javax.swing.JTextField; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; +import javax.swing.WindowConstants; import javax.swing.border.EmptyBorder; import javax.swing.event.EventListenerList; import javax.swing.event.ListSelectionEvent; @@ -247,7 +248,7 @@ private void fireInventoryUpdated() { private WardBrowserManager wardManager = Context.getApplicationContext().getBean(WardBrowserManager.class); private MedicalTypeBrowserManager medicalTypeManager = Context.getApplicationContext().getBean(MedicalTypeBrowserManager.class); private MovBrowserManager movBrowserManager = Context.getApplicationContext().getBean(MovBrowserManager.class); - + public InventoryEdit() { mode = "new"; initComponents(); @@ -510,42 +511,42 @@ private JButton getSelectedButton() { selectButton.setMnemonic(MessageBundle.getMnemonic("angal.common.select.btn.key")); selectButton.addActionListener(actionEvent -> { specificRadio.setSelected(false); - mainPanel = new JPanel(); - mainPanel.setLayout(new BorderLayout(10, 10)); - - JPanel leftPanel = new JPanel(); - leftPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 20)); - leftPanel.setLayout(new GridLayout(3,1)); - leftPanel.add(new JLabel(MessageBundle.getMessage("angal.inventoryrow.medicaltype.txt"))); - leftPanel.add(getJComboMedicalType()); - - ButtonGroup radioGroup = new ButtonGroup(); - radioGroup.add(radioButtonAll); - radioGroup.add(radioOnlyNonZero); - radioGroup.add(radioWithMovement); - - JPanel rightPanel = new JPanel(); - rightPanel.setLayout(new GridLayout(3, 1, 5, 5)); - rightPanel.add(getAllRadioButton()); - rightPanel.add(getMedicalWithNonZeroQuatityRadioButton()); - rightPanel.add(getMedicalWithMovementRadioButton()); - - JPanel bottomPanel = new JPanel(); - bottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); - bottomPanel.add(getOkButton()); - bottomPanel.add(getCancelButton()); - - mainPanel.add(leftPanel, BorderLayout.WEST); - mainPanel.add(rightPanel, BorderLayout.EAST); - mainPanel.add(bottomPanel, BorderLayout.SOUTH); - - frame = new JFrame(); - frame.add(mainPanel); - frame.setSize(450, 200); - frame.setTitle(MessageBundle.getMessage("angal.inventoryrow.lotinformation.title")); - frame.setLocationRelativeTo(null); - frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - frame.setVisible(true); + mainPanel = new JPanel(); + mainPanel.setLayout(new BorderLayout(10, 10)); + + JPanel leftPanel = new JPanel(); + leftPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 20)); + leftPanel.setLayout(new GridLayout(3, 1)); + leftPanel.add(new JLabel(MessageBundle.getMessage("angal.inventoryrow.medicaltype.txt"))); + leftPanel.add(getJComboMedicalType()); + + ButtonGroup radioGroup = new ButtonGroup(); + radioGroup.add(radioButtonAll); + radioGroup.add(radioOnlyNonZero); + radioGroup.add(radioWithMovement); + + JPanel rightPanel = new JPanel(); + rightPanel.setLayout(new GridLayout(3, 1, 5, 5)); + rightPanel.add(getAllRadioButton()); + rightPanel.add(getMedicalWithNonZeroQuatityRadioButton()); + rightPanel.add(getMedicalWithMovementRadioButton()); + + JPanel bottomPanel = new JPanel(); + bottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); + bottomPanel.add(getOkButton()); + bottomPanel.add(getCancelButton()); + + mainPanel.add(leftPanel, BorderLayout.WEST); + mainPanel.add(rightPanel, BorderLayout.EAST); + mainPanel.add(bottomPanel, BorderLayout.SOUTH); + + frame = new JFrame(); + frame.add(mainPanel); + frame.setSize(450, 200); + frame.setTitle(MessageBundle.getMessage("angal.inventoryrow.lotinformation.title")); + frame.setLocationRelativeTo(null); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + frame.setVisible(true); }); } return selectButton; @@ -742,7 +743,7 @@ private JButton getSaveButton() { medicalInventoryRow.setLot(newLot); medicalInventoryRow.setNewLot(true); } - + } } medicalInventoryRow.setInventory(inventory); @@ -965,7 +966,7 @@ private JButton getCleanTableButton() { } else { inventoryRowSearchList.clear(); } - + } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } @@ -1006,7 +1007,7 @@ private JButton getValidateButton() { String wardCode = inventory.getDestination(); String lastReference = inventory.getInventoryReference(); LocalDateTime lastDate = inventory.getInventoryDate(); - if (checkParameters(wardCode, chargeCode, dischargeCode, supplierId, lastReference, lastDate) || !lotsSaved.isEmpty() + if (checkParameters(wardCode, chargeCode, dischargeCode, supplierId, lastReference, lastDate) || !lotsSaved.isEmpty() || !inventoryRowListAdded.isEmpty() || !inventoryRowsToDelete.isEmpty()) { saveButton.doClick(); chargeCode = inventory.getChargeType(); @@ -1244,10 +1245,10 @@ public InventoryRowModel() throws OHServiceException { codeTextField.setEnabled(true); } } - + public InventoryRowModel(MedicalType medType) throws OHServiceException { inventoryRowList.clear(); - inventoryRowList = loadNewInventoryTable(medType); + inventoryRowList = loadNewInventoryTableByMedicalType(medType); if (!inventoryRowList.isEmpty()) { for (MedicalInventoryRow invRow : inventoryRowList) { addMedInRowInInventorySearchList(invRow); @@ -1280,10 +1281,10 @@ public InventoryRowModel(boolean withZeroQty, MedicalType medType) throws OHServ codeTextField.setEnabled(true); } } - + public InventoryRowModel(MedicalType medType, boolean withMovement) throws OHServiceException { inventoryRowList.clear(); - inventoryRowList = loadNewInventoryTable(medType, withMovement); + inventoryRowList = loadNewInventoryTable(medType); if (!inventoryRowList.isEmpty()) { for (MedicalInventoryRow invRow : inventoryRowList) { addMedInRowInInventorySearchList(invRow); @@ -1671,8 +1672,8 @@ private List loadNewInventoryTable(String code, MedicalInve } return inventoryRowsList; } - - private List loadNewInventoryTable(MedicalType medicalType) throws OHServiceException { + + private List loadNewInventoryTableByMedicalType(MedicalType medicalType) throws OHServiceException { return getMedicalInventoryRowsByMedicalType(medicalType); } @@ -1718,11 +1719,11 @@ private List getMedicalInventoryRows(String code) throws OH } return inventoryRowsList; } - + private List getMedicalInventoryRowsByMedicalType(MedicalType medType) throws OHServiceException { List inventoryRowsList = new ArrayList<>(); String medTypeDescription = medType.getDescription(); - List medicalList = medicalBrowsingManager.getMedicals(medTypeDescription, false); + List medicalList = medicalBrowsingManager.getMedicals(medTypeDescription, false); List lots = null; MedicalInventoryRow inventoryRowTemp = null; ListIterator medicalListIterator = medicalList.listIterator(); @@ -1748,7 +1749,7 @@ private List getMedicalInventoryRowsByMedicalType(MedicalTy } return inventoryRowsList; } - + private List getMedicalInventoryRowsWithMovement() throws OHServiceException { List inventoryRowsList = new ArrayList<>(); List medicalListWithMovement = new ArrayList<>(); @@ -1787,7 +1788,7 @@ private List getMedicalInventoryRowsWithMovement() throws O } return inventoryRowsList; } - + private void addInventoryRow(String code) throws OHServiceException { List inventoryRowsList = new ArrayList<>(); List medicalList = new ArrayList<>(); @@ -1939,7 +1940,7 @@ private JLabel getSupplierLabel() { } return supplierLabel; } - + private JLabel getAddProductLabel() { if (addProductLabel == null) { addProductLabel = new JLabel(MessageBundle.getMessage("angal.inventory.addproduct.label")); @@ -2136,63 +2137,63 @@ private void resetVariable() { inventoryRowListAdded.clear(); lotsSaved.clear(); } - + private boolean checkParameters(String wardCode, String chargeCode, String dischargeCode, Integer suplierId, String reference, LocalDateTime date) { if (!lotsSaved.isEmpty() || !inventoryRowListAdded.isEmpty() || !lotsDeleted.isEmpty() || !inventoryRowsToDelete.isEmpty() - || (destination != null && !destination.getCode().equals(wardCode)) - || (chargeType != null && !chargeType.getCode().equals(chargeCode)) - || (dischargeType != null && !dischargeType.getCode().equals(dischargeCode)) - || (supplier != null && !supplier.getSupId().equals(suplierId)) || (destination == null && wardCode != null) - || (chargeType == null && chargeCode != null) || (dischargeType == null && dischargeCode != null) - || (supplier == null && suplierId != null) || (reference != null && !reference.equals(newReference)) - || !date.toLocalDate().equals(dateInventory.toLocalDate())) { + || (destination != null && !destination.getCode().equals(wardCode)) + || (chargeType != null && !chargeType.getCode().equals(chargeCode)) + || (dischargeType != null && !dischargeType.getCode().equals(dischargeCode)) + || (supplier != null && !supplier.getSupId().equals(suplierId)) || (destination == null && wardCode != null) + || (chargeType == null && chargeCode != null) || (dischargeType == null && dischargeCode != null) + || (supplier == null && suplierId != null) || (reference != null && !reference.equals(newReference)) + || !date.toLocalDate().equals(dateInventory.toLocalDate())) { return true; } return false; } - + private JComboBox getJComboMedicalType() { if (medicalTypeComboBox == null) { medicalTypeComboBox = new JComboBox<>(); try { - List medicalTypes = medicalTypeManager.getMedicalType(); + List medicalTypes = medicalTypeManager.getMedicalType(); MedicalType medicalType = new MedicalType(MessageBundle.getMessage("angal.common.all.txt"), MessageBundle.getMessage("angal.common.all.txt")); medicalTypeComboBox.addItem(medicalType); - for (MedicalType medType: medicalTypes) { + for (MedicalType medType : medicalTypes) { medicalTypeComboBox.addItem(medType); } } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } - + medicalTypeComboBox.addActionListener(actionEvent -> { medicalTypeSelected = (MedicalType) medicalTypeComboBox.getSelectedItem(); }); } return medicalTypeComboBox; } - - private JRadioButton getAllRadioButton() { - if (radioButtonAll == null) { - radioButtonAll = new JRadioButton(MessageBundle.getMessage("angal.common.all.btn")); - radioButtonAll.setMnemonic(MessageBundle.getMnemonic("angal.common.all.btn.key")); - radioButtonAll.setSelected(true); - } - radioButtonAll.addActionListener(actionEvent -> { - if (radioButtonAll.isSelected()) { - radioOnlyNonZero.setSelected(false); + + private JRadioButton getAllRadioButton() { + if (radioButtonAll == null) { + radioButtonAll = new JRadioButton(MessageBundle.getMessage("angal.common.all.btn")); + radioButtonAll.setMnemonic(MessageBundle.getMnemonic("angal.common.all.btn.key")); + radioButtonAll.setSelected(true); + } + radioButtonAll.addActionListener(actionEvent -> { + if (radioButtonAll.isSelected()) { + radioOnlyNonZero.setSelected(false); radioWithMovement.setSelected(false); } }); return radioButtonAll; } - - private JRadioButton getMedicalWithNonZeroQuatityRadioButton() { - if (radioOnlyNonZero == null) { - radioOnlyNonZero = new JRadioButton(MessageBundle.getMessage("angal.inventory.medicalwithonlynonzeroqty.btn")); - radioOnlyNonZero.setMnemonic(MessageBundle.getMnemonic("angal.inventory.medicalwithonlynonzeroqty.btn.key")); - } - radioOnlyNonZero.addActionListener(actionEvent -> { + + private JRadioButton getMedicalWithNonZeroQuatityRadioButton() { + if (radioOnlyNonZero == null) { + radioOnlyNonZero = new JRadioButton(MessageBundle.getMessage("angal.inventory.medicalwithonlynonzeroqty.btn")); + radioOnlyNonZero.setMnemonic(MessageBundle.getMnemonic("angal.inventory.medicalwithonlynonzeroqty.btn.key")); + } + radioOnlyNonZero.addActionListener(actionEvent -> { if (radioOnlyNonZero.isSelected()) { radioButtonAll.setSelected(false); radioWithMovement.setSelected(false); @@ -2200,258 +2201,262 @@ private JRadioButton getMedicalWithNonZeroQuatityRadioButton() { }); return radioOnlyNonZero; } - - private JRadioButton getMedicalWithMovementRadioButton() { - if (radioWithMovement == null) { - radioWithMovement = new JRadioButton(MessageBundle.getMessage("angal.inventory.medicalwithmovementonly.btn")); - radioWithMovement.setMnemonic(MessageBundle.getMnemonic("angal.inventory.medicalwithmovementonly.btn.key")); - } - radioWithMovement.addActionListener(actionEvent -> { - if (radioWithMovement.isSelected()) { - radioButtonAll.setSelected(false); - radioOnlyNonZero.setSelected(false); + + private JRadioButton getMedicalWithMovementRadioButton() { + if (radioWithMovement == null) { + radioWithMovement = new JRadioButton(MessageBundle.getMessage("angal.inventory.medicalwithmovementonly.btn")); + radioWithMovement.setMnemonic(MessageBundle.getMnemonic("angal.inventory.medicalwithmovementonly.btn.key")); + } + radioWithMovement.addActionListener(actionEvent -> { + if (radioWithMovement.isSelected()) { + radioButtonAll.setSelected(false); + radioOnlyNonZero.setSelected(false); } }); return radioWithMovement; } - - private JButton getCancelButton() { - if (jButtonCancel == null) { - jButtonCancel = new JButton(MessageBundle.getMessage("angal.common.cancel.btn")); - jButtonCancel.setMnemonic(MessageBundle.getMnemonic("angal.common.cancel.btn.key")); - } + + private JButton getCancelButton() { + if (jButtonCancel == null) { + jButtonCancel = new JButton(MessageBundle.getMessage("angal.common.cancel.btn")); + jButtonCancel.setMnemonic(MessageBundle.getMnemonic("angal.common.cancel.btn.key")); + } jButtonCancel.addActionListener(actionEvent -> { frame.dispose(); }); return jButtonCancel; } - private List loadNewInventoryTable(boolean withNonZeroQty, MedicalType medicalTypeSelected) throws OHServiceException { + private List loadNewInventoryTable(boolean withNonZeroQty, MedicalType medicalTypeSelected) throws OHServiceException { List inventoryRowsList = getMedicalInventoryRows(null); if (withNonZeroQty) { inventoryRowsList = inventoryRowsList.stream().filter(inv -> inv.getTheoreticQty() > 0).collect(Collectors.toList()); } if (medicalTypeSelected != null) { - inventoryRowsList = inventoryRowsList.stream().filter(inv -> inv.getMedical().getType().getDescription().equals(medicalTypeSelected.getDescription())).collect(Collectors.toList()); + inventoryRowsList = inventoryRowsList.stream() + .filter(inv -> inv.getMedical().getType().getDescription().equals(medicalTypeSelected.getDescription())) + .collect(Collectors.toList()); } return inventoryRowsList; } - - private List loadNewInventoryTable(MedicalType medicalTypeSelected, boolean withMovement) throws OHServiceException { + + private List loadNewInventoryTable(MedicalType medicalTypeSelected) throws OHServiceException { List inventoryRowsList = getMedicalInventoryRowsWithMovement(); if (medicalTypeSelected != null) { - inventoryRowsList = inventoryRowsList.stream().filter(inv -> inv.getMedical().getType().getDescription().equals(medicalTypeSelected.getDescription())).collect(Collectors.toList()); + inventoryRowsList = inventoryRowsList.stream() + .filter(inv -> inv.getMedical().getType().getDescription().equals(medicalTypeSelected.getDescription())) + .collect(Collectors.toList()); } return inventoryRowsList; } - - private JButton getOkButton() { - if (jButtonOk == null) { - jButtonOk = new JButton(MessageBundle.getMessage("angal.common.ok.btn")); - jButtonOk.setMnemonic(MessageBundle.getMnemonic("angal.common.ok.btn.key")); - jButtonOk.addActionListener(actionEvent -> { - try { - medicalTypeSelected = (MedicalType) medicalTypeComboBox.getSelectedItem(); - if (radioButtonAll.isSelected()) { - if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { - if (!areAllMedicalsInInventory()) { - codeTextField.setEnabled(false); - codeTextField.setText(""); - if (!inventoryRowSearchList.isEmpty()) { - int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); - if (info == JOptionPane.YES_OPTION) { - try { - jTableInventoryRow.setModel(new InventoryRowModel(true)); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } else { - specificRadio.setSelected(true); - } - - } else { - try { - jTableInventoryRow.setModel(new InventoryRowModel(true)); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - fireInventoryUpdated(); - code = null; - adjustWidth(); - jButtonCancel.doClick(); - MessageDialog.info(null, "angal.invetory.allmedicaladdedsuccessfully.msg"); - } else { - jButtonCancel.doClick(); - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } else { - if (!areAllMedicalsInInventory()) { - codeTextField.setEnabled(false); - codeTextField.setText(""); - if (!inventoryRowSearchList.isEmpty()) { - int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); - if (info == JOptionPane.YES_OPTION) { - try { - jTableInventoryRow.setModel(new InventoryRowModel(medicalTypeSelected)); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } else { - specificRadio.setSelected(true); - } - - } else { - try { - jTableInventoryRow.setModel(new InventoryRowModel(medicalTypeSelected)); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - fireInventoryUpdated(); - code = null; - adjustWidth(); - jButtonCancel.doClick(); - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } else { - jButtonCancel.doClick(); - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } - } - if (radioOnlyNonZero.isSelected()) { - if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { - if (!areAllMedicalsInInventory()) { - codeTextField.setEnabled(false); - codeTextField.setText(""); - if (!inventoryRowSearchList.isEmpty()) { - int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); - if (info == JOptionPane.YES_OPTION) { - jTableInventoryRow.setModel(new InventoryRowModel(true, null)); - } else { - specificRadio.setSelected(true); - } - - } else { - try { - jTableInventoryRow.setModel(new InventoryRowModel(true, null)); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - fireInventoryUpdated(); - code = null; - adjustWidth(); - jButtonCancel.doClick(); - if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } - } else { - jButtonCancel.doClick(); - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } else { - if (!areAllMedicalsInInventory()) { - codeTextField.setEnabled(false); - codeTextField.setText(""); - if (!inventoryRowSearchList.isEmpty()) { - int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); - if (info == JOptionPane.YES_OPTION) { - jTableInventoryRow.setModel(new InventoryRowModel(true, medicalTypeSelected)); - } else { - specificRadio.setSelected(true); - } - - } else { - try { - jTableInventoryRow.setModel(new InventoryRowModel(true, medicalTypeSelected)); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - fireInventoryUpdated(); - code = null; - adjustWidth(); - jButtonCancel.doClick(); - if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } - } else { - jButtonCancel.doClick(); - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } - } - if (radioWithMovement.isSelected()) { - if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { - if (!areAllMedicalsInInventory()) { - codeTextField.setEnabled(false); - codeTextField.setText(""); - if (!inventoryRowSearchList.isEmpty()) { - int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); - if (info == JOptionPane.YES_OPTION) { - jTableInventoryRow.setModel(new InventoryRowModel(null, true)); - } else { - specificRadio.setSelected(true); - } - - } else { - try { - jTableInventoryRow.setModel(new InventoryRowModel(null, true)); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - fireInventoryUpdated(); - code = null; - adjustWidth(); - jButtonCancel.doClick(); - if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } - } else { - jButtonCancel.doClick(); - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } else { - if (!areAllMedicalsInInventory()) { - codeTextField.setEnabled(false); - codeTextField.setText(""); - if (!inventoryRowSearchList.isEmpty()) { - int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); - if (info == JOptionPane.YES_OPTION) { - jTableInventoryRow.setModel(new InventoryRowModel(medicalTypeSelected, true)); - } else { - specificRadio.setSelected(true); - } - - } else { - try { - jTableInventoryRow.setModel(new InventoryRowModel(medicalTypeSelected, true)); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - fireInventoryUpdated(); - code = null; - adjustWidth(); - jButtonCancel.doClick(); - if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } - } else { - jButtonCancel.doClick(); - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } - } - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - }); - } + + private JButton getOkButton() { + if (jButtonOk == null) { + jButtonOk = new JButton(MessageBundle.getMessage("angal.common.ok.btn")); + jButtonOk.setMnemonic(MessageBundle.getMnemonic("angal.common.ok.btn.key")); + jButtonOk.addActionListener(actionEvent -> { + try { + medicalTypeSelected = (MedicalType) medicalTypeComboBox.getSelectedItem(); + if (radioButtonAll.isSelected()) { + if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { + if (!areAllMedicalsInInventory()) { + codeTextField.setEnabled(false); + codeTextField.setText(""); + if (!inventoryRowSearchList.isEmpty()) { + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); + if (info == JOptionPane.YES_OPTION) { + try { + jTableInventoryRow.setModel(new InventoryRowModel(true)); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } else { + specificRadio.setSelected(true); + } + + } else { + try { + jTableInventoryRow.setModel(new InventoryRowModel(true)); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + fireInventoryUpdated(); + code = null; + adjustWidth(); + jButtonCancel.doClick(); + MessageDialog.info(null, "angal.invetory.allmedicaladdedsuccessfully.msg"); + } else { + jButtonCancel.doClick(); + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } else { + if (!areAllMedicalsInInventory()) { + codeTextField.setEnabled(false); + codeTextField.setText(""); + if (!inventoryRowSearchList.isEmpty()) { + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); + if (info == JOptionPane.YES_OPTION) { + try { + jTableInventoryRow.setModel(new InventoryRowModel(medicalTypeSelected)); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } else { + specificRadio.setSelected(true); + } + + } else { + try { + jTableInventoryRow.setModel(new InventoryRowModel(medicalTypeSelected)); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + fireInventoryUpdated(); + code = null; + adjustWidth(); + jButtonCancel.doClick(); + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } else { + jButtonCancel.doClick(); + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } + } + if (radioOnlyNonZero.isSelected()) { + if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { + if (!areAllMedicalsInInventory()) { + codeTextField.setEnabled(false); + codeTextField.setText(""); + if (!inventoryRowSearchList.isEmpty()) { + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); + if (info == JOptionPane.YES_OPTION) { + jTableInventoryRow.setModel(new InventoryRowModel(true, null)); + } else { + specificRadio.setSelected(true); + } + + } else { + try { + jTableInventoryRow.setModel(new InventoryRowModel(true, null)); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + fireInventoryUpdated(); + code = null; + adjustWidth(); + jButtonCancel.doClick(); + if (!inventoryRowList.isEmpty()) { + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } + } else { + jButtonCancel.doClick(); + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } else { + if (!areAllMedicalsInInventory()) { + codeTextField.setEnabled(false); + codeTextField.setText(""); + if (!inventoryRowSearchList.isEmpty()) { + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); + if (info == JOptionPane.YES_OPTION) { + jTableInventoryRow.setModel(new InventoryRowModel(true, medicalTypeSelected)); + } else { + specificRadio.setSelected(true); + } + + } else { + try { + jTableInventoryRow.setModel(new InventoryRowModel(true, medicalTypeSelected)); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + fireInventoryUpdated(); + code = null; + adjustWidth(); + jButtonCancel.doClick(); + if (!inventoryRowList.isEmpty()) { + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } + } else { + jButtonCancel.doClick(); + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } + } + if (radioWithMovement.isSelected()) { + if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { + if (!areAllMedicalsInInventory()) { + codeTextField.setEnabled(false); + codeTextField.setText(""); + if (!inventoryRowSearchList.isEmpty()) { + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); + if (info == JOptionPane.YES_OPTION) { + jTableInventoryRow.setModel(new InventoryRowModel(null, true)); + } else { + specificRadio.setSelected(true); + } + + } else { + try { + jTableInventoryRow.setModel(new InventoryRowModel(null, true)); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + fireInventoryUpdated(); + code = null; + adjustWidth(); + jButtonCancel.doClick(); + if (!inventoryRowList.isEmpty()) { + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } + } else { + jButtonCancel.doClick(); + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } else { + if (!areAllMedicalsInInventory()) { + codeTextField.setEnabled(false); + codeTextField.setText(""); + if (!inventoryRowSearchList.isEmpty()) { + int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); + if (info == JOptionPane.YES_OPTION) { + jTableInventoryRow.setModel(new InventoryRowModel(medicalTypeSelected, true)); + } else { + specificRadio.setSelected(true); + } + + } else { + try { + jTableInventoryRow.setModel(new InventoryRowModel(medicalTypeSelected, true)); + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + fireInventoryUpdated(); + code = null; + adjustWidth(); + jButtonCancel.doClick(); + if (!inventoryRowList.isEmpty()) { + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } + } else { + jButtonCancel.doClick(); + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + }); + } return jButtonOk; - } - private boolean areAllMedicalsInInventory() throws OHServiceException { + } + private boolean areAllMedicalsInInventory() throws OHServiceException { Set inventorySet = new HashSet<>(); for (MedicalInventoryRow row : inventoryRowSearchList) { inventorySet.add(row.getMedical()); From ee19b66f8a49c1b563ce5ccba0a5985159ad8d39 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Tue, 26 Nov 2024 11:04:19 +0100 Subject: [PATCH 084/147] apply suggestion --- .../medicalinventory/gui/InventoryEdit.java | 98 ++++++------------- 1 file changed, 31 insertions(+), 67 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index d0402ca859..3e60202110 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -2226,6 +2226,7 @@ private JButton getCancelButton() { }); return jButtonCancel; } + private List loadNewInventoryTable(boolean withNonZeroQty, MedicalType medicalTypeSelected) throws OHServiceException { List inventoryRowsList = getMedicalInventoryRows(null); if (withNonZeroQty) { @@ -2261,24 +2262,15 @@ private JButton getOkButton() { if (!areAllMedicalsInInventory()) { codeTextField.setEnabled(false); codeTextField.setText(""); - if (!inventoryRowSearchList.isEmpty()) { - int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); - if (info == JOptionPane.YES_OPTION) { - try { - jTableInventoryRow.setModel(new InventoryRowModel(true)); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } else { - specificRadio.setSelected(true); - } - - } else { + int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + if (info == JOptionPane.YES_OPTION) { try { jTableInventoryRow.setModel(new InventoryRowModel(true)); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } + } else { + specificRadio.setSelected(true); } fireInventoryUpdated(); code = null; @@ -2293,24 +2285,15 @@ private JButton getOkButton() { if (!areAllMedicalsInInventory()) { codeTextField.setEnabled(false); codeTextField.setText(""); - if (!inventoryRowSearchList.isEmpty()) { - int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); - if (info == JOptionPane.YES_OPTION) { - try { - jTableInventoryRow.setModel(new InventoryRowModel(medicalTypeSelected)); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } else { - specificRadio.setSelected(true); - } - - } else { + int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + if (info == JOptionPane.YES_OPTION) { try { - jTableInventoryRow.setModel(new InventoryRowModel(medicalTypeSelected)); + jTableInventoryRow.setModel(new InventoryRowModel(true)); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } + } else { + specificRadio.setSelected(true); } fireInventoryUpdated(); code = null; @@ -2328,20 +2311,15 @@ private JButton getOkButton() { if (!areAllMedicalsInInventory()) { codeTextField.setEnabled(false); codeTextField.setText(""); - if (!inventoryRowSearchList.isEmpty()) { - int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); - if (info == JOptionPane.YES_OPTION) { - jTableInventoryRow.setModel(new InventoryRowModel(true, null)); - } else { - specificRadio.setSelected(true); - } - - } else { + int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + if (info == JOptionPane.YES_OPTION) { try { - jTableInventoryRow.setModel(new InventoryRowModel(true, null)); + jTableInventoryRow.setModel(new InventoryRowModel(true)); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } + } else { + specificRadio.setSelected(true); } fireInventoryUpdated(); code = null; @@ -2358,20 +2336,15 @@ private JButton getOkButton() { if (!areAllMedicalsInInventory()) { codeTextField.setEnabled(false); codeTextField.setText(""); - if (!inventoryRowSearchList.isEmpty()) { - int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); - if (info == JOptionPane.YES_OPTION) { - jTableInventoryRow.setModel(new InventoryRowModel(true, medicalTypeSelected)); - } else { - specificRadio.setSelected(true); - } - - } else { + int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + if (info == JOptionPane.YES_OPTION) { try { - jTableInventoryRow.setModel(new InventoryRowModel(true, medicalTypeSelected)); + jTableInventoryRow.setModel(new InventoryRowModel(true)); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } + } else { + specificRadio.setSelected(true); } fireInventoryUpdated(); code = null; @@ -2391,20 +2364,15 @@ private JButton getOkButton() { if (!areAllMedicalsInInventory()) { codeTextField.setEnabled(false); codeTextField.setText(""); - if (!inventoryRowSearchList.isEmpty()) { - int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); - if (info == JOptionPane.YES_OPTION) { - jTableInventoryRow.setModel(new InventoryRowModel(null, true)); - } else { - specificRadio.setSelected(true); - } - - } else { + int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + if (info == JOptionPane.YES_OPTION) { try { - jTableInventoryRow.setModel(new InventoryRowModel(null, true)); + jTableInventoryRow.setModel(new InventoryRowModel(true)); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } + } else { + specificRadio.setSelected(true); } fireInventoryUpdated(); code = null; @@ -2421,20 +2389,15 @@ private JButton getOkButton() { if (!areAllMedicalsInInventory()) { codeTextField.setEnabled(false); codeTextField.setText(""); - if (!inventoryRowSearchList.isEmpty()) { - int info = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg"); - if (info == JOptionPane.YES_OPTION) { - jTableInventoryRow.setModel(new InventoryRowModel(medicalTypeSelected, true)); - } else { - specificRadio.setSelected(true); - } - - } else { + int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + if (info == JOptionPane.YES_OPTION) { try { - jTableInventoryRow.setModel(new InventoryRowModel(medicalTypeSelected, true)); + jTableInventoryRow.setModel(new InventoryRowModel(true)); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } + } else { + specificRadio.setSelected(true); } fireInventoryUpdated(); code = null; @@ -2456,6 +2419,7 @@ private JButton getOkButton() { } return jButtonOk; } + private boolean areAllMedicalsInInventory() throws OHServiceException { Set inventorySet = new HashSet<>(); for (MedicalInventoryRow row : inventoryRowSearchList) { From a1b5506b88ea51582720998d282450e1932f07a9 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Tue, 26 Nov 2024 14:54:36 +0100 Subject: [PATCH 085/147] enhance strategie to fetch medicals --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 3e60202110..7018920c46 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1694,7 +1694,7 @@ private List getMedicalInventoryRows(String code) throws OH } } } else { - medicalList = medicalBrowsingManager.getMedicals(); + medicalList = medicals; } ListIterator medicalListIterator = medicalList.listIterator(); while (medicalListIterator.hasNext()) { @@ -1755,7 +1755,7 @@ private List getMedicalInventoryRowsWithMovement() throws O List medicalListWithMovement = new ArrayList<>(); List lots = null; MedicalInventoryRow inventoryRowTemp = null; - List medicalList = medicalBrowsingManager.getMedicals(); + List medicalList = medicals; ListIterator medicalListIterator = medicalList.listIterator(); while (medicalListIterator.hasNext()) { Medical med = medicalListIterator.next(); From 3314de1d282d410fde5286bfabe88ff7a7e20362 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Fri, 29 Nov 2024 10:58:50 +0100 Subject: [PATCH 086/147] apply suggestion --- .../medicalinventory/gui/InventoryEdit.java | 77 ++++--------------- 1 file changed, 16 insertions(+), 61 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 7018920c46..ba616a881d 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -520,16 +520,16 @@ private JButton getSelectedButton() { leftPanel.add(new JLabel(MessageBundle.getMessage("angal.inventoryrow.medicaltype.txt"))); leftPanel.add(getJComboMedicalType()); - ButtonGroup radioGroup = new ButtonGroup(); - radioGroup.add(radioButtonAll); - radioGroup.add(radioOnlyNonZero); - radioGroup.add(radioWithMovement); - JPanel rightPanel = new JPanel(); rightPanel.setLayout(new GridLayout(3, 1, 5, 5)); rightPanel.add(getAllRadioButton()); rightPanel.add(getMedicalWithNonZeroQuatityRadioButton()); rightPanel.add(getMedicalWithMovementRadioButton()); + + ButtonGroup radioGroup = new ButtonGroup(); + radioGroup.add(radioButtonAll); + radioGroup.add(radioOnlyNonZero); + radioGroup.add(radioWithMovement); JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); @@ -1263,9 +1263,9 @@ public InventoryRowModel(MedicalType medType) throws OHServiceException { } } - public InventoryRowModel(boolean withZeroQty, MedicalType medType) throws OHServiceException { + public InventoryRowModel(boolean withNoZeroQty, MedicalType medType) throws OHServiceException { inventoryRowList.clear(); - inventoryRowList = loadNewInventoryTable(withZeroQty, medType); + inventoryRowList = loadNewInventoryTable(withNoZeroQty, medType); if (!inventoryRowList.isEmpty()) { for (MedicalInventoryRow invRow : inventoryRowList) { addMedInRowInInventorySearchList(invRow); @@ -2179,12 +2179,6 @@ private JRadioButton getAllRadioButton() { radioButtonAll.setMnemonic(MessageBundle.getMnemonic("angal.common.all.btn.key")); radioButtonAll.setSelected(true); } - radioButtonAll.addActionListener(actionEvent -> { - if (radioButtonAll.isSelected()) { - radioOnlyNonZero.setSelected(false); - radioWithMovement.setSelected(false); - } - }); return radioButtonAll; } @@ -2193,12 +2187,6 @@ private JRadioButton getMedicalWithNonZeroQuatityRadioButton() { radioOnlyNonZero = new JRadioButton(MessageBundle.getMessage("angal.inventory.medicalwithonlynonzeroqty.btn")); radioOnlyNonZero.setMnemonic(MessageBundle.getMnemonic("angal.inventory.medicalwithonlynonzeroqty.btn.key")); } - radioOnlyNonZero.addActionListener(actionEvent -> { - if (radioOnlyNonZero.isSelected()) { - radioButtonAll.setSelected(false); - radioWithMovement.setSelected(false); - } - }); return radioOnlyNonZero; } @@ -2207,12 +2195,6 @@ private JRadioButton getMedicalWithMovementRadioButton() { radioWithMovement = new JRadioButton(MessageBundle.getMessage("angal.inventory.medicalwithmovementonly.btn")); radioWithMovement.setMnemonic(MessageBundle.getMnemonic("angal.inventory.medicalwithmovementonly.btn.key")); } - radioWithMovement.addActionListener(actionEvent -> { - if (radioWithMovement.isSelected()) { - radioButtonAll.setSelected(false); - radioOnlyNonZero.setSelected(false); - } - }); return radioWithMovement; } @@ -2260,8 +2242,6 @@ private JButton getOkButton() { if (radioButtonAll.isSelected()) { if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { if (!areAllMedicalsInInventory()) { - codeTextField.setEnabled(false); - codeTextField.setText(""); int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; if (info == JOptionPane.YES_OPTION) { try { @@ -2269,11 +2249,8 @@ private JButton getOkButton() { } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } - } else { - specificRadio.setSelected(true); } fireInventoryUpdated(); - code = null; adjustWidth(); jButtonCancel.doClick(); MessageDialog.info(null, "angal.invetory.allmedicaladdedsuccessfully.msg"); @@ -2283,20 +2260,16 @@ private JButton getOkButton() { } } else { if (!areAllMedicalsInInventory()) { - codeTextField.setEnabled(false); - codeTextField.setText(""); int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; if (info == JOptionPane.YES_OPTION) { try { - jTableInventoryRow.setModel(new InventoryRowModel(true)); + MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); + jTableInventoryRow.setModel(new InventoryRowModel(medType)); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } - } else { - specificRadio.setSelected(true); } fireInventoryUpdated(); - code = null; adjustWidth(); jButtonCancel.doClick(); MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); @@ -2307,22 +2280,18 @@ private JButton getOkButton() { } } if (radioOnlyNonZero.isSelected()) { + MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { if (!areAllMedicalsInInventory()) { - codeTextField.setEnabled(false); - codeTextField.setText(""); int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; if (info == JOptionPane.YES_OPTION) { try { - jTableInventoryRow.setModel(new InventoryRowModel(true)); + jTableInventoryRow.setModel(new InventoryRowModel(true, null)); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } - } else { - specificRadio.setSelected(true); } fireInventoryUpdated(); - code = null; adjustWidth(); jButtonCancel.doClick(); if (!inventoryRowList.isEmpty()) { @@ -2334,20 +2303,15 @@ private JButton getOkButton() { } } else { if (!areAllMedicalsInInventory()) { - codeTextField.setEnabled(false); - codeTextField.setText(""); int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; if (info == JOptionPane.YES_OPTION) { try { - jTableInventoryRow.setModel(new InventoryRowModel(true)); + jTableInventoryRow.setModel(new InventoryRowModel(true, medType)); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } - } else { - specificRadio.setSelected(true); } fireInventoryUpdated(); - code = null; adjustWidth(); jButtonCancel.doClick(); if (!inventoryRowList.isEmpty()) { @@ -2360,22 +2324,18 @@ private JButton getOkButton() { } } if (radioWithMovement.isSelected()) { + MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { if (!areAllMedicalsInInventory()) { - codeTextField.setEnabled(false); - codeTextField.setText(""); int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; if (info == JOptionPane.YES_OPTION) { try { - jTableInventoryRow.setModel(new InventoryRowModel(true)); + jTableInventoryRow.setModel(new InventoryRowModel(null, true)); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } - } else { - specificRadio.setSelected(true); } fireInventoryUpdated(); - code = null; adjustWidth(); jButtonCancel.doClick(); if (!inventoryRowList.isEmpty()) { @@ -2387,20 +2347,15 @@ private JButton getOkButton() { } } else { if (!areAllMedicalsInInventory()) { - codeTextField.setEnabled(false); - codeTextField.setText(""); int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; if (info == JOptionPane.YES_OPTION) { try { - jTableInventoryRow.setModel(new InventoryRowModel(true)); + jTableInventoryRow.setModel(new InventoryRowModel(medType, true)); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } - } else { - specificRadio.setSelected(true); } fireInventoryUpdated(); - code = null; adjustWidth(); jButtonCancel.doClick(); if (!inventoryRowList.isEmpty()) { @@ -2429,5 +2384,5 @@ private boolean areAllMedicalsInInventory() throws OHServiceException { return true; } return false; - } + } } From 77ff1f2af18d83efa86ef9af496397b6f2a8c0f4 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud Date: Fri, 29 Nov 2024 11:10:59 +0100 Subject: [PATCH 087/147] Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java Co-authored-by: Alessandro Domanico --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index ba616a881d..2032e194f2 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -2182,7 +2182,7 @@ private JRadioButton getAllRadioButton() { return radioButtonAll; } - private JRadioButton getMedicalWithNonZeroQuatityRadioButton() { + private JRadioButton getMedicalWithNonZeroQuantityRadioButton() { if (radioOnlyNonZero == null) { radioOnlyNonZero = new JRadioButton(MessageBundle.getMessage("angal.inventory.medicalwithonlynonzeroqty.btn")); radioOnlyNonZero.setMnemonic(MessageBundle.getMnemonic("angal.inventory.medicalwithonlynonzeroqty.btn.key")); From c5fb8c00b5b50b62c2b2d1a0ae920f61799c6824 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud Date: Tue, 3 Dec 2024 01:16:58 +0100 Subject: [PATCH 088/147] OP-1368 | Make Inventory status language independent (#2098) * update status management * update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java * apply suggestion * apply suggestion * update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java * align status on alphabetical order --------- Co-authored-by: ArnaudFofou --- bundle/language_en.properties | 8 ++++---- .../gui/InventoryBrowser.java | 19 ++++++++++--------- .../medicalinventory/gui/InventoryEdit.java | 14 +++++++------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 83ac31c727..93f19cda79 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -671,7 +671,6 @@ angal.hospital.visitendhour.txt angal.hospital.visitstarthour.txt = Visit start hour angal.inventory.allproduct.txt = All products angal.inventory.askforrealquantityempty.msg = Do you want to print without the real quantity? -angal.inventory.canceled = Canceled angal.inventory.confirm.btn = Confirm angal.inventory.confirm.btn.key = O angal.inventory.confirm.success.msg = Inventory confirmation complete. All stock has been accurately verified and updated in the system. @@ -694,7 +693,6 @@ angal.inventory.deletion.error.msg angal.inventory.notfound.msg = Inventory not found. angal.inventory.destination.label = Destination angal.inventory.dischargetype.label = Discharge Type -angal.inventory.draft = Draft angal.inventory.inventorybrowser.title = Inventory Browser angal.inventory.id.col = Id angal.inventory.mustenterareference.msg = You must enter a reference. @@ -741,6 +739,10 @@ angal.inventory.productalreadyexist.msg angal.inventory.savelotwithnullprice.msg = Save the lot without a price? angal.inventory.selectmedical.msg = Select a medical. angal.inventory.status.txt = Status +angal.inventory.status.canceled.txt = Canceled +angal.inventory.status.draft.txt = Draft +angal.inventory.status.done.txt = Done +angal.inventory.status.validated.txt = Validated angal.inventory.specificproduct.txt = Specific product angal.inventoryrow.theoreticqty.col = Theoretic Qty angal.inventory.totalprice = Total price @@ -750,8 +752,6 @@ angal.inventory.update.error.msg angal.inventory.update.success.msg = Inventory updated. angal.inventory.doyouwanttoupdatethisinventory.msg = Do you want to update this inventory? angal.inventory.nothinghasbeenaddedonthisinventory.msg = Nothing has been added to this inventory. -angal.inventory.validated = Validated -angal.inventory.done = Done angal.inventory.validate.btn = Validate angal.inventory.validate.btn.key = V angal.inventory.inventorymustsavebeforevalidation.msg = Inventory must be saved before validation. diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 5871cedd4a..17238c356e 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -220,12 +220,12 @@ private JPanel getPanelHeader() { gbc_jCalendarTo.gridx = 3; gbc_jCalendarTo.gridy = 0; panelHeader.add(getJCalendarTo(), gbc_jCalendarTo); - GridBagConstraints gbc_stateLabel = new GridBagConstraints(); - gbc_stateLabel.fill = GridBagConstraints.HORIZONTAL; - gbc_stateLabel.insets = new Insets(0, 0, 0, 5); - gbc_stateLabel.gridx = 4; - gbc_stateLabel.gridy = 0; - panelHeader.add(getStateLabel(), gbc_stateLabel); + GridBagConstraints gbc_statusLabel = new GridBagConstraints(); + gbc_statusLabel.fill = GridBagConstraints.HORIZONTAL; + gbc_statusLabel.insets = new Insets(0, 0, 0, 5); + gbc_statusLabel.gridx = 4; + gbc_statusLabel.gridy = 0; + panelHeader.add(getStatusLabel(), gbc_statusLabel); GridBagConstraints gbc_comboBox = new GridBagConstraints(); gbc_comboBox.fill = GridBagConstraints.HORIZONTAL; gbc_comboBox.gridx = 5; @@ -602,8 +602,9 @@ private JComboBox getComboBox() { if (statusComboBox == null) { statusComboBox = new JComboBox(); statusComboBox.addItem(""); - for (InventoryStatus currentStatus : InventoryStatus.values()) { - statusComboBox.addItem(MessageBundle.getMessage("angal.inventory." + currentStatus)); + List statusList = medicalInventoryManager.getStatusList(); + for (String status : statusList) { + statusComboBox.addItem(status); } statusComboBox.addActionListener(actionEvent -> { InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); @@ -622,7 +623,7 @@ private JComboBox getComboBox() { return statusComboBox; } - private JLabel getStateLabel() { + private JLabel getStatusLabel() { if (statusLabel == null) { statusLabel = new JLabel(MessageBundle.getMessage("angal.inventory.status.txt")); statusLabel.setHorizontalAlignment(SwingConstants.RIGHT); diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 27ce3940e6..234bf0eb1e 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -91,7 +91,6 @@ import org.isf.menu.manager.Context; import org.isf.menu.manager.UserBrowsingManager; import org.isf.stat.gui.report.GenericReportPharmaceuticalInventory; -import org.isf.stat.manager.JasperReportsManager; import org.isf.supplier.manager.SupplierBrowserManager; import org.isf.supplier.model.Supplier; import org.isf.utils.db.NormalizeString; @@ -229,7 +228,6 @@ private void fireInventoryUpdated() { private MedicalDsrStockMovementTypeBrowserManager movTypeManager = Context.getApplicationContext().getBean(MedicalDsrStockMovementTypeBrowserManager.class); private SupplierBrowserManager supplierManager = Context.getApplicationContext().getBean(SupplierBrowserManager.class); private WardBrowserManager wardManager = Context.getApplicationContext().getBean(WardBrowserManager.class); - private JasperReportsManager jasperReportsManager = Context.getApplicationContext().getBean(JasperReportsManager.class); public InventoryEdit() { mode = "new"; @@ -989,7 +987,7 @@ private JButton getValidateButton() { fireInventoryUpdated(); adjustWidth(); } catch (OHServiceException e1) { - OHServiceExceptionUtil.showMessages(e); + OHServiceExceptionUtil.showMessages(e1); } } } @@ -1783,12 +1781,14 @@ private JLabel getReferenceLabel() { private JLabel getStatusLabel() { if (statusLabel == null) { if (inventory == null) { - String currentStatus = InventoryStatus.draft.toString().toUpperCase(); - statusLabel = new JLabel(currentStatus); + String currentStatus = InventoryStatus.draft.toString(); + String status = medicalInventoryManager.getStatusByKey(currentStatus); + statusLabel = new JLabel(status.toUpperCase()); statusLabel.setForeground(Color.GRAY); } else { - String currentStatus = inventory.getStatus().toUpperCase(); - statusLabel = new JLabel(currentStatus); + String currentStatus = inventory.getStatus(); + String status = medicalInventoryManager.getStatusByKey(currentStatus); + statusLabel = new JLabel(status.toUpperCase()); if (currentStatus.equalsIgnoreCase(InventoryStatus.draft.toString())) { statusLabel.setForeground(Color.GRAY); } From 490425b21620e085ee0d49691c0d9b00495a4f1e Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud Date: Tue, 3 Dec 2024 07:45:37 +0100 Subject: [PATCH 089/147] Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java Co-authored-by: David B Malkovsky --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 2032e194f2..c49630c93b 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -276,7 +276,7 @@ private void initComponents() { } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } - setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); setMinimumSize(new Dimension(1000, 600)); setLocationRelativeTo(null); if (mode.equals("new")) { From 162d44e2ff93417fd7bd9af59621476d5e6bd29b Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Tue, 3 Dec 2024 08:13:56 +0100 Subject: [PATCH 090/147] apply suggestion --- .../gui/InventoryBrowser.java | 6 ++--- .../medicalinventory/gui/InventoryEdit.java | 25 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 5871cedd4a..d175d13aca 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -339,14 +339,14 @@ private JButton getNewButton() { String validated = InventoryStatus.validated.toString(); String inventoryType = InventoryType.main.toString(); List draftMedicalInventories = new ArrayList<>(); - List validMedicalInventories = new ArrayList<>(); + List validatedMedicalInventories = new ArrayList<>(); try { draftMedicalInventories = medicalInventoryManager.getMedicalInventoryByStatusAndInventoryType(draft, inventoryType); - validMedicalInventories = medicalInventoryManager.getMedicalInventoryByStatusAndInventoryType(validated, inventoryType); + validatedMedicalInventories = medicalInventoryManager.getMedicalInventoryByStatusAndInventoryType(validated, inventoryType); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } - if (draftMedicalInventories.size() == 0 && validMedicalInventories.size() == 0) { + if (draftMedicalInventories.isEmpty() && validatedMedicalInventories.isEmpty()) { InventoryEdit inventoryEdit = new InventoryEdit(); InventoryEdit.addInventoryListener(InventoryBrowser.this); inventoryEdit.showAsModal(InventoryBrowser.this); diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index c49630c93b..5b49b33ae2 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -523,7 +523,7 @@ private JButton getSelectedButton() { JPanel rightPanel = new JPanel(); rightPanel.setLayout(new GridLayout(3, 1, 5, 5)); rightPanel.add(getAllRadioButton()); - rightPanel.add(getMedicalWithNonZeroQuatityRadioButton()); + rightPanel.add(getMedicalWithNonZeroQuantityRadioButton()); rightPanel.add(getMedicalWithMovementRadioButton()); ButtonGroup radioGroup = new ButtonGroup(); @@ -861,7 +861,7 @@ private JButton getLotButton() { if (selectedInventoryRow.getLot() == null) { List invRows = inventoryRowSearchList.stream() .filter(inv -> inv.getLot() != null && inv.getLot().getCode().equals(code)).collect(Collectors.toList()); - if (invRows.size() == 0 || code.equals("")) { + if (invRows.isEmpty() || code.equals("")) { selectedInventoryRow.setNewLot(true); selectedInventoryRow.setLot(lot); lotsSaved.add(lot); @@ -878,7 +878,7 @@ private JButton getLotButton() { List invRows = inventoryRowSearchList.stream() .filter(inv -> inv.getMedical().getCode().equals(selectedInventoryRow.getMedical().getCode())).collect(Collectors.toList()); invRows = invRows.stream().filter(inv -> inv.getLot() != null && inv.getLot().getCode().equals(code)).collect(Collectors.toList()); - if (invRows.size() == 0 || code.equals("")) { + if (invRows.isEmpty() || code.equals("")) { selectedInventoryRow.setNewLot(true); selectedInventoryRow.setLot(lot); lotsSaved.add(lot); @@ -995,7 +995,7 @@ private JButton getValidateButton() { return; } List invRowWithoutLot = inventoryRowSearchList.stream().filter(invRow -> invRow.getLot() == null).collect(Collectors.toList()); - if (invRowWithoutLot.size() > 0) { + if (!invRowWithoutLot.isEmpty()) { MessageDialog.error(null, "angal.inventory.allinventoryrowshouldhavelotbeforevalidation.msg"); return; } @@ -1069,7 +1069,7 @@ private JButton getConfirmButton() { return; } List invRowWithoutLot = inventoryRowSearchList.stream().filter(invRow -> invRow.getLot() == null).collect(Collectors.toList()); - if (invRowWithoutLot.size() > 0) { + if (!invRowWithoutLot.isEmpty()) { MessageDialog.error(null, "angal.inventory.allinventoryrowshouldhavelotbeforevalidation.msg"); return; } @@ -1701,7 +1701,7 @@ private List getMedicalInventoryRows(String code) throws OH Medical med = medicalListIterator.next(); lots = movStockInsertingManager.getLotByMedical(med, false); double actualQty = med.getInqty() - med.getOutqty(); - if (lots.size() == 0) { + if (lots.isEmpty()) { inventoryRowTemp = new MedicalInventoryRow(0, actualQty, actualQty, null, med, null); if (!existInInventorySearchList(inventoryRowTemp)) { inventoryRowsList.add(inventoryRowTemp); @@ -1731,7 +1731,7 @@ private List getMedicalInventoryRowsByMedicalType(MedicalTy Medical med = medicalListIterator.next(); lots = movStockInsertingManager.getLotByMedical(med, false); double actualQty = med.getInqty() - med.getOutqty(); - if (lots.size() == 0) { + if (lots.isEmpty()) { inventoryRowTemp = new MedicalInventoryRow(0, actualQty, actualQty, null, med, null); if (!existInInventorySearchList(inventoryRowTemp)) { inventoryRowsList.add(inventoryRowTemp); @@ -1761,7 +1761,7 @@ private List getMedicalInventoryRowsWithMovement() throws O Medical med = medicalListIterator.next(); Integer medicalCodde = med.getCode(); List movements = movBrowserManager.getMovements(medicalCodde, null, null, null, null, null, null, null, null, null); - if (movements.size() > 0) { + if (!movements.isEmpty()) { medicalListWithMovement.add(med); } } @@ -1770,7 +1770,7 @@ private List getMedicalInventoryRowsWithMovement() throws O Medical med = medicalListIterator.next(); lots = movStockInsertingManager.getLotByMedical(med, false); double actualQty = med.getInqty() - med.getOutqty(); - if (lots.size() == 0) { + if (lots.isEmpty()) { inventoryRowTemp = new MedicalInventoryRow(0, actualQty, actualQty, null, med, null); if (!existInInventorySearchList(inventoryRowTemp)) { inventoryRowsList.add(inventoryRowTemp); @@ -1814,7 +1814,7 @@ private void addInventoryRow(String code) throws OHServiceException { while (medicalListIterator.hasNext()) { Medical med = medicalListIterator.next(); lots = movStockInsertingManager.getLotByMedical(med, false); - if (lots.size() == 0) { + if (lots.isEmpty()) { inventoryRowTemp = new MedicalInventoryRow(0, 0.0, 0.0, null, med, null); if (!existInInventorySearchList(inventoryRowTemp)) { inventoryRowsList.add(inventoryRowTemp); @@ -2101,7 +2101,7 @@ private boolean existInInventorySearchList(MedicalInventoryRow inventoryRow) { boolean found = false; List invRows = inventoryRowSearchList.stream() .filter(inv -> inv.getMedical().getCode().equals(inventoryRow.getMedical().getCode())).collect(Collectors.toList()); - if (invRows.size() > 0) { + if (!invRows.isEmpty()) { for (MedicalInventoryRow invR : invRows) { if (inventoryRow.getLot() != null && invR.getLot() != null) { if (inventoryRow.getLot().getCode().equals(invR.getLot().getCode())) { @@ -2143,7 +2143,7 @@ private boolean checkParameters(String wardCode, String chargeCode, String disch || (destination != null && !destination.getCode().equals(wardCode)) || (chargeType != null && !chargeType.getCode().equals(chargeCode)) || (dischargeType != null && !dischargeType.getCode().equals(dischargeCode)) - || (supplier != null && !supplier.getSupId().equals(suplierId)) || (destination == null && wardCode != null) + || (supplier != null && supplier.getSupId() != suplierId) || (destination == null && wardCode != null) || (chargeType == null && chargeCode != null) || (dischargeType == null && dischargeCode != null) || (supplier == null && suplierId != null) || (reference != null && !reference.equals(newReference)) || !date.toLocalDate().equals(dateInventory.toLocalDate())) { @@ -2177,7 +2177,6 @@ private JRadioButton getAllRadioButton() { if (radioButtonAll == null) { radioButtonAll = new JRadioButton(MessageBundle.getMessage("angal.common.all.btn")); radioButtonAll.setMnemonic(MessageBundle.getMnemonic("angal.common.all.btn.key")); - radioButtonAll.setSelected(true); } return radioButtonAll; } From 7e9541e60e06b34f8debb72e02e07fbf09d879f2 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Tue, 3 Dec 2024 08:31:29 +0100 Subject: [PATCH 091/147] apply suggestion --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 68ec5b5a91..579dbf1a3d 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1858,7 +1858,7 @@ private Medical chooseMedical(String text) throws OHServiceException { key = med.getCode().toString().toLowerCase(); medicalMap.put(key, med); } - ArrayList medList = new ArrayList(); + ArrayList medList = new ArrayList<>(); for (Medical aMed : medicalMap.values()) { if (NormalizeString.normalizeContains(aMed.getDescription().toLowerCase(), text)) { medList.add(aMed); From 3a33a87e8e7b981effbf71f31f9e248e1ad3ed74 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Tue, 3 Dec 2024 08:42:53 +0100 Subject: [PATCH 092/147] apply suggestion --- .../java/org/isf/medicalinventory/gui/InventoryEdit.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 579dbf1a3d..ca8c569762 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -2204,9 +2204,7 @@ private JButton getCancelButton() { jButtonCancel = new JButton(MessageBundle.getMessage("angal.common.cancel.btn")); jButtonCancel.setMnemonic(MessageBundle.getMnemonic("angal.common.cancel.btn.key")); } - jButtonCancel.addActionListener(actionEvent -> { - frame.dispose(); - }); + jButtonCancel.addActionListener(actionEvent -> dispose()); return jButtonCancel; } @@ -2385,5 +2383,5 @@ private boolean areAllMedicalsInInventory() throws OHServiceException { return true; } return false; - } + } } From 423832d643b6047d3d7ed05ee87c963379bd5eb8 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Thu, 5 Dec 2024 15:07:15 +0100 Subject: [PATCH 093/147] fix suggestion --- bundle/language_en.properties | 1 + .../medicalinventory/gui/InventoryEdit.java | 91 +------------------ 2 files changed, 6 insertions(+), 86 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index d8ed64781c..56de0a0f7d 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -349,6 +349,7 @@ angal.common.age.txt angal.common.agefrom.label = Age From: angal.common.ageto.label = Age To: angal.common.all.btn = All +angal.common.all.btn.key = A angal.common.all.txt = All angal.common.alldiseasetypes.txt = All Disease Types angal.common.alltypes.txt = All Types diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index ca8c569762..616638b1e6 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -205,7 +205,7 @@ private void fireInventoryUpdated() { private boolean[] pColumnVisible = { false, true, true, true, !GeneralData.AUTOMATICLOT_IN, true, true, true, GeneralData.LOTWITHCOST, GeneralData.LOTWITHCOST }; private MedicalInventory inventory = null; - private JRadioButton specificRadio; + private JLabel specificRadio; private JLabel dateInventoryLabel; private JTextField codeTextField; private String code = null; @@ -307,7 +307,6 @@ public void windowClosing(WindowEvent e) { confirmButton.setVisible(false); deleteButton.setVisible(false); columnEditable = columnEditableView; - codeTextField.setEditable(false); resetButton.setVisible(false); referenceTextField.setEditable(false); jCalendarInventory.setEnabled(false); @@ -322,7 +321,6 @@ public void windowClosing(WindowEvent e) { saveButton.setVisible(true); validateButton.setVisible(true); deleteButton.setVisible(true); - codeTextField.setEditable(true); resetButton.setVisible(true); referenceTextField.setEditable(true); jCalendarInventory.setEnabled(true); @@ -510,7 +508,6 @@ private JButton getSelectedButton() { selectButton = new JButton(MessageBundle.getMessage("angal.common.select.btn")); selectButton.setMnemonic(MessageBundle.getMnemonic("angal.common.select.btn.key")); selectButton.addActionListener(actionEvent -> { - specificRadio.setSelected(false); mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout(10, 10)); @@ -677,13 +674,6 @@ private JButton getSaveButton() { if (confirmButton.isEnabled()) { confirmButton.setEnabled(false); } - if (areAllMedicalsInInventory()) { - specificRadio.setSelected(false); - codeTextField.setEnabled(false); - } else { - specificRadio.setSelected(true); - codeTextField.setEnabled(true); - } resetVariable(); } else { MessageDialog.error(null, "angal.inventory.update.error.msg"); @@ -700,13 +690,6 @@ private JButton getSaveButton() { if (confirmButton.isEnabled()) { confirmButton.setEnabled(false); } - if (areAllMedicalsInInventory()) { - specificRadio.setSelected(false); - codeTextField.setEnabled(false); - } else { - specificRadio.setSelected(true); - codeTextField.setEnabled(true); - } resetVariable(); } else { MessageDialog.info(null, "angal.inventory.nothinghasbeenaddedonthisinventory.msg"); @@ -761,11 +744,6 @@ private JButton getSaveButton() { resetVariable(); fireInventoryUpdated(); validateButton.setEnabled(true); - if (areAllMedicalsInInventory()) { - specificRadio.setSelected(false); - } else { - specificRadio.setSelected(true); - } } } inventoryRowSearchList = newMedicalInventoryRows; @@ -970,8 +948,6 @@ private JButton getCleanTableButton() { } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } - specificRadio.setSelected(true); - codeTextField.setEnabled(true); inventoryRowSearchList = new ArrayList<>(); DefaultTableModel model = (DefaultTableModel) jTableInventoryRow.getModel(); model.setRowCount(0); @@ -1212,13 +1188,6 @@ public InventoryRowModel(boolean add) throws OHServiceException { addMedInRowInInventorySearchList(invRow); } } - if (areAllMedicalsInInventory()) { - specificRadio.setSelected(false); - codeTextField.setEnabled(false); - } else { - specificRadio.setSelected(true); - codeTextField.setEnabled(true); - } } public InventoryRowModel() throws OHServiceException { @@ -1237,13 +1206,6 @@ public InventoryRowModel() throws OHServiceException { } } } - if (areAllMedicalsInInventory()) { - specificRadio.setSelected(false); - codeTextField.setEnabled(false); - } else { - specificRadio.setSelected(true); - codeTextField.setEnabled(true); - } } public InventoryRowModel(MedicalType medType) throws OHServiceException { @@ -1254,13 +1216,6 @@ public InventoryRowModel(MedicalType medType) throws OHServiceException { addMedInRowInInventorySearchList(invRow); } } - if (areAllMedicalsInInventory()) { - specificRadio.setSelected(false); - codeTextField.setEnabled(false); - } else { - specificRadio.setSelected(true); - codeTextField.setEnabled(true); - } } public InventoryRowModel(boolean withNoZeroQty, MedicalType medType) throws OHServiceException { @@ -1273,13 +1228,6 @@ public InventoryRowModel(boolean withNoZeroQty, MedicalType medType) throws OHSe } else { MessageDialog.info(null, "angal.invetory.notdataforthatfilter.msg"); } - if (areAllMedicalsInInventory()) { - specificRadio.setSelected(false); - codeTextField.setEnabled(false); - } else { - specificRadio.setSelected(true); - codeTextField.setEnabled(true); - } } public InventoryRowModel(MedicalType medType, boolean withMovement) throws OHServiceException { @@ -1292,13 +1240,6 @@ public InventoryRowModel(MedicalType medType, boolean withMovement) throws OHSer } else { MessageDialog.info(null, "angal.invetory.notdataforthatfilter.msg"); } - if (areAllMedicalsInInventory()) { - specificRadio.setSelected(false); - codeTextField.setEnabled(false); - } else { - specificRadio.setSelected(true); - codeTextField.setEnabled(true); - } } public Class< ? > getColumnClass(int c) { @@ -1601,15 +1542,9 @@ public void setInventory(MedicalInventory inventory) { this.inventory = inventory; } - private JRadioButton getSpecificRadio() { + private JLabel getSpecificRadio() { if (specificRadio == null) { - specificRadio = new JRadioButton(MessageBundle.getMessage("angal.inventory.specificproduct.txt")); - specificRadio.addActionListener(actionEvent -> { - if (specificRadio.isSelected()) { - codeTextField.setEnabled(true); - codeTextField.setText(""); - } - }); + specificRadio = new JLabel(MessageBundle.getMessage("angal.inventory.specificproduct.txt")); } return specificRadio; } @@ -1624,11 +1559,6 @@ private JLabel getDateInventoryLabel() { private JTextField getCodeTextField() { if (codeTextField == null) { codeTextField = new JTextField(); - if (inventory != null) { - codeTextField.setEnabled(false); - } else { - codeTextField.setEnabled(true); - } codeTextField.setColumns(10); TextPrompt suggestion = new TextPrompt(MessageBundle.getMessage("angal.common.code.txt"), codeTextField, Show.FOCUS_LOST); suggestion.setFont(new Font("Tahoma", Font.PLAIN, 12)); @@ -2204,7 +2134,7 @@ private JButton getCancelButton() { jButtonCancel = new JButton(MessageBundle.getMessage("angal.common.cancel.btn")); jButtonCancel.setMnemonic(MessageBundle.getMnemonic("angal.common.cancel.btn.key")); } - jButtonCancel.addActionListener(actionEvent -> dispose()); + jButtonCancel.addActionListener(actionEvent -> frame.dispose()); return jButtonCancel; } @@ -2251,10 +2181,8 @@ private JButton getOkButton() { } fireInventoryUpdated(); adjustWidth(); - jButtonCancel.doClick(); MessageDialog.info(null, "angal.invetory.allmedicaladdedsuccessfully.msg"); } else { - jButtonCancel.doClick(); MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); } } else { @@ -2270,10 +2198,8 @@ private JButton getOkButton() { } fireInventoryUpdated(); adjustWidth(); - jButtonCancel.doClick(); MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); } else { - jButtonCancel.doClick(); MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); } } @@ -2292,12 +2218,10 @@ private JButton getOkButton() { } fireInventoryUpdated(); adjustWidth(); - jButtonCancel.doClick(); if (!inventoryRowList.isEmpty()) { MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); } } else { - jButtonCancel.doClick(); MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); } } else { @@ -2312,12 +2236,10 @@ private JButton getOkButton() { } fireInventoryUpdated(); adjustWidth(); - jButtonCancel.doClick(); if (!inventoryRowList.isEmpty()) { MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); } } else { - jButtonCancel.doClick(); MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); } } @@ -2336,12 +2258,10 @@ private JButton getOkButton() { } fireInventoryUpdated(); adjustWidth(); - jButtonCancel.doClick(); if (!inventoryRowList.isEmpty()) { MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); } } else { - jButtonCancel.doClick(); MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); } } else { @@ -2356,16 +2276,15 @@ private JButton getOkButton() { } fireInventoryUpdated(); adjustWidth(); - jButtonCancel.doClick(); if (!inventoryRowList.isEmpty()) { MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); } } else { - jButtonCancel.doClick(); MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); } } } + jButtonCancel.doClick(); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } From f75656e02b6c6dde8b1921d3b274ef802d485aa9 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Fri, 6 Dec 2024 08:46:51 +0100 Subject: [PATCH 094/147] update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java --- .../medicalinventory/gui/InventoryEdit.java | 271 +++++++++--------- 1 file changed, 141 insertions(+), 130 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 616638b1e6..24234f5a27 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -53,6 +53,7 @@ import java.util.Set; import java.util.stream.Collectors; +import javax.swing.AbstractButton; import javax.swing.BorderFactory; import javax.swing.ButtonGroup; import javax.swing.DefaultCellEditor; @@ -239,6 +240,7 @@ private void fireInventoryUpdated() { private MedicalType medicalTypeSelected; private JComboBox medicalTypeComboBox; private List medicals = new ArrayList<>(); + private Map actions = new HashMap<>(); private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); private MedicalInventoryRowManager medicalInventoryRowManager = Context.getApplicationContext().getBean(MedicalInventoryRowManager.class); private MedicalBrowsingManager medicalBrowsingManager = Context.getApplicationContext().getBean(MedicalBrowsingManager.class); @@ -519,14 +521,18 @@ private JButton getSelectedButton() { JPanel rightPanel = new JPanel(); rightPanel.setLayout(new GridLayout(3, 1, 5, 5)); - rightPanel.add(getAllRadioButton()); - rightPanel.add(getMedicalWithNonZeroQuantityRadioButton()); - rightPanel.add(getMedicalWithMovementRadioButton()); - ButtonGroup radioGroup = new ButtonGroup(); - radioGroup.add(radioButtonAll); - radioGroup.add(radioOnlyNonZero); - radioGroup.add(radioWithMovement); + radioGroup.add(getAllRadioButton()); + radioGroup.add(getMedicalWithNonZeroQuantityRadioButton()); + radioGroup.add(getMedicalWithMovementRadioButton()); + + // Map actions to buttons + initialiseActions(); + + // Add ActionListener to each button + for (AbstractButton button : actions.keySet()) { + rightPanel.add(button); + } JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); @@ -2097,7 +2103,7 @@ private JComboBox getJComboMedicalType() { } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } - + medicalTypeSelected = (MedicalType) medicalTypeComboBox.getSelectedItem(); medicalTypeComboBox.addActionListener(actionEvent -> { medicalTypeSelected = (MedicalType) medicalTypeComboBox.getSelectedItem(); }); @@ -2166,128 +2172,12 @@ private JButton getOkButton() { jButtonOk = new JButton(MessageBundle.getMessage("angal.common.ok.btn")); jButtonOk.setMnemonic(MessageBundle.getMnemonic("angal.common.ok.btn.key")); jButtonOk.addActionListener(actionEvent -> { - try { - medicalTypeSelected = (MedicalType) medicalTypeComboBox.getSelectedItem(); - if (radioButtonAll.isSelected()) { - if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { - if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; - if (info == JOptionPane.YES_OPTION) { - try { - jTableInventoryRow.setModel(new InventoryRowModel(true)); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - fireInventoryUpdated(); - adjustWidth(); - MessageDialog.info(null, "angal.invetory.allmedicaladdedsuccessfully.msg"); - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } else { - if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; - if (info == JOptionPane.YES_OPTION) { - try { - MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); - jTableInventoryRow.setModel(new InventoryRowModel(medType)); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - fireInventoryUpdated(); - adjustWidth(); - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } - } - if (radioOnlyNonZero.isSelected()) { - MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); - if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { - if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; - if (info == JOptionPane.YES_OPTION) { - try { - jTableInventoryRow.setModel(new InventoryRowModel(true, null)); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - fireInventoryUpdated(); - adjustWidth(); - if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } else { - if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; - if (info == JOptionPane.YES_OPTION) { - try { - jTableInventoryRow.setModel(new InventoryRowModel(true, medType)); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - fireInventoryUpdated(); - adjustWidth(); - if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } - } - if (radioWithMovement.isSelected()) { - MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); - if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { - if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; - if (info == JOptionPane.YES_OPTION) { - try { - jTableInventoryRow.setModel(new InventoryRowModel(null, true)); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - fireInventoryUpdated(); - adjustWidth(); - if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } else { - if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; - if (info == JOptionPane.YES_OPTION) { - try { - jTableInventoryRow.setModel(new InventoryRowModel(medType, true)); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - fireInventoryUpdated(); - adjustWidth(); - if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } - } - jButtonCancel.doClick(); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } + for (AbstractButton button : actions.keySet()) { + if (button.isSelected()) { + actions.get(button).run(); + } + } + jButtonCancel.doClick(); }); } return jButtonOk; @@ -2303,4 +2193,125 @@ private boolean areAllMedicalsInInventory() throws OHServiceException { } return false; } + + private void initialiseActions() { + actions.put(radioButtonAll, () -> { + if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { + try { + if (!areAllMedicalsInInventory()) { + int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + if (info == JOptionPane.YES_OPTION) { + jTableInventoryRow.setModel(new InventoryRowModel(true)); + } + fireInventoryUpdated(); + adjustWidth(); + MessageDialog.info(null, "angal.invetory.allmedicaladdedsuccessfully.msg"); + } else { + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } else { + try { + if (!areAllMedicalsInInventory()) { + int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + if (info == JOptionPane.YES_OPTION) { + MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); + jTableInventoryRow.setModel(new InventoryRowModel(medType)); + } + fireInventoryUpdated(); + adjustWidth(); + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } else { + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + }); + + actions.put(radioOnlyNonZero, () -> { + if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { + try { + if (!areAllMedicalsInInventory()) { + int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + if (info == JOptionPane.YES_OPTION) { + jTableInventoryRow.setModel(new InventoryRowModel(true, null)); + } + fireInventoryUpdated(); + adjustWidth(); + if (!inventoryRowList.isEmpty()) { + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } + } else { + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } else { + try { + if (!areAllMedicalsInInventory()) { + int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + if (info == JOptionPane.YES_OPTION) { + MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); + jTableInventoryRow.setModel(new InventoryRowModel(true, medType)); + fireInventoryUpdated(); + adjustWidth(); + if (!inventoryRowList.isEmpty()) { + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } + } + } else { + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + }); + + actions.put(radioWithMovement, () -> { + if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { + try { + if (!areAllMedicalsInInventory()) { + int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + if (info == JOptionPane.YES_OPTION) { + jTableInventoryRow.setModel(new InventoryRowModel(null, true)); + fireInventoryUpdated(); + adjustWidth(); + if (!inventoryRowList.isEmpty()) { + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } + } + } else { + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } else { + try { + if (!areAllMedicalsInInventory()) { + int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + if (info == JOptionPane.YES_OPTION) { + MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); + jTableInventoryRow.setModel(new InventoryRowModel(medType, true)); + fireInventoryUpdated(); + adjustWidth(); + if (!inventoryRowList.isEmpty()) { + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } + } + } else { + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + }); + } } From 69e62ab47769184bb43048eedebb6758374efc6c Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Fri, 6 Dec 2024 15:43:10 +0100 Subject: [PATCH 095/147] enhance the logic of Select Button --- bundle/language_en.properties | 5 +--- .../medicalinventory/gui/InventoryEdit.java | 25 +++++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 56de0a0f7d..bacbd40e3c 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -349,7 +349,6 @@ angal.common.age.txt angal.common.agefrom.label = Age From: angal.common.ageto.label = Age To: angal.common.all.btn = All -angal.common.all.btn.key = A angal.common.all.txt = All angal.common.alldiseasetypes.txt = All Disease Types angal.common.alltypes.txt = All Types @@ -736,9 +735,7 @@ angal.inventoryoperation.save.error.msg angal.inventoryrow.lotinformation.title = Lot Information angal.inventoryrow.medicaltype.txt = Medical Type angal.inventory.medicalwithmovementonly.btn = With movement only -angal.inventory.medicalwithmovementonly.btn.key = W -angal.inventory.medicalwithonlynonzeroqty.btn = Only non zero quantyties -angal.inventory.medicalwithonlynonzeroqty.btn.key = O +angal.inventory.medicalwithonlynonzeroqty.btn = Only non zero quantyties angal.inventory.nextarrow.btn = > angal.inventory.arrowprevious.btn = < angal.inventory.product.col = Products diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 24234f5a27..898f28ebc2 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -44,6 +44,7 @@ import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.EventListener; import java.util.HashMap; import java.util.HashSet; @@ -51,6 +52,7 @@ import java.util.ListIterator; import java.util.Map; import java.util.Set; +import java.util.TreeMap; import java.util.stream.Collectors; import javax.swing.AbstractButton; @@ -78,6 +80,7 @@ import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; +import org.hibernate.internal.build.AllowSysOut; import org.isf.generaldata.GeneralData; import org.isf.generaldata.MessageBundle; import org.isf.medicalinventory.manager.MedicalInventoryManager; @@ -528,11 +531,13 @@ private JButton getSelectedButton() { // Map actions to buttons initialiseActions(); - + // Convertir la HashMap en TreeMap pour trier les clés + Map sortedActionMap = new TreeMap<>(Comparator.comparing(AbstractButton::getText)); + sortedActionMap.putAll(actions); // Add ActionListener to each button - for (AbstractButton button : actions.keySet()) { - rightPanel.add(button); - } + sortedActionMap.forEach((key, value) -> { + rightPanel.add(key); + }); JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); @@ -2114,7 +2119,7 @@ private JComboBox getJComboMedicalType() { private JRadioButton getAllRadioButton() { if (radioButtonAll == null) { radioButtonAll = new JRadioButton(MessageBundle.getMessage("angal.common.all.btn")); - radioButtonAll.setMnemonic(MessageBundle.getMnemonic("angal.common.all.btn.key")); + radioButtonAll.setSelected(true); } return radioButtonAll; } @@ -2122,7 +2127,6 @@ private JRadioButton getAllRadioButton() { private JRadioButton getMedicalWithNonZeroQuantityRadioButton() { if (radioOnlyNonZero == null) { radioOnlyNonZero = new JRadioButton(MessageBundle.getMessage("angal.inventory.medicalwithonlynonzeroqty.btn")); - radioOnlyNonZero.setMnemonic(MessageBundle.getMnemonic("angal.inventory.medicalwithonlynonzeroqty.btn.key")); } return radioOnlyNonZero; } @@ -2130,7 +2134,6 @@ private JRadioButton getMedicalWithNonZeroQuantityRadioButton() { private JRadioButton getMedicalWithMovementRadioButton() { if (radioWithMovement == null) { radioWithMovement = new JRadioButton(MessageBundle.getMessage("angal.inventory.medicalwithmovementonly.btn")); - radioWithMovement.setMnemonic(MessageBundle.getMnemonic("angal.inventory.medicalwithmovementonly.btn.key")); } return radioWithMovement; } @@ -2172,11 +2175,11 @@ private JButton getOkButton() { jButtonOk = new JButton(MessageBundle.getMessage("angal.common.ok.btn")); jButtonOk.setMnemonic(MessageBundle.getMnemonic("angal.common.ok.btn.key")); jButtonOk.addActionListener(actionEvent -> { - for (AbstractButton button : actions.keySet()) { - if (button.isSelected()) { - actions.get(button).run(); + actions.forEach((key, value) -> { + if (key.isSelected()) { + actions.get(key).run(); } - } + }); jButtonCancel.doClick(); }); } From bb1781a189b2c3077e885e6471b80fec54a28a0c Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud Date: Sun, 8 Dec 2024 14:37:23 +0100 Subject: [PATCH 096/147] Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java Co-authored-by: Alessandro Domanico --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 898f28ebc2..6feb331931 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -535,7 +535,7 @@ private JButton getSelectedButton() { Map sortedActionMap = new TreeMap<>(Comparator.comparing(AbstractButton::getText)); sortedActionMap.putAll(actions); // Add ActionListener to each button - sortedActionMap.forEach((key, value) -> { + sortedActionMap.forEach((key, value) -> { rightPanel.add(key); }); From 06c5a6afdcd74c9a7dee65fbb94513509eab560f Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud Date: Sun, 8 Dec 2024 14:37:57 +0100 Subject: [PATCH 097/147] Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java Co-authored-by: Alessandro Domanico --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 6feb331931..e2bfc3b84f 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -2197,7 +2197,7 @@ private boolean areAllMedicalsInInventory() throws OHServiceException { return false; } - private void initialiseActions() { + private void initializeActions() { actions.put(radioButtonAll, () -> { if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { try { From 756d6b0994a67e884fe0cccb6a51a30c6e800cc2 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Mon, 9 Dec 2024 07:52:11 +0100 Subject: [PATCH 098/147] update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java' --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index e2bfc3b84f..a90a7d18a8 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -530,7 +530,7 @@ private JButton getSelectedButton() { radioGroup.add(getMedicalWithMovementRadioButton()); // Map actions to buttons - initialiseActions(); + initializeActions(); // Convertir la HashMap en TreeMap pour trier les clés Map sortedActionMap = new TreeMap<>(Comparator.comparing(AbstractButton::getText)); sortedActionMap.putAll(actions); @@ -2062,6 +2062,7 @@ private boolean existInInventorySearchList(MedicalInventoryRow inventoryRow) { return found; } + private void addMedInRowInInventorySearchList(MedicalInventoryRow inventoryRow) { int position = getPosition(inventoryRow); if (position == -1) { @@ -2074,6 +2075,7 @@ private void addMedInRowInInventorySearchList(MedicalInventoryRow inventoryRow) inventoryRowListAdded.add(inventoryRow); } } + private void resetVariable() { inventoryRowsToDelete.clear(); lotsDeleted.clear(); From 9c649a3ad825c695d3dd5e4300eb1e74b2d5e435 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Mon, 9 Dec 2024 07:53:49 +0100 Subject: [PATCH 099/147] remove unused import --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index a90a7d18a8..0138b1458d 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -80,7 +80,6 @@ import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; -import org.hibernate.internal.build.AllowSysOut; import org.isf.generaldata.GeneralData; import org.isf.generaldata.MessageBundle; import org.isf.medicalinventory.manager.MedicalInventoryManager; From aee0bdc5ca8bfc65cf9503d0e7f6ea147fb4d3de Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Mon, 9 Dec 2024 07:59:34 +0100 Subject: [PATCH 100/147] update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java' --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 0138b1458d..898ad4a6e4 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1202,9 +1202,7 @@ public InventoryRowModel(boolean add) throws OHServiceException { public InventoryRowModel() throws OHServiceException { inventoryRowList.clear(); - if (!inventoryRowSearchList.isEmpty()) { - inventoryRowSearchList.clear(); - } + inventoryRowSearchList.clear(); if (inventory != null) { inventoryRowList = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()); } From 790e974f829df227bdf8f3a9bb2c30c1f126c031 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Mon, 9 Dec 2024 08:05:34 +0100 Subject: [PATCH 101/147] update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java' --- .../java/org/isf/medicalinventory/gui/InventoryEdit.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 898ad4a6e4..fd96f6dfb2 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1191,7 +1191,6 @@ class InventoryRowModel extends DefaultTableModel { private static final long serialVersionUID = 1L; public InventoryRowModel(boolean add) throws OHServiceException { - inventoryRowList.clear(); inventoryRowList = loadNewInventoryTable(null, inventory, add); if (!inventoryRowList.isEmpty()) { for (MedicalInventoryRow invRow : inventoryRowList) { @@ -1201,7 +1200,6 @@ public InventoryRowModel(boolean add) throws OHServiceException { } public InventoryRowModel() throws OHServiceException { - inventoryRowList.clear(); inventoryRowSearchList.clear(); if (inventory != null) { inventoryRowList = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()); @@ -1217,7 +1215,6 @@ public InventoryRowModel() throws OHServiceException { } public InventoryRowModel(MedicalType medType) throws OHServiceException { - inventoryRowList.clear(); inventoryRowList = loadNewInventoryTableByMedicalType(medType); if (!inventoryRowList.isEmpty()) { for (MedicalInventoryRow invRow : inventoryRowList) { @@ -1227,7 +1224,6 @@ public InventoryRowModel(MedicalType medType) throws OHServiceException { } public InventoryRowModel(boolean withNoZeroQty, MedicalType medType) throws OHServiceException { - inventoryRowList.clear(); inventoryRowList = loadNewInventoryTable(withNoZeroQty, medType); if (!inventoryRowList.isEmpty()) { for (MedicalInventoryRow invRow : inventoryRowList) { @@ -1239,7 +1235,6 @@ public InventoryRowModel(boolean withNoZeroQty, MedicalType medType) throws OHSe } public InventoryRowModel(MedicalType medType, boolean withMovement) throws OHServiceException { - inventoryRowList.clear(); inventoryRowList = loadNewInventoryTable(medType); if (!inventoryRowList.isEmpty()) { for (MedicalInventoryRow invRow : inventoryRowList) { From 19b19701ae7c348634d0d35fe111605731d1e97c Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Wed, 11 Dec 2024 08:26:47 +0100 Subject: [PATCH 102/147] update InventoryEdit --- .../medicalinventory/gui/InventoryEdit.java | 52 +++++++++++++++++-- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index fd96f6dfb2..6fc6ebf609 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -950,15 +950,12 @@ private JButton getCleanTableButton() { if (inventory != null) { List invRows = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()); medicalInventoryRowManager.deleteMedicalInventoryRows(invRows); - inventoryRowSearchList.clear(); - } else { - inventoryRowSearchList.clear(); } } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } - inventoryRowSearchList = new ArrayList<>(); + inventoryRowSearchList.clear(); DefaultTableModel model = (DefaultTableModel) jTableInventoryRow.getModel(); model.setRowCount(0); model.setColumnCount(0); @@ -2192,6 +2189,51 @@ private boolean areAllMedicalsInInventory() throws OHServiceException { } private void initializeActions() { + actions.put(radioButtonAll, () -> handleInventoryUpdate( + medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt")), + null, null, "angal.invetory.allmedicaladdedsuccessfully.msg" + )); + + actions.put(radioOnlyNonZero, () -> handleInventoryUpdate( + medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt")), + true, medicalTypeSelected, "angal.invetory.tablehasbeenupdated.msg" + )); + + actions.put(radioWithMovement, () -> handleInventoryUpdate( + medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt")), + null, medicalTypeSelected, "angal.invetory.tablehasbeenupdated.msg" + )); + } + + private void handleInventoryUpdate(boolean isAllSelected, Boolean withNoZeroQty, MedicalType medType, String successMessage) { + try { + if (areAllMedicalsInInventory()) { + MessageDialog.info(null, "angal.inventory.allmedicalsarealreadyin.msg"); + return; + } + + int info = (!inventoryRowSearchList.isEmpty()) + ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") + : JOptionPane.YES_OPTION; + + if (info == JOptionPane.YES_OPTION) { + InventoryRowModel model; + if (isAllSelected) { + model = new InventoryRowModel(withNoZeroQty != null ? withNoZeroQty : true); + } else { + model = new InventoryRowModel(medType, withNoZeroQty != null); + } + + jTableInventoryRow.setModel(model); + fireInventoryUpdated(); + adjustWidth(); + MessageDialog.info(null, successMessage); + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + /*private void initializeActions() { actions.put(radioButtonAll, () -> { if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { try { @@ -2310,5 +2352,5 @@ private void initializeActions() { } } }); - } + }*/ } From 9c0f1e6b98ce7df566950e5ba3fc2d897fa06ba8 Mon Sep 17 00:00:00 2001 From: mwithi Date: Thu, 19 Dec 2024 23:08:00 +0100 Subject: [PATCH 103/147] Fix formatting --- .../medicalinventory/gui/InventoryEdit.java | 113 ++++++++++-------- 1 file changed, 63 insertions(+), 50 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 898f28ebc2..35d8a2f8ae 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -80,7 +80,6 @@ import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; -import org.hibernate.internal.build.AllowSysOut; import org.isf.generaldata.GeneralData; import org.isf.generaldata.MessageBundle; import org.isf.medicalinventory.manager.MedicalInventoryManager; @@ -528,16 +527,16 @@ private JButton getSelectedButton() { radioGroup.add(getAllRadioButton()); radioGroup.add(getMedicalWithNonZeroQuantityRadioButton()); radioGroup.add(getMedicalWithMovementRadioButton()); - + // Map actions to buttons initialiseActions(); // Convertir la HashMap en TreeMap pour trier les clés Map sortedActionMap = new TreeMap<>(Comparator.comparing(AbstractButton::getText)); sortedActionMap.putAll(actions); // Add ActionListener to each button - sortedActionMap.forEach((key, value) -> { - rightPanel.add(key); - }); + sortedActionMap.forEach((key, value) -> { + rightPanel.add(key); + }); JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); @@ -849,7 +848,7 @@ private JButton getLotButton() { code = lot.getCode(); if (selectedInventoryRow.getLot() == null) { List invRows = inventoryRowSearchList.stream() - .filter(inv -> inv.getLot() != null && inv.getLot().getCode().equals(code)).collect(Collectors.toList()); + .filter(inv -> inv.getLot() != null && inv.getLot().getCode().equals(code)).collect(Collectors.toList()); if (invRows.isEmpty() || code.equals("")) { selectedInventoryRow.setNewLot(true); selectedInventoryRow.setLot(lot); @@ -865,7 +864,7 @@ private JButton getLotButton() { } } else { List invRows = inventoryRowSearchList.stream() - .filter(inv -> inv.getMedical().getCode().equals(selectedInventoryRow.getMedical().getCode())).collect(Collectors.toList()); + .filter(inv -> inv.getMedical().getCode().equals(selectedInventoryRow.getMedical().getCode())).collect(Collectors.toList()); invRows = invRows.stream().filter(inv -> inv.getLot() != null && inv.getLot().getCode().equals(code)).collect(Collectors.toList()); if (invRows.isEmpty() || code.equals("")) { selectedInventoryRow.setNewLot(true); @@ -995,7 +994,7 @@ private JButton getValidateButton() { String lastReference = inventory.getInventoryReference(); LocalDateTime lastDate = inventory.getInventoryDate(); if (checkParameters(wardCode, chargeCode, dischargeCode, supplierId, lastReference, lastDate) || !lotsSaved.isEmpty() - || !inventoryRowListAdded.isEmpty() || !inventoryRowsToDelete.isEmpty()) { + || !inventoryRowListAdded.isEmpty() || !inventoryRowsToDelete.isEmpty()) { saveButton.doClick(); chargeCode = inventory.getChargeType(); dischargeCode = inventory.getDischargeType(); @@ -1451,10 +1450,10 @@ private Lot askLot(Lot lotToUpdate) { panel.add(expireDateChooser); do { int ok = JOptionPane.showConfirmDialog( - this, - panel, - MessageBundle.getMessage("angal.medicalstock.multiplecharging.lotinformations"), - JOptionPane.OK_CANCEL_OPTION); + this, + panel, + MessageBundle.getMessage("angal.medicalstock.multiplecharging.lotinformations"), + JOptionPane.OK_CANCEL_OPTION); if (ok == JOptionPane.OK_OPTION) { String lotName = lotNameTextField.getText(); @@ -1489,8 +1488,8 @@ private BigDecimal askCost(int qty, BigDecimal lastCost) { double cost = 0.; do { String input = JOptionPane.showInputDialog(this, - MessageBundle.getMessage("angal.medicalstock.multiplecharging.unitcost"), - lastCost); + MessageBundle.getMessage("angal.medicalstock.multiplecharging.unitcost"), + lastCost); if (input != null) { try { cost = Double.parseDouble(input); @@ -1518,8 +1517,8 @@ protected LocalDateTime askExpiringDate() { panel.add(expireDateChooser); int ok = JOptionPane.showConfirmDialog(this, panel, - MessageBundle.getMessage("angal.medicalstock.multiplecharging.expiringdate"), - JOptionPane.OK_CANCEL_OPTION); + MessageBundle.getMessage("angal.medicalstock.multiplecharging.expiringdate"), + JOptionPane.OK_CANCEL_OPTION); if (ok == JOptionPane.OK_OPTION) { date = expireDateChooser.getLocalDateTime(); @@ -1529,8 +1528,8 @@ protected LocalDateTime askExpiringDate() { protected double askTotalCost() { String input = JOptionPane.showInputDialog(this, - MessageBundle.getMessage("angal.medicalstock.multiplecharging.totalcost"), - 0.); + MessageBundle.getMessage("angal.medicalstock.multiplecharging.totalcost"), + 0.); double total = 0.; if (input != null) { try { @@ -2043,7 +2042,7 @@ private int getPosition(MedicalInventoryRow inventoryRow) { private boolean existInInventorySearchList(MedicalInventoryRow inventoryRow) { boolean found = false; List invRows = inventoryRowSearchList.stream() - .filter(inv -> inv.getMedical().getCode().equals(inventoryRow.getMedical().getCode())).collect(Collectors.toList()); + .filter(inv -> inv.getMedical().getCode().equals(inventoryRow.getMedical().getCode())).collect(Collectors.toList()); if (!invRows.isEmpty()) { for (MedicalInventoryRow invR : invRows) { if (inventoryRow.getLot() != null && invR.getLot() != null) { @@ -2062,6 +2061,7 @@ private boolean existInInventorySearchList(MedicalInventoryRow inventoryRow) { return found; } + private void addMedInRowInInventorySearchList(MedicalInventoryRow inventoryRow) { int position = getPosition(inventoryRow); if (position == -1) { @@ -2074,6 +2074,7 @@ private void addMedInRowInInventorySearchList(MedicalInventoryRow inventoryRow) inventoryRowListAdded.add(inventoryRow); } } + private void resetVariable() { inventoryRowsToDelete.clear(); lotsDeleted.clear(); @@ -2083,13 +2084,13 @@ private void resetVariable() { private boolean checkParameters(String wardCode, String chargeCode, String dischargeCode, Integer suplierId, String reference, LocalDateTime date) { if (!lotsSaved.isEmpty() || !inventoryRowListAdded.isEmpty() || !lotsDeleted.isEmpty() || !inventoryRowsToDelete.isEmpty() - || (destination != null && !destination.getCode().equals(wardCode)) - || (chargeType != null && !chargeType.getCode().equals(chargeCode)) - || (dischargeType != null && !dischargeType.getCode().equals(dischargeCode)) - || (supplier != null && supplier.getSupId() != suplierId) || (destination == null && wardCode != null) - || (chargeType == null && chargeCode != null) || (dischargeType == null && dischargeCode != null) - || (supplier == null && suplierId != null) || (reference != null && !reference.equals(newReference)) - || !date.toLocalDate().equals(dateInventory.toLocalDate())) { + || (destination != null && !destination.getCode().equals(wardCode)) + || (chargeType != null && !chargeType.getCode().equals(chargeCode)) + || (dischargeType != null && !dischargeType.getCode().equals(dischargeCode)) + || (supplier != null && supplier.getSupId() != suplierId) || (destination == null && wardCode != null) + || (chargeType == null && chargeCode != null) || (dischargeType == null && dischargeCode != null) + || (supplier == null && suplierId != null) || (reference != null && !reference.equals(newReference)) + || !date.toLocalDate().equals(dateInventory.toLocalDate())) { return true; } return false; @@ -2146,7 +2147,7 @@ private JButton getCancelButton() { jButtonCancel.addActionListener(actionEvent -> frame.dispose()); return jButtonCancel; } - + private List loadNewInventoryTable(boolean withNonZeroQty, MedicalType medicalTypeSelected) throws OHServiceException { List inventoryRowsList = getMedicalInventoryRows(null); if (withNonZeroQty) { @@ -2154,8 +2155,8 @@ private List loadNewInventoryTable(boolean withNonZeroQty, } if (medicalTypeSelected != null) { inventoryRowsList = inventoryRowsList.stream() - .filter(inv -> inv.getMedical().getType().getDescription().equals(medicalTypeSelected.getDescription())) - .collect(Collectors.toList()); + .filter(inv -> inv.getMedical().getType().getDescription().equals(medicalTypeSelected.getDescription())) + .collect(Collectors.toList()); } return inventoryRowsList; } @@ -2164,8 +2165,8 @@ private List loadNewInventoryTable(MedicalType medicalTypeS List inventoryRowsList = getMedicalInventoryRowsWithMovement(); if (medicalTypeSelected != null) { inventoryRowsList = inventoryRowsList.stream() - .filter(inv -> inv.getMedical().getType().getDescription().equals(medicalTypeSelected.getDescription())) - .collect(Collectors.toList()); + .filter(inv -> inv.getMedical().getType().getDescription().equals(medicalTypeSelected.getDescription())) + .collect(Collectors.toList()); } return inventoryRowsList; } @@ -2176,16 +2177,16 @@ private JButton getOkButton() { jButtonOk.setMnemonic(MessageBundle.getMnemonic("angal.common.ok.btn.key")); jButtonOk.addActionListener(actionEvent -> { actions.forEach((key, value) -> { - if (key.isSelected()) { - actions.get(key).run(); - } - }); + if (key.isSelected()) { + actions.get(key).run(); + } + }); jButtonCancel.doClick(); }); } return jButtonOk; } - + private boolean areAllMedicalsInInventory() throws OHServiceException { Set inventorySet = new HashSet<>(); for (MedicalInventoryRow row : inventoryRowSearchList) { @@ -2196,13 +2197,15 @@ private boolean areAllMedicalsInInventory() throws OHServiceException { } return false; } - + private void initialiseActions() { actions.put(radioButtonAll, () -> { if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { try { if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + int info = (!inventoryRowSearchList.isEmpty()) + ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") + : JOptionPane.YES_OPTION; if (info == JOptionPane.YES_OPTION) { jTableInventoryRow.setModel(new InventoryRowModel(true)); } @@ -2218,9 +2221,11 @@ private void initialiseActions() { } else { try { if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + int info = (!inventoryRowSearchList.isEmpty()) + ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") + : JOptionPane.YES_OPTION; if (info == JOptionPane.YES_OPTION) { - MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); + MedicalType medType = (MedicalType) medicalTypeComboBox.getSelectedItem(); jTableInventoryRow.setModel(new InventoryRowModel(medType)); } fireInventoryUpdated(); @@ -2234,12 +2239,14 @@ private void initialiseActions() { } } }); - + actions.put(radioOnlyNonZero, () -> { if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { try { if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + int info = (!inventoryRowSearchList.isEmpty()) + ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") + : JOptionPane.YES_OPTION; if (info == JOptionPane.YES_OPTION) { jTableInventoryRow.setModel(new InventoryRowModel(true, null)); } @@ -2257,16 +2264,18 @@ private void initialiseActions() { } else { try { if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + int info = (!inventoryRowSearchList.isEmpty()) + ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") + : JOptionPane.YES_OPTION; if (info == JOptionPane.YES_OPTION) { - MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); + MedicalType medType = (MedicalType) medicalTypeComboBox.getSelectedItem(); jTableInventoryRow.setModel(new InventoryRowModel(true, medType)); fireInventoryUpdated(); adjustWidth(); if (!inventoryRowList.isEmpty()) { MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); } - } + } } else { MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); } @@ -2275,12 +2284,14 @@ private void initialiseActions() { } } }); - + actions.put(radioWithMovement, () -> { if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { try { if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + int info = (!inventoryRowSearchList.isEmpty()) + ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") + : JOptionPane.YES_OPTION; if (info == JOptionPane.YES_OPTION) { jTableInventoryRow.setModel(new InventoryRowModel(null, true)); fireInventoryUpdated(); @@ -2298,16 +2309,18 @@ private void initialiseActions() { } else { try { if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + int info = (!inventoryRowSearchList.isEmpty()) + ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") + : JOptionPane.YES_OPTION; if (info == JOptionPane.YES_OPTION) { - MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); + MedicalType medType = (MedicalType) medicalTypeComboBox.getSelectedItem(); jTableInventoryRow.setModel(new InventoryRowModel(medType, true)); fireInventoryUpdated(); adjustWidth(); if (!inventoryRowList.isEmpty()) { MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); } - } + } } else { MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); } From 05a566a927382fd6b185f58da361a5bfabb80069 Mon Sep 17 00:00:00 2001 From: mwithi Date: Thu, 19 Dec 2024 23:14:15 +0100 Subject: [PATCH 104/147] Remove redundant code and translate French comments --- .../org/isf/medicalinventory/gui/InventoryEdit.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 35d8a2f8ae..ae4360659d 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -530,9 +530,11 @@ private JButton getSelectedButton() { // Map actions to buttons initialiseActions(); - // Convertir la HashMap en TreeMap pour trier les clés + + // Convert HashMap to TreeMap to sort keys Map sortedActionMap = new TreeMap<>(Comparator.comparing(AbstractButton::getText)); sortedActionMap.putAll(actions); + // Add ActionListener to each button sortedActionMap.forEach((key, value) -> { rightPanel.add(key); @@ -1191,7 +1193,6 @@ class InventoryRowModel extends DefaultTableModel { private static final long serialVersionUID = 1L; public InventoryRowModel(boolean add) throws OHServiceException { - inventoryRowList.clear(); inventoryRowList = loadNewInventoryTable(null, inventory, add); if (!inventoryRowList.isEmpty()) { for (MedicalInventoryRow invRow : inventoryRowList) { @@ -1202,9 +1203,7 @@ public InventoryRowModel(boolean add) throws OHServiceException { public InventoryRowModel() throws OHServiceException { inventoryRowList.clear(); - if (!inventoryRowSearchList.isEmpty()) { - inventoryRowSearchList.clear(); - } + inventoryRowSearchList.clear(); if (inventory != null) { inventoryRowList = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()); } @@ -1219,7 +1218,6 @@ public InventoryRowModel() throws OHServiceException { } public InventoryRowModel(MedicalType medType) throws OHServiceException { - inventoryRowList.clear(); inventoryRowList = loadNewInventoryTableByMedicalType(medType); if (!inventoryRowList.isEmpty()) { for (MedicalInventoryRow invRow : inventoryRowList) { @@ -1229,7 +1227,6 @@ public InventoryRowModel(MedicalType medType) throws OHServiceException { } public InventoryRowModel(boolean withNoZeroQty, MedicalType medType) throws OHServiceException { - inventoryRowList.clear(); inventoryRowList = loadNewInventoryTable(withNoZeroQty, medType); if (!inventoryRowList.isEmpty()) { for (MedicalInventoryRow invRow : inventoryRowList) { @@ -1241,7 +1238,6 @@ public InventoryRowModel(boolean withNoZeroQty, MedicalType medType) throws OHSe } public InventoryRowModel(MedicalType medType, boolean withMovement) throws OHServiceException { - inventoryRowList.clear(); inventoryRowList = loadNewInventoryTable(medType); if (!inventoryRowList.isEmpty()) { for (MedicalInventoryRow invRow : inventoryRowList) { From 52dad5cb658ab97964b5bd51262022cb087b7e50 Mon Sep 17 00:00:00 2001 From: mwithi Date: Thu, 19 Dec 2024 23:24:19 +0100 Subject: [PATCH 105/147] Remove redundant code --- .../medicalinventory/gui/InventoryEdit.java | 24 +------------------ 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index ae4360659d..5aba95b3cb 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -800,7 +800,6 @@ private JButton getDeleteButton() { } } jTableInventoryRow.clearSelection(); - adjustWidth(); } else { return; } @@ -965,7 +964,6 @@ private JButton getCleanTableButton() { model.setRowCount(0); model.setColumnCount(0); jTableInventoryRow.updateUI(); - adjustWidth(); } }); return resetButton; @@ -1034,7 +1032,6 @@ private JButton getValidateButton() { confirmButton.setEnabled(true); jTableInventoryRow.setModel(new InventoryRowModel()); fireInventoryUpdated(); - adjustWidth(); } catch (OHServiceException e1) { OHServiceExceptionUtil.showMessages(e1); } @@ -1122,6 +1119,7 @@ private JTable getJTableInventoryRow() throws OHServiceException { jTableInventoryRow = new JTable(); jTextFieldEditor = new JTextField(); jTableInventoryRow.setFillsViewportHeight(true); + jTableInventoryRow.setAutoCreateColumnsFromModel(false); model = new InventoryRowModel(); jTableInventoryRow.setModel(model); for (int i = 0; i < pColumnVisible.length; i++) { @@ -1381,20 +1379,6 @@ public boolean isCellEditable(int rowIndex, int columnIndex) { } } - private void adjustWidth() { - for (int i = 0; i < jTableInventoryRow.getColumnModel().getColumnCount(); i++) { - jTableInventoryRow.getColumnModel().getColumn(i).setPreferredWidth(pColumwidth[i]); - if (i == 0 || !pColumnVisible[i]) { - jTableInventoryRow.getColumnModel().getColumn(i).setMinWidth(0); - jTableInventoryRow.getColumnModel().getColumn(i).setMaxWidth(0); - jTableInventoryRow.getColumnModel().getColumn(i).setPreferredWidth(0); - } - } - DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer(); - centerRenderer.setHorizontalAlignment(JLabel.CENTER); - jTableInventoryRow.getColumnModel().getColumn(3).setCellRenderer(centerRenderer); - } - private Lot getLot(Lot lotToUpdate) throws OHServiceException { Lot lot = null; if (isAutomaticLotIn()) { @@ -2206,7 +2190,6 @@ private void initialiseActions() { jTableInventoryRow.setModel(new InventoryRowModel(true)); } fireInventoryUpdated(); - adjustWidth(); MessageDialog.info(null, "angal.invetory.allmedicaladdedsuccessfully.msg"); } else { MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); @@ -2225,7 +2208,6 @@ private void initialiseActions() { jTableInventoryRow.setModel(new InventoryRowModel(medType)); } fireInventoryUpdated(); - adjustWidth(); MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); } else { MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); @@ -2247,7 +2229,6 @@ private void initialiseActions() { jTableInventoryRow.setModel(new InventoryRowModel(true, null)); } fireInventoryUpdated(); - adjustWidth(); if (!inventoryRowList.isEmpty()) { MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); } @@ -2267,7 +2248,6 @@ private void initialiseActions() { MedicalType medType = (MedicalType) medicalTypeComboBox.getSelectedItem(); jTableInventoryRow.setModel(new InventoryRowModel(true, medType)); fireInventoryUpdated(); - adjustWidth(); if (!inventoryRowList.isEmpty()) { MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); } @@ -2291,7 +2271,6 @@ private void initialiseActions() { if (info == JOptionPane.YES_OPTION) { jTableInventoryRow.setModel(new InventoryRowModel(null, true)); fireInventoryUpdated(); - adjustWidth(); if (!inventoryRowList.isEmpty()) { MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); } @@ -2312,7 +2291,6 @@ private void initialiseActions() { MedicalType medType = (MedicalType) medicalTypeComboBox.getSelectedItem(); jTableInventoryRow.setModel(new InventoryRowModel(medType, true)); fireInventoryUpdated(); - adjustWidth(); if (!inventoryRowList.isEmpty()) { MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); } From 4b13ab6c0a84e27355d293a8a2b39025bd54e2d2 Mon Sep 17 00:00:00 2001 From: mwithi Date: Fri, 20 Dec 2024 00:31:06 +0100 Subject: [PATCH 106/147] Fix --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 5aba95b3cb..8a15c3d90a 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1119,9 +1119,9 @@ private JTable getJTableInventoryRow() throws OHServiceException { jTableInventoryRow = new JTable(); jTextFieldEditor = new JTextField(); jTableInventoryRow.setFillsViewportHeight(true); - jTableInventoryRow.setAutoCreateColumnsFromModel(false); model = new InventoryRowModel(); jTableInventoryRow.setModel(model); + jTableInventoryRow.setAutoCreateColumnsFromModel(false); for (int i = 0; i < pColumnVisible.length; i++) { jTableInventoryRow.getColumnModel().getColumn(i).setCellRenderer(new EnabledTableCellRenderer()); jTableInventoryRow.getColumnModel().getColumn(i).setPreferredWidth(pColumwidth[i]); From efbad2b2bdd1f4456c504e9924551043d82f02aa Mon Sep 17 00:00:00 2001 From: Alessandro Domanico Date: Fri, 20 Dec 2024 00:37:23 +0100 Subject: [PATCH 107/147] Update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 0297b67474..73a6c8c691 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1201,7 +1201,7 @@ public InventoryRowModel(boolean add) throws OHServiceException { public InventoryRowModel() throws OHServiceException { inventoryRowList.clear(); - inventoryRowSearchList.clear(); + inventoryRowSearchList.clear(); if (inventory != null) { inventoryRowList = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()); } From 465f9fff5f5a1b323dab0a72db683982747e8741 Mon Sep 17 00:00:00 2001 From: mwithi Date: Fri, 20 Dec 2024 01:40:58 +0100 Subject: [PATCH 108/147] Improve cell rendering --- .../medicalinventory/gui/InventoryEdit.java | 98 ++++++++++--------- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 73a6c8c691..ef3f68a331 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -21,7 +21,7 @@ */ package org.isf.medicalinventory.gui; -import static org.isf.utils.Constants.DATE_TIME_FORMATTER; +import static org.isf.utils.Constants.DATE_FORMATTER; import java.awt.AWTEvent; import java.awt.BorderLayout; @@ -207,6 +207,10 @@ private void fireInventoryUpdated() { private boolean[] columnEditableView = { false, false, false, false, false, false, false, false, false, false }; private boolean[] pColumnVisible = { false, true, true, true, !GeneralData.AUTOMATICLOT_IN, true, true, true, GeneralData.LOTWITHCOST, GeneralData.LOTWITHCOST }; + private boolean[] columnCentered = { false, false, false, true, true, true, true, true, true, true }; + private boolean[] columnDecimalNumber = { false, false, false, false, false, false, false, false, true, true }; + private Class< ? >[] columnsClasses = { String.class, Integer.class, String.class, String.class, String.class, LocalDate.class, Integer.class, + Integer.class, BigDecimal.class, BigDecimal.class }; private MedicalInventory inventory = null; private JLabel specificRadio; private JLabel dateInventoryLabel; @@ -1123,17 +1127,19 @@ private JTable getJTableInventoryRow() throws OHServiceException { jTableInventoryRow.setModel(model); jTableInventoryRow.setAutoCreateColumnsFromModel(false); for (int i = 0; i < pColumnVisible.length; i++) { - jTableInventoryRow.getColumnModel().getColumn(i).setCellRenderer(new EnabledTableCellRenderer()); jTableInventoryRow.getColumnModel().getColumn(i).setPreferredWidth(pColumwidth[i]); - if (i == 0 || !pColumnVisible[i]) { + if (!pColumnVisible[i]) { jTableInventoryRow.getColumnModel().getColumn(i).setMinWidth(0); jTableInventoryRow.getColumnModel().getColumn(i).setMaxWidth(0); jTableInventoryRow.getColumnModel().getColumn(i).setPreferredWidth(0); } + if (columnCentered[i]) { + jTableInventoryRow.getColumnModel().getColumn(i).setCellRenderer(new CenterTableCellRenderer()); + } + if (columnDecimalNumber[i]) { + jTableInventoryRow.getColumnModel().getColumn(i).setCellRenderer(new DeciamlNumberTableCellRenderer()); + } } - DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer(); - centerRenderer.setHorizontalAlignment(JLabel.CENTER); - jTableInventoryRow.getColumnModel().getColumn(3).setCellRenderer(centerRenderer); jTableInventoryRow.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override @@ -1175,17 +1181,6 @@ public void valueChanged(ListSelectionEvent e) { return jTableInventoryRow; } - class EnabledTableCellRenderer extends DefaultTableCellRenderer { - - private static final long serialVersionUID = 1L; - - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - return cell; - } - } - class InventoryRowModel extends DefaultTableModel { private static final long serialVersionUID = 1L; @@ -1247,28 +1242,7 @@ public InventoryRowModel(MedicalType medType, boolean withMovement) throws OHSer } public Class< ? > getColumnClass(int c) { - if (c == 0) { - return Integer.class; - } else if (c == 1) { - return String.class; - } else if (c == 2) { - return String.class; - } else if (c == 3) { - return String.class; - } else if (c == 4) { - return String.class; - } else if (c == 5) { - return String.class; - } else if (c == 6) { - return Double.class; - } else if (c == 7) { - return Double.class; - } else if (c == 8) { - return BigDecimal.class; - } else if (c == 9) { - return Double.class; - } - return null; + return columnsClasses[c]; } public int getRowCount() { @@ -1310,7 +1284,7 @@ public Object getValueAt(int r, int c) { } else if (c == 5) { if (medInvtRow.getLot() != null) { if (medInvtRow.getLot().getDueDate() != null) { - return medInvtRow.getLot().getDueDate().format(DATE_TIME_FORMATTER); + return medInvtRow.getLot().getDueDate().format(DATE_FORMATTER); } } return ""; @@ -1323,18 +1297,18 @@ public Object getValueAt(int r, int c) { } else if (c == 8) { if (medInvtRow.getLot() != null) { if (medInvtRow.getLot().getCost() != null) { - medInvtRow.setTotal(medInvtRow.getRealQty() * medInvtRow.getLot().getCost().doubleValue()); + medInvtRow.setTotal(medInvtRow.getLot().getCost().multiply(BigDecimal.valueOf(medInvtRow.getRealQty()))); return medInvtRow.getLot().getCost(); } } - return new BigDecimal("0.00"); + return BigDecimal.ZERO; } else if (c == 9) { if (medInvtRow.getLot() != null) { if (medInvtRow.getLot().getCost() != null) { return medInvtRow.getTotal(); } } - return 0.0; + return BigDecimal.ZERO; } } return null; @@ -1360,7 +1334,7 @@ public void setValueAt(Object value, int r, int c) { } invRow.setRealqty(intValue); if (invRow.getLot() != null && invRow.getLot().getCost() != null) { - double total = invRow.getRealQty() * invRow.getLot().getCost().doubleValue(); + BigDecimal total = invRow.getLot().getCost().multiply(BigDecimal.valueOf(invRow.getRealQty())); invRow.setTotal(total); } inventoryRowListAdded.add(invRow); @@ -1386,10 +1360,10 @@ private Lot getLot(Lot lotToUpdate) throws OHServiceException { LocalDateTime expiringDate = askExpiringDate(); lot = new Lot("", preparationDate, expiringDate); // Cost - BigDecimal cost = new BigDecimal(0); + BigDecimal cost = BigDecimal.ZERO; if (isLotWithCost()) { cost = askCost(2, cost); - if (cost.compareTo(new BigDecimal(0)) == 0) { + if (cost.compareTo(BigDecimal.ZERO) == 0) { return null; } } @@ -1443,7 +1417,7 @@ private Lot askLot(Lot lotToUpdate) { expiringDate = expireDateChooser.getDateEndOfDay(); preparationDate = preparationDateChooser.getDateStartOfDay(); lot = new Lot(lotName, preparationDate, expiringDate); - BigDecimal cost = new BigDecimal(0); + BigDecimal cost = BigDecimal.ZERO; if (isLotWithCost()) { if (lotToUpdate != null) { cost = askCost(2, lotToUpdate.getCost()); @@ -1451,7 +1425,7 @@ private Lot askLot(Lot lotToUpdate) { cost = askCost(2, cost); } - if (cost.compareTo(new BigDecimal(0)) == 0) { + if (cost.compareTo(BigDecimal.ZERO) == 0) { return null; } else { lot.setCost(cost); @@ -2304,4 +2278,32 @@ private void initializeActions() { } }); } + + class CenterTableCellRenderer extends DefaultTableCellRenderer { + + private static final long serialVersionUID = 1L; + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + + Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + setHorizontalAlignment(CENTER); + return cell; + } + } + + public class DeciamlNumberTableCellRenderer extends DefaultTableCellRenderer { + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + + JLabel lbl = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + if (value instanceof BigDecimal) { + lbl.setText(String.format("%.02f", value)); + } + lbl.setOpaque(true); + lbl.setBackground(Color.WHITE); + setHorizontalAlignment(CENTER); + return lbl; + } + } } From 28f10e552d070fc3b88b07d3bfcea69909a0e819 Mon Sep 17 00:00:00 2001 From: mwithi Date: Fri, 20 Dec 2024 01:43:24 +0100 Subject: [PATCH 109/147] Fix typo --- .../java/org/isf/medicalinventory/gui/InventoryEdit.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index ef3f68a331..8a062f444c 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1137,7 +1137,7 @@ private JTable getJTableInventoryRow() throws OHServiceException { jTableInventoryRow.getColumnModel().getColumn(i).setCellRenderer(new CenterTableCellRenderer()); } if (columnDecimalNumber[i]) { - jTableInventoryRow.getColumnModel().getColumn(i).setCellRenderer(new DeciamlNumberTableCellRenderer()); + jTableInventoryRow.getColumnModel().getColumn(i).setCellRenderer(new DecimalNumberTableCellRenderer()); } } jTableInventoryRow.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @@ -2292,7 +2292,9 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole } } - public class DeciamlNumberTableCellRenderer extends DefaultTableCellRenderer { + public class DecimalNumberTableCellRenderer extends DefaultTableCellRenderer { + + private static final long serialVersionUID = 1L; public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { From 590650fdcdfdee6ed1cdcdfe8e4bc61233f97748 Mon Sep 17 00:00:00 2001 From: mwithi Date: Fri, 20 Dec 2024 01:48:16 +0100 Subject: [PATCH 110/147] Improve cell rendering in browser --- .../gui/InventoryBrowser.java | 88 +++++++++++-------- 1 file changed, 51 insertions(+), 37 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index ab6b1973f4..3b22e0d6cc 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -25,6 +25,7 @@ import java.awt.AWTEvent; import java.awt.BorderLayout; +import java.awt.Component; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; @@ -53,6 +54,7 @@ import javax.swing.border.EmptyBorder; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; import org.isf.generaldata.MessageBundle; @@ -89,11 +91,12 @@ public class InventoryBrowser extends ModalJFrame implements InventoryListener { private JButton jButtonView; private JScrollPane scrollPaneInventory; private JTable jTableInventory; - private String[] pColums = { MessageBundle.getMessage("angal.common.reference.label").toUpperCase(), + private String[] columsNames = { MessageBundle.getMessage("angal.common.reference.label").toUpperCase(), MessageBundle.getMessage("angal.common.date.txt").toUpperCase(), MessageBundle.getMessage("angal.inventory.status.txt").toUpperCase(), MessageBundle.getMessage("angal.common.user.col").toUpperCase() }; - private int[] pColumwidth = { 150, 150, 150, 200 }; + private int[] columwidth = { 150, 150, 150, 200 }; + private boolean[] columnCentered = { false, true, true, true }; private JComboBox statusComboBox; private JLabel statusLabel; JButton next; @@ -125,7 +128,6 @@ private void initComponents() { panelFooter = getPanelFooter(); getContentPane().add(panelFooter, BorderLayout.SOUTH); - ajustWidth(); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { @@ -342,7 +344,7 @@ private JButton getNewButton() { List validatedMedicalInventories = new ArrayList<>(); try { draftMedicalInventories = medicalInventoryManager.getMedicalInventoryByStatusAndInventoryType(draft, inventoryType); - validatedMedicalInventories = medicalInventoryManager.getMedicalInventoryByStatusAndInventoryType(validated, inventoryType); + validatedMedicalInventories = medicalInventoryManager.getMedicalInventoryByStatusAndInventoryType(validated, inventoryType); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } @@ -378,12 +380,12 @@ private JButton getUpdateButton() { MessageDialog.error(null, "angal.inventory.cancelednoteditable.msg"); return; } - + if (inventory.getStatus().equals(InventoryStatus.done.toString())) { MessageDialog.error(null, "angal.inventory.donenoteditable.msg"); return; } - InventoryEdit inventoryEdit = new InventoryEdit(inventory,"update"); + InventoryEdit inventoryEdit = new InventoryEdit(inventory, "update"); InventoryEdit.addInventoryListener(InventoryBrowser.this); inventoryEdit.showAsModal(InventoryBrowser.this); }); @@ -395,22 +397,22 @@ private JButton getViewButton() { jButtonView.setMnemonic(MessageBundle.getMnemonic("angal.common.view.btn.key")); jButtonView.setEnabled(false); jButtonView.addActionListener(actionEvent -> { - MedicalInventory inventory = new MedicalInventory(); - if (jTableInventory.getSelectedRowCount() > 1) { - MessageDialog.error(this, "angal.inventory.pleaseselectonlyoneinventory.msg"); - return; - } - int selectedRow = jTableInventory.getSelectedRow(); - if (selectedRow == -1) { - MessageDialog.error(this, "angal.inventory.pleaseselectinventory.msg"); - return; - } - if(selectedRow > -1) { - inventory = inventoryList.get(selectedRow); - InventoryEdit inventoryEdit = new InventoryEdit(inventory,"view"); - InventoryEdit.addInventoryListener(InventoryBrowser.this); - inventoryEdit.showAsModal(InventoryBrowser.this); - } + MedicalInventory inventory = new MedicalInventory(); + if (jTableInventory.getSelectedRowCount() > 1) { + MessageDialog.error(this, "angal.inventory.pleaseselectonlyoneinventory.msg"); + return; + } + int selectedRow = jTableInventory.getSelectedRow(); + if (selectedRow == -1) { + MessageDialog.error(this, "angal.inventory.pleaseselectinventory.msg"); + return; + } + if (selectedRow > -1) { + inventory = inventoryList.get(selectedRow); + InventoryEdit inventoryEdit = new InventoryEdit(inventory, "view"); + InventoryEdit.addInventoryListener(InventoryBrowser.this); + inventoryEdit.showAsModal(InventoryBrowser.this); + } }); return jButtonView; } @@ -450,8 +452,6 @@ private JButton getDeleteButton() { return jButtonDelete; } - - private JButton getCloseButton() { jButtonClose = new JButton(MessageBundle.getMessage("angal.common.close.btn")); jButtonClose.setMnemonic(MessageBundle.getMnemonic("angal.common.close.btn.key")); @@ -474,6 +474,13 @@ private JTable getJTableInventory() { jTableInventory = new JTable(); jTableInventory.setFillsViewportHeight(true); jTableInventory.setModel(new InventoryBrowsingModel()); + jTableInventory.setAutoCreateColumnsFromModel(false); + for (int i = 0; i < columwidth.length; i++) { + jTableInventory.getColumnModel().getColumn(i).setMinWidth(columwidth[i]); + if (columnCentered[i]) { + jTableInventory.getColumnModel().getColumn(i).setCellRenderer(new CenterTableCellRenderer()); + } + } jTableInventory.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override @@ -483,14 +490,14 @@ public void valueChanged(ListSelectionEvent e) { if (selectedRows.length == 1) { int selectedRow = jTableInventory.getSelectedRow(); MedicalInventory inventory = inventoryList.get(selectedRow); - if (inventory.getStatus().equals(InventoryStatus.canceled.toString()) || - inventory.getStatus().equals(InventoryStatus.done.toString())) { + if (inventory.getStatus().equals(InventoryStatus.canceled.toString()) || + inventory.getStatus().equals(InventoryStatus.done.toString())) { jButtonEdit.setEnabled(false); jButtonDelete.setEnabled(false); } else { jButtonEdit.setEnabled(true); jButtonDelete.setEnabled(true); - + } jButtonView.setEnabled(true); jButtonView.setEnabled(true); @@ -507,7 +514,7 @@ public void valueChanged(ListSelectionEvent e) { } return jTableInventory; } - + class InventoryBrowsingModel extends DefaultTableModel { private static final long serialVersionUID = 1L; @@ -529,7 +536,7 @@ public InventoryBrowsingModel(int startIndex, int pageSize) { String type = InventoryType.main.toString(); try { Page medInventorypage = medicalInventoryManager.getMedicalInventoryByParamsPageable(dateFrom, dateTo, state, type, startIndex, - pageSize); + pageSize); inventoryList = medInventorypage.getContent(); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); @@ -557,11 +564,11 @@ public int getRowCount() { } public String getColumnName(int c) { - return pColums[c]; + return columsNames[c]; } public int getColumnCount() { - return pColums.length; + return columsNames.length; } public Object getValueAt(int r, int c) { @@ -592,12 +599,6 @@ public String formatDateTime(GregorianCalendar time) { return format.format(time.getTime()); } - private void ajustWidth() { - for (int i = 0; i < pColumwidth.length; i++) { - jTableInventory.getColumnModel().getColumn(i).setMinWidth(pColumwidth[i]); - } - } - private JComboBox getComboBox() { if (statusComboBox == null) { statusComboBox = new JComboBox(); @@ -661,4 +662,17 @@ public void InventoryInserted(AWTEvent e) { public void InventoryUpdated(AWTEvent e) { jTableInventory.setModel(new InventoryBrowsingModel()); } + + class CenterTableCellRenderer extends DefaultTableCellRenderer { + + private static final long serialVersionUID = 1L; + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + + Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + setHorizontalAlignment(CENTER); + return cell; + } + } } From d8b04ad5426f68a37017bcd9977d8291f8ed4ca9 Mon Sep 17 00:00:00 2001 From: mwithi Date: Fri, 20 Dec 2024 01:51:09 +0100 Subject: [PATCH 111/147] Change columns headers --- bundle/language_en.properties | 4 ++-- .../org/isf/medicalinventory/gui/InventoryEdit.java | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index bacbd40e3c..0163092ee7 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -749,8 +749,8 @@ angal.inventory.status.done.txt angal.inventory.status.validated.txt = Validated angal.inventory.specificproduct.txt = Specific product angal.inventoryrow.theoreticqty.col = Theoretic Qty -angal.inventory.totalprice = Total price -angal.inventoryrow.unitprice.col = Unit price +angal.inventoryrow.totalcost.col = Total cost +angal.inventoryrow.unitcost.col = Unit cost angal.inventory.pleasevalidateinventoryagainsbeforeconfirmation.msg = Please validate this inventory again before confirmation. angal.invetory.tablehasbeenupdated.msg = Table has been updated. angal.inventory.update.error.msg = Inventory not updated. diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 8a062f444c..a636b583ac 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -200,12 +200,12 @@ private void fireInventoryUpdated() { MessageBundle.getMessage("angal.medicalstock.duedate.col").toUpperCase(), MessageBundle.getMessage("angal.inventoryrow.theoreticqty.col").toUpperCase(), MessageBundle.getMessage("angal.inventoryrow.realqty.col").toUpperCase(), - MessageBundle.getMessage("angal.inventoryrow.unitprice.col").toUpperCase(), - MessageBundle.getMessage("angal.inventory.totalprice").toUpperCase() }; + MessageBundle.getMessage("angal.inventoryrow.unitcost.col").toUpperCase(), + MessageBundle.getMessage("angal.inventoryrow.totalcost.col").toUpperCase() }; private int[] pColumwidth = { 50, 50, 200, 100, 100, 100, 100, 80, 80, 80 }; private boolean[] columnEditable = { false, false, false, false, false, false, false, true, false, false }; private boolean[] columnEditableView = { false, false, false, false, false, false, false, false, false, false }; - private boolean[] pColumnVisible = { false, true, true, true, !GeneralData.AUTOMATICLOT_IN, true, true, true, GeneralData.LOTWITHCOST, + private boolean[] columnVisible = { false, true, true, true, !GeneralData.AUTOMATICLOT_IN, true, true, true, GeneralData.LOTWITHCOST, GeneralData.LOTWITHCOST }; private boolean[] columnCentered = { false, false, false, true, true, true, true, true, true, true }; private boolean[] columnDecimalNumber = { false, false, false, false, false, false, false, false, true, true }; @@ -1126,9 +1126,9 @@ private JTable getJTableInventoryRow() throws OHServiceException { model = new InventoryRowModel(); jTableInventoryRow.setModel(model); jTableInventoryRow.setAutoCreateColumnsFromModel(false); - for (int i = 0; i < pColumnVisible.length; i++) { + for (int i = 0; i < columnVisible.length; i++) { jTableInventoryRow.getColumnModel().getColumn(i).setPreferredWidth(pColumwidth[i]); - if (!pColumnVisible[i]) { + if (!columnVisible[i]) { jTableInventoryRow.getColumnModel().getColumn(i).setMinWidth(0); jTableInventoryRow.getColumnModel().getColumn(i).setMaxWidth(0); jTableInventoryRow.getColumnModel().getColumn(i).setPreferredWidth(0); From 9fe3930b08fc9769c856f8c98e05bf7fc9b0e3d9 Mon Sep 17 00:00:00 2001 From: mwithi Date: Fri, 20 Dec 2024 01:52:46 +0100 Subject: [PATCH 112/147] Refactor variables --- .../org/isf/medicalinventory/gui/InventoryEdit.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index a636b583ac..f1e578e149 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -192,7 +192,7 @@ private void fireInventoryUpdated() { private List lotsSaved = new ArrayList<>(); private HashMap lotsDeleted = new HashMap<>(); List inventoryRowsToDelete = new ArrayList<>(); - private String[] pColums = { MessageBundle.getMessage("angal.inventory.id.col").toUpperCase(), + private String[] columsNames = { MessageBundle.getMessage("angal.inventory.id.col").toUpperCase(), MessageBundle.getMessage("angal.common.code.txt").toUpperCase(), MessageBundle.getMessage("angal.inventory.product.col").toUpperCase(), MessageBundle.getMessage("angal.inventory.newlot.col").toUpperCase(), @@ -202,7 +202,7 @@ private void fireInventoryUpdated() { MessageBundle.getMessage("angal.inventoryrow.realqty.col").toUpperCase(), MessageBundle.getMessage("angal.inventoryrow.unitcost.col").toUpperCase(), MessageBundle.getMessage("angal.inventoryrow.totalcost.col").toUpperCase() }; - private int[] pColumwidth = { 50, 50, 200, 100, 100, 100, 100, 80, 80, 80 }; + private int[] columwidth = { 50, 50, 200, 100, 100, 100, 100, 80, 80, 80 }; private boolean[] columnEditable = { false, false, false, false, false, false, false, true, false, false }; private boolean[] columnEditableView = { false, false, false, false, false, false, false, false, false, false }; private boolean[] columnVisible = { false, true, true, true, !GeneralData.AUTOMATICLOT_IN, true, true, true, GeneralData.LOTWITHCOST, @@ -1127,7 +1127,7 @@ private JTable getJTableInventoryRow() throws OHServiceException { jTableInventoryRow.setModel(model); jTableInventoryRow.setAutoCreateColumnsFromModel(false); for (int i = 0; i < columnVisible.length; i++) { - jTableInventoryRow.getColumnModel().getColumn(i).setPreferredWidth(pColumwidth[i]); + jTableInventoryRow.getColumnModel().getColumn(i).setPreferredWidth(columwidth[i]); if (!columnVisible[i]) { jTableInventoryRow.getColumnModel().getColumn(i).setMinWidth(0); jTableInventoryRow.getColumnModel().getColumn(i).setMaxWidth(0); @@ -1253,11 +1253,11 @@ public int getRowCount() { } public String getColumnName(int c) { - return pColums[c]; + return columsNames[c]; } public int getColumnCount() { - return pColums.length; + return columsNames.length; } public Object getValueAt(int r, int c) { From cd60a8624619696987ffcd22e9104c30d4f2fd75 Mon Sep 17 00:00:00 2001 From: mwithi Date: Fri, 20 Dec 2024 02:13:01 +0100 Subject: [PATCH 113/147] Standardize bundles --- bundle/language_en.properties | 10 +++++----- .../medicalinventory/gui/InventoryEdit.java | 20 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 0163092ee7..60c41b1742 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -748,16 +748,16 @@ angal.inventory.status.draft.txt angal.inventory.status.done.txt = Done angal.inventory.status.validated.txt = Validated angal.inventory.specificproduct.txt = Specific product -angal.inventoryrow.theoreticqty.col = Theoretic Qty -angal.inventoryrow.totalcost.col = Total cost -angal.inventoryrow.unitcost.col = Unit cost +angal.inventory.theoreticqty.col = Theoretic Qty +angal.inventory.totalcost.col = Total cost +angal.inventory.unitcost.col = Unit cost angal.inventory.pleasevalidateinventoryagainsbeforeconfirmation.msg = Please validate this inventory again before confirmation. -angal.invetory.tablehasbeenupdated.msg = Table has been updated. +angal.inventory.tablehasbeenupdated.msg = Table has been updated. angal.inventory.update.error.msg = Inventory not updated. angal.inventory.update.success.msg = Inventory updated. angal.inventory.doyouwanttoupdatethisinventory.msg = Do you want to update this inventory? angal.inventory.nothinghasbeenaddedonthisinventory.msg = Nothing has been added to this inventory. = Done -angal.invetory.notdataforthatfilter.msg = No data available for that filter. +angal.inventory.notdataforthatfilter.msg = No data available for that filter. angal.inventory.validate.btn = Validate angal.inventory.validate.btn.key = V angal.inventory.inventorymustsavebeforevalidation.msg = Inventory must be saved before validation. diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index f1e578e149..9f49fc190a 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -198,10 +198,10 @@ private void fireInventoryUpdated() { MessageBundle.getMessage("angal.inventory.newlot.col").toUpperCase(), MessageBundle.getMessage("angal.wardpharmacy.lotnumber.col").toUpperCase(), MessageBundle.getMessage("angal.medicalstock.duedate.col").toUpperCase(), - MessageBundle.getMessage("angal.inventoryrow.theoreticqty.col").toUpperCase(), + MessageBundle.getMessage("angal.inventory.theoreticqty.col").toUpperCase(), MessageBundle.getMessage("angal.inventoryrow.realqty.col").toUpperCase(), - MessageBundle.getMessage("angal.inventoryrow.unitcost.col").toUpperCase(), - MessageBundle.getMessage("angal.inventoryrow.totalcost.col").toUpperCase() }; + MessageBundle.getMessage("angal.inventory.unitcost.col").toUpperCase(), + MessageBundle.getMessage("angal.inventory.totalcost.col").toUpperCase() }; private int[] columwidth = { 50, 50, 200, 100, 100, 100, 100, 80, 80, 80 }; private boolean[] columnEditable = { false, false, false, false, false, false, false, true, false, false }; private boolean[] columnEditableView = { false, false, false, false, false, false, false, false, false, false }; @@ -1226,7 +1226,7 @@ public InventoryRowModel(boolean withNoZeroQty, MedicalType medType) throws OHSe addMedInRowInInventorySearchList(invRow); } } else { - MessageDialog.info(null, "angal.invetory.notdataforthatfilter.msg"); + MessageDialog.info(null, "angal.inventory.notdataforthatfilter.msg"); } } @@ -1237,7 +1237,7 @@ public InventoryRowModel(MedicalType medType, boolean withMovement) throws OHSer addMedInRowInInventorySearchList(invRow); } } else { - MessageDialog.info(null, "angal.invetory.notdataforthatfilter.msg"); + MessageDialog.info(null, "angal.inventory.notdataforthatfilter.msg"); } } @@ -2182,7 +2182,7 @@ private void initializeActions() { jTableInventoryRow.setModel(new InventoryRowModel(medType)); } fireInventoryUpdated(); - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + MessageDialog.info(null, "angal.inventory.tablehasbeenupdated.msg"); } else { MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); } @@ -2204,7 +2204,7 @@ private void initializeActions() { } fireInventoryUpdated(); if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + MessageDialog.info(null, "angal.inventory.tablehasbeenupdated.msg"); } } else { MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); @@ -2223,7 +2223,7 @@ private void initializeActions() { jTableInventoryRow.setModel(new InventoryRowModel(true, medType)); fireInventoryUpdated(); if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + MessageDialog.info(null, "angal.inventory.tablehasbeenupdated.msg"); } } } else { @@ -2246,7 +2246,7 @@ private void initializeActions() { jTableInventoryRow.setModel(new InventoryRowModel(null, true)); fireInventoryUpdated(); if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + MessageDialog.info(null, "angal.inventory.tablehasbeenupdated.msg"); } } } else { @@ -2266,7 +2266,7 @@ private void initializeActions() { jTableInventoryRow.setModel(new InventoryRowModel(medType, true)); fireInventoryUpdated(); if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + MessageDialog.info(null, "angal.inventory.tablehasbeenupdated.msg"); } } } else { From b2e259cac96d9efcfa602fe1830143c9c31d59e2 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Fri, 20 Dec 2024 10:03:00 +0100 Subject: [PATCH 114/147] enhance product selection --- .../medicalinventory/gui/InventoryEdit.java | 282 +++++------------- 1 file changed, 77 insertions(+), 205 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 6fc6ebf609..0e6d1e04ed 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -243,6 +243,7 @@ private void fireInventoryUpdated() { private JComboBox medicalTypeComboBox; private List medicals = new ArrayList<>(); private Map actions = new HashMap<>(); + private boolean noData = false; private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); private MedicalInventoryRowManager medicalInventoryRowManager = Context.getApplicationContext().getBean(MedicalInventoryRowManager.class); private MedicalBrowsingManager medicalBrowsingManager = Context.getApplicationContext().getBean(MedicalBrowsingManager.class); @@ -1187,60 +1188,56 @@ class InventoryRowModel extends DefaultTableModel { private static final long serialVersionUID = 1L; - public InventoryRowModel(boolean add) throws OHServiceException { - inventoryRowList = loadNewInventoryTable(null, inventory, add); - if (!inventoryRowList.isEmpty()) { - for (MedicalInventoryRow invRow : inventoryRowList) { - addMedInRowInInventorySearchList(invRow); - } - } - } - public InventoryRowModel() throws OHServiceException { - inventoryRowSearchList.clear(); - if (inventory != null) { - inventoryRowList = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()); - } - if (!inventoryRowList.isEmpty()) { - for (MedicalInventoryRow invRow : inventoryRowList) { - addMedInRowInInventorySearchList(invRow); - if (invRow.getId() == 0) { - inventoryRowListAdded.add(invRow); - } - } - } - } + this(null, false, false, false); + } - public InventoryRowModel(MedicalType medType) throws OHServiceException { - inventoryRowList = loadNewInventoryTableByMedicalType(medType); - if (!inventoryRowList.isEmpty()) { - for (MedicalInventoryRow invRow : inventoryRowList) { - addMedInRowInInventorySearchList(invRow); - } - } - } + public InventoryRowModel(boolean add) throws OHServiceException { + this(null, false, add, false); + } - public InventoryRowModel(boolean withNoZeroQty, MedicalType medType) throws OHServiceException { - inventoryRowList = loadNewInventoryTable(withNoZeroQty, medType); - if (!inventoryRowList.isEmpty()) { - for (MedicalInventoryRow invRow : inventoryRowList) { - addMedInRowInInventorySearchList(invRow); - } - } else { - MessageDialog.info(null, "angal.invetory.notdataforthatfilter.msg"); - } - } + public InventoryRowModel(MedicalType medType) throws OHServiceException { + this(medType, false, false, false); + } - public InventoryRowModel(MedicalType medType, boolean withMovement) throws OHServiceException { - inventoryRowList = loadNewInventoryTable(medType); - if (!inventoryRowList.isEmpty()) { - for (MedicalInventoryRow invRow : inventoryRowList) { - addMedInRowInInventorySearchList(invRow); - } - } else { - MessageDialog.info(null, "angal.invetory.notdataforthatfilter.msg"); - } - } + public InventoryRowModel(boolean withNoZeroQty, MedicalType medType) throws OHServiceException { + this(medType, withNoZeroQty, false, false); + } + + public InventoryRowModel(MedicalType medType, boolean withMovement) throws OHServiceException { + this(medType, false, false, withMovement); + } + + public InventoryRowModel(MedicalType medType, boolean withNoZeroQty, boolean add, boolean withMovement) throws OHServiceException { + if (add) { + inventoryRowList = loadNewInventoryTable(null, inventory, true); + } else if (withMovement) { + inventoryRowList = loadNewInventoryTable(medType); + } else if (withNoZeroQty) { + inventoryRowList = loadNewInventoryTable(withNoZeroQty, medType); + } else if (medType != null) { + inventoryRowList = loadNewInventoryTableByMedicalType(medType); + } else { + inventoryRowSearchList.clear(); + if (inventory != null) { + inventoryRowList = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()); + } + } + + if (!inventoryRowList.isEmpty()) { + for (MedicalInventoryRow invRow : inventoryRowList) { + addMedInRowInInventorySearchList(invRow); + if (!add && invRow.getId() == 0) { + inventoryRowListAdded.add(invRow); + } + } + } else { + if (!mode.equals("new")) { + noData = true; + MessageDialog.info(null, "angal.invetory.notdataforthatfilter.msg"); + } + } + } public Class< ? > getColumnClass(int c) { if (c == 0) { @@ -2189,168 +2186,43 @@ private boolean areAllMedicalsInInventory() throws OHServiceException { } private void initializeActions() { - actions.put(radioButtonAll, () -> handleInventoryUpdate( - medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt")), - null, null, "angal.invetory.allmedicaladdedsuccessfully.msg" - )); - - actions.put(radioOnlyNonZero, () -> handleInventoryUpdate( - medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt")), - true, medicalTypeSelected, "angal.invetory.tablehasbeenupdated.msg" - )); - - actions.put(radioWithMovement, () -> handleInventoryUpdate( - medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt")), - null, medicalTypeSelected, "angal.invetory.tablehasbeenupdated.msg" - )); + actions.put(radioButtonAll, () -> handleInventoryUpdate(true, false, false)); + actions.put(radioOnlyNonZero, () -> handleInventoryUpdate(false, false, true)); + actions.put(radioWithMovement, () -> handleInventoryUpdate(false, true, false)); + noData = false; } - private void handleInventoryUpdate(boolean isAllSelected, Boolean withNoZeroQty, MedicalType medType, String successMessage) { - try { - if (areAllMedicalsInInventory()) { - MessageDialog.info(null, "angal.inventory.allmedicalsarealreadyin.msg"); - return; - } - - int info = (!inventoryRowSearchList.isEmpty()) - ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") - : JOptionPane.YES_OPTION; + private void handleInventoryUpdate(boolean includeAll, boolean withMovement, boolean nonZero) { + boolean isAllSelected = medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt")); + MedicalType medType = isAllSelected ? null : (MedicalType) medicalTypeComboBox.getSelectedItem(); - if (info == JOptionPane.YES_OPTION) { - InventoryRowModel model; - if (isAllSelected) { - model = new InventoryRowModel(withNoZeroQty != null ? withNoZeroQty : true); - } else { - model = new InventoryRowModel(medType, withNoZeroQty != null); + try { + if (!areAllMedicalsInInventory()) { + int userChoice = (!inventoryRowSearchList.isEmpty()) + ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") + : JOptionPane.YES_OPTION; + + if (userChoice == JOptionPane.YES_OPTION) { + jTableInventoryRow.setModel(new InventoryRowModel(medType, nonZero,includeAll, withMovement)); + fireInventoryUpdated(); + adjustWidth(); + showUpdateSuccessMessage(); } - - jTableInventoryRow.setModel(model); - fireInventoryUpdated(); - adjustWidth(); - MessageDialog.info(null, successMessage); + } else { + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); } } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); } } - /*private void initializeActions() { - actions.put(radioButtonAll, () -> { - if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { - try { - if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; - if (info == JOptionPane.YES_OPTION) { - jTableInventoryRow.setModel(new InventoryRowModel(true)); - } - fireInventoryUpdated(); - adjustWidth(); - MessageDialog.info(null, "angal.invetory.allmedicaladdedsuccessfully.msg"); - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } else { - try { - if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; - if (info == JOptionPane.YES_OPTION) { - MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); - jTableInventoryRow.setModel(new InventoryRowModel(medType)); - } - fireInventoryUpdated(); - adjustWidth(); - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - }); - - actions.put(radioOnlyNonZero, () -> { - if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { - try { - if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; - if (info == JOptionPane.YES_OPTION) { - jTableInventoryRow.setModel(new InventoryRowModel(true, null)); - } - fireInventoryUpdated(); - adjustWidth(); - if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } else { - try { - if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; - if (info == JOptionPane.YES_OPTION) { - MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); - jTableInventoryRow.setModel(new InventoryRowModel(true, medType)); - fireInventoryUpdated(); - adjustWidth(); - if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } - } - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - }); - - actions.put(radioWithMovement, () -> { - if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { - try { - if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; - if (info == JOptionPane.YES_OPTION) { - jTableInventoryRow.setModel(new InventoryRowModel(null, true)); - fireInventoryUpdated(); - adjustWidth(); - if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } - } - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } else { - try { - if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; - if (info == JOptionPane.YES_OPTION) { - MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); - jTableInventoryRow.setModel(new InventoryRowModel(medType, true)); - fireInventoryUpdated(); - adjustWidth(); - if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } - } - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - }); - }*/ + + private void showUpdateSuccessMessage() { + if (!inventoryRowList.isEmpty()) { + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } else { + if (!noData) { + MessageDialog.info(null, "angal.invetory.allmedicaladdedsuccessfully.msg"); + } + } + } } From 7fa3d5dcb52819bfc75daa8b239d96af7c85b429 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Fri, 20 Dec 2024 11:50:42 +0100 Subject: [PATCH 115/147] update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java --- .../medicalinventory/gui/InventoryEdit.java | 153 ++++++++++++++++-- 1 file changed, 137 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 0e6d1e04ed..9648801a45 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -243,7 +243,6 @@ private void fireInventoryUpdated() { private JComboBox medicalTypeComboBox; private List medicals = new ArrayList<>(); private Map actions = new HashMap<>(); - private boolean noData = false; private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); private MedicalInventoryRowManager medicalInventoryRowManager = Context.getApplicationContext().getBean(MedicalInventoryRowManager.class); private MedicalBrowsingManager medicalBrowsingManager = Context.getApplicationContext().getBean(MedicalBrowsingManager.class); @@ -1207,16 +1206,22 @@ public InventoryRowModel(boolean withNoZeroQty, MedicalType medType) throws OHSe public InventoryRowModel(MedicalType medType, boolean withMovement) throws OHServiceException { this(medType, false, false, withMovement); } - - public InventoryRowModel(MedicalType medType, boolean withNoZeroQty, boolean add, boolean withMovement) throws OHServiceException { - if (add) { - inventoryRowList = loadNewInventoryTable(null, inventory, true); + + public InventoryRowModel(MedicalType medType, boolean withNoZeroQty, boolean includeAll, boolean withMovement) throws OHServiceException { + if (includeAll) { + if (medType == null) { + inventoryRowList = loadNewInventoryTable(null, inventory, true); + } else { + inventoryRowList = loadNewInventoryTableByMedicalType(medType); + } } else if (withMovement) { - inventoryRowList = loadNewInventoryTable(medType); + inventoryRowList = loadNewInventoryTable(medType); } else if (withNoZeroQty) { - inventoryRowList = loadNewInventoryTable(withNoZeroQty, medType); - } else if (medType != null) { - inventoryRowList = loadNewInventoryTableByMedicalType(medType); + if (medType == null) { + inventoryRowList = loadNewInventoryTable(true, null); + } else { + inventoryRowList = loadNewInventoryTable(true, medType); + } } else { inventoryRowSearchList.clear(); if (inventory != null) { @@ -1227,13 +1232,12 @@ public InventoryRowModel(MedicalType medType, boolean withNoZeroQty, boolean add if (!inventoryRowList.isEmpty()) { for (MedicalInventoryRow invRow : inventoryRowList) { addMedInRowInInventorySearchList(invRow); - if (!add && invRow.getId() == 0) { + if (!includeAll && invRow.getId() == 0) { inventoryRowListAdded.add(invRow); } } } else { if (!mode.equals("new")) { - noData = true; MessageDialog.info(null, "angal.invetory.notdataforthatfilter.msg"); } } @@ -2189,7 +2193,6 @@ private void initializeActions() { actions.put(radioButtonAll, () -> handleInventoryUpdate(true, false, false)); actions.put(radioOnlyNonZero, () -> handleInventoryUpdate(false, false, true)); actions.put(radioWithMovement, () -> handleInventoryUpdate(false, true, false)); - noData = false; } private void handleInventoryUpdate(boolean includeAll, boolean withMovement, boolean nonZero) { @@ -2203,7 +2206,7 @@ private void handleInventoryUpdate(boolean includeAll, boolean withMovement, boo : JOptionPane.YES_OPTION; if (userChoice == JOptionPane.YES_OPTION) { - jTableInventoryRow.setModel(new InventoryRowModel(medType, nonZero,includeAll, withMovement)); + jTableInventoryRow.setModel(new InventoryRowModel(medType, nonZero, includeAll, withMovement)); fireInventoryUpdated(); adjustWidth(); showUpdateSuccessMessage(); @@ -2220,9 +2223,127 @@ private void showUpdateSuccessMessage() { if (!inventoryRowList.isEmpty()) { MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); } else { - if (!noData) { - MessageDialog.info(null, "angal.invetory.allmedicaladdedsuccessfully.msg"); - } + MessageDialog.info(null, "angal.invetory.notdataforthatfilter.msg"); } } + /*private void initializeActions() { + actions.put(radioButtonAll, () -> { + if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { + try { + if (!areAllMedicalsInInventory()) { + int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + if (info == JOptionPane.YES_OPTION) { + jTableInventoryRow.setModel(new InventoryRowModel(true)); + } + fireInventoryUpdated(); + adjustWidth(); + MessageDialog.info(null, "angal.invetory.allmedicaladdedsuccessfully.msg"); + } else { + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } else { + try { + if (!areAllMedicalsInInventory()) { + int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + if (info == JOptionPane.YES_OPTION) { + MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); + jTableInventoryRow.setModel(new InventoryRowModel(medType)); + } + fireInventoryUpdated(); + adjustWidth(); + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } else { + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + }); + + actions.put(radioOnlyNonZero, () -> { + if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { + try { + if (!areAllMedicalsInInventory()) { + int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + if (info == JOptionPane.YES_OPTION) { + jTableInventoryRow.setModel(new InventoryRowModel(true, null)); + } + fireInventoryUpdated(); + adjustWidth(); + if (!inventoryRowList.isEmpty()) { + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } + } else { + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } else { + try { + if (!areAllMedicalsInInventory()) { + int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + if (info == JOptionPane.YES_OPTION) { + MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); + jTableInventoryRow.setModel(new InventoryRowModel(true, medType)); + fireInventoryUpdated(); + adjustWidth(); + if (!inventoryRowList.isEmpty()) { + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } + } + } else { + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + }); + + actions.put(radioWithMovement, () -> { + if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { + try { + if (!areAllMedicalsInInventory()) { + int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + if (info == JOptionPane.YES_OPTION) { + jTableInventoryRow.setModel(new InventoryRowModel(null, true)); + fireInventoryUpdated(); + adjustWidth(); + if (!inventoryRowList.isEmpty()) { + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } + } + } else { + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } else { + try { + if (!areAllMedicalsInInventory()) { + int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; + if (info == JOptionPane.YES_OPTION) { + MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); + jTableInventoryRow.setModel(new InventoryRowModel(medType, true)); + fireInventoryUpdated(); + adjustWidth(); + if (!inventoryRowList.isEmpty()) { + MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); + } + } + } else { + MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); + } + } catch (OHServiceException e) { + OHServiceExceptionUtil.showMessages(e); + } + } + }); + }*/ } From f0fc4aaae6504721349a2c2f264a26bef77dae7f Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Fri, 20 Dec 2024 11:59:30 +0100 Subject: [PATCH 116/147] enhance code and avoid duplicated instruction --- .../medicalinventory/gui/InventoryEdit.java | 121 ------------------ 1 file changed, 121 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 0ba2b208db..a3e4bf4073 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -2194,7 +2194,6 @@ private void handleInventoryUpdate(boolean includeAll, boolean withMovement, boo if (userChoice == JOptionPane.YES_OPTION) { jTableInventoryRow.setModel(new InventoryRowModel(medType, nonZero, includeAll, withMovement)); fireInventoryUpdated(); - adjustWidth(); showUpdateSuccessMessage(); } } else { @@ -2212,124 +2211,4 @@ private void showUpdateSuccessMessage() { MessageDialog.info(null, "angal.invetory.notdataforthatfilter.msg"); } } - /*private void initializeActions() { - actions.put(radioButtonAll, () -> { - if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { - try { - if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; - if (info == JOptionPane.YES_OPTION) { - jTableInventoryRow.setModel(new InventoryRowModel(true)); - } - fireInventoryUpdated(); - adjustWidth(); - MessageDialog.info(null, "angal.invetory.allmedicaladdedsuccessfully.msg"); - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } else { - try { - if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; - if (info == JOptionPane.YES_OPTION) { - MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); - jTableInventoryRow.setModel(new InventoryRowModel(medType)); - } - fireInventoryUpdated(); - adjustWidth(); - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - }); - - actions.put(radioOnlyNonZero, () -> { - if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { - try { - if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; - if (info == JOptionPane.YES_OPTION) { - jTableInventoryRow.setModel(new InventoryRowModel(true, null)); - } - fireInventoryUpdated(); - adjustWidth(); - if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } else { - try { - if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; - if (info == JOptionPane.YES_OPTION) { - MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); - jTableInventoryRow.setModel(new InventoryRowModel(true, medType)); - fireInventoryUpdated(); - adjustWidth(); - if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } - } - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - }); - - actions.put(radioWithMovement, () -> { - if (medicalTypeSelected.getDescription().equals(MessageBundle.getMessage("angal.common.all.txt"))) { - try { - if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; - if (info == JOptionPane.YES_OPTION) { - jTableInventoryRow.setModel(new InventoryRowModel(null, true)); - fireInventoryUpdated(); - adjustWidth(); - if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } - } - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } else { - try { - if (!areAllMedicalsInInventory()) { - int info = (!inventoryRowSearchList.isEmpty()) ? MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttoaddallnotyetlistedproducts.msg") : JOptionPane.YES_OPTION; - if (info == JOptionPane.YES_OPTION) { - MedicalType medType = (MedicalType)medicalTypeComboBox.getSelectedItem(); - jTableInventoryRow.setModel(new InventoryRowModel(medType, true)); - fireInventoryUpdated(); - adjustWidth(); - if (!inventoryRowList.isEmpty()) { - MessageDialog.info(null, "angal.invetory.tablehasbeenupdated.msg"); - } - } - } else { - MessageDialog.info(null, "angal.inventory.youhavealreadyaddedallproduct.msg"); - } - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - }); - }*/ } From 7874a4121b63142240c8c313a01b7a37a24fa7b5 Mon Sep 17 00:00:00 2001 From: mwithi Date: Mon, 23 Dec 2024 22:13:49 +0100 Subject: [PATCH 117/147] Add missing bundle and make draft inventories more evident --- bundle/language_en.properties | 1 + .../gui/InventoryBrowser.java | 37 ++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 60c41b1742..a3cdaa0fc6 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -444,6 +444,7 @@ angal.common.selectsex.txt angal.common.sex.label = Sex: angal.common.sex.txt = Sex angal.common.sms.txt = SMS +angal.common.status.txt = Status angal.common.stockcard.btn = StockCard angal.common.stockcard.btn.key = K angal.common.stockledger.btn = Stock Ledger diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 3b22e0d6cc..25adc2d22e 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -25,6 +25,7 @@ import java.awt.AWTEvent; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.GridBagConstraints; @@ -91,9 +92,10 @@ public class InventoryBrowser extends ModalJFrame implements InventoryListener { private JButton jButtonView; private JScrollPane scrollPaneInventory; private JTable jTableInventory; - private String[] columsNames = { MessageBundle.getMessage("angal.common.reference.label").toUpperCase(), + private String[] columsNames = { + MessageBundle.getMessage("angal.common.reference.label").toUpperCase(), MessageBundle.getMessage("angal.common.date.txt").toUpperCase(), - MessageBundle.getMessage("angal.inventory.status.txt").toUpperCase(), + MessageBundle.getMessage("angal.common.status.txt").toUpperCase(), MessageBundle.getMessage("angal.common.user.col").toUpperCase() }; private int[] columwidth = { 150, 150, 150, 200 }; private boolean[] columnCentered = { false, true, true, true }; @@ -478,7 +480,9 @@ private JTable getJTableInventory() { for (int i = 0; i < columwidth.length; i++) { jTableInventory.getColumnModel().getColumn(i).setMinWidth(columwidth[i]); if (columnCentered[i]) { - jTableInventory.getColumnModel().getColumn(i).setCellRenderer(new CenterTableCellRenderer()); + jTableInventory.getColumnModel().getColumn(i).setCellRenderer(new ColorCenterTableCellRenderer()); + } else { + jTableInventory.getColumnModel().getColumn(i).setCellRenderer(new ColorTableCellRenderer()); } } jTableInventory.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @@ -626,7 +630,7 @@ private JComboBox getComboBox() { private JLabel getStatusLabel() { if (statusLabel == null) { - statusLabel = new JLabel(MessageBundle.getMessage("angal.inventory.status.txt")); + statusLabel = new JLabel(MessageBundle.getMessage("angal.inventory.status.label")); statusLabel.setHorizontalAlignment(SwingConstants.RIGHT); } return statusLabel; @@ -663,7 +667,20 @@ public void InventoryUpdated(AWTEvent e) { jTableInventory.setModel(new InventoryBrowsingModel()); } - class CenterTableCellRenderer extends DefaultTableCellRenderer { + class ColorTableCellRenderer extends DefaultTableCellRenderer { + + private static final long serialVersionUID = 1L; + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + + Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + formatCellByBillStatus(table, row, cell); + return cell; + } + } + + class ColorCenterTableCellRenderer extends DefaultTableCellRenderer { private static final long serialVersionUID = 1L; @@ -672,7 +689,17 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); setHorizontalAlignment(CENTER); + formatCellByBillStatus(table, row, cell); return cell; } } + + private void formatCellByBillStatus(JTable table, int row, Component cell) { + int statusColumn = table.getColumnModel().getColumnIndex(MessageBundle.getMessage("angal.common.status.txt").toUpperCase()); + if ((table.getValueAt(row, statusColumn)).equals(InventoryStatus.draft.toString())) { + cell.setForeground(Color.BLUE); + } else { + cell.setForeground(Color.BLACK); + } + } } From 60cb33cfb288639c19f0d4ee6624f06f2b69fd85 Mon Sep 17 00:00:00 2001 From: mwithi Date: Mon, 23 Dec 2024 23:57:18 +0100 Subject: [PATCH 118/147] Fix pagination --- bundle/language_en.properties | 2 + .../gui/InventoryBrowser.java | 102 ++++++++---------- 2 files changed, 45 insertions(+), 59 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index a3cdaa0fc6..dc63919814 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -417,6 +417,8 @@ angal.common.note.txt angal.common.ok.btn = OK angal.common.ok.btn.key = O angal.common.opd.txt = OPD +angal.common.pages.txt = Pages +angal.common.page.txt = Page angal.common.patient.txt = Patient angal.common.patientID = Pat. ID angal.common.pleaseinsertacode.msg = Please insert a code. diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 25adc2d22e..01f4dff1b9 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -101,11 +101,11 @@ public class InventoryBrowser extends ModalJFrame implements InventoryListener { private boolean[] columnCentered = { false, true, true, true }; private JComboBox statusComboBox; private JLabel statusLabel; - JButton next; - JButton previous; - JComboBox pagesCombo = new JComboBox<>(); - JLabel under = new JLabel("/ 0 Page"); - private static int PAGE_SIZE = 50; + private JButton next; + private JButton previous; + private JComboBox pagesComboBox = new JComboBox<>(); + private JLabel ofPagesLabel = new JLabel("/ 1 " + MessageBundle.getMessage("angal.common.page.txt")); + private static int PAGE_SIZE = 2; private int startIndex = 0; private int totalRows; private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); @@ -136,7 +136,7 @@ public void windowClosing(WindowEvent e) { dispose(); } }); - pagesCombo.setEditable(true); + pagesComboBox.setEditable(true); previous.setEnabled(false); next.setEnabled(false); next.addActionListener(actionEvent -> { @@ -144,31 +144,32 @@ public void windowClosing(WindowEvent e) { previous.setEnabled(true); } startIndex += PAGE_SIZE; - jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); + int page = startIndex / PAGE_SIZE + 1; + jTableInventory.setModel(new InventoryBrowsingModel(page, PAGE_SIZE)); if ((startIndex + PAGE_SIZE) > totalRows) { next.setEnabled(false); } - pagesCombo.setSelectedItem(startIndex / PAGE_SIZE + 1); + pagesComboBox.setSelectedItem(page); }); - previous.addActionListener(actionEvent -> { if (!next.isEnabled()) { next.setEnabled(true); } startIndex -= PAGE_SIZE; - jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); + int page = startIndex / PAGE_SIZE + 1; + jTableInventory.setModel(new InventoryBrowsingModel(page, PAGE_SIZE)); if (startIndex < PAGE_SIZE) { previous.setEnabled(false); } - pagesCombo.setSelectedItem(startIndex / PAGE_SIZE + 1); + pagesComboBox.setSelectedItem(page); }); - pagesCombo.addItemListener(new ItemListener() { + pagesComboBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent itemEvent) { int eventID = itemEvent.getStateChange(); if (eventID == ItemEvent.SELECTED) { - int page_number = (Integer) pagesCombo.getSelectedItem(); + int page_number = (Integer) pagesComboBox.getSelectedItem(); startIndex = (page_number - 1) * PAGE_SIZE; if ((startIndex + PAGE_SIZE) > totalRows) { @@ -181,10 +182,9 @@ public void itemStateChanged(ItemEvent itemEvent) { } else { previous.setEnabled(true); } - pagesCombo.setSelectedItem(startIndex / PAGE_SIZE + 1); - jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); - - pagesCombo.setEnabled(true); + pagesComboBox.setSelectedItem(page_number); + jTableInventory.setModel(new InventoryBrowsingModel(page_number - 1, PAGE_SIZE)); + pagesComboBox.setEnabled(true); } } }); @@ -264,8 +264,8 @@ private JPanel getPanelFooter() { next.setMnemonic(KeyEvent.VK_LEFT); panelFooter.add(previous); - panelFooter.add(pagesCombo); - panelFooter.add(under); + panelFooter.add(pagesComboBox); + panelFooter.add(ofPagesLabel); panelFooter.add(next); panelFooter.add(getNewButton()); @@ -274,6 +274,7 @@ private JPanel getPanelFooter() { panelFooter.add(getDeleteButton()); panelFooter.add(getCloseButton()); } + initialisePagesCombo(totalRows); return panelFooter; } private GoodDateChooser getJCalendarTo() { @@ -281,8 +282,7 @@ private GoodDateChooser getJCalendarTo() { jCalendarTo = new GoodDateChooser(LocalDate.now(), false, false); jCalendarTo.addDateChangeListener(event -> { dateTo = jCalendarTo.getDateEndOfDay(); - InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); - totalRows = inventoryModel.getRowCount(); + totalRows = medicalInventoryManager.getInventoryCount(InventoryType.main.toString()); startIndex = 0; previous.setEnabled(false); if (totalRows <= PAGE_SIZE) { @@ -291,7 +291,7 @@ private GoodDateChooser getJCalendarTo() { next.setEnabled(true); } jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); - initialiseCombo(totalRows); + initialisePagesCombo(totalRows); }); } return jCalendarTo; @@ -302,8 +302,7 @@ private GoodDateChooser getJCalendarFrom() { jCalendarFrom = new GoodDateChooser(LocalDate.now(), false, false); jCalendarFrom.addDateChangeListener(event -> { dateFrom = jCalendarFrom.getDateStartOfDay(); - InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); - totalRows = inventoryModel.getRowCount(); + totalRows = medicalInventoryManager.getInventoryCount(InventoryType.main.toString()); startIndex = 0; previous.setEnabled(false); if (totalRows <= PAGE_SIZE) { @@ -312,7 +311,7 @@ private GoodDateChooser getJCalendarFrom() { next.setEnabled(true); } jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); - initialiseCombo(totalRows); + initialisePagesCombo(totalRows); }); } return jCalendarFrom; @@ -442,7 +441,7 @@ private JButton getDeleteButton() { try { medicalInventoryManager.deleteInventory(inventory); MessageDialog.info(this, "angal.inventory.deletion.success.msg"); - jTableInventory.setModel(new InventoryBrowsingModel()); + jTableInventory.setModel(new InventoryBrowsingModel(0, PAGE_SIZE)); } catch (OHServiceException e) { MessageDialog.error(this, "angal.inventory.deletion.error.msg"); } @@ -475,7 +474,7 @@ private JTable getJTableInventory() { if (jTableInventory == null) { jTableInventory = new JTable(); jTableInventory.setFillsViewportHeight(true); - jTableInventory.setModel(new InventoryBrowsingModel()); + jTableInventory.setModel(new InventoryBrowsingModel(0, PAGE_SIZE)); jTableInventory.setAutoCreateColumnsFromModel(false); for (int i = 0; i < columwidth.length; i++) { jTableInventory.getColumnModel().getColumn(i).setMinWidth(columwidth[i]); @@ -523,23 +522,12 @@ class InventoryBrowsingModel extends DefaultTableModel { private static final long serialVersionUID = 1L; - public InventoryBrowsingModel() { + public InventoryBrowsingModel(int page, int pageSize) { inventoryList = new ArrayList<>(); String state = statusComboBox.getSelectedIndex() > 0 ? statusComboBox.getSelectedItem().toString().toLowerCase() : null; String type = InventoryType.main.toString(); try { - inventoryList = medicalInventoryManager.getMedicalInventoryByParams(dateFrom, dateTo, state, type); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); - } - } - - public InventoryBrowsingModel(int startIndex, int pageSize) { - inventoryList = new ArrayList<>(); - String state = statusComboBox.getSelectedIndex() > 0 ? statusComboBox.getSelectedItem().toString().toLowerCase() : null; - String type = InventoryType.main.toString(); - try { - Page medInventorypage = medicalInventoryManager.getMedicalInventoryByParamsPageable(dateFrom, dateTo, state, type, startIndex, + Page medInventorypage = medicalInventoryManager.getMedicalInventoryByParamsPageable(dateFrom, dateTo, state, type, page, pageSize); inventoryList = medInventorypage.getContent(); } catch (OHServiceException e) { @@ -606,23 +594,23 @@ public String formatDateTime(GregorianCalendar time) { private JComboBox getComboBox() { if (statusComboBox == null) { statusComboBox = new JComboBox(); - statusComboBox.addItem(""); + statusComboBox.addItem(MessageBundle.getMessage("angal.common.all.txt")); List statusList = medicalInventoryManager.getStatusList(); for (String status : statusList) { statusComboBox.addItem(status); } statusComboBox.addActionListener(actionEvent -> { - InventoryBrowsingModel inventoryModel = new InventoryBrowsingModel(); - totalRows = inventoryModel.getRowCount(); + totalRows = medicalInventoryManager.getInventoryCount(InventoryType.main.toString()); startIndex = 0; + int page = startIndex / PAGE_SIZE + 1; previous.setEnabled(false); if (totalRows <= PAGE_SIZE) { next.setEnabled(false); } else { next.setEnabled(true); } - jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); - initialiseCombo(totalRows); + jTableInventory.setModel(new InventoryBrowsingModel(page, PAGE_SIZE)); + initialisePagesCombo(totalRows); }); } return statusComboBox; @@ -636,35 +624,31 @@ private JLabel getStatusLabel() { return statusLabel; } - public void initialiseCombo(int total_rows) { + public void initialisePagesCombo(int total_rows) { int j = 0; - pagesCombo.removeAllItems(); - for (int i = 0; i < total_rows / PAGE_SIZE; i++) { - j = i + 1; - pagesCombo.addItem(j); - } - if (j * PAGE_SIZE < total_rows) { - pagesCombo.addItem(j + 1); - under.setText("/" + (total_rows / PAGE_SIZE + 1 + " Pages")); - } else { - under.setText("/" + total_rows / PAGE_SIZE + " Pages"); + // if totalRows = 0 we have at least 1 page + int totalPages = Math.max(1, (int) Math.ceil((double) totalRows / PAGE_SIZE)); + for (int i = 1; i <= totalPages; i++) { + pagesComboBox.addItem(i); } + + ofPagesLabel.setText("/" + totalPages + " " + MessageBundle.getMessage("angal.common.pages.txt")); } @Override public void InventoryCancelled(AWTEvent e) { - jTableInventory.setModel(new InventoryBrowsingModel()); + jTableInventory.setModel(new InventoryBrowsingModel(0, PAGE_SIZE)); } @Override public void InventoryInserted(AWTEvent e) { - jTableInventory.setModel(new InventoryBrowsingModel()); + jTableInventory.setModel(new InventoryBrowsingModel(0, PAGE_SIZE)); } @Override public void InventoryUpdated(AWTEvent e) { - jTableInventory.setModel(new InventoryBrowsingModel()); + jTableInventory.setModel(new InventoryBrowsingModel(0, PAGE_SIZE)); } class ColorTableCellRenderer extends DefaultTableCellRenderer { From 203bc5735202570a00ea88cbb9d1b07f473d96a7 Mon Sep 17 00:00:00 2001 From: mwithi Date: Tue, 24 Dec 2024 16:51:41 +0100 Subject: [PATCH 119/147] Restore PAGE_SIZE --- .../java/org/isf/medicalinventory/gui/InventoryBrowser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 01f4dff1b9..a0deec42ba 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -105,7 +105,7 @@ public class InventoryBrowser extends ModalJFrame implements InventoryListener { private JButton previous; private JComboBox pagesComboBox = new JComboBox<>(); private JLabel ofPagesLabel = new JLabel("/ 1 " + MessageBundle.getMessage("angal.common.page.txt")); - private static int PAGE_SIZE = 2; + private static int PAGE_SIZE = 24; private int startIndex = 0; private int totalRows; private MedicalInventoryManager medicalInventoryManager = Context.getApplicationContext().getBean(MedicalInventoryManager.class); From 7949a97cb14688c922d2ac5506fa2a3acc561e7c Mon Sep 17 00:00:00 2001 From: mwithi Date: Sat, 28 Dec 2024 19:41:22 +0100 Subject: [PATCH 120/147] Fix formatting --- .../java/org/isf/medicalinventory/gui/InventoryBrowser.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index a0deec42ba..b46bea4d19 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -238,6 +238,7 @@ private JPanel getPanelHeader() { } return panelHeader; } + private JPanel getPanelContent() { if (panelContent == null) { panelContent = new JPanel(); @@ -255,6 +256,7 @@ private JPanel getPanelContent() { } return panelContent; } + private JPanel getPanelFooter() { if (panelFooter == null) { panelFooter = new JPanel(); @@ -277,6 +279,7 @@ private JPanel getPanelFooter() { initialisePagesCombo(totalRows); return panelFooter; } + private GoodDateChooser getJCalendarTo() { if (jCalendarTo == null) { jCalendarTo = new GoodDateChooser(LocalDate.now(), false, false); From ba591fb5551318034568471d1cb3639c994be2c1 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Thu, 9 Jan 2025 15:56:23 +0100 Subject: [PATCH 121/147] fix bug and enhance the code --- bundle/language_en.properties | 3 ++ .../medicalinventory/gui/InventoryEdit.java | 29 +++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index bacbd40e3c..7ca861a739 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -670,6 +670,8 @@ angal.hospital.visitduration.txt angal.hospital.visitendhour.txt = Visit end hour angal.hospital.visitstarthour.txt = Visit start hour angal.inventory.addproduct.label = Add products +angal.inventory.allinventoryrowshouldhaverealqtygreatterthanzero.msg = All inventory(ies) row(s) should have real quantity greater than zero. +angal.inventory.areyousureyouwantoclosethiswindow.msg = Are you sure you want to close the window? angal.inventory.askforrealquantityempty.msg = Do you want to print without the real quantity? angal.inventory.confirm.btn = Confirm angal.inventory.confirm.btn.key = O @@ -724,6 +726,7 @@ angal.inventory.doyoureallywanttoconfirmthisinventory.msg angal.inventoryrow.notfound.msg = Inventory not found. angal.inventoryrow.invalidquantity.msg = Invalid quantity. angal.inventory.pleaseinsertavalidinventorydate.msg = Please insert a valid inventory date. +angal.inventoryrow.pleaseinsertatleastoneinventoryrow.msg = Please insert at least one inventory row and save \n or reset the field before close the window. angal.inventoryrow.pleaseselectonlyoneinventoryrow.msg = Please select only one inventory row. angal.inventoryrow.pleaseselectatleastoneinventoryrow.msg = Please select at least one inventory row. angal.inventoryrow.pleaseselectoneinventoryrow.msg = Please select one inventory row. diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index a3e4bf4073..2cb14151ad 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -554,7 +554,16 @@ private JButton getSelectedButton() { frame.setSize(450, 200); frame.setTitle(MessageBundle.getMessage("angal.inventoryrow.lotinformation.title")); frame.setLocationRelativeTo(null); - frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); + frame.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + int choice = MessageDialog.yesNo(frame, "angal.inventory.areyousureyouwantoclosethiswindow.msg"); + if (choice == JOptionPane.YES_OPTION) { + frame.dispose(); + } + } + }); frame.setVisible(true); }); } @@ -788,6 +797,7 @@ private JButton getDeleteButton() { inventoryRowSearchList.remove(selectedInventoryRow); model.fireTableDataChanged(); jTableInventoryRow.setModel(model); + validateButton.setEnabled(false); } } else { @@ -797,6 +807,7 @@ private JButton getDeleteButton() { inventoryRowsToDelete.add(inventoryRow); model.fireTableDataChanged(); jTableInventoryRow.setModel(model); + validateButton.setEnabled(false); } } jTableInventoryRow.clearSelection(); @@ -909,9 +920,12 @@ private JButton getCloseButton() { lastDate = inventory.getInventoryDate(); } if (checkParameters(lastDestination, lastCharge, lastDischarge, lastSupplier, lastReference, lastDate)) { - int reset = MessageDialog.yesNoCancel(null, "angal.inventoryrow.doyouwanttosavethechanges.msg"); + int reset = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttosavethechanges.msg"); if (reset == JOptionPane.YES_OPTION) { this.saveButton.doClick(); + } + if (inventoryRowSearchList.isEmpty()) { + MessageDialog.info(null, "angal.inventoryrow.pleaseinsertatleastoneinventoryrow.msg"); } else { resetVariable(); dispose(); @@ -961,6 +975,7 @@ private JButton getCleanTableButton() { model.setRowCount(0); model.setColumnCount(0); jTableInventoryRow.updateUI(); + validateButton.setEnabled(false); } }); return resetButton; @@ -982,6 +997,11 @@ private JButton getValidateButton() { MessageDialog.error(null, "angal.inventory.allinventoryrowshouldhavelotbeforevalidation.msg"); return; } + List invRowWithoutRealQty = inventoryRowSearchList.stream().filter(invRow -> invRow.getRealQty() == 0).collect(Collectors.toList()); + if (!invRowWithoutRealQty.isEmpty()) { + MessageDialog.error(null, "angal.inventory.allinventoryrowshouldhaverealqtygreatterthanzero.msg"); + return; + } int reset = MessageDialog.yesNo(null, "angal.inventoryrow.doyoureallywanttovalidatethisinventory.msg"); if (reset == JOptionPane.YES_OPTION) { String chargeCode = inventory.getChargeType(); @@ -1905,6 +1925,7 @@ private JComboBox getJComboCharge() { } chargeCombo.addActionListener(actionEvent -> { chargeType = (MovementType) chargeCombo.getSelectedItem(); + validateButton.setEnabled(false); }); } return chargeCombo; @@ -1934,6 +1955,7 @@ private JComboBox getJComboDischarge() { } dischargeCombo.addActionListener(actionEvent -> { dischargeType = (MovementType) dischargeCombo.getSelectedItem(); + validateButton.setEnabled(false); }); } return dischargeCombo; @@ -1961,6 +1983,7 @@ private JComboBox getJComboSupplier() { } supplierCombo.addActionListener(actionEvent -> { supplier = (Supplier) supplierCombo.getSelectedItem(); + validateButton.setEnabled(false); }); } return supplierCombo; @@ -1988,6 +2011,7 @@ private JComboBox getJComboDestination() { } destinationCombo.addActionListener(actionEvent -> { destination = (Ward) destinationCombo.getSelectedItem(); + validateButton.setEnabled(false); }); } return destinationCombo; @@ -2049,6 +2073,7 @@ private void addMedInRowInInventorySearchList(MedicalInventoryRow inventoryRow) } if (inventoryRow.getId() == 0) { inventoryRowListAdded.add(inventoryRow); + validateButton.setEnabled(false); } } From 9e425e553f0436328c535974031b9c5a631df6f3 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Thu, 9 Jan 2025 16:34:11 +0100 Subject: [PATCH 122/147] update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java --- .../org/isf/medicalinventory/gui/InventoryEdit.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 2cb14151ad..89d6387e79 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -924,12 +924,9 @@ private JButton getCloseButton() { if (reset == JOptionPane.YES_OPTION) { this.saveButton.doClick(); } - if (inventoryRowSearchList.isEmpty()) { - MessageDialog.info(null, "angal.inventoryrow.pleaseinsertatleastoneinventoryrow.msg"); - } else { - resetVariable(); - dispose(); - } + } + if (!mode.equals("new") && inventoryRowSearchList.isEmpty()) { + MessageDialog.info(null, "angal.inventoryrow.pleaseinsertatleastoneinventoryrow.msg"); } else { resetVariable(); dispose(); @@ -1385,6 +1382,7 @@ public void setValueAt(Object value, int r, int c) { SwingUtilities.invokeLater(() -> { jTableInventoryRow.updateUI(); }); + validateButton.setEnabled(false); } } From 44472f89dfde7f7e87bda70d2846a8d0818c7ece Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Thu, 9 Jan 2025 17:39:46 +0100 Subject: [PATCH 123/147] update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 89d6387e79..f5950fa8be 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -994,7 +994,7 @@ private JButton getValidateButton() { MessageDialog.error(null, "angal.inventory.allinventoryrowshouldhavelotbeforevalidation.msg"); return; } - List invRowWithoutRealQty = inventoryRowSearchList.stream().filter(invRow -> invRow.getRealQty() == 0).collect(Collectors.toList()); + List invRowWithoutRealQty = inventoryRowSearchList.stream().filter(invRow -> invRow.getRealQty() == 0 && invRow.isNewLot()).collect(Collectors.toList()); if (!invRowWithoutRealQty.isEmpty()) { MessageDialog.error(null, "angal.inventory.allinventoryrowshouldhaverealqtygreatterthanzero.msg"); return; From 03dd0c5b4d5f3caa83fc3e7948f2169762601488 Mon Sep 17 00:00:00 2001 From: FOFOU FONZAM Gui Arnaud Date: Thu, 9 Jan 2025 18:12:45 +0100 Subject: [PATCH 124/147] Update bundle/language_en.properties Co-authored-by: David B Malkovsky --- bundle/language_en.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 7ca861a739..afa9782437 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -726,7 +726,7 @@ angal.inventory.doyoureallywanttoconfirmthisinventory.msg angal.inventoryrow.notfound.msg = Inventory not found. angal.inventoryrow.invalidquantity.msg = Invalid quantity. angal.inventory.pleaseinsertavalidinventorydate.msg = Please insert a valid inventory date. -angal.inventoryrow.pleaseinsertatleastoneinventoryrow.msg = Please insert at least one inventory row and save \n or reset the field before close the window. +angal.inventoryrow.pleaseinsertatleastoneinventoryrow.msg = Please insert at least one inventory row and save \n or reset the field before closing the window. angal.inventoryrow.pleaseselectonlyoneinventoryrow.msg = Please select only one inventory row. angal.inventoryrow.pleaseselectatleastoneinventoryrow.msg = Please select at least one inventory row. angal.inventoryrow.pleaseselectoneinventoryrow.msg = Please select one inventory row. From c8f44b338cacb37059daae06c4d87fa383d5ba5d Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Thu, 9 Jan 2025 18:13:33 +0100 Subject: [PATCH 125/147] change info to error on messageDialog --- .../org/isf/medicalinventory/gui/InventoryEdit.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index f5950fa8be..fab3f00fd5 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -926,7 +926,7 @@ private JButton getCloseButton() { } } if (!mode.equals("new") && inventoryRowSearchList.isEmpty()) { - MessageDialog.info(null, "angal.inventoryrow.pleaseinsertatleastoneinventoryrow.msg"); + MessageDialog.error(null, "angal.inventoryrow.pleaseinsertatleastoneinventoryrow.msg"); } else { resetVariable(); dispose(); @@ -958,14 +958,8 @@ private JButton getCleanTableButton() { resetButton.addActionListener(actionEvent -> { int reset = MessageDialog.yesNo(null, "angal.inventoryrow.doyoureallywanttocleanthistable.msg"); if (reset == JOptionPane.YES_OPTION) { - try { - if (inventory != null) { - List invRows = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(inventory.getId()); - medicalInventoryRowManager.deleteMedicalInventoryRows(invRows); - } - - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); + if (inventory != null) { + inventoryRowsToDelete.addAll(inventoryRowSearchList); } inventoryRowSearchList.clear(); DefaultTableModel model = (DefaultTableModel) jTableInventoryRow.getModel(); From d7460f92228d16c71431e5891ad2ed22956018e5 Mon Sep 17 00:00:00 2001 From: mwithi Date: Thu, 9 Jan 2025 22:38:16 +0100 Subject: [PATCH 126/147] Initialization to null is redundant --- .../isf/medicalinventory/gui/InventoryEdit.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 51f7418411..b6d2d5ec13 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -211,12 +211,12 @@ private void fireInventoryUpdated() { private boolean[] columnDecimalNumber = { false, false, false, false, false, false, false, false, true, true }; private Class< ? >[] columnsClasses = { String.class, Integer.class, String.class, String.class, String.class, LocalDate.class, Integer.class, Integer.class, BigDecimal.class, BigDecimal.class }; - private MedicalInventory inventory = null; + private MedicalInventory inventory; private JLabel specificRadio; private JLabel dateInventoryLabel; private JTextField codeTextField; - private String code = null; - private String mode = null; + private String code; + private String mode; private JLabel referenceLabel; private JLabel statusLabel; private JLabel chargeTypeLabel; @@ -230,11 +230,11 @@ private void fireInventoryUpdated() { private JComboBox dischargeCombo; private JComboBox supplierCombo; private JComboBox destinationCombo; - private MovementType chargeType = null; - private MovementType dischargeType = null; - private Supplier supplier = null; - private Ward destination = null; - private String newReference = null; + private MovementType chargeType; + private MovementType dischargeType; + private Supplier supplier; + private Ward destination; + private String newReference; private JButton selectButton; private JFrame frame; private JPanel mainPanel; From 89be0f16559cdb2b8e7be46a96c34be3568ac9e1 Mon Sep 17 00:00:00 2001 From: mwithi Date: Thu, 9 Jan 2025 22:45:31 +0100 Subject: [PATCH 127/147] The result of startIndex / PAGE_SIZE is always zero (startIndex is 0). So the result is always 1 --- .../java/org/isf/medicalinventory/gui/InventoryBrowser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index b46bea4d19..ae024a78f7 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -605,7 +605,7 @@ private JComboBox getComboBox() { statusComboBox.addActionListener(actionEvent -> { totalRows = medicalInventoryManager.getInventoryCount(InventoryType.main.toString()); startIndex = 0; - int page = startIndex / PAGE_SIZE + 1; + int page = 1; previous.setEnabled(false); if (totalRows <= PAGE_SIZE) { next.setEnabled(false); From 5eb57bd7f5b233adcd7ebda14ff88de2da70ca7c Mon Sep 17 00:00:00 2001 From: mwithi Date: Thu, 9 Jan 2025 22:50:05 +0100 Subject: [PATCH 128/147] use a formatted message --- bundle/language_en.properties | 2 +- .../java/org/isf/medicalinventory/gui/InventoryBrowser.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index a224df7ece..8ae7d16063 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -417,7 +417,7 @@ angal.common.note.txt angal.common.ok.btn = OK angal.common.ok.btn.key = O angal.common.opd.txt = OPD -angal.common.pages.txt = Pages +angal.common.pages.fmt.txt = / {0} Pages angal.common.page.txt = Page angal.common.patient.txt = Patient angal.common.patientID = Pat. ID diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index ae024a78f7..7045627798 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -636,7 +636,7 @@ public void initialisePagesCombo(int total_rows) { pagesComboBox.addItem(i); } - ofPagesLabel.setText("/" + totalPages + " " + MessageBundle.getMessage("angal.common.pages.txt")); + ofPagesLabel.setText(MessageBundle.formatMessage("angal.common.pages.fmt.txt", totalPages)); } @Override From a85d663298100c93af9fe6e6a6063f14ccf76f99 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Fri, 10 Jan 2025 08:12:30 +0100 Subject: [PATCH 129/147] update the message bundle --- bundle/language_en.properties | 2 +- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index afa9782437..f5ec3db5ff 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -670,7 +670,7 @@ angal.hospital.visitduration.txt angal.hospital.visitendhour.txt = Visit end hour angal.hospital.visitstarthour.txt = Visit start hour angal.inventory.addproduct.label = Add products -angal.inventory.allinventoryrowshouldhaverealqtygreatterthanzero.msg = All inventory(ies) row(s) should have real quantity greater than zero. +angal.inventory.allinventoryrowswithnewlotshouldhaverealqtygreatterthanzero.msg = All inventory(ies) row(s) with new lot should have real quantity greater than zero. angal.inventory.areyousureyouwantoclosethiswindow.msg = Are you sure you want to close the window? angal.inventory.askforrealquantityempty.msg = Do you want to print without the real quantity? angal.inventory.confirm.btn = Confirm diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index fab3f00fd5..5887e6b723 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -990,7 +990,7 @@ private JButton getValidateButton() { } List invRowWithoutRealQty = inventoryRowSearchList.stream().filter(invRow -> invRow.getRealQty() == 0 && invRow.isNewLot()).collect(Collectors.toList()); if (!invRowWithoutRealQty.isEmpty()) { - MessageDialog.error(null, "angal.inventory.allinventoryrowshouldhaverealqtygreatterthanzero.msg"); + MessageDialog.error(null, "angal.inventory.allinventoryrowswithnewlotshouldhaverealqtygreatterthanzero.msg"); return; } int reset = MessageDialog.yesNo(null, "angal.inventoryrow.doyoureallywanttovalidatethisinventory.msg"); From f62a9876001845891f22447d36b0ca0ee9569440 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Fri, 10 Jan 2025 10:25:11 +0100 Subject: [PATCH 130/147] enhance the code --- bundle/language_en.properties | 4 +- .../medicalinventory/gui/InventoryEdit.java | 47 ++++++++++--------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index f5ec3db5ff..d6da33e52c 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -670,7 +670,7 @@ angal.hospital.visitduration.txt angal.hospital.visitendhour.txt = Visit end hour angal.hospital.visitstarthour.txt = Visit start hour angal.inventory.addproduct.label = Add products -angal.inventory.allinventoryrowswithnewlotshouldhaverealqtygreatterthanzero.msg = All inventory(ies) row(s) with new lot should have real quantity greater than zero. +angal.inventory.allinventoryrowswithnewlotshouldhaverealqtygreatterthanzero.msg = All inventory(ies) row(s) with new lot should have real quantity greater than zero before validation. angal.inventory.areyousureyouwantoclosethiswindow.msg = Are you sure you want to close the window? angal.inventory.askforrealquantityempty.msg = Do you want to print without the real quantity? angal.inventory.confirm.btn = Confirm @@ -692,6 +692,7 @@ angal.inventory.deletion.confirm.msg angal.inventory.deletion.confirm.title = Confirm Deletion angal.inventory.deletion.success.msg = The inventory has been successfully marked as deleted. angal.inventory.deletion.error.msg = Deletion is only allowed for inventories with 'draft' or 'validated' status. +angal.inventory.doyouwanttocontinueediting.msg = Do you want to continue editing? angal.inventory.notfound.msg = Inventory not found. angal.inventory.destination.label = Destination angal.inventory.dischargetype.label = Discharge Type @@ -725,6 +726,7 @@ angal.inventoryrow.doyoureallywanttovalidatethisinventory.msg angal.inventory.doyoureallywanttoconfirmthisinventory.msg = Do you really want to confirm this inventory? angal.inventoryrow.notfound.msg = Inventory not found. angal.inventoryrow.invalidquantity.msg = Invalid quantity. +angal.inventory.pleasesaveinventorybeforevalidateit.msg = Please save the inventory before validating it. angal.inventory.pleaseinsertavalidinventorydate.msg = Please insert a valid inventory date. angal.inventoryrow.pleaseinsertatleastoneinventoryrow.msg = Please insert at least one inventory row and save \n or reset the field before closing the window. angal.inventoryrow.pleaseselectonlyoneinventoryrow.msg = Please select only one inventory row. diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 5887e6b723..06bed38ef1 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -649,6 +649,10 @@ private JButton getSaveButton() { fireInventoryInserted(); validateButton.setEnabled(true); resetVariable(); + int info = MessageDialog.yesNo(null, "angal.inventory.doyouwanttocontinueediting.msg"); + if (info != JOptionPane.YES_OPTION) { + dispose(); + } } else if (mode.equals("update")) { String lastCharge = inventory.getChargeType(); String lastDischarge = inventory.getDischargeType(); @@ -696,6 +700,10 @@ private JButton getSaveButton() { confirmButton.setEnabled(false); } resetVariable(); + int info = MessageDialog.yesNo(null, "angal.inventory.doyouwanttocontinueediting.msg"); + if (info != JOptionPane.YES_OPTION) { + dispose(); + } } else { MessageDialog.error(null, "angal.inventory.update.error.msg"); return; @@ -712,6 +720,10 @@ private JButton getSaveButton() { confirmButton.setEnabled(false); } resetVariable(); + int info = MessageDialog.yesNo(null, "angal.inventory.doyouwanttocontinueediting.msg"); + if (info != JOptionPane.YES_OPTION) { + dispose(); + } } else { MessageDialog.info(null, "angal.inventory.nothinghasbeenaddedonthisinventory.msg"); } @@ -736,7 +748,7 @@ private JButton getSaveButton() { } else { int idInvRow = medicalInventoryRow.getId(); MedicalInventoryRow invRow = medicalInventoryRowManager.getMedicalInventoryRowById(idInvRow); - if (invRow.getLock() != medicalInventoryRow.getLock()) { + if (invRow != null && invRow.getLock() != medicalInventoryRow.getLock()) { Lot newLot = movStockInsertingManager.storeLot(lotCode, lot, medical); invRow.setLot(newLot); invRow.setNewLot(true); @@ -765,6 +777,10 @@ private JButton getSaveButton() { resetVariable(); fireInventoryUpdated(); validateButton.setEnabled(true); + int info = MessageDialog.yesNo(null, "angal.inventory.doyouwanttocontinueediting.msg"); + if (info != JOptionPane.YES_OPTION) { + dispose(); + } } } inventoryRowSearchList = newMedicalInventoryRows; @@ -797,7 +813,6 @@ private JButton getDeleteButton() { inventoryRowSearchList.remove(selectedInventoryRow); model.fireTableDataChanged(); jTableInventoryRow.setModel(model); - validateButton.setEnabled(false); } } else { @@ -807,7 +822,6 @@ private JButton getDeleteButton() { inventoryRowsToDelete.add(inventoryRow); model.fireTableDataChanged(); jTableInventoryRow.setModel(model); - validateButton.setEnabled(false); } } jTableInventoryRow.clearSelection(); @@ -923,6 +937,7 @@ private JButton getCloseButton() { int reset = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttosavethechanges.msg"); if (reset == JOptionPane.YES_OPTION) { this.saveButton.doClick(); + return; } } if (!mode.equals("new") && inventoryRowSearchList.isEmpty()) { @@ -966,7 +981,6 @@ private JButton getCleanTableButton() { model.setRowCount(0); model.setColumnCount(0); jTableInventoryRow.updateUI(); - validateButton.setEnabled(false); } }); return resetButton; @@ -988,11 +1002,6 @@ private JButton getValidateButton() { MessageDialog.error(null, "angal.inventory.allinventoryrowshouldhavelotbeforevalidation.msg"); return; } - List invRowWithoutRealQty = inventoryRowSearchList.stream().filter(invRow -> invRow.getRealQty() == 0 && invRow.isNewLot()).collect(Collectors.toList()); - if (!invRowWithoutRealQty.isEmpty()) { - MessageDialog.error(null, "angal.inventory.allinventoryrowswithnewlotshouldhaverealqtygreatterthanzero.msg"); - return; - } int reset = MessageDialog.yesNo(null, "angal.inventoryrow.doyoureallywanttovalidatethisinventory.msg"); if (reset == JOptionPane.YES_OPTION) { String chargeCode = inventory.getChargeType(); @@ -1003,13 +1012,13 @@ private JButton getValidateButton() { LocalDateTime lastDate = inventory.getInventoryDate(); if (checkParameters(wardCode, chargeCode, dischargeCode, supplierId, lastReference, lastDate) || !lotsSaved.isEmpty() || !inventoryRowListAdded.isEmpty() || !inventoryRowsToDelete.isEmpty()) { - saveButton.doClick(); - chargeCode = inventory.getChargeType(); - dischargeCode = inventory.getDischargeType(); - supplierId = inventory.getSupplier(); - wardCode = inventory.getDestination(); - lastReference = inventory.getInventoryReference(); - lastDate = inventory.getInventoryDate(); + MessageDialog.error(null, "angal.inventory.pleasesaveinventorybeforevalidateit.msg"); + return; + } + List invRowWithoutRealQty = inventoryRowSearchList.stream().filter(invRow -> invRow.getRealQty() == 0 && invRow.isNewLot()).collect(Collectors.toList()); + if (!invRowWithoutRealQty.isEmpty()) { + MessageDialog.error(null, "angal.inventory.allinventoryrowswithnewlotshouldhaverealqtygreatterthanzero.msg"); + return; } String errorMessage = this.checkParamsValues(chargeCode, dischargeCode, supplierId, wardCode); if (errorMessage != null) { @@ -1376,7 +1385,6 @@ public void setValueAt(Object value, int r, int c) { SwingUtilities.invokeLater(() -> { jTableInventoryRow.updateUI(); }); - validateButton.setEnabled(false); } } @@ -1917,7 +1925,6 @@ private JComboBox getJComboCharge() { } chargeCombo.addActionListener(actionEvent -> { chargeType = (MovementType) chargeCombo.getSelectedItem(); - validateButton.setEnabled(false); }); } return chargeCombo; @@ -1947,7 +1954,6 @@ private JComboBox getJComboDischarge() { } dischargeCombo.addActionListener(actionEvent -> { dischargeType = (MovementType) dischargeCombo.getSelectedItem(); - validateButton.setEnabled(false); }); } return dischargeCombo; @@ -1975,7 +1981,6 @@ private JComboBox getJComboSupplier() { } supplierCombo.addActionListener(actionEvent -> { supplier = (Supplier) supplierCombo.getSelectedItem(); - validateButton.setEnabled(false); }); } return supplierCombo; @@ -2003,7 +2008,6 @@ private JComboBox getJComboDestination() { } destinationCombo.addActionListener(actionEvent -> { destination = (Ward) destinationCombo.getSelectedItem(); - validateButton.setEnabled(false); }); } return destinationCombo; @@ -2065,7 +2069,6 @@ private void addMedInRowInInventorySearchList(MedicalInventoryRow inventoryRow) } if (inventoryRow.getId() == 0) { inventoryRowListAdded.add(inventoryRow); - validateButton.setEnabled(false); } } From 727db530ae80e0e9a48dabc0951827b2e9f08aa9 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Fri, 10 Jan 2025 11:12:06 +0100 Subject: [PATCH 131/147] update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java --- .../org/isf/medicalinventory/gui/InventoryEdit.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 06bed38ef1..5fc7a1d8c6 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -783,7 +783,9 @@ private JButton getSaveButton() { } } } - inventoryRowSearchList = newMedicalInventoryRows; + if (!newMedicalInventoryRows.isEmpty()) { + inventoryRowSearchList = newMedicalInventoryRows; + } jTableInventoryRow.updateUI(); } catch (OHServiceException e) { OHServiceExceptionUtil.showMessages(e); @@ -934,11 +936,17 @@ private JButton getCloseButton() { lastDate = inventory.getInventoryDate(); } if (checkParameters(lastDestination, lastCharge, lastDischarge, lastSupplier, lastReference, lastDate)) { - int reset = MessageDialog.yesNo(null, "angal.inventoryrow.doyouwanttosavethechanges.msg"); + int reset = MessageDialog.yesNoCancel(null, "angal.inventoryrow.doyouwanttosavethechanges.msg"); if (reset == JOptionPane.YES_OPTION) { this.saveButton.doClick(); return; } + if (reset == JOptionPane.NO_OPTION) { + resetVariable(); + dispose(); + } else { + return; + } } if (!mode.equals("new") && inventoryRowSearchList.isEmpty()) { MessageDialog.error(null, "angal.inventoryrow.pleaseinsertatleastoneinventoryrow.msg"); From d917b6b92fb620c0fcb909c5364b66267bc767d1 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Fri, 10 Jan 2025 17:38:06 +0100 Subject: [PATCH 132/147] update checkParam method --- bundle/language_en.properties | 3 +- .../medicalinventory/gui/InventoryEdit.java | 45 ++++++++++--------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index d6da33e52c..63cd903959 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -728,7 +728,6 @@ angal.inventoryrow.notfound.msg angal.inventoryrow.invalidquantity.msg = Invalid quantity. angal.inventory.pleasesaveinventorybeforevalidateit.msg = Please save the inventory before validating it. angal.inventory.pleaseinsertavalidinventorydate.msg = Please insert a valid inventory date. -angal.inventoryrow.pleaseinsertatleastoneinventoryrow.msg = Please insert at least one inventory row and save \n or reset the field before closing the window. angal.inventoryrow.pleaseselectonlyoneinventoryrow.msg = Please select only one inventory row. angal.inventoryrow.pleaseselectatleastoneinventoryrow.msg = Please select at least one inventory row. angal.inventoryrow.pleaseselectoneinventoryrow.msg = Please select one inventory row. @@ -761,7 +760,7 @@ angal.invetory.tablehasbeenupdated.msg angal.inventory.update.error.msg = Inventory not updated. angal.inventory.update.success.msg = Inventory updated. angal.inventory.doyouwanttoupdatethisinventory.msg = Do you want to update this inventory? -angal.inventory.nothinghasbeenaddedonthisinventory.msg = Nothing has been added to this inventory. = Done +angal.inventory.nothinghasbeenaddedonthisinventory.msg = Nothing has been added to this inventory. angal.invetory.notdataforthatfilter.msg = No data available for that filter. angal.inventory.validate.btn = Validate angal.inventory.validate.btn.key = V diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 5fc7a1d8c6..05093405c5 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -777,6 +777,9 @@ private JButton getSaveButton() { resetVariable(); fireInventoryUpdated(); validateButton.setEnabled(true); + if (confirmButton.isEnabled()) { + confirmButton.setEnabled(false); + } int info = MessageDialog.yesNo(null, "angal.inventory.doyouwanttocontinueediting.msg"); if (info != JOptionPane.YES_OPTION) { dispose(); @@ -947,9 +950,6 @@ private JButton getCloseButton() { } else { return; } - } - if (!mode.equals("new") && inventoryRowSearchList.isEmpty()) { - MessageDialog.error(null, "angal.inventoryrow.pleaseinsertatleastoneinventoryrow.msg"); } else { resetVariable(); dispose(); @@ -1018,11 +1018,6 @@ private JButton getValidateButton() { String wardCode = inventory.getDestination(); String lastReference = inventory.getInventoryReference(); LocalDateTime lastDate = inventory.getInventoryDate(); - if (checkParameters(wardCode, chargeCode, dischargeCode, supplierId, lastReference, lastDate) || !lotsSaved.isEmpty() - || !inventoryRowListAdded.isEmpty() || !inventoryRowsToDelete.isEmpty()) { - MessageDialog.error(null, "angal.inventory.pleasesaveinventorybeforevalidateit.msg"); - return; - } List invRowWithoutRealQty = inventoryRowSearchList.stream().filter(invRow -> invRow.getRealQty() == 0 && invRow.isNewLot()).collect(Collectors.toList()); if (!invRowWithoutRealQty.isEmpty()) { MessageDialog.error(null, "angal.inventory.allinventoryrowswithnewlotshouldhaverealqtygreatterthanzero.msg"); @@ -1033,6 +1028,10 @@ private JButton getValidateButton() { MessageDialog.error(null, errorMessage); return; } + if (checkParameters(wardCode, chargeCode, dischargeCode, supplierId, lastReference, lastDate)) { + MessageDialog.error(null, "angal.inventory.pleasesaveinventorybeforevalidateit.msg"); + return; + } // validate inventory try { String status = InventoryStatus.validated.toString(); @@ -2087,18 +2086,24 @@ private void resetVariable() { lotsSaved.clear(); } - private boolean checkParameters(String wardCode, String chargeCode, String dischargeCode, Integer suplierId, String reference, LocalDateTime date) { - if (!lotsSaved.isEmpty() || !inventoryRowListAdded.isEmpty() || !lotsDeleted.isEmpty() || !inventoryRowsToDelete.isEmpty() - || (destination != null && !destination.getCode().equals(wardCode)) - || (chargeType != null && !chargeType.getCode().equals(chargeCode)) - || (dischargeType != null && !dischargeType.getCode().equals(dischargeCode)) - || (supplier != null && supplier.getSupId() != suplierId) || (destination == null && wardCode != null) - || (chargeType == null && chargeCode != null) || (dischargeType == null && dischargeCode != null) - || (supplier == null && suplierId != null) || (reference != null && !reference.equals(newReference)) - || !date.toLocalDate().equals(dateInventory.toLocalDate())) { - return true; - } - return false; + private boolean checkParameters(String wardCode, String chargeCode, String dischargeCode, Integer supplierId, String reference, LocalDateTime date) { + return !lotsSaved.isEmpty() + || !inventoryRowListAdded.isEmpty() + || !lotsDeleted.isEmpty() + || !inventoryRowsToDelete.isEmpty() + || (destination != null && isMismatch(destination.getCode(), wardCode)) + || (chargeType != null && isMismatch(chargeType.getCode(), chargeCode)) + || (dischargeType != null && isMismatch(dischargeType.getCode(), dischargeCode)) + || (supplier != null && supplier.getSupId() != supplierId) + || !isSameDate(date, dateInventory); + } + + private boolean isMismatch(String value, String expectedValue) { + return !value.equals(expectedValue); + } + + private boolean isSameDate(LocalDateTime date1, LocalDateTime date2) { + return date1.toLocalDate().equals(date2.toLocalDate()); } private JComboBox getJComboMedicalType() { From ac264e3534905ce983044cdf488be2595aa53204 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Mon, 13 Jan 2025 09:01:33 +0100 Subject: [PATCH 133/147] update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java --- .../isf/medicalinventory/gui/InventoryEdit.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 05093405c5..21a9b68b08 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -649,10 +649,6 @@ private JButton getSaveButton() { fireInventoryInserted(); validateButton.setEnabled(true); resetVariable(); - int info = MessageDialog.yesNo(null, "angal.inventory.doyouwanttocontinueediting.msg"); - if (info != JOptionPane.YES_OPTION) { - dispose(); - } } else if (mode.equals("update")) { String lastCharge = inventory.getChargeType(); String lastDischarge = inventory.getDischargeType(); @@ -700,10 +696,6 @@ private JButton getSaveButton() { confirmButton.setEnabled(false); } resetVariable(); - int info = MessageDialog.yesNo(null, "angal.inventory.doyouwanttocontinueediting.msg"); - if (info != JOptionPane.YES_OPTION) { - dispose(); - } } else { MessageDialog.error(null, "angal.inventory.update.error.msg"); return; @@ -720,10 +712,6 @@ private JButton getSaveButton() { confirmButton.setEnabled(false); } resetVariable(); - int info = MessageDialog.yesNo(null, "angal.inventory.doyouwanttocontinueediting.msg"); - if (info != JOptionPane.YES_OPTION) { - dispose(); - } } else { MessageDialog.info(null, "angal.inventory.nothinghasbeenaddedonthisinventory.msg"); } @@ -780,10 +768,6 @@ private JButton getSaveButton() { if (confirmButton.isEnabled()) { confirmButton.setEnabled(false); } - int info = MessageDialog.yesNo(null, "angal.inventory.doyouwanttocontinueediting.msg"); - if (info != JOptionPane.YES_OPTION) { - dispose(); - } } } if (!newMedicalInventoryRows.isEmpty()) { From 301aac787d24d1838723cab6f1aaf9abb9b0061b Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Mon, 13 Jan 2025 09:46:37 +0100 Subject: [PATCH 134/147] fix bugs and add message to avoid validate or confirm inventory without products' --- bundle/language_en.properties | 3 ++- src/main/java/org/isf/lab/gui/LabBrowser.java | 10 ++++++++-- .../org/isf/medicalinventory/gui/InventoryEdit.java | 8 ++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 63cd903959..947ee80883 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -678,6 +678,8 @@ angal.inventory.confirm.btn.key angal.inventory.confirm.success.msg = Inventory confirmation complete. All stock has been accurately verified and updated in the system. angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg = Cannot create another inventory with status draft, Because you already have an inventory with status draft or validated. angal.inventory.cannotsavelot.msg = Cannot save the lot. Please verify lot information and retry. +angal.inventory.cannotconfirminventorywithoutproducts.msg = Cannot confirm inventory without products. +angal.inventory.cannotvalidateinventorywithoutproducts.msg = Cannot validate inventory without products. angal.inventory.cannotsaveinventorywithoutproducts.msg = Cannot save inventory without products. angal.inventory.cancelednoteditable.msg = A canceled inventory can not be modified. angal.inventory.donenoteditable.msg = A confirm inventory can not be modified. @@ -692,7 +694,6 @@ angal.inventory.deletion.confirm.msg angal.inventory.deletion.confirm.title = Confirm Deletion angal.inventory.deletion.success.msg = The inventory has been successfully marked as deleted. angal.inventory.deletion.error.msg = Deletion is only allowed for inventories with 'draft' or 'validated' status. -angal.inventory.doyouwanttocontinueediting.msg = Do you want to continue editing? angal.inventory.notfound.msg = Inventory not found. angal.inventory.destination.label = Destination angal.inventory.dischargetype.label = Discharge Type diff --git a/src/main/java/org/isf/lab/gui/LabBrowser.java b/src/main/java/org/isf/lab/gui/LabBrowser.java index 3e00d98f99..f919342503 100644 --- a/src/main/java/org/isf/lab/gui/LabBrowser.java +++ b/src/main/java/org/isf/lab/gui/LabBrowser.java @@ -59,14 +59,18 @@ import org.isf.patient.model.Patient; import org.isf.serviceprinting.manager.PrintLabels; import org.isf.serviceprinting.manager.PrintManager; +import org.isf.utils.exception.OHException; import org.isf.utils.exception.OHServiceException; import org.isf.utils.exception.gui.OHServiceExceptionUtil; +import org.isf.utils.exception.model.OHExceptionMessage; import org.isf.utils.jobjects.GoodDateChooser; import org.isf.utils.jobjects.MessageDialog; import org.isf.utils.jobjects.ModalJFrame; import org.isf.utils.layout.SpringUtilities; import org.isf.utils.time.TimeTools; +import net.sf.jasperreports.engine.JRException; + /** * LabBrowser - list all labs */ @@ -231,8 +235,10 @@ private JButton getPrintLabelButton() { } try { new PrintLabels("LabelForSamples", patId); - } catch (OHServiceException e) { - OHServiceExceptionUtil.showMessages(e); + } catch (OHException e) { + OHServiceExceptionUtil.showMessages(new OHServiceException(new OHExceptionMessage(e.getMessage()))); + } catch (JRException e) { + OHServiceExceptionUtil.showMessages(new OHServiceException(new OHExceptionMessage(MessageBundle.getMessage("angal.lab.noprinter.msg")))); } }); diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 21a9b68b08..9aec45d0d5 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -996,6 +996,10 @@ private JButton getValidateButton() { } int reset = MessageDialog.yesNo(null, "angal.inventoryrow.doyoureallywanttovalidatethisinventory.msg"); if (reset == JOptionPane.YES_OPTION) { + if (inventoryRowSearchList == null || inventoryRowSearchList.isEmpty()) { + MessageDialog.error(null, "angal.inventory.cannotvalidateinventorywithoutproducts.msg"); + return; + } String chargeCode = inventory.getChargeType(); String dischargeCode = inventory.getDischargeType(); Integer supplierId = inventory.getSupplier(); @@ -1068,6 +1072,10 @@ private JButton getConfirmButton() { } int confirm = MessageDialog.yesNo(null, "angal.inventory.doyoureallywanttoconfirmthisinventory.msg"); if (confirm == JOptionPane.YES_OPTION) { + if (inventoryRowSearchList == null || inventoryRowSearchList.isEmpty()) { + MessageDialog.error(null, "angal.inventory.cannotconfirminventorywithoutproducts.msg"); + return; + } String dischargeCode = inventory.getDischargeType(); String chargeCode = inventory.getChargeType(); Integer supplierId = inventory.getSupplier(); From c48187b50b9639e10bcca1e2e0b593aab1bc4e16 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Mon, 13 Jan 2025 11:28:57 +0100 Subject: [PATCH 135/147] update bundle/language_en.properties --- bundle/language_en.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 947ee80883..f9729e20fc 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -727,7 +727,7 @@ angal.inventoryrow.doyoureallywanttovalidatethisinventory.msg angal.inventory.doyoureallywanttoconfirmthisinventory.msg = Do you really want to confirm this inventory? angal.inventoryrow.notfound.msg = Inventory not found. angal.inventoryrow.invalidquantity.msg = Invalid quantity. -angal.inventory.pleasesaveinventorybeforevalidateit.msg = Please save the inventory before validating it. +angal.inventory.pleasesaveinventorybeforevalidateit.msg = You have modified something. Please save the inventory before validating it. angal.inventory.pleaseinsertavalidinventorydate.msg = Please insert a valid inventory date. angal.inventoryrow.pleaseselectonlyoneinventoryrow.msg = Please select only one inventory row. angal.inventoryrow.pleaseselectatleastoneinventoryrow.msg = Please select at least one inventory row. From 8378a022c75672142df436a9208b098f5bc272be Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Mon, 13 Jan 2025 18:18:09 +0100 Subject: [PATCH 136/147] update src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 9aec45d0d5..0a7cf6a799 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -926,7 +926,7 @@ private JButton getCloseButton() { int reset = MessageDialog.yesNoCancel(null, "angal.inventoryrow.doyouwanttosavethechanges.msg"); if (reset == JOptionPane.YES_OPTION) { this.saveButton.doClick(); - return; + dispose(); } if (reset == JOptionPane.NO_OPTION) { resetVariable(); From a0858e020c72d23d28546ccd20e3cb2ad1a3441b Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Tue, 14 Jan 2025 08:36:37 +0100 Subject: [PATCH 137/147] disable codeTextField and selectButton on edit mode --- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 0a7cf6a799..188848f2be 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -321,6 +321,9 @@ public void windowClosing(WindowEvent e) { destinationCombo.setEnabled(false); lotButton.setVisible(false); printButton.setVisible(true); + selectButton.setEnabled(false); + codeTextField.setEnabled(false); + } else { saveButton.setVisible(true); validateButton.setVisible(true); From 51ed1817d8fe6c78538e670d5b4874de05a68f87 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Tue, 14 Jan 2025 10:02:36 +0100 Subject: [PATCH 138/147] check if something has been update after action confirm' --- bundle/language_en.properties | 1 + .../org/isf/medicalinventory/gui/InventoryEdit.java | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index b328ebcf85..158761e48f 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -727,6 +727,7 @@ angal.inventoryrow.doyoureallywanttovalidatethisinventory.msg angal.inventory.doyoureallywanttoconfirmthisinventory.msg = Do you really want to confirm this inventory? angal.inventoryrow.notfound.msg = Inventory not found. angal.inventoryrow.invalidquantity.msg = Invalid quantity. +angal.inventory.pleasesaveinventorybeforeconfirmation.msg = You have modified something. Please save the inventory before confirmation. angal.inventory.pleasesaveinventorybeforevalidateit.msg = You have modified something. Please save the inventory before validating it. angal.inventory.pleaseinsertavalidinventorydate.msg = Please insert a valid inventory date. angal.inventoryrow.pleaseselectonlyoneinventoryrow.msg = Please select only one inventory row. diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 188848f2be..1fd8e4c00a 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1083,11 +1083,22 @@ private JButton getConfirmButton() { String chargeCode = inventory.getChargeType(); Integer supplierId = inventory.getSupplier(); String wardCode = inventory.getDestination(); + String lastReference = inventory.getInventoryReference(); + LocalDateTime lastDate = inventory.getInventoryDate(); + List invRowWithoutRealQty = inventoryRowSearchList.stream().filter(invRow -> invRow.getRealQty() == 0 && invRow.isNewLot()).collect(Collectors.toList()); + if (!invRowWithoutRealQty.isEmpty()) { + MessageDialog.error(null, "angal.inventory.allinventoryrowswithnewlotshouldhaverealqtygreatterthanzero.msg"); + return; + } String errorMessage = this.checkParamsValues(chargeCode, dischargeCode, supplierId, wardCode); if (errorMessage != null) { MessageDialog.error(null, errorMessage); return; } + if (checkParameters(wardCode, chargeCode, dischargeCode, supplierId, lastReference, lastDate)) { + MessageDialog.error(null, "angal.inventory.pleasesaveinventorybeforeconfirmation.msg"); + return; + } // confirm inventory try { medicalInventoryManager.confirmMedicalInventoryRow(inventory, inventoryRowSearchList); From 04336655844710238c0b8029f634a581e0f97240 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Tue, 14 Jan 2025 16:33:01 +0100 Subject: [PATCH 139/147] update the date of the Licence --- .../java/org/isf/examination/gui/PatientExaminationEdit.java | 2 +- src/main/java/org/isf/lab/gui/LabBrowser.java | 2 +- .../java/org/isf/medicalinventory/gui/InventoryBrowser.java | 2 +- src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java | 2 +- src/main/java/org/isf/medicalstockward/gui/WardPharmacy.java | 2 +- .../java/org/isf/medicalstockward/gui/WardPharmacyRectify.java | 2 +- src/main/java/org/isf/menu/gui/GroupEdit.java | 2 +- src/main/java/org/isf/opd/gui/OpdBrowser.java | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/isf/examination/gui/PatientExaminationEdit.java b/src/main/java/org/isf/examination/gui/PatientExaminationEdit.java index 359e7add98..687ab26535 100644 --- a/src/main/java/org/isf/examination/gui/PatientExaminationEdit.java +++ b/src/main/java/org/isf/examination/gui/PatientExaminationEdit.java @@ -1,6 +1,6 @@ /* * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * Copyright © 2006-2025 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) * * Open Hospital is a free and open source software for healthcare data management. * diff --git a/src/main/java/org/isf/lab/gui/LabBrowser.java b/src/main/java/org/isf/lab/gui/LabBrowser.java index 30b68f8cab..caf0558ba0 100644 --- a/src/main/java/org/isf/lab/gui/LabBrowser.java +++ b/src/main/java/org/isf/lab/gui/LabBrowser.java @@ -1,6 +1,6 @@ /* * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2023 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * Copyright © 2006-2025 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) * * Open Hospital is a free and open source software for healthcare data management. * diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index ab6b1973f4..68a8b3187a 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -1,6 +1,6 @@ /* * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * Copyright © 2006-2025 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) * * Open Hospital is a free and open source software for healthcare data management. * diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 1fd8e4c00a..02203217ee 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1,6 +1,6 @@ /* * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * Copyright © 2006-2025 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) * * Open Hospital is a free and open source software for healthcare data management. * diff --git a/src/main/java/org/isf/medicalstockward/gui/WardPharmacy.java b/src/main/java/org/isf/medicalstockward/gui/WardPharmacy.java index eaeee96f85..51e6a69c83 100644 --- a/src/main/java/org/isf/medicalstockward/gui/WardPharmacy.java +++ b/src/main/java/org/isf/medicalstockward/gui/WardPharmacy.java @@ -1,6 +1,6 @@ /* * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * Copyright © 2006-2025 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) * * Open Hospital is a free and open source software for healthcare data management. * diff --git a/src/main/java/org/isf/medicalstockward/gui/WardPharmacyRectify.java b/src/main/java/org/isf/medicalstockward/gui/WardPharmacyRectify.java index bdc0a51b6f..7a207df586 100644 --- a/src/main/java/org/isf/medicalstockward/gui/WardPharmacyRectify.java +++ b/src/main/java/org/isf/medicalstockward/gui/WardPharmacyRectify.java @@ -1,6 +1,6 @@ /* * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * Copyright © 2006-2025 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) * * Open Hospital is a free and open source software for healthcare data management. * diff --git a/src/main/java/org/isf/menu/gui/GroupEdit.java b/src/main/java/org/isf/menu/gui/GroupEdit.java index 7e59ca01d7..7aa61762a6 100644 --- a/src/main/java/org/isf/menu/gui/GroupEdit.java +++ b/src/main/java/org/isf/menu/gui/GroupEdit.java @@ -1,6 +1,6 @@ /* * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2023 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * Copyright © 2006-2025 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) * * Open Hospital is a free and open source software for healthcare data management. * diff --git a/src/main/java/org/isf/opd/gui/OpdBrowser.java b/src/main/java/org/isf/opd/gui/OpdBrowser.java index aa192c6c59..450b6e0b93 100644 --- a/src/main/java/org/isf/opd/gui/OpdBrowser.java +++ b/src/main/java/org/isf/opd/gui/OpdBrowser.java @@ -1,6 +1,6 @@ /* * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2023 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * Copyright © 2006-2025 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) * * Open Hospital is a free and open source software for healthcare data management. * From 3fbac0905fd639fd691c1781d0b189c53a715e92 Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Tue, 14 Jan 2025 16:36:47 +0100 Subject: [PATCH 140/147] update the date of the Licence --- src/main/java/org/isf/priceslist/gui/ListBrowser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/priceslist/gui/ListBrowser.java b/src/main/java/org/isf/priceslist/gui/ListBrowser.java index 00ec407d66..e05d5619b7 100644 --- a/src/main/java/org/isf/priceslist/gui/ListBrowser.java +++ b/src/main/java/org/isf/priceslist/gui/ListBrowser.java @@ -1,6 +1,6 @@ /* * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2023 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * Copyright © 2006-2025 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) * * Open Hospital is a free and open source software for healthcare data management. * From 2e1abede9b54710d33950574f44c5f9797cde17b Mon Sep 17 00:00:00 2001 From: ArnaudFofou Date: Tue, 14 Jan 2025 17:03:04 +0100 Subject: [PATCH 141/147] update the status if the table is not actualise during validation --- .../org/isf/medicalinventory/gui/InventoryEdit.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 02203217ee..8815bf5fb9 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -1050,6 +1050,16 @@ private JButton getValidateButton() { } catch (OHServiceException e1) { OHServiceExceptionUtil.showMessages(e1); } + } else { + try { + inventory.setStatus(InventoryStatus.draft.toString()); + statusLabel.setText(InventoryStatus.draft.toString().toUpperCase()); + statusLabel.setForeground(Color.GRAY); + inventory = medicalInventoryManager.updateMedicalInventory(inventory, true); + fireInventoryUpdated(); + } catch (OHServiceException ex) { + OHServiceExceptionUtil.showMessages(ex); + } } } } From 57fe0c016f212253af15ce98d018b13b75e03dd0 Mon Sep 17 00:00:00 2001 From: Alessandro Domanico Date: Fri, 24 Jan 2025 19:30:38 +0100 Subject: [PATCH 142/147] Apply suggestions from code review Co-authored-by: David B Malkovsky --- bundle/language_en.properties | 12 ++++++------ .../org/isf/medicalinventory/gui/MedicalPicker.java | 2 +- .../org/isf/medicalinventory/gui/StockMedModel.java | 2 +- .../report/GenericReportPharmaceuticalInventory.java | 2 +- .../java/org/isf/utils/jobjects/ModalJFrame.java | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 652f72d163..3fde1b1284 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -679,13 +679,13 @@ angal.inventory.askforrealquantityempty.msg angal.inventory.confirm.btn = Confirm angal.inventory.confirm.btn.key = O angal.inventory.confirm.success.msg = Inventory confirmation complete. All stock has been accurately verified and updated in the system. -angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg = Cannot create another inventory with status draft, Because you already have an inventory with status draft or validated. +angal.inventory.cannotcreateanotherinventorywithstatusdraft.msg = Cannot create another inventory with status draft because there is an inventory with status draft or validated. angal.inventory.cannotsavelot.msg = Cannot save the lot. Please verify lot information and retry. angal.inventory.cannotconfirminventorywithoutproducts.msg = Cannot confirm inventory without products. angal.inventory.cannotvalidateinventorywithoutproducts.msg = Cannot validate inventory without products. angal.inventory.cannotsaveinventorywithoutproducts.msg = Cannot save inventory without products. angal.inventory.cancelednoteditable.msg = A canceled inventory can not be modified. -angal.inventory.donenoteditable.msg = A confirm inventory can not be modified. +angal.inventory.donenoteditable.msg = A confirmed inventory can not be modified. angal.inventory.chargetype.label = Charge Type angal.inventory.clean.btn = Clean Table angal.inventory.clean.btn.key = T @@ -748,7 +748,7 @@ angal.inventory.medicalwithonlynonzeroqty.btn angal.inventory.nextarrow.btn = > angal.inventory.arrowprevious.btn = < angal.inventory.product.col = Products -angal.inventory.productalreadyexist.msg = {0} already exist in the list. do you still like to add it? +angal.inventory.productalreadyexist.msg = {0} already exists in the list. Do you still like to add it? angal.inventory.savelotwithnullprice.msg = Save the lot without a price? angal.inventory.selectmedical.msg = Select a medical. angal.inventory.status.txt = Status @@ -777,9 +777,9 @@ angal.inventory.allinventoryrowshouldhavelotbeforevalidation.msg angal.inventory.viewinventory.title = View Inventory angal.inventory.youhavealreadyaddedallproduct.msg = You have already added all the products. angal.inventoryrow.realqty.col = Real Qty -angal.inventory.newinvenotryrowtoadd.msg = New lot(s) have been detected in the main Store for these medical(s): {0} do you want to add them to this inventory? -angal.invetory.allmedicalisalreadypresent.msg = All medical is already present in this list. -angal.invetory.allmedicaladdedsuccessfully.msg = All medical are added successfully. +angal.inventory.newinvenotryrowtoadd.msg = New lot(s) have been detected in the main Store for these medical(s): {0}. Do you want to add them to this inventory? +angal.invetory.allmedicalisalreadypresent.msg = All medicals are already present in this list. +angal.invetory.allmedicaladdedsuccessfully.msg = All medicals are added successfully. angal.lab.allnegative.txt = All negative. angal.lab.blood.txt = Blood angal.lab.cfs.txt = CFS diff --git a/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java b/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java index e4509c2d33..9d8d21c1ea 100644 --- a/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java +++ b/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java @@ -1,6 +1,6 @@ /* * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * Copyright © 2006-2025 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) * * Open Hospital is a free and open source software for healthcare data management. * diff --git a/src/main/java/org/isf/medicalinventory/gui/StockMedModel.java b/src/main/java/org/isf/medicalinventory/gui/StockMedModel.java index 771664a2bf..da2cf086bf 100644 --- a/src/main/java/org/isf/medicalinventory/gui/StockMedModel.java +++ b/src/main/java/org/isf/medicalinventory/gui/StockMedModel.java @@ -1,6 +1,6 @@ /* * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * Copyright © 2006-2025 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) * * Open Hospital is a free and open source software for healthcare data management. * diff --git a/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java b/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java index d8a96fff68..e21ac4532c 100644 --- a/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java +++ b/src/main/java/org/isf/stat/gui/report/GenericReportPharmaceuticalInventory.java @@ -1,6 +1,6 @@ /* * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * Copyright © 2006-2025 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) * * Open Hospital is a free and open source software for healthcare data management. * diff --git a/src/main/java/org/isf/utils/jobjects/ModalJFrame.java b/src/main/java/org/isf/utils/jobjects/ModalJFrame.java index e87ff3677c..69d8d5eb48 100644 --- a/src/main/java/org/isf/utils/jobjects/ModalJFrame.java +++ b/src/main/java/org/isf/utils/jobjects/ModalJFrame.java @@ -1,6 +1,6 @@ /* * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * Copyright © 2006-2025 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) * * Open Hospital is a free and open source software for healthcare data management. * From 544d027b3ca4d41164c0afb204ccf15f099fcda4 Mon Sep 17 00:00:00 2001 From: mwithi Date: Fri, 24 Jan 2025 19:35:35 +0100 Subject: [PATCH 143/147] Fix default JLabel --- .../java/org/isf/medicalinventory/gui/InventoryBrowser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index daa2af1ba0..81fd573343 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -104,7 +104,7 @@ public class InventoryBrowser extends ModalJFrame implements InventoryListener { private JButton next; private JButton previous; private JComboBox pagesComboBox = new JComboBox<>(); - private JLabel ofPagesLabel = new JLabel("/ 1 " + MessageBundle.getMessage("angal.common.page.txt")); + private JLabel ofPagesLabel = new JLabel(MessageBundle.formatMessage("angal.common.pages.fmt.txt"), 1); private static int PAGE_SIZE = 24; private int startIndex = 0; private int totalRows; From 135cd69dcf0dc8a2edfbbf4fb7f62dcab25b54aa Mon Sep 17 00:00:00 2001 From: mwithi Date: Fri, 24 Jan 2025 19:36:44 +0100 Subject: [PATCH 144/147] Add blank line --- .../medicalinventory/gui/InventoryEdit.java | 62 ++++++++++--------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 184087895c..265db9cc22 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -327,7 +327,7 @@ public void windowClosing(WindowEvent e) { printButton.setVisible(true); selectButton.setEnabled(false); codeTextField.setEnabled(false); - + } else { saveButton.setVisible(true); validateButton.setVisible(true); @@ -563,13 +563,14 @@ private JButton getSelectedButton() { frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - int choice = MessageDialog.yesNo(frame, "angal.inventory.areyousureyouwantoclosethiswindow.msg"); - if (choice == JOptionPane.YES_OPTION) { - frame.dispose(); - } - } + + @Override + public void windowClosing(WindowEvent e) { + int choice = MessageDialog.yesNo(frame, "angal.inventory.areyousureyouwantoclosethiswindow.msg"); + if (choice == JOptionPane.YES_OPTION) { + frame.dispose(); + } + } }); frame.setVisible(true); }); @@ -1013,7 +1014,8 @@ private JButton getValidateButton() { String wardCode = inventory.getDestination(); String lastReference = inventory.getInventoryReference(); LocalDateTime lastDate = inventory.getInventoryDate(); - List invRowWithoutRealQty = inventoryRowSearchList.stream().filter(invRow -> invRow.getRealQty() == 0 && invRow.isNewLot()).collect(Collectors.toList()); + List invRowWithoutRealQty = inventoryRowSearchList.stream().filter(invRow -> invRow.getRealQty() == 0 && invRow.isNewLot()) + .collect(Collectors.toList()); if (!invRowWithoutRealQty.isEmpty()) { MessageDialog.error(null, "angal.inventory.allinventoryrowswithnewlotshouldhaverealqtygreatterthanzero.msg"); return; @@ -1025,7 +1027,7 @@ private JButton getValidateButton() { } if (checkParameters(wardCode, chargeCode, dischargeCode, supplierId, lastReference, lastDate)) { MessageDialog.error(null, "angal.inventory.pleasesaveinventorybeforevalidateit.msg"); - return; + return; } // validate inventory try { @@ -1057,10 +1059,10 @@ private JButton getValidateButton() { } else { try { inventory.setStatus(InventoryStatus.draft.toString()); - statusLabel.setText(InventoryStatus.draft.toString().toUpperCase()); - statusLabel.setForeground(Color.GRAY); - inventory = medicalInventoryManager.updateMedicalInventory(inventory, true); - fireInventoryUpdated(); + statusLabel.setText(InventoryStatus.draft.toString().toUpperCase()); + statusLabel.setForeground(Color.GRAY); + inventory = medicalInventoryManager.updateMedicalInventory(inventory, true); + fireInventoryUpdated(); } catch (OHServiceException ex) { OHServiceExceptionUtil.showMessages(ex); } @@ -1099,7 +1101,8 @@ private JButton getConfirmButton() { String wardCode = inventory.getDestination(); String lastReference = inventory.getInventoryReference(); LocalDateTime lastDate = inventory.getInventoryDate(); - List invRowWithoutRealQty = inventoryRowSearchList.stream().filter(invRow -> invRow.getRealQty() == 0 && invRow.isNewLot()).collect(Collectors.toList()); + List invRowWithoutRealQty = inventoryRowSearchList.stream().filter(invRow -> invRow.getRealQty() == 0 && invRow.isNewLot()) + .collect(Collectors.toList()); if (!invRowWithoutRealQty.isEmpty()) { MessageDialog.error(null, "angal.inventory.allinventoryrowswithnewlotshouldhaverealqtygreatterthanzero.msg"); return; @@ -1111,7 +1114,7 @@ private JButton getConfirmButton() { } if (checkParameters(wardCode, chargeCode, dischargeCode, supplierId, lastReference, lastDate)) { MessageDialog.error(null, "angal.inventory.pleasesaveinventorybeforeconfirmation.msg"); - return; + return; } // confirm inventory try { @@ -1478,6 +1481,7 @@ private Lot askLot(Lot lotToUpdate) { } while (lot == null); return lot; } + private BigDecimal askCost(int qty, BigDecimal lastCost) { double cost = 0.; do { @@ -2077,23 +2081,23 @@ private void resetVariable() { } private boolean checkParameters(String wardCode, String chargeCode, String dischargeCode, Integer supplierId, String reference, LocalDateTime date) { - return !lotsSaved.isEmpty() - || !inventoryRowListAdded.isEmpty() - || !lotsDeleted.isEmpty() - || !inventoryRowsToDelete.isEmpty() - || (destination != null && isMismatch(destination.getCode(), wardCode)) - || (chargeType != null && isMismatch(chargeType.getCode(), chargeCode)) - || (dischargeType != null && isMismatch(dischargeType.getCode(), dischargeCode)) - || (supplier != null && supplier.getSupId() != supplierId) - || !isSameDate(date, dateInventory); - } - + return !lotsSaved.isEmpty() + || !inventoryRowListAdded.isEmpty() + || !lotsDeleted.isEmpty() + || !inventoryRowsToDelete.isEmpty() + || (destination != null && isMismatch(destination.getCode(), wardCode)) + || (chargeType != null && isMismatch(chargeType.getCode(), chargeCode)) + || (dischargeType != null && isMismatch(dischargeType.getCode(), dischargeCode)) + || (supplier != null && supplier.getSupId() != supplierId) + || !isSameDate(date, dateInventory); + } + private boolean isMismatch(String value, String expectedValue) { - return !value.equals(expectedValue); + return !value.equals(expectedValue); } private boolean isSameDate(LocalDateTime date1, LocalDateTime date2) { - return date1.toLocalDate().equals(date2.toLocalDate()); + return date1.toLocalDate().equals(date2.toLocalDate()); } private JComboBox getJComboMedicalType() { From c2178325026fba6b1e923901088c6be9e911dbe6 Mon Sep 17 00:00:00 2001 From: mwithi Date: Fri, 24 Jan 2025 20:57:24 +0100 Subject: [PATCH 145/147] Remove unused bundle --- bundle/language_en.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index a0c537da32..6db5b1e3fe 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -418,7 +418,6 @@ angal.common.ok.btn angal.common.ok.btn.key = O angal.common.opd.txt = OPD angal.common.pages.fmt.txt = / {0} Pages -angal.common.page.txt = Page angal.common.patient.txt = Patient angal.common.patientID = Pat. ID angal.common.pleaseinsertacode.msg = Please insert a code. From 903c874aba0f67189774aad531d68a45459e9535 Mon Sep 17 00:00:00 2001 From: Alessandro Domanico Date: Fri, 24 Jan 2025 20:58:20 +0100 Subject: [PATCH 146/147] Apply suggestions from code review Co-authored-by: David B Malkovsky --- bundle/language_en.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundle/language_en.properties b/bundle/language_en.properties index 6db5b1e3fe..b45c80d68a 100644 --- a/bundle/language_en.properties +++ b/bundle/language_en.properties @@ -1955,7 +1955,7 @@ angal.xmpp.isnowoffline.txt angal.xmpp.isnowonline.txt = is now online angal.xmpp.me.txt = me angal.xmpp.sendfile.txt = Send File -angal.xmpp.thefiletransferofbetweenyouandendedsuccessfully.fmt.msg = the file transfer of {0} between you and {1} ended successfully +angal.xmpp.thefiletransferofbetweenyouandendedsuccessfully.fmt.msg = The file transfer of {0} between you and {1} ended successfully. angal.xmpp.userinfo.fmt.txt = User: {0}\nInfo: {1} angal.xmpp.usersinfo.border = User's Info angal.xmpp.wantstosharewithyouthisreport.fmt.msg = \n*** {0} wants to share with you this report: {1}\n From cf55d037410247b7dac01d2c6855ba15aea36394 Mon Sep 17 00:00:00 2001 From: mwithi Date: Tue, 28 Jan 2025 21:29:02 +0100 Subject: [PATCH 147/147] Apply code review suggestions --- .../gui/InventoryBrowser.java | 119 ++++++++---------- .../medicalinventory/gui/InventoryEdit.java | 84 ++++++------- .../medicalinventory/gui/MedicalPicker.java | 40 +++--- .../medicalinventory/gui/StockMedModel.java | 22 ++-- 4 files changed, 130 insertions(+), 135 deletions(-) diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java index 81fd573343..8f5e35e418 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java @@ -32,7 +32,6 @@ import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; @@ -45,16 +44,14 @@ import javax.swing.JButton; import javax.swing.JComboBox; -import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.SwingConstants; +import javax.swing.WindowConstants; import javax.swing.border.EmptyBorder; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; @@ -99,6 +96,7 @@ public class InventoryBrowser extends ModalJFrame implements InventoryListener { MessageBundle.getMessage("angal.common.user.col").toUpperCase() }; private int[] columwidth = { 150, 150, 150, 200 }; private boolean[] columnCentered = { false, true, true, true }; + private Class[] columnClasses = { String.class, String.class, String.class, String.class }; private JComboBox statusComboBox; private JLabel statusLabel; private JButton next; @@ -116,7 +114,7 @@ public InventoryBrowser() { } private void initComponents() { - setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setMinimumSize(new Dimension(850, 550)); setLocationRelativeTo(null); // center setTitle(MessageBundle.getMessage("angal.inventory.inventorybrowser.title")); @@ -132,6 +130,7 @@ private void initComponents() { addWindowListener(new WindowAdapter() { + @Override public void windowClosing(WindowEvent e) { dispose(); } @@ -163,29 +162,27 @@ public void windowClosing(WindowEvent e) { } pagesComboBox.setSelectedItem(page); }); - pagesComboBox.addItemListener(new ItemListener() { + pagesComboBox.addItemListener(itemEvent -> { - public void itemStateChanged(ItemEvent itemEvent) { - int eventID = itemEvent.getStateChange(); + int eventID = itemEvent.getStateChange(); - if (eventID == ItemEvent.SELECTED) { - int page_number = (Integer) pagesComboBox.getSelectedItem(); - startIndex = (page_number - 1) * PAGE_SIZE; + if (eventID == ItemEvent.SELECTED) { + int page_number = (Integer) pagesComboBox.getSelectedItem(); + startIndex = (page_number - 1) * PAGE_SIZE; - if ((startIndex + PAGE_SIZE) > totalRows) { - next.setEnabled(false); - } else { - next.setEnabled(true); - } - if (page_number == 1) { - previous.setEnabled(false); - } else { - previous.setEnabled(true); - } - pagesComboBox.setSelectedItem(page_number); - jTableInventory.setModel(new InventoryBrowsingModel(page_number - 1, PAGE_SIZE)); - pagesComboBox.setEnabled(true); + if ((startIndex + PAGE_SIZE) > totalRows) { + next.setEnabled(false); + } else { + next.setEnabled(true); } + if (page_number == 1) { + previous.setEnabled(false); + } else { + previous.setEnabled(true); + } + pagesComboBox.setSelectedItem(page_number); + jTableInventory.setModel(new InventoryBrowsingModel(page_number - 1, PAGE_SIZE)); + pagesComboBox.setEnabled(true); } }); } @@ -276,7 +273,7 @@ private JPanel getPanelFooter() { panelFooter.add(getDeleteButton()); panelFooter.add(getCloseButton()); } - initialisePagesCombo(totalRows); + initializePagesCombo(); return panelFooter; } @@ -294,7 +291,7 @@ private GoodDateChooser getJCalendarTo() { next.setEnabled(true); } jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); - initialisePagesCombo(totalRows); + initializePagesCombo(); }); } return jCalendarTo; @@ -314,7 +311,7 @@ private GoodDateChooser getJCalendarFrom() { next.setEnabled(true); } jTableInventory.setModel(new InventoryBrowsingModel(startIndex, PAGE_SIZE)); - initialisePagesCombo(totalRows); + initializePagesCombo(); }); } return jCalendarFrom; @@ -487,34 +484,30 @@ private JTable getJTableInventory() { jTableInventory.getColumnModel().getColumn(i).setCellRenderer(new ColorTableCellRenderer()); } } - jTableInventory.getSelectionModel().addListSelectionListener(new ListSelectionListener() { - - @Override - public void valueChanged(ListSelectionEvent e) { - if (e.getValueIsAdjusting()) { - int[] selectedRows = jTableInventory.getSelectedRows(); - if (selectedRows.length == 1) { - int selectedRow = jTableInventory.getSelectedRow(); - MedicalInventory inventory = inventoryList.get(selectedRow); - if (inventory.getStatus().equals(InventoryStatus.canceled.toString()) || - inventory.getStatus().equals(InventoryStatus.done.toString())) { - jButtonEdit.setEnabled(false); - jButtonDelete.setEnabled(false); - } else { - jButtonEdit.setEnabled(true); - jButtonDelete.setEnabled(true); - - } - jButtonView.setEnabled(true); - jButtonView.setEnabled(true); - jButtonDelete.setEnabled(true); - } else { + jTableInventory.getSelectionModel().addListSelectionListener(listSelectionEvent -> { + + if (listSelectionEvent.getValueIsAdjusting()) { + int[] selectedRows = jTableInventory.getSelectedRows(); + if (selectedRows.length == 1) { + int selectedRow = jTableInventory.getSelectedRow(); + MedicalInventory inventory = inventoryList.get(selectedRow); + if (inventory.getStatus().equals(InventoryStatus.canceled.toString()) || + inventory.getStatus().equals(InventoryStatus.done.toString())) { jButtonEdit.setEnabled(false); - jButtonView.setEnabled(false); jButtonDelete.setEnabled(false); + } else { + jButtonEdit.setEnabled(true); + jButtonDelete.setEnabled(true); + } + jButtonView.setEnabled(true); + jButtonView.setEnabled(true); + jButtonDelete.setEnabled(true); + } else { + jButtonEdit.setEnabled(false); + jButtonView.setEnabled(false); + jButtonDelete.setEnabled(false); } - } }); } @@ -538,19 +531,12 @@ public InventoryBrowsingModel(int page, int pageSize) { } } + @Override public Class< ? > getColumnClass(int c) { - if (c == 0) { - return String.class; - } else if (c == 1) { - return String.class; - } else if (c == 2) { - return String.class; - } else if (c == 3) { - return String.class; - } - return null; + return columnClasses[c]; } + @Override public int getRowCount() { if (inventoryList == null) { return 0; @@ -558,14 +544,17 @@ public int getRowCount() { return inventoryList.size(); } + @Override public String getColumnName(int c) { return columsNames[c]; } + @Override public int getColumnCount() { return columsNames.length; } + @Override public Object getValueAt(int r, int c) { MedicalInventory medInvt = inventoryList.get(r); if (c == -1) { @@ -596,7 +585,7 @@ public String formatDateTime(GregorianCalendar time) { private JComboBox getComboBox() { if (statusComboBox == null) { - statusComboBox = new JComboBox(); + statusComboBox = new JComboBox<>(); statusComboBox.addItem(MessageBundle.getMessage("angal.common.all.txt")); List statusList = medicalInventoryManager.getStatusList(); for (String status : statusList) { @@ -613,7 +602,7 @@ private JComboBox getComboBox() { next.setEnabled(true); } jTableInventory.setModel(new InventoryBrowsingModel(page, PAGE_SIZE)); - initialisePagesCombo(totalRows); + initializePagesCombo(); }); } return statusComboBox; @@ -627,9 +616,7 @@ private JLabel getStatusLabel() { return statusLabel; } - public void initialisePagesCombo(int total_rows) { - int j = 0; - + public void initializePagesCombo() { // if totalRows = 0 we have at least 1 page int totalPages = Math.max(1, (int) Math.ceil((double) totalRows / PAGE_SIZE)); for (int i = 1; i <= totalPages; i++) { diff --git a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java index 265db9cc22..ac4af31dee 100644 --- a/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java +++ b/src/main/java/org/isf/medicalinventory/gui/InventoryEdit.java @@ -75,8 +75,6 @@ import javax.swing.WindowConstants; import javax.swing.border.EmptyBorder; import javax.swing.event.EventListenerList; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; @@ -305,6 +303,7 @@ private void initComponents() { getContentPane().add(panelFooter, BorderLayout.SOUTH); addWindowListener(new WindowAdapter() { + @Override public void windowClosing(WindowEvent e) { closeButton.doClick(); } @@ -1183,38 +1182,33 @@ private JTable getJTableInventoryRow() throws OHServiceException { jTableInventoryRow.getColumnModel().getColumn(i).setCellRenderer(new DecimalNumberTableCellRenderer()); } } - jTableInventoryRow.getSelectionModel().addListSelectionListener(new ListSelectionListener() { - - @Override - public void valueChanged(ListSelectionEvent e) { - if (e.getValueIsAdjusting()) { - int selectedRow = jTableInventoryRow.getSelectedRow(); - if (selectedRow != -1) { - MedicalInventoryRow medInvRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRow, -1); - Lot lot = medInvRow.getLot(); - if (lot == null) { - lotButton.setEnabled(true); + jTableInventoryRow.getSelectionModel().addListSelectionListener(listSelectionEvent -> { + + if (listSelectionEvent.getValueIsAdjusting()) { + int selectedRow = jTableInventoryRow.getSelectedRow(); + if (selectedRow != -1) { + MedicalInventoryRow medInvRow = (MedicalInventoryRow) jTableInventoryRow.getValueAt(selectedRow, -1); + Lot lot = medInvRow.getLot(); + if (lot == null) { + lotButton.setEnabled(true); + } else { + BigDecimal cost = lot.getCost() != null ? lot.getCost() : BigDecimal.ZERO; + if (isLotWithCost()) { + if (cost.doubleValue() == 0.00 || medInvRow.isNewLot()) { + lotButton.setEnabled(true); + } else { + lotButton.setEnabled(false); + } } else { - BigDecimal cost = lot.getCost() != null ? lot.getCost() : BigDecimal.ZERO; - if (lot != null) { - if (isLotWithCost()) { - if (cost.doubleValue() == 0.00 || medInvRow.isNewLot()) { - lotButton.setEnabled(true); - } else { - lotButton.setEnabled(false); - } - } else { - if (medInvRow.isNewLot()) { - lotButton.setEnabled(true); - } else { - lotButton.setEnabled(false); - } - } + if (medInvRow.isNewLot()) { + lotButton.setEnabled(true); + } else { + lotButton.setEnabled(false); } } - } else { - lotButton.setEnabled(false); } + } else { + lotButton.setEnabled(false); } } }); @@ -1284,10 +1278,12 @@ public InventoryRowModel(MedicalType medType, boolean withNoZeroQty, boolean inc } } + @Override public Class< ? > getColumnClass(int c) { return columnsClasses[c]; } + @Override public int getRowCount() { if (inventoryRowSearchList == null) { return 0; @@ -1295,14 +1291,17 @@ public int getRowCount() { return inventoryRowSearchList.size(); } + @Override public String getColumnName(int c) { return columsNames[c]; } + @Override public int getColumnCount() { return columsNames.length; } + @Override public Object getValueAt(int r, int c) { if (r < inventoryRowSearchList.size()) { MedicalInventoryRow medInvtRow = inventoryRowSearchList.get(r); @@ -1367,7 +1366,6 @@ public void setValueAt(Object value, int r, int c) { try { intValue = Double.parseDouble(value.toString()); } catch (NumberFormatException e) { - intValue = 0.0; return; } } @@ -1571,7 +1569,7 @@ private JTextField getCodeTextField() { TextPrompt suggestion = new TextPrompt(MessageBundle.getMessage("angal.common.code.txt"), codeTextField, Show.FOCUS_LOST); suggestion.setFont(new Font("Tahoma", Font.PLAIN, 12)); suggestion.setForeground(Color.GRAY); - suggestion.setHorizontalAlignment(JLabel.CENTER); + suggestion.setHorizontalAlignment(SwingConstants.CENTER); suggestion.changeAlpha(0.5f); suggestion.changeStyle(Font.BOLD + Font.ITALIC); codeTextField.addKeyListener(new KeyAdapter() { @@ -1598,7 +1596,7 @@ public void keyPressed(KeyEvent e) { } private List loadNewInventoryTable(String code, MedicalInventory inventory, boolean add) throws OHServiceException { - List inventoryRowsList = new ArrayList<>(); + List inventoryRowsList; if (inventory != null) { int id = inventory.getId(); inventoryRowsList = medicalInventoryRowManager.getMedicalInventoryRowByInventoryId(id); @@ -1789,11 +1787,9 @@ private void addInventoryRow(String code) throws OHServiceException { } private Medical chooseMedical(String text) throws OHServiceException { - Map medicalMap; - medicalMap = new HashMap(); + Map medicalMap = new HashMap<>(); for (Medical med : medicals) { - String key = med.getProdCode().toLowerCase(); - key = med.getCode().toString().toLowerCase(); + String key = med.getCode().toString().toLowerCase(); medicalMap.put(key, med); } ArrayList medList = new ArrayList<>(); @@ -1816,7 +1812,7 @@ private Medical chooseMedical(String text) throws OHServiceException { framas.setParentFrame(dialog); dialog.setContentPane(framas); dialog.setVisible(true); - dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); med = framas.getSelectedMedical(); return med; } @@ -1905,7 +1901,7 @@ private JLabel getDestinationLabel() { private JComboBox getJComboCharge() { MovementType movementSelected = null; if (chargeCombo == null) { - chargeCombo = new JComboBox(); + chargeCombo = new JComboBox<>(); try { List movementTypes = movTypeManager.getMedicalDsrStockMovementType(); chargeCombo.addItem(null); @@ -1934,7 +1930,7 @@ private JComboBox getJComboCharge() { private JComboBox getJComboDischarge() { MovementType movementSelected = null; if (dischargeCombo == null) { - dischargeCombo = new JComboBox(); + dischargeCombo = new JComboBox<>(); try { List movementTypes = movTypeManager.getMedicalDsrStockMovementType(); dischargeCombo.addItem(null); @@ -1963,7 +1959,7 @@ private JComboBox getJComboDischarge() { private JComboBox getJComboSupplier() { Supplier supplierSelected = null; if (supplierCombo == null) { - supplierCombo = new JComboBox(); + supplierCombo = new JComboBox<>(); try { List suppliers = supplierManager.getList(); supplierCombo.addItem(null); @@ -2196,10 +2192,7 @@ private boolean areAllMedicalsInInventory() throws OHServiceException { for (MedicalInventoryRow row : inventoryRowSearchList) { inventorySet.add(row.getMedical()); } - if (medicals.size() == inventorySet.size()) { - return true; - } - return false; + return medicals.size() == inventorySet.size() ? true : false; } private void initializeActions() { @@ -2256,6 +2249,7 @@ public class DecimalNumberTableCellRenderer extends DefaultTableCellRenderer { private static final long serialVersionUID = 1L; + @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel lbl = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); diff --git a/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java b/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java index 9d8d21c1ea..12628eb1a5 100644 --- a/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java +++ b/src/main/java/org/isf/medicalinventory/gui/MedicalPicker.java @@ -59,7 +59,7 @@ public class MedicalPicker extends JPanel { OhDefaultCellRenderer cellRenderer = new OhDefaultCellRenderer(); private static final long serialVersionUID = 1L; - private Collection medicalMapValues = new ArrayList(); + private Collection medicalMapValues = new ArrayList(); private String searchCode; private JButton jButtonSelect; private JButton jButtonQuit; @@ -72,7 +72,7 @@ public class MedicalPicker extends JPanel { private JTextField jTextFieldFind; private int selectedRow = -1; private JDialog parentFrame; - + private int getSelectedRow() { return selectedRow; } @@ -86,8 +86,6 @@ private void setSelectedRow(int selectedRow) { this.selectedRow = selectedRow; } - - public JDialog getParentFrame() { return parentFrame; } @@ -95,15 +93,14 @@ public JDialog getParentFrame() { public void setParentFrame(JDialog parentFrame) { this.parentFrame = parentFrame; } - + public MedicalPicker(StockMedModel model, List medicals) { initComponents(model); this.medicalMapValues = medicals; } - + /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always + * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ private void initComponents(TableModel model) { @@ -129,6 +126,7 @@ private void initComponents(TableModel model) { jTableData.setDefaultRenderer(Object.class, cellRenderer); jTableData.setDefaultRenderer(Double.class, cellRenderer); jTableData.addMouseMotionListener(new MouseMotionListener() { + @Override public void mouseMoved(MouseEvent e) { JTable aTable = (JTable) e.getSource(); @@ -142,9 +140,11 @@ public void mouseMoved(MouseEvent e) { } @Override - public void mouseDragged(MouseEvent e) {} + public void mouseDragged(MouseEvent e) { + } }); jTableData.addMouseListener(new MouseAdapter() { + @Override public void mouseExited(MouseEvent e) { cellRenderer.setHoveredRow(-1); @@ -155,10 +155,13 @@ public void mouseExited(MouseEvent e) { jTableData.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTableData.setShowVerticalLines(false); jTableData.addMouseListener(new MouseAdapter() { + + @Override public void mouseClicked(MouseEvent evt) { jTableDataMouseClicked(evt); } + @Override public void mousePressed(MouseEvent evt) { if (evt.getClickCount() == 2) { validateSelection(); @@ -167,6 +170,7 @@ public void mousePressed(MouseEvent evt) { }); jTableData.addKeyListener(new KeyAdapter() { + @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { @@ -215,12 +219,12 @@ public void insertUpdate(DocumentEvent e) { String text = jTextFieldFind.getText(); ArrayList medList = new ArrayList(); for (Medical aMed : medicalMapValues) { - medList.add(aMed); + medList.add(aMed); } StockMedModel model = new StockMedModel(medList); jTableData.setModel(model); TableColumn column; - for(int i = 0; i < 2; i++) { + for (int i = 0; i < 2; i++) { column = jTableData.getColumnModel().getColumn(i); if (i == 1) { column.setPreferredWidth(375); @@ -233,7 +237,7 @@ public void insertUpdate(DocumentEvent e) { jTableData.setRowSelectionInterval(0, 0); } jTableData.updateUI(); - + } @Override @@ -255,6 +259,7 @@ public void changedUpdate(DocumentEvent e) { }); jTextFieldFind.addKeyListener(new KeyAdapter() { + @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { @@ -288,16 +293,20 @@ public void keyPressed(KeyEvent e) { jButtonSelect.setText(MessageBundle.getMessage("angal.common.select.btn")); jButtonSelect.setMnemonic(MessageBundle.getMnemonic("angal.common.select.btn.key")); jButtonSelect.addMouseListener(new MouseAdapter() { + + @Override public void mouseClicked(MouseEvent evt) { jButtonSelectMouseClicked(evt); } }); - jButtonSelect.addActionListener( actionEvent -> { - jButtonSelectActionPerformed(actionEvent); + jButtonSelect.addActionListener(actionEvent -> { + jButtonSelectActionPerformed(actionEvent); }); jButtonQuit.setText(MessageBundle.getMessage("angal.common.cancel.btn")); jButtonQuit.setMnemonic(MessageBundle.getMnemonic("angal.common.cancel.btn.key")); jButtonQuit.addMouseListener(new MouseAdapter() { + + @Override public void mouseClicked(MouseEvent evt) { jButtonQuitMouseClicked(evt); } @@ -306,7 +315,7 @@ public void mouseClicked(MouseEvent evt) { jPanel2.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5)); jPanel2.add(jButtonSelect); jPanel2.add(jButtonQuit); - + if (jTableData.getRowCount() > 0) { jTableData.setRowSelectionInterval(0, 0); } @@ -338,4 +347,3 @@ private void jButtonQuitMouseClicked(MouseEvent evt) { this.getParentFrame().dispose(); } } - diff --git a/src/main/java/org/isf/medicalinventory/gui/StockMedModel.java b/src/main/java/org/isf/medicalinventory/gui/StockMedModel.java index da2cf086bf..dc9af6a1a7 100644 --- a/src/main/java/org/isf/medicalinventory/gui/StockMedModel.java +++ b/src/main/java/org/isf/medicalinventory/gui/StockMedModel.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import javax.swing.table.DefaultTableModel; @@ -33,13 +34,15 @@ public class StockMedModel extends DefaultTableModel { private static final long serialVersionUID = 1L; - private ArrayList medList; - private ArrayList initList=new ArrayList(); - + private List medList; + private List initList = new ArrayList<>(); + public StockMedModel(ArrayList meds) { medList = meds; initList.addAll(medList); } + + @Override public int getRowCount() { if (medList == null) { return 0; @@ -47,6 +50,7 @@ public int getRowCount() { return medList.size(); } + @Override public String getColumnName(int c) { if (c == 0) { return MessageBundle.getMessage("angal.common.code.txt").toUpperCase(); @@ -57,10 +61,12 @@ public String getColumnName(int c) { return ""; } + @Override public int getColumnCount() { return 2; } + @Override public Object getValueAt(int r, int c) { Medical med = medList.get(r); if (c == -1) { @@ -72,19 +78,20 @@ public Object getValueAt(int r, int c) { } return null; } - + public void filter(String searchValue) { medList.clear(); for (Iterator iterator = initList.iterator(); iterator.hasNext();) { - Medical med = (Medical) iterator.next(); + Medical med = iterator.next(); if (med.getProdCode().trim().equalsIgnoreCase(searchValue.trim())) { medList.add(med); - } - else if (NormalizeString.normalizeContains(med.getProdCode().toLowerCase().trim()+med.getDescription().toLowerCase(), searchValue.toLowerCase().trim())) { + } else if (NormalizeString.normalizeContains(med.getProdCode().toLowerCase().trim() + med.getDescription().toLowerCase(), + searchValue.toLowerCase().trim())) { medList.add(med); } } } + public Medical getMedicalAtRow(int row) { if (medList.size() > row && row >= 0) { return medList.get(row); @@ -97,5 +104,4 @@ public boolean isCellEditable(int arg0, int arg1) { return false; } - } \ No newline at end of file