FANDOM


THIS MY EDITED VERSION OF ANOTHER SCRIPT POSTED HERE

This code is based on the work of Jeff Breeden and Mikel Irurita.

This script Generates an extra line of discount or expense.

Add either a fixed amount or e percentage.

Conditions: The volume of the product, the date and if the customer is recognized.

How to get it to work:

1. Go into Administration->Maintenance and select Resources

2. Create a new resource and name it script.autotag

Add this to the script.autotag Edit

// This code is based on the work of Jeff Breeden and Mikel Irurita.

// This i Version 1.0, revision 1.



import com.openbravo.format.Formats;

import com.openbravo.pos.ticket.TicketLineInfo;

import com.openbravo.pos.ticket.TicketProductInfo;

import java.lang.Math;

import java.util.*;

import java.text.*;



index = sales.getSelectedIndex();



if (index >= 0) {



    line = ticket.getLine(index);



    double crv = Double.parseDouble(line.getProperty("CRV", "0"));



        if (crv != 0) {

            itm = line.getProperty("ITEM", "0");

            double moms = Double.parseDouble(line.getProperty("MOMS", "0"));



                if (moms != 0) {

                    ticket.insertLine(index + 1,

                    new TicketLineInfo(

                    "* " + itm,

                    line.getProductTaxCategoryID(),

                    line.getMultiply(),

                    crv,

                    line.getTaxInfo()));

                    sales.setSelectedIndex(index + 1);

                } else {



                    ticket.insertLine(index + 1,

                    new TicketLineInfo(

                    "* " + itm,

                    "000",

                    line.getMultiply(),

                    crv,

                    line.getTaxInfo()));

                    sales.setSelectedIndex(index + 1);

                }

        } else {



// Discoint module



            double antal = Double.parseDouble(line.getProperty("RABATANTAL", "0"));



            if (antal > 0 && (antal <= line.getMultiply()) ) {

                double foralle = Double.parseDouble(line.getProperty("FORALLE", "0"));

                medlem = ticket.getCustomer();

                    if ( foralle == 1 || medlem != null ) {

                        Date cal = Calendar.getInstance().getTime();

                        String str_date= (String)line.getProperty("INDEN_DATO", "0");

                        DateFormat formatter ;

                        formatter = new SimpleDateFormat("dd-MM-yyyy");

                        dato = (Date)formatter.parse(str_date);



                        tidl=cal.before(dato);

                            if (tidl) {

                                double procent = Double.parseDouble(line.getProperty("PROCENT", "0"));

                                sdiscount = Formats.PERCENT.formatValue(procent/100);

                                itm = line.getProperty("TEKST", "0");

    


                                ticket.insertLine(index + 1,

                                    new TicketLineInfo(

                                    "* " + itm + " " + sdiscount,

                                    line.getProductTaxCategoryID(),

                                    line.getMultiply(),

                                    -line.getPrice () * procent / 100,

                                    line.getTaxInfo()));



                                sales.setSelectedIndex(index + 1);

                            }

                    }

            }

        }

}

3. Save the script (by exiting)

Add this to the resource Ticket.Buttons Edit

and add this line just above the </configuration> line:

<event key="ticket.change" code="script.autotag"/>

5. Save (by exiting), and restart.

Add this specifically formatted XML to your products "notes" Edit

Put this XML into the Note field of any product.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">



<properties>



// Method 1: Add an extra line with a fixed amount to the receipt.



 <entry key="CRV">25.00</entry>

 <entry key="ITEM">Extra handling cost</entry>

 <entry key="MOMS">1</entry>



// The parameters:



// CRV - the amount (without tax) to add to the line (use real number, may even be negative)

// ITEM - the text to put in the line (an * is adde to indicate an automated line). Max 25 characters.

// MOMS - If 1, TAX is added to the amount, 0 no TAX is added



// Method 2: Add an extra line to the receipt if you buy a number of the same product (volume discount).



 <entry key="RABATANTAL">2</entry>

 <entry key="TEKST">Mængderabat</entry>

 <entry key="PROCENT">10</entry>

 <entry key="FORALLE">1</entry>

 <entry key="INDEN_DATO">29-12-2011</entry>



// The parameters:



// RABATANTAL - number of items to trigger discount. May be 0 (no discount), 1 (discount on any volumen), 2 and up ...

// TEKST - the text that is put in the receipt. A leading * and a trailing discount % is added

// PROCENT - the discount percentage. Use a real number from 0.00 to 99.99 (or even 100 if item is free)

// FORALLE - 1 if discount is available for every customer. 0 if only registered customers may get the discount

// INDEN_DATO - the discount is used until the start (the day entered is NOT included in the discount interval) of this day. Date format: dd-MM-yyyy

// If date is set to 28-12-2011 the discount period terminates by the 27-12-2011 at 23:59



</properties>

NOTE: Your XML must be correctly entered into each products Note field. IF you make mistakes, the product will trigger a script error.

When deleting items from the receipt, always delete the product line first, then the automated (*) line.

this is the link for the module

http://forge.openbravo.com/projects/apd

Here are some comments about this module

https://sourceforge.net/p/unicentaopos/discussion/1126901/thread/25041fc2/?limit=25#e746

Good luck

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.