diff --git a/README.md b/README.md index 5b90b86..03890f3 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ To provide certain functionality which can be used by unTill(r) POS, driver must - [ITimeAttendance](docs/time_and_attendance.md) - implement for handling time and attendance operations (clock in, end break) - [IPosPrinter](docs/pos_printer.md) - implement for handling POS printer operations (print, upload logo) - [IExportHandler](docs/export_handler.md) - implement for handling exports +- [ITablesHandler](docs/tables_handler.md) - implement for handling table events Declaration of supported interfaces is made by `init` method which is called at driver initialization stage. Driver must return a map of supported interfaces: ```java diff --git a/docs/tables_handler.md b/docs/tables_handler.md new file mode 100644 index 0000000..4c5a066 --- /dev/null +++ b/docs/tables_handler.md @@ -0,0 +1,18 @@ +# Tables operations handler - ITablesHandler +POS invokes this interface when +- Table is dirty +- Table is clean + Example implementation +```java +public class TablesHandler implements ITablesHandler { + + @Override + public void operation(DriverConfiguration cfg, TableChangedRequest req) { + if (req instanceof TableDirtyChangedRequest) { + return handleTableDirtyChangedRequest(cfg, req); + } else { + throw new IllegalArgumentException("Operation not supported"); + } + } +} +``` \ No newline at end of file diff --git a/src/main/java/com/untill/driver/interfaces/tables/ITablesHandler.java b/src/main/java/com/untill/driver/interfaces/tables/ITablesHandler.java new file mode 100644 index 0000000..1899333 --- /dev/null +++ b/src/main/java/com/untill/driver/interfaces/tables/ITablesHandler.java @@ -0,0 +1,21 @@ +package com.untill.driver.interfaces.tables; + +import com.untill.driver.IDriver; +import com.untill.driver.interfaces.IDriverInterface; +import com.untill.driver.params.DriverConfiguration; + +/** + * Tables handler driver interface + * + * @see IDriverInterface + * @see IDriver + */ +public interface ITablesHandler extends IDriverInterface { + /** + * Handles table operations + * + * @param cfg driver instance configuration + * @param req request details + */ + void operation(DriverConfiguration cfg, TableChangedRequest req); +} diff --git a/src/main/java/com/untill/driver/interfaces/tables/TableChangedRequest.java b/src/main/java/com/untill/driver/interfaces/tables/TableChangedRequest.java new file mode 100644 index 0000000..d55e088 --- /dev/null +++ b/src/main/java/com/untill/driver/interfaces/tables/TableChangedRequest.java @@ -0,0 +1,38 @@ +package com.untill.driver.interfaces.tables; + +import com.untill.driver.interfaces.DriverRequest; + +public abstract class TableChangedRequest extends DriverRequest { + /** + * Table number + */ + private int tableNumber; + /** + * Table part + */ + private String tablePart; + + public int getTableNumber() { + return tableNumber; + } + + public void setTableNumber(int tableNumber) { + this.tableNumber = tableNumber; + } + + public String getTablePart() { + return tablePart; + } + + public void setTablePart(String tablePart) { + this.tablePart = tablePart; + } + + @Override + public String toString() { + return "TableChangedRequest{" + + "tableNumber=" + tableNumber + + ", tablePart='" + tablePart + '\'' + + "} " + super.toString(); + } +} diff --git a/src/main/java/com/untill/driver/interfaces/tables/TableDirtyChangedRequest.java b/src/main/java/com/untill/driver/interfaces/tables/TableDirtyChangedRequest.java new file mode 100644 index 0000000..03476b4 --- /dev/null +++ b/src/main/java/com/untill/driver/interfaces/tables/TableDirtyChangedRequest.java @@ -0,0 +1,23 @@ +package com.untill.driver.interfaces.tables; + +public class TableDirtyChangedRequest extends TableChangedRequest { + /** + * The flag is true if the Sales area setting Close tables manually is checked and everything is paid otherwise false + */ + private boolean dirty; + + public boolean isDirty() { + return dirty; + } + + public void setDirty(boolean dirty) { + this.dirty = dirty; + } + + @Override + public String toString() { + return "TableDirtyChangedRequest{" + + "dirty=" + dirty + + "} " + super.toString(); + } +}