brotherton-erpnext/erpnext/selling/page/point_of_sale/point_of_sale.py

277 lines
8.8 KiB
Python
Raw Normal View History

2017-08-23 06:45:10 +00:00
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe, json
from frappe.utils.nestedset import get_root_of
2018-01-23 12:58:05 +00:00
from frappe.utils import cint
from erpnext.accounts.doctype.pos_profile.pos_profile import get_item_groups
refactor: POS workflow (#20789) * refactor: add pos invoice doctype replacing sales invoice in POS * refactor: move pos.py to pos invoice * feat: add pos invoice merge log doctype * feat: ability to merge pos invoices into a sales invoice * feat: [wip] new ui for point of sale * fix: pos.py moved to pos_invoice * feat: loyalty points for POS Invoice * fix: loyalty points on merging * feat: return against pos invoices * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: status fix and set warehouse from pos profile * fix: naming series * feat: merge pos returns into credit notes * feat: add pos list action for merging into sales invoices * feat[UX]: add shortcuts & focus on search after customer selection * feat: stock validation from previous pos transactions * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: fix df not found for base_amount precision * feat: serial no validation from previous pos transactions * chore: move pos.py into pos page * feat: pos opening voucher * feat: link pos closing voucher with opening voucher * chore: use map_doc instead of get_mapped_doc for better perf * feat: enforce opening voucher on pos page * feat: [ui] [wip] point of sale beta ui refactor * fix: auto fetching serial nos with batch no * feat: [ui] item details section for new pos ui * feat: remove item from cart * refactor: [ui] [wip] split point_of_sale into components * new payment component * new numberpad * fix pos opening status * move from flex to grids * fix: search from item selector * feat: loyalty points as payment method * feat: pos invoice status * fix a bug with invalid JSON * fix: loyalty program ui fixes * feat: past order list and past order summary * feat: (minor) setting discount from item details * fix: adding item before customer selection * feat: post order submission summary * save and open draft orders * fix: item group filter * fix: item_det not defined while submitting sle * fix: minor bugs * fix: minor ux fixes * feat: show opening time in pos ui * feat: item and customer images * feat: emailing and printing an invoice * fix: item details field edit shows empty alert * fix: (minor) ux fixes * chore: rename pos opening voucher to pos opening entry * chore: (minor) rename pos closing voucher and sub doctypes * chore: add patch for renaming pos closing doctypes * fix: negative stock not allowed in pos invoices* default is_pos in pos invoices* fix: transalation * fix: invoices not getting fetched on pos closing * fix: indentation * feat: view / edit customer info * fix: minor bugs * fix: minor bug * fix: patch * fix: minor ux issues * fix: remove uppercase status * refactor: pos closing payment reconciliation * fix: move pos invoice print formats to pos invoice doctype * fix: ui issues * feat: new child doctype to store pos payment mode details * fix: add to patches.txt * feat: search by serial no * chore: [wip] code cleanup * fix: item not selectable from cart * chore: [wip] code cleanup * fix: minor issues * loyalty points transactions * default payment mode * fix: minor fixes * set correct mop amount with loaylty points * editing draft invoices from UI * chore: pos invoice merge log tests * fix: batch / serial validation in pos ui and on submission * feat: use onscan js for barcode scan events * fix: cart header with amount column * fix: validate batch no and qty in pos transactions * chore: do not fetch closing balances as opening balance * feat: show available qty in item selector * feat: shortcuts * fix: onscan.js not found * fix: onscan.js not found * fix: cannot return partial items * fix: neagtive stock indicator * feat: invoice discount * fix: change available stock on warehouse change * chore: cleanup code * fix: pos profile payment method table * feat: adding same item with different uom * fix: loyalty points deleted after consolidation * fix: enter loyalty amount instead of loyalty points * chore: return print format * feat: custom fields in pos view * chore: pos invoice test * chore: remove offline pos * fix: cyclic dependency * fix: cyclic dependency * patch: remove pos page and order fixes * chore: little fixes * fix: patch perf and plural naming * chore: tidy up pos invoice validation * chore: move pos closing to accounts * fix: move pos doctypes to accounts * fix: move pos doctypes to accounts * fix: item description in cart * fix: item description in cart * chore: loyalty tests * minor fixes * chore: rename point of sale beta to point of sale * chore: reset past order summary on filter change * chore: add point of sale to accounting desk * fix: payment reconciliation table in pos closing * fix: travis * Update accounting.json * fix: test cases * fix: tests * patch loyalty point entries * fix: remove test * default mode of payment is mandatory for pos transaction * chore: remove unused checks from pos profile * fix: loyalty point entry patch * fix: numpad reset and patches * fix: minor bugs * fix: travis * fix: travis * fix: travis * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-07-23 13:21:26 +00:00
from erpnext.accounts.doctype.pos_invoice.pos_invoice import get_stock_availability
2017-08-23 06:45:10 +00:00
2018-02-15 06:09:45 +00:00
from six import string_types
2017-08-23 06:45:10 +00:00
@frappe.whitelist()
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
def get_items(start, page_length, price_list, item_group, pos_profile, search_value=""):
data = dict()
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
result = []
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
allow_negative_stock = frappe.db.get_single_value('Stock Settings', 'allow_negative_stock')
warehouse, hide_unavailable_items = frappe.db.get_value('POS Profile', pos_profile, ['warehouse', 'hide_unavailable_items'])
if not frappe.db.exists('Item Group', item_group):
item_group = get_root_of('Item Group')
2017-08-23 06:45:10 +00:00
2017-08-23 10:55:16 +00:00
if search_value:
data = search_serial_or_batch_or_barcode_number(search_value)
item_code = data.get("item_code") if data.get("item_code") else search_value
serial_no = data.get("serial_no") if data.get("serial_no") else ""
batch_no = data.get("batch_no") if data.get("batch_no") else ""
barcode = data.get("barcode") if data.get("barcode") else ""
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
if data:
item_info = frappe.db.get_value(
"Item", data.get("item_code"),
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
["name as item_code", "item_name", "description", "stock_uom", "image as item_image", "is_stock_item"]
, as_dict=1)
item_info.setdefault('serial_no', serial_no)
item_info.setdefault('batch_no', batch_no)
item_info.setdefault('barcode', barcode)
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
return { 'items': [item_info] }
condition = get_conditions(item_code, serial_no, batch_no, barcode)
condition += get_item_group_condition(pos_profile)
lft, rgt = frappe.db.get_value('Item Group', item_group, ['lft', 'rgt'])
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
bin_join_selection, bin_join_condition = "", ""
if hide_unavailable_items:
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
bin_join_selection = ", `tabBin` bin"
bin_join_condition = "AND bin.warehouse = %(warehouse)s AND bin.item_code = item.name AND bin.actual_qty > 0"
2020-04-14 08:35:14 +00:00
items_data = frappe.db.sql("""
SELECT
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
item.name AS item_code,
item.item_name,
item.description,
item.stock_uom,
item.image AS item_image,
item.is_stock_item
FROM
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
`tabItem` item {bin_join_selection}
WHERE
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
item.disabled = 0
AND item.is_stock_item = 1
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
AND item.has_variants = 0
AND item.is_sales_item = 1
AND item.is_fixed_asset = 0
AND item.item_group in (SELECT name FROM `tabItem Group` WHERE lft >= {lft} AND rgt <= {rgt})
AND {condition}
{bin_join_condition}
2020-04-14 08:35:14 +00:00
ORDER BY
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
item.name asc
2020-04-14 08:35:14 +00:00
LIMIT
{start}, {page_length}"""
.format(
2020-04-14 08:35:14 +00:00
start=start,
page_length=page_length,
lft=lft,
rgt=rgt,
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
condition=condition,
bin_join_selection=bin_join_selection,
bin_join_condition=bin_join_condition
), {'warehouse': warehouse}, as_dict=1)
if items_data:
items = [d.item_code for d in items_data]
item_prices_data = frappe.get_all("Item Price",
fields = ["item_code", "price_list_rate", "currency"],
filters = {'price_list': price_list, 'item_code': ['in', items]})
refactor: POS workflow (#20789) * refactor: add pos invoice doctype replacing sales invoice in POS * refactor: move pos.py to pos invoice * feat: add pos invoice merge log doctype * feat: ability to merge pos invoices into a sales invoice * feat: [wip] new ui for point of sale * fix: pos.py moved to pos_invoice * feat: loyalty points for POS Invoice * fix: loyalty points on merging * feat: return against pos invoices * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: status fix and set warehouse from pos profile * fix: naming series * feat: merge pos returns into credit notes * feat: add pos list action for merging into sales invoices * feat[UX]: add shortcuts & focus on search after customer selection * feat: stock validation from previous pos transactions * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: fix df not found for base_amount precision * feat: serial no validation from previous pos transactions * chore: move pos.py into pos page * feat: pos opening voucher * feat: link pos closing voucher with opening voucher * chore: use map_doc instead of get_mapped_doc for better perf * feat: enforce opening voucher on pos page * feat: [ui] [wip] point of sale beta ui refactor * fix: auto fetching serial nos with batch no * feat: [ui] item details section for new pos ui * feat: remove item from cart * refactor: [ui] [wip] split point_of_sale into components * new payment component * new numberpad * fix pos opening status * move from flex to grids * fix: search from item selector * feat: loyalty points as payment method * feat: pos invoice status * fix a bug with invalid JSON * fix: loyalty program ui fixes * feat: past order list and past order summary * feat: (minor) setting discount from item details * fix: adding item before customer selection * feat: post order submission summary * save and open draft orders * fix: item group filter * fix: item_det not defined while submitting sle * fix: minor bugs * fix: minor ux fixes * feat: show opening time in pos ui * feat: item and customer images * feat: emailing and printing an invoice * fix: item details field edit shows empty alert * fix: (minor) ux fixes * chore: rename pos opening voucher to pos opening entry * chore: (minor) rename pos closing voucher and sub doctypes * chore: add patch for renaming pos closing doctypes * fix: negative stock not allowed in pos invoices* default is_pos in pos invoices* fix: transalation * fix: invoices not getting fetched on pos closing * fix: indentation * feat: view / edit customer info * fix: minor bugs * fix: minor bug * fix: patch * fix: minor ux issues * fix: remove uppercase status * refactor: pos closing payment reconciliation * fix: move pos invoice print formats to pos invoice doctype * fix: ui issues * feat: new child doctype to store pos payment mode details * fix: add to patches.txt * feat: search by serial no * chore: [wip] code cleanup * fix: item not selectable from cart * chore: [wip] code cleanup * fix: minor issues * loyalty points transactions * default payment mode * fix: minor fixes * set correct mop amount with loaylty points * editing draft invoices from UI * chore: pos invoice merge log tests * fix: batch / serial validation in pos ui and on submission * feat: use onscan js for barcode scan events * fix: cart header with amount column * fix: validate batch no and qty in pos transactions * chore: do not fetch closing balances as opening balance * feat: show available qty in item selector * feat: shortcuts * fix: onscan.js not found * fix: onscan.js not found * fix: cannot return partial items * fix: neagtive stock indicator * feat: invoice discount * fix: change available stock on warehouse change * chore: cleanup code * fix: pos profile payment method table * feat: adding same item with different uom * fix: loyalty points deleted after consolidation * fix: enter loyalty amount instead of loyalty points * chore: return print format * feat: custom fields in pos view * chore: pos invoice test * chore: remove offline pos * fix: cyclic dependency * fix: cyclic dependency * patch: remove pos page and order fixes * chore: little fixes * fix: patch perf and plural naming * chore: tidy up pos invoice validation * chore: move pos closing to accounts * fix: move pos doctypes to accounts * fix: move pos doctypes to accounts * fix: item description in cart * fix: item description in cart * chore: loyalty tests * minor fixes * chore: rename point of sale beta to point of sale * chore: reset past order summary on filter change * chore: add point of sale to accounting desk * fix: payment reconciliation table in pos closing * fix: travis * Update accounting.json * fix: test cases * fix: tests * patch loyalty point entries * fix: remove test * default mode of payment is mandatory for pos transaction * chore: remove unused checks from pos profile * fix: loyalty point entry patch * fix: numpad reset and patches * fix: minor bugs * fix: travis * fix: travis * fix: travis * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-07-23 13:21:26 +00:00
item_prices = {}
for d in item_prices_data:
item_prices[d.item_code] = d
for item in items_data:
2020-03-26 13:46:36 +00:00
item_code = item.item_code
item_price = item_prices.get(item_code) or {}
if allow_negative_stock:
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
item_stock_qty = frappe.db.sql("""select ifnull(sum(actual_qty), 0) from `tabBin` where item_code = %s""", item_code)[0][0]
2020-03-26 13:46:36 +00:00
else:
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
item_stock_qty = get_stock_availability(item_code, warehouse)
row = {}
row.update(item)
row.update({
'price_list_rate': item_price.get('price_list_rate'),
'currency': item_price.get('currency'),
'actual_qty': item_stock_qty,
})
result.append(row)
res = {
'items': result
}
2017-08-23 10:55:16 +00:00
return res
@frappe.whitelist()
def search_serial_or_batch_or_barcode_number(search_value):
# search barcode no
barcode_data = frappe.db.get_value('Item Barcode', {'barcode': search_value}, ['barcode', 'parent as item_code'], as_dict=True)
if barcode_data:
return barcode_data
# search serial no
serial_no_data = frappe.db.get_value('Serial No', search_value, ['name as serial_no', 'item_code'], as_dict=True)
if serial_no_data:
return serial_no_data
# search batch no
batch_no_data = frappe.db.get_value('Batch', search_value, ['name as batch_no', 'item as item_code'], as_dict=True)
if batch_no_data:
return batch_no_data
return {}
def get_conditions(item_code, serial_no, batch_no, barcode):
if serial_no or batch_no or barcode:
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
return "item.name = {0}".format(frappe.db.escape(item_code))
return make_condition(item_code)
def make_condition(item_code):
condition = "("
condition += """item.name like {item_code}
or item.item_name like {item_code}""".format(item_code = frappe.db.escape('%' + item_code + '%'))
condition += add_search_fields_condition(item_code)
condition += ")"
return condition
def add_search_fields_condition(item_code):
condition = ''
search_fields = frappe.get_all('POS Search Fields', fields = ['fieldname'])
if search_fields:
for field in search_fields:
condition += " or item.{0} like {1}".format(field['fieldname'], frappe.db.escape('%' + item_code + '%'))
return condition
def get_item_group_condition(pos_profile):
cond = "and 1=1"
item_groups = get_item_groups(pos_profile)
if item_groups:
fix: multiple pos issues (#23347) * fix: point of sale search * fix: pos fetches expired serial nos * fix: pos doesn't refresh on route change * fix: opening balances not set in opening entry * fix: remove debug statement * fix: invalid query if no serial no is reserved by pos invoice * chore: make new order btn primary * chore: filter warehouse by company * chore: add shortcuts for new order and email * fix: cannot fetch serial no if no batch control * chore: add shortcuts for menu items * feat: standard keyboard shortcuts for pos page * feat: display only items that are in stock * fix: empty point of sale page if opening entry dialog is closed * feat: conversion factor in pos item details * fix: show all invalid mode of payments * chore: show all items if allow negative stock is checked * fix: -ve amount set when changing mode of payment * fix: pos closing validations * fix: test * fix: non expired serial no fetching query * fix: cannot dismiss pos opening creation dialog * fix: transalation strings * fix: msgprint to throw * chore: use as_list in frappe.throw * chore: clean up pos invoice.js & .py * fix: codacy * fix: transalation syntax * fix: codacy * fix: set_missing_values called twice from pos page * fix: mode selector with double spaces * fix: do not allow tables in pos additional fields * fix: pos is not defined * feat: set mode of payments for returns * fix: remove naming series from pos profile * fix: error message * fix: minor bugs * chore: re-arrange pos closing entry detail fields * fix: sider & frappe linter * fix: more translation strings * fix: travis * fix: more translation strings * fix: sider * fix: travis * fix: unexpected end of string * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-10-26 05:47:04 +00:00
cond = "and item.item_group in (%s)"%(', '.join(['%s']*len(item_groups)))
return cond % tuple(item_groups)
@frappe.whitelist()
@frappe.validate_and_sanitize_search_inputs
def item_group_query(doctype, txt, searchfield, start, page_len, filters):
item_groups = []
cond = "1=1"
pos_profile= filters.get('pos_profile')
if pos_profile:
item_groups = get_item_groups(pos_profile)
if item_groups:
cond = "name in (%s)"%(', '.join(['%s']*len(item_groups)))
cond = cond % tuple(item_groups)
return frappe.db.sql(""" select distinct name from `tabItem Group`
where {condition} and (name like %(txt)s) limit {start}, {page_len}"""
.format(condition = cond, start=start, page_len= page_len),
{'txt': '%%%s%%' % txt})
@frappe.whitelist()
refactor: POS workflow (#20789) * refactor: add pos invoice doctype replacing sales invoice in POS * refactor: move pos.py to pos invoice * feat: add pos invoice merge log doctype * feat: ability to merge pos invoices into a sales invoice * feat: [wip] new ui for point of sale * fix: pos.py moved to pos_invoice * feat: loyalty points for POS Invoice * fix: loyalty points on merging * feat: return against pos invoices * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: status fix and set warehouse from pos profile * fix: naming series * feat: merge pos returns into credit notes * feat: add pos list action for merging into sales invoices * feat[UX]: add shortcuts & focus on search after customer selection * feat: stock validation from previous pos transactions * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: fix df not found for base_amount precision * feat: serial no validation from previous pos transactions * chore: move pos.py into pos page * feat: pos opening voucher * feat: link pos closing voucher with opening voucher * chore: use map_doc instead of get_mapped_doc for better perf * feat: enforce opening voucher on pos page * feat: [ui] [wip] point of sale beta ui refactor * fix: auto fetching serial nos with batch no * feat: [ui] item details section for new pos ui * feat: remove item from cart * refactor: [ui] [wip] split point_of_sale into components * new payment component * new numberpad * fix pos opening status * move from flex to grids * fix: search from item selector * feat: loyalty points as payment method * feat: pos invoice status * fix a bug with invalid JSON * fix: loyalty program ui fixes * feat: past order list and past order summary * feat: (minor) setting discount from item details * fix: adding item before customer selection * feat: post order submission summary * save and open draft orders * fix: item group filter * fix: item_det not defined while submitting sle * fix: minor bugs * fix: minor ux fixes * feat: show opening time in pos ui * feat: item and customer images * feat: emailing and printing an invoice * fix: item details field edit shows empty alert * fix: (minor) ux fixes * chore: rename pos opening voucher to pos opening entry * chore: (minor) rename pos closing voucher and sub doctypes * chore: add patch for renaming pos closing doctypes * fix: negative stock not allowed in pos invoices* default is_pos in pos invoices* fix: transalation * fix: invoices not getting fetched on pos closing * fix: indentation * feat: view / edit customer info * fix: minor bugs * fix: minor bug * fix: patch * fix: minor ux issues * fix: remove uppercase status * refactor: pos closing payment reconciliation * fix: move pos invoice print formats to pos invoice doctype * fix: ui issues * feat: new child doctype to store pos payment mode details * fix: add to patches.txt * feat: search by serial no * chore: [wip] code cleanup * fix: item not selectable from cart * chore: [wip] code cleanup * fix: minor issues * loyalty points transactions * default payment mode * fix: minor fixes * set correct mop amount with loaylty points * editing draft invoices from UI * chore: pos invoice merge log tests * fix: batch / serial validation in pos ui and on submission * feat: use onscan js for barcode scan events * fix: cart header with amount column * fix: validate batch no and qty in pos transactions * chore: do not fetch closing balances as opening balance * feat: show available qty in item selector * feat: shortcuts * fix: onscan.js not found * fix: onscan.js not found * fix: cannot return partial items * fix: neagtive stock indicator * feat: invoice discount * fix: change available stock on warehouse change * chore: cleanup code * fix: pos profile payment method table * feat: adding same item with different uom * fix: loyalty points deleted after consolidation * fix: enter loyalty amount instead of loyalty points * chore: return print format * feat: custom fields in pos view * chore: pos invoice test * chore: remove offline pos * fix: cyclic dependency * fix: cyclic dependency * patch: remove pos page and order fixes * chore: little fixes * fix: patch perf and plural naming * chore: tidy up pos invoice validation * chore: move pos closing to accounts * fix: move pos doctypes to accounts * fix: move pos doctypes to accounts * fix: item description in cart * fix: item description in cart * chore: loyalty tests * minor fixes * chore: rename point of sale beta to point of sale * chore: reset past order summary on filter change * chore: add point of sale to accounting desk * fix: payment reconciliation table in pos closing * fix: travis * Update accounting.json * fix: test cases * fix: tests * patch loyalty point entries * fix: remove test * default mode of payment is mandatory for pos transaction * chore: remove unused checks from pos profile * fix: loyalty point entry patch * fix: numpad reset and patches * fix: minor bugs * fix: travis * fix: travis * fix: travis * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-07-23 13:21:26 +00:00
def check_opening_entry(user):
open_vouchers = frappe.db.get_all("POS Opening Entry",
filters = {
"user": user,
refactor: POS workflow (#20789) * refactor: add pos invoice doctype replacing sales invoice in POS * refactor: move pos.py to pos invoice * feat: add pos invoice merge log doctype * feat: ability to merge pos invoices into a sales invoice * feat: [wip] new ui for point of sale * fix: pos.py moved to pos_invoice * feat: loyalty points for POS Invoice * fix: loyalty points on merging * feat: return against pos invoices * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: status fix and set warehouse from pos profile * fix: naming series * feat: merge pos returns into credit notes * feat: add pos list action for merging into sales invoices * feat[UX]: add shortcuts & focus on search after customer selection * feat: stock validation from previous pos transactions * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: fix df not found for base_amount precision * feat: serial no validation from previous pos transactions * chore: move pos.py into pos page * feat: pos opening voucher * feat: link pos closing voucher with opening voucher * chore: use map_doc instead of get_mapped_doc for better perf * feat: enforce opening voucher on pos page * feat: [ui] [wip] point of sale beta ui refactor * fix: auto fetching serial nos with batch no * feat: [ui] item details section for new pos ui * feat: remove item from cart * refactor: [ui] [wip] split point_of_sale into components * new payment component * new numberpad * fix pos opening status * move from flex to grids * fix: search from item selector * feat: loyalty points as payment method * feat: pos invoice status * fix a bug with invalid JSON * fix: loyalty program ui fixes * feat: past order list and past order summary * feat: (minor) setting discount from item details * fix: adding item before customer selection * feat: post order submission summary * save and open draft orders * fix: item group filter * fix: item_det not defined while submitting sle * fix: minor bugs * fix: minor ux fixes * feat: show opening time in pos ui * feat: item and customer images * feat: emailing and printing an invoice * fix: item details field edit shows empty alert * fix: (minor) ux fixes * chore: rename pos opening voucher to pos opening entry * chore: (minor) rename pos closing voucher and sub doctypes * chore: add patch for renaming pos closing doctypes * fix: negative stock not allowed in pos invoices* default is_pos in pos invoices* fix: transalation * fix: invoices not getting fetched on pos closing * fix: indentation * feat: view / edit customer info * fix: minor bugs * fix: minor bug * fix: patch * fix: minor ux issues * fix: remove uppercase status * refactor: pos closing payment reconciliation * fix: move pos invoice print formats to pos invoice doctype * fix: ui issues * feat: new child doctype to store pos payment mode details * fix: add to patches.txt * feat: search by serial no * chore: [wip] code cleanup * fix: item not selectable from cart * chore: [wip] code cleanup * fix: minor issues * loyalty points transactions * default payment mode * fix: minor fixes * set correct mop amount with loaylty points * editing draft invoices from UI * chore: pos invoice merge log tests * fix: batch / serial validation in pos ui and on submission * feat: use onscan js for barcode scan events * fix: cart header with amount column * fix: validate batch no and qty in pos transactions * chore: do not fetch closing balances as opening balance * feat: show available qty in item selector * feat: shortcuts * fix: onscan.js not found * fix: onscan.js not found * fix: cannot return partial items * fix: neagtive stock indicator * feat: invoice discount * fix: change available stock on warehouse change * chore: cleanup code * fix: pos profile payment method table * feat: adding same item with different uom * fix: loyalty points deleted after consolidation * fix: enter loyalty amount instead of loyalty points * chore: return print format * feat: custom fields in pos view * chore: pos invoice test * chore: remove offline pos * fix: cyclic dependency * fix: cyclic dependency * patch: remove pos page and order fixes * chore: little fixes * fix: patch perf and plural naming * chore: tidy up pos invoice validation * chore: move pos closing to accounts * fix: move pos doctypes to accounts * fix: move pos doctypes to accounts * fix: item description in cart * fix: item description in cart * chore: loyalty tests * minor fixes * chore: rename point of sale beta to point of sale * chore: reset past order summary on filter change * chore: add point of sale to accounting desk * fix: payment reconciliation table in pos closing * fix: travis * Update accounting.json * fix: test cases * fix: tests * patch loyalty point entries * fix: remove test * default mode of payment is mandatory for pos transaction * chore: remove unused checks from pos profile * fix: loyalty point entry patch * fix: numpad reset and patches * fix: minor bugs * fix: travis * fix: travis * fix: travis * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-07-23 13:21:26 +00:00
"pos_closing_entry": ["in", ["", None]],
"docstatus": 1
},
refactor: POS workflow (#20789) * refactor: add pos invoice doctype replacing sales invoice in POS * refactor: move pos.py to pos invoice * feat: add pos invoice merge log doctype * feat: ability to merge pos invoices into a sales invoice * feat: [wip] new ui for point of sale * fix: pos.py moved to pos_invoice * feat: loyalty points for POS Invoice * fix: loyalty points on merging * feat: return against pos invoices * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: status fix and set warehouse from pos profile * fix: naming series * feat: merge pos returns into credit notes * feat: add pos list action for merging into sales invoices * feat[UX]: add shortcuts & focus on search after customer selection * feat: stock validation from previous pos transactions * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: fix df not found for base_amount precision * feat: serial no validation from previous pos transactions * chore: move pos.py into pos page * feat: pos opening voucher * feat: link pos closing voucher with opening voucher * chore: use map_doc instead of get_mapped_doc for better perf * feat: enforce opening voucher on pos page * feat: [ui] [wip] point of sale beta ui refactor * fix: auto fetching serial nos with batch no * feat: [ui] item details section for new pos ui * feat: remove item from cart * refactor: [ui] [wip] split point_of_sale into components * new payment component * new numberpad * fix pos opening status * move from flex to grids * fix: search from item selector * feat: loyalty points as payment method * feat: pos invoice status * fix a bug with invalid JSON * fix: loyalty program ui fixes * feat: past order list and past order summary * feat: (minor) setting discount from item details * fix: adding item before customer selection * feat: post order submission summary * save and open draft orders * fix: item group filter * fix: item_det not defined while submitting sle * fix: minor bugs * fix: minor ux fixes * feat: show opening time in pos ui * feat: item and customer images * feat: emailing and printing an invoice * fix: item details field edit shows empty alert * fix: (minor) ux fixes * chore: rename pos opening voucher to pos opening entry * chore: (minor) rename pos closing voucher and sub doctypes * chore: add patch for renaming pos closing doctypes * fix: negative stock not allowed in pos invoices* default is_pos in pos invoices* fix: transalation * fix: invoices not getting fetched on pos closing * fix: indentation * feat: view / edit customer info * fix: minor bugs * fix: minor bug * fix: patch * fix: minor ux issues * fix: remove uppercase status * refactor: pos closing payment reconciliation * fix: move pos invoice print formats to pos invoice doctype * fix: ui issues * feat: new child doctype to store pos payment mode details * fix: add to patches.txt * feat: search by serial no * chore: [wip] code cleanup * fix: item not selectable from cart * chore: [wip] code cleanup * fix: minor issues * loyalty points transactions * default payment mode * fix: minor fixes * set correct mop amount with loaylty points * editing draft invoices from UI * chore: pos invoice merge log tests * fix: batch / serial validation in pos ui and on submission * feat: use onscan js for barcode scan events * fix: cart header with amount column * fix: validate batch no and qty in pos transactions * chore: do not fetch closing balances as opening balance * feat: show available qty in item selector * feat: shortcuts * fix: onscan.js not found * fix: onscan.js not found * fix: cannot return partial items * fix: neagtive stock indicator * feat: invoice discount * fix: change available stock on warehouse change * chore: cleanup code * fix: pos profile payment method table * feat: adding same item with different uom * fix: loyalty points deleted after consolidation * fix: enter loyalty amount instead of loyalty points * chore: return print format * feat: custom fields in pos view * chore: pos invoice test * chore: remove offline pos * fix: cyclic dependency * fix: cyclic dependency * patch: remove pos page and order fixes * chore: little fixes * fix: patch perf and plural naming * chore: tidy up pos invoice validation * chore: move pos closing to accounts * fix: move pos doctypes to accounts * fix: move pos doctypes to accounts * fix: item description in cart * fix: item description in cart * chore: loyalty tests * minor fixes * chore: rename point of sale beta to point of sale * chore: reset past order summary on filter change * chore: add point of sale to accounting desk * fix: payment reconciliation table in pos closing * fix: travis * Update accounting.json * fix: test cases * fix: tests * patch loyalty point entries * fix: remove test * default mode of payment is mandatory for pos transaction * chore: remove unused checks from pos profile * fix: loyalty point entry patch * fix: numpad reset and patches * fix: minor bugs * fix: travis * fix: travis * fix: travis * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-07-23 13:21:26 +00:00
fields = ["name", "company", "pos_profile", "period_start_date"],
order_by = "period_start_date desc"
)
return open_vouchers
@frappe.whitelist()
def create_opening_voucher(pos_profile, company, balance_details):
import json
balance_details = json.loads(balance_details)
new_pos_opening = frappe.get_doc({
'doctype': 'POS Opening Entry',
"period_start_date": frappe.utils.get_datetime(),
"posting_date": frappe.utils.getdate(),
"user": frappe.session.user,
"pos_profile": pos_profile,
"company": company,
})
new_pos_opening.set("balance_details", balance_details)
new_pos_opening.submit()
return new_pos_opening.as_dict()
@frappe.whitelist()
def get_past_order_list(search_term, status, limit=20):
fields = ['name', 'grand_total', 'currency', 'customer', 'posting_time', 'posting_date']
invoice_list = []
if search_term and status:
invoices_by_customer = frappe.db.get_all('POS Invoice', filters={
'customer': ['like', '%{}%'.format(search_term)],
'status': status
}, fields=fields)
invoices_by_name = frappe.db.get_all('POS Invoice', filters={
'name': ['like', '%{}%'.format(search_term)],
'status': status
}, fields=fields)
invoice_list = invoices_by_customer + invoices_by_name
elif status:
invoice_list = frappe.db.get_all('POS Invoice', filters={
'status': status
}, fields=fields)
refactor: POS workflow (#20789) * refactor: add pos invoice doctype replacing sales invoice in POS * refactor: move pos.py to pos invoice * feat: add pos invoice merge log doctype * feat: ability to merge pos invoices into a sales invoice * feat: [wip] new ui for point of sale * fix: pos.py moved to pos_invoice * feat: loyalty points for POS Invoice * fix: loyalty points on merging * feat: return against pos invoices * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: status fix and set warehouse from pos profile * fix: naming series * feat: merge pos returns into credit notes * feat: add pos list action for merging into sales invoices * feat[UX]: add shortcuts & focus on search after customer selection * feat: stock validation from previous pos transactions * Merge 'fork/serial-no-selector' into refactor-pos-invoice * chore: fix df not found for base_amount precision * feat: serial no validation from previous pos transactions * chore: move pos.py into pos page * feat: pos opening voucher * feat: link pos closing voucher with opening voucher * chore: use map_doc instead of get_mapped_doc for better perf * feat: enforce opening voucher on pos page * feat: [ui] [wip] point of sale beta ui refactor * fix: auto fetching serial nos with batch no * feat: [ui] item details section for new pos ui * feat: remove item from cart * refactor: [ui] [wip] split point_of_sale into components * new payment component * new numberpad * fix pos opening status * move from flex to grids * fix: search from item selector * feat: loyalty points as payment method * feat: pos invoice status * fix a bug with invalid JSON * fix: loyalty program ui fixes * feat: past order list and past order summary * feat: (minor) setting discount from item details * fix: adding item before customer selection * feat: post order submission summary * save and open draft orders * fix: item group filter * fix: item_det not defined while submitting sle * fix: minor bugs * fix: minor ux fixes * feat: show opening time in pos ui * feat: item and customer images * feat: emailing and printing an invoice * fix: item details field edit shows empty alert * fix: (minor) ux fixes * chore: rename pos opening voucher to pos opening entry * chore: (minor) rename pos closing voucher and sub doctypes * chore: add patch for renaming pos closing doctypes * fix: negative stock not allowed in pos invoices* default is_pos in pos invoices* fix: transalation * fix: invoices not getting fetched on pos closing * fix: indentation * feat: view / edit customer info * fix: minor bugs * fix: minor bug * fix: patch * fix: minor ux issues * fix: remove uppercase status * refactor: pos closing payment reconciliation * fix: move pos invoice print formats to pos invoice doctype * fix: ui issues * feat: new child doctype to store pos payment mode details * fix: add to patches.txt * feat: search by serial no * chore: [wip] code cleanup * fix: item not selectable from cart * chore: [wip] code cleanup * fix: minor issues * loyalty points transactions * default payment mode * fix: minor fixes * set correct mop amount with loaylty points * editing draft invoices from UI * chore: pos invoice merge log tests * fix: batch / serial validation in pos ui and on submission * feat: use onscan js for barcode scan events * fix: cart header with amount column * fix: validate batch no and qty in pos transactions * chore: do not fetch closing balances as opening balance * feat: show available qty in item selector * feat: shortcuts * fix: onscan.js not found * fix: onscan.js not found * fix: cannot return partial items * fix: neagtive stock indicator * feat: invoice discount * fix: change available stock on warehouse change * chore: cleanup code * fix: pos profile payment method table * feat: adding same item with different uom * fix: loyalty points deleted after consolidation * fix: enter loyalty amount instead of loyalty points * chore: return print format * feat: custom fields in pos view * chore: pos invoice test * chore: remove offline pos * fix: cyclic dependency * fix: cyclic dependency * patch: remove pos page and order fixes * chore: little fixes * fix: patch perf and plural naming * chore: tidy up pos invoice validation * chore: move pos closing to accounts * fix: move pos doctypes to accounts * fix: move pos doctypes to accounts * fix: item description in cart * fix: item description in cart * chore: loyalty tests * minor fixes * chore: rename point of sale beta to point of sale * chore: reset past order summary on filter change * chore: add point of sale to accounting desk * fix: payment reconciliation table in pos closing * fix: travis * Update accounting.json * fix: test cases * fix: tests * patch loyalty point entries * fix: remove test * default mode of payment is mandatory for pos transaction * chore: remove unused checks from pos profile * fix: loyalty point entry patch * fix: numpad reset and patches * fix: minor bugs * fix: travis * fix: travis * fix: travis * fix: travis Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2020-07-23 13:21:26 +00:00
return invoice_list
@frappe.whitelist()
def set_customer_info(fieldname, customer, value=""):
if fieldname == 'loyalty_program':
frappe.db.set_value('Customer', customer, 'loyalty_program', value)
contact = frappe.get_cached_value('Customer', customer, 'customer_primary_contact')
if not contact:
contact = frappe.db.sql("""
SELECT parent FROM `tabDynamic Link`
WHERE
parenttype = 'Contact' AND
parentfield = 'links' AND
link_doctype = 'Customer' AND
link_name = %s
""", (customer), as_dict=1)
contact = contact[0].get('parent') if contact else None
if not contact:
new_contact = frappe.new_doc('Contact')
new_contact.is_primary_contact = 1
new_contact.first_name = customer
new_contact.set('links', [{'link_doctype': 'Customer', 'link_name': customer}])
new_contact.save()
contact = new_contact.name
frappe.db.set_value('Customer', customer, 'customer_primary_contact', contact)
contact_doc = frappe.get_doc('Contact', contact)
if fieldname == 'email_id':
contact_doc.set('email_ids', [{ 'email_id': value, 'is_primary': 1}])
frappe.db.set_value('Customer', customer, 'email_id', value)
elif fieldname == 'mobile_no':
contact_doc.set('phone_nos', [{ 'phone': value, 'is_primary_mobile_no': 1}])
frappe.db.set_value('Customer', customer, 'mobile_no', value)
contact_doc.save()