fix: merge conflict

This commit is contained in:
Nabin Hait
2020-04-14 20:31:50 +05:30
182 changed files with 4451 additions and 9675 deletions

View File

@@ -199,7 +199,7 @@
"idx": 1, "idx": 1,
"is_tree": 1, "is_tree": 1,
"links": [], "links": [],
"modified": "2020-03-18 18:35:45.618817", "modified": "2020-03-18 18:26:03.992861",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Account", "name": "Account",

View File

@@ -102,15 +102,15 @@ class Account(NestedSet):
if not frappe.db.get_value("Account", if not frappe.db.get_value("Account",
{'account_name': self.account_name, 'company': ancestors[0]}, 'name'): {'account_name': self.account_name, 'company': ancestors[0]}, 'name'):
frappe.throw(_("Please add the account to root level Company - %s" % ancestors[0])) frappe.throw(_("Please add the account to root level Company - %s" % ancestors[0]))
else: elif self.parent_account:
descendants = get_descendants_of('Company', self.company) descendants = get_descendants_of('Company', self.company)
if not descendants: return if not descendants: return
parent_acc_name_map = {} parent_acc_name_map = {}
parent_acc_name, parent_acc_number = frappe.db.get_value('Account', self.parent_account, \ parent_acc_name, parent_acc_number = frappe.db.get_value('Account', self.parent_account, \
["account_name", "account_number"]) ["account_name", "account_number"])
filters = { filters = {
"company": ["in", descendants], "company": ["in", descendants],
"account_name": parent_acc_name, "account_name": parent_acc_name,
} }
if parent_acc_number: if parent_acc_number:
filters["account_number"] = parent_acc_number filters["account_number"] = parent_acc_number

View File

