mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
Merge branch 'responsive' of git://github.com/webnotes/erpnext into responsive
This commit is contained in:
@@ -12,5 +12,6 @@ test_records = [
|
||||
"income_account": "Sales - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"expense_account": "_Test Account Cost for Goods Sold - _TC",
|
||||
"naming_series": "_T-Sales Invoice-"
|
||||
}]
|
||||
]
|
||||
@@ -58,16 +58,7 @@ class DocType(BuyingController):
|
||||
self.clear_unallocated_advances("Purchase Invoice Advance", "advance_allocation_details")
|
||||
self.check_for_acc_head_of_supplier()
|
||||
self.check_for_stopped_status()
|
||||
|
||||
self.po_list, self.pr_list = [], []
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
self.validate_supplier(d)
|
||||
self.validate_po_pr(d)
|
||||
if not d.purchase_order in self.po_list:
|
||||
self.po_list.append(d.purchase_order)
|
||||
if not d.purhcase_receipt in self.pr_list:
|
||||
self.pr_list.append(d.purchase_receipt)
|
||||
|
||||
self.validate_with_previous_doc()
|
||||
|
||||
if not self.doc.is_opening:
|
||||
self.doc.is_opening = 'No'
|
||||
@@ -156,10 +147,7 @@ class DocType(BuyingController):
|
||||
if (self.doc.currency == default_currency and flt(self.doc.conversion_rate) != 1.00) or not self.doc.conversion_rate or (self.doc.currency != default_currency and flt(self.doc.conversion_rate) == 1.00):
|
||||
msgprint("Message: Please Enter Appropriate Conversion Rate.")
|
||||
raise Exception
|
||||
|
||||
# 1. Check whether bill is already booked against this bill no. or not
|
||||
# 2. Add Remarks
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
def validate_bill_no(self):
|
||||
if self.doc.bill_no and self.doc.bill_no.lower().strip() not in ['na', 'not applicable', 'none']:
|
||||
b_no = sql("select bill_no, name, ifnull(is_opening,'') from `tabPurchase Invoice` where bill_no = '%s' and credit_to = '%s' and docstatus = 1 and name != '%s' " % (self.doc.bill_no, self.doc.credit_to, self.doc.name))
|
||||
@@ -172,16 +160,10 @@ class DocType(BuyingController):
|
||||
if not self.doc.remarks:
|
||||
self.doc.remarks = "No Remarks"
|
||||
|
||||
# Validate Bill No Date
|
||||
# ---------------------
|
||||
def validate_bill_no_date(self):
|
||||
if self.doc.bill_no and not self.doc.bill_date and self.doc.bill_no.lower().strip() not in ['na', 'not applicable', 'none']:
|
||||
msgprint(_("Please enter Bill Date"), raise_exception=1)
|
||||
|
||||
# 1. Credit To Account Exists
|
||||
# 2. Is a Credit Account
|
||||
# 3. Is not a PL Account
|
||||
# ----------------------------
|
||||
def validate_credit_acc(self):
|
||||
acc = sql("select debit_or_credit, is_pl_account from tabAccount where name = %s",
|
||||
self.doc.credit_to)
|
||||
@@ -215,50 +197,30 @@ class DocType(BuyingController):
|
||||
if stopped:
|
||||
msgprint("One cannot do any transaction against 'Purchase Order' : %s, it's status is 'Stopped'" % (d.purhcase_order))
|
||||
raise Exception
|
||||
|
||||
# Validate Supplier
|
||||
# -----------------
|
||||
def validate_supplier(self, d):
|
||||
supplier = ''
|
||||
if d.purchase_order and not d.purchase_order in self.po_list:
|
||||
supplier = sql("select supplier from `tabPurchase Order` where name = '%s'" % d.purchase_order)[0][0]
|
||||
if supplier and not cstr(self.doc.supplier) == cstr(supplier):
|
||||
msgprint("Supplier name %s do not match with supplier name of purhase order: %s." %(self.doc.supplier,cstr(d.purchase_order)))
|
||||
raise Exception , " Validation Error "
|
||||
|
||||
if d.purchase_receipt and not d.purchase_receipt in self.pr_list:
|
||||
supplier = sql("select supplier from `tabPurchase Receipt` where name = '%s'" % d.purchase_receipt)[0][0]
|
||||
if supplier and not cstr(self.doc.supplier) == cstr(supplier):
|
||||
msgprint("Supplier name %s do not match with supplier name of %s %s." %(self.doc.supplier,cstr(d.purchase_receipt)))
|
||||
raise Exception , " Validation Error "
|
||||
|
||||
def validate_reference_value(self):
|
||||
pass
|
||||
|
||||
# Validate PO and PR
|
||||
# -------------------
|
||||
def validate_po_pr(self, d):
|
||||
# check po / pr for qty and rates and currency and conversion rate
|
||||
|
||||
# currency, import_rate must be equal to currency, import_rate of purchase order
|
||||
if d.purchase_order and not d.purchase_order in self.po_list:
|
||||
# currency
|
||||
currency = cstr(sql("select currency from `tabPurchase Order` where name = '%s'" % d.purchase_order)[0][0])
|
||||
if not cstr(currency) == cstr(self.doc.currency):
|
||||
msgprint("Purchase Order: " + cstr(d.purchase_order) + " currency : " + cstr(currency) + " does not match with currency of current document.")
|
||||
raise Exception
|
||||
# import_rate
|
||||
rate = flt(sql('select import_rate from `tabPurchase Order Item` where item_code=%s and parent=%s and name = %s', (d.item_code, d.purchase_order, d.po_detail))[0][0])
|
||||
if abs(rate - flt(d.import_rate)) > 1 and cint(webnotes.defaults.get_global_default('maintain_same_rate')):
|
||||
msgprint("Import Rate for %s in the Purchase Order is %s. Rate must be same as Purchase Order Rate" % (d.item_code,rate))
|
||||
raise Exception
|
||||
|
||||
if d.purchase_receipt and not d.purchase_receipt in self.pr_list:
|
||||
# currency , conversion_rate
|
||||
data = sql("select currency, conversion_rate from `tabPurchase Receipt` where name = '%s'" % d.purchase_receipt, as_dict = 1)
|
||||
if not cstr(data[0]['currency']) == cstr(self.doc.currency):
|
||||
msgprint("Purchase Receipt: " + cstr(d.purchase_receipt) + " currency : " + cstr(data[0]['currency']) + " does not match with currency of current document.")
|
||||
raise Exception
|
||||
|
||||
def validate_with_previous_doc(self):
|
||||
super(DocType, self).validate_with_previous_doc(self.tname, {
|
||||
"Purchase Order": {
|
||||
"ref_dn_field": "purchase_order",
|
||||
"compare_fields": [["supplier", "="], ["company", "="], ["currency", "="]],
|
||||
},
|
||||
"Purchase Order Item": {
|
||||
"ref_dn_field": "po_detail",
|
||||
"compare_fields": [["export_rate", "="], ["project_name", "="], ["item_code", "="],
|
||||
["uom", "="]],
|
||||
"is_child_table": True
|
||||
},
|
||||
"Purchase Receipt": {
|
||||
"ref_dn_field": "purchase_receipt",
|
||||
"compare_fields": [["customer", "="], ["company", "="], ["currency", "="]],
|
||||
},
|
||||
"Purchase Receipt Item": {
|
||||
"ref_dn_field": "pr_detail",
|
||||
"compare_fields": [["export_rate", "="], ["project_name", "="], ["item_code", "="],
|
||||
["uom", "="]],
|
||||
"is_child_table": True
|
||||
}
|
||||
})
|
||||
|
||||
def set_aging_date(self):
|
||||
if self.doc.is_opening != 'Yes':
|
||||
|
||||
@@ -366,6 +366,7 @@ test_records = [
|
||||
# parent
|
||||
{
|
||||
"doctype": "Purchase Invoice",
|
||||
"naming_series": "_T-Purchase Invoice-",
|
||||
"supplier_name": "_Test Supplier",
|
||||
"credit_to": "_Test Supplier - _TC",
|
||||
"bill_no": "NA",
|
||||
|
||||
@@ -59,6 +59,7 @@ class DocType(SellingController):
|
||||
self.validate_posting_time()
|
||||
self.so_dn_required()
|
||||
self.validate_proj_cust()
|
||||
self.validate_with_previous_doc()
|
||||
sales_com_obj = get_obj('Sales Common')
|
||||
sales_com_obj.check_stop_sales_order(self)
|
||||
sales_com_obj.check_active_sales_items(self)
|
||||
@@ -66,7 +67,6 @@ class DocType(SellingController):
|
||||
sales_com_obj.validate_max_discount(self, 'entries')
|
||||
sales_com_obj.validate_fiscal_year(self.doc.fiscal_year,
|
||||
self.doc.posting_date,'Posting Date')
|
||||
self.validate_customer()
|
||||
self.validate_customer_account()
|
||||
self.validate_debit_acc()
|
||||
self.validate_fixed_asset_account()
|
||||
@@ -91,11 +91,9 @@ class DocType(SellingController):
|
||||
self.set_aging_date()
|
||||
self.set_against_income_account()
|
||||
self.validate_c_form()
|
||||
self.validate_rate_with_refdoc()
|
||||
self.validate_time_logs_are_submitted()
|
||||
self.validate_recurring_invoice()
|
||||
|
||||
|
||||
|
||||
def on_submit(self):
|
||||
if cint(self.doc.update_stock) == 1:
|
||||
sl_obj = get_obj("Stock Ledger")
|
||||
@@ -361,19 +359,6 @@ class DocType(SellingController):
|
||||
(not acc_head and (self.doc.debit_to != cstr(self.doc.customer) + " - " + self.get_company_abbr())):
|
||||
msgprint("Debit To: %s do not match with Customer: %s for Company: %s.\n If both correctly entered, please select Master Type \
|
||||
and Master Name in account master." %(self.doc.debit_to, self.doc.customer,self.doc.company), raise_exception=1)
|
||||
|
||||
|
||||
def validate_customer(self):
|
||||
""" Validate customer name with SO and DN"""
|
||||
if self.doc.customer:
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
dt = d.delivery_note and 'Delivery Note' or d.sales_order and 'Sales Order' or ''
|
||||
if dt:
|
||||
dt_no = d.delivery_note or d.sales_order
|
||||
cust = webnotes.conn.get_value(dt, dt_no, "customer")
|
||||
if cust and cstr(cust) != cstr(self.doc.customer):
|
||||
msgprint("Customer %s does not match with customer of %s: %s."
|
||||
%(self.doc.customer, dt, dt_no), raise_exception=1)
|
||||
|
||||
|
||||
def validate_debit_acc(self):
|
||||
@@ -400,6 +385,31 @@ class DocType(SellingController):
|
||||
elif item and item[0][1] == 'Yes' and not acc[0][0] == 'Fixed Asset Account':
|
||||
msgprint("Please select income head with account type 'Fixed Asset Account' as Item %s is an asset item" % d.item_code)
|
||||
raise Exception
|
||||
|
||||
|
||||
def validate_with_previous_doc(self):
|
||||
super(DocType, self).validate_with_previous_doc(self.tname, {
|
||||
"Sales Order": {
|
||||
"ref_dn_field": "sales_order",
|
||||
"compare_fields": [["customer", "="], ["company", "="], ["project_name", "="],
|
||||
["currency", "="]],
|
||||
},
|
||||
"Sales Order Item": {
|
||||
"ref_dn_field": "so_detail",
|
||||
"compare_fields": [["export_rate", "="]],
|
||||
"is_child_table": True
|
||||
},
|
||||
"Delivery Note": {
|
||||
"ref_dn_field": "delivery_note",
|
||||
"compare_fields": [["customer", "="], ["company", "="], ["project_name", "="],
|
||||
["currency", "="]],
|
||||
},
|
||||
"Delivery Note Item": {
|
||||
"ref_dn_field": "dn_detail",
|
||||
"compare_fields": [["export_rate", "="]],
|
||||
"is_child_table": True
|
||||
}
|
||||
})
|
||||
|
||||
def set_aging_date(self):
|
||||
if self.doc.is_opening != 'Yes':
|
||||
@@ -475,22 +485,6 @@ class DocType(SellingController):
|
||||
|
||||
webnotes.conn.set(self.doc, 'c_form_no', '')
|
||||
|
||||
def validate_rate_with_refdoc(self):
|
||||
"""Validate values with reference document with previous document"""
|
||||
for d in self.doclist.get({"parentfield": "entries"}):
|
||||
if d.so_detail:
|
||||
self.check_value("Sales Order", d.sales_order, d.so_detail,
|
||||
d.export_rate, d.item_code)
|
||||
if d.dn_detail:
|
||||
self.check_value("Delivery Note", d.delivery_note, d.dn_detail,
|
||||
d.export_rate, d.item_code)
|
||||
|
||||
def check_value(self, ref_dt, ref_dn, ref_item_dn, val, item_code):
|
||||
ref_val = webnotes.conn.get_value(ref_dt + " Item", ref_item_dn, "export_rate")
|
||||
if flt(ref_val, 2) != flt(val, 2):
|
||||
msgprint(_("Rate is not matching with ") + ref_dt + ": " + ref_dn +
|
||||
_(" for item: ") + item_code, raise_exception=True)
|
||||
|
||||
def update_current_stock(self):
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
if d.item_code and d.warehouse:
|
||||
|
||||
@@ -423,6 +423,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
from stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
|
||||
as pr_test_records
|
||||
pr = webnotes.bean(copy=pr_test_records[0])
|
||||
pr.doc.naming_series = "_T-Purchase Receipt-"
|
||||
pr.run_method("calculate_taxes_and_totals")
|
||||
pr.insert()
|
||||
pr.submit()
|
||||
@@ -431,6 +432,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
from stock.doctype.delivery_note.test_delivery_note import test_records \
|
||||
as dn_test_records
|
||||
dn = webnotes.bean(copy=dn_test_records[0])
|
||||
dn.doc.naming_series = "_T-Delivery Note-"
|
||||
dn.insert()
|
||||
dn.submit()
|
||||
return dn
|
||||
|
||||
@@ -32,6 +32,7 @@ test_records = [
|
||||
[
|
||||
{
|
||||
"doctype": "Shipping Rule",
|
||||
"label": "_Test Shipping Rule",
|
||||
"calculate_based_on": "Net Total",
|
||||
"company": "_Test Company",
|
||||
"account": "_Test Account Shipping Charges - _TC",
|
||||
|
||||
@@ -204,16 +204,6 @@ wn.module_page["Accounts"] = [
|
||||
route: "query-report/Bank Reconciliation Statement",
|
||||
doctype: "Journal Voucher"
|
||||
},
|
||||
{
|
||||
"label":wn._("Delivered Items To Be Billed"),
|
||||
route: "query-report/Delivered Items To Be Billed",
|
||||
doctype: "Sales Invoice"
|
||||
},
|
||||
{
|
||||
"label":wn._("Received Items To Be Billed"),
|
||||
route: "query-report/Received Items To Be Billed",
|
||||
doctype: "Purchase Invoice"
|
||||
},
|
||||
{
|
||||
"label":wn._("Ordered Items To Be Billed"),
|
||||
route: "query-report/Ordered Items To Be Billed",
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-05-02 15:20:25",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-08 11:08:23",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"name": "__common__",
|
||||
"query": "select \n `tabDelivery Note`.`name` as \"Delivery Note:Link/Delivery Note:120\",\n`tabDelivery Note`.`customer` as \"Customer:Link/Customer:120\",\n`tabDelivery Note`.`status` as \"Status\",\n `tabDelivery Note`.`posting_date` as \"Date:Date\",\n `tabDelivery Note`.`project_name` as \"Project\",\n `tabDelivery Note Item`.item_code as \"Item:Link/Item:120\",\n `tabDelivery Note Item`.amount as \"Amount:Currency:110\",\n (`tabDelivery Note Item`.billed_amt * ifnull(`tabDelivery Note`.conversion_rate, 1)) as \"Billed Amount:Currency:110\",\n (ifnull(`tabDelivery Note Item`.amount,0) - (ifnull(`tabDelivery Note Item`.billed_amt,0) * ifnull(`tabDelivery Note`.conversion_rate, 1))) as \"Pending Amount:Currency:120\",\n `tabDelivery Note Item`.item_name as \"Item Name::150\",\n `tabDelivery Note Item`.description as \"Description:Data:200\",\n `tabDelivery Note Item`.prevdoc_docname as \"Sales Order:Link/Sales Order:120\",\n `tabDelivery Note Item`.prevdoc_date as \"SO Date:Date:100\",\n `tabDelivery Note`.address_display as \"Customer Address::150\"\nfrom\n `tabDelivery Note`, `tabDelivery Note Item`\nwhere\n `tabDelivery Note Item`.`parent` = `tabDelivery Note`.`name`\n and `tabDelivery Note`.docstatus = 1\n and `tabDelivery Note`.status != \"Stopped\"\n and ifnull(`tabDelivery Note Item`.billed_amt,0) < ifnull(`tabDelivery Note Item`.export_amount,0)\norder by `tabDelivery Note`.posting_date asc",
|
||||
"ref_doctype": "Sales Invoice",
|
||||
"report_name": "Delivered Items To Be Billed",
|
||||
"report_type": "Query Report"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"name": "Delivered Items To Be Billed"
|
||||
}
|
||||
]
|
||||
@@ -1,23 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-05-28 15:57:59",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-06-05 12:59:17",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"add_total_row": 1,
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"name": "__common__",
|
||||
"query": "select \n `tabPurchase Receipt`.`name` as \"Purchase Receipt:Link/Purchase Receipt:120\",\n `tabPurchase Receipt`.`posting_date` as \"Date:Date:100\",\n `tabPurchase Receipt`.`supplier` as \"Supplier:Link/Supplier:120\",\n `tabPurchase Receipt Item`.`project_name` as \"Project\",\n\t`tabPurchase Receipt Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Receipt Item`.amount as \"Amount:Currency:100\",\n\t`tabPurchase Receipt Item`.billed_amt as \"Billed Amount:Currency:100\", \n\t(`tabPurchase Receipt Item`.amount - ifnull(`tabPurchase Receipt Item`.billed_amt, 0)) as \"Amount to Bill:Currency:100\",\n\t`tabPurchase Receipt Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Receipt Item`.description as \"Description::200\"\nfrom\n\t`tabPurchase Receipt`, `tabPurchase Receipt Item`\nwhere\n\t`tabPurchase Receipt Item`.`parent` = `tabPurchase Receipt`.`name`\n\tand `tabPurchase Receipt`.docstatus = 1\n\tand `tabPurchase Receipt`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Receipt Item`.billed_amt, 0) < ifnull(`tabPurchase Receipt Item`.amount, 0)\norder by `tabPurchase Receipt`.posting_date asc",
|
||||
"ref_doctype": "Purchase Invoice",
|
||||
"report_name": "Received Items To Be Billed",
|
||||
"report_type": "Query Report"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"name": "Received Items To Be Billed"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user