Commit 4dd8d87c authored by Charles-Henri Decultot's avatar Charles-Henri Decultot
Browse files

Merge branch 'staging'

parents 8d242f9c b0d3513f
......@@ -5,7 +5,7 @@ import frappe
from erpnext.hooks import regional_overrides
from frappe.utils import getdate
__version__ = '1.3.12'
__version__ = '1.3.13'
def get_default_company(user=None):
'''Get default company for user'''
......
......@@ -12,7 +12,7 @@
</div>
</div>
<div class="flex flex-wrap justify-center align-center">
<a type="button" class="btn btn-success" :disabled="is_reconciliation_disabled" @click="reconcile_entries"><span>{{ __("Reconcile") }}</span><i class='uil uil-check'></i></a>
<a type="button" class="btn btn-success" :disabled="is_reconciliation_disabled || btn_clicked" @click="reconcile_entries"><span>{{ btn_clicked ? __("In progress...") : __("Reconcile") }}</span><i v-show="!btn_clicked" class='uil uil-check'></i></a>
</div>
</div>
</div>
......@@ -33,6 +33,7 @@ export default {
},
data() {
return {
btn_clicked: false
}
},
computed: {
......@@ -64,6 +65,7 @@ export default {
},
methods: {
reconcile_entries: function() {
this.btn_clicked = true;
if ((this.selected_transactions.length == 1 && this.selected_documents.length >= 1)
|| (this.selected_transactions.length >= 1 && this.selected_documents.length == 1)) {
if (["Sales Invoice", "Purchase Invoice"].includes(this.selected_documents[0]["doctype"]) && !this.is_pos.length) {
......@@ -75,6 +77,7 @@ export default {
}
} else {
frappe.msgprint(__("You can only reconcile one bank transaction with several documents or several bank transactions with one document."))
this.btn_clicked = false;
}
},
call_reconciliation: function() {
......@@ -82,6 +85,7 @@ export default {
{bank_transactions: this.selected_transactions, documents: !this.is_pos.length ? this.selected_documents : this.is_pos}
).then((result) => {
this.$emit('resetList')
this.btn_clicked = false;
frappe.show_alert({message: __(`${this.selected_documents.length} documents reconciled`), indicator: "green"})
})
}
......
......@@ -57,7 +57,7 @@ def validate_filters(filters, account_details):
and filters.get("group_by") in [_('Group by Voucher')]):
frappe.throw(_("Can not filter based on Voucher No, if grouped by Voucher"))
if filters.from_date > filters.to_date:
if getdate(filters.from_date) > getdate(filters.to_date):
frappe.throw(_("From Date must be before To Date"))
if filters.get('project'):
......
......@@ -2,7 +2,7 @@ from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils import flt
from erpnext.accounts.utils import get_fiscal_year
from erpnext.accounts.utils import get_fiscal_year, getdate
from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category \
import get_advance_vouchers, get_debit_note_amount
......@@ -18,7 +18,7 @@ def execute(filters=None):
def validate_filters(filters):
''' Validate if dates are properly set and lie in the same fiscal year'''
if filters.from_date > filters.to_date:
if getdate(filters.from_date) > getdate(filters.to_date):
frappe.throw(_("From Date must be before To Date"))
from_year = get_fiscal_year(filters.from_date)[0]
......
......@@ -21,7 +21,7 @@ def execute(filters=None):
def validate_filters(filters):
''' Validate if dates are properly set '''
if filters.from_date > filters.to_date:
if getdate(filters.from_date) > getdate(filters.to_date):
frappe.throw(_("From Date must be before To Date"))
def set_filters(filters):
......
......@@ -37,7 +37,7 @@ def validate_filters(filters):
filters.from_date = getdate(filters.from_date)
filters.to_date = getdate(filters.to_date)
if filters.from_date > filters.to_date:
if getdate(filters.from_date) > getdate(filters.to_date):
frappe.throw(_("From Date cannot be greater than To Date"))
if (filters.from_date < filters.year_start_date) or (filters.from_date > filters.year_end_date):
......
......@@ -20,9 +20,7 @@ class SupplierScorecard(Document):
self.update_standing()
def on_update(self):
score = make_all_scorecards(self.name)
if score > 0:
self.save()
self.make_all_scorecards()
def validate_standings(self):
# Check that there are no overlapping scores and check that there are no missing scores
......@@ -98,6 +96,53 @@ class SupplierScorecard(Document):
self.set(fieldname, standing.get(fieldname))
frappe.db.set_value("Supplier", self.supplier, fieldname, self.get(fieldname))
def make_all_scorecards(self):
supplier = frappe.get_doc('Supplier',self.supplier)
start_date = getdate(supplier.creation)
end_date = get_scorecard_date(self.period, start_date)
todays = getdate(nowdate())
scp_count = 0
first_start_date = todays
last_end_date = todays
while (start_date < todays) and (end_date <= todays):
# check to make sure there is no scorecard period already created
scorecards = frappe.db.sql("""
SELECT
scp.name
FROM
`tabSupplier Scorecard Period` scp
WHERE
scp.scorecard = %(sc)s
AND scp.docstatus = 1
AND (
(scp.start_date > %(end_date)s
AND scp.end_date < %(start_date)s)
OR
(scp.start_date < %(end_date)s
AND scp.end_date > %(start_date)s))
ORDER BY
scp.end_date DESC""",
{"sc": self.name, "start_date": start_date, "end_date": end_date}, as_dict=1)
if len(scorecards) == 0:
period_card = make_supplier_scorecard(self.name, None)
period_card.start_date = start_date
period_card.end_date = end_date
period_card.submit()
scp_count = scp_count + 1
if start_date < first_start_date:
first_start_date = start_date
last_end_date = end_date
start_date = getdate(add_days(end_date,1))
end_date = get_scorecard_date(self.period, start_date)
if scp_count > 0:
self.save()
frappe.msgprint(_("Created {0} scorecards for {1} between: ").format(scp_count, self.supplier) + str(first_start_date) + " - " + str(last_end_date))
return scp_count
@frappe.whitelist()
def get_timeline_data(doctype, name):
......@@ -135,60 +180,7 @@ def refresh_scorecards():
`tabSupplier Scorecard` sc""",
{}, as_dict=1)
for sc in scorecards:
# Check to see if any new scorecard periods are created
if make_all_scorecards(sc.name) > 0:
# Save the scorecard to update the score and standings
frappe.get_doc("Supplier Scorecard", sc.name).save()
@frappe.whitelist()
def make_all_scorecards(docname):
sc = frappe.get_doc('Supplier Scorecard', docname)
supplier = frappe.get_doc('Supplier',sc.supplier)
start_date = getdate(supplier.creation)
end_date = get_scorecard_date(sc.period, start_date)
todays = getdate(nowdate())
scp_count = 0
first_start_date = todays
last_end_date = todays
while (start_date < todays) and (end_date <= todays):
# check to make sure there is no scorecard period already created
scorecards = frappe.db.sql("""
SELECT
scp.name
FROM
`tabSupplier Scorecard Period` scp
WHERE
scp.scorecard = %(sc)s
AND scp.docstatus = 1
AND (
(scp.start_date > %(end_date)s
AND scp.end_date < %(start_date)s)
OR
(scp.start_date < %(end_date)s
AND scp.end_date > %(start_date)s))
ORDER BY
scp.end_date DESC""",
{"sc": docname, "start_date": start_date, "end_date": end_date}, as_dict=1)
if len(scorecards) == 0:
period_card = make_supplier_scorecard(docname, None)
period_card.start_date = start_date
period_card.end_date = end_date
period_card.submit()
scp_count = scp_count + 1
if start_date < first_start_date:
first_start_date = start_date
last_end_date = end_date
start_date = getdate(add_days(end_date,1))
end_date = get_scorecard_date(sc.period, start_date)
if scp_count > 0:
frappe.msgprint(_("Created {0} scorecards for {1} between: ").format(scp_count, sc.supplier) + str(first_start_date) + " - " + str(last_end_date))
return scp_count
frappe.enqueue_doc("Supplier Scorecard", sc.name, "make_all_scorecards", queue="long", timeout=3600)
def get_scorecard_date(period, start_date):
if period == 'Per Week':
......
{
"actions": [],
"allow_import": 1,
"allow_rename": 1,
"autoname": "naming_series:",
......@@ -119,7 +120,6 @@
"no_copy": 1
},
{
"default": "Sales",
"fieldname": "opportunity_type",
"fieldtype": "Link",
"in_list_view": 1,
......@@ -158,9 +158,9 @@
"read_only": 1
},
{
"fieldname": "expected_closing",
"fieldtype": "Date",
"label": "Expected Closing Date"
"fieldname": "expected_closing",
"fieldtype": "Date",
"label": "Expected Closing Date"
},
{
"collapsible": 1,
......@@ -227,7 +227,6 @@
"fieldtype": "Column Break"
},
{
"default": "Prospecting",
"fieldname": "sales_stage",
"fieldtype": "Link",
"label": "Sales Stage",
......@@ -418,7 +417,8 @@
],
"icon": "fa fa-info-sign",
"idx": 195,
"modified": "2019-09-30 12:58:37.385400",
"links": [],
"modified": "2020-03-20 17:57:13.833359",
"modified_by": "Administrator",
"module": "CRM",
"name": "Opportunity",
......
......@@ -17,7 +17,6 @@ def webhooks():
return
account, events = get_events(r)
for event in events:
try:
doc = create_new_integration_log(event, account)
......@@ -81,5 +80,6 @@ def create_new_integration_log(event, account):
integration_request.flags._name = event.attributes.get("id")
integration_request.insert(ignore_permissions=True)
frappe.db.commit()
return integration_request
\ No newline at end of file
......@@ -81,5 +81,6 @@ def create_new_integration_log(event, account):
integration_request.flags._name = event.id
integration_request.insert(ignore_permissions=True)
frappe.db.commit()
return integration_request
......@@ -8,6 +8,7 @@ import itertools
from frappe import _, get_all
def execute(filters=None):
company_country = frappe.db.get_value("Company", filters.company, "country")
columns = [
{
"label": _("Payroll Number"),
......@@ -52,6 +53,7 @@ def execute(filters=None):
"label": _("IFSC Code"),
"fieldtype": "Data",
"fieldname": "bank_code",
"hidden": company_country != "India",
"width": 100
},
{
......@@ -73,7 +75,8 @@ def execute(filters=None):
accounts = get_bank_accounts()
payroll_entries = get_payroll_entries(accounts, filters)
salary_slips = get_salary_slips(payroll_entries)
get_emp_bank_ifsc_code(salary_slips)
if company_country == "India":
get_emp_bank_ifsc_code(salary_slips)
for salary in salary_slips:
if salary.bank_name and salary.bank_account_no and salary.debit_acc_no and salary.status in ["Submitted", "Paid"]:
......@@ -83,7 +86,7 @@ def execute(filters=None):
"payment_date": frappe.utils.formatdate(salary.modified.strftime('%Y-%m-%d')),
"bank_name": salary.bank_name,
"employee_account_no": salary.bank_account_no,
"bank_code": salary.ifsc_code,
"bank_code": salary.get("ifsc_code"),
"employee_name": salary.employee+": " + salary.employee_name,
"currency": frappe.get_cached_value('Company', filters.company, 'default_currency'),
"amount": salary.net_pay,
......
......@@ -23,13 +23,13 @@ def execute():
flt(payment_entry.paid_amount) if payment_entry.payment_type == "Pay" else flt(payment_entry.received_amount))
for sales_invoice_payment in frappe.get_all("Sales Invoice Payment", \
filters={"mode_of_payment": ["is", "set"], "clearance_date": ["is", "not set"]}, fields=["sum(amount) as amount", "parent"], group_by="parent"):
filters={"mode_of_payment": ["is", "set"], "clearance_date": ["is", "not set"]}, fields=["sum(base_amount) as amount", "parent"], group_by="parent"):
is_return = frappe.db.get_value("Sales Invoice", sales_invoice_payment.parent, "is_return")
frappe.db.set_value("Sales Invoice", sales_invoice_payment.parent, "unreconciled_amount", \
(flt(sales_invoice_payment.base_amount) * -1) if is_return else flt(sales_invoice_payment.base_amount))
(flt(sales_invoice_payment.amount) * -1) if is_return else flt(sales_invoice_payment.amount))
for purchase_invoice in frappe.get_all("Purchase Invoice", \
filters={"docstatus": 1, "clearance_date": ["is", "not set"], "mode_of_payment": ["is", "set"]}, fields=["paid_amount", "name", "is_return"]):
filters={"docstatus": 1, "clearance_date": ["is", "not set"], "mode_of_payment": ["is", "set"]}, fields=["base_paid_amount", "name", "is_return"]):
frappe.db.set_value("Purchase Invoice", purchase_invoice.name, "unreconciled_amount", \
(flt(purchase_invoice.base_paid_amount) * -1) if purchase_invoice.is_return else flt(purchase_invoice.base_paid_amount))
......
......@@ -46,8 +46,7 @@ def get_columns(filters):
"CompAuxNum" + "::90", "CompAuxLib" + "::90",
"PieceRef" + "::90", "PieceDate" + "::90",
"EcritureLib" + "::90", "Debit" + "::90", "Credit" + "::90",
"EcritureLet" + "::90", "DateLet" +
"::90", "ValidDate" + "::90",
"EcritureLet" + "::90", "DateLet" + "::90", "ValidDate" + "::90",
"Montantdevise" + "::90", "Idevise" + "::90"
]
......@@ -105,8 +104,9 @@ def get_result_as_list(data, filters):
company_currency = frappe.get_cached_value('Company', filters.company, "default_currency")
accounts = frappe.get_all("Account", filters={"Company": filters.company}, fields=["name", "account_number"])
for d in data:
party_data = [x for x in data if x.get("against_voucher")]
for d in data:
JournalCode = re.split("-|/|[0-9]", d.get("voucher_no"))[0]
if d.get("voucher_no").startswith("{0}-".format(JournalCode)) or d.get("voucher_no").startswith("{0}/".format(JournalCode)):
......@@ -164,14 +164,28 @@ def get_result_as_list(data, filters):
Idevise = d.get("account_currency")
DateLet = get_date_let(d, party_data) if d.get("against_voucher") else None
EcritureLet = d.get("against_voucher", "") if DateLet else ""
if Idevise != company_currency:
Montantdevise = '{:.2f}'.format(d.get("debitCurr")).replace(".", ",") if d.get("debitCurr") != 0 else '{:.2f}'.format(d.get("creditCurr")).replace(".", ",")
else:
Montantdevise = '{:.2f}'.format(d.get("debit")).replace(".", ",") if d.get("debit") != 0 else '{:.2f}'.format(d.get("credit")).replace(".", ",")
row = [JournalCode, d.get("voucher_type"), EcritureNum, EcritureDate, CompteNum, d.get("account"), CompAuxNum, CompAuxLib,
PieceRef, PieceDate, EcritureLib, debit, credit, "", "", ValidDate, Montantdevise, Idevise]
PieceRef, PieceDate, EcritureLib, debit, credit, EcritureLet, DateLet or "", ValidDate, Montantdevise, Idevise]
result.append(row)
return result
def get_date_let(d, data):
let_dates = [x.get("GlPostDate") for x in data if (x.get("against_voucher") == d.get("against_voucher") and x.get("against_voucher_type") == d.get("against_voucher_type") and x.get("party") == d.get("party"))]
if not let_dates or len(let_dates) == 1:
let_vouchers = frappe.get_all("GL Entry", filters={"against_voucher": d.get("against_voucher"), "against_voucher_type": d.get("against_voucher_type"), "party": d.get("party")}, fields=["posting_date"])
if len(let_vouchers) > 1:
return format_datetime(max([x.get("posting_date") for x in let_vouchers]), "yyyyMMdd")
return format_datetime(max(let_dates), "yyyyMMdd") if len(let_dates) > 1 else None
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment