diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/README.md b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/README.md deleted file mode 100644 index bcde4b3133..0000000000 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/README.md +++ /dev/null @@ -1 +0,0 @@ -Tool for mapping (cancelling) unpaid invoices and payments. \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/__init__.py b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js deleted file mode 100644 index 4c5a3822c0..0000000000 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -// License: GNU General Public License v3. See license.txt - -cur_frm.cscript.onload_post_render = function(doc) { - $(cur_frm.get_field("reconcile").input).addClass("btn-info"); -} - -cur_frm.fields_dict.voucher_no.get_query = function(doc) { - // TO-do: check for pos, it should not come - if (!doc.account) msgprint(__("Please select Account first")); - else { - return { - doctype: doc.voucher_type, - query: "erpnext.accounts.doctype.payment_to_invoice_matching_tool.payment_to_invoice_matching_tool.get_voucher_nos", - filters: { - "voucher_type": doc.voucher_type, - "account": doc.account - } - } - } -} - -cur_frm.cscript.voucher_no = function() { - return cur_frm.call({ - doc: cur_frm.doc, - method: "get_voucher_details" - }); -} - -cur_frm.cscript.get_against_entries = function() { - return cur_frm.call({ - doc: cur_frm.doc, - method: "get_against_entries" - }); -} - -cur_frm.cscript.reconcile = function() { - return cur_frm.call({ - doc: cur_frm.doc, - method: "reconcile" - }); -} - -cur_frm.cscript.allocated_amount = function(doc, cdt, cdn) { - var total_allocated_amount = 0 - $.each(cur_frm.doc.against_entries, function(i, d) { - if(d.allocated_amount > 0) total_allocated_amount += flt(d.allocated_amount); - else if (d.allocated_amount < 0) frappe.throw(__("Allocated amount can not be negative")); - }) - cur_frm.set_value("total_allocated_amount", total_allocated_amount); -} diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.json b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.json deleted file mode 100644 index 8d12f08f72..0000000000 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.json +++ /dev/null @@ -1,187 +0,0 @@ -{ - "creation": "2013-01-30 12:49:46", - "docstatus": 0, - "doctype": "DocType", - "document_type": "Other", - "fields": [ - { - "fieldname": "account", - "fieldtype": "Link", - "in_list_view": 0, - "label": "Account", - "options": "Account", - "permlevel": 0, - "reqd": 1 - }, - { - "default": "Journal Voucher", - "fieldname": "voucher_type", - "fieldtype": "Select", - "in_list_view": 0, - "label": "Voucher Type", - "options": "Sales Invoice\nPurchase Invoice\nJournal Voucher", - "permlevel": 0, - "reqd": 1 - }, - { - "fieldname": "voucher_no", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Voucher No", - "options": "[Select]", - "permlevel": 0, - "reqd": 1 - }, - { - "fieldname": "column_break1", - "fieldtype": "Column Break", - "in_list_view": 0, - "permlevel": 0, - "print_width": "50%", - "width": "50%" - }, - { - "fieldname": "total_amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Total Amount", - "options": "", - "permlevel": 0, - "read_only": 1 - }, - { - "fieldname": "unmatched_amount", - "fieldtype": "Currency", - "label": "Unmatched Amount", - "options": "", - "permlevel": 0, - "read_only": 1 - }, - { - "fieldname": "against_entries_section", - "fieldtype": "Section Break", - "label": "Against Entries", - "permlevel": 0 - }, - { - "fieldname": "from_date", - "fieldtype": "Date", - "label": "From Date", - "permlevel": 0 - }, - { - "fieldname": "to_date", - "fieldtype": "Date", - "label": "To Date", - "permlevel": 0 - }, - { - "fieldname": "column_break3", - "fieldtype": "Column Break", - "label": "", - "permlevel": 0, - "print_width": "50%", - "width": "50%" - }, - { - "fieldname": "amt_greater_than", - "fieldtype": "Currency", - "label": "Amount >=", - "permlevel": 0 - }, - { - "fieldname": "amt_less_than", - "fieldtype": "Currency", - "label": "Amount <=", - "permlevel": 0 - }, - { - "fieldname": "section_break0", - "fieldtype": "Section Break", - "options": "Simple", - "permlevel": 0 - }, - { - "fieldname": "get_against_entries", - "fieldtype": "Button", - "label": "Get Against Entries", - "options": "", - "permlevel": 0 - }, - { - "description": "Update allocated amount in the above table and then click \"Allocate\" button", - "fieldname": "against_entries", - "fieldtype": "Table", - "label": "Against Entries", - "options": "Payment to Invoice Matching Tool Detail", - "permlevel": 0 - }, - { - "fieldname": "sec_break1", - "fieldtype": "Section Break", - "options": "Simple", - "permlevel": 0 - }, - { - "fieldname": "total_allocated_amount", - "fieldtype": "Currency", - "label": "Total Allocated Amount", - "permlevel": 0, - "read_only": 1 - }, - { - "fieldname": "col_breal4", - "fieldtype": "Column Break", - "permlevel": 0 - }, - { - "default": "", - "fieldname": "allocate_amount_automatically", - "fieldtype": "Button", - "hidden": 1, - "label": "Allocate Amount Automatically", - "permlevel": 0, - "reqd": 0 - }, - { - "fieldname": "reconcile", - "fieldtype": "Button", - "label": "Reconcile", - "options": "", - "permlevel": 0 - } - ], - "hide_toolbar": 0, - "icon": "icon-magic", - "idx": 1, - "issingle": 1, - "modified": "2014-04-30 17:11:05.908619", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Payment to Invoice Matching Tool", - "owner": "Administrator", - "permissions": [ - { - "create": 1, - "email": 1, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 0, - "role": "Accounts Manager", - "submit": 0, - "write": 1 - }, - { - "create": 1, - "email": 1, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 0, - "role": "Accounts User", - "submit": 0, - "write": 1 - } - ] -} \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py deleted file mode 100644 index 300d25efee..0000000000 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py +++ /dev/null @@ -1,173 +0,0 @@ -# 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 flt - -from frappe import msgprint, _ - -from frappe.model.document import Document - -class PaymenttoInvoiceMatchingTool(Document): - def get_voucher_details(self): - total_amount = frappe.db.sql("""select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) - from `tabGL Entry` - where voucher_type = %s and voucher_no = %s - and account = %s and ifnull(against_voucher, '') != voucher_no""", - (self.voucher_type, self.voucher_no, self.account)) - - self.total_amount = total_amount and flt(total_amount[0][0]) or 0 - - reconciled_payment = frappe.db.sql(""" - select abs(sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))) - from `tabGL Entry` - where against_voucher_type = %s and against_voucher = %s and account = %s - """, (self.voucher_type, self.voucher_no, self.account)) - - reconciled_payment = reconciled_payment and flt(reconciled_payment[0][0]) or 0 - self.unmatched_amount = self.total_amount - reconciled_payment - - def get_against_entries(self): - self.set('against_entries', []) - gle = self.get_gl_entries() - self.create_against_entries_table(gle) - - def get_gl_entries(self): - self.validate_mandatory() - - dr_or_cr = "credit" if self.total_amount > 0 else "debit" - - cond = self.from_date and " and t1.posting_date >= '" + self.from_date + "'" or "" - cond += self.to_date and " and t1.posting_date <= '" + self.to_date + "'" or "" - - if self.amt_greater_than: - cond += ' and abs(ifnull(t2.debit, 0) - ifnull(t2.credit, 0)) >= ' + self.amt_greater_than - if self.amt_less_than: - cond += ' and abs(ifnull(t2.debit, 0) - ifnull(t2.credit, 0)) >= ' + self.amt_less_than - - gle = frappe.db.sql(""" - select - t1.name as voucher_no, t1.posting_date, t1.total_debit as total_amt, - abs(ifnull(t2.debit, 0) - ifnull(t2.credit, 0)) as unmatched_amount, t1.remark, - t2.against_account, t2.name as voucher_detail_no, t2.is_advance - from - `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 - where - t1.name = t2.parent and t1.docstatus = 1 and t2.account = %s - and ifnull(t2.against_voucher, '')='' and ifnull(t2.against_invoice, '')='' - and ifnull(t2.against_jv, '')='' and t2.%s > 0 and t1.name != %s - and not exists (select * from `tabJournal Voucher Detail` - where parent=%s and against_jv = t1.name) %s - group by t1.name, t2.name """ % ('%s', dr_or_cr, '%s', '%s', cond), - (self.account, self.voucher_no, self.voucher_no), as_dict=1) - - return gle - - def create_against_entries_table(self, gle): - adjusted_jv = {} - for d in gle: - if not adjusted_jv.has_key(d.get("voucher_no")): - matched_amount = frappe.db.sql(""" - select - ifnull(abs(sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))), 0) - from - `tabGL Entry` - where - account = %s and against_voucher_type = "Journal Voucher" - and ifnull(against_voucher, '') = %s - """, (self.account, d.get('voucher_no'))) - matched_amount = matched_amount[0][0] if matched_amount else 0 - else: - matched_amount = adjusted_jv.get(d.get("voucher_no")) - - if matched_amount < flt(d.get('unmatched_amount')): - unmatched_amount = flt(d.get('unmatched_amount')) - matched_amount - adjusted_jv.setdefault(d.get("voucher_no"), 0) - else: - unmatched_amount = 0 - adjusted_jv.setdefault(d.get("voucher_no"), matched_amount - flt(d.get('unmatched_amount'))) - - if unmatched_amount: - ch = self.append('against_entries', {}) - ch.voucher_no = d.get('voucher_no') - ch.posting_date = d.get('posting_date') - ch.unmatched_amount = unmatched_amount - ch.total_amt = flt(d.get('total_amt')) - ch.against_account = d.get('against_account') - ch.remarks = d.get('remark') - ch.voucher_detail_no = d.get('voucher_detail_no') - ch.is_advance = d.get("is_advance") - ch.original_amount = flt(d.get('unmatched_amount')) - - def validate_mandatory(self): - for fieldname in ["account", "voucher_type", "voucher_no"]: - if not self.get(fieldname): - frappe.throw(_("Please select {0} first").format(self.meta.get_label("fieldname"))) - - if not frappe.db.exists(self.voucher_type, self.voucher_no): - frappe.throw(_("Voucher No is not valid")) - - def reconcile(self): - self.validate_mandatory() - self.validate_allocated_amount() - - dr_or_cr = "credit" if self.total_amount > 0 else "debit" - - lst = [] - for d in self.get('against_entries'): - if flt(d.allocated_amount) > 0: - lst.append({ - 'voucher_no' : d.voucher_no, - 'voucher_detail_no' : d.voucher_detail_no, - 'against_voucher_type' : self.voucher_type, - 'against_voucher' : self.voucher_no, - 'account' : self.account, - 'is_advance' : d.is_advance, - 'dr_or_cr' : dr_or_cr, - 'unadjusted_amt' : flt(d.original_amount), - 'allocated_amt' : flt(d.allocated_amount) - }) - - if lst: - from erpnext.accounts.utils import reconcile_against_document - reconcile_against_document(lst) - self.get_voucher_details() - self.get_against_entries() - msgprint(_("Successfully allocated")) - - def validate_allocated_amount(self): - if not self.total_allocated_amount: - frappe.throw(_("You must allocate amount before reconcile")) - elif self.total_allocated_amount > self.unmatched_amount: - frappe.throw(_("Total Allocated Amount can not be greater than unmatched amount")) - -def get_voucher_nos(doctype, txt, searchfield, start, page_len, filters): - non_reconclied_entries = [] - entries = frappe.db.sql(""" - select - voucher_no, posting_date, ifnull(abs(sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))), 0) as amount - from - `tabGL Entry` - where - account = %s and voucher_type = %s and voucher_no like %s - and ifnull(against_voucher, '') = '' - group by voucher_no - """, (filters["account"], filters["voucher_type"], "%%%s%%" % txt), as_dict=True) - - for d in entries: - adjusted_amount = frappe.db.sql(""" - select - ifnull(abs(sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))), 0) - from - `tabGL Entry` - where - account = %s and against_voucher_type = %s and ifnull(against_voucher, '') = %s - """, (filters["account"], filters["voucher_type"], d.voucher_no)) - adjusted_amount = adjusted_amount[0][0] if adjusted_amount else 0 - - if d.amount > adjusted_amount: - non_reconclied_entries.append([d.voucher_no, d.posting_date, d.amount]) - - return non_reconclied_entries diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py deleted file mode 100644 index 2198909d45..0000000000 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py +++ /dev/null @@ -1,8 +0,0 @@ -# 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 unittest -import frappe - -test_records = frappe.get_test_records('Payment To Invoice Matching Tool') \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_records.json b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_records.json deleted file mode 100644 index 0637a088a0..0000000000 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/test_records.json +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/README.md b/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/README.md deleted file mode 100644 index ed329911d3..0000000000 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/README.md +++ /dev/null @@ -1 +0,0 @@ -Journal Voucher (payment) detail for matching to invoice. \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/__init__.py b/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.json b/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.json deleted file mode 100644 index 247f023b2b..0000000000 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "creation": "2013-02-22 01:27:39", - "docstatus": 0, - "doctype": "DocType", - "fields": [ - { - "fieldname": "voucher_no", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Voucher No", - "options": "Journal Voucher", - "permlevel": 0, - "print_width": "140px", - "read_only": 1, - "reqd": 0, - "width": "140px" - }, - { - "fieldname": "unmatched_amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Unmatched Amount", - "options": "Company:company:default_currency", - "permlevel": 0, - "read_only": 1 - }, - { - "fieldname": "allocated_amount", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Allocated Amount", - "options": "Company:company:default_currency", - "permlevel": 0, - "reqd": 1 - }, - { - "fieldname": "col_break1", - "fieldtype": "Column Break", - "permlevel": 0 - }, - { - "fieldname": "posting_date", - "fieldtype": "Date", - "in_list_view": 1, - "label": "Posting Date", - "permlevel": 0, - "read_only": 1 - }, - { - "fieldname": "total_amt", - "fieldtype": "Currency", - "in_list_view": 1, - "label": "Total Amount", - "options": "Company:company:default_currency", - "permlevel": 0, - "read_only": 1 - }, - { - "fieldname": "against_account", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Against Account", - "permlevel": 0, - "read_only": 1 - }, - { - "fieldname": "remarks", - "fieldtype": "Small Text", - "label": "Remarks", - "permlevel": 0, - "print_width": "200px", - "read_only": 1, - "width": "200px" - }, - { - "fieldname": "voucher_detail_no", - "fieldtype": "Data", - "hidden": 1, - "label": "Voucher Detail No", - "permlevel": 0, - "print_hide": 1, - "read_only": 1, - "reqd": 0 - }, - { - "fieldname": "is_advance", - "fieldtype": "Data", - "hidden": 1, - "label": "Is Advance", - "permlevel": 0, - "read_only": 1 - }, - { - "fieldname": "original_amount", - "fieldtype": "Currency", - "hidden": 1, - "label": "Original Amount", - "permlevel": 0 - } - ], - "hide_toolbar": 1, - "idx": 1, - "istable": 1, - "modified": "2014-04-30 19:27:15.993641", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Payment to Invoice Matching Tool Detail", - "owner": "Administrator", - "permissions": [] -} \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py b/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py deleted file mode 100644 index a7bf686170..0000000000 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py +++ /dev/null @@ -1,10 +0,0 @@ -# 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.model.document import Document - -class PaymentToInvoiceMatchingToolDetail(Document): - pass \ No newline at end of file