### Install ERPNext App using Bench Source: https://github.com/ury-erp/ury/blob/develop/INSTALLATION.md This command adds the ERPNext application to your Frappe bench, making it available for installation on sites. Ensure you have Frappe bench installed and configured. ```shell bench get-app --branch version-15 erpnext https://github.com/frappe/erpnext.git ``` -------------------------------- ### Install URY App to Frappe Site Source: https://github.com/ury-erp/ury/blob/develop/INSTALLATION.md Installs the URY application onto the specified Frappe site, enabling its features within that site context. ```shell bench --site sitename install-app ury ``` -------------------------------- ### Install URY App using Bench Source: https://github.com/ury-erp/ury/blob/develop/INSTALLATION.md Adds the URY application to your Frappe bench. This command clones the URY repository into the apps directory of your bench. ```shell bench get-app ury https://github.com/ury-erp/ury.git ``` -------------------------------- ### Create New Frappe Site Source: https://github.com/ury-erp/ury/blob/develop/INSTALLATION.md Initializes a new Frappe site with the specified name. This command sets up the necessary database and configuration for a new site. ```shell bench new-site sitename ``` -------------------------------- ### Install ERPNext to Frappe Site Source: https://github.com/ury-erp/ury/blob/develop/INSTALLATION.md Installs the previously added ERPNext application onto a specific Frappe site. This makes ERPNext's functionalities available within that site. ```shell bench --site sitename install-app erpnext ``` -------------------------------- ### Migrate Frappe Site Source: https://github.com/ury-erp/ury/blob/develop/INSTALLATION.md Applies database schema changes and updates for all installed apps on the specified Frappe site. This command ensures the database is synchronized with the installed application versions. ```shell bench --site sitename migrate ``` -------------------------------- ### Build Frappe Site Source: https://github.com/ury-erp/ury/blob/develop/INSTALLATION.md Compiles and bundles static resources for the specified Frappe site. This command is essential after installing new apps or making changes to optimize site performance. ```shell bench --site sitename build ``` -------------------------------- ### Install Frappe HR App using Bench Source: https://github.com/ury-erp/ury/blob/develop/INSTALLATION.md Installs the Frappe HR application, a prerequisite for URY's employee management reports, into your Frappe bench. This command fetches the app from its GitHub repository. ```shell bench get-app --branch hrms https://github.com/frappe/hrms.git ``` -------------------------------- ### Install Frappe HR to Frappe Site Source: https://github.com/ury-erp/ury/blob/develop/INSTALLATION.md Installs the Frappe HR application onto the specified Frappe site. This is required for URY's reporting features related to employee management. ```shell bench --site sitename install-app hrms ``` -------------------------------- ### Add React-Specific ESLint Rules with Plugins Source: https://github.com/ury-erp/ury/blob/develop/pos/README.md This JavaScript code snippet shows how to integrate `eslint-plugin-react-x` and `eslint-plugin-react-dom` into an ESLint configuration. It involves importing the plugins and then adding them to the `plugins` object. Finally, it enables recommended TypeScript and general recommended rules from these plugins. ```javascript // eslint.config.js import reactX from 'eslint-plugin-react-x' import reactDom from 'eslint-plugin-react-dom' export default tseslint.config({ plugins: { // Add the react-x and react-dom plugins 'react-x': reactX, 'react-dom': reactDom, }, rules: { // other rules... // Enable its recommended typescript rules ...reactX.configs['recommended-typescript'].rules, ...reactDom.configs.recommended.rules, }, }) ``` -------------------------------- ### Templating Engine for Financial Data Display (Example) Source: https://github.com/ury-erp/ury/blob/develop/ury/ury/doctype/ury_daily_p_and_l/profit_loss_details.html Demonstrates how a templating engine (likely Jinja, based on syntax) is used to iterate through financial data and format it for display. It includes placeholders for currency formatting and translations. ```jinja {% for expense in data.indirect_expenses_breakup %} {{ expense.breakup }} {{ expense.amount }} {{ expense.percent }}% {% endfor %} {{ _('Gross Sales') }} {{ frappe.utils.fmt_money(data.gross_sales or '', currency=currency) }} {{ data.gross_sales_percent }}% {{ _('Net Sales') }} {{ frappe.utils.fmt_money(data.net_sales or '', currency=currency) }} {{ data.net_sales_percent }}% {{ _('Total Indirect Expenses') }} {{ frappe.utils.fmt_money(data.total_indirect_expenses or '', currency=currency) }} {{ data.total_indirect_expenses_percent }}% {{ _('Net Profit/Loss') }} {{ frappe.utils.fmt_money(data.net_profit or '', currency=currency) }} {{ data.net_profit_percent }}% ``` -------------------------------- ### Enable Type-Aware ESLint Rules in TypeScript Source: https://github.com/ury-erp/ury/blob/develop/pos/README.md This code snippet demonstrates how to configure ESLint to use type-aware lint rules in a TypeScript project. It requires the `tseslint` configuration and specifies project configuration files like `tsconfig.node.json` and `tsconfig.app.json`. The output enables stricter linting based on TypeScript's type information. ```javascript export default tseslint.config({ extends: [ // Remove ...tseslint.configs.recommended and replace with this ...tseslint.configs.recommendedTypeChecked, // Alternatively, use this for stricter rules ...tseslint.configs.strictTypeChecked, // Optionally, add this for stylistic rules ...tseslint.configs.stylisticTypeChecked, ], languageOptions: { // other options... parserOptions: { project: ['./tsconfig.node.json', './tsconfig.app.json'], tsconfigRootDir: import.meta.dirname, }, }, }) ``` -------------------------------- ### Manage POS Invoices and Items (TypeScript) Source: https://context7.com/ury-erp/ury/llms.txt API for retrieving, searching, and updating Point of Sale (POS) invoices. It supports pagination, status filtering, and retrieving invoice items and taxes. Dependencies include the './lib/invoice-api' module. Handles operations like fetching invoices, getting item details, searching, and status updates. ```typescript import { getPOSInvoices, getPOSInvoiceItems, updateInvoiceStatus, searchPosInvoice } from './lib/invoice-api'; // Get invoices with pagination const result = await getPOSInvoices({ status: 'Draft', limit: 20, limit_start: 0 }); console.log("Invoices:", result.invoices); console.log("Has more:", result.hasMore); // Get invoice items and taxes const { items, taxes } = await getPOSInvoiceItems("POS-INV-2024-00001"); items.forEach(item => { console.log(`${item.item_name}: ${item.qty} x ${item.amount}`); }); // Search invoices const searchResults = await searchPosInvoice("John Doe", "Paid"); console.log("Search results:", searchResults); // Update invoice status await updateInvoiceStatus("POS-INV-2024-00001", "Paid"); ``` -------------------------------- ### Get Table Order Details API Source: https://context7.com/ury-erp/ury/llms.txt This API retrieves the current active order information for a specific table, including customer details, items ordered, and total amounts. ```APIDOC ## GET /api/tables/{table_id}/order ### Description Fetches current active order information for a specific table, including customer details and order items. ### Method GET ### Endpoint /api/tables/{table_id}/order ### Parameters #### Path Parameters - **table_id** (string) - Required - The identifier of the table to retrieve the order for. #### Query Parameters None #### Request Body None ### Request Example GET /api/tables/TABLE-001/order ### Response #### Success Response (200) - **message** (object) - Contains the order details if an active order exists. - **name** (string) - The invoice ID of the order. - **customer_name** (string) - The name of the customer. - **grand_total** (number) - The total amount of the order. - **items** (array) - List of items in the order. - **item_name** (string) - Name of the item. - **qty** (number) - Quantity ordered. - **rate** (number) - Price per unit. - **amount** (number) - Total amount for this item line. #### Response Example ```json { "message": { "name": "INV-2024-00123", "customer_name": "John Doe", "grand_total": 30.50, "items": [ {"item_name": "Pizza Margherita", "qty": 1, "rate": 15.00, "amount": 15.00}, {"item_name": "Coke", "qty": 2, "rate": 7.75, "amount": 15.50} ] } } ``` #### No Active Order Response (200) ```json { "message": null } ``` ### Error Handling - **404 Not Found**: The specified table does not exist. - **500 Internal Server Error**: Server error while fetching order details. ``` -------------------------------- ### Build Customer Search Index with Bench CLI Source: https://github.com/ury-erp/ury/blob/develop/SETUP.md Commands to build and rebuild the global search index for customers in an ERPNext site using the bench CLI. These are essential for efficient customer searching. ```bash bench --site site-name build-search-index ``` ```bash bench --site site-name rebuild-global-search ``` -------------------------------- ### POS Invoice Management API Source: https://context7.com/ury-erp/ury/llms.txt Retrieves, searches, and manages POS invoices with pagination and status filtering. It allows fetching invoices, getting details of invoice items and taxes, searching invoices, and updating their status. ```APIDOC ## POS Invoice Management API ### Description Retrieves, searches, and manages POS invoices with pagination and status filtering. ### Method GET (Implied by `getPOSInvoices`, `getPOSInvoiceItems`, `searchPosInvoice`) PUT (Implied by `updateInvoiceStatus`) ### Endpoint `/api/pos/invoices` (for `getPOSInvoices`) `/api/pos/invoices/{invoiceId}/items` (for `getPOSInvoiceItems`) `/api/pos/invoices/{invoiceId}/status` (for `updateInvoiceStatus`) `/api/pos/invoices/search` (for `searchPosInvoice`) ### Parameters #### Path Parameters - **invoiceId** (string) - Required - The ID of the POS invoice. #### Query Parameters (for `getPOSInvoices`) - **status** (string) - Optional - Filters invoices by status (e.g., 'Draft', 'Paid'). - **limit** (integer) - Optional - The maximum number of invoices to return. - **limit_start** (integer) - Optional - The starting offset for pagination. #### Query Parameters (for `searchPosInvoice`) - **customerName** (string) - Required - The name of the customer to search for. - **status** (string) - Required - The status of the invoice to search for. ### Request Body (for `updateInvoiceStatus`) - **status** (string) - Required - The new status to set for the invoice. ### Request Example ```typescript // Get invoices with pagination const result = await getPOSInvoices({ status: 'Draft', limit: 20, limit_start: 0 }); // Get invoice items and taxes const { items, taxes } = await getPOSInvoiceItems("POS-INV-2024-00001"); // Search invoices const searchResults = await searchPosInvoice("John Doe", "Paid"); // Update invoice status await updateInvoiceStatus("POS-INV-2024-00001", "Paid"); ``` ### Response #### Success Response (200) - **result** (object) - Contains `invoices` (array) and `hasMore` (boolean) for `getPOSInvoices`. - **items** (array) - List of invoice items. - **taxes** (array) - List of taxes applied to the invoice. - **searchResults** (array) - List of invoices matching the search criteria. #### Response Example ```json // Example for getPOSInvoices { "invoices": [ { "id": "POS-INV-2024-00001", "customer": "John Doe", "total": 50.00, "status": "Draft" } ], "hasMore": true } // Example for getPOSInvoiceItems { "items": [ { "item_name": "Burger", "qty": 2, "amount": 10.00 } ], "taxes": [ { "tax_name": "GST", "amount": 1.80 } ] } // Example for searchPosInvoice [ { "id": "POS-INV-2024-00002", "customer": "John Doe", "total": 75.50, "status": "Paid" } ] ``` ``` -------------------------------- ### Importing UI Components from Index (TypeScript/React) Source: https://github.com/ury-erp/ury/blob/develop/pos/src/components/ui/README.md Demonstrates how to import multiple UI components at once from the main UI index file, useful for convenience. Assumes components are exported from '@/components/ui'. ```tsx import { Button, Input, Select, Badge, Card, Dialog } from "@/components/ui" ``` -------------------------------- ### Handle User Login and Roles (TypeScript) Source: https://context7.com/ury-erp/ury/llms.txt API for user authentication, including logging in, retrieving user roles, and managing sessions. It relies on the './lib/auth-api' module. Inputs include user credentials for login and outputs user details and role information. ```typescript import { getLoggedUser, getUserRoles, logout } from './lib/auth-api'; // Get current logged-in user const userEmail = await getLoggedUser(); console.log("Logged in user:", userEmail); // Get user roles and details if (userEmail) { const userDetails = await getUserRoles(userEmail); console.log("Full name:", userDetails.full_name); console.log("Roles:", userDetails.roles); // Check for specific role const isCashier = userDetails.roles.includes("Cashier"); const isWaiter = userDetails.roles.includes("Waiter"); console.log(`Cashier access: ${isCashier}`); console.log(`Waiter access: ${isWaiter}`); } // Logout user await logout(); ``` -------------------------------- ### Importing Individual UI Components (TypeScript/React) Source: https://github.com/ury-erp/ury/blob/develop/pos/src/components/ui/README.md Shows how to import specific UI components individually from their respective files within the '@/components/ui' directory. This approach can be beneficial for code splitting or when only a few components are needed. ```tsx import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" ``` -------------------------------- ### Kitchen Display System API Source: https://context7.com/ury-erp/ury/llms.txt Manages KOT (Kitchen Order Ticket) display for kitchen screens, including order status updates. It allows fetching active KOTs and marking orders as served. ```APIDOC ## Kitchen Display System API ### Description Manages KOT display for kitchen screens including order status updates. ### Method GET (Implied by `get_kot_list`) POST (Implied by `serve_order`) ### Endpoint `/api/kitchen/kots` (for `get_kot_list`) `/api/kitchen/kot/{kotId}/serve` (for `serve_order`) ### Parameters #### Path Parameters - **kotId** (string) - Required - The ID of the KOT to mark as served. ### Request Example ```python # Get active KOTs for kitchen display result = get_kot_list() for kot in result['KOT']: print(f"Order: {kot['order_no']}") # ... other details # Mark KOT as served serve_order("KOT-001") ``` ### Response #### Success Response (200) - **result** (object) - Contains `KOT` (list of KOT documents), `Branch` (string), `kot_alert_time` (integer), `audio_alert` (boolean), `daily_order_number` (boolean). #### Response Example ```json { "KOT": [ { "order_no": "12345", "restaurant_table": "Table 5", "order_status": "Pending", "kot_items": [ { "item_name": "Pizza", "qty": 1 } ] } ], "Branch": "Main Branch", "kot_alert_time": 5, "audio_alert": true, "daily_order_number": true } ``` ``` -------------------------------- ### Generate Kitchen Order Ticket (KOT) - Python Source: https://context7.com/ury-erp/ury/llms.txt Creates or modifies Kitchen Order Tickets (KOTs) for kitchen staff coordination. It compares current and previous order items to detect changes, generates new KOTs for added items, and cancel KOTs for removed items. Items are routed to appropriate production units based on item groups, and order modifications are handled with proper KOT typing. This function is part of the Frappe backend. ```python import frappe # Create new KOT or modify existing orders data = { "invoice_id": "POS-INV-2024-00001", "customer": "John Doe", "restaurant_table": "TABLE-001", "current_items": [ {"item": "ITEM-001", "item_name": "Pizza Margherita", "qty": 2, "comment": "Extra cheese"}, {"item": "ITEM-002", "item_name": "Pasta Carbonara", "qty": 1, "comment": ""} ], "previous_items": [], "comments": "Rush order" } response = frappe.call({ "method": "ury.ury.api.ury_kot_generate.kot_execute", "args": data }) # The function automatically: # - Compares current and previous items to detect changes # - Creates new KOTs for added items # - Creates cancel KOTs for removed items # - Routes items to appropriate production units based on item groups # - Handles order modifications with proper KOT typing ``` -------------------------------- ### Order Number Generation Logic Source: https://context7.com/ury-erp/ury/llms.txt Explains the automatic generation of sequential order numbers for KOT display and tracking. ```APIDOC ## Order Number Generation ### Description This section outlines the logic for automatically generating sequential order numbers for Kitchen Order Tickets (KOTs), used for display and tracking purposes within the POS system. This process is typically managed via a server-side hook. ### Mechanism - **Hook**: The order number generation is triggered by an `after_insert` event on the `POS Invoice` doctype, configured in the `hooks.py` file. - **Sequence**: - For regular orders, numbers increment sequentially (1, 2, 3, ...). - For aggregator orders (e.g., from delivery platforms), a prefix is used (e.g., `AGR - 1`, `AGR - 2`, ...). - **Resetting**: Order numbers are reset at each POS opening or on a daily basis, as determined by system configuration. The last used invoice number is tracked in the `POS Opening Entry` doctype. ### Example Flow 1. **POS Opening**: The system notes the last invoice number, e.g., `POS-INV-2024-00100`. 2. **New Regular Order**: A new `POS Invoice` (`POS-INV-2024-00101`) is created. The assigned Order Number is `1`. 3. **Another Regular Order**: A subsequent `POS Invoice` (`POS-INV-2024-00102`) is created. The assigned Order Number is `2`. 4. **New Aggregator Order**: An aggregator `POS Invoice` (`POS-INV-2024-00103`) is created. The assigned Order Number is `AGR - 1`. ### Configuration - The exact prefix for aggregator orders and the reset mechanism (per POS opening or daily) are configurable within the system's settings or via the `hooks.py` file. ``` -------------------------------- ### Input Component with Variants and Sizes (TypeScript/React) Source: https://github.com/ury-erp/ury/blob/develop/pos/src/components/ui/README.md A styled input component offering various states and sizes. It includes variants like default, error, success, and search, with adjustable sizes (default, sm, lg). Imported from '@/components/ui'. ```tsx import { Input } from "@/components/ui" // Variants: default, error, success, search // Sizes: default, sm, lg ``` -------------------------------- ### Manage Kitchen Order Tickets (Python) Source: https://context7.com/ury-erp/ury/llms.txt API for managing Kitchen Order Tickets (KOTs) for display on kitchen screens and updating their status. This Python API uses Frappe framework functionalities. It allows fetching active KOTs and marking orders as served, automatically calculating production time. ```python import frappe # Get active KOTs for kitchen display @frappe.whitelist() def get_kot_list(): result = frappe.call({ "method": "ury.ury.api.ury_kot_display.kot_list" }) # Returns: # - KOT: List of active KOT documents # - Branch: Current branch # - kot_alert_time: Warning time threshold in minutes # - audio_alert: Boolean for audio notifications # - daily_order_number: Whether order numbers reset daily for kot in result['KOT']: print(f"Order: {kot['order_no']}") print(f"Table: {kot['restaurant_table']}") print(f"Status: {kot['order_status']}") print(f"Items: {kot['kot_items']}") # Mark KOT as served @frappe.whitelist() def serve_order(kot_id): frappe.call({ "method": "ury.ury.api.ury_kot_display.serve_kot", "args": { "name": kot_id, "time": frappe.utils.now() } }) # Automatically calculates production time and updates status ``` -------------------------------- ### Invoice Printing API (TypeScript) Source: https://context7.com/ury-erp/ury/llms.txt Handles invoice printing via network printers and QZ Tray, with support for retrieving invoice HTML, direct network printing, auto-printer selection, and status updates. Requires a local library for network printing capabilities. ```typescript import { getInvoicePrintHtml, networkPrint, selectNetworkPrinter, updatePrintStatus } from './lib/invoice-api'; // Get invoice HTML for printing const printHtml = await getInvoicePrintHtml("POS-INV-2024-00001", "POS Invoice"); console.log("Print HTML ready"); // Print to specific network printer await networkPrint("POS-INV-2024-00001", "PRINTER-001", "POS Invoice"); // Auto-select printer based on POS profile configuration await selectNetworkPrinter("POS-INV-2024-00001", "POS-PROFILE-001", "POS Invoice"); // Update print status after successful print await updatePrintStatus("POS-INV-2024-00001"); ``` -------------------------------- ### Restaurant Menu API Source: https://context7.com/ury-erp/ury/llms.txt This API allows retrieval of menu items for different contexts, such as dine-in or aggregator platforms. It includes item details like name, price, and course information. ```APIDOC ## GET /api/menu ### Description Retrieves menu items based on POS profile, room, and order type with pricing and availability. Also supports fetching menus for aggregator platforms. ### Method GET ### Endpoint /api/menu ### Parameters #### Query Parameters - **pos_profile** (string) - Required - The POS profile identifier. - **room** (string) - Optional - The room identifier, if applicable. - **order_type** (string) - Required - The type of order (e.g., "Dine In", "Takeaway", "Swiggy"). ### Request Example GET /api/menu?pos_profile=POS-PROFILE-001&order_type=Dine In GET /api/menu?order_type=Swiggy ### Response #### Success Response (200) - Returns an array of menu items. Each item may include: - **item_name** (string) - Name of the menu item. - **rate** (number) - Price of the item. - **course** (string) - The course the item belongs to (e.g., "Appetizer", "Main Course"). - **special_dish** (boolean) - Indicates if the item is a special dish. #### Response Example (Dine-in) ```json [ { "item_name": "Pizza Margherita", "rate": 12.99, "course": "Main Course", "special_dish": false }, { "item_name": "Garlic Bread", "rate": 5.50, "course": "Appetizer", "special_dish": false } ] ``` #### Response Example (Aggregator) ```json [ { "item_name": "Burger", "rate": 8.00 }, { "item_name": "Fries", "rate": 3.50 } ] ``` ### Error Handling - **400 Bad Request**: Missing required query parameters. - **500 Internal Server Error**: Server error while fetching the menu. ``` -------------------------------- ### Customer Management API Source: https://context7.com/ury-erp/ury/llms.txt Creates and searches customer records with validation. ```APIDOC ## Customer Management API ### Description Provides endpoints for creating new customer records and searching for existing customers. ### Methods - `createCustomer(customerData)`: Creates a new customer record. - `searchCustomers(searchTerm)`: Searches for customers by name or phone number. ### Request Example (TypeScript) ```typescript import { createCustomer, searchCustomers } from './lib/customer-api'; // Create new customer const newCustomer = await createCustomer({ customer_name: "John Doe", mobile_number: "+1234567890", customer_group: "Individual", territory: "All Territories" }); console.log("Customer created:", newCustomer); // Search customers by name or phone const customers = await searchCustomers("John"); customers.forEach(customer => { console.log(`${customer.customer_name} - ${customer.mobile_number}`); }); ``` ### Response Responses vary based on the specific method called. `createCustomer` typically returns the newly created customer object, and `searchCustomers` returns an array of customer objects matching the search criteria. ``` -------------------------------- ### Manage Restaurant Rooms and Tables (TypeScript) Source: https://context7.com/ury-erp/ury/llms.txt API for managing restaurant rooms and tables, including retrieving room and table information, and checking table occupancy. It depends on the './lib/table-api' module. Retrieves lists of rooms or tables and counts for specific rooms. ```typescript import { getRooms, getTables, getTableCount } from './lib/table-api'; // Get all rooms for a branch const rooms = await getRooms("BRANCH-001"); console.log("Available rooms:", rooms); // Get tables in a specific room const tables = await getTables("ROOM-001"); tables.forEach(table => { console.log(`Table: ${table.name}`); console.log(`Shape: ${table.table_shape}, Seats: ${table.no_of_seats}`); console.log(`Occupied: ${table.occupied ? 'Yes' : 'No'}`); if (table.latest_invoice_time) { console.log(`Last order: ${table.latest_invoice_time}`); } }); // Get table count for a room const count = await getTableCount("ROOM-001", "BRANCH-001"); console.log(`Total tables: ${count}`); ``` -------------------------------- ### User Authentication API Source: https://context7.com/ury-erp/ury/llms.txt Handles user login, role retrieval, and session management. It allows fetching the currently logged-in user's email, their roles and details, and logging out the user. ```APIDOC ## User Authentication API ### Description Handles user login, role retrieval, and session management. ### Method GET (Implied by `getLoggedUser`, `getUserRoles`) POST (Implied by `logout`) ### Endpoint `/api/auth/user` (for `getLoggedUser`) `/api/auth/user/{email}/roles` (for `getUserRoles`) `/api/auth/logout` (for `logout`) ### Parameters #### Path Parameters - **email** (string) - Required - The email of the user whose roles are to be retrieved. ### Request Example ```typescript // Get current logged-in user const userEmail = await getLoggedUser(); // Get user roles and details if (userEmail) { const userDetails = await getUserRoles(userEmail); // Check for specific role const isCashier = userDetails.roles.includes("Cashier"); } // Logout user await logout(); ``` ### Response #### Success Response (200) - **userEmail** (string) - The email of the logged-in user. - **userDetails** (object) - An object containing user details including `full_name` and `roles` (array of strings). #### Response Example ```json // Example for getLoggedUser "user@example.com" // Example for getUserRoles { "full_name": "John Doe", "roles": ["Waiter", "Cashier"] } ``` ``` -------------------------------- ### Customer Management API (TypeScript) Source: https://context7.com/ury-erp/ury/llms.txt Provides functions to create new customer records and search for existing customers by name or phone number. Requires customer details like name, mobile number, group, and territory for creation. ```typescript import { createCustomer, searchCustomers } from './lib/customer-api'; // Create new customer const newCustomer = await createCustomer({ customer_name: "John Doe", mobile_number: "+1234567890", customer_group: "Individual", territory: "All Territories" }); console.log("Customer created:", newCustomer); // Search customers by name or phone const customers = await searchCustomers("John"); customers.forEach(customer => { console.log(`${customer.customer_name} - ${customer.mobile_number}`); }); ``` -------------------------------- ### Invoice Printing API Source: https://context7.com/ury-erp/ury/llms.txt Handles invoice printing through network printers and QZ Tray with print status tracking. ```APIDOC ## Invoice Printing API ### Description Handles invoice printing through network printers and QZ Tray with print status tracking. ### Methods - `getInvoicePrintHtml(invoiceId, invoiceType)`: Retrieves the HTML content for an invoice. - `networkPrint(invoiceId, printerName, invoiceType)`: Prints an invoice to a specified network printer. - `selectNetworkPrinter(invoiceId, posProfile, invoiceType)`: Automatically selects a network printer based on POS profile configuration. - `updatePrintStatus(invoiceId)`: Updates the print status of an invoice after successful printing. ### Request Example (TypeScript) ```typescript import { getInvoicePrintHtml, networkPrint, selectNetworkPrinter, updatePrintStatus } from './lib/invoice-api'; // Get invoice HTML for printing const printHtml = await getInvoicePrintHtml("POS-INV-2024-00001", "POS Invoice"); console.log("Print HTML ready"); // Print to specific network printer await networkPrint("POS-INV-2024-00001", "PRINTER-001", "POS Invoice"); // Auto-select printer based on POS profile configuration await selectNetworkPrinter("POS-INV-2024-00001", "POS-PROFILE-001", "POS Invoice"); // Update print status after successful print await updatePrintStatus("POS-INV-2024-00001"); ``` ### Response Responses vary based on the specific method called. Refer to the `invoice-api` library for detailed response structures. ``` -------------------------------- ### Retrieve Restaurant and Aggregator Menus - TypeScript Source: https://context7.com/ury-erp/ury/llms.txt Fetches restaurant menu items based on POS profile, room, and order type, including pricing and availability. It also retrieves menus specifically for aggregator platforms like Swiggy or Zomato. This functionality uses `getRestaurantMenu` and `getAggregatorMenu` functions from a local `menu-api` library. ```typescript import { getRestaurantMenu, getAggregatorMenu } from './lib/menu-api'; // Get restaurant menu for dine-in try { const menu = await getRestaurantMenu("POS-PROFILE-001", "ROOM-001", "Dine In"); menu.forEach(item => { console.log(`${item.item_name} - ${item.rate}`); console.log(`Course: ${item.course}`); if (item.special_dish) console.log("Special Dish!"); }); } catch (error) { console.error("Menu fetch error:", error.message); } // Get menu for aggregator orders (Swiggy, Zomato, etc.) const aggregatorMenu = await getAggregatorMenu("Swiggy"); console.log("Aggregator items:", aggregatorMenu); ``` -------------------------------- ### Dialog Component with Content and Variants (TypeScript/React) Source: https://github.com/ury-erp/ury/blob/develop/pos/src/components/ui/README.md A modal dialog component featuring an overlay and content sections. It supports variants like default and fullscreen, and various sizes (default, sm, lg, etc.). Imported from '@/components/ui'. ```tsx import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter } from "@/components/ui" // Variants: default, fullscreen // Sizes: default, sm, lg, xl, 2xl, 3xl, 4xl, 5xl, 6xl, 7xl Dialog Title Dialog description
Dialog content
``` -------------------------------- ### Table and Room Management API Source: https://context7.com/ury-erp/ury/llms.txt Manages restaurant rooms and tables, including their occupancy status and availability. It allows fetching all rooms for a branch, tables within a specific room, and the count of tables in a room. ```APIDOC ## Table and Room Management API ### Description Manages restaurant rooms and tables including occupancy status and availability. ### Method GET (Implied by `getRooms`, `getTables`, `getTableCount`) ### Endpoint `/api/rooms` (for `getRooms`) `/api/rooms/{roomId}/tables` (for `getTables`) `/api/rooms/{roomId}/tables/count` (for `getTableCount`) ### Parameters #### Path Parameters - **roomId** (string) - Required - The ID of the room to retrieve tables for. #### Query Parameters - **branchId** (string) - Required - The ID of the branch to retrieve rooms for. ### Request Example ```typescript // Get all rooms for a branch const rooms = await getRooms("BRANCH-001"); // Get tables in a specific room const tables = await getTables("ROOM-001"); // Get table count for a room const count = await getTableCount("ROOM-001", "BRANCH-001"); ``` ### Response #### Success Response (200) - **rooms** (array) - List of room objects. - **tables** (array) - List of table objects. - **count** (integer) - The total number of tables in the room. #### Response Example ```json // Example for getRooms [ { "id": "ROOM-001", "name": "Dining Area 1", "capacity": 50 } ] // Example for getTables [ { "id": "TABLE-001", "name": "Table 1", "table_shape": "Round", "no_of_seats": 4, "occupied": false, "latest_invoice_time": null } ] // Example for getTableCount 15 ``` ``` -------------------------------- ### Kitchen Order Ticket (KOT) Generation API Source: https://context7.com/ury-erp/ury/llms.txt This API endpoint is used to create and manage Kitchen Order Tickets (KOTs). It facilitates communication between front-of-house and kitchen staff by handling new orders, modifications, and cancellations. The system routes items to appropriate production units and manages KOT modifications. ```APIDOC ## POST /api/kitchen/kot ### Description Creates and manages Kitchen Order Tickets (KOTs) for coordinating between front-of-house and kitchen staff. Handles new orders, modifications, and cancellations across multiple production units. ### Method POST ### Endpoint /api/kitchen/kot ### Parameters #### Query Parameters None #### Request Body - **invoice_id** (string) - Required - The ID of the associated invoice. - **customer** (string) - Required - The name of the customer. - **restaurant_table** (string) - Required - The identifier for the restaurant table. - **current_items** (array) - Required - A list of current items in the order. - **item** (string) - Required - Item ID. - **item_name** (string) - Required - Name of the item. - **qty** (number) - Required - Quantity of the item. - **comment** (string) - Optional - Any specific comments for the item. - **previous_items** (array) - Optional - A list of previous items for comparison (used for modifications). - **comments** (string) - Optional - General comments for the order. ### Request Example ```json { "invoice_id": "POS-INV-2024-00001", "customer": "John Doe", "restaurant_table": "TABLE-001", "current_items": [ {"item": "ITEM-001", "item_name": "Pizza Margherita", "qty": 2, "comment": "Extra cheese"}, {"item": "ITEM-002", "item_name": "Pasta Carbonara", "qty": 1, "comment": ""} ], "previous_items": [], "comments": "Rush order" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. - **message** (string) - A confirmation message. #### Response Example ```json { "status": "success", "message": "KOT generated and processed successfully." } ``` ### Error Handling - **400 Bad Request**: Invalid input data. - **500 Internal Server Error**: Server-side issue during processing. ``` -------------------------------- ### Select Component with Variants and Sizes (TypeScript/React) Source: https://github.com/ury-erp/ury/blob/develop/pos/src/components/ui/README.md A styled select component featuring error states and adjustable sizes. It supports variants like default, error, and success, along with sizes such as default, sm, and lg. Imported from '@/components/ui'. ```tsx import { Select } from "@/components/ui" // Variants: default, error, success // Sizes: default, sm, lg ``` -------------------------------- ### Synchronize Restaurant Orders - TypeScript Source: https://context7.com/ury-erp/ury/llms.txt Synchronizes restaurant orders across tables, POS terminals, and invoices, providing real-time updates. This function is used to create new table orders or update existing ones, including details like items, customer, payment mode, and order type. It relies on a `syncOrder` function from a local `order-api` library. ```typescript import { syncOrder } from './lib/order-api'; // Create or update a table order const orderData = { table: "TABLE-001", customer: "Walk-In Customer", items: [ { item: "ITEM-001", item_name: "Pizza Margherita", rate: 12.99, qty: 2 }, { item: "ITEM-002", item_name: "Coke", rate: 2.50, qty: 2 } ], no_of_pax: 4, mode_of_payment: "Cash", waiter: "waiter@example.com", pos_profile: "POS-PROFILE-001", invoice: null, // null for new order, invoice ID for updates order_type: "Dine In", last_invoice: null, comments: "Table near window", room: "ROOM-001" }; try { const result = await syncOrder(orderData); console.log("Order synced:", result); } catch (error) { console.error("Sync failed:", error); } ``` -------------------------------- ### Order Synchronization API Source: https://context7.com/ury-erp/ury/llms.txt This API synchronizes orders across tables, POS terminals, and invoices, ensuring real-time updates throughout the system. It supports creating new orders and updating existing ones. ```APIDOC ## POST /api/orders/sync ### Description Synchronizes orders between tables, POS terminals, and invoices with real-time updates across the system. Allows for creation and updating of table orders. ### Method POST ### Endpoint /api/orders/sync ### Parameters #### Query Parameters None #### Request Body - **table** (string) - Required - The identifier for the restaurant table. - **customer** (string) - Required - The name of the customer. - **items** (array) - Required - A list of items in the order. - **item** (string) - Required - Item ID. - **item_name** (string) - Required - Name of the item. - **rate** (number) - Required - Price per unit of the item. - **qty** (number) - Required - Quantity of the item. - **no_of_pax** (number) - Optional - Number of people at the table. - **mode_of_payment** (string) - Optional - The payment method used. - **waiter** (string) - Optional - Email or identifier of the waiter. - **pos_profile** (string) - Required - Identifier for the POS profile. - **invoice** (string) - Optional - Invoice ID if updating an existing order; null for a new order. - **order_type** (string) - Required - Type of order (e.g., "Dine In", "Takeaway"). - **last_invoice** (string) - Optional - ID of the last related invoice. - **comments** (string) - Optional - Any comments for the order. - **room** (string) - Optional - Identifier for the room, if applicable. ### Request Example ```json { "table": "TABLE-001", "customer": "Walk-In Customer", "items": [ {"item": "ITEM-001", "item_name": "Pizza Margherita", "rate": 12.99, "qty": 2}, {"item": "ITEM-002", "item_name": "Coke", "rate": 2.50, "qty": 2} ], "no_of_pax": 4, "mode_of_payment": "Cash", "waiter": "waiter@example.com", "pos_profile": "POS-PROFILE-001", "invoice": null, "order_type": "Dine In", "last_invoice": null, "comments": "Table near window", "room": "ROOM-001" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the synchronization. - **order_id** (string) - The ID of the synchronized order. #### Response Example ```json { "status": "success", "order_id": "INV-2024-00123" } ``` ### Error Handling - **400 Bad Request**: Missing or invalid required fields. - **500 Internal Server Error**: Problem during order synchronization. ``` -------------------------------- ### Fetch Table Order Details - TypeScript Source: https://context7.com/ury-erp/ury/llms.txt Retrieves current active order information for a specified table, including customer details, items, and total amount. It uses the `getTableOrder` function from a local `order-api` library. The output can be used to display order summaries or for further processing. ```typescript import { getTableOrder } from './lib/order-api'; // Fetch active order for a table const tableOrder = await getTableOrder("TABLE-001"); if (tableOrder.message) { console.log("Invoice ID:", tableOrder.message.name); console.log("Customer:", tableOrder.message.customer_name); console.log("Grand Total:", tableOrder.message.grand_total); console.log("Items:", tableOrder.message.items); // Access item details tableOrder.message.items.forEach(item => { console.log(`${item.item_name}: ${item.qty} x ${item.rate} = ${item.amount}`); }); } else { console.log("No active order for this table"); } ``` -------------------------------- ### Order Number Generation Logic (Python) Source: https://context7.com/ury-erp/ury/llms.txt Describes the automatic generation of sequential order numbers for KOTs and invoices, differentiating between regular and aggregator orders. The logic is triggered by the 'after_insert' event for 'POS Invoice' doctype. ```python # This hook runs automatically on POS Invoice creation # Configured in hooks.py as: doc_events = {"POS Invoice": {"after_insert": [...set_order_number]}} # For regular orders: 1, 2, 3, 4... # For aggregator orders: AGR - 1, AGR - 2, AGR - 3... # Order numbers reset at each POS opening or daily based on configuration # Last invoice is tracked in POS Opening Entry # Example flow: # 1. POS Opening: last_invoice = POS-INV-2024-00100 # 2. New Order: POS-INV-2024-00101 → Order Number = 1 # 3. New Order: POS-INV-2024-00102 → Order Number = 2 # 4. Aggregator Order: POS-INV-2024-00103 → Order Number = AGR - 1 ``` -------------------------------- ### HTML Table Styling with CSS Source: https://github.com/ury-erp/ury/blob/develop/ury/ury/doctype/ury_daily_p_and_l/profit_loss_details.html Defines the visual presentation for financial data tables. It includes styles for borders, background colors, text alignment, and font weight, ensuring a clear and organized display of financial information. ```html ``` -------------------------------- ### Customizing Button Variants with CVA (TypeScript/React) Source: https://github.com/ury-erp/ury/blob/develop/pos/src/components/ui/README.md Illustrates how to leverage the `buttonVariants` function exported by the Button component to create custom styles. This allows for advanced customization by combining predefined variants, sizes, and adding custom class names. Uses class-variance-authority. ```tsx import { buttonVariants } from "@/components/ui/button" const customButtonClass = buttonVariants({ variant: "outline", size: "lg", className: "custom-class" }) ```