mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-28 05:18:34 +00:00
Compare commits
176 Commits
v12.23.0
...
v12-pre-re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ad2684121 | ||
|
|
1413af8f3a | ||
|
|
9a1afeb13b | ||
|
|
13a9b304b7 | ||
|
|
ee7ac93ff3 | ||
|
|
3aa4411a0d | ||
|
|
7db947550b | ||
|
|
c74a6f1827 | ||
|
|
73243c8ac3 | ||
|
|
1800ce2780 | ||
|
|
e5ea16a6dd | ||
|
|
54cb62c7bf | ||
|
|
11ad77f491 | ||
|
|
95b0c743d4 | ||
|
|
fee83e8ba4 | ||
|
|
4c5b5607ba | ||
|
|
00b40c0f3c | ||
|
|
ac08379f2b | ||
|
|
753adf3ce4 | ||
|
|
fbbf29e829 | ||
|
|
ce2aa767b2 | ||
|
|
c9927efcae | ||
|
|
e9dbb46a06 | ||
|
|
39125a78e0 | ||
|
|
2a00164059 | ||
|
|
7d1953bb3b | ||
|
|
33eeb64fec | ||
|
|
bbffb5d91e | ||
|
|
260b9c1885 | ||
|
|
034e8bd028 | ||
|
|
eb8b03f590 | ||
|
|
abb4d99ca8 | ||
|
|
a6fd5a69e8 | ||
|
|
849c795113 | ||
|
|
3647a24f60 | ||
|
|
67f17c7a0c | ||
|
|
24c004b537 | ||
|
|
1fce25180c | ||
|
|
23946cea2e | ||
|
|
1b78c501a1 | ||
|
|
d09ed0a578 | ||
|
|
9b83e3856a | ||
|
|
656686f2b1 | ||
|
|
8e7ee953c1 | ||
|
|
d2af2b31e5 | ||
|
|
f79651c54d | ||
|
|
80ba0cf978 | ||
|
|
30c1a7bb20 | ||
|
|
d119b4321d | ||
|
|
4b1befb691 | ||
|
|
fa5e018330 | ||
|
|
8c84d6a1d9 | ||
|
|
f76139dceb | ||
|
|
97544e2bbc | ||
|
|
117718d410 | ||
|
|
bcb0683be1 | ||
|
|
bf5f0a226e | ||
|
|
55aaefb53c | ||
|
|
52ed3c219b | ||
|
|
1e378cfde0 | ||
|
|
29f5d434d8 | ||
|
|
aa0e21e84b | ||
|
|
34bf2004bb | ||
|
|
7ac656d737 | ||
|
|
ba537b0b93 | ||
|
|
89b0e5023a | ||
|
|
a0e4708470 | ||
|
|
e60d7ac09e | ||
|
|
d6555e8632 | ||
|
|
14602178e7 | ||
|
|
5f2819c9b1 | ||
|
|
5bc7d63646 | ||
|
|
94162e0139 | ||
|
|
e2e751e26f | ||
|
|
70244cee89 | ||
|
|
ae6e69ebd4 | ||
|
|
6fdf4dd03e | ||
|
|
4aede0ea3f | ||
|
|
de660bf9c4 | ||
|
|
391bf86e0a | ||
|
|
452c613974 | ||
|
|
dd7b02ad7d | ||
|
|
7cc02bf861 | ||
|
|
678960209c | ||
|
|
e4995dc9ed | ||
|
|
7cf5dc7dab | ||
|
|
e676a09c18 | ||
|
|
6431243ce3 | ||
|
|
49f93b347c | ||
|
|
27e9e47ba8 | ||
|
|
c9f51d3cec | ||
|
|
9ae3f26dbf | ||
|
|
ad736f1789 | ||
|
|
16ece12516 | ||
|
|
c9e75d2ab5 | ||
|
|
985fdade7e | ||
|
|
10c34da174 | ||
|
|
d1480be596 | ||
|
|
93a744dc12 | ||
|
|
a2b98bb80c | ||
|
|
4fdff12242 | ||
|
|
9c9cde48ad | ||
|
|
999a3f1305 | ||
|
|
8139672c7a | ||
|
|
7169a4c113 | ||
|
|
bc960ab35f | ||
|
|
f9e9c5f637 | ||
|
|
fbc8fb36dd | ||
|
|
6359e69503 | ||
|
|
1d68d12b7a | ||
|
|
b7a74aa578 | ||
|
|
efddcbe42e | ||
|
|
6f6e390863 | ||
|
|
7843c3d51a | ||
|
|
8871bd4bfb | ||
|
|
d0a7141e35 | ||
|
|
6fe28e83e2 | ||
|
|
abf353a286 | ||
|
|
cef6a8434a | ||
|
|
dc76094a9f | ||
|
|
1e428f9531 | ||
|
|
710c1c1786 | ||
|
|
aa358b021e | ||
|
|
8bc37da20d | ||
|
|
914709099f | ||
|
|
87dddbe868 | ||
|
|
ca42b16d3a | ||
|
|
73666982c7 | ||
|
|
48bd1965e4 | ||
|
|
ab84579b0e | ||
|
|
8064792b8c | ||
|
|
fe6c96cab9 | ||
|
|
d5e89d98c2 | ||
|
|
f8fa3860d9 | ||
|
|
d8a7abcd02 | ||
|
|
5bb9de8614 | ||
|
|
0fd50e0426 | ||
|
|
bdfc300896 | ||
|
|
14292456cf | ||
|
|
24d67c35b7 | ||
|
|
8d71fcb948 | ||
|
|
2945e604aa | ||
|
|
ea085b3a76 | ||
|
|
611966c139 | ||
|
|
d650b55f52 | ||
|
|
8eca908365 | ||
|
|
09d5ddc42b | ||
|
|
abd53b114c | ||
|
|
b1e932a6f8 | ||
|
|
e6a3e6beb7 | ||
|
|
239974c73e | ||
|
|
27ecb54b8c | ||
|
|
6b4b80a4a4 | ||
|
|
68225bbcad | ||
|
|
b549287b94 | ||
|
|
12c3e5dfd6 | ||
|
|
c908add82e | ||
|
|
c74f0f3530 | ||
|
|
2e5a358e96 | ||
|
|
01f8833bd1 | ||
|
|
c5a0c22352 | ||
|
|
b22cbb3122 | ||
|
|
f4a9e52cbe | ||
|
|
24e1786e49 | ||
|
|
5399891b25 | ||
|
|
1b8670b263 | ||
|
|
371d124a0e | ||
|
|
3302ed4658 | ||
|
|
5271ce36de | ||
|
|
88bab1e3ad | ||
|
|
6ec804d77f | ||
|
|
5cced71ce4 | ||
|
|
aea8773503 | ||
|
|
a0cfe449df | ||
|
|
b135569ca6 | ||
|
|
266f24bb74 |
26
.github/workflows/backport.yml
vendored
Normal file
26
.github/workflows/backport.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
name: Backport
|
||||
on:
|
||||
pull_request_target:
|
||||
types:
|
||||
- closed
|
||||
- labeled
|
||||
|
||||
jobs:
|
||||
main:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- name: Checkout Actions
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: "frappe/backport"
|
||||
path: ./actions
|
||||
ref: develop
|
||||
- name: Install Actions
|
||||
run: npm install --production --prefix ./actions
|
||||
- name: Run backport
|
||||
uses: ./actions/backport
|
||||
with:
|
||||
token: ${{secrets.BACKPORT_BOT_TOKEN}}
|
||||
labelsToAdd: "backport"
|
||||
title: "{{originalTitle}}"
|
||||
@@ -5,7 +5,7 @@ import frappe
|
||||
from erpnext.hooks import regional_overrides
|
||||
from frappe.utils import getdate
|
||||
|
||||
__version__ = '12.23.0'
|
||||
__version__ = '12.29.0'
|
||||
|
||||
def get_default_company(user=None):
|
||||
'''Get default company for user'''
|
||||
|
||||
@@ -271,6 +271,7 @@
|
||||
"label": "Debit",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "currency",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
@@ -304,6 +305,7 @@
|
||||
"label": "Credit",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "currency",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
@@ -632,6 +634,7 @@
|
||||
"label": "Allocated Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "currency",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
@@ -731,6 +734,7 @@
|
||||
"label": "Unallocated Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "currency",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
@@ -755,7 +759,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2019-05-11 05:27:55.244721",
|
||||
"modified": "2021-11-26 12:44:55.244721",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Bank Transaction",
|
||||
|
||||
@@ -81,10 +81,11 @@ class ExchangeRateRevaluation(Document):
|
||||
sum(debit) - sum(credit) as balance
|
||||
from `tabGL Entry`
|
||||
where account in (%s)
|
||||
group by account, party_type, party
|
||||
and posting_date <= %s
|
||||
group by account, NULLIF(party_type,''), NULLIF(party,'')
|
||||
having sum(debit) != sum(credit)
|
||||
order by account
|
||||
""" % ', '.join(['%s']*len(accounts)), tuple(accounts), as_dict=1)
|
||||
""" % (', '.join(['%s']*len(accounts)), '%s'), tuple(accounts + [self.posting_date]), as_dict=1)
|
||||
|
||||
return account_details
|
||||
|
||||
@@ -124,9 +125,9 @@ class ExchangeRateRevaluation(Document):
|
||||
"party_type": d.get("party_type"),
|
||||
"party": d.get("party"),
|
||||
"account_currency": d.get("account_currency"),
|
||||
"balance": d.get("balance_in_account_currency"),
|
||||
dr_or_cr: abs(d.get("balance_in_account_currency")),
|
||||
"exchange_rate":d.get("new_exchange_rate"),
|
||||
"balance": flt(d.get("balance_in_account_currency"), d.precision("balance_in_account_currency")),
|
||||
dr_or_cr: flt(abs(d.get("balance_in_account_currency")), d.precision("balance_in_account_currency")),
|
||||
"exchange_rate": flt(d.get("new_exchange_rate"), d.precision("new_exchange_rate")),
|
||||
"reference_type": "Exchange Rate Revaluation",
|
||||
"reference_name": self.name,
|
||||
})
|
||||
@@ -135,9 +136,9 @@ class ExchangeRateRevaluation(Document):
|
||||
"party_type": d.get("party_type"),
|
||||
"party": d.get("party"),
|
||||
"account_currency": d.get("account_currency"),
|
||||
"balance": d.get("balance_in_account_currency"),
|
||||
reverse_dr_or_cr: abs(d.get("balance_in_account_currency")),
|
||||
"exchange_rate": d.get("current_exchange_rate"),
|
||||
"balance": flt(d.get("balance_in_account_currency"), d.precision("balance_in_account_currency")),
|
||||
reverse_dr_or_cr: flt(abs(d.get("balance_in_account_currency")), d.precision("balance_in_account_currency")),
|
||||
"exchange_rate": flt(d.get("current_exchange_rate"), d.precision("current_exchange_rate")),
|
||||
"reference_type": "Exchange Rate Revaluation",
|
||||
"reference_name": self.name
|
||||
})
|
||||
@@ -166,9 +167,9 @@ def get_account_details(account, company, posting_date, party_type=None, party=N
|
||||
|
||||
account_details = {}
|
||||
company_currency = erpnext.get_company_currency(company)
|
||||
balance = get_balance_on(account, party_type=party_type, party=party, in_account_currency=False)
|
||||
balance = get_balance_on(account, date=posting_date, party_type=party_type, party=party, in_account_currency=False)
|
||||
if balance:
|
||||
balance_in_account_currency = get_balance_on(account, party_type=party_type, party=party)
|
||||
balance_in_account_currency = get_balance_on(account, date=posting_date, party_type=party_type, party=party)
|
||||
current_exchange_rate = balance / balance_in_account_currency if balance_in_account_currency else 0
|
||||
new_exchange_rate = get_exchange_rate(account_currency, company_currency, posting_date)
|
||||
new_balance_in_base_currency = balance_in_account_currency * new_exchange_rate
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe, unittest
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
from frappe.utils import now_datetime
|
||||
|
||||
from erpnext.accounts.doctype.fiscal_year.fiscal_year import FiscalYearIncorrectDate
|
||||
|
||||
test_records = frappe.get_test_records('Fiscal Year')
|
||||
test_ignore = ["Company"]
|
||||
|
||||
class TestFiscalYear(unittest.TestCase):
|
||||
@@ -23,3 +25,29 @@ class TestFiscalYear(unittest.TestCase):
|
||||
})
|
||||
|
||||
self.assertRaises(FiscalYearIncorrectDate, fy.insert)
|
||||
|
||||
|
||||
def test_record_generator():
|
||||
test_records = [
|
||||
{
|
||||
"doctype": "Fiscal Year",
|
||||
"year": "_Test Short Fiscal Year 2011",
|
||||
"is_short_year": 1,
|
||||
"year_end_date": "2011-04-01",
|
||||
"year_start_date": "2011-12-31"
|
||||
}
|
||||
]
|
||||
|
||||
start = 2012
|
||||
end = now_datetime().year + 5
|
||||
for year in range(start, end):
|
||||
test_records.append({
|
||||
"doctype": "Fiscal Year",
|
||||
"year": "_Test Fiscal Year {}".format(year),
|
||||
"year_start_date": "{}-01-01".format(year),
|
||||
"year_end_date": "{}-12-31".format(year)
|
||||
})
|
||||
|
||||
return test_records
|
||||
|
||||
test_records = test_record_generator()
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
[
|
||||
{
|
||||
"doctype": "Fiscal Year",
|
||||
"year": "_Test Fiscal Year 2012",
|
||||
"year_end_date": "2012-12-31",
|
||||
"year_start_date": "2012-01-01"
|
||||
},
|
||||
{
|
||||
"doctype": "Fiscal Year",
|
||||
"year": "_Test Fiscal Year 2013",
|
||||
"year_end_date": "2013-12-31",
|
||||
"year_start_date": "2013-01-01"
|
||||
},
|
||||
{
|
||||
"doctype": "Fiscal Year",
|
||||
"year": "_Test Fiscal Year 2014",
|
||||
"year_end_date": "2014-12-31",
|
||||
"year_start_date": "2014-01-01"
|
||||
},
|
||||
{
|
||||
"doctype": "Fiscal Year",
|
||||
"year": "_Test Fiscal Year 2015",
|
||||
"year_end_date": "2015-12-31",
|
||||
"year_start_date": "2015-01-01"
|
||||
},
|
||||
{
|
||||
"doctype": "Fiscal Year",
|
||||
"year": "_Test Fiscal Year 2016",
|
||||
"year_end_date": "2016-12-31",
|
||||
"year_start_date": "2016-01-01"
|
||||
},
|
||||
{
|
||||
"doctype": "Fiscal Year",
|
||||
"year": "_Test Fiscal Year 2017",
|
||||
"year_end_date": "2017-12-31",
|
||||
"year_start_date": "2017-01-01"
|
||||
},
|
||||
{
|
||||
"doctype": "Fiscal Year",
|
||||
"year": "_Test Fiscal Year 2018",
|
||||
"year_end_date": "2018-12-31",
|
||||
"year_start_date": "2018-01-01"
|
||||
},
|
||||
{
|
||||
"doctype": "Fiscal Year",
|
||||
"year": "_Test Fiscal Year 2019",
|
||||
"year_end_date": "2019-12-31",
|
||||
"year_start_date": "2019-01-01"
|
||||
},
|
||||
{
|
||||
"doctype": "Fiscal Year",
|
||||
"year": "_Test Fiscal Year 2020",
|
||||
"year_end_date": "2020-12-31",
|
||||
"year_start_date": "2020-01-01"
|
||||
},
|
||||
{
|
||||
"doctype": "Fiscal Year",
|
||||
"year": "_Test Fiscal Year 2021",
|
||||
"year_end_date": "2021-12-31",
|
||||
"year_start_date": "2021-01-01"
|
||||
},
|
||||
{
|
||||
"doctype": "Fiscal Year",
|
||||
"year": "_Test Short Fiscal Year 2021",
|
||||
"is_short_year": 1,
|
||||
"year_end_date": "2021-12-31",
|
||||
"year_start_date": "2021-04-01"
|
||||
}
|
||||
]
|
||||
@@ -593,12 +593,22 @@ frappe.ui.form.on('Payment Entry', {
|
||||
{fieldtype:"Column Break"},
|
||||
{fieldtype:"Float", label: __("Less Than Amount"), fieldname:"outstanding_amt_less_than"},
|
||||
{fieldtype:"Section Break"},
|
||||
{fieldtype:"Link", label:__("Cost Center"), fieldname:"cost_center", options:"Cost Center",
|
||||
"get_query": function() {
|
||||
return {
|
||||
"filters": {"company": frm.doc.company}
|
||||
}
|
||||
}
|
||||
},
|
||||
{fieldtype:"Column Break"},
|
||||
{fieldtype:"Section Break"},
|
||||
{fieldtype:"Check", label: __("Allocate Payment Amount"), fieldname:"allocate_payment_amount", default:1},
|
||||
];
|
||||
|
||||
frappe.prompt(fields, function(filters){
|
||||
frappe.flags.allocate_payment_amount = true;
|
||||
frm.events.validate_filters_data(frm, filters);
|
||||
frm.doc.cost_center = filters.cost_center;
|
||||
frm.events.get_outstanding_documents(frm, filters);
|
||||
}, __("Filters"), __("Get Outstanding Documents"));
|
||||
},
|
||||
@@ -1041,18 +1051,10 @@ frappe.ui.form.on('Payment Entry', {
|
||||
},
|
||||
callback: function(r, rt) {
|
||||
if(r.message) {
|
||||
frappe.run_serially([
|
||||
() => {
|
||||
|
||||
frm.set_value("paid_from_account_balance", r.message.paid_from_account_balance);
|
||||
frm.set_value("paid_to_account_balance", r.message.paid_to_account_balance);
|
||||
frm.set_value("party_balance", r.message.party_balance);
|
||||
},
|
||||
() => {
|
||||
if(frm.doc.payment_type != "Internal") {
|
||||
frm.clear_table("references");
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,13 +330,17 @@ def get_pricing_rule_details(args, pricing_rule):
|
||||
def apply_price_discount_rule(pricing_rule, item_details, args):
|
||||
item_details.pricing_rule_for = pricing_rule.rate_or_discount
|
||||
|
||||
if ((pricing_rule.margin_type == 'Amount' and pricing_rule.currency == args.currency)
|
||||
or (pricing_rule.margin_type == 'Percentage')):
|
||||
item_details.margin_type = pricing_rule.margin_type
|
||||
item_details.margin_rate_or_amount = pricing_rule.margin_rate_or_amount
|
||||
else:
|
||||
item_details.margin_type = None
|
||||
item_details.margin_rate_or_amount = 0.0
|
||||
for apply_on in ['Percentage', 'Amount']:
|
||||
if pricing_rule.margin_type != apply_on:
|
||||
continue
|
||||
|
||||
field = 'margin_rate_or_amount'
|
||||
if field not in item_details:
|
||||
item_details.setdefault(field, 0)
|
||||
item_details.setdefault('margin_type', apply_on)
|
||||
|
||||
item_details[field] += (pricing_rule.get(field, 0)
|
||||
if pricing_rule else args.get(field, 0))
|
||||
|
||||
if pricing_rule.rate_or_discount == 'Rate':
|
||||
pricing_rule_rate = 0.0
|
||||
|
||||
@@ -247,8 +247,15 @@ class PurchaseInvoice(BuyingController):
|
||||
else:
|
||||
item.expense_account = stock_not_billed_account
|
||||
elif item.is_fixed_asset and not is_cwip_accounting_enabled(asset_category):
|
||||
item.expense_account = get_asset_category_account('fixed_asset_account', item=item.item_code,
|
||||
asset_category_account = get_asset_category_account('fixed_asset_account', item=item.item_code,
|
||||
company = self.company)
|
||||
if not asset_category_account:
|
||||
form_link = get_link_to_form('Asset Category', asset_category)
|
||||
throw(
|
||||
_("Please set Fixed Asset Account in {} against {}.").format(form_link, self.company),
|
||||
title=_("Missing Account")
|
||||
)
|
||||
item.expense_account = asset_category_account
|
||||
elif item.is_fixed_asset and item.pr_detail:
|
||||
item.expense_account = asset_received_but_not_billed
|
||||
elif not item.expense_account and for_validate:
|
||||
|
||||
@@ -825,45 +825,43 @@ frappe.ui.form.on('Sales Invoice', {
|
||||
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.create_invoice_discounting",
|
||||
frm: frm
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
frappe.ui.form.on('Sales Invoice Timesheet', {
|
||||
calculate_timesheet_totals: function(frm) {
|
||||
frm.set_value("total_billing_amount",
|
||||
frm.doc.timesheets.reduce((a, b) => a + (b["billing_amount"] || 0.0), 0.0));
|
||||
frm.set_value("total_billing_hours",
|
||||
frm.doc.timesheets.reduce((a, b) => a + (b["billing_hours"] || 0.0), 0.0));
|
||||
}
|
||||
});
|
||||
|
||||
frappe.ui.form.on("Sales Invoice Timesheet", {
|
||||
time_sheet: function(frm, cdt, cdn){
|
||||
var d = locals[cdt][cdn];
|
||||
if(d.time_sheet) {
|
||||
frappe.call({
|
||||
method: "erpnext.projects.doctype.timesheet.timesheet.get_timesheet_data",
|
||||
args: {
|
||||
'name': d.time_sheet,
|
||||
'project': frm.doc.project || null
|
||||
"name": d.time_sheet,
|
||||
"project": frm.doc.project || null
|
||||
},
|
||||
callback: function(r, rt) {
|
||||
callback: function(r) {
|
||||
if(r.message){
|
||||
data = r.message;
|
||||
frappe.model.set_value(cdt, cdn, "billing_hours", data.billing_hours);
|
||||
frappe.model.set_value(cdt, cdn, "billing_amount", data.billing_amount);
|
||||
frappe.model.set_value(cdt, cdn, "timesheet_detail", data.timesheet_detail);
|
||||
calculate_total_billing_amount(frm)
|
||||
frappe.model.set_value(cdt, cdn, "billing_hours", r.message.billing_hours);
|
||||
frappe.model.set_value(cdt, cdn, "billing_amount", r.message.billing_amount);
|
||||
frappe.model.set_value(cdt, cdn, "timesheet_detail", r.message.timesheet_detail);
|
||||
frm.trigger("calculate_timesheet_totals");
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
timesheets_remove: function(frm, cdt, cdn) {
|
||||
frm.trigger("calculate_timesheet_totals");
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
var calculate_total_billing_amount = function(frm) {
|
||||
var doc = frm.doc;
|
||||
|
||||
doc.total_billing_amount = 0.0
|
||||
if(doc.timesheets) {
|
||||
$.each(doc.timesheets, function(index, data){
|
||||
doc.total_billing_amount += data.billing_amount
|
||||
})
|
||||
}
|
||||
|
||||
refresh_field('total_billing_amount')
|
||||
}
|
||||
|
||||
var select_loyalty_program = function(frm, loyalty_programs) {
|
||||
var dialog = new frappe.ui.Dialog({
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
"time_sheet_list",
|
||||
"timesheets",
|
||||
"total_billing_amount",
|
||||
"total_billing_hours",
|
||||
"section_break_30",
|
||||
"total_qty",
|
||||
"base_total",
|
||||
@@ -1564,12 +1565,20 @@
|
||||
{
|
||||
"fieldname": "dimension_col_break",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "total_billing_hours",
|
||||
"fieldtype": "Float",
|
||||
"label": "Total Billing Hours",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-file-text",
|
||||
"idx": 181,
|
||||
"is_submittable": 1,
|
||||
"modified": "2020-07-01 12:41:29.484813",
|
||||
"modified": "2021-07-26 14:01:34.605644",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Sales Invoice",
|
||||
|
||||
@@ -683,12 +683,11 @@ class SalesInvoice(SellingController):
|
||||
self.calculate_billing_amount_for_timesheet()
|
||||
|
||||
def calculate_billing_amount_for_timesheet(self):
|
||||
total_billing_amount = 0.0
|
||||
for data in self.timesheets:
|
||||
if data.billing_amount:
|
||||
total_billing_amount += data.billing_amount
|
||||
def timesheet_sum(field):
|
||||
return sum((ts.get(field) or 0.0) for ts in self.timesheets)
|
||||
|
||||
self.total_billing_amount = total_billing_amount
|
||||
self.total_billing_amount = timesheet_sum("billing_amount")
|
||||
self.total_billing_hours = timesheet_sum("billing_hours")
|
||||
|
||||
def get_warehouse(self):
|
||||
user_pos_profile = frappe.db.sql("""select name, warehouse from `tabPOS Profile`
|
||||
|
||||
@@ -288,6 +288,7 @@ class Subscription(Document):
|
||||
invoice.to_date = self.current_invoice_end
|
||||
|
||||
invoice.flags.ignore_mandatory = True
|
||||
invoice.set_missing_values()
|
||||
invoice.save()
|
||||
|
||||
if self.submit_invoice:
|
||||
|
||||
@@ -147,7 +147,7 @@ def make_entry(args, adv_adj, update_outstanding, from_repost=False):
|
||||
gle.submit()
|
||||
|
||||
def validate_account_for_perpetual_inventory(gl_map):
|
||||
if cint(erpnext.is_perpetual_inventory_enabled(gl_map[0].company)):
|
||||
if cint(erpnext.is_perpetual_inventory_enabled(gl_map[0].company)) and gl_map[0].voucher_type=="Journal Entry":
|
||||
account_list = [gl_entries.account for gl_entries in gl_map]
|
||||
|
||||
aii_accounts = [d.name for d in frappe.get_all("Account",
|
||||
@@ -160,13 +160,12 @@ def validate_account_for_perpetual_inventory(gl_map):
|
||||
account_bal, stock_bal, warehouse_list = get_stock_and_account_balance(account,
|
||||
gl_map[0].posting_date, gl_map[0].company)
|
||||
|
||||
if gl_map[0].voucher_type=="Journal Entry":
|
||||
# In case of Journal Entry, there are no corresponding SL entries,
|
||||
# hence deducting currency amount
|
||||
account_bal -= flt(gl_map[0].debit) - flt(gl_map[0].credit)
|
||||
if account_bal == stock_bal:
|
||||
frappe.throw(_("Account: {0} can only be updated via Stock Transactions")
|
||||
.format(account), StockAccountInvalidTransaction)
|
||||
# In case of Journal Entry, there are no corresponding SL entries,
|
||||
# hence deducting currency amount
|
||||
account_bal -= flt(gl_map[0].debit) - flt(gl_map[0].credit)
|
||||
if account_bal == stock_bal:
|
||||
frappe.throw(_("Account: {0} can only be updated via Stock Transactions")
|
||||
.format(account), StockAccountInvalidTransaction)
|
||||
|
||||
# This has been comment for a temporary, will add this code again on release of immutable ledger
|
||||
# elif account_bal != stock_bal:
|
||||
@@ -294,7 +293,8 @@ def delete_gl_entries(gl_entries=None, voucher_type=None, voucher_no=None,
|
||||
select account, posting_date, party_type, party, cost_center, fiscal_year,voucher_type,
|
||||
voucher_no, against_voucher_type, against_voucher, cost_center, company
|
||||
from `tabGL Entry`
|
||||
where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no), as_dict=True)
|
||||
where voucher_type=%s and voucher_no=%s
|
||||
for update""", (voucher_type, voucher_no), as_dict=True)
|
||||
|
||||
if gl_entries:
|
||||
validate_accounting_period(gl_entries)
|
||||
|
||||
@@ -49,7 +49,10 @@ class TestAccountBalance(unittest.TestCase):
|
||||
},
|
||||
]
|
||||
|
||||
self.assertEqual(expected_data, report[1])
|
||||
expected_data = sorted(expected_data, key=lambda k:k['account'])
|
||||
output = sorted(report[1], key=lambda k:k['account'])
|
||||
|
||||
self.assertEqual(expected_data, output)
|
||||
|
||||
def make_sales_invoice():
|
||||
frappe.set_user("Administrator")
|
||||
|
||||
@@ -36,5 +36,20 @@ frappe.query_reports["Gross Profit"] = {
|
||||
"options": "Invoice\nItem Code\nItem Group\nBrand\nWarehouse\nCustomer\nCustomer Group\nTerritory\nSales Person\nProject",
|
||||
"default": "Invoice"
|
||||
},
|
||||
]
|
||||
],
|
||||
"tree": true,
|
||||
"name_field": "parent",
|
||||
"parent_field": "parent_invoice",
|
||||
"initial_depth": 3,
|
||||
"formatter": function(value, row, column, data, default_formatter) {
|
||||
value = default_formatter(value, row, column, data);
|
||||
|
||||
if (data && data.indent == 0.0) {
|
||||
value = $(`<span>${value}</span>`);
|
||||
var $value = $(value).css("font-weight", "bold");
|
||||
value = $value.wrap("<p></p>").parent().html();
|
||||
}
|
||||
|
||||
return value;
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
{
|
||||
"add_total_row": 1,
|
||||
"add_total_row": 0,
|
||||
"columns": [],
|
||||
"creation": "2013-02-25 17:03:34",
|
||||
"disable_prepared_report": 0,
|
||||
"disabled": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "Report",
|
||||
"filters": [],
|
||||
"idx": 3,
|
||||
"is_standard": "Yes",
|
||||
"modified": "2020-08-13 11:26:39.112352",
|
||||
"modified": "2021-08-19 18:57:07.468202",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Gross Profit",
|
||||
"owner": "Administrator",
|
||||
"prepared_report": 0,
|
||||
"ref_doctype": "Sales Invoice",
|
||||
"report_name": "Gross Profit",
|
||||
"report_type": "Script Report",
|
||||
|
||||
@@ -41,16 +41,44 @@ def execute(filters=None):
|
||||
|
||||
columns = get_columns(group_wise_columns, filters)
|
||||
|
||||
for src in gross_profit_data.grouped_data:
|
||||
if filters.group_by == 'Invoice':
|
||||
get_data_when_grouped_by_invoice(columns, gross_profit_data, filters, group_wise_columns, data)
|
||||
|
||||
else:
|
||||
get_data_when_not_grouped_by_invoice(gross_profit_data, filters, group_wise_columns, data)
|
||||
|
||||
return columns, data
|
||||
|
||||
def get_data_when_grouped_by_invoice(columns, gross_profit_data, filters, group_wise_columns, data):
|
||||
column_names = get_column_names()
|
||||
|
||||
# to display item as Item Code: Item Name
|
||||
columns[0] = 'Sales Invoice:Link/Item:300'
|
||||
# removing Item Code and Item Name columns
|
||||
del columns[4:6]
|
||||
|
||||
for src in gross_profit_data.si_list:
|
||||
row = frappe._dict()
|
||||
row.indent = src.indent
|
||||
row.parent_invoice = src.parent_invoice
|
||||
row.currency = filters.currency
|
||||
|
||||
for col in group_wise_columns.get(scrub(filters.group_by)):
|
||||
row[column_names[col]] = src.get(col)
|
||||
|
||||
data.append(row)
|
||||
|
||||
def get_data_when_not_grouped_by_invoice(gross_profit_data, filters, group_wise_columns, data):
|
||||
for idx, src in enumerate(gross_profit_data.grouped_data):
|
||||
row = []
|
||||
for col in group_wise_columns.get(scrub(filters.group_by)):
|
||||
row.append(src.get(col))
|
||||
|
||||
row.append(filters.currency)
|
||||
if idx == len(gross_profit_data.grouped_data)-1:
|
||||
row[0] = frappe.bold("Total")
|
||||
data.append(row)
|
||||
|
||||
return columns, data
|
||||
|
||||
def get_columns(group_wise_columns, filters):
|
||||
columns = []
|
||||
column_map = frappe._dict({
|
||||
@@ -91,12 +119,38 @@ def get_columns(group_wise_columns, filters):
|
||||
|
||||
return columns
|
||||
|
||||
def get_column_names():
|
||||
return frappe._dict({
|
||||
'parent': 'sales_invoice',
|
||||
'customer': 'customer',
|
||||
'customer_group': 'customer_group',
|
||||
'posting_date': 'posting_date',
|
||||
'item_code': 'item_code',
|
||||
'item_name': 'item_name',
|
||||
'item_group': 'item_group',
|
||||
'brand': 'brand',
|
||||
'description': 'description',
|
||||
'warehouse': 'warehouse',
|
||||
'qty': 'qty',
|
||||
'base_rate': 'avg._selling_rate',
|
||||
'buying_rate': 'valuation_rate',
|
||||
'base_amount': 'selling_amount',
|
||||
'buying_amount': 'buying_amount',
|
||||
'gross_profit': 'gross_profit',
|
||||
'gross_profit_percent': 'gross_profit_%',
|
||||
'project': 'project'
|
||||
})
|
||||
|
||||
class GrossProfitGenerator(object):
|
||||
def __init__(self, filters=None):
|
||||
self.data = []
|
||||
self.average_buying_rate = {}
|
||||
self.filters = frappe._dict(filters)
|
||||
self.load_invoice_items()
|
||||
|
||||
if filters.group_by == 'Invoice':
|
||||
self.group_items_by_invoice()
|
||||
|
||||
self.load_stock_ledger_entries()
|
||||
self.load_product_bundle()
|
||||
self.load_non_stock_items()
|
||||
@@ -110,7 +164,12 @@ class GrossProfitGenerator(object):
|
||||
self.currency_precision = cint(frappe.db.get_default("currency_precision")) or 3
|
||||
self.float_precision = cint(frappe.db.get_default("float_precision")) or 2
|
||||
|
||||
for row in self.si_list:
|
||||
grouped_by_invoice = True if self.filters.get("group_by") == "Invoice" else False
|
||||
|
||||
if grouped_by_invoice:
|
||||
buying_amount = 0
|
||||
|
||||
for row in reversed(self.si_list):
|
||||
if self.skip_row(row, self.product_bundles):
|
||||
continue
|
||||
|
||||
@@ -132,12 +191,20 @@ class GrossProfitGenerator(object):
|
||||
row.buying_amount = flt(self.get_buying_amount(row, row.item_code),
|
||||
self.currency_precision)
|
||||
|
||||
if grouped_by_invoice:
|
||||
if row.indent == 1.0:
|
||||
buying_amount += row.buying_amount
|
||||
elif row.indent == 0.0:
|
||||
row.buying_amount = buying_amount
|
||||
buying_amount = 0
|
||||
|
||||
# get buying rate
|
||||
if row.qty:
|
||||
row.buying_rate = flt(row.buying_amount / row.qty, self.float_precision)
|
||||
row.base_rate = flt(row.base_amount / row.qty, self.float_precision)
|
||||
else:
|
||||
row.buying_rate, row.base_rate = 0.0, 0.0
|
||||
if self.is_not_invoice_row(row):
|
||||
row.buying_rate, row.base_rate = 0.0, 0.0
|
||||
|
||||
# calculate gross profit
|
||||
row.gross_profit = flt(row.base_amount - row.buying_amount, self.currency_precision)
|
||||
@@ -154,6 +221,15 @@ class GrossProfitGenerator(object):
|
||||
|
||||
def get_average_rate_based_on_group_by(self):
|
||||
# sum buying / selling totals for group
|
||||
self.totals = frappe._dict(
|
||||
qty=0,
|
||||
base_amount=0,
|
||||
buying_amount=0,
|
||||
gross_profit=0,
|
||||
gross_profit_percent=0,
|
||||
base_rate=0,
|
||||
buying_rate=0
|
||||
)
|
||||
for key in list(self.grouped):
|
||||
if self.filters.get("group_by") != "Invoice":
|
||||
for i, row in enumerate(self.grouped[key]):
|
||||
@@ -165,6 +241,7 @@ class GrossProfitGenerator(object):
|
||||
new_row.base_amount += flt(row.base_amount, self.currency_precision)
|
||||
new_row = self.set_average_rate(new_row)
|
||||
self.grouped_data.append(new_row)
|
||||
self.add_to_totals(new_row)
|
||||
else:
|
||||
for i, row in enumerate(self.grouped[key]):
|
||||
if row.parent in self.returned_invoices \
|
||||
@@ -173,19 +250,32 @@ class GrossProfitGenerator(object):
|
||||
for returned_item_row in returned_item_rows:
|
||||
row.qty += returned_item_row.qty
|
||||
row.base_amount += flt(returned_item_row.base_amount, self.currency_precision)
|
||||
row.buying_amount = flt(row.qty * row.buying_rate, self.currency_precision)
|
||||
if row.qty or row.base_amount:
|
||||
row.buying_amount = flt(flt(row.qty) * flt(row.buying_rate), self.currency_precision)
|
||||
if (flt(row.qty) or row.base_amount) and self.is_not_invoice_row(row):
|
||||
row = self.set_average_rate(row)
|
||||
self.grouped_data.append(row)
|
||||
self.add_to_totals(row)
|
||||
self.set_average_gross_profit(self.totals)
|
||||
self.grouped_data.append(self.totals)
|
||||
|
||||
def is_not_invoice_row(self, row):
|
||||
return (self.filters.get("group_by") == "Invoice" and row.indent != 0.0) or self.filters.get("group_by") != "Invoice"
|
||||
|
||||
def set_average_rate(self, new_row):
|
||||
self.set_average_gross_profit(new_row)
|
||||
new_row.buying_rate = flt(new_row.buying_amount / new_row.qty, self.float_precision) if new_row.qty else 0
|
||||
new_row.base_rate = flt(new_row.base_amount / new_row.qty, self.float_precision) if new_row.qty else 0
|
||||
return new_row
|
||||
|
||||
def set_average_gross_profit(self, new_row):
|
||||
new_row.gross_profit = flt(new_row.base_amount - new_row.buying_amount, self.currency_precision)
|
||||
new_row.gross_profit_percent = flt(((new_row.gross_profit / new_row.base_amount) * 100.0), self.currency_precision) \
|
||||
if new_row.base_amount else 0
|
||||
new_row.buying_rate = flt(new_row.buying_amount / new_row.qty, self.float_precision) if new_row.qty else 0
|
||||
new_row.base_rate = flt(new_row.base_amount / new_row.qty, self.float_precision) if new_row.qty else 0
|
||||
|
||||
return new_row
|
||||
def add_to_totals(self, new_row):
|
||||
for key in self.totals:
|
||||
if new_row.get(key):
|
||||
self.totals[key] += new_row[key]
|
||||
|
||||
def get_returned_invoice_items(self):
|
||||
returned_invoices = frappe.db.sql("""
|
||||
@@ -334,6 +424,109 @@ class GrossProfitGenerator(object):
|
||||
.format(conditions=conditions, sales_person_cols=sales_person_cols,
|
||||
sales_team_table=sales_team_table, match_cond = get_match_cond('Sales Invoice')), self.filters, as_dict=1)
|
||||
|
||||
def group_items_by_invoice(self):
|
||||
"""
|
||||
Turns list of Sales Invoice Items to a tree of Sales Invoices with their Items as children.
|
||||
"""
|
||||
|
||||
parents = []
|
||||
|
||||
for row in self.si_list:
|
||||
if row.parent not in parents:
|
||||
parents.append(row.parent)
|
||||
|
||||
parents_index = 0
|
||||
for index, row in enumerate(self.si_list):
|
||||
if parents_index < len(parents) and row.parent == parents[parents_index]:
|
||||
invoice = self.get_invoice_row(row)
|
||||
self.si_list.insert(index, invoice)
|
||||
parents_index += 1
|
||||
|
||||
else:
|
||||
# skipping the bundle items rows
|
||||
if not row.indent:
|
||||
row.indent = 1.0
|
||||
row.parent_invoice = row.parent
|
||||
row.parent = row.item_code
|
||||
|
||||
if frappe.db.exists('Product Bundle', row.item_code):
|
||||
self.add_bundle_items(row, index)
|
||||
|
||||
def get_invoice_row(self, row):
|
||||
return frappe._dict({
|
||||
'parent_invoice': "",
|
||||
'indent': 0.0,
|
||||
'parent': row.parent,
|
||||
'posting_date': row.posting_date,
|
||||
'posting_time': row.posting_time,
|
||||
'project': row.project,
|
||||
'update_stock': row.update_stock,
|
||||
'customer': row.customer,
|
||||
'customer_group': row.customer_group,
|
||||
'item_code': None,
|
||||
'item_name': None,
|
||||
'description': None,
|
||||
'warehouse': None,
|
||||
'item_group': None,
|
||||
'brand': None,
|
||||
'dn_detail': None,
|
||||
'delivery_note': None,
|
||||
'qty': None,
|
||||
'item_row': None,
|
||||
'is_return': row.is_return,
|
||||
'cost_center': row.cost_center,
|
||||
'base_net_amount': frappe.db.get_value('Sales Invoice', row.parent, 'base_net_total')
|
||||
})
|
||||
|
||||
def add_bundle_items(self, product_bundle, index):
|
||||
bundle_items = self.get_bundle_items(product_bundle)
|
||||
|
||||
for i, item in enumerate(bundle_items):
|
||||
bundle_item = self.get_bundle_item_row(product_bundle, item)
|
||||
self.si_list.insert((index+i+1), bundle_item)
|
||||
|
||||
def get_bundle_items(self, product_bundle):
|
||||
return frappe.get_all(
|
||||
'Product Bundle Item',
|
||||
filters = {
|
||||
'parent': product_bundle.item_code
|
||||
},
|
||||
fields = ['item_code', 'qty']
|
||||
)
|
||||
|
||||
def get_bundle_item_row(self, product_bundle, item):
|
||||
item_name, description, item_group, brand = self.get_bundle_item_details(item.item_code)
|
||||
|
||||
return frappe._dict({
|
||||
'parent_invoice': product_bundle.item_code,
|
||||
'indent': product_bundle.indent + 1,
|
||||
'parent': item.item_code,
|
||||
'posting_date': product_bundle.posting_date,
|
||||
'posting_time': product_bundle.posting_time,
|
||||
'project': product_bundle.project,
|
||||
'customer': product_bundle.customer,
|
||||
'customer_group': product_bundle.customer_group,
|
||||
'item_code': item.item_code,
|
||||
'item_name': item_name,
|
||||
'description': description,
|
||||
'warehouse': product_bundle.warehouse,
|
||||
'item_group': item_group,
|
||||
'brand': brand,
|
||||
'dn_detail': product_bundle.dn_detail,
|
||||
'delivery_note': product_bundle.delivery_note,
|
||||
'qty': (flt(product_bundle.qty) * flt(item.qty)),
|
||||
'item_row': None,
|
||||
'is_return': product_bundle.is_return,
|
||||
'cost_center': product_bundle.cost_center
|
||||
})
|
||||
|
||||
def get_bundle_item_details(self, item_code):
|
||||
return frappe.db.get_value(
|
||||
'Item',
|
||||
item_code,
|
||||
['item_name', 'description', 'item_group', 'brand']
|
||||
)
|
||||
|
||||
def load_stock_ledger_entries(self):
|
||||
res = frappe.db.sql("""select item_code, voucher_type, voucher_no,
|
||||
voucher_detail_no, stock_value, warehouse, actual_qty as qty
|
||||
|
||||
@@ -78,6 +78,7 @@ frappe.ui.form.on('Asset', {
|
||||
frappe.ui.form.trigger("Asset", "is_existing_asset");
|
||||
frm.toggle_display("next_depreciation_date", frm.doc.docstatus < 1);
|
||||
frm.events.make_schedules_editable(frm);
|
||||
frm.trigger("toggle_make_depreciation_entry");
|
||||
|
||||
if (frm.doc.docstatus==1) {
|
||||
if (in_list(["Submitted", "Partially Depreciated", "Fully Depreciated"], frm.doc.status)) {
|
||||
@@ -141,6 +142,18 @@ frappe.ui.form.on('Asset', {
|
||||
}
|
||||
},
|
||||
|
||||
toggle_make_depreciation_entry: function(frm) {
|
||||
if (frm.doc.calculate_depreciation){
|
||||
if (in_list(["Submitted", "Partially Depreciated"], frm.doc.status)){
|
||||
frm.fields_dict['schedules'].grid.set_column_disp('make_depreciation_entry', true);
|
||||
} else {
|
||||
frm.fields_dict['schedules'].grid.set_column_disp('make_depreciation_entry', false);
|
||||
}
|
||||
|
||||
frm.refresh_field('schedules');
|
||||
}
|
||||
},
|
||||
|
||||
toggle_reference_doc: function(frm) {
|
||||
if (frm.doc.purchase_receipt && frm.doc.purchase_invoice && frm.doc.docstatus === 1) {
|
||||
frm.set_df_property('purchase_invoice', 'read_only', 1);
|
||||
|
||||
@@ -122,11 +122,6 @@ class Asset(AccountsController):
|
||||
if self.is_existing_asset:
|
||||
return
|
||||
|
||||
docname = self.purchase_receipt or self.purchase_invoice
|
||||
if docname:
|
||||
doctype = 'Purchase Receipt' if self.purchase_receipt else 'Purchase Invoice'
|
||||
date = frappe.db.get_value(doctype, docname, 'posting_date')
|
||||
|
||||
if self.available_for_use_date and getdate(self.available_for_use_date) < getdate(self.purchase_date):
|
||||
frappe.throw(_("Available-for-use Date should be after purchase date"))
|
||||
|
||||
@@ -404,9 +399,10 @@ class Asset(AccountsController):
|
||||
if accumulated_depreciation_after_full_schedule:
|
||||
accumulated_depreciation_after_full_schedule = max(accumulated_depreciation_after_full_schedule)
|
||||
|
||||
asset_value_after_full_schedule = flt(flt(self.gross_purchase_amount) -
|
||||
flt(accumulated_depreciation_after_full_schedule),
|
||||
self.precision('gross_purchase_amount'))
|
||||
asset_value_after_full_schedule = flt(
|
||||
flt(self.gross_purchase_amount) -
|
||||
flt(self.opening_accumulated_depreciation) -
|
||||
flt(accumulated_depreciation_after_full_schedule), self.precision('gross_purchase_amount'))
|
||||
|
||||
if (row.expected_value_after_useful_life and
|
||||
row.expected_value_after_useful_life < asset_value_after_full_schedule):
|
||||
|
||||
@@ -34,6 +34,8 @@ def make_depreciation_entry(asset_name, date=None):
|
||||
date = today()
|
||||
|
||||
asset = frappe.get_doc("Asset", asset_name)
|
||||
validate_asset(asset)
|
||||
|
||||
fixed_asset_account, accumulated_depreciation_account, depreciation_expense_account = \
|
||||
get_depreciation_accounts(asset)
|
||||
|
||||
@@ -59,7 +61,7 @@ def make_depreciation_entry(asset_name, date=None):
|
||||
"credit_in_account_currency": d.depreciation_amount,
|
||||
"reference_type": "Asset",
|
||||
"reference_name": asset.name,
|
||||
"cost_center": ""
|
||||
"cost_center": depreciation_cost_center
|
||||
}
|
||||
|
||||
debit_entry = {
|
||||
@@ -101,6 +103,10 @@ def make_depreciation_entry(asset_name, date=None):
|
||||
|
||||
return asset
|
||||
|
||||
def validate_asset(asset):
|
||||
if asset.status not in ['Submitted', 'Partially Depreciated']:
|
||||
frappe.throw(_("Cannot depreciate {0} Asset").format(asset.status))
|
||||
|
||||
def get_depreciation_accounts(asset):
|
||||
fixed_asset_account = accumulated_depreciation_account = depreciation_expense_account = None
|
||||
|
||||
|
||||
13
erpnext/change_log/v12/v12_24_0.md
Normal file
13
erpnext/change_log/v12/v12_24_0.md
Normal file
@@ -0,0 +1,13 @@
|
||||
## Version 12.24.0 Release Notes
|
||||
|
||||
### Fixes & Enhancements
|
||||
- Sales order qty update fails in "Update Items" button ([#26992](https://github.com/frappe/erpnext/pull/26992))
|
||||
- Speed up validate_account_for_perpetual_inventory ([#26730](https://github.com/frappe/erpnext/pull/26730))
|
||||
- Deadlock while doing payment reconciliation ([#26674](https://github.com/frappe/erpnext/pull/26674))
|
||||
- Remove incorrect condition in GLE comparison ([#26713](https://github.com/frappe/erpnext/pull/26713))
|
||||
- Cannot cancel invoice if IRN cancelled on portal ([#26880](https://github.com/frappe/erpnext/pull/26880))
|
||||
- Item name is missing into job card ([#26956](https://github.com/frappe/erpnext/pull/26956))
|
||||
- Removed company filter for Loan Type ([#26463](https://github.com/frappe/erpnext/pull/26463))
|
||||
- Exchange rate revaluation posting date and precision fixes ([#26629](https://github.com/frappe/erpnext/pull/26629))
|
||||
- Fixed clearing issue of payment references on setting cost center ([#26548](https://github.com/frappe/erpnext/pull/26548))
|
||||
- Increase number of supported currency exchanges ([#25722](https://github.com/frappe/erpnext/pull/25722))
|
||||
10
erpnext/change_log/v12/v12_25_0.md
Normal file
10
erpnext/change_log/v12/v12_25_0.md
Normal file
@@ -0,0 +1,10 @@
|
||||
## Version 12.25.0 Release Notes
|
||||
|
||||
### Fixes & Enhancements
|
||||
- Multiple price rules margin. ([#24844](https://github.com/frappe/erpnext/pull/24844))
|
||||
- Document naming rule not working for subscription invoices ([#27394](https://github.com/frappe/erpnext/pull/27394))
|
||||
- Prematurely referenced variable in buying controller for subcontracting ([#27333](https://github.com/frappe/erpnext/pull/27333))
|
||||
- Calculation of gross profit percentage in Gross Profit Report ([#26713](https://github.com/frappe/erpnext/pull/27045))
|
||||
- Price list rate not fetched for return sales invoice fixed ([#26593](https://github.com/frappe/erpnext/pull/26593))
|
||||
- Set production plan to completed even on over production ([#27027](https://github.com/frappe/erpnext/pull/27027))
|
||||
- Add `total_billing_hours` to Sales Invoice ([#26652](https://github.com/frappe/erpnext/pull/26652))
|
||||
8
erpnext/change_log/v12/v12_26_0.md
Normal file
8
erpnext/change_log/v12/v12_26_0.md
Normal file
@@ -0,0 +1,8 @@
|
||||
## ERPNext Version 12.26.0 Release Notes
|
||||
|
||||
### Fixes & Enhancements
|
||||
- Make Gross Profit Report more readable ([#27124](https://github.com/frappe/erpnext/pull/27124))
|
||||
- Set item uom as stock_uom if it isn't set ([#27623](https://github.com/frappe/erpnext/pull/27623))
|
||||
- Adding empty row on new maintenance visit ([#27626](https://github.com/frappe/erpnext/pull/27626))
|
||||
- Employee Leave Balance report should only consider ledgers of transaction type Leave Allocation ([#28017](https://github.com/frappe/erpnext/pull/28017))
|
||||
- Validate if item exists on uploading items in stock reco ([#27538](https://github.com/frappe/erpnext/pull/27538))
|
||||
9
erpnext/change_log/v12/v12_27_0.md
Normal file
9
erpnext/change_log/v12/v12_27_0.md
Normal file
@@ -0,0 +1,9 @@
|
||||
## ERPNext Version 12.27.0 Release Notes
|
||||
|
||||
### Fixes & Enhancements
|
||||
- Always expect signature in webhook requests for WooCommerce ([#28367](https://github.com/frappe/erpnext/pull/28367))
|
||||
- Debit & Credit currency in bank transaction ([#28574](https://github.com/frappe/erpnext/pull/28574))
|
||||
- Incorrect balance in "Warehouse Wise Item Balance and Age" report ([#28583](https://github.com/frappe/erpnext/pull/28583))
|
||||
- Check if gst_category exists while validating GSTIN ([#28065](https://github.com/frappe/erpnext/pull/28065))
|
||||
- Skip empty rows while updating unsaved BOM cost ([#28136](https://github.com/frappe/erpnext/pull/28136))
|
||||
- Remove warehouse filter on Batch field for Material Receipt ([#28195](https://github.com/frappe/erpnext/pull/28195))
|
||||
7
erpnext/change_log/v12/v12_28_0.md
Normal file
7
erpnext/change_log/v12/v12_28_0.md
Normal file
@@ -0,0 +1,7 @@
|
||||
## ERPNext Version 12.28.0 Release Notes
|
||||
|
||||
### Fixes & Enhancements
|
||||
- Set cost center for credit entries while posting Depreciation Entries ([#28908](https://github.com/frappe/erpnext/pull/28908))
|
||||
- Incorrect amount based on Payment Days in timesheet based salary slip ([#28884](https://github.com/frappe/erpnext/pull/28884))
|
||||
- Removed rename feature for the Warehouse document ([#28712](https://github.com/frappe/erpnext/pull/28712))
|
||||
- Actual tax conversion in case of multicurrency invoices ([#28539](https://github.com/frappe/erpnext/pull/28539))
|
||||
5
erpnext/change_log/v12/v12_29_0.md
Normal file
5
erpnext/change_log/v12/v12_29_0.md
Normal file
@@ -0,0 +1,5 @@
|
||||
## ERPNext Version 12.29.0 Release Notes
|
||||
|
||||
### Fixes & Enhancements
|
||||
|
||||
- Display 'Make Depreciation Entry' only for submitted or partially depreciated Assets ([#29291](https://github.com/frappe/erpnext/pull/29291))
|
||||
@@ -1290,6 +1290,11 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, chil
|
||||
|
||||
for d in data:
|
||||
new_child_flag = False
|
||||
|
||||
if not d.get("item_code"):
|
||||
# ignore empty rows
|
||||
continue
|
||||
|
||||
if not d.get("docname"):
|
||||
new_child_flag = True
|
||||
check_doc_permissions(parent, 'create')
|
||||
@@ -1312,7 +1317,7 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, chil
|
||||
qty_unchanged = prev_qty == new_qty
|
||||
uom_unchanged = prev_uom == new_uom
|
||||
conversion_factor_unchanged = prev_con_fac == new_con_fac
|
||||
date_unchanged = prev_date == new_date if prev_date and new_date else False # in case of delivery note etc
|
||||
date_unchanged = prev_date == getdate(new_date) if prev_date and new_date else False # in case of delivery note etc
|
||||
if rate_unchanged and qty_unchanged and conversion_factor_unchanged and uom_unchanged and date_unchanged:
|
||||
continue
|
||||
|
||||
|
||||
@@ -983,11 +983,11 @@ def get_non_stock_items(purchase_order, fg_item_code):
|
||||
def set_serial_nos(raw_material, consumed_serial_nos, qty):
|
||||
consumed_serial_nos_list = []
|
||||
|
||||
if isinstance(consumed_serial_nos, list):
|
||||
if consumed_serial_nos and isinstance(consumed_serial_nos, list):
|
||||
for row in consumed_serial_nos:
|
||||
consumed_serial_nos_list.extend(get_serial_nos(row))
|
||||
else:
|
||||
consumed_serial_nos_list = get_serial_nos(row)
|
||||
elif consumed_serial_nos:
|
||||
consumed_serial_nos_list = get_serial_nos(consumed_serial_nos)
|
||||
|
||||
serial_nos = set(get_serial_nos(raw_material.serial_nos)) - set(consumed_serial_nos_list)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import flt, comma_or, nowdate, getdate
|
||||
from frappe.utils import flt, comma_or, nowdate, getdate, now
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
|
||||
@@ -307,10 +307,14 @@ class StatusUpdater(Document):
|
||||
target.notify_update()
|
||||
|
||||
def _update_modified(self, args, update_modified):
|
||||
args['update_modified'] = ''
|
||||
if update_modified:
|
||||
args['update_modified'] = ', modified = now(), modified_by = {0}'\
|
||||
.format(frappe.db.escape(frappe.session.user))
|
||||
if not update_modified:
|
||||
args['update_modified'] = ''
|
||||
return
|
||||
|
||||
args['update_modified'] = ', modified = {0}, modified_by = {1}'.format(
|
||||
frappe.db.escape(now()),
|
||||
frappe.db.escape(frappe.session.user)
|
||||
)
|
||||
|
||||
def update_billing_status_for_zero_amount_refdoc(self, ref_dt):
|
||||
ref_fieldname = frappe.scrub(ref_dt)
|
||||
|
||||
@@ -418,7 +418,7 @@ def compare_existing_and_expected_gle(existing_gle, expected_gle):
|
||||
for e in existing_gle:
|
||||
if entry.account == e.account:
|
||||
account_existed = True
|
||||
if entry.account == e.account and entry.against_account == e.against_account \
|
||||
if entry.account == e.account \
|
||||
and (not entry.cost_center or not e.cost_center or entry.cost_center == e.cost_center) \
|
||||
and (entry.debit != e.debit or entry.credit != e.credit):
|
||||
matched = False
|
||||
|
||||
@@ -14,8 +14,7 @@ def verify_request():
|
||||
)
|
||||
|
||||
if frappe.request.data and \
|
||||
frappe.get_request_header("X-Wc-Webhook-Signature") and \
|
||||
not sig == bytes(frappe.get_request_header("X-Wc-Webhook-Signature").encode()):
|
||||
not sig == frappe.get_request_header("X-Wc-Webhook-Signature", "").encode():
|
||||
frappe.throw(_("Unverified Webhook Data"))
|
||||
frappe.set_user(woocommerce_settings.creation_user)
|
||||
|
||||
|
||||
@@ -83,10 +83,8 @@ def add_bank_accounts(response, bank, company):
|
||||
if not acc_subtype:
|
||||
add_account_subtype(account["subtype"])
|
||||
|
||||
existing_bank_account = frappe.db.exists("Bank Account", {
|
||||
'account_name': account["name"],
|
||||
'bank': bank["bank_name"]
|
||||
})
|
||||
bank_account_name = "{} - {}".format(account["name"], bank["bank_name"])
|
||||
existing_bank_account = frappe.db.exists("Bank Account", bank_account_name)
|
||||
|
||||
if not existing_bank_account:
|
||||
try:
|
||||
@@ -198,6 +196,7 @@ def get_transactions(bank, bank_account=None, start_date=None, end_date=None):
|
||||
|
||||
plaid = PlaidConnector(access_token)
|
||||
|
||||
transactions = []
|
||||
try:
|
||||
transactions = plaid.get_transactions(start_date=start_date, end_date=end_date, account_id=account_id)
|
||||
except ItemError as e:
|
||||
@@ -206,7 +205,7 @@ def get_transactions(bank, bank_account=None, start_date=None, end_date=None):
|
||||
msg += _("Please refresh or reset the Plaid linking of the Bank {}.").format(bank) + " "
|
||||
frappe.log_error(msg, title=_("Plaid Link Refresh Required"))
|
||||
|
||||
return transactions or []
|
||||
return transactions
|
||||
|
||||
|
||||
def new_bank_transaction(transaction):
|
||||
|
||||
@@ -18,5 +18,8 @@ frappe.ui.form.on('Shopify Log', {
|
||||
})
|
||||
}).addClass('btn-primary');
|
||||
}
|
||||
|
||||
let app_link = "<a href='https://frappecloud.com/marketplace/apps/ecommerce-integrations' target='_blank'>Ecommerce Integrations</a>"
|
||||
frm.dashboard.add_comment(__("Shopify Integration will be removed from ERPNext in Version 14. Please install {0} app to continue using it.", [app_link]), "yellow", true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -64,5 +64,8 @@ def dump_request_data(data, event="create/order"):
|
||||
@frappe.whitelist()
|
||||
def resync(method, name, request_data):
|
||||
frappe.db.set_value("Shopify Log", name, "status", "Queued", update_modified=False)
|
||||
if not method.startswith("erpnext.erpnext_integrations.connectors.shopify_connection"):
|
||||
return
|
||||
|
||||
frappe.enqueue(method=method, queue='short', timeout=300, is_async=True,
|
||||
**{"order": json.loads(request_data), "request_id": name})
|
||||
|
||||
@@ -36,6 +36,10 @@ frappe.ui.form.on("Shopify Settings", "refresh", function(frm){
|
||||
frm.toggle_reqd("delivery_note_series", frm.doc.sync_delivery_note);
|
||||
|
||||
}
|
||||
|
||||
let app_link = "<a href='https://frappecloud.com/marketplace/apps/ecommerce-integrations' target='_blank'>Ecommerce Integrations</a>"
|
||||
frm.dashboard.add_comment(__("Shopify Integration will be removed from ERPNext in Version 14. Please install {0} app to continue using it.", [app_link]), "yellow", true);
|
||||
|
||||
})
|
||||
|
||||
$.extend(erpnext_integrations.shopify_settings, {
|
||||
|
||||
@@ -18,7 +18,6 @@ def validate_webhooks_request(doctype, hmac_key, secret_key='secret'):
|
||||
)
|
||||
|
||||
if frappe.request.data and \
|
||||
frappe.get_request_header(hmac_key) and \
|
||||
not sig == bytes(frappe.get_request_header(hmac_key).encode()):
|
||||
frappe.throw(_("Unverified Webhook Data"))
|
||||
frappe.set_user(settings.modified_by)
|
||||
|
||||
@@ -15,15 +15,6 @@ frappe.ui.form.on('Loan', {
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query("loan_type", function () {
|
||||
return {
|
||||
"filters": {
|
||||
"docstatus": 1,
|
||||
"company": frm.doc.company
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query("interest_income_account", function () {
|
||||
return {
|
||||
"filters": {
|
||||
|
||||
@@ -7,13 +7,6 @@ frappe.ui.form.on('Loan Application', {
|
||||
refresh: function(frm) {
|
||||
frm.trigger("toggle_fields");
|
||||
frm.trigger("add_toolbar_buttons");
|
||||
frm.set_query('loan_type', () => {
|
||||
return {
|
||||
filters: {
|
||||
company: frm.doc.company
|
||||
}
|
||||
};
|
||||
});
|
||||
},
|
||||
repayment_method: function(frm) {
|
||||
frm.doc.repayment_amount = frm.doc.repayment_periods = ""
|
||||
|
||||
@@ -5,6 +5,7 @@ frappe.ui.form.on('Salary Component', {
|
||||
setup: function(frm) {
|
||||
frm.set_query("default_account", "accounts", function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
|
||||
return {
|
||||
filters: {
|
||||
"is_group": 0,
|
||||
|
||||
@@ -303,11 +303,11 @@ class SalarySlip(TransactionBase):
|
||||
|
||||
if self.salary_structure:
|
||||
self.calculate_component_amounts("deductions")
|
||||
|
||||
|
||||
self.set_loan_repayment()
|
||||
self.set_component_amounts_based_on_payment_days()
|
||||
self.set_net_pay()
|
||||
|
||||
|
||||
def set_net_pay(self):
|
||||
self.total_deduction = self.get_component_totals("deductions")
|
||||
self.net_pay = flt(self.gross_pay) - (flt(self.total_deduction) + flt(self.total_loan_repayment))
|
||||
@@ -519,7 +519,7 @@ class SalarySlip(TransactionBase):
|
||||
# Total taxable earnings including additional and other incomes
|
||||
total_taxable_earnings = previous_taxable_earnings + current_structured_taxable_earnings + future_structured_taxable_earnings \
|
||||
+ current_additional_earnings + other_incomes + unclaimed_taxable_benefits - total_exemption_amount
|
||||
|
||||
|
||||
# Total taxable earnings without additional earnings with full tax
|
||||
total_taxable_earnings_without_full_tax_addl_components = total_taxable_earnings - current_additional_earnings_with_full_tax
|
||||
|
||||
@@ -527,7 +527,7 @@ class SalarySlip(TransactionBase):
|
||||
total_structured_tax_amount = self.calculate_tax_by_tax_slab(
|
||||
total_taxable_earnings_without_full_tax_addl_components, tax_slab)
|
||||
current_structured_tax_amount = (total_structured_tax_amount - previous_total_paid_taxes) / remaining_sub_periods
|
||||
|
||||
|
||||
# Total taxable earnings with additional earnings with full tax
|
||||
full_tax_on_additional_earnings = 0.0
|
||||
if current_additional_earnings_with_full_tax:
|
||||
@@ -563,7 +563,7 @@ class SalarySlip(TransactionBase):
|
||||
select sum(sd.amount)
|
||||
from
|
||||
`tabSalary Detail` sd join `tabSalary Slip` ss on sd.parent=ss.name
|
||||
where
|
||||
where
|
||||
sd.parentfield='earnings'
|
||||
and sd.is_tax_applicable=1
|
||||
and is_flexible_benefit=0
|
||||
@@ -676,9 +676,11 @@ class SalarySlip(TransactionBase):
|
||||
|
||||
def get_amount_based_on_payment_days(self, row, joining_date, relieving_date):
|
||||
amount, additional_amount = row.amount, row.additional_amount
|
||||
timesheet_component = frappe.db.get_value("Salary Structure", self.salary_structure, "salary_component")
|
||||
|
||||
if (self.salary_structure and
|
||||
cint(row.depends_on_payment_days) and cint(self.total_working_days) and
|
||||
(not self.salary_slip_based_on_timesheet or
|
||||
cint(row.depends_on_payment_days) and cint(self.total_working_days)
|
||||
and (row.salary_component != timesheet_component or
|
||||
getdate(self.start_date) < joining_date or
|
||||
(relieving_date and getdate(self.end_date) > relieving_date)
|
||||
)):
|
||||
@@ -687,7 +689,7 @@ class SalarySlip(TransactionBase):
|
||||
amount = flt((flt(row.default_amount) * flt(self.payment_days)
|
||||
/ cint(self.total_working_days)), row.precision("amount")) + additional_amount
|
||||
|
||||
elif not self.payment_days and not self.salary_slip_based_on_timesheet and cint(row.depends_on_payment_days):
|
||||
elif not self.payment_days and row.salary_component != timesheet_component and cint(row.depends_on_payment_days):
|
||||
amount, additional_amount = 0, 0
|
||||
elif not row.amount:
|
||||
amount = flt(row.default_amount) + flt(row.additional_amount)
|
||||
@@ -782,7 +784,7 @@ class SalarySlip(TransactionBase):
|
||||
|
||||
if flt(d.max_taxable_income) and flt(d.max_taxable_income) < annual_taxable_earning:
|
||||
continue
|
||||
|
||||
|
||||
tax_amount += tax_amount * flt(d.percent) / 100
|
||||
|
||||
return tax_amount
|
||||
|
||||
@@ -115,6 +115,41 @@ class TestSalarySlip(unittest.TestCase):
|
||||
frappe.db.set_value("Employee", frappe.get_value("Employee",
|
||||
{"employee_name":"test_employee@salary.com"}, "name"), "status", "Active")
|
||||
|
||||
def test_payment_days_in_salary_slip_based_on_timesheet(self):
|
||||
from erpnext.projects.doctype.timesheet.test_timesheet import (
|
||||
make_salary_structure_for_timesheet,
|
||||
make_timesheet,
|
||||
)
|
||||
from erpnext.projects.doctype.timesheet.timesheet import (
|
||||
make_salary_slip as make_salary_slip_for_timesheet,
|
||||
)
|
||||
|
||||
# Holidays included in working days
|
||||
frappe.db.set_value("HR Settings", None, "include_holidays_in_total_working_days", 0)
|
||||
|
||||
emp = make_employee("test_employee_timesheet1@salary.com", company=erpnext.get_default_company())
|
||||
frappe.db.set_value("Employee", emp, {"relieving_date": None, "status": "Active"})
|
||||
|
||||
# salary structure based on timesheet
|
||||
make_salary_structure_for_timesheet(emp)
|
||||
timesheet = make_timesheet(emp, simulate=True)
|
||||
salary_slip = make_salary_slip_for_timesheet(timesheet.name)
|
||||
salary_slip.start_date = get_first_day(nowdate())
|
||||
salary_slip.end_date = get_last_day(nowdate())
|
||||
salary_slip.save()
|
||||
salary_slip.submit()
|
||||
|
||||
no_of_days = self.get_no_of_days()
|
||||
days_in_month = no_of_days[0]
|
||||
no_of_holidays = no_of_days[1]
|
||||
|
||||
self.assertEqual(salary_slip.payment_days, days_in_month - no_of_holidays)
|
||||
|
||||
# gross pay calculation based on attendance (payment days)
|
||||
gross_pay = 78100 - ((78000 / (days_in_month - no_of_holidays)) * flt(salary_slip.leave_without_pay))
|
||||
|
||||
self.assertEqual(salary_slip.gross_pay, flt(gross_pay, 2))
|
||||
|
||||
def test_employee_salary_slip_read_permission(self):
|
||||
make_employee("test_employee@salary.com")
|
||||
|
||||
@@ -175,7 +210,7 @@ class TestSalarySlip(unittest.TestCase):
|
||||
# as per assigned salary structure 40500 in monthly salary so 236000*5/100/12
|
||||
frappe.db.sql("""delete from `tabPayroll Period`""")
|
||||
frappe.db.sql("""delete from `tabSalary Component`""")
|
||||
|
||||
|
||||
payroll_period = create_payroll_period()
|
||||
|
||||
create_tax_slab(payroll_period, allow_tax_exemption=True)
|
||||
|
||||
@@ -89,6 +89,7 @@ def execute(filters=None):
|
||||
"amount": salary.net_pay,
|
||||
}
|
||||
data.append(row)
|
||||
|
||||
return columns, data
|
||||
|
||||
def get_bank_accounts():
|
||||
@@ -110,7 +111,7 @@ def get_payroll_entries(accounts, filters):
|
||||
entries = get_all("Payroll Entry", payroll_filter, ["name", "payment_account"])
|
||||
|
||||
payment_accounts = [d.payment_account for d in entries]
|
||||
set_company_account(payment_accounts, entries)
|
||||
entries = set_company_account(payment_accounts, entries)
|
||||
return entries
|
||||
|
||||
def get_salary_slips(payroll_entries):
|
||||
|
||||
@@ -124,11 +124,12 @@ def get_allocated_and_expired_leaves(records, from_date, to_date):
|
||||
def get_leave_ledger_entries(from_date, to_date, employee, leave_type):
|
||||
records= frappe.db.sql("""
|
||||
SELECT
|
||||
employee, leave_type, from_date, to_date, leaves, transaction_name, transaction_type
|
||||
is_carry_forward, is_expired
|
||||
employee, leave_type, from_date, to_date, leaves, transaction_name,
|
||||
transaction_type, is_carry_forward, is_expired
|
||||
FROM `tabLeave Ledger Entry`
|
||||
WHERE employee=%(employee)s AND leave_type=%(leave_type)s
|
||||
AND docstatus=1
|
||||
AND transaction_type = 'Leave Allocation'
|
||||
AND (from_date between %(from_date)s AND %(to_date)s
|
||||
OR to_date between %(from_date)s AND %(to_date)s
|
||||
OR (from_date < %(from_date)s AND to_date > %(to_date)s))
|
||||
|
||||
@@ -27,6 +27,9 @@ frappe.ui.form.on('Maintenance Visit', {
|
||||
if (frm.doc.__islocal) {
|
||||
frm.set_value({mntc_date: frappe.datetime.get_today()});
|
||||
}
|
||||
if (frm.doc.purposes.length && frm.doc.purposes[0].item_name == undefined) {
|
||||
frm.clear_table("purposes");
|
||||
}
|
||||
},
|
||||
customer: function(frm) {
|
||||
erpnext.utils.get_party_details(frm);
|
||||
@@ -49,13 +52,17 @@ erpnext.maintenance.MaintenanceVisit = frappe.ui.form.Controller.extend({
|
||||
|
||||
if (this.frm.doc.docstatus===0) {
|
||||
this.frm.add_custom_button(__('Maintenance Schedule'),
|
||||
function() {
|
||||
function () {
|
||||
if (!me.frm.doc.customer) {
|
||||
frappe.msgprint(__('Please select Customer first'));
|
||||
return;
|
||||
}
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.maintenance.doctype.maintenance_schedule.maintenance_schedule.make_maintenance_visit",
|
||||
source_doctype: "Maintenance Schedule",
|
||||
target: me.frm,
|
||||
setters: {
|
||||
customer: me.frm.doc.customer || undefined,
|
||||
customer: me.frm.doc.customer,
|
||||
},
|
||||
get_query_filters: {
|
||||
docstatus: 1,
|
||||
@@ -80,13 +87,17 @@ erpnext.maintenance.MaintenanceVisit = frappe.ui.form.Controller.extend({
|
||||
})
|
||||
}, __("Get items from"));
|
||||
this.frm.add_custom_button(__('Sales Order'),
|
||||
function() {
|
||||
function () {
|
||||
if (!me.frm.doc.customer) {
|
||||
frappe.msgprint(__('Please select Customer first'));
|
||||
return;
|
||||
}
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.selling.doctype.sales_order.sales_order.make_maintenance_visit",
|
||||
source_doctype: "Sales Order",
|
||||
target: me.frm,
|
||||
setters: {
|
||||
customer: me.frm.doc.customer || undefined,
|
||||
customer: me.frm.doc.customer,
|
||||
},
|
||||
get_query_filters: {
|
||||
docstatus: 1,
|
||||
@@ -99,4 +110,4 @@ erpnext.maintenance.MaintenanceVisit = frappe.ui.form.Controller.extend({
|
||||
},
|
||||
});
|
||||
|
||||
$.extend(cur_frm.cscript, new erpnext.maintenance.MaintenanceVisit({frm: cur_frm}));
|
||||
$.extend(cur_frm.cscript, new erpnext.maintenance.MaintenanceVisit({frm: cur_frm}));
|
||||
|
||||
@@ -240,6 +240,9 @@ class BOM(WebsiteGenerator):
|
||||
existing_bom_cost = self.total_cost
|
||||
|
||||
for d in self.get("items"):
|
||||
if not d.item_code:
|
||||
continue
|
||||
|
||||
rate = self.get_rm_rate({
|
||||
"company": self.company,
|
||||
"item_code": d.item_code,
|
||||
@@ -414,25 +417,29 @@ class BOM(WebsiteGenerator):
|
||||
frappe.throw(_("Quantity required for Item {0} in row {1}").format(m.item_code, m.idx))
|
||||
check_list.append(m)
|
||||
|
||||
def check_recursion(self, bom_list=[]):
|
||||
def check_recursion(self, bom_list=None):
|
||||
""" Check whether recursion occurs in any bom"""
|
||||
def _throw_error(bom_name):
|
||||
frappe.throw(_("BOM recursion: {0} cannot be parent or child of {0}").format(bom_name))
|
||||
|
||||
bom_list = self.traverse_tree()
|
||||
bom_nos = frappe.get_all('BOM Item', fields=["bom_no"],
|
||||
filters={'parent': ('in', bom_list), 'parenttype': 'BOM'})
|
||||
child_items = frappe.get_all('BOM Item', fields=["bom_no", "item_code"],
|
||||
filters={'parent': ('in', bom_list), 'parenttype': 'BOM'}) or []
|
||||
|
||||
raise_exception = False
|
||||
if bom_nos and self.name in [d.bom_no for d in bom_nos]:
|
||||
raise_exception = True
|
||||
child_bom = {d.bom_no for d in child_items}
|
||||
child_items_codes = {d.item_code for d in child_items}
|
||||
|
||||
if not raise_exception:
|
||||
bom_nos = frappe.get_all('BOM Item', fields=["parent"],
|
||||
filters={'bom_no': self.name, 'parenttype': 'BOM'})
|
||||
if self.name in child_bom:
|
||||
_throw_error(self.name)
|
||||
|
||||
if self.name in [d.parent for d in bom_nos]:
|
||||
raise_exception = True
|
||||
if self.item in child_items_codes:
|
||||
_throw_error(self.item)
|
||||
|
||||
if raise_exception:
|
||||
frappe.throw(_("BOM recursion: {0} cannot be parent or child of {1}").format(self.name, self.name))
|
||||
bom_nos = frappe.get_all('BOM Item', fields=["parent"],
|
||||
filters={'bom_no': self.name, 'parenttype': 'BOM'}) or []
|
||||
|
||||
if self.name in {d.parent for d in bom_nos}:
|
||||
_throw_error(self.name)
|
||||
|
||||
def update_cost_and_exploded_items(self, bom_list=[]):
|
||||
bom_list = self.traverse_tree(bom_list)
|
||||
@@ -545,7 +552,7 @@ class BOM(WebsiteGenerator):
|
||||
for d in self.get('items'):
|
||||
if d.bom_no:
|
||||
self.get_child_exploded_items(d.bom_no, d.stock_qty)
|
||||
else:
|
||||
elif d.item_code:
|
||||
self.add_to_cur_exploded_items(frappe._dict({
|
||||
'item_code' : d.item_code,
|
||||
'item_name' : d.item_name,
|
||||
|
||||
@@ -228,7 +228,7 @@ class ProductionPlan(Document):
|
||||
|
||||
if self.total_produced_qty > 0:
|
||||
self.status = "In Process"
|
||||
if self.total_produced_qty == self.total_planned_qty:
|
||||
if self.total_produced_qty >= self.total_planned_qty:
|
||||
self.status = "Completed"
|
||||
|
||||
if self.status != 'Completed':
|
||||
|
||||
@@ -198,6 +198,7 @@ class TestProductionPlan(unittest.TestCase):
|
||||
pln.cancel()
|
||||
frappe.delete_doc("Production Plan", pln.name)
|
||||
|
||||
|
||||
def create_production_plan(**args):
|
||||
args = frappe._dict(args)
|
||||
|
||||
|
||||
@@ -107,6 +107,8 @@
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.production_item",
|
||||
"fetch_from": "production_item.item_name",
|
||||
"fetch_if_empty": 1,
|
||||
"fieldname": "item_name",
|
||||
"fieldtype": "Data",
|
||||
"label": "Item Name",
|
||||
@@ -470,7 +472,7 @@
|
||||
"image_field": "image",
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2019-12-04 11:20:04.695123",
|
||||
"modified": "2021-08-16 11:20:04.695123",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Manufacturing",
|
||||
"name": "Work Order",
|
||||
|
||||
@@ -88,7 +88,7 @@ def get_bom_stock(filters):
|
||||
GROUP BY bom_item.item_code""".format(qty_field=qty_field, table=table, conditions=conditions, bom=bom), as_dict=1)
|
||||
|
||||
def get_manufacturer_records():
|
||||
details = frappe.get_list('Item Manufacturer', fields = ["manufacturer", "manufacturer_part_no", "parent"])
|
||||
details = frappe.get_all('Item Manufacturer', fields = ["manufacturer", "manufacturer_part_no", "parent"])
|
||||
manufacture_details = frappe._dict()
|
||||
for detail in details:
|
||||
dic = manufacture_details.setdefault(detail.get('parent'), {})
|
||||
|
||||
@@ -686,3 +686,4 @@ erpnext.patches.v12_0.purchase_receipt_status
|
||||
erpnext.patches.v12_0.add_company_link_to_einvoice_settings
|
||||
erpnext.patches.v12_0.add_document_type_field_for_italy_einvoicing
|
||||
erpnext.patches.v12_0.create_taxable_value_field_in_purchase_invoice
|
||||
erpnext.patches.v12_0.show_einvoice_irn_cancelled_field
|
||||
|
||||
@@ -6,6 +6,9 @@ import frappe
|
||||
from frappe.model.utils.rename_field import rename_field
|
||||
|
||||
def execute():
|
||||
# updating column value to handle field change from Data to Currency
|
||||
frappe.db.sql("update `tabBOM` set base_scrap_material_cost = '0' where trim(coalesce(base_scrap_material_cost, ''))= ''")
|
||||
|
||||
for doctype in ['BOM Explosion Item', 'BOM Item', 'Work Order Item', 'Item']:
|
||||
if frappe.db.has_column(doctype, 'allow_transfer_for_manufacture'):
|
||||
if doctype != 'Item':
|
||||
@@ -26,4 +29,4 @@ def execute():
|
||||
else:
|
||||
frappe.db.sql(""" UPDATE `tab%s`
|
||||
SET transfer_material_against = 'Work Order'
|
||||
WHERE docstatus < 2""" % (doctype))
|
||||
WHERE docstatus < 2""" % (doctype))
|
||||
|
||||
12
erpnext/patches/v12_0/show_einvoice_irn_cancelled_field.py
Normal file
12
erpnext/patches/v12_0/show_einvoice_irn_cancelled_field.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
if not company:
|
||||
return
|
||||
|
||||
irn_cancelled_field = frappe.db.exists('Custom Field', {'dt': 'Sales Invoice', 'fieldname': 'irn_cancelled'})
|
||||
if irn_cancelled_field:
|
||||
frappe.db.set_value('Custom Field', irn_cancelled_field, 'depends_on', 'eval: doc.irn')
|
||||
frappe.db.set_value('Custom Field', irn_cancelled_field, 'read_only', 0)
|
||||
@@ -86,6 +86,10 @@ class Project(Document):
|
||||
if self.sales_order:
|
||||
frappe.db.set_value("Sales Order", self.sales_order, "project", self.name)
|
||||
|
||||
def on_trash(self):
|
||||
for so in frappe.get_all("Sales Order", {"project": self.name}, ["name"]):
|
||||
frappe.db.set_value("Sales Order", so.get('name'), "project", "")
|
||||
|
||||
def update_percent_complete(self):
|
||||
if self.percent_complete_method == "Manual":
|
||||
if self.status == "Completed":
|
||||
|
||||
@@ -8,7 +8,8 @@ test_records = frappe.get_test_records('Project')
|
||||
test_ignore = ["Sales Order"]
|
||||
|
||||
from erpnext.projects.doctype.project_template.test_project_template import get_project_template, make_project_template
|
||||
from erpnext.projects.doctype.project.project import set_project_status
|
||||
from erpnext.selling.doctype.sales_order.sales_order import make_project as make_project_from_so
|
||||
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||
|
||||
from frappe.utils import getdate
|
||||
|
||||
@@ -32,6 +33,21 @@ class TestProject(unittest.TestCase):
|
||||
self.assertEqual(task4.subject, 'Task 4')
|
||||
self.assertEqual(getdate(task4.exp_end_date), getdate('2019-01-06'))
|
||||
|
||||
def test_project_linking_with_sales_order(self):
|
||||
so = make_sales_order()
|
||||
project = make_project_from_so(so.name)
|
||||
|
||||
project.save()
|
||||
self.assertEqual(project.sales_order, so.name)
|
||||
|
||||
so.reload()
|
||||
self.assertEqual(so.project, project.name)
|
||||
|
||||
project.delete()
|
||||
|
||||
so.reload()
|
||||
self.assertFalse(so.project)
|
||||
|
||||
def get_project(name):
|
||||
template = get_project_template()
|
||||
|
||||
|
||||
@@ -73,9 +73,6 @@ class Task(NestedSet):
|
||||
if (self.progress or 0) > 100:
|
||||
frappe.throw(_("Progress % for a task cannot be more than 100."))
|
||||
|
||||
if self.progress == 100:
|
||||
self.status = 'Completed'
|
||||
|
||||
if self.status == 'Completed':
|
||||
self.progress = 100
|
||||
|
||||
|
||||
@@ -20,10 +20,6 @@ class TestTimesheet(unittest.TestCase):
|
||||
for dt in ["Salary Slip", "Salary Structure", "Salary Structure Assignment", "Timesheet"]:
|
||||
frappe.db.sql("delete from `tab%s`" % dt)
|
||||
|
||||
if not frappe.db.exists("Salary Component", "Timesheet Component"):
|
||||
frappe.get_doc({"doctype": "Salary Component", "salary_component": "Timesheet Component"}).insert()
|
||||
|
||||
|
||||
def test_timesheet_billing_amount(self):
|
||||
make_salary_structure_for_timesheet("_T-Employee-00001")
|
||||
timesheet = make_timesheet("_T-Employee-00001", simulate=True, billable=1)
|
||||
@@ -177,6 +173,9 @@ def make_salary_structure_for_timesheet(employee):
|
||||
salary_structure_name = "Timesheet Salary Structure Test"
|
||||
frequency = "Monthly"
|
||||
|
||||
if not frappe.db.exists("Salary Component", "Timesheet Component"):
|
||||
frappe.get_doc({"doctype": "Salary Component", "salary_component": "Timesheet Component"}).insert()
|
||||
|
||||
salary_structure = make_salary_structure(salary_structure_name, frequency, dont_submit=True)
|
||||
salary_structure.salary_component = "Timesheet Component"
|
||||
salary_structure.salary_slip_based_on_timesheet = 1
|
||||
|
||||
@@ -940,7 +940,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
$.each(this.frm.doc.taxes || [], function(i, d) {
|
||||
if(d.charge_type == "Actual") {
|
||||
frappe.model.set_value(d.doctype, d.name, "tax_amount",
|
||||
flt(d.tax_amount) / flt(exchange_rate));
|
||||
flt(d.base_tax_amount) / flt(exchange_rate));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -550,7 +550,7 @@ erpnext.utils.update_child_items = function(opts) {
|
||||
},
|
||||
],
|
||||
primary_action: function() {
|
||||
const trans_items = this.get_values()["trans_items"];
|
||||
const trans_items = this.get_values()["trans_items"].filter((item) => !!item.item_code);
|
||||
frappe.call({
|
||||
method: 'erpnext.controllers.accounts_controller.update_child_qty_rate',
|
||||
freeze: true,
|
||||
|
||||
@@ -414,7 +414,7 @@ def make_custom_fields(update=True):
|
||||
dict(fieldname='ack_date', label='Ack. Date', fieldtype='Data', read_only=1, hidden=1, insert_after='ack_no', no_copy=1, print_hide=1),
|
||||
|
||||
dict(fieldname='irn_cancelled', label='IRN Cancelled', fieldtype='Check', no_copy=1, print_hide=1,
|
||||
depends_on='eval:(doc.irn_cancelled === 1)', read_only=1, allow_on_submit=1, insert_after='customer'),
|
||||
depends_on='eval: doc.irn', allow_on_submit=1, insert_after='customer'),
|
||||
|
||||
dict(fieldname='eway_bill_cancelled', label='E-Way Bill Cancelled', fieldtype='Check', no_copy=1, print_hide=1,
|
||||
depends_on='eval:(doc.eway_bill_cancelled === 1)', read_only=1, allow_on_submit=1, insert_after='customer'),
|
||||
|
||||
@@ -30,12 +30,13 @@ def validate_gstin_for_india(doc, method):
|
||||
|
||||
gst_category = []
|
||||
|
||||
if len(doc.links):
|
||||
link_doctype = doc.links[0].get("link_doctype")
|
||||
link_name = doc.links[0].get("link_name")
|
||||
if hasattr(doc, 'gst_category'):
|
||||
if len(doc.links):
|
||||
link_doctype = doc.links[0].get("link_doctype")
|
||||
link_name = doc.links[0].get("link_name")
|
||||
|
||||
if link_doctype in ["Customer", "Supplier"]:
|
||||
gst_category = frappe.db.get_value(link_doctype, {'name': link_name}, ['gst_category'])
|
||||
if link_doctype in ["Customer", "Supplier"]:
|
||||
gst_category = frappe.db.get_value(link_doctype, {'name': link_name}, ['gst_category'])
|
||||
|
||||
doc.gstin = doc.gstin.upper().strip()
|
||||
if not doc.gstin or doc.gstin == 'NA':
|
||||
@@ -68,10 +69,9 @@ def validate_tax_category(doc, method):
|
||||
def update_gst_category(doc, method):
|
||||
for link in doc.links:
|
||||
if link.link_doctype in ['Customer', 'Supplier']:
|
||||
if doc.get('gstin'):
|
||||
frappe.db.sql("""
|
||||
UPDATE `tab{0}` SET gst_category = %s WHERE name = %s AND gst_category = 'Unregistered'
|
||||
""".format(link.link_doctype), ("Registered Regular", link.link_name)) #nosec
|
||||
meta = frappe.get_meta(link.link_doctype)
|
||||
if doc.get('gstin') and meta.has_field('gst_category'):
|
||||
frappe.db.set_value(link.link_doctype, {'name': link.link_name, 'gst_category': 'Unregistered'}, 'gst_category', 'Registered Regular')
|
||||
|
||||
def set_gst_state_and_state_number(doc):
|
||||
if not doc.gst_state:
|
||||
|
||||
@@ -104,14 +104,14 @@ def set_address_details(row, special_characters):
|
||||
row.update({'ship_to_state': row.to_state})
|
||||
|
||||
def set_taxes(row, filters):
|
||||
taxes = frappe.get_list("Sales Taxes and Charges",
|
||||
taxes = frappe.get_all("Sales Taxes and Charges",
|
||||
filters={
|
||||
'parent': row.dn_id
|
||||
},
|
||||
fields=('item_wise_tax_detail', 'account_head'))
|
||||
|
||||
account_list = ["cgst_account", "sgst_account", "igst_account", "cess_account"]
|
||||
taxes_list = frappe.get_list("GST Account",
|
||||
taxes_list = frappe.get_all("GST Account",
|
||||
filters={
|
||||
"parent": "GST Settings",
|
||||
"company": filters.company
|
||||
|
||||
@@ -714,8 +714,7 @@ def make_maintenance_schedule(source_name, target_doc=None):
|
||||
"doctype": "Maintenance Schedule Item",
|
||||
"field_map": {
|
||||
"parent": "sales_order"
|
||||
},
|
||||
"add_if_empty": True
|
||||
}
|
||||
}
|
||||
}, target_doc)
|
||||
|
||||
@@ -741,8 +740,7 @@ def make_maintenance_visit(source_name, target_doc=None):
|
||||
"field_map": {
|
||||
"parent": "prevdoc_docname",
|
||||
"parenttype": "prevdoc_doctype"
|
||||
},
|
||||
"add_if_empty": True
|
||||
}
|
||||
}
|
||||
}, target_doc)
|
||||
|
||||
|
||||
@@ -62,12 +62,12 @@ class TestCurrencyExchange(unittest.TestCase):
|
||||
|
||||
exchange_rate = get_exchange_rate("USD", "INR", "2016-01-30", "for_selling")
|
||||
self.assertEqual(exchange_rate, 62.9)
|
||||
|
||||
# Exchange rate as on 15th Dec, 2015, should be fetched from fixer.io
|
||||
|
||||
# Exchange rate as on 15th Dec, 2015
|
||||
self.clear_cache()
|
||||
exchange_rate = get_exchange_rate("USD", "INR", "2015-12-15", "for_selling")
|
||||
self.assertFalse(exchange_rate == 60)
|
||||
self.assertEqual(flt(exchange_rate, 3), 66.894)
|
||||
self.assertEqual(flt(exchange_rate, 3), 66.999)
|
||||
|
||||
def test_exchange_rate_strict(self):
|
||||
# strict currency settings
|
||||
@@ -77,28 +77,17 @@ class TestCurrencyExchange(unittest.TestCase):
|
||||
exchange_rate = get_exchange_rate("USD", "INR", "2016-01-01", "for_buying")
|
||||
self.assertEqual(exchange_rate, 60.0)
|
||||
|
||||
# Will fetch from fixer.io
|
||||
self.clear_cache()
|
||||
exchange_rate = get_exchange_rate("USD", "INR", "2016-01-15", "for_buying")
|
||||
self.assertEqual(flt(exchange_rate, 3), 67.79)
|
||||
self.assertEqual(flt(exchange_rate, 3), 67.235)
|
||||
|
||||
exchange_rate = get_exchange_rate("USD", "INR", "2016-01-30", "for_selling")
|
||||
self.assertEqual(exchange_rate, 62.9)
|
||||
|
||||
# Exchange rate as on 15th Dec, 2015, should be fetched from fixer.io
|
||||
# Exchange rate as on 15th Dec, 2015
|
||||
self.clear_cache()
|
||||
exchange_rate = get_exchange_rate("USD", "INR", "2015-12-15", "for_buying")
|
||||
self.assertEqual(flt(exchange_rate, 3), 66.894)
|
||||
|
||||
exchange_rate = get_exchange_rate("INR", "NGN", "2016-01-10", "for_selling")
|
||||
self.assertEqual(exchange_rate, 65.1)
|
||||
|
||||
# NGN is not available on fixer.io so these should return 0
|
||||
exchange_rate = get_exchange_rate("INR", "NGN", "2016-01-09", "for_selling")
|
||||
self.assertEqual(exchange_rate, 0)
|
||||
|
||||
exchange_rate = get_exchange_rate("INR", "NGN", "2016-01-11", "for_selling")
|
||||
self.assertEqual(exchange_rate, 0)
|
||||
self.assertEqual(flt(exchange_rate, 3), 66.999)
|
||||
|
||||
def test_exchange_rate_strict_switched(self):
|
||||
# Start with allow_stale is True
|
||||
@@ -111,4 +100,4 @@ class TestCurrencyExchange(unittest.TestCase):
|
||||
# Will fetch from fixer.io
|
||||
self.clear_cache()
|
||||
exchange_rate = get_exchange_rate("USD", "INR", "2016-01-15", "for_buying")
|
||||
self.assertEqual(flt(exchange_rate, 3), 67.79)
|
||||
self.assertEqual(flt(exchange_rate, 3), 67.235)
|
||||
|
||||
@@ -33,6 +33,7 @@ class ItemGroup(NestedSet, WebsiteGenerator):
|
||||
self.parent_item_group = _('All Item Groups')
|
||||
|
||||
self.make_route()
|
||||
self.validate_item_group_defaults()
|
||||
|
||||
def on_update(self):
|
||||
NestedSet.on_update(self)
|
||||
@@ -88,6 +89,10 @@ class ItemGroup(NestedSet, WebsiteGenerator):
|
||||
def delete_child_item_groups_key(self):
|
||||
frappe.cache().hdel("child_item_groups", self.name)
|
||||
|
||||
def validate_item_group_defaults(self):
|
||||
from erpnext.stock.doctype.item.item import validate_item_default_company_links
|
||||
validate_item_default_company_links(self.item_group_defaults)
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def get_product_list_for_group(product_group=None, start=0, limit=10, search=None):
|
||||
if product_group:
|
||||
|
||||
@@ -1,73 +1,74 @@
|
||||
[
|
||||
{
|
||||
"doctype": "Item Group",
|
||||
"is_group": 0,
|
||||
"item_group_name": "_Test Item Group",
|
||||
"doctype": "Item Group",
|
||||
"is_group": 0,
|
||||
"item_group_name": "_Test Item Group",
|
||||
"parent_item_group": "All Item Groups",
|
||||
"item_group_defaults": [{
|
||||
"company": "_Test Company",
|
||||
"buying_cost_center": "_Test Cost Center 2 - _TC",
|
||||
"selling_cost_center": "_Test Cost Center 2 - _TC"
|
||||
"selling_cost_center": "_Test Cost Center 2 - _TC",
|
||||
"default_warehouse": "_Test Warehouse - _TC"
|
||||
}]
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "Item Group",
|
||||
"is_group": 0,
|
||||
"item_group_name": "_Test Item Group Desktops",
|
||||
"doctype": "Item Group",
|
||||
"is_group": 0,
|
||||
"item_group_name": "_Test Item Group Desktops",
|
||||
"parent_item_group": "All Item Groups"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "Item Group",
|
||||
"is_group": 1,
|
||||
"item_group_name": "_Test Item Group A",
|
||||
"doctype": "Item Group",
|
||||
"is_group": 1,
|
||||
"item_group_name": "_Test Item Group A",
|
||||
"parent_item_group": "All Item Groups"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "Item Group",
|
||||
"is_group": 1,
|
||||
"item_group_name": "_Test Item Group B",
|
||||
"doctype": "Item Group",
|
||||
"is_group": 1,
|
||||
"item_group_name": "_Test Item Group B",
|
||||
"parent_item_group": "All Item Groups"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "Item Group",
|
||||
"is_group": 1,
|
||||
"item_group_name": "_Test Item Group B - 1",
|
||||
"doctype": "Item Group",
|
||||
"is_group": 1,
|
||||
"item_group_name": "_Test Item Group B - 1",
|
||||
"parent_item_group": "_Test Item Group B"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "Item Group",
|
||||
"is_group": 1,
|
||||
"item_group_name": "_Test Item Group B - 2",
|
||||
"doctype": "Item Group",
|
||||
"is_group": 1,
|
||||
"item_group_name": "_Test Item Group B - 2",
|
||||
"parent_item_group": "_Test Item Group B"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "Item Group",
|
||||
"is_group": 0,
|
||||
"item_group_name": "_Test Item Group B - 3",
|
||||
"doctype": "Item Group",
|
||||
"is_group": 0,
|
||||
"item_group_name": "_Test Item Group B - 3",
|
||||
"parent_item_group": "_Test Item Group B"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "Item Group",
|
||||
"is_group": 1,
|
||||
"item_group_name": "_Test Item Group C",
|
||||
"doctype": "Item Group",
|
||||
"is_group": 1,
|
||||
"item_group_name": "_Test Item Group C",
|
||||
"parent_item_group": "All Item Groups"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "Item Group",
|
||||
"is_group": 1,
|
||||
"item_group_name": "_Test Item Group C - 1",
|
||||
"doctype": "Item Group",
|
||||
"is_group": 1,
|
||||
"item_group_name": "_Test Item Group C - 1",
|
||||
"parent_item_group": "_Test Item Group C"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "Item Group",
|
||||
"is_group": 1,
|
||||
"item_group_name": "_Test Item Group C - 2",
|
||||
"doctype": "Item Group",
|
||||
"is_group": 1,
|
||||
"item_group_name": "_Test Item Group C - 2",
|
||||
"parent_item_group": "_Test Item Group C"
|
||||
},
|
||||
},
|
||||
{
|
||||
"doctype": "Item Group",
|
||||
"is_group": 1,
|
||||
"item_group_name": "_Test Item Group D",
|
||||
"doctype": "Item Group",
|
||||
"is_group": 1,
|
||||
"item_group_name": "_Test Item Group D",
|
||||
"parent_item_group": "All Item Groups"
|
||||
},
|
||||
{
|
||||
@@ -104,4 +105,4 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
@@ -175,9 +175,9 @@ def install(country=None):
|
||||
]},
|
||||
|
||||
# Issue Priority
|
||||
{'doctype': 'Issue Priority', 'name': _('Low')},
|
||||
{'doctype': 'Issue Priority', 'name': _('Medium')},
|
||||
{'doctype': 'Issue Priority', 'name': _('High')},
|
||||
{'doctype': 'Issue Priority', 'name': 'Low'},
|
||||
{'doctype': 'Issue Priority', 'name': 'Medium'},
|
||||
{'doctype': 'Issue Priority', 'name': 'High'},
|
||||
|
||||
#Job Applicant Source
|
||||
{'doctype': 'Job Applicant Source', 'source_name': _('Website Listing')},
|
||||
|
||||
@@ -93,20 +93,21 @@ def get_exchange_rate(from_currency, to_currency, transaction_date=None, args=No
|
||||
|
||||
try:
|
||||
cache = frappe.cache()
|
||||
key = "currency_exchange_rate_{0}:{1}:{2}".format(transaction_date,from_currency, to_currency)
|
||||
key = "currency_exchange_rate_{0}:{1}:{2}".format(transaction_date, from_currency, to_currency)
|
||||
value = cache.get(key)
|
||||
|
||||
if not value:
|
||||
import requests
|
||||
api_url = "https://frankfurter.app/{0}".format(transaction_date)
|
||||
api_url = "https://api.exchangerate.host/convert"
|
||||
response = requests.get(api_url, params={
|
||||
"base": from_currency,
|
||||
"symbols": to_currency
|
||||
"date": transaction_date,
|
||||
"from": from_currency,
|
||||
"to": to_currency
|
||||
})
|
||||
# expire in 6 hours
|
||||
response.raise_for_status()
|
||||
value = response.json()["rates"][to_currency]
|
||||
cache.setex(key, value, 6 * 60 * 60)
|
||||
value = response.json()["result"]
|
||||
cache.setex(name=key, time=21600, value=flt(value))
|
||||
return flt(value)
|
||||
except:
|
||||
frappe.log_error(title="Get Exchange Rate")
|
||||
|
||||
@@ -175,7 +175,9 @@ def add_new_address(doc):
|
||||
def create_lead_for_item_inquiry(lead, subject, message):
|
||||
lead = frappe.parse_json(lead)
|
||||
lead_doc = frappe.new_doc('Lead')
|
||||
lead_doc.update(lead)
|
||||
for fieldname in ("lead_name", "company_name", "email_id", "phone"):
|
||||
lead_doc.set(fieldname, lead.get(fieldname))
|
||||
|
||||
lead_doc.set('lead_owner', '')
|
||||
|
||||
try:
|
||||
@@ -206,11 +208,11 @@ def update_cart_address(address_type, address_name):
|
||||
if address_type.lower() == "billing":
|
||||
quotation.customer_address = address_name
|
||||
quotation.address_display = address_display
|
||||
quotation.shipping_address_name == quotation.shipping_address_name or address_name
|
||||
quotation.shipping_address_name = quotation.shipping_address_name or address_name
|
||||
elif address_type.lower() == "shipping":
|
||||
quotation.shipping_address_name = address_name
|
||||
quotation.shipping_address = address_display
|
||||
quotation.customer_address == quotation.customer_address or address_name
|
||||
quotation.customer_address = quotation.customer_address or address_name
|
||||
|
||||
apply_cart_settings(quotation=quotation)
|
||||
|
||||
@@ -279,7 +281,7 @@ def update_party(fullname, company_name=None, mobile_no=None, phone=None):
|
||||
party = get_party()
|
||||
|
||||
party.customer_name = company_name or fullname
|
||||
party.customer_type == "Company" if company_name else "Individual"
|
||||
party.customer_type = "Company" if company_name else "Individual"
|
||||
|
||||
contact_name = frappe.db.get_value("Contact", {"email_id": frappe.session.user})
|
||||
contact = frappe.get_doc("Contact", contact_name)
|
||||
|
||||
@@ -85,7 +85,7 @@ frappe.ui.form.on("Item", {
|
||||
}
|
||||
if (frm.doc.variant_of) {
|
||||
frm.set_intro(__('This Item is a Variant of {0} (Template).',
|
||||
[`<a href="/app/item/${frm.doc.variant_of}" onclick="location.reload()">${frm.doc.variant_of}</a>`]), true);
|
||||
[`<a href="#Form/Item/${frm.doc.variant_of}" target="_blank">${frm.doc.variant_of}</a>`]), true);
|
||||
}
|
||||
|
||||
if (frappe.defaults.get_default("item_naming_by")!="Naming Series" || frm.doc.variant_of) {
|
||||
|
||||
@@ -6,6 +6,7 @@ from __future__ import unicode_literals
|
||||
import itertools
|
||||
import json
|
||||
import erpnext
|
||||
|
||||
import frappe
|
||||
import copy
|
||||
from erpnext.controllers.item_variant import (ItemVariantExistsError,
|
||||
@@ -121,9 +122,9 @@ class Item(WebsiteGenerator):
|
||||
self.validate_fixed_asset()
|
||||
self.validate_retain_sample()
|
||||
self.validate_uom_conversion_factor()
|
||||
self.validate_item_defaults()
|
||||
self.validate_customer_provided_part()
|
||||
self.update_defaults_from_item_group()
|
||||
self.validate_item_defaults()
|
||||
self.validate_auto_reorder_enabled_in_stock_settings()
|
||||
self.cant_change()
|
||||
self.update_show_in_website()
|
||||
@@ -205,10 +206,11 @@ class Item(WebsiteGenerator):
|
||||
'route')) + '/' + self.scrub((self.item_name if self.item_name else self.item_code) + '-' + random_string(5))
|
||||
|
||||
def validate_website_image(self):
|
||||
"""Validate if the website image is a public file"""
|
||||
|
||||
if frappe.flags.in_import:
|
||||
return
|
||||
|
||||
"""Validate if the website image is a public file"""
|
||||
auto_set_website_image = False
|
||||
if not self.website_image and self.image:
|
||||
auto_set_website_image = True
|
||||
@@ -238,10 +240,11 @@ class Item(WebsiteGenerator):
|
||||
self.website_image = None
|
||||
|
||||
def make_thumbnail(self):
|
||||
"""Make a thumbnail of `website_image`"""
|
||||
|
||||
if frappe.flags.in_import:
|
||||
return
|
||||
|
||||
"""Make a thumbnail of `website_image`"""
|
||||
import requests.exceptions
|
||||
|
||||
if not self.is_new() and self.website_image != frappe.db.get_value(self.doctype, self.name, "website_image"):
|
||||
@@ -687,7 +690,6 @@ class Item(WebsiteGenerator):
|
||||
|
||||
def recalculate_bin_qty(self, new_name):
|
||||
from erpnext.stock.stock_balance import repost_stock
|
||||
frappe.db.auto_commit_on_many_writes = 1
|
||||
existing_allow_negative_stock = frappe.db.get_value("Stock Settings", None, "allow_negative_stock")
|
||||
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
|
||||
|
||||
@@ -701,7 +703,6 @@ class Item(WebsiteGenerator):
|
||||
repost_stock(new_name, warehouse)
|
||||
|
||||
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", existing_allow_negative_stock)
|
||||
frappe.db.auto_commit_on_many_writes = 0
|
||||
|
||||
def copy_specification_from_item_group(self):
|
||||
self.set("website_specifications", [])
|
||||
@@ -758,35 +759,39 @@ class Item(WebsiteGenerator):
|
||||
if len(companies) != len(self.item_defaults):
|
||||
frappe.throw(_("Cannot set multiple Item Defaults for a company."))
|
||||
|
||||
validate_item_default_company_links(self.item_defaults)
|
||||
|
||||
|
||||
def update_defaults_from_item_group(self):
|
||||
"""Get defaults from Item Group"""
|
||||
if self.item_group and not self.item_defaults:
|
||||
item_defaults = frappe.db.get_values("Item Default", {"parent": self.item_group},
|
||||
['company', 'default_warehouse','default_price_list','buying_cost_center','default_supplier',
|
||||
'expense_account','selling_cost_center','income_account'], as_dict = 1)
|
||||
if item_defaults:
|
||||
for item in item_defaults:
|
||||
self.append('item_defaults', {
|
||||
'company': item.company,
|
||||
'default_warehouse': item.default_warehouse,
|
||||
'default_price_list': item.default_price_list,
|
||||
'buying_cost_center': item.buying_cost_center,
|
||||
'default_supplier': item.default_supplier,
|
||||
'expense_account': item.expense_account,
|
||||
'selling_cost_center': item.selling_cost_center,
|
||||
'income_account': item.income_account
|
||||
})
|
||||
else:
|
||||
warehouse = ''
|
||||
defaults = frappe.defaults.get_defaults() or {}
|
||||
if self.item_defaults or not self.item_group:
|
||||
return
|
||||
|
||||
# To check default warehouse is belong to the default company
|
||||
if defaults.get("default_warehouse") and defaults.company and frappe.db.exists("Warehouse",
|
||||
{'name': defaults.default_warehouse, 'company': defaults.company}):
|
||||
self.append("item_defaults", {
|
||||
"company": defaults.get("company"),
|
||||
"default_warehouse": defaults.default_warehouse
|
||||
})
|
||||
item_defaults = frappe.db.get_values("Item Default", {"parent": self.item_group},
|
||||
['company', 'default_warehouse','default_price_list','buying_cost_center','default_supplier',
|
||||
'expense_account','selling_cost_center','income_account'], as_dict = 1)
|
||||
if item_defaults:
|
||||
for item in item_defaults:
|
||||
self.append('item_defaults', {
|
||||
'company': item.company,
|
||||
'default_warehouse': item.default_warehouse,
|
||||
'default_price_list': item.default_price_list,
|
||||
'buying_cost_center': item.buying_cost_center,
|
||||
'default_supplier': item.default_supplier,
|
||||
'expense_account': item.expense_account,
|
||||
'selling_cost_center': item.selling_cost_center,
|
||||
'income_account': item.income_account
|
||||
})
|
||||
else:
|
||||
defaults = frappe.defaults.get_defaults() or {}
|
||||
|
||||
# To check default warehouse is belong to the default company
|
||||
if defaults.get("default_warehouse") and defaults.company and frappe.db.exists("Warehouse",
|
||||
{'name': defaults.default_warehouse, 'company': defaults.company}):
|
||||
self.append("item_defaults", {
|
||||
"company": defaults.get("company"),
|
||||
"default_warehouse": defaults.default_warehouse
|
||||
})
|
||||
|
||||
def update_variants(self):
|
||||
if self.flags.dont_update_variants or \
|
||||
@@ -1237,3 +1242,24 @@ def update_variants(variants, template, publish_progress=True):
|
||||
def on_doctype_update():
|
||||
# since route is a Text column, it needs a length for indexing
|
||||
frappe.db.add_index("Item", ["route(500)"])
|
||||
|
||||
def validate_item_default_company_links(item_defaults):
|
||||
for item_default in item_defaults:
|
||||
for doctype, field in [
|
||||
['Warehouse', 'default_warehouse'],
|
||||
['Cost Center', 'buying_cost_center'],
|
||||
['Cost Center', 'selling_cost_center'],
|
||||
['Account', 'expense_account'],
|
||||
['Account', 'income_account']
|
||||
]:
|
||||
if item_default.get(field):
|
||||
company = frappe.db.get_value(doctype, item_default.get(field), 'company', cache=True)
|
||||
if company and company != item_default.company:
|
||||
frappe.throw(_("Row #{}: {} {} doesn't belong to Company {}. Please select valid {}.")
|
||||
.format(
|
||||
item_default.idx,
|
||||
doctype,
|
||||
frappe.bold(item_default.get(field)),
|
||||
frappe.bold(item_default.company),
|
||||
frappe.bold(frappe.unscrub(field))
|
||||
), title=_("Invalid Item Defaults"))
|
||||
|
||||
@@ -219,6 +219,23 @@ class TestItem(unittest.TestCase):
|
||||
for key, value in iteritems(purchase_item_check):
|
||||
self.assertEqual(value, purchase_item_details.get(key))
|
||||
|
||||
def test_item_default_validations(self):
|
||||
|
||||
with self.assertRaises(frappe.ValidationError) as ve:
|
||||
make_item("Bad Item defaults", {
|
||||
"item_group": "_Test Item Group",
|
||||
"item_defaults": [{
|
||||
"company": "_Test Company 1",
|
||||
"default_warehouse": "_Test Warehouse - _TC",
|
||||
"expense_account": "Stock In Hand - _TC",
|
||||
"buying_cost_center": "_Test Cost Center - _TC",
|
||||
"selling_cost_center": "_Test Cost Center - _TC",
|
||||
}]
|
||||
})
|
||||
|
||||
self.assertTrue("belong to company" in str(ve.exception).lower(),
|
||||
msg="Mismatching company entities in item defaults should not be allowed.")
|
||||
|
||||
def test_item_attribute_change_after_variant(self):
|
||||
frappe.delete_doc_if_exists("Item", "_Test Variant Item-L", force=1)
|
||||
|
||||
@@ -451,7 +468,7 @@ class TestItem(unittest.TestCase):
|
||||
item_doc.save()
|
||||
|
||||
# Check values saved correctly
|
||||
barcodes = frappe.get_list(
|
||||
barcodes = frappe.get_all(
|
||||
'Item Barcode',
|
||||
fields=['barcode', 'barcode_type'],
|
||||
filters={'parent': item_code})
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
"fieldname": "qty",
|
||||
"fieldtype": "Float",
|
||||
"in_list_view": 1,
|
||||
"label": "Qty"
|
||||
"label": "Qty",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "picked_qty",
|
||||
@@ -180,7 +181,7 @@
|
||||
],
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2020-03-13 19:08:21.995986",
|
||||
"modified": "2021-09-28 12:02:16.923056",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Pick List Item",
|
||||
@@ -190,4 +191,4 @@
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ frappe.ui.form.on("Purchase Receipt", {
|
||||
frappe.set_route("Form", lcv.doctype, lcv.name);
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
frm.custom_make_buttons = {
|
||||
'Stock Entry': 'Return',
|
||||
'Purchase Invoice': 'Purchase Invoice'
|
||||
@@ -34,7 +34,7 @@ frappe.ui.form.on("Purchase Receipt", {
|
||||
filters: {'company': frm.doc.company }
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
onload: function(frm) {
|
||||
erpnext.queries.setup_queries(frm, "Warehouse", function() {
|
||||
@@ -107,6 +107,8 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
|
||||
message: __("Please Select a Supplier")
|
||||
});
|
||||
}
|
||||
|
||||
me.frm.doc.taxes = [];
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_receipt",
|
||||
source_doctype: "Purchase Order",
|
||||
|
||||
@@ -78,7 +78,11 @@ frappe.ui.form.on('Stock Entry', {
|
||||
}
|
||||
}
|
||||
|
||||
filters["warehouse"] = item.s_warehouse || item.t_warehouse;
|
||||
// User could want to select a manually created empty batch (no warehouse)
|
||||
// or a pre-existing batch
|
||||
if (frm.doc.purpose != "Material Receipt") {
|
||||
filters["warehouse"] = item.s_warehouse || item.t_warehouse;
|
||||
}
|
||||
|
||||
return {
|
||||
query : "erpnext.controllers.queries.get_batch_no",
|
||||
@@ -282,6 +286,12 @@ frappe.ui.form.on('Stock Entry', {
|
||||
frm.trigger("setup_quality_inspection");
|
||||
},
|
||||
|
||||
before_save: function(frm) {
|
||||
frm.doc.items.forEach((item) => {
|
||||
item.uom = item.uom || item.stock_uom;
|
||||
})
|
||||
},
|
||||
|
||||
purpose: function(frm) {
|
||||
frm.trigger('validate_purpose_consumption');
|
||||
frm.fields_dict.items.grid.refresh();
|
||||
|
||||
@@ -537,6 +537,11 @@ def get_stock_balance_for(item_code, warehouse,
|
||||
item_dict = frappe.db.get_value("Item", item_code,
|
||||
["has_serial_no", "has_batch_no"], as_dict=1)
|
||||
|
||||
if not item_dict:
|
||||
# In cases of data upload to Items table
|
||||
msg = _("Item {} does not exist.").format(item_code)
|
||||
frappe.throw(msg, title=_("Missing"))
|
||||
|
||||
serial_nos = ""
|
||||
with_serial_no = True if item_dict.get("has_serial_no") else False
|
||||
data = get_stock_balance(item_code, warehouse, posting_date, posting_time,
|
||||
|
||||
@@ -32,64 +32,6 @@ class TestWarehouse(unittest.TestCase):
|
||||
self.assertEqual(p_warehouse.name, child_warehouse.parent_warehouse)
|
||||
self.assertEqual(child_warehouse.is_group, 0)
|
||||
|
||||
def test_warehouse_renaming(self):
|
||||
set_perpetual_inventory(1)
|
||||
create_warehouse("Test Warehouse for Renaming 1")
|
||||
account = get_inventory_account("_Test Company", "Test Warehouse for Renaming 1 - _TC")
|
||||
self.assertTrue(frappe.db.get_value("Warehouse", filters={"account": account}))
|
||||
|
||||
# Rename with abbr
|
||||
if frappe.db.exists("Warehouse", "Test Warehouse for Renaming 2 - _TC"):
|
||||
frappe.delete_doc("Warehouse", "Test Warehouse for Renaming 2 - _TC")
|
||||
rename_doc("Warehouse", "Test Warehouse for Renaming 1 - _TC", "Test Warehouse for Renaming 2 - _TC")
|
||||
|
||||
self.assertTrue(frappe.db.get_value("Warehouse",
|
||||
filters={"account": "Test Warehouse for Renaming 1 - _TC"}))
|
||||
|
||||
# Rename without abbr
|
||||
if frappe.db.exists("Warehouse", "Test Warehouse for Renaming 3 - _TC"):
|
||||
frappe.delete_doc("Warehouse", "Test Warehouse for Renaming 3 - _TC")
|
||||
|
||||
rename_doc("Warehouse", "Test Warehouse for Renaming 2 - _TC", "Test Warehouse for Renaming 3")
|
||||
|
||||
self.assertTrue(frappe.db.get_value("Warehouse",
|
||||
filters={"account": "Test Warehouse for Renaming 1 - _TC"}))
|
||||
|
||||
# Another rename with multiple dashes
|
||||
if frappe.db.exists("Warehouse", "Test - Warehouse - Company - _TC"):
|
||||
frappe.delete_doc("Warehouse", "Test - Warehouse - Company - _TC")
|
||||
rename_doc("Warehouse", "Test Warehouse for Renaming 3 - _TC", "Test - Warehouse - Company")
|
||||
|
||||
def test_warehouse_merging(self):
|
||||
set_perpetual_inventory(1)
|
||||
|
||||
create_warehouse("Test Warehouse for Merging 1")
|
||||
create_warehouse("Test Warehouse for Merging 2")
|
||||
|
||||
make_stock_entry(item_code="_Test Item", target="Test Warehouse for Merging 1 - _TC",
|
||||
qty=1, rate=100)
|
||||
make_stock_entry(item_code="_Test Item", target="Test Warehouse for Merging 2 - _TC",
|
||||
qty=1, rate=100)
|
||||
|
||||
existing_bin_qty = (
|
||||
cint(frappe.db.get_value("Bin",
|
||||
{"item_code": "_Test Item", "warehouse": "Test Warehouse for Merging 1 - _TC"}, "actual_qty"))
|
||||
+ cint(frappe.db.get_value("Bin",
|
||||
{"item_code": "_Test Item", "warehouse": "Test Warehouse for Merging 2 - _TC"}, "actual_qty"))
|
||||
)
|
||||
|
||||
rename_doc("Warehouse", "Test Warehouse for Merging 1 - _TC",
|
||||
"Test Warehouse for Merging 2 - _TC", merge=True)
|
||||
|
||||
self.assertFalse(frappe.db.exists("Warehouse", "Test Warehouse for Merging 1 - _TC"))
|
||||
|
||||
bin_qty = frappe.db.get_value("Bin",
|
||||
{"item_code": "_Test Item", "warehouse": "Test Warehouse for Merging 2 - _TC"}, "actual_qty")
|
||||
|
||||
self.assertEqual(bin_qty, existing_bin_qty)
|
||||
|
||||
self.assertTrue(frappe.db.get_value("Warehouse",
|
||||
filters={"account": "Test Warehouse for Merging 2 - _TC"}))
|
||||
|
||||
def create_warehouse(warehouse_name, properties=None, company=None):
|
||||
if not company:
|
||||
@@ -145,4 +87,4 @@ def get_group_stock_account(company, company_abbr=None):
|
||||
if not company_abbr:
|
||||
company_abbr = frappe.get_cached_value("Company", company, 'abbr')
|
||||
group_stock_account = "Current Assets - " + company_abbr
|
||||
return group_stock_account
|
||||
return group_stock_account
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
"creation": "2013-03-07 18:50:32",
|
||||
"description": "A logical Warehouse against which stock entries are made.",
|
||||
"doctype": "DocType",
|
||||
@@ -235,7 +234,7 @@
|
||||
"idx": 1,
|
||||
"is_tree": 1,
|
||||
"links": [],
|
||||
"modified": "2020-08-03 18:41:52.442502",
|
||||
"modified": "2021-12-03 04:40:06.414630",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Warehouse",
|
||||
|
||||
@@ -7,6 +7,7 @@ from frappe.utils import cint, flt
|
||||
from frappe import throw, _
|
||||
from collections import defaultdict
|
||||
from frappe.utils.nestedset import NestedSet
|
||||
|
||||
from erpnext.stock import get_warehouse_account
|
||||
from frappe.contacts.address_and_contact import load_address_and_contact
|
||||
|
||||
@@ -63,57 +64,6 @@ class Warehouse(NestedSet):
|
||||
return frappe.db.sql("""select name from `tabWarehouse`
|
||||
where parent_warehouse = %s limit 1""", self.name)
|
||||
|
||||
def before_rename(self, old_name, new_name, merge=False):
|
||||
super(Warehouse, self).before_rename(old_name, new_name, merge)
|
||||
|
||||
# Add company abbr if not provided
|
||||
new_warehouse = erpnext.encode_company_abbr(new_name, self.company)
|
||||
|
||||
if merge:
|
||||
if not frappe.db.exists("Warehouse", new_warehouse):
|
||||
frappe.throw(_("Warehouse {0} does not exist").format(new_warehouse))
|
||||
|
||||
if self.company != frappe.db.get_value("Warehouse", new_warehouse, "company"):
|
||||
frappe.throw(_("Both Warehouse must belong to same Company"))
|
||||
|
||||
return new_warehouse
|
||||
|
||||
def after_rename(self, old_name, new_name, merge=False):
|
||||
super(Warehouse, self).after_rename(old_name, new_name, merge)
|
||||
|
||||
new_warehouse_name = self.get_new_warehouse_name_without_abbr(new_name)
|
||||
self.db_set("warehouse_name", new_warehouse_name)
|
||||
|
||||
if merge:
|
||||
self.recalculate_bin_qty(new_name)
|
||||
|
||||
def get_new_warehouse_name_without_abbr(self, name):
|
||||
company_abbr = frappe.get_cached_value('Company', self.company, "abbr")
|
||||
parts = name.rsplit(" - ", 1)
|
||||
|
||||
if parts[-1].lower() == company_abbr.lower():
|
||||
name = parts[0]
|
||||
|
||||
return name
|
||||
|
||||
def recalculate_bin_qty(self, new_name):
|
||||
from erpnext.stock.stock_balance import repost_stock
|
||||
frappe.db.auto_commit_on_many_writes = 1
|
||||
existing_allow_negative_stock = frappe.db.get_value("Stock Settings", None, "allow_negative_stock")
|
||||
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
|
||||
|
||||
repost_stock_for_items = frappe.db.sql_list("""select distinct item_code
|
||||
from tabBin where warehouse=%s""", new_name)
|
||||
|
||||
# Delete all existing bins to avoid duplicate bins for the same item and warehouse
|
||||
frappe.db.sql("delete from `tabBin` where warehouse=%s", new_name)
|
||||
|
||||
for item_code in repost_stock_for_items:
|
||||
repost_stock(item_code, new_name)
|
||||
|
||||
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", existing_allow_negative_stock)
|
||||
frappe.db.auto_commit_on_many_writes = 0
|
||||
|
||||
def convert_to_group_or_ledger(self):
|
||||
if self.is_group:
|
||||
self.convert_to_ledger()
|
||||
@@ -232,4 +182,4 @@ def get_warehouses_based_on_account(account, company=None):
|
||||
frappe.throw(_("Warehouse not found against the account {0}")
|
||||
.format(account))
|
||||
|
||||
return warehouses
|
||||
return warehouses
|
||||
|
||||
@@ -72,9 +72,7 @@ def get_item_details(args, doc=None, for_validate=False, overwrite_warehouse=Tru
|
||||
|
||||
update_party_blanket_order(args, out)
|
||||
|
||||
if not doc or cint(doc.get('is_return')) == 0:
|
||||
# get price list rate only if the invoice is not a credit or debit note
|
||||
get_price_list_rate(args, item, out)
|
||||
get_price_list_rate(args, item, out)
|
||||
|
||||
if args.customer and cint(args.is_pos):
|
||||
out.update(get_pos_profile_item_details(args.company, args, update_data=True))
|
||||
@@ -331,7 +329,7 @@ def get_basic_details(args, item, overwrite_warehouse=True):
|
||||
if not out[d[1]]:
|
||||
out[d[1]] = frappe.get_cached_value('Company', args.company, d[2]) if d[2] else None
|
||||
|
||||
for fieldname in ("item_name", "item_group", "barcodes", "brand", "stock_uom"):
|
||||
for fieldname in ("item_name", "item_group", "brand", "stock_uom"):
|
||||
out[fieldname] = item.get(fieldname)
|
||||
|
||||
if args.get("manufacturer"):
|
||||
|
||||
@@ -175,9 +175,7 @@ def get_fifo_queue(filters, sle=None):
|
||||
fifo_queue.append([d.actual_qty, d.posting_date])
|
||||
else:
|
||||
if serial_no_list:
|
||||
for serial_no in fifo_queue:
|
||||
if serial_no[0] in serial_no_list:
|
||||
fifo_queue.remove(serial_no)
|
||||
fifo_queue[:] = [serial_no for serial_no in fifo_queue if serial_no[0] not in serial_no_list]
|
||||
else:
|
||||
qty_to_pop = abs(d.actual_qty)
|
||||
while qty_to_pop:
|
||||
|
||||
@@ -15,8 +15,6 @@ from six import iteritems
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
|
||||
validate_filters(filters)
|
||||
|
||||
from_date = filters.get('from_date')
|
||||
to_date = filters.get('to_date')
|
||||
|
||||
@@ -293,12 +291,6 @@ def get_item_reorder_details(items):
|
||||
|
||||
return dict((d.parent + d.warehouse, d) for d in item_reorder_details)
|
||||
|
||||
def validate_filters(filters):
|
||||
if not (filters.get("item_code") or filters.get("warehouse")):
|
||||
sle_count = flt(frappe.db.sql("""select count(name) from `tabStock Ledger Entry`""")[0][0])
|
||||
if sle_count > 500000:
|
||||
frappe.throw(_("Please set filter based on Item or Warehouse due to a large amount of entries."))
|
||||
|
||||
def get_variants_attributes():
|
||||
'''Return all item variant attributes.'''
|
||||
return [i.name for i in frappe.get_all('Item Attribute')]
|
||||
|
||||
@@ -39,8 +39,8 @@ def execute(filters=None):
|
||||
item_balance.setdefault((item, item_map[item]["item_group"]), [])
|
||||
total_stock_value = 0.00
|
||||
for wh in warehouse_list:
|
||||
row += [qty_dict.bal_qty] if wh.name in warehouse else [0.00]
|
||||
total_stock_value += qty_dict.bal_val if wh.name in warehouse else 0.00
|
||||
row += [qty_dict.bal_qty] if wh.name == warehouse else [0.00]
|
||||
total_stock_value += qty_dict.bal_val if wh.name == warehouse else 0.00
|
||||
|
||||
item_balance[(item, item_map[item]["item_group"])].append(row)
|
||||
item_value.setdefault((item, item_map[item]["item_group"]),[])
|
||||
|
||||
@@ -316,13 +316,16 @@ def update_included_uom_in_report(columns, result, include_uom, conversion_facto
|
||||
for row_idx, row in enumerate(result):
|
||||
data = row.items() if is_dict_obj else enumerate(row)
|
||||
for key, value in data:
|
||||
if key not in convertible_columns or not conversion_factors[row_idx-1]:
|
||||
if key not in convertible_columns:
|
||||
continue
|
||||
# If no conversion factor for the UOM, defaults to 1
|
||||
if not conversion_factors[row_idx]:
|
||||
conversion_factors[row_idx] = 1
|
||||
|
||||
if convertible_columns.get(key) == 'rate':
|
||||
new_value = flt(value) * conversion_factors[row_idx-1]
|
||||
new_value = flt(value) * conversion_factors[row_idx]
|
||||
else:
|
||||
new_value = flt(value) / conversion_factors[row_idx-1]
|
||||
new_value = flt(value) / conversion_factors[row_idx]
|
||||
|
||||
if not is_dict_obj:
|
||||
row.insert(key+1, new_value)
|
||||
@@ -370,4 +373,4 @@ def add_additional_uom_columns(columns, result, include_uom, conversion_factors)
|
||||
else:
|
||||
row[data.converted_col] = flt(value_before_conversion) / conversion_factor
|
||||
|
||||
result[row_idx] = row
|
||||
result[row_idx] = row
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
braintree==3.57.1
|
||||
frappe
|
||||
# frappe # https://github.com/frappe/frappe is installed during bench-init
|
||||
gocardless-pro==1.11.0
|
||||
googlemaps==3.1.1
|
||||
pandas==0.24.2
|
||||
plaid-python>=7.0.0
|
||||
pandas>=0.24.0,<1.2.0
|
||||
plaid-python~=7.2.1
|
||||
PyGithub==1.44.1
|
||||
python-stdnum==1.12
|
||||
Unidecode==1.1.1
|
||||
WooCommerce==2.1.1
|
||||
pycryptodome==3.9.8
|
||||
|
||||
Reference in New Issue
Block a user