Merge branch 'hotfix'

This commit is contained in:
Nabin Hait 2016-08-26 12:37:19 +05:30
commit f92f04bffc
9 changed files with 97 additions and 57 deletions

View File

@ -2,7 +2,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
__version__ = '7.0.32' __version__ = '7.0.33'
def get_default_company(user=None): def get_default_company(user=None):
'''Get default company for user''' '''Get default company for user'''

View File

@ -252,17 +252,17 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "bill_date", "fieldname": "due_date",
"fieldtype": "Date", "fieldtype": "Date",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 1, "in_filter": 1,
"in_list_view": 0, "in_list_view": 0,
"label": "Supplier Invoice Date", "label": "Due Date",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"oldfieldname": "bill_date", "oldfieldname": "due_date",
"oldfieldtype": "Date", "oldfieldtype": "Date",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
@ -278,17 +278,17 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "due_date", "fieldname": "bill_date",
"fieldtype": "Date", "fieldtype": "Date",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 1, "in_filter": 1,
"in_list_view": 0, "in_list_view": 0,
"label": "Due Date", "label": "Supplier Invoice Date",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"oldfieldname": "due_date", "oldfieldname": "bill_date",
"oldfieldtype": "Date", "oldfieldtype": "Date",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
@ -3032,7 +3032,7 @@
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"menu_index": 0, "menu_index": 0,
"modified": "2016-08-10 02:45:28.746569", "modified": "2016-08-24 12:50:15.777689",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Purchase Invoice", "name": "Purchase Invoice",

View File

