1 Conceptual Map of Scripts



 

2 Script Structure

Menu path:
System / Scripts / Scripts
Mobile / Scripts / Scripts
Mobile CRM / System / Scripts / Scripts
Mobile / System / Scripts / Scripts
Sistema / Scripts / Scripts

The APPS system takes advantage of JavaScript to customize application actions and forms. At various points, each installation will require its own customizations, so as to be able to perform actions online with the application. These points may include loading, assignment validation, document editing, new customer registration, document line editing, payment verification, or printing. The apps_scripts table contains all Java programs synchronized to the device, which are interpreted by the application.

apps_sys_scripts
Label Description
Code Script code

  • Values:
    • ticketh.print: ticketh.print.
    • apps_pos_ticketh_open.edit: apps_pos_ticketh_open.edit.
    • apps_pos_ticketh_open.save: apps_pos_ticketh_open.save.
    • ticketh.validate: ticketh.validate.
    • ticketh.close: ticketh.close.
    • apps_customers_new.commit: apps_customers_new.commit.
    • apps_customers_new.edit: apps_customers_new.edit.
    • ticketl.validate: ticketl.validate.
    • apps_pos_ticketl_open.edit: apps_pos_ticketl_open.edit.
    • apps_pos_ticketl_open.save: apps_pos_ticketl_open.save.
    • main: main.
    • apps_sfa_task_assign.save: apps_sfa_task_assign.save.
    • apps_sfa_task_assign.commit: apps_sfa_task_assign.commit.
    • apps_sfa_task_assign.validate: apps_sfa_task_assign.validate.
    • apps_sfa_task_assign.edit: .
    • apps_pos_moveh.commit: apps_pos_moveh.commit.
    • apps_pos_cash.print: apps_pos_cash.print.
    • apps_pos_movement.print: apps_pos_movement.print.
    • apps_pos_moveh.validate: .
    • apps_pos_moveh.edit: apps_pos_moveh.edit.
    • apps_pos_moveh.save: apps_pos_moveh.save.
    • apps_pos_movel.edit: apps_pos_movel.edit.
    • assign_from_action.validate: assign_from_action.validate.
Description Script information
Script Script

Status Status

  • Default: A
  • Case: Upshift
  • Values:
    • A: Valid.
    • B: Drop.
Creator User who first entered/created the record

  • Default: USER
Registration date Log entry date

  • Default: CURRENT
Updater Last user to modify the record

  • Default: USER
Update date Date of most recent registry modification

  • Default: CURRENT
 

3 Movement Scripts

 

3.1 apps_pos_moveh.commit

The script with the apps_pos_moveh.commit code is executed by pressing the 'OK' button in the movement registration editor. The program must return a [true/false] boolean value. There is a set of functions intrinsic to the script which can be used:

Example
Copy
/**
* Get the source bean of this edit form
*/
SQLBean      moveh     = caller.getBean();
 
/**
* From Constants
*/
    public static final Uri             TABLE_MOVEH                     = Uri.parse(CONTENT_URI +  "apps_pos_moveh");
    public static final String          COLUMN_MOVEH_TERMID                 = "terminal_id";
    public static final String          COLUMN_MOVEH_TYPE               = "moveh_type";
    public static final String          COLUMN_MOVEH_NUMBER                 = "moveh_number";
    public static final String          COLUMN_MOVEH_TIPDOC                 = "moveh_tipdoc";
    public static final String          COLUMN_MOVEH_CUENTA                 = "moveh_cuenta";
    public static final String          COLUMN_MOVEH_ORIGIN                 = "moveh_origin";
    public static final String          COLUMN_MOVEH_DOCORI                 = "moveh_docori";   
    public static final String          COLUMN_MOVEH_CARRIER                = "moveh_carrier";
    public static final String          COLUMN_MOVEH_DATE               = "moveh_date";
    public static final String          COLUMN_MOVEH_NOTE                   = "moveh_note";
    public static final String          COLUMN_MOVEH_STATE              = "moveh_state";
 
 
EditText ed_tipdoc  = caller.get(Constants.COLUMN_MOVEH_TIPDOC).getEditText();

Example: Manual delivery recounts on the device are not permitted.

Copy
import android.widget.Toast;
 
/**
* Get the source bean of this edit form
*/
SQLBean      moveh     = caller.getBean();
 
// Get the editor of the tipdoc movement (in,out,recount,inventory...)
EditText ed_tipdoc  = caller.get(Constants.COLUMN_MOVEH_TIPDOC).getEditText();
String m_moveh_tipdoc      = ed_tipdoc.getText().toString();
 
// Do not permit manual recounts
if (m_moveh_tipdoc.equals("REC")) {
  Toast.makeText(context, "Recount not permitted!!!", Toast.LENGTH_LONG).show();
  return false;
}
return true;

New Movement Editor

The Recount movement type is not permitted.
 

3.2 apps_pos_moveh.validate

The script with the apps_pos_moveh.validate code will be executed when a movement is closed. The program must return a [true/false] boolean value. There is a set of functions intrinsic to the script which can be used:

Example
Copy
/**
* Get the source bean of this edit form
*/
SQLBean      moveh     = caller.getBean();
 
