Merge branch 'develop' into item-group-filter-portal

This commit is contained in:
Anupam Kumar 2020-09-08 10:04:51 +05:30 committed by GitHub
commit 7131024bf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 81 additions and 45 deletions

View File

@ -91,15 +91,11 @@ class TestBankTransaction(unittest.TestCase):
self.assertEqual(frappe.db.get_value("Bank Transaction", bank_transaction.name, "unallocated_amount"), 0)
self.assertTrue(frappe.db.get_value("Sales Invoice Payment", dict(parent=payment.name), "clearance_date") is not None)
def add_transactions():
if frappe.flags.test_bank_transactions_created:
return
frappe.set_user("Administrator")
def create_bank_account(bank_name="Citi Bank", account_name="_Test Bank - _TC"):
try:
frappe.get_doc({
"doctype": "Bank",
"bank_name":"Citi Bank",
"bank_name":bank_name,
}).insert()
except frappe.DuplicateEntryError:
pass
@ -108,12 +104,19 @@ def add_transactions():
frappe.get_doc({
"doctype": "Bank Account",
"account_name":"Checking Account",
"bank": "Citi Bank",
"account": "_Test Bank - _TC"
"bank": bank_name,
"account": account_name
}).insert()
except frappe.DuplicateEntryError:
pass
def add_transactions():
if frappe.flags.test_bank_transactions_created:
return
frappe.set_user("Administrator")
create_bank_account()
doc = frappe.get_doc({
"doctype": "Bank Transaction",
"description":"1512567 BG/000002918 OPSKATTUZWXXX AT776000000098709837 Herr G",

View File

@ -1172,30 +1172,23 @@ def make_payment_order(source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc
def set_missing_values(source, target):
target.payment_order_type = "Payment Entry"
target.append('references', dict(
reference_doctype="Payment Entry",
reference_name=source.name,
bank_account=source.party_bank_account,
amount=source.paid_amount,
account=source.paid_to,
supplier=source.party,
mode_of_payment=source.mode_of_payment,
))
def update_item(source_doc, target_doc, source_parent):
target_doc.bank_account = source_parent.party_bank_account
target_doc.amount = source_doc.allocated_amount
target_doc.account = source_parent.paid_to
target_doc.payment_entry = source_parent.name
target_doc.supplier = source_parent.party
target_doc.mode_of_payment = source_parent.mode_of_payment
doclist = get_mapped_doc("Payment Entry", source_name, {
doclist = get_mapped_doc("Payment Entry", source_name, {
"Payment Entry": {
"doctype": "Payment Order",
"validation": {
"docstatus": ["=", 1]
}
},
"Payment Entry Reference": {
"doctype": "Payment Order Reference",
"validation": {
"docstatus": ["=", 1]
},
"postprocess": update_item
},
}
}, target_doc, set_missing_values)

View File

@ -21,10 +21,15 @@ class PaymentOrder(Document):
if cancel:
status = 'Initiated'
ref_field = "status" if self.payment_order_type == "Payment Request" else "payment_order_status"
if self.payment_order_type == "Payment Request":
ref_field = "status"
ref_doc_field = frappe.scrub(self.payment_order_type)
else:
ref_field = "payment_order_status"
ref_doc_field = "reference_name"
for d in self.references:
frappe.db.set_value(self.payment_order_type, d.get(frappe.scrub(self.payment_order_type)), ref_field, status)
frappe.db.set_value(self.payment_order_type, d.get(ref_doc_field), ref_field, status)
@frappe.whitelist()
@frappe.validate_and_sanitize_search_inputs

View File

@ -5,6 +5,45 @@ from __future__ import unicode_literals
import frappe
import unittest
from frappe.utils import getdate
from erpnext.accounts.doctype.bank_transaction.test_bank_transaction import create_bank_account
from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry, make_payment_order
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
class TestPaymentOrder(unittest.TestCase):
pass
def setUp(self):
create_bank_account()
def tearDown(self):
for bt in frappe.get_all("Payment Order"):
doc = frappe.get_doc("Payment Order", bt.name)
doc.cancel()
doc.delete()
def test_payment_order_creation_against_payment_entry(self):
purchase_invoice = make_purchase_invoice()
payment_entry = get_payment_entry("Purchase Invoice", purchase_invoice.name, bank_account="_Test Bank - _TC")
payment_entry.reference_no = "_Test_Payment_Order"
payment_entry.reference_date = getdate()
payment_entry.party_bank_account = "Checking Account - Citi Bank"
payment_entry.insert()
payment_entry.submit()
doc = create_payment_order_against_payment_entry(payment_entry, "Payment Entry")
reference_doc = doc.get("references")[0]
self.assertEquals(reference_doc.reference_name, payment_entry.name)
self.assertEquals(reference_doc.reference_doctype, "Payment Entry")
self.assertEquals(reference_doc.supplier, "_Test Supplier")
self.assertEquals(reference_doc.amount, 250)
def create_payment_order_against_payment_entry(ref_doc, order_type):
payment_order = frappe.get_doc(dict(
doctype="Payment Order",
company="_Test Company",
payment_order_type=order_type,
company_bank_account="Checking Account - Citi Bank"
))
doc = make_payment_order(ref_doc.name, payment_order)
doc.save()
doc.submit()
return doc

View File

@ -1,4 +1,5 @@
{
"actions": [],
"creation": "2018-07-20 16:38:06.630813",
"doctype": "DocType",
"editable_grid": 1,
@ -10,7 +11,6 @@
"column_break_4",
"supplier",
"payment_request",
"payment_entry",
"mode_of_payment",
"bank_account_details",
"bank_account",
@ -103,17 +103,12 @@
"no_copy": 1,
"print_hide": 1,
"read_only": 1
},
{
"fieldname": "payment_entry",
"fieldtype": "Link",
"label": "Payment Entry",
"options": "Payment Entry",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"modified": "2019-05-08 13:56:25.724557",
"links": [],
"modified": "2020-09-04 08:29:51.014390",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Order Reference",

View File

@ -256,7 +256,7 @@ def accumulate_values_into_parents(accounts, accounts_by_name, companies):
"""accumulate children's values in parent accounts"""
for d in reversed(accounts):
if d.parent_account:
account = d.parent_account.split('-')[0].strip()
account = d.parent_account.split(' - ')[0].strip()
if not accounts_by_name.get(account):
continue

View File

@ -240,15 +240,19 @@ def unpledge_security(loan=None, loan_security_pledge=None, as_dict=0, save=0, s
unpledge_request = create_loan_security_unpledge(security_map, pledge_doc.loan,
pledge_doc.company, pledge_doc.applicant_type, pledge_doc.applicant)
if approve:
unpledge_request.status = 'Approved'
if save:
unpledge_request.save()
if submit:
unpledge_request.submit()
if approve:
if unpledge_request.docstatus == 1:
unpledge_request.status = 'Approved'
unpledge_request.save()
else:
frappe.throw(_('Only submittted unpledge requests can be approved'))
if as_dict:
return unpledge_request
else:

View File

@ -20,9 +20,6 @@ class LoanSecurityUnpledge(Document):
self.update_loan_status(cancel=1)
self.db_set('status', 'Requested')
def on_submit(self):
self.approve()
def validate_duplicate_securities(self):
security_list = []
for d in self.securities: