[fixes] test case fixes for multi-currency check

This commit is contained in:
Saurabh 2016-02-23 12:07:20 +05:30
parent 1864879b91
commit f54be2c7f0
4 changed files with 19 additions and 13 deletions

View File

@ -626,8 +626,6 @@ def get_payment_entry(ref_doc, args):
cost_center = frappe.db.get_value("Company", ref_doc.company, "cost_center")
exchange_rate = 1
if args.get("party_account"):
print "here..."
print args.get("party_account"), args.get("party_account_currency")
exchange_rate = get_exchange_rate(args.get("party_account"), args.get("party_account_currency"),
ref_doc.company, ref_doc.doctype, ref_doc.name)

View File

@ -33,7 +33,7 @@ class PaymentRequest(Document):
frappe.throw(_("Payment Gateway Account is not configured"))
def validate_payment_gateway(self):
if self.gateway == "PayPal":
if self.payment_gateway == "PayPal":
if not frappe.db.get_value("PayPal Settings", None, "api_username"):
if not frappe.conf.paypal_username:
frappe.throw(_("PayPal Settings missing"))
@ -109,7 +109,6 @@ class PaymentRequest(Document):
"posting_date": nowdate()
})
print jv.as_dict()
jv.insert(ignore_permissions=True)
jv.submit()
@ -126,7 +125,6 @@ class PaymentRequest(Document):
def get_message(self):
"""return message with payment gateway link"""
print self.payment_url
return cstr(self.message) + " <a href='{0}'>{1}</a>".format(self.payment_url, \
self.payment_url_message or _(" Click here to pay"))
@ -209,11 +207,11 @@ def get_amount(ref_doc, dt):
"""get amount based on doctype"""
if dt == "Sales Order":
base_grand_total = flt(ref_doc.base_grand_total)
grand_total = flt(ref_doc.base_grand_total) - flt(ref_doc.advance_paid) / flt(ref_doc.conversion_rate)
grand_total = (flt(ref_doc.base_grand_total) - flt(ref_doc.advance_paid)) / flt(ref_doc.conversion_rate, 2)
if dt == "Sales Invoice":
base_grand_total = flt(ref_doc.base_grand_total)
grand_total = flt(ref_doc.base_grand_total) - flt(ref_doc.outstanding_amount) / flt(ref_doc.conversion_rate)
grand_total = (flt(ref_doc.base_grand_total) - flt(ref_doc.outstanding_amount)) / flt(ref_doc.conversion_rate, 2)
if base_grand_total > 0 and grand_total > 0 :
return base_grand_total, grand_total

View File

@ -6,7 +6,7 @@ from __future__ import unicode_literals
import frappe
import unittest
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request
from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request, get_gateway_details
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
# test_records = frappe.get_test_records('Payment Request')
@ -74,6 +74,18 @@ class TestPaymentRequest(unittest.TestCase):
pr = make_payment_request(dt="Sales Invoice", dn=SI_USD.name, recipient_id="saurabh@erpnext.com",
mute_email=1, return_doc=1, payemnt_gateway="_Test Gateway - USD")
self.assertRaises(frappe.ValidationError, pr.save)
jv = pr.set_as_paid()
payemnt_gateway_details = get_gateway_details({"payemnt_gateway": "_Test Gateway - USD"})
accounts = jv.accounts.as_dict()
self.assertEquals(accounts[0].account, "_Test Receivable USD - _TC")
self.assertEquals(accounts[0].account, payemnt_gateway_details.payment_account)

View File

@ -17,8 +17,6 @@ def get_context(context):
{"reference_name": frappe.form_dict.name}, "name")
context.enabled_checkout = frappe.get_doc("Shopping Cart Settings").enable_checkout
print context.enabled_checkout
if not context.doc.has_website_permission("read"):
frappe.throw(_("Not Permitted"), frappe.PermissionError)