/**
* From Constants
*/
    public static final Uri             TABLE_MOVEH                     = Uri.parse(CONTENT_URI +  "apps_pos_moveh");
    public static final String          COLUMN_MOVEH_TERMID                 = "terminal_id";
    public static final String          COLUMN_MOVEH_TYPE               = "moveh_type";
    public static final String          COLUMN_MOVEH_NUMBER                 = "moveh_number";
    public static final String          COLUMN_MOVEH_TIPDOC                 = "moveh_tipdoc";
    public static final String          COLUMN_MOVEH_CUENTA                 = "moveh_cuenta";
    public static final String          COLUMN_MOVEH_ORIGIN                 = "moveh_origin";
    public static final String          COLUMN_MOVEH_DOCORI                 = "moveh_docori";   
    public static final String          COLUMN_MOVEH_CARRIER                = "moveh_carrier";
    public static final String          COLUMN_MOVEH_DATE               = "moveh_date";
    public static final String          COLUMN_MOVEH_NOTE                   = "moveh_note";
    public static final String          COLUMN_MOVEH_STATE              = "moveh_state";

Example: Close a generated stock movement.

Copy
import android.net.Uri;
import deister.android.apps.R;
import java.util.regex;



 
// Get the source bean of this edit form
SQLBean      moveh = context.getMoveBean();

String       m_terminal_id      = moveh.getString(Constants.COLUMN_MOVEL_TERMID);
String       m_type             = moveh.getString(Constants.COLUMN_MOVEL_TYPE);
String       m_numero           = moveh.getString(Constants.COLUMN_MOVEL_NUMBER);


SQLBean     m_movel = new SQLBean(Constants.TABLE_MOVEL);
 
   Cursor cur_movel = context.getContentResolver().query(
            Constants.TABLE_MOVEL,
            new String[] {"rowid, *"},
            Constants.TABLE_MOVEL_ITEM_MATCH,
            new String[] {m_terminal_id,m_numero,m_type},
            null
       );

     while (cur_movel.moveToNext()) {
           
         int    rowid         = cur_movel.getInt(0);
         String m_codean = (cur_movel.getString(cur_movel.getColumnIndexOrThrow(Constants.COLUMN_MOVEL_CODEAN)));         
        
         // Replace non ASCII Characters
         String m_new_codean= m_codean.replaceAll("[^\\x00-\\x7F]", "");
        
         // Replace unicode 0x 1d
         m_new_codean =  m_new_codean.replaceAll("\\p{C}", "/");
             
         SQLBean m_l = new SQLBean(m_movel, rowid);
         
         m_l.updateString(Constants.COLUMN_MOVEL_CODEAN, m_new_codean);
                 
     }

    cur_movel.close();

  return true;

To convert ASCII characters:

Copy
String m_new_codean= m_codean.replaceAll("[^\\x00-\\x7F]", "");

To convert Unicode 0x 1d characters:

Copy
m_new_codean =  m_new_codean.replaceAll("\\p{C}", "/");
 

3.3 apps_pos_movement.print

The script with the apps_pos_movement.print code is executed when the user wishes to print a movement. The printing job will be performed by the default printer configured, if one exists. There is a set of functions intrinsic to the script which can be used:

Example
Copy
/**
* Get the source bean of this edit form
*/
SQLBean      moveh     = caller.getBean();
 
// Obtain PK to get info from header
 
String      term_id         = moveh.getString(Constants.COLUMN_MOVEH_TERMID);
int         type            = moveh.getInt(Constants.COLUMN_MOVEH_TYPE);
int         number          = moveh.getInt(Constants.COLUMN_MOVEH_NUMBER);
 
/**
* From Constants
*/
    public static final Uri             TABLE_MOVEH                 = Uri.parse(CONTENT_URI +  "apps_pos_moveh");
    public static final String          COLUMN_MOVEH_TERMID         = "terminal_id";
    public static final String          COLUMN_MOVEH_TYPE           = "moveh_type";
    public static final String          COLUMN_MOVEH_NUMBER         = "moveh_number";
    public static final String          COLUMN_MOVEH_TIPDOC         = "moveh_tipdoc";
    public static final String          COLUMN_MOVEH_CUENTA         = "moveh_cuenta";
    public static final String          COLUMN_MOVEH_ORIGIN         = "moveh_origin";
    public static final String          COLUMN_MOVEH_DOCORI         = "moveh_docori";   
    public static final String          COLUMN_MOVEH_CARRIER        = "moveh_carrier";
    public static final String          COLUMN_MOVEH_DATE           = "moveh_date";
    public static final String          COLUMN_MOVEH_NOTE           = "moveh_note";
    public static final String          COLUMN_MOVEH_STATE          = "moveh_state";
 
 
 /**
    * String    getAppUser()            
    * String    getLoginCode()()
    * SQLBean   getMoveBean()
    * void      print(char c)
    * void      print(String s)
    * void      println(String s)   
    * void      println(int gravity, String s)
    * void      println(String left, String right)      
    * void      println(int gravity, String[] data) 
    * void      println(String[] left, String[] center, String[] right)         
    * void      printLine(int type)
    * void      printData(String[] data)
    * void      printHead(String caption)
    * void      printFoot(String left, String right)
    * void      print(String text)
    */