@ -65,8 +65,8 @@ class SalesInvoice(SellingController):
self.validate_fixed_asset() self.validate_fixed_asset()
self.set_income_account_for_fixed_assets() self.set_income_account_for_fixed_assets()
# if cint(self.is_pos): if cint(self.is_pos):
# self.validate_pos() self.validate_pos()
if cint(self.update_stock): if cint(self.update_stock):
self.validate_dropship_item() self.validate_dropship_item()
@ -219,6 +219,20 @@ class SalesInvoice(SellingController):
timesheet.set_status() timesheet.set_status()
timesheet.save() timesheet.save()
def on_update(self):
self.set_paid_amount()
def set_paid_amount(self):
paid_amount = 0.0
base_paid_amount = 0.0
for data in self.payments:
data.base_amount = flt(data.amount*self.conversion_rate, self.precision("base_paid_amount"))
paid_amount += data.amount
base_paid_amount += data.base_amount
self.paid_amount = paid_amount
self.base_paid_amount = base_paid_amount
def validate_time_sheets_are_submitted(self): def validate_time_sheets_are_submitted(self):
for data in self.timesheets: for data in self.timesheets:
if data.time_sheet: if data.time_sheet:
@ -356,11 +370,8 @@ class SalesInvoice(SellingController):
throw(_("Customer {0} does not belong to project {1}").format(self.customer,self.project)) throw(_("Customer {0} does not belong to project {1}").format(self.customer,self.project))
def validate_pos(self): def validate_pos(self):
if not self.cash_bank_account and flt(self.paid_amount):
frappe.throw(_("Cash or Bank Account is mandatory for making payment entry"))
if flt(self.paid_amount) + flt(self.write_off_amount) \ if flt(self.paid_amount) + flt(self.write_off_amount) \
- flt(self.grand_total) > 1/(10**(self.precision("grand_total") + 1)): - flt(self.grand_total) > 1/(10**(self.precision("grand_total") + 1)) and self.is_return:
frappe.throw(_("""Paid amount + Write Off Amount can not be greater than Grand Total""")) frappe.throw(_("""Paid amount + Write Off Amount can not be greater than Grand Total"""))
@ -588,9 +599,8 @@ class SalesInvoice(SellingController):
gl_entries += super(SalesInvoice, self).get_gl_entries() gl_entries += super(SalesInvoice, self).get_gl_entries()
def make_pos_gl_entries(self, gl_entries): def make_pos_gl_entries(self, gl_entries):
if cint(self.is_pos) and self.paid_amount: if cint(self.is_pos):
for payment_mode in self.payments: for payment_mode in self.payments:
if payment_mode.base_amount > 0:
# POS, make payment entries # POS, make payment entries
gl_entries.append( gl_entries.append(
self.get_gl_dict({ self.get_gl_dict({

View File

@ -142,7 +142,7 @@ class StatusUpdater(Document):
if item['reduce_by'] > .01: if item['reduce_by'] > .01:
self.limits_crossed_error(args, item) self.limits_crossed_error(args, item)
else: elif item[args['target_ref_field']]:
self.check_overflow_with_tolerance(item, args) self.check_overflow_with_tolerance(item, args)
def check_overflow_with_tolerance(self, item, args): def check_overflow_with_tolerance(self, item, args):

View File

@ -420,8 +420,10 @@ class calculate_taxes_and_totals(object):
# NOTE: # NOTE:
# write_off_amount is only for POS Invoice # write_off_amount is only for POS Invoice
# total_advance is only for non POS Invoice # total_advance is only for non POS Invoice
if self.doc.is_return: if self.doc.doctype == "Sales Invoice":
return self.calculate_paid_amount()
if self.doc.is_return: return
self.doc.round_floats_in(self.doc, ["grand_total", "total_advance", "write_off_amount"]) self.doc.round_floats_in(self.doc, ["grand_total", "total_advance", "write_off_amount"])
self._set_in_company_currency(self.doc, ['write_off_amount']) self._set_in_company_currency(self.doc, ['write_off_amount'])
@ -435,7 +437,6 @@ class calculate_taxes_and_totals(object):
- flt(self.doc.base_write_off_amount), self.doc.precision("grand_total")) - flt(self.doc.base_write_off_amount), self.doc.precision("grand_total"))
if self.doc.doctype == "Sales Invoice": if self.doc.doctype == "Sales Invoice":
self.calculate_paid_amount()
self.doc.round_floats_in(self.doc, ["paid_amount"]) self.doc.round_floats_in(self.doc, ["paid_amount"])
paid_amount = self.doc.paid_amount \ paid_amount = self.doc.paid_amount \
if self.doc.party_account_currency == self.doc.currency else self.doc.base_paid_amount if self.doc.party_account_currency == self.doc.currency else self.doc.base_paid_amount
@ -452,7 +453,6 @@ class calculate_taxes_and_totals(object):
def calculate_paid_amount(self): def calculate_paid_amount(self):
paid_amount = base_paid_amount = 0.0 paid_amount = base_paid_amount = 0.0
for payment in self.doc.get('payments'): for payment in self.doc.get('payments'):
if flt(payment.amount) > 0:
payment.base_amount = flt(payment.amount * self.doc.conversion_rate) payment.base_amount = flt(payment.amount * self.doc.conversion_rate)
paid_amount += payment.amount paid_amount += payment.amount
base_paid_amount += payment.base_amount base_paid_amount += payment.base_amount

View File

@ -311,3 +311,4 @@ erpnext.patches.v7_0.rename_examination_to_assessment
erpnext.patches.v7_0.set_portal_settings erpnext.patches.v7_0.set_portal_settings
erpnext.patches.v7_0.repost_future_gle_for_purchase_invoice erpnext.patches.v7_0.repost_future_gle_for_purchase_invoice
erpnext.patches.v7_0.fix_duplicate_icons erpnext.patches.v7_0.fix_duplicate_icons
erpnext.patches.v7_0.repost_gle_for_pos_sales_return

View File

@ -10,6 +10,8 @@ def execute():
if not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): if not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")):
return return
frappe.reload_doc('accounts', 'doctype', 'sales_invoice')
frappe.reload_doctype("Purchase Invoice") frappe.reload_doctype("Purchase Invoice")
wh_account = get_warehouse_account() wh_account = get_warehouse_account()

View File

@ -0,0 +1,24 @@
# 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, flt
def execute():
frappe.reload_doctype("Sales Invoice")
for si in frappe.get_all("Sales Invoice", fields = ["name"],
filters={"docstatus": 1, "is_pos": 1, "is_return": 1}):
si_doc = frappe.get_doc("Sales Invoice", si.name)
if len(si_doc.payments) > 0:
si_doc.set_paid_amount()
si_doc.flags.ignore_validate_update_after_submit = True
si_doc.save()
if si_doc.grand_total <= si_doc.paid_amount and si_doc.paid_amount < 0:
delete_gle_for_voucher(si_doc.name)
si_doc.run_method("make_gl_entries")
def delete_gle_for_voucher(voucher_no):
frappe.db.sql("""delete from `tabGL Entry` where voucher_no = %(voucher_no)s""",
{'voucher_no': voucher_no})

View File

@ -532,6 +532,11 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
// NOTE: // NOTE:
// paid_amount and write_off_amount is only for POS Invoice // paid_amount and write_off_amount is only for POS Invoice
// total_advance is only for non POS Invoice // total_advance is only for non POS Invoice
if(this.frm.doc.doctype == "Sales Invoice" && this.frm.doc.is_return){
this.calculate_paid_amount()
}
if(this.frm.doc.is_return || this.frm.doc.docstatus > 0) return; if(this.frm.doc.is_return || this.frm.doc.docstatus > 0) return;
frappe.model.round_floats_in(this.frm.doc, ["grand_total", "total_advance", "write_off_amount"]); frappe.model.round_floats_in(this.frm.doc, ["grand_total", "total_advance", "write_off_amount"]);
@ -594,11 +599,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
var me = this; var me = this;
var paid_amount = base_paid_amount = 0.0; var paid_amount = base_paid_amount = 0.0;
$.each(this.frm.doc['payments'] || [], function(index, data){ $.each(this.frm.doc['payments'] || [], function(index, data){
if(data.amount > -1){
data.base_amount = flt(data.amount * me.frm.doc.conversion_rate); data.base_amount = flt(data.amount * me.frm.doc.conversion_rate);
paid_amount += data.amount; paid_amount += data.amount;
base_paid_amount += data.base_amount; base_paid_amount += data.base_amount;
}
}) })
this.frm.doc.paid_amount = flt(paid_amount, precision("paid_amount")); this.frm.doc.paid_amount = flt(paid_amount, precision("paid_amount"));
@ -607,7 +610,7 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
calculate_change_amount: function(){ calculate_change_amount: function(){
this.frm.doc.change_amount = 0.0; this.frm.doc.change_amount = 0.0;
if(this.frm.doc.paid_amount > this.frm.doc.grand_total){ if(this.frm.doc.paid_amount > this.frm.doc.grand_total && !this.frm.doc.is_return){
this.frm.doc.change_amount = flt(this.frm.doc.paid_amount - this.frm.doc.grand_total + this.frm.doc.change_amount = flt(this.frm.doc.paid_amount - this.frm.doc.grand_total +
this.frm.doc.write_off_amount, precision("change_amount")); this.frm.doc.write_off_amount, precision("change_amount"));
} }