View source | Discuss this page | Page history | Printable version   

POS-Check Stocks (Stock Management)

Check stocks in the stock management,

1. edit the following a.) addLine, b.) addUnits and c.) setUnits 2. Compile and run the applciation

//Edited addLine JLDy0717Philippines

   private void addLine(ProductInfoExt oProduct, double dpor, double dprice) {
       //Begin Add Local Variables
       InventoryLine readrow;
       double addsameprodidmultiply = 0;
       //End Add Local Variables
            //Begin Total of the inputed units of the same product id
            for (int iaddcntr= 0; iaddcntr < m_invlines.getCount(); iaddcntr++)
            {
             readrow = m_invlines.getLine(iaddcntr);
             String str_productinput = oProduct.getID();
             String str_productloopi = readrow.getProductID();
                  if (str_productloopi.equals(str_productinput))
                      {
                        addsameprodidmultiply = addsameprodidmultiply + readrow.getMultiply();
                      }
            }
            //End Total of the inputed units of the same product id
       try {
           // Get and show source and target locations
           String sourceloc = (String) m_LocationsModel.getSelectedKey();
           //Get and show inputed product id and attributeid.
           //String inputprod = m_invlines.getLine(i).getProductID();
           String inputprod = oProduct.getID();
           String inputprodattrib = oProduct.getAttributeSetID();
           //Get and show inputed product id input units
           double inputprodunits = dpor;
           double checkavailprodunits = m_dlSales.findProductStock(sourceloc, inputprod, inputprodattrib);
           //Check if stocks are avalable
           double checkdiff = checkavailprodunits - inputprodunits - addsameprodidmultiply;
           double checklacks = checkdiff * -1;
                       if (checkdiff < 0.0)
                           {
                               JOptionPane.showMessageDialog(null, "Insufficient " + checklacks + " unit/s. Current stocks is " + checkavailprodunits + " unit/s.", "Stocks Warning!", JOptionPane.WARNING_MESSAGE);
                           }
                       else
                           {
                               m_invlines.addLine(new InventoryLine(oProduct, dpor, dprice));
                               m_jreason.setEnabled(false);
                               m_jLocation.setEnabled(false);
                               m_jLocationDes.setEnabled(false);
                           }
       } catch (BasicException ex) {
           Logger.getLogger(StockManagement.class.getName()).log(Level.SEVERE, null, ex);
       }
   }


//Edited addUnits JLDy0717Philippines


   private void addUnits(double dUnits) {
       int i  = m_invlines.getSelectedRow();
       //Begin Add Local Variables
       InventoryLine readrow;
       double addsameprodidmultiply = 0;
       //End Add Local Variables


       if (i >= 0 )
       {
           InventoryLine inv = m_invlines.getLine(i);
           double dunits = inv.getMultiply() + dUnits;
            //Begin Total of the inputed units of the same product id
            for (int iaddcntr= 0; iaddcntr < m_invlines.getCount(); iaddcntr++)
            {
             readrow = m_invlines.getLine(iaddcntr);
             String str_productinput = m_invlines.getLine(i).getProductID();
             String str_productloopi = readrow.getProductID();
                  if (str_productloopi.equals(str_productinput))
                      {
                        addsameprodidmultiply = addsameprodidmultiply + readrow.getMultiply();
                      }
            }
            //End Total of the inputed units of the same product id
           if (dunits <= 0.0)
               {
               deleteLine(i);
               }
           else
               {
                //Try Statement
                try {
                   // This must validate first if there is enough stock in the source warehouse/site
                   // Get and show source and target locations
                   String sourceloc = (String) m_LocationsModel.getSelectedKey();
                   //Get and show inputed product id and attributeid.
                   String inputprod = m_invlines.getLine(i).getProductID();
                   String inputprodattrib = m_invlines.getLine(i).getProductAttSetInstId();
                   //Get and show inputed product id input units
                   double inputprodunits = dUnits;
                   //Get available units in the source warehouse/site
                   double checkavailprodunits = m_dlSales.findProductStock(sourceloc, inputprod, inputprodattrib);
                   //Check if stocks are avalable
                   double checkdiff = checkavailprodunits - inputprodunits - addsameprodidmultiply;
                   double checklacks = checkdiff * -1;
                       if (checkdiff < 0.0)
                           {
                               JOptionPane.showMessageDialog(null, "Insufficient " + checklacks + " unit/s. Current stocks is " + checkavailprodunits + " unit/s.", "Stocks Warning!", JOptionPane.WARNING_MESSAGE);
                           }
                       else
                           {
                               inv.setMultiply(inv.getMultiply() + dUnits);
                               m_invlines.setLine(i, inv);
                               m_jreason.setEnabled(false);
                               m_jLocation.setEnabled(false);
                               m_jLocationDes.setEnabled(false);
                           }
                } catch (BasicException ex) {
                   Logger.getLogger(StockManagement.class.getName()).log(Level.SEVERE, null, ex);
                }
                //Try Statement
               } // If else Statement
       } //If Statement
   }


//Edited setUnits JLDy0717Philippines


   private void setUnits(double dUnits) {
       int i  = m_invlines.getSelectedRow();
       //Begin Add Local Variables
       InventoryLine readrow;
       double addsameprodidmultiply = 0;
       //End Add Local Variables
       if (i >= 0 )
       {
           InventoryLine inv = m_invlines.getLine(i);
           inv.setMultiply(dUnits);
            //Begin Total of the inputed units of the same product id
            for (int iaddcntr= 0; iaddcntr < m_invlines.getCount(); iaddcntr++)
            {
             readrow = m_invlines.getLine(iaddcntr);
             String str_productinput = m_invlines.getLine(i).getProductID();
             String str_productloopi = readrow.getProductID();
                  if (str_productloopi.equals(str_productinput))
                      {
                        addsameprodidmultiply = addsameprodidmultiply + readrow.getMultiply();
                      }
            }
            //End Total of the inputed units of the same product id
                try {
                   // This must validate first if there is enough stock in the source warehouse/site
                   // Get and show source and target locations
                   String sourceloc = (String) m_LocationsModel.getSelectedKey();
                   //Get and show inputed product id and attributeid.
                   String inputprod = m_invlines.getLine(i).getProductID();
                   String inputprodattrib = m_invlines.getLine(i).getProductAttSetInstId();
                   //Get and show inputed product id input units
                   double inputprodunits = dUnits;
                   //Get available units in the source warehouse/site
                   double checkavailprodunits = m_dlSales.findProductStock(sourceloc, inputprod, inputprodattrib);
                   //Check if stocks are avalable
                   double checkdiff = checkavailprodunits - inputprodunits - addsameprodidmultiply;
                   double checklacks = checkdiff * -1;
                       if (checkdiff < 0.0)
                           {
                               JOptionPane.showMessageDialog(null, "Insufficient " + checklacks + " unit/s. Current stocks is " + checkavailprodunits + " unit/s.", "Stocks Warning!", JOptionPane.WARNING_MESSAGE);
                           }
                       else
                           {
                               m_invlines.setLine(i, inv);
                               m_jreason.setEnabled(false);
                               m_jLocation.setEnabled(false);
                               m_jLocationDes.setEnabled(false);
                           }
                } catch (BasicException ex) {
                   Logger.getLogger(StockManagement.class.getName()).log(Level.SEVERE, null, ex);
                }
       }
   }

Retrieved from "http://wiki.openbravo.com/wiki/POS-Check_Stocks_(Stock_Management)"

This page has been accessed 1,707 times. This page was last modified on 2 December 2010, at 04:31. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.