View source | Discuss this page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Add page
Show collection (0 pages)
Collections help

Search

POS - Consolidate the Receipt (Stock Management)

Code snippet

Name: POS - Consolidate the Receipt (Stock Management)
Version: POS/2.20 & 2.30 Beta
Author: jldy0717



This code has been copied from this forum thread.

These scripts will consolidate the receipt (Stock Management) by, removing duplicate item entries and adding their units to the first entry of the item.

1) Edit stateTransition method in StockManagement (com.openbravo.pos.inventory) class

Put before saveData() method:

else if (cTrans == ' ' || cTrans == '=') {
  if (m_invlines.getCount() == 0) {
    // No podemos grabar, no hay ningun registro.
    Toolkit.getDefaultToolkit().beep();
  } else {
    //HERE!!!
    saveData();
  }

the following code:

// 19 November 2009 // Begin Add Code jldy0717

               int numlinessm = m_invlines.getCount();
               for (int icounter = 0; icounter < numlinessm; icounter++) {
                   current_stockmgtline = m_invlines.getLine(icounter);
                   current_unitsm = current_stockmgtline.getMultiply();
                   if (current_unitsm != 0) {
                       for (int jcounter = icounter + 1; jcounter < numlinessm; jcounter++) {
                           loop_stockmgtline = m_invlines.getLine(jcounter);
                           loop_unitsm = loop_stockmgtline.getMultiply();
                           String current_productidsm = current_stockmgtline.getProductID();
                           String current_productatt = current_stockmgtline.getProductAttSetInstId();
                           String loop_productidsm = loop_stockmgtline.getProductID();
                           String loop_productatt = loop_stockmgtline.getProductAttSetInstId();
                           if (loop_productidsm.equals(current_productidsm) && (loop_unitsm != 0) && ((loop_productatt!=null && loop_productatt.equals(current_productatt)) || (loop_productatt==null)&&(current_productatt==null)) ) {
                               current_unitsm = current_unitsm + loop_unitsm;
                               loop_stockmgtline.setMultiply(0);
                           }
                       }
                       current_stockmgtline.setMultiply(current_unitsm);
                   }
               }
               for (int icounter = numlinessm - 1; icounter > 0; icounter--) {
                   loop_stockmgtline = m_invlines.getLine(icounter);
                   loop_unitsm = loop_stockmgtline.getMultiply();
                   if (loop_unitsm == 0) {
                       m_invlines.deleteLine(icounter);
                   }
               }
 // End Add Code jldy0717


2)Compile and run the application

Retrieved from "http://wiki.openbravo.com/wiki/POS_-_Consolidate_the_Receipt_(Stock_Management)"

This page has been accessed 4,655 times. This page was last modified on 12 October 2010, at 08:34. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.