Merge remote-tracking branch 'upstream/develop' into feat/so-po-advance-payment-status
This commit is contained in:
@@ -13,6 +13,7 @@ from frappe.utils import (
|
||||
add_days,
|
||||
add_months,
|
||||
cint,
|
||||
comma_and,
|
||||
flt,
|
||||
fmt_money,
|
||||
formatdate,
|
||||
@@ -181,6 +182,17 @@ class AccountsController(TransactionBase):
|
||||
self.validate_party_account_currency()
|
||||
|
||||
if self.doctype in ["Purchase Invoice", "Sales Invoice"]:
|
||||
if invalid_advances := [
|
||||
x for x in self.advances if not x.reference_type or not x.reference_name
|
||||
]:
|
||||
frappe.throw(
|
||||
_(
|
||||
"Rows: {0} in {1} section are Invalid. Reference Name should point to a valid Payment Entry or Journal Entry."
|
||||
).format(
|
||||
frappe.bold(comma_and([x.idx for x in invalid_advances])), frappe.bold(_("Advance Payments"))
|
||||
)
|
||||
)
|
||||
|
||||
pos_check_field = "is_pos" if self.doctype == "Sales Invoice" else "is_paid"
|
||||
if cint(self.allocate_advances_automatically) and not cint(self.get(pos_check_field)):
|
||||
self.set_advances()
|
||||
@@ -572,6 +584,17 @@ class AccountsController(TransactionBase):
|
||||
self.currency, self.company_currency, transaction_date, args
|
||||
)
|
||||
|
||||
if (
|
||||
self.currency
|
||||
and buying_or_selling == "Buying"
|
||||
and frappe.db.get_single_value("Buying Settings", "use_transaction_date_exchange_rate")
|
||||
and self.doctype == "Purchase Invoice"
|
||||
):
|
||||
self.use_transaction_date_exchange_rate = True
|
||||
self.conversion_rate = get_exchange_rate(
|
||||
self.currency, self.company_currency, transaction_date, args
|
||||
)
|
||||
|
||||
def set_missing_item_details(self, for_validate=False):
|
||||
"""set missing item values"""
|
||||
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
|
||||
@@ -1155,7 +1178,9 @@ class AccountsController(TransactionBase):
|
||||
self.name,
|
||||
arg.get("referenced_row"),
|
||||
):
|
||||
posting_date = frappe.db.get_value(arg.voucher_type, arg.voucher_no, "posting_date")
|
||||
posting_date = arg.get("difference_posting_date") or frappe.db.get_value(
|
||||
arg.voucher_type, arg.voucher_no, "posting_date"
|
||||
)
|
||||
je = create_gain_loss_journal(
|
||||
self.company,
|
||||
posting_date,
|
||||
@@ -1238,7 +1263,7 @@ class AccountsController(TransactionBase):
|
||||
|
||||
je = create_gain_loss_journal(
|
||||
self.company,
|
||||
self.posting_date,
|
||||
args.get("difference_posting_date") if args else self.posting_date,
|
||||
self.party_type,
|
||||
self.party,
|
||||
party_account,
|
||||
|
||||
Reference in New Issue
Block a user