mirror of
https://github.com/frappe/erpnext.git
synced 2025-12-03 18:35:36 +00:00
Compare commits
17 Commits
add-einvoi
...
v7.0.x
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a558683e40 | ||
|
|
03a3c852c3 | ||
|
|
13bd69c27d | ||
|
|
27affe4c5e | ||
|
|
d85f149b5e | ||
|
|
d275f0ec7f | ||
|
|
1b4e9898ce | ||
|
|
37b1b613f5 | ||
|
|
594642441b | ||
|
|
e803adc4e3 | ||
|
|
f7ac1236ed | ||
|
|
9600b29399 | ||
|
|
9f6a09e661 | ||
|
|
ab5e7fecb0 | ||
|
|
6f4e1ed96c | ||
|
|
b337b7208d | ||
|
|
6996bb0826 |
@@ -44,18 +44,25 @@ class GLEntry(Document):
|
||||
frappe.throw(_("{0} is required").format(_(self.meta.get_label(k))))
|
||||
|
||||
account_type = frappe.db.get_value("Account", self.account, "account_type")
|
||||
if account_type in ["Receivable", "Payable"] and not (self.party_type and self.party):
|
||||
frappe.throw(_("Party Type and Party is required for Receivable / Payable account {0}").format(self.account))
|
||||
|
||||
if not (self.party_type and self.party):
|
||||
if account_type == "Receivable":
|
||||
frappe.throw(_("{0} {1}: Customer is required against Receivable account {2}")
|
||||
.format(self.voucher_type, self.voucher_no, self.account))
|
||||
elif account_type == "Payable":
|
||||
frappe.throw(_("{0} {1}: Supplier is required against Payable account {2}")
|
||||
.format(self.voucher_type, self.voucher_no, self.account))
|
||||
|
||||
# Zero value transaction is not allowed
|
||||
if not (flt(self.debit) or flt(self.credit)):
|
||||
frappe.throw(_("Either debit or credit amount is required for {0}").format(self.account))
|
||||
frappe.throw(_("{0} {1}: Either debit or credit amount is required for {2}")
|
||||
.format(self.voucher_type, self.voucher_no, self.account))
|
||||
|
||||
def pl_must_have_cost_center(self):
|
||||
if frappe.db.get_value("Account", self.account, "report_type") == "Profit and Loss":
|
||||
if not self.cost_center and self.voucher_type != 'Period Closing Voucher':
|
||||
frappe.throw(_("Cost Center is required for 'Profit and Loss' account {0}")
|
||||
.format(self.account))
|
||||
frappe.throw(_("{0} {1}: Cost Center is required for 'Profit and Loss' account {2}. Please set up a default Cost Center for the Company.")
|
||||
.format(self.voucher_type, self.voucher_no, self.account))
|
||||
else:
|
||||
if self.cost_center:
|
||||
self.cost_center = None
|
||||
@@ -65,7 +72,8 @@ class GLEntry(Document):
|
||||
def check_pl_account(self):
|
||||
if self.is_opening=='Yes' and \
|
||||
frappe.db.get_value("Account", self.account, "report_type")=="Profit and Loss":
|
||||
frappe.throw(_("'Profit and Loss' type account {0} not allowed in Opening Entry").format(self.account))
|
||||
frappe.throw(_("{0} {1}: 'Profit and Loss' type account {2} not allowed in Opening Entry")
|
||||
.format(self.voucher_type, self.voucher_no, self.account))
|
||||
|
||||
def validate_account_details(self, adv_adj):
|
||||
"""Account must be ledger, active and not freezed"""
|
||||
@@ -74,13 +82,16 @@ class GLEntry(Document):
|
||||
from tabAccount where name=%s""", self.account, as_dict=1)[0]
|
||||
|
||||
if ret.is_group==1:
|
||||
frappe.throw(_("Account {0} cannot be a Group").format(self.account))
|
||||
frappe.throw(_("{0} {1}: Account {2} cannot be a Group")
|
||||
.format(self.voucher_type, self.voucher_no, self.account))
|
||||
|
||||
if ret.docstatus==2:
|
||||
frappe.throw(_("Account {0} is inactive").format(self.account))
|
||||
frappe.throw(_("{0} {1}: Account {2} is inactive")
|
||||
.format(self.voucher_type, self.voucher_no, self.account))
|
||||
|
||||
if ret.company != self.company:
|
||||
frappe.throw(_("Account {0} does not belong to Company {1}").format(self.account, self.company))
|
||||
frappe.throw(_("{0} {1}: Account {2} does not belong to Company {3}")
|
||||
.format(self.voucher_type, self.voucher_no, self.account, self.company))
|
||||
|
||||
def validate_cost_center(self):
|
||||
if not hasattr(self, "cost_center_company"):
|
||||
@@ -94,7 +105,8 @@ class GLEntry(Document):
|
||||
return self.cost_center_company[self.cost_center]
|
||||
|
||||
if self.cost_center and _get_cost_center_company() != self.company:
|
||||
frappe.throw(_("Cost Center {0} does not belong to Company {1}").format(self.cost_center, self.company))
|
||||
frappe.throw(_("{0} {1}: Cost Center {2} does not belong to Company {3}")
|
||||
.format(self.voucher_type, self.voucher_no, self.cost_center, self.company))
|
||||
|
||||
def validate_party(self):
|
||||
validate_party_frozen_disabled(self.party_type, self.party)
|
||||
@@ -107,8 +119,9 @@ class GLEntry(Document):
|
||||
self.account_currency = company_currency
|
||||
|
||||
if account_currency != self.account_currency:
|
||||
frappe.throw(_("Accounting Entry for {0} can only be made in currency: {1}")
|
||||
.format(self.account, (account_currency or company_currency)), InvalidAccountCurrency)
|
||||
frappe.throw(_("{0} {1}: Accounting Entry for {2} can only be made in currency: {3}")
|
||||
.format(self.voucher_type, self.voucher_no, self.account,
|
||||
(account_currency or company_currency)), InvalidAccountCurrency)
|
||||
|
||||
if self.party_type and self.party:
|
||||
validate_party_gle_currency(self.party_type, self.party, self.company, self.account_currency)
|
||||
|
||||
@@ -760,7 +760,8 @@ def get_party_account_and_balance(company, party_type, party):
|
||||
return {
|
||||
"account": account,
|
||||
"balance": account_balance,
|
||||
"party_balance": party_balance
|
||||
"party_balance": party_balance,
|
||||
"account_currency": frappe.db.get_value("Account", account, "account_currency")
|
||||
}
|
||||
|
||||
@frappe.whitelist()
|
||||
|
||||
@@ -305,24 +305,7 @@ class PurchaseInvoice(BuyingController):
|
||||
if not self.grand_total:
|
||||
return
|
||||
|
||||
self.auto_accounting_for_stock = \
|
||||
cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
|
||||
|
||||
self.stock_received_but_not_billed = self.get_company_default("stock_received_but_not_billed")
|
||||
self.expenses_included_in_valuation = self.get_company_default("expenses_included_in_valuation")
|
||||
self.negative_expense_to_be_booked = 0.0
|
||||
gl_entries = []
|
||||
|
||||
|
||||
self.make_supplier_gl_entry(gl_entries)
|
||||
self.make_item_gl_entries(gl_entries)
|
||||
self.make_tax_gl_entries(gl_entries)
|
||||
|
||||
gl_entries = merge_similar_entries(gl_entries)
|
||||
|
||||
self.make_payment_gl_entries(gl_entries)
|
||||
|
||||
self.make_write_off_gl_entry(gl_entries)
|
||||
gl_entries = self.get_gl_entries()
|
||||
|
||||
if gl_entries:
|
||||
update_outstanding = "No" if (cint(self.is_paid) or self.write_off_account) else "Yes"
|
||||
@@ -341,7 +324,27 @@ class PurchaseInvoice(BuyingController):
|
||||
|
||||
elif self.docstatus == 2 and cint(self.update_stock) and self.auto_accounting_for_stock:
|
||||
delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
|
||||
|
||||
def get_gl_entries(self, warehouse_account=None):
|
||||
self.auto_accounting_for_stock = \
|
||||
cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
|
||||
|
||||
self.stock_received_but_not_billed = self.get_company_default("stock_received_but_not_billed")
|
||||
self.expenses_included_in_valuation = self.get_company_default("expenses_included_in_valuation")
|
||||
self.negative_expense_to_be_booked = 0.0
|
||||
gl_entries = []
|
||||
|
||||
|
||||
self.make_supplier_gl_entry(gl_entries)
|
||||
self.make_item_gl_entries(gl_entries)
|
||||
self.make_tax_gl_entries(gl_entries)
|
||||
|
||||
gl_entries = merge_similar_entries(gl_entries)
|
||||
|
||||
self.make_payment_gl_entries(gl_entries)
|
||||
self.make_write_off_gl_entry(gl_entries)
|
||||
|
||||
return gl_entries
|
||||
|
||||
def make_supplier_gl_entry(self, gl_entries):
|
||||
if self.grand_total:
|
||||
|
||||
@@ -550,7 +550,7 @@
|
||||
"collapsible": 0,
|
||||
"depends_on": "eval:doc.margin_type && doc.price_list_rate",
|
||||
"fieldname": "total_margin",
|
||||
"fieldtype": "Float",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
@@ -1660,7 +1660,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"modified": "2016-07-11 03:28:07.483665",
|
||||
"modified": "2016-11-01 16:27:09.402277",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Sales Invoice Item",
|
||||
|
||||
@@ -380,7 +380,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
if(index < 30){
|
||||
$(frappe.render_template("pos_item", {
|
||||
item_code: obj.name,
|
||||
item_price: format_currency(obj.price_list_rate, obj.currency),
|
||||
item_price: format_currency(obj.price_list_rate, me.frm.doc.currency),
|
||||
item_name: obj.name===obj.item_name ? "" : obj.item_name,
|
||||
item_image: obj.image ? "url('" + obj.image + "')" : null,
|
||||
color: frappe.get_palette(obj.item_name),
|
||||
@@ -956,6 +956,10 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
item.margin_rate_or_amount = pricing_rule[0].margin_rate_or_amount;
|
||||
item.discount_percentage = pricing_rule[0].discount_percentage || 0.0;
|
||||
me.apply_pricing_rule_on_item(item)
|
||||
} else if(item.discount_percentage > 0 || item.margin_rate_or_amount > 0) {
|
||||
item.margin_rate_or_amount = 0.0;
|
||||
item.discount_percentage = 0.0;
|
||||
me.apply_pricing_rule_on_item(item)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@@ -3,6 +3,9 @@ from frappe import _
|
||||
def get_data():
|
||||
return {
|
||||
'fieldname': 'prevdoc_docname',
|
||||
'non_standard_fieldnames': {
|
||||
'Supplier Quotation': 'opportunity',
|
||||
},
|
||||
'transactions': [
|
||||
{
|
||||
'label': _('Related'),
|
||||
|
||||
@@ -321,3 +321,5 @@ erpnext.patches.v7_0.update_mode_of_payment_type
|
||||
finally:erpnext.patches.v7_0.update_timesheet_communications
|
||||
erpnext.patches.v7_0.update_status_of_zero_amount_sales_order
|
||||
erpnext.patches.v7_0.repost_bin_qty_and_item_projected_qty
|
||||
erpnext.patches.v7_0.repost_gle_for_pi_with_update_stock #2016-11-01
|
||||
erpnext.patches.v7_0.set_base_amount_in_invoice_payment_table
|
||||
20
erpnext/patches/v7_0/repost_gle_for_pi_with_update_stock.py
Normal file
20
erpnext/patches/v7_0/repost_gle_for_pi_with_update_stock.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import cint
|
||||
|
||||
def execute():
|
||||
if not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")):
|
||||
return
|
||||
|
||||
for pi in frappe.db.sql("""select name from `tabPurchase Invoice`
|
||||
where update_stock=1 and docstatus=1 order by posting_date asc""", as_dict=1):
|
||||
|
||||
frappe.db.sql("""delete from `tabGL Entry`
|
||||
where voucher_type = 'Purchase Invoice' and voucher_no = %s""", pi.name)
|
||||
|
||||
pi_doc = frappe.get_doc("Purchase Invoice", pi.name)
|
||||
pi_doc.make_gl_entries(repost_future_gle=False)
|
||||
frappe.db.commit()
|
||||
@@ -0,0 +1,23 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import flt
|
||||
|
||||
def execute():
|
||||
si_list = frappe.db.sql("""
|
||||
select distinct parent
|
||||
from `tabSales Invoice Payment`
|
||||
where docstatus!=2 and amount != 0 and base_amount = 0
|
||||
""")
|
||||
|
||||
count = 0
|
||||
for d in si_list:
|
||||
si = frappe.get_doc("Sales Invoice", d[0])
|
||||
for p in si.get("payments"):
|
||||
if p.amount and not p.base_amount:
|
||||
base_amount = flt(p.amount*si.conversion_rate, si.precision("base_paid_amount"))
|
||||
frappe.db.set_value("Sales Invoice Payment", p.name, "base_amount", base_amount, update_modified=False)
|
||||
|
||||
count +=1
|
||||
|
||||
if count % 200 == 0:
|
||||
frappe.db.commit()
|
||||
@@ -16,9 +16,10 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
|
||||
},
|
||||
apply_pricing_rule_on_item: function(item){
|
||||
if(item.margin_type == "Percentage"){
|
||||
item.total_margin = item.price_list_rate + item.price_list_rate * ( item.margin_rate_or_amount / 100);
|
||||
item.total_margin = flt(item.price_list_rate)
|
||||
+ flt(item.price_list_rate) * ( flt(item.margin_rate_or_amount) / 100);
|
||||
}else{
|
||||
item.total_margin = item.price_list_rate + item.margin_rate_or_amount;
|
||||
item.total_margin = flt(item.price_list_rate) + flt(item.margin_rate_or_amount);
|
||||
}
|
||||
|
||||
item.rate = flt(item.total_margin , precision("rate", item));
|
||||
|
||||
@@ -542,7 +542,7 @@
|
||||
"collapsible": 0,
|
||||
"depends_on": "eval:doc.margin_type && doc.price_list_rate",
|
||||
"fieldname": "total_margin",
|
||||
"fieldtype": "Float",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
@@ -1230,7 +1230,7 @@
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"menu_index": 0,
|
||||
"modified": "2016-07-11 03:28:06.436316",
|
||||
"modified": "2016-11-01 16:26:46.507292",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Selling",
|
||||
"name": "Quotation Item",
|
||||
|
||||
@@ -542,7 +542,7 @@
|
||||
"collapsible": 0,
|
||||
"depends_on": "eval:doc.margin_type && doc.price_list_rate",
|
||||
"fieldname": "total_margin",
|
||||
"fieldtype": "Float",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
@@ -591,7 +591,7 @@
|
||||
"collapsible": 0,
|
||||
"depends_on": "eval: doc.type != \"\"",
|
||||
"fieldname": "rate",
|
||||
"fieldtype": "Float",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
@@ -1525,7 +1525,7 @@
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"menu_index": 0,
|
||||
"modified": "2016-07-11 03:28:07.988319",
|
||||
"modified": "2016-11-01 16:26:27.256029",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Selling",
|
||||
"name": "Sales Order Item",
|
||||
|
||||
@@ -566,7 +566,7 @@
|
||||
"collapsible": 0,
|
||||
"depends_on": "eval:doc.margin_type && doc.price_list_rate",
|
||||
"fieldname": "total_margin",
|
||||
"fieldtype": "Float",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
@@ -1468,7 +1468,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"modified": "2016-07-11 03:27:59.254550",
|
||||
"modified": "2016-11-01 16:35:45.800082",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Delivery Note Item",
|
||||
|
||||
@@ -567,7 +567,7 @@ class Item(WebsiteGenerator):
|
||||
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)
|
||||
|
||||
for warehouse in frappe.db.sql("select name from `tabWarehouse` where is_group = 0"):
|
||||
for warehouse in frappe.db.sql("select warehouse from `tabBin` where item_code=%s", new_name):
|
||||
repost_stock(new_name, warehouse[0])
|
||||
|
||||
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", existing_allow_negative_stock)
|
||||
|
||||
Reference in New Issue
Block a user