Merge branch 'version-13-hotfix' into fix-payment-reconciliation-jv-cost-center

This commit is contained in:
Maharshi Patel
2022-09-26 23:03:39 +05:30
committed by GitHub
4 changed files with 51 additions and 19 deletions

View File

@@ -8,7 +8,11 @@ from frappe.model.document import Document
from frappe.utils import flt, getdate, nowdate, today
import erpnext
from erpnext.accounts.utils import get_outstanding_invoices, reconcile_against_document
from erpnext.accounts.utils import (
get_outstanding_invoices,
reconcile_against_document,
update_reference_in_payment_entry,
)
from erpnext.controllers.accounts_controller import get_advance_payment_entries
@@ -190,6 +194,23 @@ class PaymentReconciliation(Document):
inv.currency = entry.get("currency")
inv.outstanding_amount = flt(entry.get("outstanding_amount"))
def get_difference_amount(self, allocated_entry):
if allocated_entry.get("reference_type") != "Payment Entry":
return
dr_or_cr = (
"credit_in_account_currency"
if erpnext.get_party_account_type(self.party_type) == "Receivable"
else "debit_in_account_currency"
)
row = self.get_payment_details(allocated_entry, dr_or_cr)
doc = frappe.get_doc(allocated_entry.reference_type, allocated_entry.reference_name)
update_reference_in_payment_entry(row, doc, do_not_save=True)
return doc.difference_amount
@frappe.whitelist()
def allocate_entries(self, args):
self.validate_entries()
@@ -205,12 +226,16 @@ class PaymentReconciliation(Document):
res = self.get_allocated_entry(pay, inv, pay["amount"])
inv["outstanding_amount"] = flt(inv.get("outstanding_amount")) - flt(pay.get("amount"))
pay["amount"] = 0
res.difference_amount = self.get_difference_amount(res)
if pay.get("amount") == 0:
entries.append(res)
break
elif inv.get("outstanding_amount") == 0:
entries.append(res)
continue
else:
break

View File

@@ -155,7 +155,6 @@ def adjust_account(data, period_list, consolidated=False):
for d in data:
for period in period_list:
key = period if consolidated else period.key
d[key] = totals[d["account"]]
d["total"] = totals[d["account"]]
return data

View File

@@ -894,6 +894,7 @@ class GSPConnector:
return self.e_invoice_settings.auth_token
def make_request(self, request_type, url, headers=None, data=None):
res = None
try:
if request_type == "post":
res = make_post_request(url, headers=headers, data=data)

View File

@@ -4,6 +4,8 @@
import frappe
from frappe import _
from frappe.query_builder import Field
from frappe.query_builder.functions import Min, Timestamp
from frappe.utils import add_days, getdate, today
from six import iteritems
@@ -29,7 +31,7 @@ def execute(filters=None):
def get_unsync_date(filters):
date = filters.from_date
if not date:
date = frappe.db.sql(""" SELECT min(posting_date) from `tabStock Ledger Entry`""")
date = (frappe.qb.from_("Stock Ledger Entry").select(Min(Field("posting_date")))).run()
date = date[0][0]
if not date:
@@ -55,22 +57,27 @@ def get_data(report_filters):
result = []
voucher_wise_dict = {}
data = frappe.db.sql(
"""
SELECT
name, posting_date, posting_time, voucher_type, voucher_no,
stock_value_difference, stock_value, warehouse, item_code
FROM
`tabStock Ledger Entry`
WHERE
posting_date
= %s and company = %s
and is_cancelled = 0
ORDER BY timestamp(posting_date, posting_time) asc, creation asc
""",
(from_date, report_filters.company),
as_dict=1,
)
sle = frappe.qb.DocType("Stock Ledger Entry")
data = (
frappe.qb.from_(sle)
.select(
sle.name,
sle.posting_date,
sle.posting_time,
sle.voucher_type,
sle.voucher_no,
sle.stock_value_difference,
sle.stock_value,
sle.warehouse,
sle.item_code,
)
.where(
(sle.posting_date == from_date)
& (sle.company == report_filters.company)
& (sle.is_cancelled == 0)
)
.orderby(Timestamp(sle.posting_date, sle.posting_time), sle.creation)
).run(as_dict=True)
for d in data:
voucher_wise_dict.setdefault((d.item_code, d.warehouse), []).append(d)