mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-20 05:29:18 +00:00
Merge branch 'develop' of https://github.com/frappe/erpnext into defaut_accounting_dimension
This commit is contained in:
101
.travis.yml
101
.travis.yml
@@ -1,51 +1,80 @@
|
|||||||
language: python
|
|
||||||
dist: trusty
|
dist: trusty
|
||||||
|
|
||||||
python:
|
language: python
|
||||||
- "2.7"
|
|
||||||
- "3.6"
|
|
||||||
|
|
||||||
env:
|
git:
|
||||||
- TEST_TYPE="Server Side Test"
|
depth: 1
|
||||||
- TEST_TYPE="Patch Test"
|
|
||||||
|
|
||||||
services:
|
cache:
|
||||||
- mysql
|
- pip
|
||||||
|
|
||||||
|
addons:
|
||||||
|
hosts: test_site
|
||||||
|
mariadb: 10.3
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
include:
|
||||||
|
- name: "Python 2.7 Server Side Test"
|
||||||
|
python: 2.7
|
||||||
|
script: bench --site test_site run-tests --app erpnext --coverage
|
||||||
|
|
||||||
|
- name: "Python 3.6 Server Side Test"
|
||||||
|
python: 3.6
|
||||||
|
script: bench --site test_site run-tests --app erpnext --coverage
|
||||||
|
|
||||||
|
- name: "Python 2.7 Patch Test"
|
||||||
|
python: 2.7
|
||||||
|
before_script:
|
||||||
|
- wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz
|
||||||
|
- bench --site test_site --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz
|
||||||
|
script: bench --site test_site migrate
|
||||||
|
|
||||||
|
- name: "Python 3.6 Patch Test"
|
||||||
|
python: 3.6
|
||||||
|
before_script:
|
||||||
|
- wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz
|
||||||
|
- bench --site test_site --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz
|
||||||
|
script: bench --site test_site migrate
|
||||||
|
|
||||||
install:
|
install:
|
||||||
# fix mongodb travis error
|
- cd ~
|
||||||
- sudo rm /etc/apt/sources.list.d/mongodb*.list
|
|
||||||
- pip install flake8==3.3.0
|
|
||||||
- flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
|
|
||||||
- sudo rm /etc/apt/sources.list.d/docker.list
|
|
||||||
- sudo apt-get install hhvm && rm -rf /home/travis/.kiex/
|
|
||||||
- sudo apt-get purge -y mysql-common mysql-server mysql-client
|
|
||||||
- nvm install 10
|
- nvm install 10
|
||||||
- pip install python-coveralls
|
|
||||||
- wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py
|
|
||||||
- sudo python install.py --develop --user travis --without-bench-setup
|
|
||||||
- sudo pip install -e ~/bench
|
|
||||||
|
|
||||||
- rm $TRAVIS_BUILD_DIR/.git/shallow
|
- git clone https://github.com/frappe/bench --depth 1
|
||||||
- bash $TRAVIS_BUILD_DIR/travis/bench_init.sh
|
- pip install -e ./bench
|
||||||
- cp -r $TRAVIS_BUILD_DIR/test_sites/test_site ~/frappe-bench/sites/
|
|
||||||
|
|
||||||
before_script:
|
- git clone https://github.com/frappe/frappe --branch $TRAVIS_BRANCH --depth 1
|
||||||
- mysql -u root -ptravis -e 'create database test_frappe'
|
- bench init --skip-assets --frappe-path ~/frappe --python $(which python) frappe-bench
|
||||||
- echo "USE mysql;\nCREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe';\nFLUSH PRIVILEGES;\n" | mysql -u root -ptravis
|
|
||||||
- echo "USE mysql;\nGRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost';\n" | mysql -u root -ptravis
|
- mkdir ~/frappe-bench/sites/test_site
|
||||||
|
- cp -r $TRAVIS_BUILD_DIR/.travis/site_config.json ~/frappe-bench/sites/test_site/
|
||||||
|
|
||||||
|
- mysql -u root -e "SET GLOBAL character_set_server = 'utf8mb4'"
|
||||||
|
- mysql -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'"
|
||||||
|
|
||||||
|
- mysql -u root -e "CREATE DATABASE test_frappe"
|
||||||
|
- mysql -u root -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'"
|
||||||
|
- mysql -u root -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'"
|
||||||
|
|
||||||
|
- mysql -u root -e "UPDATE mysql.user SET Password=PASSWORD('travis') WHERE User='root'"
|
||||||
|
- mysql -u root -e "FLUSH PRIVILEGES"
|
||||||
|
|
||||||
|
- wget -O /tmp/wkhtmltox.tar.xz https://github.com/frappe/wkhtmltopdf/raw/master/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
|
||||||
|
- tar -xf /tmp/wkhtmltox.tar.xz -C /tmp
|
||||||
|
- sudo mv /tmp/wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
|
||||||
|
- sudo chmod o+x /usr/local/bin/wkhtmltopdf
|
||||||
|
|
||||||
- cd ~/frappe-bench
|
- cd ~/frappe-bench
|
||||||
- bench get-app erpnext $TRAVIS_BUILD_DIR
|
|
||||||
- bench use test_site
|
|
||||||
- bench reinstall --mariadb-root-username root --mariadb-root-password travis --yes
|
|
||||||
- bench scheduler disable
|
|
||||||
- sed -i 's/9000/9001/g' sites/common_site_config.json
|
|
||||||
- bench start &
|
|
||||||
- sleep 10
|
|
||||||
|
|
||||||
script:
|
- sed -i 's/watch:/# watch:/g' Procfile
|
||||||
- bash $TRAVIS_BUILD_DIR/travis/run-tests.sh
|
- sed -i 's/schedule:/# schedule:/g' Procfile
|
||||||
|
- sed -i 's/socketio:/# socketio:/g' Procfile
|
||||||
|
- sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile
|
||||||
|
|
||||||
|
- bench get-app erpnext $TRAVIS_BUILD_DIR
|
||||||
|
- bench start &
|
||||||
|
- bench --site test_site reinstall --yes
|
||||||
|
|
||||||
after_script:
|
after_script:
|
||||||
|
- pip install python-coveralls
|
||||||
- coveralls -b apps/erpnext -d ../../sites/.coverage
|
- coveralls -b apps/erpnext -d ../../sites/.coverage
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
"mail_login": "test@example.com",
|
"mail_login": "test@example.com",
|
||||||
"mail_password": "test",
|
"mail_password": "test",
|
||||||
"admin_password": "admin",
|
"admin_password": "admin",
|
||||||
"run_selenium_tests": 1,
|
"root_login": "root",
|
||||||
"root_password": "travis",
|
"root_password": "travis",
|
||||||
"host_name": "http://localhost:8000",
|
"host_name": "http://test_site:8000",
|
||||||
"install_apps": ["erpnext"]
|
"install_apps": ["erpnext"]
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,9 @@ class Account(NestedSet):
|
|||||||
doc.flags.ignore_root_company_validation = True
|
doc.flags.ignore_root_company_validation = True
|
||||||
doc.update({
|
doc.update({
|
||||||
"company": company,
|
"company": company,
|
||||||
"account_currency": None,
|
# parent account's currency should be passed down to child account's curreny
|
||||||
|
# if it is None, it picks it up from default company currency, which might be unintended
|
||||||
|
"account_currency": self.account_currency,
|
||||||
"parent_account": parent_acc_name_map[company]
|
"parent_account": parent_acc_name_map[company]
|
||||||
})
|
})
|
||||||
doc.save()
|
doc.save()
|
||||||
|
|||||||
@@ -20,11 +20,13 @@ test_dependencies = ["Item", "Cost Center", "Payment Term", "Payment Terms Templ
|
|||||||
test_ignore = ["Serial No"]
|
test_ignore = ["Serial No"]
|
||||||
|
|
||||||
class TestPurchaseInvoice(unittest.TestCase):
|
class TestPurchaseInvoice(unittest.TestCase):
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpClass(self):
|
||||||
unlink_payment_on_cancel_of_invoice()
|
unlink_payment_on_cancel_of_invoice()
|
||||||
frappe.db.set_value("Buying Settings", None, "allow_multiple_items", 1)
|
frappe.db.set_value("Buying Settings", None, "allow_multiple_items", 1)
|
||||||
|
|
||||||
def tearDown(self):
|
@classmethod
|
||||||
|
def tearDownClass(self):
|
||||||
unlink_payment_on_cancel_of_invoice(0)
|
unlink_payment_on_cancel_of_invoice(0)
|
||||||
|
|
||||||
def test_gl_entries_without_perpetual_inventory(self):
|
def test_gl_entries_without_perpetual_inventory(self):
|
||||||
@@ -91,6 +93,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
pi_doc = frappe.get_doc('Purchase Invoice', pi_doc.name)
|
pi_doc = frappe.get_doc('Purchase Invoice', pi_doc.name)
|
||||||
|
|
||||||
self.assertRaises(frappe.LinkExistsError, pi_doc.cancel)
|
self.assertRaises(frappe.LinkExistsError, pi_doc.cancel)
|
||||||
|
unlink_payment_on_cancel_of_invoice()
|
||||||
|
|
||||||
def test_purchase_invoice_for_blocked_supplier(self):
|
def test_purchase_invoice_for_blocked_supplier(self):
|
||||||
supplier = frappe.get_doc('Supplier', '_Test Supplier')
|
supplier = frappe.get_doc('Supplier', '_Test Supplier')
|
||||||
|
|||||||
@@ -29,10 +29,12 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
w.submit()
|
w.submit()
|
||||||
return w
|
return w
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpClass(self):
|
||||||
unlink_payment_on_cancel_of_invoice()
|
unlink_payment_on_cancel_of_invoice()
|
||||||
|
|
||||||
def tearDown(self):
|
@classmethod
|
||||||
|
def tearDownClass(self):
|
||||||
unlink_payment_on_cancel_of_invoice(0)
|
unlink_payment_on_cancel_of_invoice(0)
|
||||||
|
|
||||||
def test_timestamp_change(self):
|
def test_timestamp_change(self):
|
||||||
@@ -135,6 +137,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
unlink_payment_on_cancel_of_invoice(0)
|
unlink_payment_on_cancel_of_invoice(0)
|
||||||
si = frappe.get_doc('Sales Invoice', si.name)
|
si = frappe.get_doc('Sales Invoice', si.name)
|
||||||
self.assertRaises(frappe.LinkExistsError, si.cancel)
|
self.assertRaises(frappe.LinkExistsError, si.cancel)
|
||||||
|
unlink_payment_on_cancel_of_invoice()
|
||||||
|
|
||||||
def test_sales_invoice_calculation_export_currency(self):
|
def test_sales_invoice_calculation_export_currency(self):
|
||||||
si = frappe.copy_doc(test_records[2])
|
si = frappe.copy_doc(test_records[2])
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class TestProcurementTracker(unittest.TestCase):
|
|||||||
company_name="_Test Procurement Company",
|
company_name="_Test Procurement Company",
|
||||||
abbr="_TPC",
|
abbr="_TPC",
|
||||||
default_currency="INR",
|
default_currency="INR",
|
||||||
country="India"
|
country="Pakistan"
|
||||||
)).insert()
|
)).insert()
|
||||||
warehouse = create_warehouse("_Test Procurement Warehouse", company="_Test Procurement Company")
|
warehouse = create_warehouse("_Test Procurement Warehouse", company="_Test Procurement Company")
|
||||||
mr = make_material_request(company="_Test Procurement Company", warehouse=warehouse)
|
mr = make_material_request(company="_Test Procurement Company", warehouse=warehouse)
|
||||||
|
|||||||
@@ -92,5 +92,5 @@ def make_company():
|
|||||||
company.abbr = "_TC10"
|
company.abbr = "_TC10"
|
||||||
company.parent_company = "_Test Company"
|
company.parent_company = "_Test Company"
|
||||||
company.default_currency = "INR"
|
company.default_currency = "INR"
|
||||||
company.country = "India"
|
company.country = "Pakistan"
|
||||||
company.insert()
|
company.insert()
|
||||||
@@ -327,7 +327,8 @@ class StockReconciliation(StockController):
|
|||||||
|
|
||||||
if sl_entries:
|
if sl_entries:
|
||||||
sl_entries.reverse()
|
sl_entries.reverse()
|
||||||
self.make_sl_entries(sl_entries)
|
allow_negative_stock = frappe.db.get_value("Stock Settings", None, "allow_negative_stock")
|
||||||
|
self.make_sl_entries(sl_entries, allow_negative_stock=allow_negative_stock)
|
||||||
|
|
||||||
# repost future entries for selected item_code, warehouse
|
# repost future entries for selected item_code, warehouse
|
||||||
for entries in existing_entries:
|
for entries in existing_entries:
|
||||||
|
|||||||
@@ -17,10 +17,11 @@ from erpnext.stock.utils import get_stock_balance, get_incoming_rate, get_availa
|
|||||||
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
|
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
|
||||||
|
|
||||||
class TestStockReconciliation(unittest.TestCase):
|
class TestStockReconciliation(unittest.TestCase):
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpClass(self):
|
||||||
create_batch_or_serial_no_items()
|
create_batch_or_serial_no_items()
|
||||||
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
|
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
|
||||||
self.insert_existing_sle()
|
insert_existing_sle()
|
||||||
|
|
||||||
def test_reco_for_fifo(self):
|
def test_reco_for_fifo(self):
|
||||||
self._test_reco_sle_gle("FIFO")
|
self._test_reco_sle_gle("FIFO")
|
||||||
@@ -97,18 +98,6 @@ class TestStockReconciliation(unittest.TestCase):
|
|||||||
self.assertEqual(["_Test Stock Reco Item", "_Test Warehouse Ledger 1 - _TC", 100],
|
self.assertEqual(["_Test Stock Reco Item", "_Test Warehouse Ledger 1 - _TC", 100],
|
||||||
[items[0]["item_code"], items[0]["warehouse"], items[0]["qty"]])
|
[items[0]["item_code"], items[0]["warehouse"], items[0]["qty"]])
|
||||||
|
|
||||||
def insert_existing_sle(self):
|
|
||||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
|
|
||||||
|
|
||||||
make_stock_entry(posting_date="2012-12-15", posting_time="02:00", item_code="_Test Item",
|
|
||||||
target="_Test Warehouse - _TC", qty=10, basic_rate=700)
|
|
||||||
|
|
||||||
make_stock_entry(posting_date="2012-12-25", posting_time="03:00", item_code="_Test Item",
|
|
||||||
source="_Test Warehouse - _TC", qty=15)
|
|
||||||
|
|
||||||
make_stock_entry(posting_date="2013-01-05", posting_time="07:00", item_code="_Test Item",
|
|
||||||
target="_Test Warehouse - _TC", qty=15, basic_rate=1200)
|
|
||||||
|
|
||||||
def test_stock_reco_for_serialized_item(self):
|
def test_stock_reco_for_serialized_item(self):
|
||||||
set_perpetual_inventory()
|
set_perpetual_inventory()
|
||||||
|
|
||||||
@@ -218,6 +207,18 @@ class TestStockReconciliation(unittest.TestCase):
|
|||||||
for d in to_delete_records:
|
for d in to_delete_records:
|
||||||
frappe.delete_doc("Stock Reconciliation", d)
|
frappe.delete_doc("Stock Reconciliation", d)
|
||||||
|
|
||||||
|
def insert_existing_sle():
|
||||||
|
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
|
||||||
|
|
||||||
|
make_stock_entry(posting_date="2012-12-15", posting_time="02:00", item_code="_Test Item",
|
||||||
|
target="_Test Warehouse - _TC", qty=10, basic_rate=700)
|
||||||
|
|
||||||
|
make_stock_entry(posting_date="2012-12-25", posting_time="03:00", item_code="_Test Item",
|
||||||
|
source="_Test Warehouse - _TC", qty=15)
|
||||||
|
|
||||||
|
make_stock_entry(posting_date="2013-01-05", posting_time="07:00", item_code="_Test Item",
|
||||||
|
target="_Test Warehouse - _TC", qty=15, basic_rate=1200)
|
||||||
|
|
||||||
def create_batch_or_serial_no_items():
|
def create_batch_or_serial_no_items():
|
||||||
create_warehouse("_Test Warehouse for Stock Reco1",
|
create_warehouse("_Test Warehouse for Stock Reco1",
|
||||||
{"is_group": 0, "parent_warehouse": "_Test Warehouse Group - _TC"})
|
{"is_group": 0, "parent_warehouse": "_Test Warehouse Group - _TC"})
|
||||||
|
|||||||
@@ -8,16 +8,7 @@ import unittest
|
|||||||
|
|
||||||
class TestStockSettings(unittest.TestCase):
|
class TestStockSettings(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
settings = frappe.get_single('Stock Settings')
|
frappe.db.set_value("Stock Settings", None, "clean_description_html", 0)
|
||||||
settings.clean_description_html = 0
|
|
||||||
settings.save()
|
|
||||||
|
|
||||||
frappe.delete_doc('Item', 'Item for description test')
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
settings = frappe.get_single('Stock Settings')
|
|
||||||
settings.clean_description_html = 1
|
|
||||||
settings.save()
|
|
||||||
|
|
||||||
def test_settings(self):
|
def test_settings(self):
|
||||||
item = frappe.get_doc(dict(
|
item = frappe.get_doc(dict(
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ frappe.query_reports["Stock Ageing"] = {
|
|||||||
"options": "Brand"
|
"options": "Brand"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"show_ageing_warehouse_wise",
|
"fieldname":"show_warehouse_wise_stock",
|
||||||
"label": __("Show Ageing Warehouse-wise"),
|
"label": __("Show Warehouse-wise Stock"),
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"default": 0
|
"default": 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import frappe
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import date_diff, flt
|
from frappe.utils import date_diff, flt
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
|
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
|
|
||||||
@@ -14,9 +15,9 @@ def execute(filters=None):
|
|||||||
to_date = filters["to_date"]
|
to_date = filters["to_date"]
|
||||||
data = []
|
data = []
|
||||||
for item, item_dict in iteritems(item_details):
|
for item, item_dict in iteritems(item_details):
|
||||||
fifo_queue = item_dict["fifo_queue"]
|
fifo_queue = sorted(item_dict["fifo_queue"], key=lambda x: x[1])
|
||||||
details = item_dict["details"]
|
details = item_dict["details"]
|
||||||
if not fifo_queue: continue
|
if not fifo_queue or (not item_dict.get("total_qty")): continue
|
||||||
|
|
||||||
average_age = get_average_age(fifo_queue, to_date)
|
average_age = get_average_age(fifo_queue, to_date)
|
||||||
earliest_age = date_diff(to_date, fifo_queue[0][1])
|
earliest_age = date_diff(to_date, fifo_queue[0][1])
|
||||||
@@ -25,7 +26,7 @@ def execute(filters=None):
|
|||||||
row = [details.name, details.item_name,
|
row = [details.name, details.item_name,
|
||||||
details.description, details.item_group, details.brand]
|
details.description, details.item_group, details.brand]
|
||||||
|
|
||||||
if filters.get("show_ageing_warehouse_wise"):
|
if filters.get("show_warehouse_wise_stock"):
|
||||||
row.append(details.warehouse)
|
row.append(details.warehouse)
|
||||||
|
|
||||||
row.extend([item_dict.get("total_qty"), average_age,
|
row.extend([item_dict.get("total_qty"), average_age,
|
||||||
@@ -39,48 +40,150 @@ def get_average_age(fifo_queue, to_date):
|
|||||||
batch_age = age_qty = total_qty = 0.0
|
batch_age = age_qty = total_qty = 0.0
|
||||||
for batch in fifo_queue:
|
for batch in fifo_queue:
|
||||||
batch_age = date_diff(to_date, batch[1])
|
batch_age = date_diff(to_date, batch[1])
|
||||||
age_qty += batch_age * batch[0]
|
|
||||||
total_qty += batch[0]
|
if type(batch[0]) in ['int', 'float']:
|
||||||
|
age_qty += batch_age * batch[0]
|
||||||
|
total_qty += batch[0]
|
||||||
|
else:
|
||||||
|
age_qty += batch_age * 1
|
||||||
|
total_qty += 1
|
||||||
|
|
||||||
return (age_qty / total_qty) if total_qty else 0.0
|
return (age_qty / total_qty) if total_qty else 0.0
|
||||||
|
|
||||||
def get_columns(filters):
|
def get_columns(filters):
|
||||||
columns = [_("Item Code") + ":Link/Item:100", _("Item Name") + "::100", _("Description") + "::200",
|
columns = [
|
||||||
_("Item Group") + ":Link/Item Group:100", _("Brand") + ":Link/Brand:100"]
|
{
|
||||||
|
"label": _("Item Code"),
|
||||||
|
"fieldname": "item_code",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Item",
|
||||||
|
"width": 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Item Name"),
|
||||||
|
"fieldname": "item_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"width": 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Description"),
|
||||||
|
"fieldname": "description",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"width": 200
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Item Group"),
|
||||||
|
"fieldname": "item_group",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Item Group",
|
||||||
|
"width": 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Brand"),
|
||||||
|
"fieldname": "brand",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Brand",
|
||||||
|
"width": 100
|
||||||
|
}]
|
||||||
|
|
||||||
if filters.get("show_ageing_warehouse_wise"):
|
if filters.get("show_warehouse_wise_stock"):
|
||||||
columns.extend([_("Warehouse") + ":Link/Warehouse:100"])
|
columns +=[{
|
||||||
|
"label": _("Warehouse"),
|
||||||
|
"fieldname": "warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Warehouse",
|
||||||
|
"width": 100
|
||||||
|
}]
|
||||||
|
|
||||||
columns.extend([_("Available Qty") + ":Float:100", _("Average Age") + ":Float:100",
|
columns.extend([
|
||||||
_("Earliest") + ":Int:80", _("Latest") + ":Int:80", _("UOM") + ":Link/UOM:100"])
|
{
|
||||||
|
"label": _("Available Qty"),
|
||||||
|
"fieldname": "qty",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"width": 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Average Age"),
|
||||||
|
"fieldname": "average_age",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"width": 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Earliest"),
|
||||||
|
"fieldname": "earliest",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"width": 80
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Latest"),
|
||||||
|
"fieldname": "latest",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"width": 80
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("UOM"),
|
||||||
|
"fieldname": "uom",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "UOM",
|
||||||
|
"width": 100
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
return columns
|
return columns
|
||||||
|
|
||||||
def get_fifo_queue(filters):
|
def get_fifo_queue(filters):
|
||||||
item_details = {}
|
item_details = {}
|
||||||
for d in get_stock_ledger_entries(filters):
|
transfered_item_details = {}
|
||||||
key = (d.name, d.warehouse) if filters.get('show_ageing_warehouse_wise') else d.name
|
serial_no_batch_purchase_details = {}
|
||||||
|
|
||||||
|
sle = get_stock_ledger_entries(filters)
|
||||||
|
|
||||||
|
for d in sle:
|
||||||
|
key = (d.name, d.warehouse) if filters.get('show_warehouse_wise_stock') else d.name
|
||||||
item_details.setdefault(key, {"details": d, "fifo_queue": []})
|
item_details.setdefault(key, {"details": d, "fifo_queue": []})
|
||||||
fifo_queue = item_details[key]["fifo_queue"]
|
fifo_queue = item_details[key]["fifo_queue"]
|
||||||
|
|
||||||
|
transfered_item_details.setdefault((d.voucher_no, d.name), [])
|
||||||
|
|
||||||
if d.voucher_type == "Stock Reconciliation":
|
if d.voucher_type == "Stock Reconciliation":
|
||||||
d.actual_qty = flt(d.qty_after_transaction) - flt(item_details[key].get("qty_after_transaction", 0))
|
d.actual_qty = flt(d.qty_after_transaction) - flt(item_details[key].get("qty_after_transaction", 0))
|
||||||
|
|
||||||
|
serial_no_list = get_serial_nos(d.serial_no) if d.serial_no else []
|
||||||
|
|
||||||
if d.actual_qty > 0:
|
if d.actual_qty > 0:
|
||||||
fifo_queue.append([d.actual_qty, d.posting_date])
|
if transfered_item_details.get((d.voucher_no, d.name)):
|
||||||
else:
|
batch = transfered_item_details[(d.voucher_no, d.name)][0]
|
||||||
qty_to_pop = abs(d.actual_qty)
|
fifo_queue.append(batch)
|
||||||
while qty_to_pop:
|
transfered_item_details[((d.voucher_no, d.name))].pop(0)
|
||||||
batch = fifo_queue[0] if fifo_queue else [0, None]
|
else:
|
||||||
if 0 < batch[0] <= qty_to_pop:
|
if serial_no_list:
|
||||||
# if batch qty > 0
|
for serial_no in serial_no_list:
|
||||||
# not enough or exactly same qty in current batch, clear batch
|
if serial_no_batch_purchase_details.get(serial_no):
|
||||||
qty_to_pop -= batch[0]
|
fifo_queue.append([serial_no, serial_no_batch_purchase_details.get(serial_no)])
|
||||||
fifo_queue.pop(0)
|
else:
|
||||||
|
serial_no_batch_purchase_details.setdefault(serial_no, d.posting_date)
|
||||||
|
fifo_queue.append([serial_no, d.posting_date])
|
||||||
else:
|
else:
|
||||||
# all from current batch
|
fifo_queue.append([d.actual_qty, d.posting_date])
|
||||||
batch[0] -= qty_to_pop
|
else:
|
||||||
qty_to_pop = 0
|
if serial_no_list:
|
||||||
|
for serial_no in fifo_queue:
|
||||||
|
if serial_no[0] in serial_no_list:
|
||||||
|
fifo_queue.remove(serial_no)
|
||||||
|
else:
|
||||||
|
qty_to_pop = abs(d.actual_qty)
|
||||||
|
while qty_to_pop:
|
||||||
|
batch = fifo_queue[0] if fifo_queue else [0, None]
|
||||||
|
if 0 < batch[0] <= qty_to_pop:
|
||||||
|
# if batch qty > 0
|
||||||
|
# not enough or exactly same qty in current batch, clear batch
|
||||||
|
qty_to_pop -= batch[0]
|
||||||
|
transfered_item_details[(d.voucher_no, d.name)].append(fifo_queue.pop(0))
|
||||||
|
else:
|
||||||
|
# all from current batch
|
||||||
|
batch[0] -= qty_to_pop
|
||||||
|
transfered_item_details[(d.voucher_no, d.name)].append([qty_to_pop, batch[1]])
|
||||||
|
qty_to_pop = 0
|
||||||
|
|
||||||
item_details[key]["qty_after_transaction"] = d.qty_after_transaction
|
item_details[key]["qty_after_transaction"] = d.qty_after_transaction
|
||||||
|
|
||||||
@@ -94,7 +197,7 @@ def get_fifo_queue(filters):
|
|||||||
def get_stock_ledger_entries(filters):
|
def get_stock_ledger_entries(filters):
|
||||||
return frappe.db.sql("""select
|
return frappe.db.sql("""select
|
||||||
item.name, item.item_name, item_group, brand, description, item.stock_uom,
|
item.name, item.item_name, item_group, brand, description, item.stock_uom,
|
||||||
actual_qty, posting_date, voucher_type, qty_after_transaction, warehouse
|
actual_qty, posting_date, voucher_type, voucher_no, serial_no, batch_no, qty_after_transaction, warehouse
|
||||||
from `tabStock Ledger Entry` sle,
|
from `tabStock Ledger Entry` sle,
|
||||||
(select name, item_name, description, stock_uom, brand, item_group
|
(select name, item_name, description, stock_uom, brand, item_group
|
||||||
from `tabItem` {item_conditions}) item
|
from `tabItem` {item_conditions}) item
|
||||||
@@ -102,7 +205,7 @@ def get_stock_ledger_entries(filters):
|
|||||||
company = %(company)s and
|
company = %(company)s and
|
||||||
posting_date <= %(to_date)s
|
posting_date <= %(to_date)s
|
||||||
{sle_conditions}
|
{sle_conditions}
|
||||||
order by posting_date, posting_time, sle.creation"""\
|
order by posting_date, posting_time, sle.creation, actual_qty""" #nosec
|
||||||
.format(item_conditions=get_item_conditions(filters),
|
.format(item_conditions=get_item_conditions(filters),
|
||||||
sle_conditions=get_sle_conditions(filters)), filters, as_dict=True)
|
sle_conditions=get_sle_conditions(filters)), filters, as_dict=True)
|
||||||
|
|
||||||
|
|||||||
@@ -2,45 +2,31 @@
|
|||||||
# MIT License. See license.txt
|
# MIT License. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from frappe.desk import notifications
|
from frappe.desk import notifications
|
||||||
from frappe.test_runner import make_test_objects
|
from frappe.test_runner import make_test_objects
|
||||||
|
|
||||||
class TestNotifications(unittest.TestCase):
|
class TestNotifications(unittest.TestCase):
|
||||||
def setUp(self):
|
|
||||||
test_records_company = [
|
|
||||||
{
|
|
||||||
"abbr": "_TC6",
|
|
||||||
"company_name": "_Test Company 6",
|
|
||||||
"country": "India",
|
|
||||||
"default_currency": "INR",
|
|
||||||
"doctype": "Company",
|
|
||||||
"domain": "Manufacturing",
|
|
||||||
"monthly_sales_target": 2000,
|
|
||||||
"chart_of_accounts": "Standard"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"abbr": "_TC7",
|
|
||||||
"company_name": "_Test Company 7",
|
|
||||||
"country": "United States",
|
|
||||||
"default_currency": "USD",
|
|
||||||
"doctype": "Company",
|
|
||||||
"domain": "Retail",
|
|
||||||
"monthly_sales_target": 10000,
|
|
||||||
"total_monthly_sales": 1000,
|
|
||||||
"chart_of_accounts": "Standard"
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
make_test_objects('Company', test_records=test_records_company, reset=True)
|
|
||||||
|
|
||||||
def test_get_notifications_for_targets(self):
|
def test_get_notifications_for_targets(self):
|
||||||
'''
|
'''
|
||||||
Test notification config entries for targets as percentages
|
Test notification config entries for targets as percentages
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
company = frappe.get_all("Company")[0]
|
||||||
|
frappe.db.set_value("Company", company.name, "monthly_sales_target", 10000)
|
||||||
|
frappe.db.set_value("Company", company.name, "total_monthly_sales", 1000)
|
||||||
|
|
||||||
config = notifications.get_notification_config()
|
config = notifications.get_notification_config()
|
||||||
doc_target_percents = notifications.get_notifications_for_targets(config, {})
|
doc_target_percents = notifications.get_notifications_for_targets(config, {})
|
||||||
self.assertEqual(doc_target_percents['Company']['_Test Company 7'], 10)
|
|
||||||
self.assertEqual(doc_target_percents['Company']['_Test Company 6'], 0)
|
self.assertEqual(doc_target_percents['Company'][company.name], 10)
|
||||||
|
|
||||||
|
frappe.db.set_value("Company", company.name, "monthly_sales_target", 2000)
|
||||||
|
frappe.db.set_value("Company", company.name, "total_monthly_sales", 0)
|
||||||
|
|
||||||
|
config = notifications.get_notification_config()
|
||||||
|
doc_target_percents = notifications.get_notifications_for_targets(config, {})
|
||||||
|
|
||||||
|
self.assertEqual(doc_target_percents['Company'][company.name], 0)
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
erpnext
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cd ~/
|
|
||||||
curl -I https://github.com/frappe/frappe/tree/$TRAVIS_BRANCH | head -n 1 | cut -d $' ' -f2 | (
|
|
||||||
read response;
|
|
||||||
[ $response == '200' ] && branch=$TRAVIS_BRANCH || branch='develop';
|
|
||||||
bench init frappe-bench --frappe-path https://github.com/frappe/frappe.git --frappe-branch $branch --python $(which python)
|
|
||||||
)
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [[ $TEST_TYPE == 'Server Side Test' ]]; then
|
|
||||||
bench run-tests --app erpnext --coverage
|
|
||||||
|
|
||||||
elif [[ $TEST_TYPE == 'Patch Test' ]]; then
|
|
||||||
wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz
|
|
||||||
bench --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz --mariadb-root-password travis
|
|
||||||
bench migrate
|
|
||||||
fi
|
|
||||||
Reference in New Issue
Block a user