@@ -1,7 +1,7 @@
frappe.provide("frappe.treeview_settings") frappe.provide("frappe.treeview_settings")
frappe.treeview_settings["Account"] = { frappe.treeview_settings["Account"] = {
breadcrumbs: "Accounts", breadcrumb: "Accounts",
title: __("Chart Of Accounts"), title: __("Chart Of Accounts"),
get_tree_root: false, get_tree_root: false,
filters: [ filters: [

View File

@@ -2417,29 +2417,26 @@
"Erl\u00f6se aus Verk\u00e4ufen Sachanlageverm\u00f6gen (bei Buchgewinn)": { "Erl\u00f6se aus Verk\u00e4ufen Sachanlageverm\u00f6gen (bei Buchgewinn)": {
"account_number": "4849" "account_number": "4849"
}, },
"Erl\u00f6se aus Verk\u00e4ufen immaterieller VG (bei Buchgewinn) (Gruppe)": { "Erl\u00f6se aus Verk\u00e4ufen immaterieller VG (bei Buchgewinn)": {
"is_group": 1, "account_number": "4850"
"Erl\u00f6se aus Verk\u00e4ufen immaterieller VG (bei Buchgewinn)": { },
"account_number": "4850" "Erl\u00f6se aus Verk\u00e4ufen Finanzanlagen (bei Buchgewinn)": {
}, "account_number": "4851"
"Erl\u00f6se aus Verk\u00e4ufen Finanzanlagen (bei Buchgewinn)": { },
"account_number": "4851" "Erl\u00f6se aus Verk\u00e4ufen Finanzanlagen (inl\u00e4ndische Kap.Ges., bei Buchgewinn)": {
}, "account_number": "4852"
"Erl\u00f6se aus Verk\u00e4ufen Finanzanlagen (inl\u00e4ndische Kap.Ges., bei Buchgewinn)": { },
"account_number": "4852" "Anlagenabg\u00e4nge Sachanlagen (Restbuchwert bei Buchvergewinn)": {
}, "account_number": "4855"
"Anlagenabg\u00e4nge Sachanlagen (Restbuchwert bei Buchvergewinn)": { },
"account_number": "4855" "Anlagenabg\u00e4nge immaterielle VG (Restbuchwert bei Buchgewinn)": {
}, "account_number": "4856"
"Anlagenabg\u00e4nge immaterielle VG (Restbuchwert bei Buchgewinn)": { },
"account_number": "4856" "Anlagenabg\u00e4nge Finanzanlagen (Restbuchwert bei Buchgewinn)": {
}, "account_number": "4857"
"Anlagenabg\u00e4nge Finanzanlagen (Restbuchwert bei Buchgewinn)": { },
"account_number": "4857" "Anlagenabg\u00e4nge Finanzanlagen (inl\u00e4ndische Kap.Ges., Restbuchwert bei Buchgewinn)": {
}, "account_number": "4858"
"Anlagenabg\u00e4nge Finanzanlagen (inl\u00e4ndische Kap.Ges., Restbuchwert bei Buchgewinn)": {
"account_number": "4858"
}
}, },
"Ertr\u00e4ge aus Zuschreibungen des Sachanlageverm\u00f6gens": { "Ertr\u00e4ge aus Zuschreibungen des Sachanlageverm\u00f6gens": {
"account_number": "4910", "account_number": "4910",
@@ -2562,20 +2559,17 @@
"Entnahme von Gegenst\u00e4nden ohne USt": { "Entnahme von Gegenst\u00e4nden ohne USt": {
"account_number": "4605" "account_number": "4605"
}, },
"Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternehmens 7 % USt (Gruppe)": { "Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternehmens 7 % USt": {
"is_group": 1, "account_number": "4630"
"Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternehmens 7 % USt": { },
"account_number": "4630" "Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternehmens ohne USt": {
}, "account_number": "4637"
"Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternehmens ohne USt": { },
"account_number": "4637" "Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternnehmens ohne USt (Telefon-Nutzung)": {
}, "account_number": "4638"
"Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternnehmens ohne USt (Telefon-Nutzung)": { },
"account_number": "4638" "Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternehmens ohne USt (Kfz-Nutzung)": {
}, "account_number": "4639"
"Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternehmens ohne USt (Kfz-Nutzung)": {
"account_number": "4639"
}
}, },
"Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternehmens 19 % USt (Gruppe)": { "Verwendung von Gegenst\u00e4nden f. Zwecke au\u00dferhalb des Unternehmens 19 % USt (Gruppe)": {
"is_group": 1, "is_group": 1,
@@ -2613,14 +2607,11 @@
"Unentgeltliche Zuwendung von Gegenst\u00e4nden ohne USt": { "Unentgeltliche Zuwendung von Gegenst\u00e4nden ohne USt": {
"account_number": "4689" "account_number": "4689"
}, },
"Nicht steuerbare Ums\u00e4tze (Innenums\u00e4tze) (Gruppe)": { "Nicht steuerbare Ums\u00e4tze (Innenums\u00e4tze)": {
"is_group": 1, "account_number": "4690"
"Nicht steuerbare Ums\u00e4tze (Innenums\u00e4tze)": { },
"account_number": "4690" "Umsatzsteuerverg\u00fctungen, z.B. nach \u00a7 24 UStG": {
}, "account_number": "4695"
"Umsatzsteuerverg\u00fctungen, z.B. nach \u00a7 24 UStG": {
"account_number": "4695"
}
}, },
"Au\u00dferordentliche Ertr\u00e4ge (Gruppe)": { "Au\u00dferordentliche Ertr\u00e4ge (Gruppe)": {
"is_group": 1, "is_group": 1,
@@ -2630,41 +2621,35 @@
"Au\u00dferordentliche Ertr\u00e4ge finanzwirksam": { "Au\u00dferordentliche Ertr\u00e4ge finanzwirksam": {
"account_number": "7401" "account_number": "7401"
}, },
"Au\u00dferordentliche Ertr\u00e4ge nicht finanzwirksam (Gruppe)": { "Au\u00dferordentliche Ertr\u00e4ge nicht finanzwirksam": {
"is_group": 1, "account_number": "7450"
"Au\u00dferordentliche Ertr\u00e4ge nicht finanzwirksam": {
"account_number": "7450"
},
"Ertr\u00e4ge durch Verschmelzung und Umwandlung": {
"account_number": "7451"
},
"Ertr\u00e4ge durch den Verkauf von bedeutenden Beteiligungen": {
"account_number": "7452"
},
"Ert\u00e4ge durch den Verkauf von bedeutenden Grundst\u00fccken": {
"account_number": "7453"
},
"Gewinn aus der Ver\u00e4u\u00dferung oder der Aufgabe von Gesch\u00e4ftsaktivit\u00e4ten nach Steuern": {
"account_number": "7454"
}
}, },
"Au\u00dferordentliche Ertr\u00e4ge aus der Anwendung von \u00dcbergangsvorschriften (Gruppe)": { "Ertr\u00e4ge durch Verschmelzung und Umwandlung": {
"is_group": 1, "account_number": "7451"
"Au\u00dferordentliche Ertr\u00e4ge aus der Anwendung von \u00dcbergangsvorschriften": { },
"account_number": "7460" "Ertr\u00e4ge durch den Verkauf von bedeutenden Beteiligungen": {
}, "account_number": "7452"
"Au\u00dferordentliche Ertr\u00e4ge: Zuschreibung f. Sachanlageverm\u00f6gen": { },
"account_number": "7461" "Ert\u00e4ge durch den Verkauf von bedeutenden Grundst\u00fccken": {
}, "account_number": "7453"
"Au\u00dferordentliche Ertr\u00e4ge: Zuschreibung f. Finanzanlageverm\u00f6gen": { },
"account_number": "7462" "Gewinn aus der Ver\u00e4u\u00dferung oder der Aufgabe von Gesch\u00e4ftsaktivit\u00e4ten nach Steuern": {
}, "account_number": "7454"
"Au\u00dferordentliche Ertr\u00e4ge: Wertpapiere im Umlaufverm\u00f6gen": { },
"account_number": "7463" "Au\u00dferordentliche Ertr\u00e4ge aus der Anwendung von \u00dcbergangsvorschriften": {
}, "account_number": "7460"
"Au\u00dferordentliche Ertr\u00e4ge: latente Steuern": { },
"account_number": "7464" "Au\u00dferordentliche Ertr\u00e4ge: Zuschreibung f. Sachanlageverm\u00f6gen": {
} "account_number": "7461"
},
"Au\u00dferordentliche Ertr\u00e4ge: Zuschreibung f. Finanzanlageverm\u00f6gen": {
"account_number": "7462"
},
"Au\u00dferordentliche Ertr\u00e4ge: Wertpapiere im Umlaufverm\u00f6gen": {
"account_number": "7463"
},
"Au\u00dferordentliche Ertr\u00e4ge: latente Steuern": {
"account_number": "7464"
} }
} }
}, },
@@ -2702,40 +2687,43 @@
}, },
"Erl\u00f6sschm\u00e4lerungen aus im Inland steuerpfl. EU-Lieferungen 16 % USt": { "Erl\u00f6sschm\u00e4lerungen aus im Inland steuerpfl. EU-Lieferungen 16 % USt": {
"account_number": "4729" "account_number": "4729"
}
},
"Gew\u00e4hrte Skonti (Gruppe)": {
"is_group": 1,
"Gew. Skonti": {
"account_number": "4730"
}, },
"Gew\u00e4hrte Skonti (Gruppe)": { "Gew. Skonti 7 % USt": {
"is_group": 1, "account_number": "4731"
"Gew. Skonti": {
"account_number": "4730"
},
"Gew. Skonti 7 % USt": {
"account_number": "4731"
},
"Gew. Skonti 19 % USt": {
"account_number": "4736"
},
"Gew. Skonti aus Lieferungen von Mobilfunkger./Schaltkr., f. die der Leistungsempf. die Ust. schuldet": {
"account_number": "4738"
},
"Gew. Skonti aus Leistungen, f. die der Leistungsempf. die Umsatzsteuer nach \u00a7 13b UStG schuldet": {
"account_number": "4741"
},
"Gew. Skonti aus Erl\u00f6sen aus im anderen EU-Land steuerpfl. Leistungen, f. die der Leistungsempf. die Ust. schuldet": {
"account_number": "4742"
},
"Gew. Skonti aus steuerfreien innergem. Lieferungen \u00a7 4 Nr. 1b UStG": {
"account_number": "4743"
},
"Gew. Skonti aus im Inland steuerpfl. EU-Lieferungen": {
"account_number": "4745"
},
"Gew. Skonti aus im Inland steuerpfl. EU-Lieferungen 7% USt": {
"account_number": "4746"
},
"Gew. Skonti aus im Inland steuerpfl. EU-Lieferungen 19% USt": {
"account_number": "4748"
}
}, },
"Gew. Skonti 19 % USt": {
"account_number": "4736"
},
"Gew. Skonti aus Lieferungen von Mobilfunkger./Schaltkr., f. die der Leistungsempf. die Ust. schuldet": {
"account_number": "4738"
},
"Gew. Skonti aus Leistungen, f. die der Leistungsempf. die Umsatzsteuer nach \u00a7 13b UStG schuldet": {
"account_number": "4741"
},
"Gew. Skonti aus Erl\u00f6sen aus im anderen EU-Land steuerpfl. Leistungen, f. die der Leistungsempf. die Ust. schuldet": {
"account_number": "4742"
},
"Gew. Skonti aus steuerfreien innergem. Lieferungen \u00a7 4 Nr. 1b UStG": {
"account_number": "4743"
},
"Gew. Skonti aus im Inland steuerpfl. EU-Lieferungen": {
"account_number": "4745"
},
"Gew. Skonti aus im Inland steuerpfl. EU-Lieferungen 7% USt": {
"account_number": "4746"
},
"Gew. Skonti aus im Inland steuerpfl. EU-Lieferungen 19% USt": {
"account_number": "4748"
}
},
"Gew\u00e4hrte Boni (Gruppe)": {
"is_group": 1,
"Gew\u00e4hrte Boni 7 % USt": { "Gew\u00e4hrte Boni 7 % USt": {
"account_number": "4750" "account_number": "4750"
}, },
@@ -2848,103 +2836,79 @@
"account_number": "6398" "account_number": "6398"
} }
}, },
"Versicherungen (Gruppe)": { "Versicherungen": {
"is_group": 1, "account_number": "6400"
"Versicherungen": { },
"account_number": "6400" "Versicherungen f. Geb\u00e4ude, die zum Betriebsverm\u00f6gen geh\u00f6ren": {
}, "account_number": "6405"
"Versicherungen f. Geb\u00e4ude, die zum Betriebsverm\u00f6gen geh\u00f6ren": { },
"account_number": "6405" "Netto-Pr\u00e4mie f. R\u00fcckdeckung k\u00fcnftiger Versorgungsleistungen": {
}, "account_number": "6410"
"Netto-Pr\u00e4mie f. R\u00fcckdeckung k\u00fcnftiger Versorgungsleistungen": { },
"account_number": "6410" "Beitr\u00e4ge": {
}, "account_number": "6420"
"Beitr\u00e4ge": { },
"account_number": "6420" "Sonstige Abgaben": {
}, "account_number": "6430"
"Sonstige Abgaben": { },
"account_number": "6430" "Steuerlich abzugsf\u00e4hige Versp\u00e4tungszuschl\u00e4ge und Zwangsgelder": {
}, "account_number": "6436"
"Steuerlich abzugsf\u00e4hige Versp\u00e4tungszuschl\u00e4ge und Zwangsgelder": { },
"account_number": "6436" "Steuerlich nicht abzugsf\u00e4hige Versp\u00e4tungszuschl\u00e4ge und Zwangsgelder": {
}, "account_number": "6437"
"Steuerlich nicht abzugsf\u00e4hige Versp\u00e4tungszuschl\u00e4ge und Zwangsgelder": { },
"account_number": "6437" "Ausgleichsabgabe i. S. d. Schwerbehindertengesetzes": {
}, "account_number": "6440"
"Ausgleichsabgabe i. S. d. Schwerbehindertengesetzes": { },
"account_number": "6440" "Reparaturen und Instandhaltung von Bauten": {
}, "account_number": "6450"
"Reparaturen und Instandhaltung von Bauten": { },
"account_number": "6450" "Reparaturen und Instandhaltung von technischenAnlagen und Maschinen": {
}, "account_number": "6460"
"Reparaturen und Instandhaltung von technischenAnlagen und Maschinen": { },
"account_number": "6460" "Reparaturen und Instandhaltung von anderen Anlagen und Betriebs- und Gesch\u00e4ftsausstattung": {
}, "account_number": "6470"
"Reparaturen und Instandhaltung von anderen Anlagen und Betriebs- und Gesch\u00e4ftsausstattung": { },
"account_number": "6470" "Zuf\u00fchrung zu Aufwandsr\u00fcckstellungen": {
}, "account_number": "6475"
"Zuf\u00fchrung zu Aufwandsr\u00fcckstellungen": { },
"account_number": "6475" "Reparaturen und Instandhaltung von anderen Anlagen": {
}, "account_number": "6485"
"Reparaturen und Instandhaltung von anderen Anlagen": { },
"account_number": "6485" "Sonstige Reparaturen und Instandhaltungen": {
}, "account_number": "6490"
"Sonstige Reparaturen und Instandhaltungen": { },
"account_number": "6490" "Wartungskosten f. Hard- und Software": {
}, "account_number": "6495"
"Wartungskosten f. Hard- und Software": { },
"account_number": "6495" "Mietleasing (bewegliche Wirtschaftsg\u00fcter)": {
}, "account_number": "6498"
"Mietleasing (bewegliche Wirtschaftsg\u00fcter)": {
"account_number": "6498"
}
}, },
"Fahrzeugkosten (Gruppe)": { "Fahrzeugkosten (Gruppe)": {
"is_group": 1, "is_group": 1,
"Fahrzeugkosten": { "Fahrzeugkosten": {
"account_number": "6500" "account_number": "6500"
}, },
"Kfz-Versicherungen (Gruppe)": { "Kfz-Versicherungen": {
"is_group": 1, "account_number": "6520"
"Kfz-Versicherungen": {
"account_number": "6520"
}
}, },
"Laufende Kfz-Betriebskosten (Gruppe)": { "Laufende Kfz-Betriebskosten": {
"is_group": 1, "account_number": "6530"
"Laufende Kfz-Betriebskosten": {
"account_number": "6530"
}
}, },
"Kfz-Reparaturen (Gruppe)": { "Kfz-Reparaturen": {
"is_group": 1, "account_number": "6540"
"Kfz-Reparaturen": {
"account_number": "6540"
}
}, },
"Garagenmiete (Gruppe)": { "Garagenmiete": {
"is_group": 1, "account_number": "6550"
"Garagenmiete": {
"account_number": "6550"
}
}, },
"Mietleasing Kfz (Gruppe)": { "Mietleasing Kfz": {
"is_group": 1, "account_number": "6560"
"Mietleasing Kfz": {
"account_number": "6560"
}
}, },
"Sonstige Kfz-Kosten (Gruppe)": { "Sonstige Kfz-Kosten": {
"is_group": 1, "account_number": "6570"
"Sonstige Kfz-Kosten": {
"account_number": "6570"
}
}, },
"Mautgeb\u00fchren (Gruppe)": { "Mautgeb\u00fchren": {
"is_group": 1, "account_number": "6580"
"Mautgeb\u00fchren": {
"account_number": "6580"
}
}, },
"Kfz-Kosten f. betrieblich genutzte zum Privatverm\u00f6gen geh\u00f6rende Kraftfahrzeuge": { "Kfz-Kosten f. betrieblich genutzte zum Privatverm\u00f6gen geh\u00f6rende Kraftfahrzeuge": {
"account_number": "6590" "account_number": "6590"
@@ -3006,20 +2970,23 @@
"Nicht abzugsf\u00e4hige Betriebsausgaben aus Werbe- und Repr\u00e4sentationskosten": { "Nicht abzugsf\u00e4hige Betriebsausgaben aus Werbe- und Repr\u00e4sentationskosten": {
"account_number": "6645" "account_number": "6645"
}, },
"Reisekosten Arbeitnehmer": { "Reisekosten Arbeitnehmer (Gruppe)": {
"account_number": "6650" "is_group": 1,
}, "Reisekosten Arbeitnehmer": {
"Reisekosten Arbeitnehmer \u00dcbernachtungsaufwand": { "account_number": "6650"
"account_number": "6660" },
}, "Reisekosten Arbeitnehmer \u00dcbernachtungsaufwand": {
"Reisekosten Arbeitnehmer Fahrtkosten": { "account_number": "6660"
"account_number": "6663" },
}, "Reisekosten Arbeitnehmer Fahrtkosten": {
"Reisekosten Arbeitnehmer Verpflegungsmehraufwand": { "account_number": "6663"
"account_number": "6664" },
}, "Reisekosten Arbeitnehmer Verpflegungsmehraufwand": {
"Kilometergelderstattung Arbeitnehmer": { "account_number": "6664"
"account_number": "6668" },
"Kilometergelderstattung Arbeitnehmer": {
"account_number": "6668"
}
}, },
"Reisekosten Unternehmer (Gruppe)": { "Reisekosten Unternehmer (Gruppe)": {
"is_group": 1, "is_group": 1,

View File

@@ -48,12 +48,6 @@ frappe.ui.form.on('Accounting Dimension', {
frm.set_value('label', frm.doc.document_type); frm.set_value('label', frm.doc.document_type);
frm.set_value('fieldname', frappe.model.scrub(frm.doc.document_type)); frm.set_value('fieldname', frappe.model.scrub(frm.doc.document_type));
if (frm.is_new()){
let row = frappe.model.add_child(frm.doc, "Accounting Dimension Detail", "dimension_defaults");
row.reference_document = frm.doc.document_type;
frm.refresh_fields("dimension_defaults");
}
frappe.db.get_value('Accounting Dimension', {'document_type': frm.doc.document_type}, 'document_type', (r) => { frappe.db.get_value('Accounting Dimension', {'document_type': frm.doc.document_type}, 'document_type', (r) => {
if (r && r.document_type) { if (r && r.document_type) {
frm.set_df_property('document_type', 'description', "Document type is already set as dimension"); frm.set_df_property('document_type', 'description', "Document type is already set as dimension");

View File

@@ -1,4 +1,5 @@
{ {
"actions": [],
"autoname": "field:label", "autoname": "field:label",
"creation": "2019-05-04 18:13:37.002352", "creation": "2019-05-04 18:13:37.002352",
"doctype": "DocType", "doctype": "DocType",
@@ -46,7 +47,8 @@
"options": "Accounting Dimension Detail" "options": "Accounting Dimension Detail"
} }
], ],
"modified": "2019-07-17 16:49:31.134385", "links": [],
"modified": "2020-03-22 20:34:39.805728",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Accounting Dimension", "name": "Accounting Dimension",
@@ -63,9 +65,20 @@
"role": "System Manager", "role": "System Manager",
"share": 1, "share": 1,
"write": 1 "write": 1
},
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Accounts Manager",
"share": 1,
"write": 1
} }
], ],
"quick_entry": 1,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "ASC", "sort_order": "ASC",
"track_changes": 1 "track_changes": 1

View File

@@ -193,7 +193,7 @@ def get_dimension_with_children(doctype, dimension):
all_dimensions = [] all_dimensions = []
lft, rgt = frappe.db.get_value(doctype, dimension, ["lft", "rgt"]) lft, rgt = frappe.db.get_value(doctype, dimension, ["lft", "rgt"])
children = frappe.get_all(doctype, filters={"lft": [">=", lft], "rgt": ["<=", rgt]}) children = frappe.get_all(doctype, filters={"lft": [">=", lft], "rgt": ["<=", rgt]}, order_by="lft")
all_dimensions += [c.name for c in children] all_dimensions += [c.name for c in children]
return all_dimensions return all_dimensions

View File

@@ -97,7 +97,7 @@ def build_forest(data):
return [parent_account] return [parent_account]
elif account_name == child: elif account_name == child:
parent_account_list = return_parent(data, parent_account) parent_account_list = return_parent(data, parent_account)
if not parent_account_list: if not parent_account_list and parent_account:
frappe.throw(_("The parent account {0} does not exists") frappe.throw(_("The parent account {0} does not exists")
.format(parent_account)) .format(parent_account))
return [child] + parent_account_list return [child] + parent_account_list
@@ -108,7 +108,7 @@ def build_forest(data):
error_messages = [] error_messages = []
for i in data: for i in data:
account_name, _, account_number, is_group, account_type, root_type = i account_name, dummy, account_number, is_group, account_type, root_type = i
if not account_name: if not account_name:
error_messages.append("Row {0}: Please enter Account Name".format(line_no)) error_messages.append("Row {0}: Please enter Account Name".format(line_no))

View File

@@ -126,7 +126,7 @@
"idx": 1, "idx": 1,
"is_tree": 1, "is_tree": 1,
"links": [], "links": [],
"modified": "2020-03-18 18:35:43.334214", "modified": "2020-03-18 18:26:01.540170",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Cost Center", "name": "Cost Center",

View File

@@ -1,5 +1,5 @@
frappe.treeview_settings["Cost Center"] = { frappe.treeview_settings["Cost Center"] = {
breadcrumbs: "Accounts", breadcrumb: "Accounts",
get_tree_root: false, get_tree_root: false,
filters: [{ filters: [{
fieldname: "company", fieldname: "company",

View File

@@ -114,13 +114,13 @@
"fieldname": "debit_in_account_currency", "fieldname": "debit_in_account_currency",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Debit Amount in Account Currency", "label": "Debit Amount in Account Currency",
"options": "currency" "options": "account_currency"
}, },
{ {
"fieldname": "credit_in_account_currency", "fieldname": "credit_in_account_currency",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Credit Amount in Account Currency", "label": "Credit Amount in Account Currency",
"options": "currency" "options": "account_currency"
}, },
{ {
"fieldname": "against", "fieldname": "against",
@@ -250,7 +250,7 @@
"icon": "fa fa-list", "icon": "fa fa-list",
"idx": 1, "idx": 1,
"in_create": 1, "in_create": 1,
"modified": "2020-02-10 04:54:57.777905", "modified": "2020-03-28 16:22:33.766994",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "GL Entry", "name": "GL Entry",

View File

@@ -154,8 +154,11 @@ frappe.ui.form.on('Payment Entry', {
frm.toggle_display("base_paid_amount", frm.doc.paid_from_account_currency != company_currency); frm.toggle_display("base_paid_amount", frm.doc.paid_from_account_currency != company_currency);
frm.toggle_display("base_received_amount", (frm.doc.paid_to_account_currency != company_currency && frm.toggle_display("base_received_amount", (
frm.doc.paid_from_account_currency != frm.doc.paid_to_account_currency)); frm.doc.paid_to_account_currency != company_currency &&
frm.doc.paid_from_account_currency != frm.doc.paid_to_account_currency
&& frm.doc.base_paid_amount != frm.doc.base_received_amount
));
frm.toggle_display("received_amount", (frm.doc.payment_type=="Internal Transfer" || frm.toggle_display("received_amount", (frm.doc.payment_type=="Internal Transfer" ||
frm.doc.paid_from_account_currency != frm.doc.paid_to_account_currency)) frm.doc.paid_from_account_currency != frm.doc.paid_to_account_currency))
@@ -486,6 +489,7 @@ frappe.ui.form.on('Payment Entry', {
paid_amount: function(frm) { paid_amount: function(frm) {
frm.set_value("base_paid_amount", flt(frm.doc.paid_amount) * flt(frm.doc.source_exchange_rate)); frm.set_value("base_paid_amount", flt(frm.doc.paid_amount) * flt(frm.doc.source_exchange_rate));
frm.trigger("reset_received_amount"); frm.trigger("reset_received_amount");
frm.events.hide_unhide_fields(frm);
}, },
received_amount: function(frm) { received_amount: function(frm) {
@@ -509,6 +513,7 @@ frappe.ui.form.on('Payment Entry', {
frm.events.set_unallocated_amount(frm); frm.events.set_unallocated_amount(frm);
frm.set_paid_amount_based_on_received_amount = false; frm.set_paid_amount_based_on_received_amount = false;
frm.events.hide_unhide_fields(frm);
}, },
reset_received_amount: function(frm) { reset_received_amount: function(frm) {

View File

@@ -81,7 +81,12 @@ class PaymentEntry(AccountsController):
self.update_advance_paid() self.update_advance_paid()
self.update_expense_claim() self.update_expense_claim()
self.delink_advance_entry_references() self.delink_advance_entry_references()
self.set_payment_req_status()
self.set_status() self.set_status()
def set_payment_req_status(self):
from erpnext.accounts.doctype.payment_request.payment_request import update_payment_req_status
update_payment_req_status(self, None)
def update_outstanding_amounts(self): def update_outstanding_amounts(self):
self.set_missing_ref_details(force=True) self.set_missing_ref_details(force=True)

View File

@@ -15,11 +15,11 @@ frappe.ui.form.on('Payment Order', {
if (frm.doc.docstatus == 0) { if (frm.doc.docstatus == 0) {
frm.add_custom_button(__('Payment Request'), function() { frm.add_custom_button(__('Payment Request'), function() {
frm.trigger("get_from_payment_request"); frm.trigger("get_from_payment_request");
}, __("Get from")); }, __("Get Payments from"));
frm.add_custom_button(__('Payment Entry'), function() { frm.add_custom_button(__('Payment Entry'), function() {
frm.trigger("get_from_payment_entry"); frm.trigger("get_from_payment_entry");
}, __("Get from")); }, __("Get Payments from"));
frm.trigger('remove_button'); frm.trigger('remove_button');
} }

View File

@@ -59,7 +59,6 @@
"fieldtype": "Section Break" "fieldtype": "Section Break"
}, },
{ {
"allow_bulk_edit": 1,
"fieldname": "references", "fieldname": "references",
"fieldtype": "Table", "fieldtype": "Table",
"label": "Payment Order Reference", "label": "Payment Order Reference",
@@ -108,7 +107,7 @@
} }
], ],
"is_submittable": 1, "is_submittable": 1,
"modified": "2019-05-14 17:12:24.912666", "modified": "2020-04-06 18:00:56.022642",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Payment Order", "name": "Payment Order",

File diff suppressed because it is too large Load Diff

View File

@@ -66,6 +66,8 @@ class PaymentRequest(Document):
if self.payment_request_type == 'Outward': if self.payment_request_type == 'Outward':
self.db_set('status', 'Initiated') self.db_set('status', 'Initiated')
return return
elif self.payment_request_type == 'Inward':
self.db_set('status', 'Requested')
send_mail = self.payment_gateway_validation() send_mail = self.payment_gateway_validation()
ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name) ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)
@@ -88,6 +90,7 @@ class PaymentRequest(Document):
if (hasattr(ref_doc, "order_type") and getattr(ref_doc, "order_type") == "Shopping Cart"): if (hasattr(ref_doc, "order_type") and getattr(ref_doc, "order_type") == "Shopping Cart"):
from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice
si = make_sales_invoice(self.reference_name, ignore_permissions=True) si = make_sales_invoice(self.reference_name, ignore_permissions=True)
si.allocate_advances_automatically = True
si = si.insert(ignore_permissions=True) si = si.insert(ignore_permissions=True)
si.submit() si.submit()
@@ -317,13 +320,13 @@ def make_payment_request(**args):
"payment_request_type": args.get("payment_request_type"), "payment_request_type": args.get("payment_request_type"),
"currency": ref_doc.currency, "currency": ref_doc.currency,
"grand_total": grand_total, "grand_total": grand_total,
"email_to": args.recipient_id or "", "email_to": args.recipient_id or ref_doc.owner,
"subject": _("Payment Request for {0}").format(args.dn), "subject": _("Payment Request for {0}").format(args.dn),
"message": gateway_account.get("message") or get_dummy_message(ref_doc), "message": gateway_account.get("message") or get_dummy_message(ref_doc),
"reference_doctype": args.dt, "reference_doctype": args.dt,
"reference_name": args.dn, "reference_name": args.dn,
"party_type": args.get("party_type"), "party_type": args.get("party_type") or "Customer",
"party": args.get("party"), "party": args.get("party") or ref_doc.customer,
"bank_account": bank_account "bank_account": bank_account
}) })
@@ -415,17 +418,31 @@ def make_payment_entry(docname):
doc = frappe.get_doc("Payment Request", docname) doc = frappe.get_doc("Payment Request", docname)
return doc.create_payment_entry(submit=False).as_dict() return doc.create_payment_entry(submit=False).as_dict()
def make_status_as_paid(doc, method): def update_payment_req_status(doc, method):
from erpnext.accounts.doctype.payment_entry.payment_entry import get_reference_details
for ref in doc.references: for ref in doc.references:
payment_request_name = frappe.db.get_value("Payment Request", payment_request_name = frappe.db.get_value("Payment Request",
{"reference_doctype": ref.reference_doctype, "reference_name": ref.reference_name, {"reference_doctype": ref.reference_doctype, "reference_name": ref.reference_name,
"docstatus": 1}) "docstatus": 1})
if payment_request_name: if payment_request_name:
doc = frappe.get_doc("Payment Request", payment_request_name) ref_details = get_reference_details(ref.reference_doctype, ref.reference_name, doc.party_account_currency)
if doc.status != "Paid": pay_req_doc = frappe.get_doc('Payment Request', payment_request_name)
doc.db_set('status', 'Paid') status = pay_req_doc.status
frappe.db.commit()
if status != "Paid" and not ref_details.outstanding_amount:
status = 'Paid'
elif status != "Partially Paid" and ref_details.outstanding_amount != ref_details.total_amount:
status = 'Partially Paid'
elif ref_details.outstanding_amount == ref_details.total_amount:
if pay_req_doc.payment_request_type == 'Outward':
status = 'Initiated'
elif pay_req_doc.payment_request_type == 'Inward':
status = 'Requested'
pay_req_doc.db_set('status', status)
frappe.db.commit()
def get_dummy_message(doc): def get_dummy_message(doc):
return frappe.render_template("""{% if doc.contact_person -%} return frappe.render_template("""{% if doc.contact_person -%}

View File

@@ -4,14 +4,20 @@ frappe.listview_settings['Payment Request'] = {
if(doc.status == "Draft") { if(doc.status == "Draft") {
return [__("Draft"), "darkgrey", "status,=,Draft"]; return [__("Draft"), "darkgrey", "status,=,Draft"];
} }
if(doc.status == "Requested") {
return [__("Requested"), "green", "status,=,Requested"];
}
else if(doc.status == "Initiated") { else if(doc.status == "Initiated") {
return [__("Initiated"), "green", "status,=,Initiated"]; return [__("Initiated"), "green", "status,=,Initiated"];
} }
else if(doc.status == "Partially Paid") {
return [__("Partially Paid"), "orange", "status,=,Partially Paid"];
}
else if(doc.status == "Paid") { else if(doc.status == "Paid") {
return [__("Paid"), "blue", "status,=,Paid"]; return [__("Paid"), "blue", "status,=,Paid"];
} }
else if(doc.status == "Cancelled") { else if(doc.status == "Cancelled") {
return [__("Cancelled"), "orange", "status,=,Cancelled"]; return [__("Cancelled"), "red", "status,=,Cancelled"];
} }
} }
} }

View File

@@ -101,6 +101,23 @@ class TestPaymentRequest(unittest.TestCase):
self.assertEqual(expected_gle[gle.account][2], gle.credit) self.assertEqual(expected_gle[gle.account][2], gle.credit)
self.assertEqual(expected_gle[gle.account][3], gle.against_voucher) self.assertEqual(expected_gle[gle.account][3], gle.against_voucher)
def test_status(self):
si_usd = create_sales_invoice(customer="_Test Customer USD", debit_to="_Test Receivable USD - _TC",
currency="USD", conversion_rate=50)
pr = make_payment_request(dt="Sales Invoice", dn=si_usd.name, recipient_id="saurabh@erpnext.com",
mute_email=1, payment_gateway="_Test Gateway - USD", submit_doc=1, return_doc=1)
pe = pr.create_payment_entry()
pr.load_from_db()
self.assertEqual(pr.status, 'Paid')
pe.cancel()
pr.load_from_db()
self.assertEqual(pr.status, 'Requested')
def test_multiple_payment_entries_against_sales_order(self): def test_multiple_payment_entries_against_sales_order(self):
# Make Sales Order, grand_total = 1000 # Make Sales Order, grand_total = 1000
so = make_sales_order() so = make_sales_order()

View File

@@ -178,7 +178,8 @@ def filter_pricing_rules(args, pricing_rules, doc=None):
if pricing_rules[0].mixed_conditions and doc: if pricing_rules[0].mixed_conditions and doc:
stock_qty, amount, items = get_qty_and_rate_for_mixed_conditions(doc, pr_doc, args) stock_qty, amount, items = get_qty_and_rate_for_mixed_conditions(doc, pr_doc, args)
pricing_rules[0].apply_rule_on_other_items = items for pricing_rule_args in pricing_rules:
pricing_rule_args.apply_rule_on_other_items = items
elif pricing_rules[0].is_cumulative: elif pricing_rules[0].is_cumulative:
items = [args.get(frappe.scrub(pr_doc.get('apply_on')))] items = [args.get(frappe.scrub(pr_doc.get('apply_on')))]
@@ -329,9 +330,9 @@ def get_qty_and_rate_for_mixed_conditions(doc, pr_doc, args):
if pr_doc.mixed_conditions: if pr_doc.mixed_conditions:
amt = args.get('qty') * args.get("price_list_rate") amt = args.get('qty') * args.get("price_list_rate")
if args.get("item_code") != row.get("item_code"): if args.get("item_code") != row.get("item_code"):
amt = row.get('qty') * row.get("price_list_rate") amt = row.get('qty') * (row.get("price_list_rate") or args.get("rate"))
sum_qty += row.get("stock_qty") or args.get("stock_qty") sum_qty += row.get("stock_qty") or args.get("stock_qty") or args.get("qty")
sum_amt += amt sum_amt += amt
if pr_doc.is_cumulative: if pr_doc.is_cumulative:

View File

@@ -4,7 +4,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe, erpnext import frappe, erpnext
from frappe.utils import cint, cstr, formatdate, flt, getdate, nowdate from frappe.utils import cint, cstr, formatdate, flt, getdate, nowdate, get_link_to_form
from frappe import _, throw from frappe import _, throw
import frappe.defaults import frappe.defaults
@@ -146,10 +146,14 @@ class PurchaseInvoice(BuyingController):
["account_type", "report_type", "account_currency"], as_dict=True) ["account_type", "report_type", "account_currency"], as_dict=True)
if account.report_type != "Balance Sheet": if account.report_type != "Balance Sheet":
frappe.throw(_("Credit To account must be a Balance Sheet account")) frappe.throw(_("Please ensure {} account is a Balance Sheet account. \
You can change the parent account to a Balance Sheet account or select a different account.")
.format(frappe.bold("Credit To")), title=_("Invalid Account"))
if self.supplier and account.account_type != "Payable": if self.supplier and account.account_type != "Payable":
frappe.throw(_("Credit To account must be a Payable account")) frappe.throw(_("Please ensure {} account is a Payable account. \
Change the account type to Payable or select a different account.")
.format(frappe.bold("Credit To")), title=_("Invalid Account"))
self.party_account_currency = account.account_currency self.party_account_currency = account.account_currency
@@ -255,16 +259,30 @@ class PurchaseInvoice(BuyingController):
def po_required(self): def po_required(self):
if frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes': if frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes':
if frappe.get_value('Supplier', self.supplier, 'allow_purchase_invoice_creation_without_purchase_order'):
return
for d in self.get('items'): for d in self.get('items'):
if not d.purchase_order: if not d.purchase_order:
throw(_("As per the Buying Settings if Purchase Order Required == 'YES', then for creating Purchase Invoice, user need to create Purchase Order first for item {0}").format(d.item_code)) throw(_("""Purchase Order Required for item {0}
To submit the invoice without purchase order please set
{1} as {2} in {3}""").format(frappe.bold(d.item_code), frappe.bold(_('Purchase Order Required')),
frappe.bold('No'), get_link_to_form('Buying Settings', 'Buying Settings', 'Buying Settings')))
def pr_required(self): def pr_required(self):
stock_items = self.get_stock_items() stock_items = self.get_stock_items()
if frappe.db.get_value("Buying Settings", None, "pr_required") == 'Yes': if frappe.db.get_value("Buying Settings", None, "pr_required") == 'Yes':
if frappe.get_value('Supplier', self.supplier, 'allow_purchase_invoice_creation_without_purchase_receipt'):
return
for d in self.get('items'): for d in self.get('items'):
if not d.purchase_receipt and d.item_code in stock_items: if not d.purchase_receipt and d.item_code in stock_items:
throw(_("As per the Buying Settings if Purchase Reciept Required == 'YES', then for creating Purchase Invoice, user need to create Purchase Receipt first for item {0}").format(d.item_code)) throw(_("""Purchase Receipt Required for item {0}
To submit the invoice without purchase receipt please set
{1} as {2} in {3}""").format(frappe.bold(d.item_code), frappe.bold(_('Purchase Receipt Required')),
frappe.bold('No'), get_link_to_form('Buying Settings', 'Buying Settings', 'Buying Settings')))
def validate_write_off_account(self): def validate_write_off_account(self):
if self.write_off_amount and not self.write_off_account: if self.write_off_amount and not self.write_off_account:

View File

@@ -760,7 +760,7 @@
"depends_on": "is_fixed_asset", "depends_on": "is_fixed_asset",
"fetch_from": "item_code.asset_category", "fetch_from": "item_code.asset_category",
"fieldname": "asset_category", "fieldname": "asset_category",
"fieldtype": "Data", "fieldtype": "Link",
"in_preview": 1, "in_preview": 1,
"label": "Asset Category", "label": "Asset Category",
"options": "Asset Category", "options": "Asset Category",
@@ -770,7 +770,7 @@
"idx": 1, "idx": 1,
"istable": 1, "istable": 1,
"links": [], "links": [],
"modified": "2020-03-05 14:20:17.297284", "modified": "2020-04-01 14:20:17.297284",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Purchase Invoice Item", "name": "Purchase Invoice Item",

View File

@@ -412,7 +412,7 @@ class SalesInvoice(SellingController):
if pos: if pos:
self.allow_print_before_pay = pos.allow_print_before_pay self.allow_print_before_pay = pos.allow_print_before_pay
if not for_validate: if not for_validate:
self.tax_category = pos.get("tax_category") self.tax_category = pos.get("tax_category")
@@ -429,13 +429,17 @@ class SalesInvoice(SellingController):
if (not for_validate) or (for_validate and not self.get(fieldname)): if (not for_validate) or (for_validate and not self.get(fieldname)):
self.set(fieldname, pos.get(fieldname)) self.set(fieldname, pos.get(fieldname))
customer_price_list = frappe.get_value("Customer", self.customer, 'default_price_list')
if pos.get("company_address"): if pos.get("company_address"):
self.company_address = pos.get("company_address") self.company_address = pos.get("company_address")
if not customer_price_list: customer_price_list, customer_group = frappe.get_value("Customer", self.customer, ['default_price_list', 'customer_group'])
self.set('selling_price_list', pos.get('selling_price_list'))
customer_group_price_list = frappe.get_value("Customer Group", customer_group, 'default_price_list')
selling_price_list = customer_price_list or customer_group_price_list or pos.get('selling_price_list')
if selling_price_list:
self.set('selling_price_list', selling_price_list)
if not for_validate: if not for_validate:
self.update_stock = cint(pos.get("update_stock")) self.update_stock = cint(pos.get("update_stock"))
@@ -466,13 +470,17 @@ class SalesInvoice(SellingController):
["account_type", "report_type", "account_currency"], as_dict=True) ["account_type", "report_type", "account_currency"], as_dict=True)
if not account: if not account:
frappe.throw(_("Debit To is required")) frappe.throw(_("Debit To is required"), title=_("Account Missing"))
if account.report_type != "Balance Sheet": if account.report_type != "Balance Sheet":
frappe.throw(_("Debit To account must be a Balance Sheet account")) frappe.throw(_("Please ensure {} account is a Balance Sheet account. \
You can change the parent account to a Balance Sheet account or select a different account.")
.format(frappe.bold("Debit To")), title=_("Invalid Account"))
if self.customer and account.account_type != "Receivable": if self.customer and account.account_type != "Receivable":
frappe.throw(_("Debit To account must be a Receivable account")) frappe.throw(_("Please ensure {} account is a Receivable account. \
Change the account type to Receivable or select a different account.")
.format(frappe.bold("Debit To")), title=_("Invalid Account"))
self.party_account_currency = account.account_currency self.party_account_currency = account.account_currency
@@ -534,14 +542,18 @@ class SalesInvoice(SellingController):
"""check in manage account if sales order / delivery note required or not.""" """check in manage account if sales order / delivery note required or not."""
if self.is_return: if self.is_return:
return return
dic = {'Sales Order':['so_required', 'is_pos'],'Delivery Note':['dn_required', 'update_stock']}
for i in dic: prev_doc_field_map = {'Sales Order': ['so_required', 'is_pos'],'Delivery Note': ['dn_required', 'update_stock']}
if frappe.db.get_single_value('Selling Settings', dic[i][0]) == 'Yes': for key, value in iteritems(prev_doc_field_map):
if frappe.db.get_single_value('Selling Settings', value[0]) == 'Yes':
if frappe.get_value('Customer', self.customer, value[0]):
continue
for d in self.get('items'): for d in self.get('items'):
is_stock_item = frappe.get_cached_value('Item', d.item_code, 'is_stock_item') is_stock_item = frappe.get_cached_value('Item', d.item_code, 'is_stock_item')
if (d.item_code and is_stock_item == 1\ if (d.item_code and is_stock_item ==1 and not d.get(key.lower().replace(' ', '_')) and not self.get(value[1])):
and not d.get(i.lower().replace(' ','_')) and not self.get(dic[i][1])): msgprint(_("{0} is mandatory for Item {1}").format(key, d.item_code), raise_exception=1)
msgprint(_("{0} is mandatory for Item {1}").format(i,d.item_code), raise_exception=1)
def validate_proj_cust(self): def validate_proj_cust(self):

View File

@@ -1868,6 +1868,16 @@ class TestSalesInvoice(unittest.TestCase):
item.taxes = [] item.taxes = []
item.save() item.save()
def test_customer_provided_parts_si(self):
create_item('CUST-0987', is_customer_provided_item = 1, customer = '_Test Customer', is_purchase_item = 0)
si = create_sales_invoice(item_code='CUST-0987', rate=0)
self.assertEqual(si.get("items")[0].allow_zero_valuation_rate, 1)
self.assertEqual(si.get("items")[0].amount, 0)
# test if Sales Invoice with rate is allowed
si2 = create_sales_invoice(item_code='CUST-0987', do_not_save=True)
self.assertRaises(frappe.ValidationError, si2.save)
def create_sales_invoice(**args): def create_sales_invoice(**args):
si = frappe.new_doc("Sales Invoice") si = frappe.new_doc("Sales Invoice")
args = frappe._dict(args) args = frappe._dict(args)
@@ -1890,7 +1900,7 @@ def create_sales_invoice(**args):
"gst_hsn_code": "999800", "gst_hsn_code": "999800",
"warehouse": args.warehouse or "_Test Warehouse - _TC", "warehouse": args.warehouse or "_Test Warehouse - _TC",
"qty": args.qty or 1, "qty": args.qty or 1,
"rate": args.rate or 100, "rate": args.rate if args.get("rate") is not None else 100,
"income_account": args.income_account or "Sales - _TC", "income_account": args.income_account or "Sales - _TC",
"expense_account": args.expense_account or "Cost of Goods Sold - _TC", "expense_account": args.expense_account or "Cost of Goods Sold - _TC",
"cost_center": args.cost_center or "_Test Cost Center - _TC", "cost_center": args.cost_center or "_Test Cost Center - _TC",

View File

@@ -82,7 +82,7 @@ class ShippingRule(Document):
if not shipping_country: if not shipping_country:
frappe.throw(_('Shipping Address does not have country, which is required for this Shipping Rule')) frappe.throw(_('Shipping Address does not have country, which is required for this Shipping Rule'))
if shipping_country not in [d.country for d in self.countries]: if shipping_country not in [d.country for d in self.countries]:
frappe.throw(_('Shipping rule not applicable for country {0}'.format(shipping_country))) frappe.throw(_('Shipping rule not applicable for country {0} in Shipping Address').format(shipping_country))
def add_shipping_rule_to_tax_table(self, doc, shipping_amount): def add_shipping_rule_to_tax_table(self, doc, shipping_amount):
shipping_charge = { shipping_charge = {

View File

@@ -163,8 +163,9 @@ def get_default_price_list(party):
def set_price_list(party_details, party, party_type, given_price_list, pos=None): def set_price_list(party_details, party, party_type, given_price_list, pos=None):
# price list # price list
price_list = get_permitted_documents('Price List') price_list = get_permitted_documents('Price List')
if price_list: # if there is only one permitted document based on user permissions, set it
if price_list and len(price_list) == 1:
price_list = price_list[0] price_list = price_list[0]
elif pos and party_type == 'Customer': elif pos and party_type == 'Customer':
customer_price_list = frappe.get_value('Customer', party.name, 'default_price_list') customer_price_list = frappe.get_value('Customer', party.name, 'default_price_list')

View File

@@ -218,15 +218,15 @@
<td></td> <td></td>
<td style="text-align: right"><b>{%= __("Total") %}</b></td> <td style="text-align: right"><b>{%= __("Total") %}</b></td>
<td style="text-align: right"> <td style="text-align: right">
{%= format_currency(data[i]["invoiced"], data[i]["currency"] ) %}</td> {%= format_currency(data[i]["invoiced"], data[0]["currency"] ) %}</td>
{% if(!filters.show_future_payments) { %} {% if(!filters.show_future_payments) { %}
<td style="text-align: right"> <td style="text-align: right">
{%= format_currency(data[i]["paid"], data[i]["currency"]) %}</td> {%= format_currency(data[i]["paid"], data[0]["currency"]) %}</td>
<td style="text-align: right">{%= format_currency(data[i]["credit_note"], data[i]["currency"]) %} </td> <td style="text-align: right">{%= format_currency(data[i]["credit_note"], data[0]["currency"]) %} </td>
{% } %} {% } %}
<td style="text-align: right"> <td style="text-align: right">
{%= format_currency(data[i]["outstanding"], data[i]["currency"]) %}</td> {%= format_currency(data[i]["outstanding"], data[0]["currency"]) %}</td>
{% if(filters.show_future_payments) { %} {% if(filters.show_future_payments) { %}
{% if(report.report_name === "Accounts Receivable") { %} {% if(report.report_name === "Accounts Receivable") { %}
@@ -234,8 +234,8 @@
{%= data[i]["po_no"] %}</td> {%= data[i]["po_no"] %}</td>
{% } %} {% } %}
<td style="text-align: right">{%= data[i]["future_ref"] %}</td> <td style="text-align: right">{%= data[i]["future_ref"] %}</td>
<td style="text-align: right">{%= format_currency(data[i]["future_amount"], data[i]["currency"]) %}</td> <td style="text-align: right">{%= format_currency(data[i]["future_amount"], data[0]["currency"]) %}</td>
<td style="text-align: right">{%= format_currency(data[i]["remaining_balance"], data[i]["currency"]) %}</td> <td style="text-align: right">{%= format_currency(data[i]["remaining_balance"], data[0]["currency"]) %}</td>
{% } %} {% } %}
{% } %} {% } %}
{% } else { %} {% } else { %}
@@ -256,10 +256,10 @@
{% } else { %} {% } else { %}
<td><b>{%= __("Total") %}</b></td> <td><b>{%= __("Total") %}</b></td>
{% } %} {% } %}
<td style="text-align: right">{%= format_currency(data[i]["invoiced"], data[i]["currency"]) %}</td> <td style="text-align: right">{%= format_currency(data[i]["invoiced"], data[0]["currency"]) %}</td>
<td style="text-align: right">{%= format_currency(data[i]["paid"], data[i]["currency"]) %}</td> <td style="text-align: right">{%= format_currency(data[i]["paid"], data[0]["currency"]) %}</td>
<td style="text-align: right">{%= format_currency(data[i]["credit_note"], data[i]["currency"]) %}</td> <td style="text-align: right">{%= format_currency(data[i]["credit_note"], data[0]["currency"]) %}</td>
<td style="text-align: right">{%= format_currency(data[i]["outstanding"], data[i]["currency"]) %}</td> <td style="text-align: right">{%= format_currency(data[i]["outstanding"], data[0]["currency"]) %}</td>
{% } %} {% } %}
{% } %} {% } %}
</tr> </tr>

View File

@@ -4,126 +4,137 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import _ from frappe import _
from frappe.utils import formatdate, getdate, flt, add_days from frappe.utils import formatdate, flt, add_days
def execute(filters=None): def execute(filters=None):
filters.day_before_from_date = add_days(filters.from_date, -1) filters.day_before_from_date = add_days(filters.from_date, -1)
columns, data = get_columns(filters), get_data(filters) columns, data = get_columns(filters), get_data(filters)
return columns, data return columns, data
def get_data(filters): def get_data(filters):
data = [] data = []
asset_categories = get_asset_categories(filters) asset_categories = get_asset_categories(filters)
assets = get_assets(filters) assets = get_assets(filters)
asset_costs = get_asset_costs(assets, filters)
asset_depreciations = get_accumulated_depreciations(assets, filters)
for asset_category in asset_categories: for asset_category in asset_categories:
row = frappe._dict() row = frappe._dict()
row.asset_category = asset_category # row.asset_category = asset_category
row.update(asset_costs.get(asset_category)) row.update(asset_category)
row.cost_as_on_to_date = (flt(row.cost_as_on_from_date) + flt(row.cost_of_new_purchase) -
flt(row.cost_of_sold_asset) - flt(row.cost_of_scrapped_asset))
row.update(next(asset for asset in assets if asset["asset_category"] == asset_category.get("asset_category", "")))
row.accumulated_depreciation_as_on_to_date = (flt(row.accumulated_depreciation_as_on_from_date) +
flt(row.depreciation_amount_during_the_period) - flt(row.depreciation_eliminated_during_the_period))
row.net_asset_value_as_on_from_date = (flt(row.cost_as_on_from_date) -
flt(row.accumulated_depreciation_as_on_from_date))
row.net_asset_value_as_on_to_date = (flt(row.cost_as_on_to_date) -
flt(row.accumulated_depreciation_as_on_to_date))
row.cost_as_on_to_date = (flt(row.cost_as_on_from_date) + flt(row.cost_of_new_purchase)
- flt(row.cost_of_sold_asset) - flt(row.cost_of_scrapped_asset))
row.update(asset_depreciations.get(asset_category))
row.accumulated_depreciation_as_on_to_date = (flt(row.accumulated_depreciation_as_on_from_date) +
flt(row.depreciation_amount_during_the_period) - flt(row.depreciation_eliminated))
row.net_asset_value_as_on_from_date = (flt(row.cost_as_on_from_date) -
flt(row.accumulated_depreciation_as_on_from_date))
row.net_asset_value_as_on_to_date = (flt(row.cost_as_on_to_date) -
flt(row.accumulated_depreciation_as_on_to_date))
data.append(row) data.append(row)
return data return data
def get_asset_categories(filters): def get_asset_categories(filters):
return frappe.db.sql_list(""" return frappe.db.sql("""
select distinct asset_category from `tabAsset` SELECT asset_category,
where docstatus=1 and company=%s and purchase_date <= %s ifnull(sum(case when purchase_date < %(from_date)s then
""", (filters.company, filters.to_date)) case when ifnull(disposal_date, 0) = 0 or disposal_date >= %(from_date)s then
gross_purchase_amount
else
0
end
else
0
end), 0) as cost_as_on_from_date,
ifnull(sum(case when purchase_date >= %(from_date)s then
gross_purchase_amount
else
0
end), 0) as cost_of_new_purchase,
ifnull(sum(case when ifnull(disposal_date, 0) != 0
and disposal_date >= %(from_date)s
and disposal_date <= %(to_date)s then
case when status = "Sold" then
gross_purchase_amount
else
0
end
else
0
end), 0) as cost_of_sold_asset,
ifnull(sum(case when ifnull(disposal_date, 0) != 0
and disposal_date >= %(from_date)s
and disposal_date <= %(to_date)s then
case when status = "Scrapped" then
gross_purchase_amount
else
0
end
else
0
end), 0) as cost_of_scrapped_asset
from `tabAsset`
where docstatus=1 and company=%(company)s and purchase_date <= %(to_date)s
group by asset_category
""", {"to_date": filters.to_date, "from_date": filters.from_date, "company": filters.company}, as_dict=1)
def get_assets(filters): def get_assets(filters):
return frappe.db.sql(""" return frappe.db.sql("""
select name, asset_category, purchase_date, gross_purchase_amount, disposal_date, status SELECT results.asset_category,
from `tabAsset` sum(results.accumulated_depreciation_as_on_from_date) as accumulated_depreciation_as_on_from_date,
where docstatus=1 and company=%s and purchase_date <= %s""", sum(results.depreciation_eliminated_during_the_period) as depreciation_eliminated_during_the_period,
(filters.company, filters.to_date), as_dict=1) sum(results.depreciation_amount_during_the_period) as depreciation_amount_during_the_period
from (SELECT a.asset_category,
def get_asset_costs(assets, filters): ifnull(sum(case when ds.schedule_date < %(from_date)s then
asset_costs = frappe._dict() ds.depreciation_amount
for d in assets: else
asset_costs.setdefault(d.asset_category, frappe._dict({ 0
"cost_as_on_from_date": 0, end), 0) as accumulated_depreciation_as_on_from_date,
"cost_of_new_purchase": 0, ifnull(sum(case when ifnull(a.disposal_date, 0) != 0 and a.disposal_date >= %(from_date)s
"cost_of_sold_asset": 0, and a.disposal_date <= %(to_date)s and ds.schedule_date <= a.disposal_date then
"cost_of_scrapped_asset": 0 ds.depreciation_amount
})) else
0
costs = asset_costs[d.asset_category] end), 0) as depreciation_eliminated_during_the_period,
ifnull(sum(case when ds.schedule_date >= %(from_date)s and ds.schedule_date <= %(to_date)s
if getdate(d.purchase_date) < getdate(filters.from_date): and (ifnull(a.disposal_date, 0) = 0 or ds.schedule_date <= a.disposal_date) then
if not d.disposal_date or getdate(d.disposal_date) >= getdate(filters.from_date): ds.depreciation_amount
costs.cost_as_on_from_date += flt(d.gross_purchase_amount) else
else: 0
costs.cost_of_new_purchase += flt(d.gross_purchase_amount) end), 0) as depreciation_amount_during_the_period
from `tabAsset` a, `tabDepreciation Schedule` ds
if d.disposal_date and getdate(d.disposal_date) >= getdate(filters.from_date) \ where a.docstatus=1 and a.company=%(company)s and a.purchase_date <= %(to_date)s and a.name = ds.parent
and getdate(d.disposal_date) <= getdate(filters.to_date): group by a.asset_category
if d.status == "Sold": union
costs.cost_of_sold_asset += flt(d.gross_purchase_amount) SELECT a.asset_category,
elif d.status == "Scrapped": ifnull(sum(case when ifnull(a.disposal_date, 0) != 0
costs.cost_of_scrapped_asset += flt(d.gross_purchase_amount) and (a.disposal_date < %(from_date)s or a.disposal_date > %(to_date)s)
then
return asset_costs 0
else
def get_accumulated_depreciations(assets, filters): a.opening_accumulated_depreciation
asset_depreciations = frappe._dict() end), 0) as accumulated_depreciation_as_on_from_date,
for d in assets: ifnull(sum(case when a.disposal_date >= %(from_date)s and a.disposal_date <= %(to_date)s then
asset = frappe.get_doc("Asset", d.name) a.opening_accumulated_depreciation
else
if d.asset_category in asset_depreciations: 0
asset_depreciations[d.asset_category]['accumulated_depreciation_as_on_from_date'] += asset.opening_accumulated_depreciation end), 0) as depreciation_eliminated_during_the_period,
else: 0 as depreciation_amount_during_the_period
asset_depreciations.setdefault(d.asset_category, frappe._dict({ from `tabAsset` a
"accumulated_depreciation_as_on_from_date": asset.opening_accumulated_depreciation, where a.docstatus=1 and a.company=%(company)s and a.purchase_date <= %(to_date)s
"depreciation_amount_during_the_period": 0, group by a.asset_category) as results
"depreciation_eliminated_during_the_period": 0 group by results.asset_category
})) """, {"to_date": filters.to_date, "from_date": filters.from_date, "company": filters.company}, as_dict=1)
depr = asset_depreciations[d.asset_category]
if not asset.schedules: # if no schedule,
if asset.disposal_date:
# and disposal is NOT within the period, then opening accumulated depreciation not included
if getdate(asset.disposal_date) < getdate(filters.from_date) or getdate(asset.disposal_date) > getdate(filters.to_date):
asset_depreciations[d.asset_category]['accumulated_depreciation_as_on_from_date'] = 0
# if no schedule, and disposal is within period, accumulated dep is the amount eliminated
if getdate(asset.disposal_date) >= getdate(filters.from_date) and getdate(asset.disposal_date) <= getdate(filters.to_date):
depr.depreciation_eliminated_during_the_period += asset.opening_accumulated_depreciation
for schedule in asset.get("schedules"):
if getdate(schedule.schedule_date) < getdate(filters.from_date):
if not asset.disposal_date or getdate(asset.disposal_date) >= getdate(filters.from_date):
depr.accumulated_depreciation_as_on_from_date += flt(schedule.depreciation_amount)
elif getdate(schedule.schedule_date) <= getdate(filters.to_date):
if not asset.disposal_date:
depr.depreciation_amount_during_the_period += flt(schedule.depreciation_amount)
else:
if getdate(schedule.schedule_date) <= getdate(asset.disposal_date):
depr.depreciation_amount_during_the_period += flt(schedule.depreciation_amount)
if asset.disposal_date and getdate(asset.disposal_date) >= getdate(filters.from_date) and getdate(asset.disposal_date) <= getdate(filters.to_date):
if getdate(schedule.schedule_date) <= getdate(asset.disposal_date):
depr.depreciation_eliminated_during_the_period += flt(schedule.depreciation_amount)
return asset_depreciations
def get_columns(filters): def get_columns(filters):
return [ return [
{ {

View File

@@ -419,7 +419,9 @@ def get_additional_conditions(from_date, ignore_closing_entries, filters):
if frappe.get_cached_value('DocType', dimension.document_type, 'is_tree'): if frappe.get_cached_value('DocType', dimension.document_type, 'is_tree'):
filters[dimension.fieldname] = get_dimension_with_children(dimension.document_type, filters[dimension.fieldname] = get_dimension_with_children(dimension.document_type,
filters.get(dimension.fieldname)) filters.get(dimension.fieldname))
additional_conditions.append("{0} in %({0})s".format(dimension.fieldname)) additional_conditions.append("{0} in %({0})s".format(dimension.fieldname))
else:
additional_conditions.append("{0} in (%({0})s)".format(dimension.fieldname))
return " and {}".format(" and ".join(additional_conditions)) if additional_conditions else "" return " and {}".format(" and ".join(additional_conditions)) if additional_conditions else ""

View File

@@ -131,7 +131,7 @@ def get_gl_entries(filters):
gl_entries = frappe.db.sql( gl_entries = frappe.db.sql(
""" """
select select
posting_date, account, party_type, party, name as gl_entry, posting_date, account, party_type, party,
voucher_type, voucher_no, cost_center, project, voucher_type, voucher_no, cost_center, project,
against_voucher_type, against_voucher, account_currency, against_voucher_type, against_voucher, account_currency,
remarks, against, is_opening {select_fields} remarks, against, is_opening {select_fields}
@@ -202,7 +202,9 @@ def get_conditions(filters):
if frappe.get_cached_value('DocType', dimension.document_type, 'is_tree'): if frappe.get_cached_value('DocType', dimension.document_type, 'is_tree'):
filters[dimension.fieldname] = get_dimension_with_children(dimension.document_type, filters[dimension.fieldname] = get_dimension_with_children(dimension.document_type,
filters.get(dimension.fieldname)) filters.get(dimension.fieldname))
conditions.append("{0} in %({0})s".format(dimension.fieldname)) conditions.append("{0} in %({0})s".format(dimension.fieldname))
else:
conditions.append("{0} in (%({0})s)".format(dimension.fieldname))
return "and {}".format(" and ".join(conditions)) if conditions else "" return "and {}".format(" and ".join(conditions)) if conditions else ""
@@ -362,6 +364,12 @@ def get_columns(filters):
currency = get_company_currency(company) currency = get_company_currency(company)
columns = [ columns = [
{
"fieldname": "gl_entry",
"fieldtype": "Link",
"options": "GL Entry",
"hidden": 1
},
{ {
"label": _("Posting Date"), "label": _("Posting Date"),
"fieldname": "posting_date", "fieldname": "posting_date",

View File

@@ -34,6 +34,33 @@ frappe.query_reports["Purchase Register"] = {
"label": __("Mode of Payment"), "label": __("Mode of Payment"),
"fieldtype": "Link", "fieldtype": "Link",
"options": "Mode of Payment" "options": "Mode of Payment"
},
{
"fieldname":"cost_center",
"label": __("Cost Center"),
"fieldtype": "Link",
"options": "Cost Center"
},
{
"fieldname":"warehouse",
"label": __("Warehouse"),
"fieldtype": "Link",
"options": "Warehouse"
},
{
"fieldname":"item_group",
"label": __("Item Group"),
"fieldtype": "Link",
"options": "Item Group"
} }
] ]
} }
erpnext.dimension_filters.forEach((dimension) => {
frappe.query_reports["Purchase Register"].filters.splice(7, 0 ,{
"fieldname": dimension["fieldname"],
"label": __(dimension["label"]),
"fieldtype": "Link",
"options": dimension["document_type"]
});
});

View File

@@ -5,6 +5,7 @@ from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import flt from frappe.utils import flt
from frappe import msgprint, _ from frappe import msgprint, _
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions, get_dimension_with_children
def execute(filters=None): def execute(filters=None):
return _execute(filters) return _execute(filters)
@@ -66,7 +67,7 @@ def _execute(filters=None, additional_table_columns=None, additional_query_colum
total_tax += tax_amount total_tax += tax_amount
row.append(tax_amount) row.append(tax_amount)
# total tax, grand total, rounded total & outstanding amount # total tax, grand total, rounded total & outstanding amount
row += [total_tax, inv.base_grand_total, flt(inv.base_grand_total, 0), inv.outstanding_amount] row += [total_tax, inv.base_grand_total, flt(inv.base_grand_total, 0), inv.outstanding_amount]
data.append(row) data.append(row)
@@ -134,6 +135,38 @@ def get_conditions(filters):
if filters.get("mode_of_payment"): conditions += " and ifnull(mode_of_payment, '') = %(mode_of_payment)s" if filters.get("mode_of_payment"): conditions += " and ifnull(mode_of_payment, '') = %(mode_of_payment)s"
if filters.get("cost_center"):
conditions += """ and exists(select name from `tabPurchase Invoice Item`
where parent=`tabPurchase Invoice`.name
and ifnull(`tabPurchase Invoice Item`.cost_center, '') = %(cost_center)s)"""
if filters.get("warehouse"):
conditions += """ and exists(select name from `tabPurchase Invoice Item`
where parent=`tabPurchase Invoice`.name
and ifnull(`tabPurchase Invoice Item`.warehouse, '') = %(warehouse)s)"""
if filters.get("item_group"):
conditions += """ and exists(select name from `tabPurchase Invoice Item`
where parent=`tabPurchase Invoice`.name
and ifnull(`tabPurchase Invoice Item`.item_group, '') = %(item_group)s)"""
accounting_dimensions = get_accounting_dimensions(as_list=False)
if accounting_dimensions:
common_condition = """
and exists(select name from `tabPurchase Invoice Item`
where parent=`tabPurchase Invoice`.name
"""
for dimension in accounting_dimensions:
if filters.get(dimension.fieldname):
if frappe.get_cached_value('DocType', dimension.document_type, 'is_tree'):
filters[dimension.fieldname] = get_dimension_with_children(dimension.document_type,
filters.get(dimension.fieldname))
conditions += common_condition + "and ifnull(`tabPurchase Invoice Item`.{0}, '') in %({0})s)".format(dimension.fieldname)
else:
conditions += common_condition + "and ifnull(`tabPurchase Invoice Item`.{0}, '') in (%({0})s))".format(dimension.fieldname)
return conditions return conditions
def get_invoices(filters, additional_query_columns): def get_invoices(filters, additional_query_columns):

View File

@@ -344,16 +344,19 @@ def get_conditions(filters):
accounting_dimensions = get_accounting_dimensions(as_list=False) accounting_dimensions = get_accounting_dimensions(as_list=False)
if accounting_dimensions: if accounting_dimensions:
common_condition = """
and exists(select name from `tabSales Invoice Item`
where parent=`tabSales Invoice`.name
"""
for dimension in accounting_dimensions: for dimension in accounting_dimensions:
if filters.get(dimension.fieldname): if filters.get(dimension.fieldname):
if frappe.get_cached_value('DocType', dimension.document_type, 'is_tree'): if frappe.get_cached_value('DocType', dimension.document_type, 'is_tree'):
filters[dimension.fieldname] = get_dimension_with_children(dimension.document_type, filters[dimension.fieldname] = get_dimension_with_children(dimension.document_type,
filters.get(dimension.fieldname)) filters.get(dimension.fieldname))
conditions += """ and exists(select name from `tabSales Invoice Item` conditions += common_condition + "and ifnull(`tabSales Invoice Item`.{0}, '') in %({0})s)".format(dimension.fieldname)
where parent=`tabSales Invoice`.name else:
and ifnull(`tabSales Invoice Item`.{0}, '') in %({0})s)""".format(dimension.fieldname) conditions += common_condition + "and ifnull(`tabSales Invoice Item`.{0}, '') in (%({0})s))".format(dimension.fieldname)
return conditions return conditions

View File

@@ -126,7 +126,9 @@ def get_rootwise_opening_balances(filters, report_type):
if frappe.get_cached_value('DocType', dimension.document_type, 'is_tree'): if frappe.get_cached_value('DocType', dimension.document_type, 'is_tree'):
filters[dimension.fieldname] = get_dimension_with_children(dimension.document_type, filters[dimension.fieldname] = get_dimension_with_children(dimension.document_type,
filters.get(dimension.fieldname)) filters.get(dimension.fieldname))
additional_conditions += "and {0} in %({0})s".format(dimension.fieldname) additional_conditions += "and {0} in %({0})s".format(dimension.fieldname)
else:
additional_conditions += "and {0} in (%({0})s)".format(dimension.fieldname)
query_filters.update({ query_filters.update({
dimension.fieldname: filters.get(dimension.fieldname) dimension.fieldname: filters.get(dimension.fieldname)

View File

@@ -141,7 +141,7 @@
], ],
"is_tree": 1, "is_tree": 1,
"links": [], "links": [],
"modified": "2020-03-18 18:35:41.062417", "modified": "2020-03-18 18:25:59.283057",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Assets", "module": "Assets",
"name": "Location", "name": "Location",

File diff suppressed because it is too large Load Diff

View File

@@ -9,7 +9,8 @@ def get_data():
'heatmap_message': _('This is based on transactions against this Supplier. See timeline below for details'), 'heatmap_message': _('This is based on transactions against this Supplier. See timeline below for details'),
'fieldname': 'supplier', 'fieldname': 'supplier',
'non_standard_fieldnames': { 'non_standard_fieldnames': {
'Payment Entry': 'party_name' 'Payment Entry': 'party_name',
'Bank Account': 'party'
}, },
'transactions': [ 'transactions': [
{ {
@@ -24,6 +25,10 @@ def get_data():
'label': _('Payments'), 'label': _('Payments'),
'items': ['Payment Entry'] 'items': ['Payment Entry']
}, },
{
'label': _('Bank'),
'items': ['Bank Account']
},
{ {
'label': _('Pricing'), 'label': _('Pricing'),
'items': ['Pricing Rule'] 'items': ['Pricing Rule']

View File

@@ -4,15 +4,17 @@
// attach required files // attach required files
{% include 'erpnext/public/js/controllers/buying.js' %}; {% include 'erpnext/public/js/controllers/buying.js' %};
frappe.ui.form.on('Suppier Quotation', {
setup: function(frm) {
frm.custom_make_buttons = {
'Purchase Order': 'Purchase Order'
}
}
});
erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({ erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({
setup: function() {
this.frm.custom_make_buttons = {
'Purchase Order': 'Purchase Order',
'Quotation': 'Quotation',
'Subscription': 'Subscription'
}
this._super();
},
refresh: function() { refresh: function() {
var me = this; var me = this;
this._super(); this._super();

View File

@@ -19,6 +19,7 @@ from erpnext.accounts.doctype.pricing_rule.utils import (apply_pricing_rule_on_t
from erpnext.exceptions import InvalidCurrency from erpnext.exceptions import InvalidCurrency
from six import text_type from six import text_type
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions
from erpnext.stock.get_item_details import get_item_warehouse
force_item_fields = ("item_group", "brand", "stock_uom", "is_fixed_asset", "item_tax_rate", "pricing_rules") force_item_fields = ("item_group", "brand", "stock_uom", "is_fixed_asset", "item_tax_rate", "pricing_rules")
@@ -1126,16 +1127,16 @@ def set_sales_order_defaults(parent_doctype, parent_doctype_name, child_docname,
""" """
Returns a Sales Order Item child item containing the default values Returns a Sales Order Item child item containing the default values
""" """
p_doctype = frappe.get_doc(parent_doctype, parent_doctype_name) p_doc = frappe.get_doc(parent_doctype, parent_doctype_name)
child_item = frappe.new_doc('Sales Order Item', p_doctype, child_docname) child_item = frappe.new_doc('Sales Order Item', p_doc, child_docname)
item = frappe.get_doc("Item", item_code) item = frappe.get_doc("Item", item_code)
child_item.item_code = item.item_code child_item.item_code = item.item_code
child_item.item_name = item.item_name child_item.item_name = item.item_name
child_item.description = item.description child_item.description = item.description
child_item.reqd_by_date = p_doctype.delivery_date child_item.reqd_by_date = p_doc.delivery_date
child_item.uom = item.stock_uom child_item.uom = item.stock_uom
child_item.conversion_factor = get_conversion_factor(item_code, item.stock_uom).get("conversion_factor") or 1.0 child_item.conversion_factor = get_conversion_factor(item_code, item.stock_uom).get("conversion_factor") or 1.0
child_item.warehouse = p_doctype.set_warehouse or p_doctype.items[0].warehouse child_item.warehouse = get_item_warehouse(item, p_doc, overwrite_warehouse=True)
return child_item return child_item
@@ -1143,13 +1144,13 @@ def set_purchase_order_defaults(parent_doctype, parent_doctype_name, child_docna
""" """
Returns a Purchase Order Item child item containing the default values Returns a Purchase Order Item child item containing the default values
""" """
p_doctype = frappe.get_doc(parent_doctype, parent_doctype_name) p_doc = frappe.get_doc(parent_doctype, parent_doctype_name)
child_item = frappe.new_doc('Purchase Order Item', p_doctype, child_docname) child_item = frappe.new_doc('Purchase Order Item', p_doc, child_docname)
item = frappe.get_doc("Item", item_code) item = frappe.get_doc("Item", item_code)
child_item.item_code = item.item_code child_item.item_code = item.item_code
child_item.item_name = item.item_name child_item.item_name = item.item_name
child_item.description = item.description child_item.description = item.description
child_item.schedule_date = p_doctype.schedule_date child_item.schedule_date = p_doc.schedule_date
child_item.uom = item.stock_uom child_item.uom = item.stock_uom
child_item.conversion_factor = get_conversion_factor(item_code, item.stock_uom).get("conversion_factor") or 1.0 child_item.conversion_factor = get_conversion_factor(item_code, item.stock_uom).get("conversion_factor") or 1.0
child_item.base_rate = 1 # Initiallize value will update in parent validation child_item.base_rate = 1 # Initiallize value will update in parent validation

View File

@@ -658,19 +658,32 @@ class BuyingController(StockController):
# If asset has to be auto created # If asset has to be auto created
# Check for asset naming series # Check for asset naming series
if item_data.get('asset_naming_series'): if item_data.get('asset_naming_series'):
created_assets = []
for qty in range(cint(d.qty)): for qty in range(cint(d.qty)):
self.make_asset(d) asset = self.make_asset(d)
is_plural = 's' if cint(d.qty) != 1 else '' created_assets.append(asset)
messages.append(_('{0} Asset{2} Created for <b>{1}</b>').format(cint(d.qty), d.item_code, is_plural))
if len(created_assets) > 5:
# dont show asset form links if more than 5 assets are created
messages.append(_('{} Asset{} created for {}').format(len(created_assets), is_plural, frappe.bold(d.item_code)))
else:
assets_link = list(map(lambda d: frappe.utils.get_link_to_form('Asset', d), created_assets))
assets_link = frappe.bold(','.join(assets_link))
is_plural = 's' if len(created_assets) != 1 else ''
messages.append(
_('Asset{} {assets_link} created for {}').format(is_plural, frappe.bold(d.item_code), assets_link=assets_link)
)
else: else:
frappe.throw(_("Row {1}: Asset Naming Series is mandatory for the auto creation for item {0}") frappe.throw(_("Row {}: Asset Naming Series is mandatory for the auto creation for item {}")
.format(d.item_code, d.idx)) .format(d.idx, frappe.bold(d.item_code)))
else: else:
messages.append(_("Assets not created for <b>{0}</b>. You will have to create asset manually.") messages.append(_("Assets not created for {0}. You will have to create asset manually.")
.format(d.item_code)) .format(frappe.bold(d.item_code)))
for message in messages: for message in messages:
frappe.msgprint(message, title="Success") frappe.msgprint(message, title="Success", indicator="green")
def make_asset(self, row): def make_asset(self, row):
if not row.asset_location: if not row.asset_location:
@@ -702,6 +715,8 @@ class BuyingController(StockController):
asset.set_missing_values() asset.set_missing_values()
asset.insert() asset.insert()
return asset.name
def update_fixed_asset(self, field, delete_asset = False): def update_fixed_asset(self, field, delete_asset = False):
for d in self.get("items"): for d in self.get("items"):
if d.is_fixed_asset: if d.is_fixed_asset:
@@ -731,7 +746,7 @@ class BuyingController(StockController):
asset.supplier = None asset.supplier = None
if asset.docstatus == 1 and delete_asset: if asset.docstatus == 1 and delete_asset:
frappe.throw(_('Cannot cancel this document as it is linked with submitted asset {0}.\ frappe.throw(_('Cannot cancel this document as it is linked with submitted asset {0}.\
Please cancel the it to continue.').format(asset.name)) Please cancel the it to continue.').format(frappe.utils.get_link_to_form('Asset', asset.name)))
asset.flags.ignore_validate_update_after_submit = True asset.flags.ignore_validate_update_after_submit = True
asset.flags.ignore_mandatory = True asset.flags.ignore_mandatory = True
@@ -1012,4 +1027,4 @@ def get_batches_with_qty(item_code, fg_item, required_qty, transferred_batch_qty
available_batches.append({'batch': batch, 'qty': available_qty}) available_batches.append({'batch': batch, 'qty': available_qty})
required_qty -= available_qty required_qty -= available_qty
return available_batches return available_batches

View File

@@ -3,6 +3,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
import erpnext
from frappe.desk.reportview import get_match_cond, get_filters_cond from frappe.desk.reportview import get_match_cond, get_filters_cond
from frappe.utils import nowdate, getdate from frappe.utils import nowdate, getdate
from collections import defaultdict from collections import defaultdict
@@ -129,23 +130,26 @@ def supplier_query(doctype, txt, searchfield, start, page_len, filters):
}) })
def tax_account_query(doctype, txt, searchfield, start, page_len, filters): def tax_account_query(doctype, txt, searchfield, start, page_len, filters):
company_currency = erpnext.get_company_currency(filters.get('company'))
tax_accounts = frappe.db.sql("""select name, parent_account from tabAccount tax_accounts = frappe.db.sql("""select name, parent_account from tabAccount
where tabAccount.docstatus!=2 where tabAccount.docstatus!=2
and account_type in (%s) and account_type in (%s)
and is_group = 0 and is_group = 0
and company = %s and company = %s
and account_currency = %s
and `%s` LIKE %s and `%s` LIKE %s
order by idx desc, name order by idx desc, name
limit %s, %s""" % limit %s, %s""" %
(", ".join(['%s']*len(filters.get("account_type"))), "%s", searchfield, "%s", "%s", "%s"), (", ".join(['%s']*len(filters.get("account_type"))), "%s", "%s", searchfield, "%s", "%s", "%s"),
tuple(filters.get("account_type") + [filters.get("company"), "%%%s%%" % txt, tuple(filters.get("account_type") + [filters.get("company"), company_currency, "%%%s%%" % txt,
start, page_len])) start, page_len]))
if not tax_accounts: if not tax_accounts:
tax_accounts = frappe.db.sql("""select name, parent_account from tabAccount tax_accounts = frappe.db.sql("""select name, parent_account from tabAccount
where tabAccount.docstatus!=2 and is_group = 0 where tabAccount.docstatus!=2 and is_group = 0
and company = %s and `%s` LIKE %s limit %s, %s""" and company = %s and account_currency = %s and `%s` LIKE %s limit %s, %s""" #nosec
% ("%s", searchfield, "%s", "%s", "%s"), % ("%s", "%s", searchfield, "%s", "%s", "%s"),
(filters.get("company"), "%%%s%%" % txt, start, page_len)) (filters.get("company"), company_currency, "%%%s%%" % txt, start, page_len))
return tax_accounts return tax_accounts

View File

@@ -148,13 +148,6 @@ class SellingController(StockController):
if sales_team and total != 100.0: if sales_team and total != 100.0:
throw(_("Total allocated percentage for sales team should be 100")) throw(_("Total allocated percentage for sales team should be 100"))
def validate_order_type(self):
valid_types = ["Sales", "Maintenance", "Shopping Cart"]
if not self.order_type:
self.order_type = "Sales"
elif self.order_type not in valid_types:
throw(_("Order Type must be one of {0}").format(comma_or(valid_types)))
def validate_max_discount(self): def validate_max_discount(self):
for d in self.get("items"): for d in self.get("items"):
if d.item_code: if d.item_code:

View File

@@ -69,16 +69,16 @@ status_map = {
["Cancelled", "eval:self.docstatus==2"], ["Cancelled", "eval:self.docstatus==2"],
["Closed", "eval:self.status=='Closed'"], ["Closed", "eval:self.status=='Closed'"],
], ],
"Purchase Invoice": [ "Purchase Invoice": [
["Draft", None], ["Draft", None],
["Submitted", "eval:self.docstatus==1"], ["Submitted", "eval:self.docstatus==1"],
["Paid", "eval:self.outstanding_amount==0 and self.docstatus==1"], ["Paid", "eval:self.outstanding_amount==0 and self.docstatus==1"],
["Return", "eval:self.is_return==1 and self.docstatus==1"], ["Return", "eval:self.is_return==1 and self.docstatus==1"],
["Debit Note Issued", ["Debit Note Issued",
"eval:self.outstanding_amount <= 0 and self.docstatus==1 and self.is_return==0 and get_value('Purchase Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1})"], "eval:self.outstanding_amount <= 0 and self.docstatus==1 and self.is_return==0 and get_value('Purchase Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1})"],
["Unpaid", "eval:self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.docstatus==1"], ["Unpaid", "eval:self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.docstatus==1"],
["Overdue", "eval:self.outstanding_amount > 0 and getdate(self.due_date) < getdate(nowdate()) and self.docstatus==1"], ["Overdue", "eval:self.outstanding_amount > 0 and getdate(self.due_date) < getdate(nowdate()) and self.docstatus==1"],
["Cancelled", "eval:self.docstatus==2"], ["Cancelled", "eval:self.docstatus==2"],
], ],
"Material Request": [ "Material Request": [
["Draft", None], ["Draft", None],

View File

@@ -21,6 +21,7 @@ class StockController(AccountsController):
super(StockController, self).validate() super(StockController, self).validate()
self.validate_inspection() self.validate_inspection()
self.validate_serialized_batch() self.validate_serialized_batch()
self.validate_customer_provided_item()
def make_gl_entries(self, gl_entries=None, repost_future_gle=True, from_repost=False): def make_gl_entries(self, gl_entries=None, repost_future_gle=True, from_repost=False):
if self.docstatus == 2: if self.docstatus == 2:
@@ -368,6 +369,15 @@ class StockController(AccountsController):
for blanket_order in blanket_orders: for blanket_order in blanket_orders:
frappe.get_doc("Blanket Order", blanket_order).update_ordered_qty() frappe.get_doc("Blanket Order", blanket_order).update_ordered_qty()
def validate_customer_provided_item(self):
for d in self.get('items'):
# Customer Provided parts will have zero valuation rate
if frappe.db.get_value('Item', d.item_code, 'is_customer_provided_item'):
d.allow_zero_valuation_rate = 1
if d.parenttype in ["Delivery Note", "Sales Invoice"] and d.rate:
frappe.throw(_("Row #{0}: {1} cannot have {2} as it is a Customer Provided Item")
.format(d.idx, frappe.bold(d.item_code), frappe.bold("Rate")))
def update_gl_entries_after(posting_date, posting_time, for_warehouses=None, for_items=None, def update_gl_entries_after(posting_date, posting_time, for_warehouses=None, for_items=None,
warehouse_account=None, company=None): warehouse_account=None, company=None):
def _delete_gl_entries(voucher_type, voucher_no): def _delete_gl_entries(voucher_type, voucher_no):

View File

@@ -1,4 +1,5 @@
{ {
"actions": [],
"allow_import": 1, "allow_import": 1,
"allow_rename": 1, "allow_rename": 1,
"autoname": "naming_series:", "autoname": "naming_series:",
@@ -208,7 +209,8 @@
{ {
"fieldname": "opportunity_amount", "fieldname": "opportunity_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Opportunity Amount" "label": "Opportunity Amount",
"options": "currency"
}, },
{ {
"default": "0", "default": "0",
@@ -412,7 +414,8 @@
], ],
"icon": "fa fa-info-sign", "icon": "fa fa-info-sign",
"idx": 195, "idx": 195,
"modified": "2019-09-30 12:58:37.385400", "links": [],
"modified": "2020-03-20 12:28:45.228994",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "CRM", "module": "CRM",
"name": "Opportunity", "name": "Opportunity",

View File

@@ -64,7 +64,7 @@
], ],
"is_tree": 1, "is_tree": 1,
"links": [], "links": [],
"modified": "2020-03-18 18:35:48.798477", "modified": "2020-03-18 18:26:07.834596",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Education", "module": "Education",
"name": "Assessment Group", "name": "Assessment Group",

View File

@@ -74,7 +74,7 @@
} }
], ],
"image_field": "hero_image", "image_field": "hero_image",
"modified": "2019-06-12 12:34:23.748157", "modified": "2020-03-29 12:50:27.677589",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Education", "module": "Education",
"name": "Course", "name": "Course",
@@ -103,6 +103,30 @@
"role": "Instructor", "role": "Instructor",
"share": 1, "share": 1,
"write": 1 "write": 1
},
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Administrator",
"share": 1,
"write": 1
},
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Education Manager",
"share": 1,
"write": 1
} }
], ],
"restrict_to_domain": "Education", "restrict_to_domain": "Education",

View File

@@ -121,7 +121,7 @@ def call_mws_method(mws_method, *args, **kwargs):
time.sleep(delay) time.sleep(delay)
continue continue
mws_settings.enable_synch = 0 mws_settings.enable_sync = 0
mws_settings.save() mws_settings.save()
frappe.throw(_("Sync has been temporarily disabled because maximum retries have been exceeded")) frappe.throw(_("Sync has been temporarily disabled because maximum retries have been exceeded"))

View File

@@ -39,16 +39,19 @@ __all__ = [
# for a list of the end points and marketplace IDs # for a list of the end points and marketplace IDs
MARKETPLACES = { MARKETPLACES = {
"CA" : "https://mws.amazonservices.ca", #A2EUQ1WTGCTBG2 "CA": "https://mws.amazonservices.ca", #A2EUQ1WTGCTBG2
"US" : "https://mws.amazonservices.com", #ATVPDKIKX0DER", "US": "https://mws.amazonservices.com", #ATVPDKIKX0DER",
"DE" : "https://mws-eu.amazonservices.com", #A1PA6795UKMFR9 "DE": "https://mws-eu.amazonservices.com", #A1PA6795UKMFR9
"ES" : "https://mws-eu.amazonservices.com", #A1RKKUPIHCS9HS "ES": "https://mws-eu.amazonservices.com", #A1RKKUPIHCS9HS
"FR" : "https://mws-eu.amazonservices.com", #A13V1IB3VIYZZH "FR": "https://mws-eu.amazonservices.com", #A13V1IB3VIYZZH
"IN" : "https://mws.amazonservices.in", #A21TJRUUN4KGV "IN": "https://mws.amazonservices.in", #A21TJRUUN4KGV
"IT" : "https://mws-eu.amazonservices.com", #APJ6JRA9NG5V4 "IT": "https://mws-eu.amazonservices.com", #APJ6JRA9NG5V4
"UK" : "https://mws-eu.amazonservices.com", #A1F83G8C2ARO7P "UK": "https://mws-eu.amazonservices.com", #A1F83G8C2ARO7P
"JP" : "https://mws.amazonservices.jp", #A1VC38T7YXB528 "JP": "https://mws.amazonservices.jp", #A1VC38T7YXB528
"CN" : "https://mws.amazonservices.com.cn", #AAHKV2X7AFYLW "CN": "https://mws.amazonservices.com.cn", #AAHKV2X7AFYLW
"AE": " https://mws.amazonservices.ae", #A2VIGQ35RCS4UG
"MX": "https://mws.amazonservices.com.mx", #A1AM78C64UM0Y8
"BR": "https://mws.amazonservices.com", #A2Q3Y263D00KWC
} }

View File

@@ -7,14 +7,15 @@ import frappe
from frappe.model.document import Document from frappe.model.document import Document
import dateutil import dateutil
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
from erpnext.erpnext_integrations.doctype.amazon_mws_settings.amazon_methods import get_orders
class AmazonMWSSettings(Document): class AmazonMWSSettings(Document):
def validate(self): def validate(self):
if self.enable_amazon == 1: if self.enable_amazon == 1:
self.enable_synch = 1 self.enable_sync = 1
setup_custom_fields() setup_custom_fields()
else: else:
self.enable_synch = 0 self.enable_sync = 0
def get_products_details(self): def get_products_details(self):
if self.enable_amazon == 1: if self.enable_amazon == 1:
@@ -27,7 +28,7 @@ class AmazonMWSSettings(Document):
def schedule_get_order_details(): def schedule_get_order_details():
mws_settings = frappe.get_doc("Amazon MWS Settings") mws_settings = frappe.get_doc("Amazon MWS Settings")
if mws_settings.enable_synch and mws_settings.enable_amazon: if mws_settings.enable_sync and mws_settings.enable_amazon:
after_date = dateutil.parser.parse(mws_settings.after_date).strftime("%Y-%m-%d") after_date = dateutil.parser.parse(mws_settings.after_date).strftime("%Y-%m-%d")
get_orders(after_date = after_date) get_orders(after_date = after_date)

View File

@@ -5,20 +5,16 @@ frappe.ui.form.on('Clinical Procedure', {
setup: function(frm) { setup: function(frm) {
frm.set_query('batch_no', 'items', function(doc, cdt, cdn) { frm.set_query('batch_no', 'items', function(doc, cdt, cdn) {
var item = locals[cdt][cdn]; var item = locals[cdt][cdn];
if(!item.item_code) { if (!item.item_code) {
frappe.throw(__("Please enter Item Code to get Batch Number")); frappe.throw(__('Please enter Item Code to get Batch Number'));
} else { } else {
let filters = {'item_code': item.item_code};
if (frm.doc.status == 'In Progress') { if (frm.doc.status == 'In Progress') {
var filters = { filters['posting_date'] = frm.doc.start_date || frappe.datetime.nowdate();
'item_code': item.item_code, if (frm.doc.warehouse) filters['warehouse'] = frm.doc.warehouse;
'posting_date': frm.doc.start_date || frappe.datetime.nowdate()
};
if(frm.doc.warehouse) filters["warehouse"] = frm.doc.warehouse;
} else {
filters = {
'item_code': item.item_code
};
} }
return { return {
query : "erpnext.controllers.queries.get_batch_no", query : "erpnext.controllers.queries.get_batch_no",
filters: filters filters: filters
@@ -29,7 +25,7 @@ frappe.ui.form.on('Clinical Procedure', {
refresh: function(frm) { refresh: function(frm) {
frm.set_query("patient", function () { frm.set_query("patient", function () {
return { return {
filters: {"disabled": 0} filters: {"status": "Active"}
}; };
}); });
frm.set_query("appointment", function () { frm.set_query("appointment", function () {

View File

@@ -31,17 +31,7 @@ frappe.ui.form.on('Clinical Procedure Template', {
if(!frm.doc.__islocal) { if(!frm.doc.__islocal) {
cur_frm.add_custom_button(__('Change Item Code'), function() { cur_frm.add_custom_button(__('Change Item Code'), function() {
change_template_code(frm.doc); change_template_code(frm.doc);
} ); });
if(frm.doc.disabled == 1){
cur_frm.add_custom_button(__('Enable Template'), function() {
enable_template(frm.doc);
} );
}
else{
cur_frm.add_custom_button(__('Disable Template'), function() {
disable_template(frm.doc);
} );
}
} }
} }
}); });
@@ -52,27 +42,6 @@ var mark_change_in_item = function(frm) {
} }
}; };
var disable_template = function(doc){
frappe.call({
method: "erpnext.healthcare.doctype.clinical_procedure_template.clinical_procedure_template.disable_enable_template",
args: {status: 1, name: doc.name, item_code: doc.item_code, is_billable: doc.is_billable},
callback: function(){
cur_frm.reload_doc();
}
});
};
var enable_template = function(doc){
frappe.call({
method: "erpnext.healthcare.doctype.clinical_procedure_template.clinical_procedure_template.disable_enable_template",
args: {status: 0, name: doc.name, item_code: doc.item_code, is_billable: doc.is_billable},
callback: function(){
cur_frm.reload_doc();
}
});
};
var change_template_code = function(doc){ var change_template_code = function(doc){
var d = new frappe.ui.Dialog({ var d = new frappe.ui.Dialog({
title:__("Change Template Code"), title:__("Change Template Code"),

View File

@@ -9,26 +9,36 @@ from frappe.model.document import Document
from frappe.utils import nowdate from frappe.utils import nowdate
class ClinicalProcedureTemplate(Document): class ClinicalProcedureTemplate(Document):
def on_update(self): def validate(self):
#Item and Price List update --> if (change_in_item) self.enable_disable_item()
if(self.change_in_item and self.is_billable == 1 and self.item):
updating_item(self)
if(self.rate != 0.0):
updating_rate(self)
elif(self.is_billable == 0 and self.item):
frappe.db.set_value("Item",self.item,"disabled",1)
frappe.db.set_value(self.doctype,self.name,"change_in_item",0)
self.reload()
def after_insert(self): def after_insert(self):
create_item_from_template(self) create_item_from_template(self)
def on_update(self):
#Item and Price List update --> if (change_in_item)
if self.change_in_item and self.is_billable == 1 and self.item:
updating_item(self)
if self.rate != 0.0:
updating_rate(self)
elif self.is_billable == 0 and self.item:
frappe.db.set_value('Item',self.item,'disabled',1)
frappe.db.set_value(self.doctype,self.name,'change_in_item',0)
self.reload()
def enable_disable_item(self):
if self.is_billable:
if self.disabled:
frappe.db.set_value('Item', self.item, 'disabled', 1)
else:
frappe.db.set_value('Item', self.item, 'disabled', 0)
#Call before delete the template #Call before delete the template
def on_trash(self): def on_trash(self):
if(self.item): if(self.item):
try: try:
frappe.delete_doc("Item",self.item) frappe.delete_doc('Item',self.item)
except Exception: except Exception:
frappe.throw(_("""Not permitted. Please disable the Procedure Template""")) frappe.throw(_("""Not permitted. Please disable the Procedure Template"""))
@@ -40,7 +50,7 @@ class ClinicalProcedureTemplate(Document):
and (end_of_life is null or end_of_life='0000-00-00' or end_of_life > %s)""", and (end_of_life is null or end_of_life='0000-00-00' or end_of_life > %s)""",
(args.get('item_code'), nowdate()), as_dict = 1) (args.get('item_code'), nowdate()), as_dict = 1)
if not item: if not item:
frappe.throw(_("Item {0} is not active or end of life has been reached").format(args.get('item_code'))) frappe.throw(_('Item {0} is not active or end of life has been reached').format(args.get('item_code')))
item = item[0] item = item[0]
@@ -63,46 +73,47 @@ def updating_rate(self):
item_code=%s""",(self.template, self.rate, self.item)) item_code=%s""",(self.template, self.rate, self.item))
def create_item_from_template(doc): def create_item_from_template(doc):
if(doc.is_billable == 1): disabled = 1
if doc.is_billable:
disabled = 0 disabled = 0
else:
disabled = 1
#insert item #insert item
item = frappe.get_doc({ item = frappe.get_doc({
"doctype": "Item", 'doctype': 'Item',
"item_code": doc.template, 'item_code': doc.template,
"item_name":doc.template, 'item_name':doc.template,
"item_group": doc.item_group, 'item_group': doc.item_group,
"description":doc.description, 'description':doc.description,
"is_sales_item": 1, 'is_sales_item': 1,
"is_service_item": 1, 'is_service_item': 1,
"is_purchase_item": 0, 'is_purchase_item': 0,
"is_stock_item": 0, 'is_stock_item': 0,
"show_in_website": 0, 'show_in_website': 0,
"is_pro_applicable": 0, 'is_pro_applicable': 0,
"disabled": disabled, 'disabled': disabled,
"stock_uom": "Unit" 'stock_uom': 'Unit'
}).insert(ignore_permissions=True) }).insert(ignore_permissions=True)
#insert item price #insert item price
#get item price list to insert item price #get item price list to insert item price
if(doc.rate != 0.0): if(doc.rate != 0.0):
price_list_name = frappe.db.get_value("Price List", {"selling": 1}) price_list_name = frappe.db.get_value('Price List', {'selling': 1})
if(doc.rate): if(doc.rate):
make_item_price(item.name, price_list_name, doc.rate) make_item_price(item.name, price_list_name, doc.rate)
else: else:
make_item_price(item.name, price_list_name, 0.0) make_item_price(item.name, price_list_name, 0.0)
#Set item to the template #Set item to the template
frappe.db.set_value("Clinical Procedure Template", doc.name, "item", item.name) frappe.db.set_value('Clinical Procedure Template', doc.name, 'item', item.name)
doc.reload() #refresh the doc after insert. doc.reload() #refresh the doc after insert.
def make_item_price(item, price_list_name, item_price): def make_item_price(item, price_list_name, item_price):
frappe.get_doc({ frappe.get_doc({
"doctype": "Item Price", 'doctype': 'Item Price',
"price_list": price_list_name, 'price_list': price_list_name,
"item_code": item, 'item_code': item,
"price_list_rate": item_price 'price_list_rate': item_price
}).insert(ignore_permissions=True) }).insert(ignore_permissions=True)
@frappe.whitelist() @frappe.whitelist()
@@ -111,20 +122,11 @@ def change_item_code_from_template(item_code, doc):
doc = frappe._dict(args) doc = frappe._dict(args)
if(frappe.db.exists({ if(frappe.db.exists({
"doctype": "Item", 'doctype': 'Item',
"item_code": item_code})): 'item_code': item_code})):
frappe.throw(_("Code {0} already exist").format(item_code)) frappe.throw(_('Code {0} already exist').format(item_code))
else: else:
frappe.rename_doc("Item", doc.item_code, item_code, ignore_permissions = True) frappe.rename_doc('Item', doc.item_code, item_code, ignore_permissions=True)
frappe.db.set_value("Clinical Procedure Template", doc.name, "item_code", item_code) frappe.db.set_value('Clinical Procedure Template', doc.name, 'item_code', item_code)
return return
@frappe.whitelist()
def disable_enable_template(status, name, item_code):
frappe.db.set_value("Clinical Procedure Template", name, "disabled", status)
if (frappe.db.exists({ #set Item's disabled field to status
"doctype": "Item",
"item_code": item_code})):
frappe.db.set_value("Item", item_code, "disabled", status)
return

View File

@@ -156,7 +156,7 @@
], ],
"is_tree": 1, "is_tree": 1,
"links": [], "links": [],
"modified": "2020-03-18 18:35:47.811627", "modified": "2020-03-18 18:26:06.360941",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Healthcare", "module": "Healthcare",
"name": "Healthcare Service Unit", "name": "Healthcare Service Unit",

View File

@@ -78,6 +78,7 @@
}, },
{ {
"default": "0", "default": "0",
"description": "Checking this will create new Patients with a Disabled status by default and will only be enabled after invoicing the Registration Fee.",
"fieldname": "collect_registration_fee", "fieldname": "collect_registration_fee",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Collect Fee for Patient Registration" "label": "Collect Fee for Patient Registration"

View File

@@ -290,19 +290,23 @@ def insert_lab_test_to_medical_record(doc):
comment = "" comment = ""
if item.lab_test_comment: if item.lab_test_comment:
comment = str(item.lab_test_comment) comment = str(item.lab_test_comment)
event = "" table_row = item.lab_test_name
if item.lab_test_event: if item.lab_test_event:
event = item.lab_test_event table_row += " " + item.lab_test_event
table_row = item.lab_test_name +" "+ event +" "+ item.result_value
if item.result_value:
table_row += " " + item.result_value
if item.normal_range: if item.normal_range:
table_row += " normal_range("+item.normal_range+")" table_row += " normal_range("+item.normal_range+")"
table_row += " "+comment table_row += " " + comment
elif doc.special_test_items: elif doc.special_test_items:
item = doc.special_test_items[0] item = doc.special_test_items[0]
if item.lab_test_particulars and item.result_value: if item.lab_test_particulars and item.result_value:
table_row = item.lab_test_particulars +" "+ item.result_value table_row = item.lab_test_particulars + " " + item.result_value
elif doc.sensitivity_test_items: elif doc.sensitivity_test_items:
item = doc.sensitivity_test_items[0] item = doc.sensitivity_test_items[0]

View File

@@ -5,6 +5,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe, json import frappe, json
from frappe.model.document import Document from frappe.model.document import Document
from frappe.model.rename_doc import rename_doc
from frappe import _ from frappe import _
class LabTestTemplate(Document): class LabTestTemplate(Document):
@@ -98,13 +99,11 @@ def create_item_from_template(doc):
# get item price list to insert item price # get item price list to insert item price
if doc.lab_test_rate != 0.0: if doc.lab_test_rate != 0.0:
price_list_name = frappe.db.get_value("Price List", {"selling": 1}) price_list_name = frappe.db.get_value("Price List", {"selling": 1})
if(doc.lab_test_rate): if doc.lab_test_rate:
make_item_price(item.name, price_list_name, doc.lab_test_rate) make_item_price(item.name, price_list_name, doc.lab_test_rate)
item.standard_rate = doc.lab_test_rate
else: else:
make_item_price(item.name, price_list_name, 0.0) make_item_price(item.name, price_list_name, 0.0)
item.standard_rate = 0.0
item.save(ignore_permissions = True)
# Set item in the template # Set item in the template
frappe.db.set_value("Lab Test Template", doc.name, "item", item.name) frappe.db.set_value("Lab Test Template", doc.name, "item", item.name)

View File

@@ -15,7 +15,7 @@ frappe.ui.form.on('Patient', {
} else { } else {
erpnext.toggle_naming_series(); erpnext.toggle_naming_series();
} }
if (frappe.defaults.get_default("collect_registration_fee") && frm.doc.disabled == 1) { if (frappe.defaults.get_default("collect_registration_fee") && frm.doc.status == 'Disabled') {
frm.add_custom_button(__('Invoice Patient Registration'), function () { frm.add_custom_button(__('Invoice Patient Registration'), function () {
btn_invoice_registration(frm); btn_invoice_registration(frm);
}); });

View File

@@ -1,4 +1,5 @@
{ {
"actions": [],
"allow_copy": 1, "allow_copy": 1,
"allow_import": 1, "allow_import": 1,
"allow_rename": 1, "allow_rename": 1,
@@ -19,15 +20,14 @@
"blood_group", "blood_group",
"dob", "dob",
"age_html", "age_html",
"status",
"image", "image",
"column_break_14", "column_break_14",
"status",
"customer", "customer",
"report_preference", "report_preference",
"mobile", "mobile",
"email", "email",
"phone", "phone",
"disabled",
"sb_relation", "sb_relation",
"patient_relation", "patient_relation",
"allergy_medical_and_surgical_history", "allergy_medical_and_surgical_history",
@@ -125,15 +125,15 @@
"report_hide": 1 "report_hide": 1
}, },
{ {
"default": "Active",
"fieldname": "status", "fieldname": "status",
"fieldtype": "Select", "fieldtype": "Select",
"hidden": 1, "in_filter": 1,
"in_list_view": 1,
"label": "Status", "label": "Status",
"no_copy": 1, "no_copy": 1,
"options": "Active\nDormant\nOpen", "options": "Active\nDisabled",
"print_hide": 1, "print_hide": 1,
"report_hide": 1 "read_only": 1
}, },
{ {
"fieldname": "image", "fieldname": "image",
@@ -183,19 +183,8 @@
"fieldname": "phone", "fieldname": "phone",
"fieldtype": "Data", "fieldtype": "Data",
"in_filter": 1, "in_filter": 1,
"in_list_view": 1,
"label": "Phone" "label": "Phone"
}, },
{
"default": "0",
"fieldname": "disabled",
"fieldtype": "Check",
"hidden": 1,
"label": "Disabled",
"no_copy": 1,
"print_hide": 1,
"report_hide": 1
},
{ {
"collapsible": 1, "collapsible": 1,
"fieldname": "sb_relation", "fieldname": "sb_relation",
@@ -346,8 +335,9 @@
], ],
"icon": "fa fa-user", "icon": "fa fa-user",
"image_field": "image", "image_field": "image",
"links": [],
"max_attachments": 50, "max_attachments": 50,
"modified": "2019-09-25 23:30:49.905893", "modified": "2020-01-29 11:22:40.698125",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Healthcare", "module": "Healthcare",
"name": "Patient", "name": "Patient",

View File

@@ -15,8 +15,8 @@ class Patient(Document):
def after_insert(self): def after_insert(self):
if(frappe.db.get_value("Healthcare Settings", None, "manage_customer") == '1' and not self.customer): if(frappe.db.get_value("Healthcare Settings", None, "manage_customer") == '1' and not self.customer):
create_customer(self) create_customer(self)
if(frappe.db.get_value("Healthcare Settings", None, "collect_registration_fee") == '1'): if frappe.db.get_single_value('Healthcare Settings', 'collect_registration_fee'):
frappe.db.set_value("Patient", self.name, "disabled", 1) frappe.db.set_value('Patient', self.name, 'status', 'Disabled')
else: else:
send_registration_sms(self) send_registration_sms(self)
self.reload() self.reload()
@@ -62,7 +62,7 @@ class Patient(Document):
return age_str return age_str
def invoice_patient_registration(self): def invoice_patient_registration(self):
frappe.db.set_value("Patient", self.name, "disabled", 0) frappe.db.set_value("Patient", self.name, "status", "Active")
send_registration_sms(self) send_registration_sms(self)
if(flt(frappe.get_value("Healthcare Settings", None, "registration_fee"))>0): if(flt(frappe.get_value("Healthcare Settings", None, "registration_fee"))>0):
company = frappe.defaults.get_user_default('company') company = frappe.defaults.get_user_default('company')

View File

@@ -11,7 +11,7 @@ frappe.ui.form.on('Patient Appointment', {
refresh: function(frm) { refresh: function(frm) {
frm.set_query("patient", function () { frm.set_query("patient", function () {
return { return {
filters: {"disabled": 0} filters: {"status": "Active"}
}; };
}); });
frm.set_query("practitioner", function() { frm.set_query("practitioner", function() {
@@ -288,12 +288,19 @@ var check_and_set_availability = function(frm) {
}; };
var get_procedure_prescribed = function(frm){ var get_procedure_prescribed = function(frm){
if(frm.doc.patient){ if (frm.doc.patient) {
frappe.call({ frappe.call({
method:"erpnext.healthcare.doctype.patient_appointment.patient_appointment.get_procedure_prescribed", method:"erpnext.healthcare.doctype.patient_appointment.patient_appointment.get_procedure_prescribed",
args: {patient: frm.doc.patient}, args: {patient: frm.doc.patient},
callback: function(r){ callback: function(r) {
show_procedure_templates(frm, r.message); if (r.message && r.message.length) {
show_procedure_templates(frm, r.message);
} else {
frappe.msgprint({
title: __('Not Found'),
message: __('No Prescribed Procedures found for the selected Patient')
});
}
} }
}); });
} }

View File

@@ -25,6 +25,7 @@ class PatientAppointment(Document):
self.reload() self.reload()
def validate(self): def validate(self):
self.set_appointment_datetime()
end_time = datetime.datetime.combine(getdate(self.appointment_date), get_time(self.appointment_time)) + datetime.timedelta(minutes=float(self.duration)) end_time = datetime.datetime.combine(getdate(self.appointment_date), get_time(self.appointment_time)) + datetime.timedelta(minutes=float(self.duration))
overlaps = frappe.db.sql(""" overlaps = frappe.db.sql("""
select select
@@ -44,6 +45,9 @@ class PatientAppointment(Document):
frappe.throw(_("""Appointment overlaps with {0}.<br> {1} has appointment scheduled frappe.throw(_("""Appointment overlaps with {0}.<br> {1} has appointment scheduled
with {2} at {3} having {4} minute(s) duration.""").format(overlaps[0][0], overlaps[0][1], overlaps[0][2], overlaps[0][3], overlaps[0][4])) with {2} at {3} having {4} minute(s) duration.""").format(overlaps[0][0], overlaps[0][1], overlaps[0][2], overlaps[0][3], overlaps[0][4]))
def set_appointment_datetime(self):
self.appointment_datetime = "%s %s" % (self.appointment_date, self.appointment_time or "00:00:00")
def after_insert(self): def after_insert(self):
if self.procedure_prescription: if self.procedure_prescription:
frappe.db.set_value("Procedure Prescription", self.procedure_prescription, "appointment_booked", True) frappe.db.set_value("Procedure Prescription", self.procedure_prescription, "appointment_booked", True)
@@ -319,27 +323,29 @@ def create_encounter(appointment):
return encounter.as_dict() return encounter.as_dict()
def remind_appointment(): def set_appointment_reminder():
if frappe.db.get_value("Healthcare Settings", None, "app_rem") == '1': if frappe.db.get_single_value("Healthcare Settings", "app_rem"):
rem_before = datetime.datetime.strptime(frappe.get_value("Healthcare Settings", None, "rem_before"), "%H:%M:%S") remind_before = datetime.datetime.strptime(frappe.db.get_single_value("Healthcare Settings", "rem_before"), '%H:%M:%S')
rem_dt = datetime.datetime.now() + datetime.timedelta(
hours=rem_before.hour, minutes=rem_before.minute, seconds=rem_before.second)
appointment_list = frappe.db.sql( reminder_dt = datetime.datetime.now() + datetime.timedelta(
"select name from `tabPatient Appointment` where start_dt between %s and %s and reminded = 0 ", hours=remind_before.hour, minutes=remind_before.minute, seconds=remind_before.second)
(datetime.datetime.now(), rem_dt)
)
for i in range(0, len(appointment_list)): appointment_list = frappe.db.get_all("Patient Appointment", {
doc = frappe.get_doc("Patient Appointment", appointment_list[i][0]) "appointment_datetime": ["between", (datetime.datetime.now(), reminder_dt)],
message = frappe.db.get_value("Healthcare Settings", None, "app_rem_msg") "reminded": 0,
"status": ["!=", "Cancelled"]
})
for appointment in appointment_list:
doc = frappe.get_doc('Patient Appointment', appointment.name)
message = frappe.db.get_single_value("Healthcare Settings", "app_rem_msg")
send_message(doc, message) send_message(doc, message)
frappe.db.set_value("Patient Appointment", doc.name, "reminded",1) frappe.db.set_value('Patient Appointment', doc.name, 'reminded', 1)
def send_message(doc, message): def send_message(doc, message):
patient = frappe.get_doc("Patient", doc.patient) patient_mobile = frappe.db.get_value("Patient", doc.patient, "mobile")
if patient.mobile: if patient_mobile:
context = {"doc": doc, "alert": doc, "comments": None} context = {"doc": doc, "alert": doc, "comments": None}
if doc.get("_comments"): if doc.get("_comments"):
context["comments"] = json.loads(doc.get("_comments")) context["comments"] = json.loads(doc.get("_comments"))

View File

@@ -62,7 +62,7 @@ frappe.ui.form.on('Patient Encounter', {
frm.set_query("patient", function () { frm.set_query("patient", function () {
return { return {
filters: {"disabled": 0} filters: {"status": "Active"}
}; };
}); });
frm.set_query("drug_code", "drug_prescription", function() { frm.set_query("drug_code", "drug_prescription", function() {

View File

@@ -1,160 +1,71 @@
{ {
"allow_copy": 0, "actions": [],
"allow_guest_to_view": 0, "allow_import": 1,
"allow_import": 1, "allow_rename": 1,
"allow_rename": 1, "autoname": "field:schedule_name",
"autoname": "field:schedule_name", "beta": 1,
"beta": 1, "creation": "2017-05-03 17:28:03.926787",
"creation": "2017-05-03 17:28:03.926787", "doctype": "DocType",
"custom": 0, "editable_grid": 1,
"docstatus": 0, "engine": "InnoDB",
"doctype": "DocType", "field_order": [
"document_type": "", "disabled",
"editable_grid": 1, "schedule_details_section",
"engine": "InnoDB", "schedule_name",
"time_slots"
],
"fields": [ "fields": [
{ {
"allow_bulk_edit": 0, "fieldname": "schedule_name",
"allow_in_quick_entry": 0, "fieldtype": "Data",
"allow_on_submit": 0, "ignore_xss_filter": 1,
"bold": 0, "in_list_view": 1,
"collapsible": 0, "label": "Schedule Name",
"columns": 0, "reqd": 1,
"fieldname": "schedule_name", "unique": 1
"fieldtype": "Data", },
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 1,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Schedule Name",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "fieldname": "time_slots",
"allow_in_quick_entry": 0, "fieldtype": "Table",
"allow_on_submit": 0, "label": "Time Slots",
"bold": 0, "options": "Healthcare Schedule Time Slot"
"collapsible": 0, },
"columns": 0,
"fieldname": "time_slots",
"fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Time Slots",
"length": 0,
"no_copy": 0,
"options": "Healthcare Schedule Time Slot",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "default": "0",
"allow_in_quick_entry": 0, "fieldname": "disabled",
"allow_on_submit": 0, "fieldtype": "Check",
"bold": 0, "label": "Disabled",
"collapsible": 0, "print_hide": 1
"columns": 0, },
"fieldname": "disabled", {
"fieldtype": "Check", "fieldname": "schedule_details_section",
"hidden": 0, "fieldtype": "Section Break",
"ignore_user_permissions": 0, "label": "Schedule Details"
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Disabled",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 1,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
} }
], ],
"has_web_view": 0, "links": [],
"hide_heading": 0, "modified": "2020-01-31 12:21:45.975488",
"hide_toolbar": 0, "modified_by": "Administrator",
"idx": 0, "module": "Healthcare",
"image_view": 0, "name": "Practitioner Schedule",
"in_create": 0, "owner": "rmehta@gmail.com",
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-06-29 14:55:34.795995",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Practitioner Schedule",
"name_case": "",
"owner": "rmehta@gmail.com",
"permissions": [ "permissions": [
{ {
"amend": 0, "create": 1,
"cancel": 0, "delete": 1,
"create": 1, "email": 1,
"delete": 1, "export": 1,
"email": 1, "print": 1,
"export": 1, "read": 1,
"if_owner": 0, "report": 1,
"import": 0, "role": "Healthcare Administrator",
"permlevel": 0, "share": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Healthcare Administrator",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1 "write": 1
} }
], ],
"quick_entry": 0, "restrict_to_domain": "Healthcare",
"read_only": 0, "show_name_in_global_search": 1,
"read_only_onload": 0, "sort_field": "modified",
"restrict_to_domain": "Healthcare", "sort_order": "DESC",
"show_name_in_global_search": 1, "track_changes": 1
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1,
"track_seen": 0
} }

View File

@@ -245,7 +245,7 @@ doc_events = {
"on_trash": "erpnext.regional.check_deletion_permission" "on_trash": "erpnext.regional.check_deletion_permission"
}, },
"Payment Entry": { "Payment Entry": {
"on_submit": ["erpnext.regional.create_transaction_log", "erpnext.accounts.doctype.payment_request.payment_request.make_status_as_paid"], "on_submit": ["erpnext.regional.create_transaction_log", "erpnext.accounts.doctype.payment_request.payment_request.update_payment_req_status"],
"on_trash": "erpnext.regional.check_deletion_permission" "on_trash": "erpnext.regional.check_deletion_permission"
}, },
'Address': { 'Address': {
@@ -268,7 +268,9 @@ doc_events = {
scheduler_events = { scheduler_events = {
"all": [ "all": [
"erpnext.projects.doctype.project.project.project_status_update_reminder" "erpnext.projects.doctype.project.project.project_status_update_reminder",
"erpnext.healthcare_healthcare.doctype.patient_appointment.patient_appointment.send_appointment_reminder"
], ],
"hourly": [ "hourly": [
'erpnext.hr.doctype.daily_work_summary_group.daily_work_summary_group.trigger_emails', 'erpnext.hr.doctype.daily_work_summary_group.daily_work_summary_group.trigger_emails',

View File

@@ -126,7 +126,7 @@
"idx": 1, "idx": 1,
"is_tree": 1, "is_tree": 1,
"links": [], "links": [],
"modified": "2020-03-18 18:35:47.295588", "modified": "2020-03-18 18:26:05.966022",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Department", "name": "Department",

View File

@@ -278,6 +278,7 @@
"label": "More Details" "label": "More Details"
}, },
{ {
"allow_on_submit": 1,
"default": "Draft", "default": "Draft",
"fieldname": "status", "fieldname": "status",
"fieldtype": "Select", "fieldtype": "Select",
@@ -366,7 +367,8 @@
"icon": "fa fa-money", "icon": "fa fa-money",
"idx": 1, "idx": 1,
"is_submittable": 1, "is_submittable": 1,
"modified": "2019-11-08 14:13:08.964547", "links": [],
"modified": "2020-03-16 18:11:07.861985",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Expense Claim", "name": "Expense Claim",

View File

@@ -45,10 +45,10 @@ class ExpenseClaim(AccountsController):
paid_amount = flt(self.total_amount_reimbursed) + flt(self.total_advance_amount) paid_amount = flt(self.total_amount_reimbursed) + flt(self.total_advance_amount)
precision = self.precision("grand_total") precision = self.precision("grand_total")
if (self.is_paid or (flt(self.total_sanctioned_amount) > 0 if (self.is_paid or (flt(self.total_sanctioned_amount) > 0
and flt(self.grand_total, precision) == flt(paid_amount, precision))) \ and flt(flt(self.total_sanctioned_amount) + flt(self.total_taxes_and_charges), precision) == flt(paid_amount, precision))) \
and self.docstatus == 1 and self.approval_status == 'Approved': and self.docstatus == 1 and self.approval_status == 'Approved':
self.status = "Paid" self.status = "Paid"
elif flt(self.total_sanctioned_amount) > 0 and self.docstatus == 1 and self.approval_status == 'Approved': elif flt(self.grand_total) > 0 and self.docstatus == 1 and self.approval_status == 'Approved':
self.status = "Unpaid" self.status = "Unpaid"
elif self.docstatus == 1 and self.approval_status == 'Rejected': elif self.docstatus == 1 and self.approval_status == 'Rejected':
self.status = 'Rejected' self.status = 'Rejected'

View File

@@ -34,12 +34,14 @@ class TestExpenseClaim(unittest.TestCase):
task_name = task.name task_name = task.name
payable_account = get_payable_account(company_name) payable_account = get_payable_account(company_name)
make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC4", "_Test Project 1", task_name) make_expense_claim(payable_account, 300, 200, company_name,
"Travel Expenses - _TC4", "_Test Project 1", task_name, cost_center="Main - _TC4")
self.assertEqual(frappe.db.get_value("Task", task_name, "total_expense_claim"), 200) self.assertEqual(frappe.db.get_value("Task", task_name, "total_expense_claim"), 200)
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 200) self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 200)
expense_claim2 = make_expense_claim(payable_account, 600, 500, company_name, "Travel Expenses - _TC4","_Test Project 1", task_name) expense_claim2 = make_expense_claim(payable_account, 600, 500, company_name,
"Travel Expenses - _TC4","_Test Project 1", task_name, cost_center="Main - _TC4")
self.assertEqual(frappe.db.get_value("Task", task_name, "total_expense_claim"), 700) self.assertEqual(frappe.db.get_value("Task", task_name, "total_expense_claim"), 700)
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 700) self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 700)
@@ -51,7 +53,8 @@ class TestExpenseClaim(unittest.TestCase):
def test_expense_claim_status(self): def test_expense_claim_status(self):
payable_account = get_payable_account(company_name) payable_account = get_payable_account(company_name)
expense_claim = make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC4") expense_claim = make_expense_claim(payable_account, 300, 200, company_name,
"Travel Expenses - _TC4", cost_center="Main - _TC4")
je_dict = make_bank_entry("Expense Claim", expense_claim.name) je_dict = make_bank_entry("Expense Claim", expense_claim.name)
je = frappe.get_doc(je_dict) je = frappe.get_doc(je_dict)
@@ -70,7 +73,8 @@ class TestExpenseClaim(unittest.TestCase):
def test_expense_claim_gl_entry(self): def test_expense_claim_gl_entry(self):
payable_account = get_payable_account(company_name) payable_account = get_payable_account(company_name)
taxes = generate_taxes() taxes = generate_taxes()
expense_claim = make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC4", do_not_submit=True, taxes=taxes) expense_claim = make_expense_claim(payable_account, 300, 200, company_name,
"Travel Expenses - _TC4", do_not_submit=True, taxes=taxes, cost_center="Main - _TC4")
expense_claim.submit() expense_claim.submit()
gl_entries = frappe.db.sql("""select account, debit, credit gl_entries = frappe.db.sql("""select account, debit, credit
@@ -124,9 +128,10 @@ def generate_taxes():
"total": 210 "total": 210
}]} }]}
def make_expense_claim(payable_account, amount, sanctioned_amount, company, account, project=None, task_name=None, do_not_submit=False, taxes=None): def make_expense_claim(payable_account, amount, sanctioned_amount, company, account,
project=None, task_name=None, do_not_submit=False, taxes=None, cost_center=None):
employee = frappe.db.get_value("Employee", {"status": "Active"}) employee = frappe.db.get_value("Employee", {"status": "Active"})
currency = frappe.db.get_value('Company', company, 'default_currency') currency, company_cost_center = frappe.db.get_value('Company', company, ['default_currency', 'cost_center'])
expense_claim = { expense_claim = {
"doctype": "Expense Claim", "doctype": "Expense Claim",
"employee": employee, "employee": employee,
@@ -134,12 +139,15 @@ def make_expense_claim(payable_account, amount, sanctioned_amount, company, acco
"approval_status": "Approved", "approval_status": "Approved",
"company": company, "company": company,
'currency': currency, 'currency': currency,
"expenses": "expenses": [{
[{"expense_type": "Travel", "expense_type": "Travel",
"default_account": account, "default_account": account,
'currency': currency, 'currency': currency,
"amount": amount, "amount": amount,
"sanctioned_amount": sanctioned_amount}]} "sanctioned_amount": sanctioned_amount,
"cost_center": cost_center or company_cost_center
}]
}
if taxes: if taxes:
expense_claim.update(taxes) expense_claim.update(taxes)

View File

@@ -122,7 +122,7 @@ class LeaveApplication(Document):
if self.status == "Approved": if self.status == "Approved":
for dt in daterange(getdate(self.from_date), getdate(self.to_date)): for dt in daterange(getdate(self.from_date), getdate(self.to_date)):
date = dt.strftime("%Y-%m-%d") date = dt.strftime("%Y-%m-%d")
status = "Half Day" if date == self.half_day_date else "On Leave" status = "Half Day" if getdate(date) == getdate(self.half_day_date) else "On Leave"
attendance_name = frappe.db.exists('Attendance', dict(employee = self.employee, attendance_name = frappe.db.exists('Attendance', dict(employee = self.employee,
attendance_date = date, docstatus = ('!=', 2))) attendance_date = date, docstatus = ('!=', 2)))
@@ -575,19 +575,22 @@ def get_leaves_for_period(employee, leave_type, from_date, to_date):
return leave_days return leave_days
def skip_expiry_leaves(leave_entry, date): def skip_expiry_leaves(leave_entry, date):
''' Checks whether the expired leaves coincide with the to_date of leave balance check ''' ''' Checks whether the expired leaves coincide with the to_date of leave balance check.
This allows backdated leave entry creation for non carry forwarded allocation '''
end_date = frappe.db.get_value("Leave Allocation", {'name': leave_entry.transaction_name}, ['to_date']) end_date = frappe.db.get_value("Leave Allocation", {'name': leave_entry.transaction_name}, ['to_date'])
return True if end_date == date and not leave_entry.is_carry_forward else False return True if end_date == date and not leave_entry.is_carry_forward else False
def get_leave_entries(employee, leave_type, from_date, to_date): def get_leave_entries(employee, leave_type, from_date, to_date):
''' Returns leave entries between from_date and to_date ''' ''' Returns leave entries between from_date and to_date. '''
return frappe.db.sql(""" return frappe.db.sql("""
SELECT SELECT
employee, leave_type, from_date, to_date, leaves, transaction_name, transaction_type, holiday_list, employee, leave_type, from_date, to_date, leaves, transaction_name, transaction_type, holiday_list,
is_carry_forward, is_expired is_carry_forward, is_expired
FROM `tabLeave Ledger Entry` FROM `tabLeave Ledger Entry`
WHERE employee=%(employee)s AND leave_type=%(leave_type)s WHERE employee=%(employee)s AND leave_type=%(leave_type)s
AND docstatus=1 AND leaves<0 AND docstatus=1
AND (leaves<0
OR is_expired=1)
AND (from_date between %(from_date)s AND %(to_date)s AND (from_date between %(from_date)s AND %(to_date)s
OR to_date between %(from_date)s AND %(to_date)s OR to_date between %(from_date)s AND %(to_date)s
OR (from_date < %(from_date)s AND to_date > %(to_date)s)) OR (from_date < %(from_date)s AND to_date > %(to_date)s))

View File

@@ -8,7 +8,6 @@ from frappe import _
from frappe.model.document import Document from frappe.model.document import Document
from frappe.utils import getdate, nowdate, flt from frappe.utils import getdate, nowdate, flt
from erpnext.hr.utils import set_employee_name from erpnext.hr.utils import set_employee_name
from erpnext.hr.doctype.leave_application.leave_application import get_leave_balance_on
from erpnext.hr.doctype.salary_structure_assignment.salary_structure_assignment import get_assigned_salary_structure from erpnext.hr.doctype.salary_structure_assignment.salary_structure_assignment import get_assigned_salary_structure
from erpnext.hr.doctype.leave_ledger_entry.leave_ledger_entry import create_leave_ledger_entry from erpnext.hr.doctype.leave_ledger_entry.leave_ledger_entry import create_leave_ledger_entry
from erpnext.hr.doctype.leave_allocation.leave_allocation import get_unused_leaves from erpnext.hr.doctype.leave_allocation.leave_allocation import get_unused_leaves

View File

@@ -141,6 +141,7 @@ def expire_allocation(allocation, expiry_date=None):
leaves = get_remaining_leaves(allocation) leaves = get_remaining_leaves(allocation)
expiry_date = expiry_date if expiry_date else allocation.to_date expiry_date = expiry_date if expiry_date else allocation.to_date
# allows expired leaves entry to be created/reverted
if leaves: if leaves:
args = dict( args = dict(
leaves=flt(leaves) * -1, leaves=flt(leaves) * -1,
@@ -160,6 +161,8 @@ def expire_carried_forward_allocation(allocation):
from erpnext.hr.doctype.leave_application.leave_application import get_leaves_for_period from erpnext.hr.doctype.leave_application.leave_application import get_leaves_for_period
leaves_taken = get_leaves_for_period(allocation.employee, allocation.leave_type, allocation.from_date, allocation.to_date) leaves_taken = get_leaves_for_period(allocation.employee, allocation.leave_type, allocation.from_date, allocation.to_date)
leaves = flt(allocation.leaves) + flt(leaves_taken) leaves = flt(allocation.leaves) + flt(leaves_taken)
# allow expired leaves entry to be created
if leaves > 0: if leaves > 0:
args = frappe._dict( args = frappe._dict(
transaction_name=allocation.name, transaction_name=allocation.name,

View File

@@ -355,13 +355,13 @@ class SalarySlip(TransactionBase):
def eval_condition_and_formula(self, d, data): def eval_condition_and_formula(self, d, data):
try: try:
condition = d.condition.strip() if d.condition else None condition = d.condition.strip().replace("\n", " ") if d.condition else None
if condition: if condition:
if not frappe.safe_eval(condition, self.whitelisted_globals, data): if not frappe.safe_eval(condition, self.whitelisted_globals, data):
return None return None
amount = d.amount amount = d.amount
if d.amount_based_on_formula: if d.amount_based_on_formula:
formula = d.formula.strip() if d.formula else None formula = d.formula.strip().replace("\n", " ") if d.formula else None
if formula: if formula:
amount = flt(frappe.safe_eval(formula, self.whitelisted_globals, data), d.precision("amount")) amount = flt(frappe.safe_eval(formula, self.whitelisted_globals, data), d.precision("amount"))
if amount: if amount:

View File

@@ -76,7 +76,7 @@ def get_data(filters, leave_types):
opening = get_leave_balance_on(employee.name, leave_type, filters.from_date) opening = get_leave_balance_on(employee.name, leave_type, filters.from_date)
# closing balance # closing balance
closing = get_leave_balance_on(employee.name, leave_type, filters.to_date) closing = max(opening - leaves_taken, 0)
row += [opening, leaves_taken, closing] row += [opening, leaves_taken, closing]

View File

@@ -6,7 +6,6 @@ frappe.provide("erpnext.bom");
frappe.ui.form.on("BOM", { frappe.ui.form.on("BOM", {
setup: function(frm) { setup: function(frm) {
frm.custom_make_buttons = { frm.custom_make_buttons = {
'BOM': 'Duplicate BOM',
'Work Order': 'Work Order', 'Work Order': 'Work Order',
'Quality Inspection': 'Quality Inspection' 'Quality Inspection': 'Quality Inspection'
}; };
@@ -91,10 +90,6 @@ frappe.ui.form.on("BOM", {
} }
if(frm.doc.docstatus!=0) { if(frm.doc.docstatus!=0) {
frm.add_custom_button(__("Duplicate BOM"), function() {
frm.copy_doc();
}, __("Create"));
frm.add_custom_button(__("Work Order"), function() { frm.add_custom_button(__("Work Order"), function() {
frm.trigger("make_work_order"); frm.trigger("make_work_order");
}, __("Create")); }, __("Create"));
@@ -140,6 +135,7 @@ frappe.ui.form.on("BOM", {
frappe.call({ frappe.call({
method: "erpnext.manufacturing.doctype.work_order.work_order.make_work_order", method: "erpnext.manufacturing.doctype.work_order.work_order.make_work_order",
args: { args: {
bom_no: frm.doc.name,
item: frm.doc.item, item: frm.doc.item,
qty: data.qty || 0.0, qty: data.qty || 0.0,
project: frm.doc.project project: frm.doc.project

View File

@@ -23,7 +23,5 @@ def get_data():
'label': _('Subcontract'), 'label': _('Subcontract'),
'items': ['Purchase Order', 'Purchase Receipt', 'Purchase Invoice'] 'items': ['Purchase Order', 'Purchase Receipt', 'Purchase Invoice']
} }
], ]
'disable_create_buttons': ["Item", "Purchase Order", "Purchase Receipt",
"Purchase Invoice", "Job Card", "Stock Entry"]
} }

View File

@@ -7,6 +7,8 @@ frappe.ui.form.on('Job Card', {
if(frm.doc.docstatus == 0) { if(frm.doc.docstatus == 0) {
frm.set_df_property("operation", "read_only", frm.doc.operation_id ? 1 : 0); frm.set_df_property("operation", "read_only", frm.doc.operation_id ? 1 : 0);
} }
frappe.flags.pause_job = 0;
frappe.flags.resume_job = 0;
if(!frm.doc.__islocal && frm.doc.items && frm.doc.items.length) { if(!frm.doc.__islocal && frm.doc.items && frm.doc.items.length) {
if (frm.doc.for_quantity != frm.doc.transferred_qty) { if (frm.doc.for_quantity != frm.doc.transferred_qty) {
@@ -18,44 +20,103 @@ frappe.ui.form.on('Job Card', {
if (frm.doc.for_quantity != frm.doc.transferred_qty) { if (frm.doc.for_quantity != frm.doc.transferred_qty) {
frm.add_custom_button(__("Material Transfer"), () => { frm.add_custom_button(__("Material Transfer"), () => {
frm.trigger("make_stock_entry"); frm.trigger("make_stock_entry");
}); }).addClass("btn-primary");
} }
} }
if (frm.doc.docstatus == 0) { if (frm.doc.docstatus == 0 && (frm.doc.for_quantity > frm.doc.total_completed_qty || !frm.doc.for_quantity)
frm.trigger("make_dashboard"); && (!frm.doc.items.length || frm.doc.for_quantity == frm.doc.transferred_qty)) {
frm.trigger("prepare_timer_buttons");
}
},
if (!frm.doc.job_started) { prepare_timer_buttons: function(frm) {
frm.add_custom_button(__("Start Job"), () => { frm.trigger("make_dashboard");
let row = frappe.model.add_child(frm.doc, 'Job Card Time Log', 'time_logs'); if (!frm.doc.job_started) {
row.from_time = frappe.datetime.now_datetime(); frm.add_custom_button(__("Start"), () => {
frm.set_value('job_started', 1); if (!frm.doc.employee) {
frm.set_value('started_time' , row.from_time); frappe.prompt({fieldtype: 'Link', label: __('Employee'), options: "Employee",
frm.save(); fieldname: 'employee'}, d => {
}); if (d.employee) {
} else { frm.set_value("employee", d.employee);
frm.add_custom_button(__("Complete Job"), () => {
let completed_time = frappe.datetime.now_datetime();
frm.doc.time_logs.forEach(d => {
if (d.from_time && !d.to_time) {
d.to_time = completed_time;
frm.set_value('started_time' , '');
frm.set_value('job_started', 0);
frm.save();
} }
})
}); frm.events.start_job(frm);
} }, __("Enter Value"), __("Start"));
} else {
frm.events.start_job(frm);
}
}).addClass("btn-primary");
} else if (frm.doc.status == "On Hold") {
frm.add_custom_button(__("Resume"), () => {
frappe.flags.resume_job = 1;
frm.events.start_job(frm);
}).addClass("btn-primary");
} else {
frm.add_custom_button(__("Pause"), () => {
frappe.flags.pause_job = 1;
frm.set_value("status", "On Hold");
frm.events.complete_job(frm);
});
frm.add_custom_button(__("Complete"), () => {
let completed_time = frappe.datetime.now_datetime();
frm.trigger("hide_timer");
if (frm.doc.for_quantity) {
frappe.prompt({fieldtype: 'Float', label: __('Completed Quantity'),
fieldname: 'qty', reqd: 1, default: frm.doc.for_quantity}, data => {
frm.events.complete_job(frm, completed_time, data.qty);
}, __("Enter Value"), __("Complete"));
} else {
frm.events.complete_job(frm, completed_time, 0);
}
}).addClass("btn-primary");
} }
}, },
start_job: function(frm) {
let row = frappe.model.add_child(frm.doc, 'Job Card Time Log', 'time_logs');
row.from_time = frappe.datetime.now_datetime();
frm.set_value('job_started', 1);
frm.set_value('started_time' , row.from_time);
frm.set_value("status", "Work In Progress");
if (!frappe.flags.resume_job) {
frm.set_value('current_time' , 0);
}
frm.save();
},
complete_job: function(frm, completed_time, completed_qty) {
frm.doc.time_logs.forEach(d => {
if (d.from_time && !d.to_time) {
d.to_time = completed_time || frappe.datetime.now_datetime();
d.completed_qty = completed_qty || 0;
if(frappe.flags.pause_job) {
let currentIncrement = moment(d.to_time).diff(moment(d.from_time),"seconds") || 0;
frm.set_value('current_time' , currentIncrement + (frm.doc.current_time || 0));
} else {
frm.set_value('started_time' , '');
frm.set_value('job_started', 0);
frm.set_value('current_time' , 0);
}
frm.save();
}
});
},
make_dashboard: function(frm) { make_dashboard: function(frm) {
if(frm.doc.__islocal) if(frm.doc.__islocal)
return; return;
frm.dashboard.refresh(); frm.dashboard.refresh();
const timer = ` const timer = `
<div class="stopwatch" style="font-weight:bold"> <div class="stopwatch" style="font-weight:bold;margin:0px 13px 0px 2px;
color:#545454;font-size:18px;display:inline-block;vertical-align:text-bottom;>
<span class="hours">00</span> <span class="hours">00</span>
<span class="colon">:</span> <span class="colon">:</span>
<span class="minutes">00</span> <span class="minutes">00</span>
@@ -63,11 +124,16 @@ frappe.ui.form.on('Job Card', {
<span class="seconds">00</span> <span class="seconds">00</span>
</div>`; </div>`;
var section = frm.dashboard.add_section(timer); var section = frm.toolbar.page.add_inner_message(timer);
if (frm.doc.started_time) { let currentIncrement = frm.doc.current_time || 0;
let currentIncrement = moment(frappe.datetime.now_datetime()).diff(moment(frm.doc.started_time),"seconds"); if (frm.doc.started_time || frm.doc.current_time) {
initialiseTimer(); if (frm.doc.status == "On Hold") {
updateStopwatch(currentIncrement);
} else {
currentIncrement += moment(frappe.datetime.now_datetime()).diff(moment(frm.doc.started_time),"seconds");
initialiseTimer();
}
function initialiseTimer() { function initialiseTimer() {
const interval = setInterval(function() { const interval = setInterval(function() {
@@ -93,6 +159,10 @@ frappe.ui.form.on('Job Card', {
} }
}, },
hide_timer: function(frm) {
frm.toolbar.page.inner_toolbar.find(".stopwatch").remove();
},
for_quantity: function(frm) { for_quantity: function(frm) {
frm.doc.items = []; frm.doc.items = [];
frm.call({ frm.call({
@@ -122,5 +192,22 @@ frappe.ui.form.on('Job Card', {
timer: function(frm) { timer: function(frm) {
return `<button> Start </button>` return `<button> Start </button>`
},
set_total_completed_qty: function(frm) {
frm.doc.total_completed_qty = 0;
frm.doc.time_logs.forEach(d => {
if (d.completed_qty) {
frm.doc.total_completed_qty += d.completed_qty;
}
});
refresh_field("total_completed_qty");
} }
}); });
frappe.ui.form.on('Job Card Time Log', {
completed_qty: function(frm) {
frm.events.set_total_completed_qty(frm);
}
})

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import _ from frappe import _
from frappe.utils import flt, time_diff_in_hours, get_datetime from frappe.utils import flt, time_diff_in_hours, get_datetime, time_diff
from frappe.model.mapper import get_mapped_doc from frappe.model.mapper import get_mapped_doc
from frappe.model.document import Document from frappe.model.document import Document
@@ -92,11 +92,9 @@ class JobCard(Document):
if not self.time_logs: if not self.time_logs:
frappe.throw(_("Time logs are required for job card {0}").format(self.name)) frappe.throw(_("Time logs are required for job card {0}").format(self.name))
if self.total_completed_qty <= 0.0: if self.for_quantity and self.total_completed_qty != self.for_quantity:
frappe.throw(_("Total completed qty must be greater than zero")) frappe.throw(_("The total completed qty({0}) must be equal to qty to manufacture({1})"
.format(frappe.bold(self.total_completed_qty),frappe.bold(self.for_quantity))))
if self.total_completed_qty > self.for_quantity:
frappe.throw(_("Total completed qty can not be greater than for quantity"))
def update_work_order(self): def update_work_order(self):
if not self.work_order: if not self.work_order:
@@ -105,27 +103,34 @@ class JobCard(Document):
for_quantity, time_in_mins = 0, 0 for_quantity, time_in_mins = 0, 0
from_time_list, to_time_list = [], [] from_time_list, to_time_list = [], []
for d in frappe.get_all('Job Card',
filters = {'docstatus': 1, 'operation_id': self.operation_id}):
doc = frappe.get_doc('Job Card', d.name)
for_quantity += doc.total_completed_qty data = frappe.get_all('Job Card',
time_in_mins += doc.total_time_in_mins fields = ["sum(total_time_in_mins) as time_in_mins", "sum(total_completed_qty) as completed_qty"],
for time_log in doc.time_logs: filters = {"docstatus": 1, "work_order": self.work_order,
if time_log.from_time: "workstation": self.workstation, "operation": self.operation})
from_time_list.append(time_log.from_time)
if time_log.to_time: if data and len(data) > 0:
to_time_list.append(time_log.to_time) for_quantity = data[0].completed_qty
time_in_mins = data[0].time_in_mins
if for_quantity: if for_quantity:
time_data = frappe.db.sql("""
SELECT
min(from_time) as start_time, max(to_time) as end_time
FROM `tabJob Card` jc, `tabJob Card Time Log` jctl
WHERE
jctl.parent = jc.name and jc.work_order = %s
and jc.workstation = %s and jc.operation = %s and jc.docstatus = 1
""", (self.work_order, self.workstation, self.operation), as_dict=1)
wo = frappe.get_doc('Work Order', self.work_order) wo = frappe.get_doc('Work Order', self.work_order)
for data in wo.operations: for data in wo.operations:
if data.name == self.operation_id: if data.workstation == self.workstation and data.operation == self.operation:
data.completed_qty = for_quantity data.completed_qty = for_quantity
data.actual_operation_time = time_in_mins data.actual_operation_time = time_in_mins
data.actual_start_time = min(from_time_list) if from_time_list else None data.actual_start_time = time_data[0].start_time if time_data else None
data.actual_end_time = max(to_time_list) if to_time_list else None data.actual_end_time = time_data[0].end_time if time_data else None
wo.flags.ignore_validate_update_after_submit = True wo.flags.ignore_validate_update_after_submit = True
wo.update_operation_status() wo.update_operation_status()
@@ -172,6 +177,8 @@ class JobCard(Document):
self.set_status(update_status) self.set_status(update_status)
def set_status(self, update_status=False): def set_status(self, update_status=False):
if self.status == "On Hold": return
self.status = { self.status = {
0: "Open", 0: "Open",
1: "Submitted", 1: "Submitted",
@@ -230,6 +237,7 @@ def make_stock_entry(source_name, target_doc=None):
target.fg_completed_qty = source.get('for_quantity', 0) - source.get('transferred_qty', 0) target.fg_completed_qty = source.get('for_quantity', 0) - source.get('transferred_qty', 0)
target.calculate_rate_and_amount() target.calculate_rate_and_amount()
target.set_missing_values() target.set_missing_values()
target.set_stock_entry_type()
doclist = get_mapped_doc("Job Card", source_name, { doclist = get_mapped_doc("Job Card", source_name, {
"Job Card": { "Job Card": {
@@ -251,3 +259,48 @@ def make_stock_entry(source_name, target_doc=None):
}, target_doc, set_missing_values) }, target_doc, set_missing_values)
return doclist return doclist
def time_diff_in_minutes(string_ed_date, string_st_date):
return time_diff(string_ed_date, string_st_date).total_seconds() / 60
@frappe.whitelist()
def get_job_details(start, end, filters=None):
events = []
event_color = {
"Completed": "#cdf5a6",
"Material Transferred": "#ffdd9e",
"Work In Progress": "#D3D3D3"
}
from frappe.desk.reportview import get_filters_cond
conditions = get_filters_cond("Job Card", filters, [])
job_cards = frappe.db.sql(""" SELECT `tabJob Card`.name, `tabJob Card`.work_order,
`tabJob Card`.employee_name, `tabJob Card`.status, ifnull(`tabJob Card`.remarks, ''),
min(`tabJob Card Time Log`.from_time) as from_time,
max(`tabJob Card Time Log`.to_time) as to_time
FROM `tabJob Card` , `tabJob Card Time Log`
WHERE
`tabJob Card`.name = `tabJob Card Time Log`.parent {0}
group by `tabJob Card`.name""".format(conditions), as_dict=1)
for d in job_cards:
subject_data = []
for field in ["name", "work_order", "remarks", "employee_name"]:
if not d.get(field): continue
subject_data.append(d.get(field))
color = event_color.get(d.status)
job_card_data = {
'from_time': d.from_time,
'to_time': d.to_time,
'name': d.name,
'subject': '\n'.join(subject_data),
'color': color if color else "#89bcde"
}
events.append(job_card_data)
return events

View File

@@ -0,0 +1,21 @@
frappe.views.calendar["Job Card"] = {
field_map: {
"start": "from_time",
"end": "to_time",
"id": "name",
"title": "subject",
"color": "color",
"allDay": "allDay",
"progress": "progress"
},
gantt: true,
filters: [
{
"fieldtype": "Link",
"fieldname": "employee",
"options": "Employee",
"label": __("Employee")
}
],
get_events_method: "erpnext.manufacturing.doctype.job_card.job_card.get_job_details"
};

View File

@@ -1,208 +1,57 @@
{ {
"allow_copy": 0, "creation": "2019-03-08 23:56:43.187569",
"allow_events_in_timeline": 0, "doctype": "DocType",
"allow_guest_to_view": 0, "editable_grid": 1,
"allow_import": 0, "engine": "InnoDB",
"allow_rename": 0, "field_order": [
"beta": 0, "from_time",
"creation": "2019-03-08 23:56:43.187569", "to_time",
"custom": 0, "column_break_2",
"docstatus": 0, "time_in_mins",
"doctype": "DocType", "completed_qty"
"document_type": "", ],
"editable_grid": 1,
"engine": "InnoDB",
"fields": [ "fields": [
{ {
"allow_bulk_edit": 0, "fieldname": "from_time",
"allow_in_quick_entry": 0, "fieldtype": "Datetime",
"allow_on_submit": 0, "in_list_view": 1,
"bold": 0, "label": "From Time"
"collapsible": 0, },
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "from_time",
"fieldtype": "Datetime",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "From Time",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "fieldname": "to_time",
"allow_in_quick_entry": 0, "fieldtype": "Datetime",
"allow_on_submit": 0, "in_list_view": 1,
"bold": 0, "label": "To Time"
"collapsible": 0, },
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "to_time",
"fieldtype": "Datetime",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "To Time",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "fieldname": "column_break_2",
"allow_in_quick_entry": 0, "fieldtype": "Column Break"
"allow_on_submit": 0, },
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_2",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "fieldname": "time_in_mins",
"allow_in_quick_entry": 0, "fieldtype": "Float",
"allow_on_submit": 0, "in_list_view": 1,
"bold": 0, "label": "Time In Mins",
"collapsible": 0, "read_only": 1
"columns": 0, },
"fetch_if_empty": 0,
"fieldname": "time_in_mins",
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Time In Mins",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "default": "0",
"allow_in_quick_entry": 0, "fieldname": "completed_qty",
"allow_on_submit": 0, "fieldtype": "Float",
"bold": 0, "in_list_view": 1,
"collapsible": 0, "label": "Completed Qty",
"columns": 0, "reqd": 1
"default": "0",
"fetch_if_empty": 0,
"fieldname": "completed_qty",
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Completed Qty",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
} }
], ],
"has_web_view": 0, "istable": 1,
"hide_heading": 0, "modified": "2019-12-03 12:56:02.285448",
"hide_toolbar": 0, "modified_by": "Administrator",
"idx": 0, "module": "Manufacturing",
"image_view": 0, "name": "Job Card Time Log",
"in_create": 0, "owner": "Administrator",
"is_submittable": 0, "permissions": [],
"issingle": 0, "quick_entry": 1,
"istable": 1, "sort_field": "modified",
"max_attachments": 0, "sort_order": "ASC",
"modified": "2019-03-10 17:08:46.504910", "track_changes": 1
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Job Card Time Log",
"name_case": "",
"owner": "Administrator",
"permissions": [],
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "ASC",
"track_changes": 1,
"track_seen": 0,
"track_views": 0
} }

View File

@@ -71,12 +71,13 @@ frappe.ui.form.on('Production Plan', {
}, __('Create')); }, __('Create'));
} }
frm.page.set_inner_btn_group_as_primary(__('Create'));
frm.trigger("material_requirement"); frm.trigger("material_requirement");
const projected_qty_formula = ` <table class="table table-bordered" style="background-color: #f9f9f9;"> const projected_qty_formula = ` <table class="table table-bordered" style="background-color: #f9f9f9;">
<tr><td style="padding-left:25px"> <tr><td style="padding-left:25px">
<div> <div>
<h3> <h3 style="text-decoration: underline;">
<a href = "https://erpnext.com/docs/user/manual/en/stock/projected-quantity"> <a href = "https://erpnext.com/docs/user/manual/en/stock/projected-quantity">
${__("Projected Quantity Formula")} ${__("Projected Quantity Formula")}
</a> </a>

View File

@@ -144,7 +144,7 @@ class ProductionPlan(Document):
item_condition = " and mr_item.item_code ={0}".format(frappe.db.escape(self.item_code)) item_condition = " and mr_item.item_code ={0}".format(frappe.db.escape(self.item_code))
items = frappe.db.sql("""select distinct parent, name, item_code, warehouse, description, items = frappe.db.sql("""select distinct parent, name, item_code, warehouse, description,
(qty - ordered_qty) as pending_qty (qty - ordered_qty) * conversion_factor as pending_qty
from `tabMaterial Request Item` mr_item from `tabMaterial Request Item` mr_item
where parent in (%s) and docstatus = 1 and qty > ordered_qty where parent in (%s) and docstatus = 1 and qty > ordered_qty
and exists (select name from `tabBOM` bom where bom.item=mr_item.item_code and exists (select name from `tabBOM` bom where bom.item=mr_item.item_code

View File

@@ -6,7 +6,7 @@ def get_data():
'fieldname': 'production_plan', 'fieldname': 'production_plan',
'transactions': [ 'transactions': [
{ {
'label': _('Related'), 'label': _('Transactions'),
'items': ['Work Order', 'Material Request'] 'items': ['Work Order', 'Material Request']
}, },
] ]

View File

@@ -6,7 +6,7 @@ frappe.ui.form.on("Work Order", {
frm.custom_make_buttons = { frm.custom_make_buttons = {
'Stock Entry': 'Start', 'Stock Entry': 'Start',
'Pick List': 'Create Pick List', 'Pick List': 'Create Pick List',
'Job Card': 'Create Job Card', 'Job Card': 'Create Job Card'
}; };
// Set query for warehouses // Set query for warehouses
@@ -132,7 +132,8 @@ frappe.ui.form.on("Work Order", {
} }
if (frm.doc.docstatus===1) { if (frm.doc.docstatus===1) {
frm.trigger('show_progress'); frm.trigger('show_progress_for_items');
frm.trigger('show_progress_for_operations');
} }
if (frm.doc.docstatus === 1 if (frm.doc.docstatus === 1
@@ -180,89 +181,72 @@ frappe.ui.form.on("Work Order", {
make_job_card: function(frm) { make_job_card: function(frm) {
let qty = 0; let qty = 0;
const fields = [{ let operations_data = [];
fieldtype: "Link",
fieldname: "operation",
options: "Operation",
label: __("Operation"),
get_query: () => {
const filter_workstation = frm.doc.operations.filter(d => {
if (d.status != "Completed") {
return d;
}
});
return { const dialog = frappe.prompt({fieldname: 'operations', fieldtype: 'Table', label: __('Operations'),
filters: { fields: [
name: ["in", (filter_workstation || []).map(d => d.operation)] {
} fieldtype:'Link',
}; fieldname:'operation',
}, label: __('Operation'),
reqd: true read_only:1,
}, { in_list_view:1
fieldtype: "Link", },
fieldname: "workstation", {
options: "Workstation", fieldtype:'Link',
label: __("Workstation"), fieldname:'workstation',
get_query: () => { label: __('Workstation'),
const operation = dialog.get_value("operation"); read_only:1,
const filter_workstation = frm.doc.operations.filter(d => { in_list_view:1
if (d.operation == operation) { },
return d; {
} fieldtype:'Data',
}); fieldname:'name',
label: __('Operation Id')
return { },
filters: { {
name: ["in", (filter_workstation || []).map(d => d.workstation)] fieldtype:'Float',
} fieldname:'pending_qty',
}; label: __('Pending Qty'),
}, },
onchange: () => { {
const operation = dialog.get_value("operation"); fieldtype:'Float',
const workstation = dialog.get_value("workstation"); fieldname:'qty',
if (operation && workstation) { label: __('Quantity to Manufacture'),
const row = frm.doc.operations.filter(d => d.operation == operation && d.workstation == workstation)[0]; read_only:0,
qty = frm.doc.qty - row.completed_qty; in_list_view:1,
},
if (qty > 0) { ],
dialog.set_value("qty", qty); data: operations_data,
} in_place_edit: true,
} get_data: function() {
}, return operations_data;
reqd: true
}, {
fieldtype: "Float",
fieldname: "qty",
label: __("For Quantity"),
reqd: true
}];
const dialog = frappe.prompt(fields, function(data) {
if (data.qty > qty) {
frappe.throw(__("For Quantity must be less than quantity {0}", [qty]));
} }
}, function(data) {
if (data.qty <= 0) {
frappe.throw(__("For Quantity must be greater than zero"));
}
frappe.call({ frappe.call({
method: "erpnext.manufacturing.doctype.work_order.work_order.make_job_card", method: "erpnext.manufacturing.doctype.work_order.work_order.make_job_card",
args: { args: {
work_order: frm.doc.name, work_order: frm.doc.name,
operation: data.operation, operations: data.operations,
workstation: data.workstation,
qty: data.qty
},
callback: function(r){
if (r.message) {
var doc = frappe.model.sync(r.message)[0];
frappe.set_route("Form", doc.doctype, doc.name);
}
} }
}); });
}, __("For Job Card")); }, __("Job Card"), __("Create"));
var pending_qty = 0;
frm.doc.operations.forEach(data => {
if(data.completed_qty != frm.doc.qty) {
pending_qty = frm.doc.qty - flt(data.completed_qty);
dialog.fields_dict.operations.df.data.push({
'name': data.name,
'operation': data.operation,
'workstation': data.workstation,
'qty': pending_qty,
'pending_qty': pending_qty,
});
}
});
dialog.fields_dict.operations.grid.refresh();
}, },
make_bom: function(frm) { make_bom: function(frm) {
@@ -278,7 +262,7 @@ frappe.ui.form.on("Work Order", {
}); });
}, },
show_progress: function(frm) { show_progress_for_items: function(frm) {
var bars = []; var bars = [];
var message = ''; var message = '';
var added_min = false; var added_min = false;
@@ -312,6 +296,44 @@ frappe.ui.form.on("Work Order", {
frm.dashboard.add_progress(__('Status'), bars, message); frm.dashboard.add_progress(__('Status'), bars, message);
}, },
show_progress_for_operations: function(frm) {
if (frm.doc.operations && frm.doc.operations.length) {
let progress_class = {
"Work in Progress": "progress-bar-warning",
"Completed": "progress-bar-success"
};
let bars = [];
let message = '';
let title = '';
let status_wise_oprtation_data = {};
let total_completed_qty = frm.doc.qty * frm.doc.operations.length;
frm.doc.operations.forEach(d => {
if (!status_wise_oprtation_data[d.status]) {
status_wise_oprtation_data[d.status] = [d.completed_qty, d.operation];
} else {
status_wise_oprtation_data[d.status][0] += d.completed_qty;
status_wise_oprtation_data[d.status][1] += ', ' + d.operation;
}
});
for (let key in status_wise_oprtation_data) {
title = __("{0} Operations: {1}", [key, status_wise_oprtation_data[key][1].bold()]);
bars.push({
'title': title,
'width': status_wise_oprtation_data[key][0] / total_completed_qty * 100 + '%',
'progress_class': progress_class[key]
});
message += title + '. ';
}
frm.dashboard.add_progress(__('Status'), bars, message);
}
},
production_item: function(frm) { production_item: function(frm) {
if (frm.doc.production_item) { if (frm.doc.production_item) {
frappe.call({ frappe.call({

View File

@@ -1,4 +1,5 @@
{ {
"actions": [],
"allow_import": 1, "allow_import": 1,
"autoname": "naming_series:", "autoname": "naming_series:",
"creation": "2013-01-10 16:34:16", "creation": "2013-01-10 16:34:16",
@@ -468,7 +469,8 @@
"idx": 1, "idx": 1,
"image_field": "image", "image_field": "image",
"is_submittable": 1, "is_submittable": 1,
"modified": "2019-08-28 12:29:35.315239", "links": [],
"modified": "2019-12-04 11:20:04.695123",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Manufacturing", "module": "Manufacturing",
"name": "Work Order", "name": "Work Order",

View File

@@ -6,7 +6,7 @@ import frappe
import json import json
import math import math
from frappe import _ from frappe import _
from frappe.utils import flt, get_datetime, getdate, date_diff, cint, nowdate from frappe.utils import flt, get_datetime, getdate, date_diff, cint, nowdate, get_link_to_form
from frappe.model.document import Document from frappe.model.document import Document
from erpnext.manufacturing.doctype.bom.bom import validate_bom_no, get_bom_items_as_dict from erpnext.manufacturing.doctype.bom.bom import validate_bom_no, get_bom_items_as_dict
from dateutil.relativedelta import relativedelta from dateutil.relativedelta import relativedelta
@@ -274,7 +274,7 @@ class WorkOrder(Document):
stock_entry = frappe.db.sql("""select name from `tabStock Entry` stock_entry = frappe.db.sql("""select name from `tabStock Entry`
where work_order = %s and docstatus = 1""", self.name) where work_order = %s and docstatus = 1""", self.name)
if stock_entry: if stock_entry:
frappe.throw(_("Cannot cancel because submitted Stock Entry {0} exists").format(stock_entry[0][0])) frappe.throw(_("Cannot cancel because submitted Stock Entry {0} exists").format(frappe.utils.get_link_to_form('Stock Entry', stock_entry[0][0])))
def update_planned_qty(self): def update_planned_qty(self):
update_bin_qty(self.production_item, self.fg_warehouse, { update_bin_qty(self.production_item, self.fg_warehouse, {
@@ -609,7 +609,7 @@ def get_item_details(item, project = None):
return res return res
@frappe.whitelist() @frappe.whitelist()
def make_work_order(item, qty=0, project=None): def make_work_order(bom_no, item, qty=0, project=None):
if not frappe.has_permission("Work Order", "write"): if not frappe.has_permission("Work Order", "write"):
frappe.throw(_("Not permitted"), frappe.PermissionError) frappe.throw(_("Not permitted"), frappe.PermissionError)
@@ -618,6 +618,7 @@ def make_work_order(item, qty=0, project=None):
wo_doc = frappe.new_doc("Work Order") wo_doc = frappe.new_doc("Work Order")
wo_doc.production_item = item wo_doc.production_item = item
wo_doc.update(item_details) wo_doc.update(item_details)
wo_doc.bom_no = bom_no
if flt(qty) > 0: if flt(qty) > 0:
wo_doc.qty = flt(qty) wo_doc.qty = flt(qty)
@@ -711,21 +712,41 @@ def query_sales_order(production_item):
return out return out
@frappe.whitelist() @frappe.whitelist()
def make_job_card(work_order, operation, workstation, qty=0): def make_job_card(work_order, operations):
if isinstance(operations, string_types):
operations = json.loads(operations)
work_order = frappe.get_doc('Work Order', work_order) work_order = frappe.get_doc('Work Order', work_order)
row = get_work_order_operation_data(work_order, operation, workstation) for row in operations:
if row: validate_operation_data(row)
return create_job_card(work_order, row, qty) create_job_card(work_order, row, row.get("qty"), auto_create=True)
def validate_operation_data(row):
if row.get("qty") <= 0:
frappe.throw(_("Quantity to Manufacture can not be zero for the operation {0}")
.format(
frappe.bold(row.get("operation"))
)
)
if row.get("qty") > row.get("pending_qty"):
frappe.throw(_("For operation {0}: Quantity ({1}) can not be greter than pending quantity({2})")
.format(
frappe.bold(row.get("operation")),
frappe.bold(row.get("qty")),
frappe.bold(row.get("pending_qty"))
)
)
def create_job_card(work_order, row, qty=0, auto_create=False): def create_job_card(work_order, row, qty=0, auto_create=False):
doc = frappe.new_doc("Job Card") doc = frappe.new_doc("Job Card")
doc.update({ doc.update({
'work_order': work_order.name, 'work_order': work_order.name,
'operation': row.operation, 'operation': row.get("operation"),
'workstation': row.workstation, 'workstation': row.get("workstation"),
'posting_date': nowdate(), 'posting_date': nowdate(),
'for_quantity': qty or work_order.get('qty', 0), 'for_quantity': qty or work_order.get('qty', 0),
'operation_id': row.name, 'operation_id': row.get("name"),
'bom_no': work_order.bom_no, 'bom_no': work_order.bom_no,
'project': work_order.project, 'project': work_order.project,
'company': work_order.company, 'company': work_order.company,
@@ -738,7 +759,7 @@ def create_job_card(work_order, row, qty=0, auto_create=False):
if auto_create: if auto_create:
doc.flags.ignore_mandatory = True doc.flags.ignore_mandatory = True
doc.insert() doc.insert()
frappe.msgprint(_("Job card {0} created").format(doc.name)) frappe.msgprint(_("Job card {0} created").format(get_link_to_form("Job Card", doc.name)))
return doc return doc

View File

@@ -2,11 +2,13 @@
// For license information, please see license.txt // For license information, please see license.txt
frappe.views.calendar["Work Order"] = { frappe.views.calendar["Work Order"] = {
fields: ["planned_start_date", "planned_end_date", "status", "produced_qty", "qty", "name", "name"],
field_map: { field_map: {
"start": "planned_start_date", "start": "planned_start_date",
"end": "planned_end_date", "end": "planned_end_date",
"id": "name", "id": "name",
"title": "name", "title": "name",
"status": "status",
"allDay": "allDay", "allDay": "allDay",
"progress": function(data) { "progress": function(data) {
return flt(data.produced_qty) / data.qty * 100; return flt(data.produced_qty) / data.qty * 100;

View File

@@ -6,7 +6,8 @@ def get_data():
'fieldname': 'work_order', 'fieldname': 'work_order',
'transactions': [ 'transactions': [
{ {
'items': ['Pick List', 'Stock Entry', 'Job Card'] 'label': _('Transactions'),
'items': ['Stock Entry', 'Job Card', 'Pick List']
} }
] ]
} }

View File

@@ -1,4 +1,5 @@
{ {
"actions": [],
"creation": "2014-10-16 14:35:41.950175", "creation": "2014-10-16 14:35:41.950175",
"doctype": "DocType", "doctype": "DocType",
"editable_grid": 1, "editable_grid": 1,
@@ -68,6 +69,7 @@
"description": "Operation completed for how many finished goods?", "description": "Operation completed for how many finished goods?",
"fieldname": "completed_qty", "fieldname": "completed_qty",
"fieldtype": "Float", "fieldtype": "Float",
"in_list_view": 1,
"label": "Completed Qty", "label": "Completed Qty",
"no_copy": 1, "no_copy": 1,
"read_only": 1 "read_only": 1
@@ -188,8 +190,9 @@
} }
], ],
"istable": 1, "istable": 1,
"modified": "2019-07-16 23:01:07.720337", "links": [],
"modified_by": "govindsmenokee@gmail.com", "modified": "2019-12-03 19:24:29.594189",
"modified_by": "Administrator",
"module": "Manufacturing", "module": "Manufacturing",
"name": "Work Order Operation", "name": "Work Order Operation",
"owner": "Administrator", "owner": "Administrator",
@@ -197,4 +200,4 @@
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC", "sort_order": "DESC",
"track_changes": 1 "track_changes": 1
} }

View File

@@ -582,7 +582,7 @@ erpnext.patches.v11_0.rename_bom_wo_fields
erpnext.patches.v12_0.set_default_homepage_type erpnext.patches.v12_0.set_default_homepage_type
erpnext.patches.v11_0.rename_additional_salary_component_additional_salary erpnext.patches.v11_0.rename_additional_salary_component_additional_salary
erpnext.patches.v11_0.renamed_from_to_fields_in_project erpnext.patches.v11_0.renamed_from_to_fields_in_project
erpnext.patches.v11_0.add_permissions_in_gst_settings erpnext.patches.v11_0.add_permissions_in_gst_settings #2020-04-04
erpnext.patches.v11_1.setup_guardian_role erpnext.patches.v11_1.setup_guardian_role
execute:frappe.delete_doc('DocType', 'Notification Control') execute:frappe.delete_doc('DocType', 'Notification Control')
erpnext.patches.v12_0.set_gst_category erpnext.patches.v12_0.set_gst_category
@@ -627,10 +627,11 @@ erpnext.patches.v12_0.update_ewaybill_field_position
erpnext.patches.v12_0.create_accounting_dimensions_in_missing_doctypes erpnext.patches.v12_0.create_accounting_dimensions_in_missing_doctypes
erpnext.patches.v11_1.set_status_for_material_request_type_manufacture erpnext.patches.v11_1.set_status_for_material_request_type_manufacture
erpnext.patches.v12_0.move_plaid_settings_to_doctype erpnext.patches.v12_0.move_plaid_settings_to_doctype
execute:frappe.reload_doc('desk', 'doctype','dashboard_chart_link') execute:frappe.reload_doc('desk', 'doctype', 'dashboard_chart_link')
execute:frappe.reload_doc('desk', 'doctype','dashboard') execute:frappe.reload_doc('desk', 'doctype', 'dashboard')
execute:frappe.reload_doc('desk', 'doctype','dashboard_chart_source') execute:frappe.reload_doc('desk', 'doctype', 'dashboard_chart_source')
execute:frappe.reload_doc('desk', 'doctype','dashboard_chart') execute:frappe.reload_doc('desk', 'doctype', 'dashboard_chart')
execute:frappe.reload_doc('desk', 'doctype', 'dashboard_chart_field')
erpnext.patches.v12_0.add_default_dashboards erpnext.patches.v12_0.add_default_dashboards
erpnext.patches.v12_0.remove_bank_remittance_custom_fields erpnext.patches.v12_0.remove_bank_remittance_custom_fields
erpnext.patches.v12_0.generate_leave_ledger_entries erpnext.patches.v12_0.generate_leave_ledger_entries
@@ -650,3 +651,8 @@ erpnext.patches.v12_0.update_price_or_product_discount
erpnext.patches.v12_0.add_export_type_field_in_party_master erpnext.patches.v12_0.add_export_type_field_in_party_master
erpnext.patches.v12_0.rename_bank_reconciliation_fields # 2020-01-22 erpnext.patches.v12_0.rename_bank_reconciliation_fields # 2020-01-22
erpnext.patches.v12_0.create_irs_1099_field_united_states erpnext.patches.v12_0.create_irs_1099_field_united_states
erpnext.patches.v12_0.set_permission_einvoicing
erpnext.patches.v12_0.set_received_qty_in_material_request_as_per_stock_uom
erpnext.patches.v12_0.recalculate_requested_qty_in_bin
erpnext.patches.v12_0.rename_mws_settings_fields
erpnext.patches.v12_0.set_correct_status_for_expense_claim

View File

@@ -1,12 +1,9 @@
import frappe import frappe
from frappe.permissions import add_permission, update_permission_property from erpnext.regional.india.setup import add_permissions
def execute(): def execute():
company = frappe.get_all('Company', filters = {'country': 'India'}) company = frappe.get_all('Company', filters = {'country': 'India'})
if not company: if not company:
return return
for doctype in ('GST HSN Code', 'GST Settings'): add_permissions()
add_permission(doctype, 'Accounts Manager', 0)
update_permission_property(doctype, 'Accounts Manager', 0, 'write', 1)
update_permission_property(doctype, 'Accounts Manager', 0, 'create', 1)

View File

@@ -0,0 +1,13 @@
from __future__ import unicode_literals
import frappe
from erpnext.stock.stock_balance import update_bin_qty, get_indented_qty
def execute():
bin_details = frappe.db.sql("""
SELECT item_code, warehouse
FROM `tabBin`""",as_dict=1)
for entry in bin_details:
update_bin_qty(entry.get("item_code"), entry.get("warehouse"), {
"indented_qty": get_indented_qty(entry.get("item_code"), entry.get("warehouse"))
})

View File

@@ -0,0 +1,11 @@
# Copyright (c) 2020, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
import frappe
def execute():
count = frappe.db.sql("SELECT COUNT(*) FROM `tabSingles` WHERE doctype='Amazon MWS Settings' AND field='enable_sync';")[0][0]
if count == 0:
frappe.db.sql("UPDATE `tabSingles` SET field='enable_sync' WHERE doctype='Amazon MWS Settings' AND field='enable_synch';")
frappe.reload_doc("ERPNext Integrations", "doctype", "Amazon MWS Settings")

View File

@@ -0,0 +1,11 @@
# Copyright (c) 2020, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
import frappe
def execute():
frappe.db.sql("""
update `tabExpense Claim`
set status = 'Paid'
where total_advance_amount + total_amount_reimbursed = total_sanctioned_amount + total_taxes_and_charges
""")

View File

@@ -0,0 +1,15 @@
import frappe
from erpnext.regional.italy.setup import make_custom_fields
from frappe.permissions import add_permission, update_permission_property
def execute():
company = frappe.get_all('Company', filters = {'country': 'Italy'})
if not company:
return
make_custom_fields()
add_permission('Import Supplier Invoice', 'Accounts Manager', 0)
update_permission_property('Import Supplier Invoice', 'Accounts Manager', 0, 'write', 1)
update_permission_property('Import Supplier Invoice', 'Accounts Manager', 0, 'create', 1)

Some files were not shown because too many files have changed in this diff Show More