Merge branch 'version-12-hotfix' into po_supplier_skip_v12

This commit is contained in:
Marica
2020-04-02 21:14:19 +05:30
committed by GitHub
173 changed files with 4220 additions and 7747 deletions

View File

@@ -1,4 +1,5 @@
{ {
"actions": [],
"allow_copy": 1, "allow_copy": 1,
"allow_import": 1, "allow_import": 1,
"creation": "2013-01-30 12:49:46", "creation": "2013-01-30 12:49:46",
@@ -196,10 +197,13 @@
], ],
"icon": "fa fa-money", "icon": "fa fa-money",
"idx": 1, "idx": 1,
"modified": "2019-10-10 19:10:02.967554", "is_tree": 1,
"links": [],
"modified": "2020-03-18 18:26:03.992861",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Account", "name": "Account",
"nsm_parent_field": "parent_account",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {

View File

@@ -102,7 +102,7 @@ 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 = {}

View File

@@ -406,11 +406,11 @@
"is_group": 1, "is_group": 1,
"Bewertungskorrektur zu Forderungen aus Lieferungen und Leistungen": { "Bewertungskorrektur zu Forderungen aus Lieferungen und Leistungen": {
"account_number": "9960" "account_number": "9960"
}, },
"Debitoren": { "Debitoren": {
"is_group": 1, "is_group": 1,
"account_number": "10000" "account_number": "10000"
}, },
"Forderungen aus Lieferungen und Leistungen": { "Forderungen aus Lieferungen und Leistungen": {
"account_number": "1200", "account_number": "1200",
"account_type": "Receivable" "account_type": "Receivable"
@@ -663,16 +663,22 @@
"account_number": "1400" "account_number": "1400"
}, },
"Abziehbare Vorsteuer 7 %": { "Abziehbare Vorsteuer 7 %": {
"account_number": "1401" "account_number": "1401",
"account_type": "Tax",
"tax_rate": 7.0
}, },
"Abziehbare Vorsteuer aus innergem. Erwerb": { "Abziehbare Vorsteuer aus innergem. Erwerb": {
"account_number": "1402" "account_number": "1402"
}, },
"Abziehbare Vorsteuer aus innergem. Erwerb 19%": { "Abziehbare Vorsteuer aus innergem. Erwerb 19%": {
"account_number": "1404" "account_number": "1404",
"account_type": "Tax",
"tax_rate": 19.0
}, },
"Abziehbare Vorsteuer 19 %": { "Abziehbare Vorsteuer 19 %": {
"account_number": "1406" "account_number": "1406",
"account_type": "Tax",
"tax_rate": 19.0
}, },
"Abziehbare Vorsteuer nach \u00a7 13b UStG 19 %": { "Abziehbare Vorsteuer nach \u00a7 13b UStG 19 %": {
"account_number": "1407" "account_number": "1407"
@@ -1197,15 +1203,15 @@
"is_group": 1, "is_group": 1,
"Bewertungskorrektur zu Verb. aus Lieferungen und Leistungen": { "Bewertungskorrektur zu Verb. aus Lieferungen und Leistungen": {
"account_number": "9964" "account_number": "9964"
}, },
"Kreditoren": { "Kreditoren": {
"account_number": "70000", "account_number": "70000",
"is_group": 1, "is_group": 1,
"Wareneingangs-­Verrechnungskonto" : { "Wareneingangs-­Verrechnungskonto" : {
"account_number": "70001", "account_number": "70001",
"account_type": "Stock Received But Not Billed" "account_type": "Stock Received But Not Billed"
} }
}, },
"Verb. aus Lieferungen und Leistungen": { "Verb. aus Lieferungen und Leistungen": {
"account_number": "3300", "account_number": "3300",
"account_type": "Payable" "account_type": "Payable"
@@ -1488,17 +1494,21 @@
}, },
"Umsatzsteuer 7 %": { "Umsatzsteuer 7 %": {
"account_number": "3801", "account_number": "3801",
"account_type": "Tax" "account_type": "Tax",
"tax_rate": 7.0
}, },
"Umsatzsteuer aus innergem. Erwerb": { "Umsatzsteuer aus innergem. Erwerb": {
"account_number": "3802" "account_number": "3802"
}, },
"Umsatzsteuer aus innergem. Erwerb 19 %": { "Umsatzsteuer aus innergem. Erwerb 19 %": {
"account_number": "3804" "account_number": "3804",
"account_type": "Tax",
"tax_rate": 19.0
}, },
"Umsatzsteuer 19 %": { "Umsatzsteuer 19 %": {
"account_number": "3806", "account_number": "3806",
"account_type": "Tax" "account_type": "Tax",
"tax_rate": 19.0
}, },
"Umsatzsteuer aus im Inland steuerpfl. EU-Lieferungen": { "Umsatzsteuer aus im Inland steuerpfl. EU-Lieferungen": {
"account_number": "3807" "account_number": "3807"
@@ -2295,49 +2305,49 @@
}, },
"6 - sonstige betriebliche Ertr\u00e4ge": { "6 - sonstige betriebliche Ertr\u00e4ge": {
"root_type": "Income", "root_type": "Income",
"is_group": 1, "is_group": 1,
"Erhaltene Boni (Gruppe)": { "Erhaltene Boni (Gruppe)": {
"is_group": 1, "is_group": 1,
"Erhaltene Boni 7 % Vorsteuer": { "Erhaltene Boni 7 % Vorsteuer": {
"account_number": "5750" "account_number": "5750"
}, },
"Erhaltene Boni aus Einkauf Roh-, Hilfs- und Betriebsstoffe": { "Erhaltene Boni aus Einkauf Roh-, Hilfs- und Betriebsstoffe": {
"account_number": "5753" "account_number": "5753"
}, },
"Erhaltene Boni aus Einkauf Roh-, Hilfs- und Betriebsstoffe 7% Vorsteuer": { "Erhaltene Boni aus Einkauf Roh-, Hilfs- und Betriebsstoffe 7% Vorsteuer": {
"account_number": "5754" "account_number": "5754"
}, },
"Erhaltene Boni aus Einkauf Roh-, Hilfs- und Betriebsstoffe 19% Vorsteuer": { "Erhaltene Boni aus Einkauf Roh-, Hilfs- und Betriebsstoffe 19% Vorsteuer": {
"account_number": "5755" "account_number": "5755"
}, },
"Erhaltene Boni 19 % Vorsteuer": { "Erhaltene Boni 19 % Vorsteuer": {
"account_number": "5760" "account_number": "5760"
}, },
"Erhaltene Boni": { "Erhaltene Boni": {
"account_number": "5769" "account_number": "5769"
} }
}, },
"Erhaltene Rabatte (Gruppe)": { "Erhaltene Rabatte (Gruppe)": {
"is_group": 1, "is_group": 1,
"Erhaltene Rabatte": { "Erhaltene Rabatte": {
"account_number": "5770" "account_number": "5770"
}, },
"Erhaltene Rabatte 7 % Vorsteuer": { "Erhaltene Rabatte 7 % Vorsteuer": {
"account_number": "5780" "account_number": "5780"
}, },
"Erhaltene Rabatte aus Einkauf Roh-, Hilfs- und Betriebsstoffe": { "Erhaltene Rabatte aus Einkauf Roh-, Hilfs- und Betriebsstoffe": {
"account_number": "5783" "account_number": "5783"
}, },
"Erhaltene Rabatte aus Einkauf Roh-, Hilfs- und Betriebsstoffe 7% Vorsteuer": { "Erhaltene Rabatte aus Einkauf Roh-, Hilfs- und Betriebsstoffe 7% Vorsteuer": {
"account_number": "5784" "account_number": "5784"
}, },
"Erhaltene Rabatte aus Einkauf Roh-, Hilfs- und Betriebsstoffe 19% Vorsteuer": { "Erhaltene Rabatte aus Einkauf Roh-, Hilfs- und Betriebsstoffe 19% Vorsteuer": {
"account_number": "5785" "account_number": "5785"
}, },
"Erhaltene Rabatte 19 % Vorsteuer": { "Erhaltene Rabatte 19 % Vorsteuer": {
"account_number": "5790" "account_number": "5790"
} }
}, },
"Andere aktivierte Eigenleistungen": { "Andere aktivierte Eigenleistungen": {
"account_number": "4820" "account_number": "4820"
}, },
@@ -2407,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",
@@ -2552,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,
@@ -2603,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,
@@ -2620,48 +2621,42 @@
"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"
} }
} }
}, },
"7 - sonstige betriebliche Aufwendungen": { "7 - sonstige betriebliche Aufwendungen": {
"root_type": "Expense", "root_type": "Expense",
"is_group": 1, "is_group": 1,
"Erl\u00f6sschm\u00e4lerungen (Gruppe)": { "Erl\u00f6sschm\u00e4lerungen (Gruppe)": {
"is_group": 1, "is_group": 1,
"Erl\u00f6sschm\u00e4lerungen": { "Erl\u00f6sschm\u00e4lerungen": {
"account_number": "4700" "account_number": "4700"
@@ -2692,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"
}, },
@@ -2744,7 +2742,7 @@
"Gew\u00e4hrte Rabatte 19 % USt": { "Gew\u00e4hrte Rabatte 19 % USt": {
"account_number": "4790" "account_number": "4790"
} }
}, },
"Sonstige betriebliche Aufwendungen": { "Sonstige betriebliche Aufwendungen": {
"account_number": "6300" "account_number": "6300"
}, },
@@ -2838,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"
@@ -2996,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

@@ -172,7 +172,7 @@ def get_doctypes_with_dimensions():
return doclist return doclist
def get_accounting_dimensions(as_list=True): def get_accounting_dimensions(as_list=True):
accounting_dimensions = frappe.get_all("Accounting Dimension", fields=["label", "fieldname", "disabled"]) accounting_dimensions = frappe.get_all("Accounting Dimension", fields=["label", "fieldname", "disabled", "document_type"])
if as_list: if as_list:
return [d.fieldname for d in accounting_dimensions] return [d.fieldname for d in accounting_dimensions]
@@ -186,6 +186,18 @@ def get_checks_for_pl_and_bs_accounts():
return dimensions return dimensions
def get_dimension_with_children(doctype, dimension):
if isinstance(dimension, list):
dimension = dimension[0]
all_dimensions = []
lft, rgt = frappe.db.get_value(doctype, dimension, ["lft", "rgt"])
children = frappe.get_all(doctype, filters={"lft": [">=", lft], "rgt": ["<=", rgt]})
all_dimensions += [c.name for c in children]
return all_dimensions
@frappe.whitelist() @frappe.whitelist()
def get_dimension_filters(): def get_dimension_filters():
dimension_filters = frappe.db.sql(""" dimension_filters = frappe.db.sql("""

View File

@@ -0,0 +1,8 @@
frappe.ui.form.on('Accounts Settings', {
refresh: function(frm) {
frm.set_df_property("acc_frozen_upto", "label", "Books Closed Through");
frm.set_df_property("frozen_accounts_modifier", "label", "Role Allowed to Close Books & Make Changes to Closed Periods");
frm.set_df_property("credit_controller", "label", "Credit Manager");
}
});

View File

@@ -6,6 +6,7 @@ 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 import _ from frappe import _
from frappe.desk.search import sanitize_searchfield
class BankGuarantee(Document): class BankGuarantee(Document):
def validate(self): def validate(self):
@@ -22,5 +23,8 @@ class BankGuarantee(Document):
@frappe.whitelist() @frappe.whitelist()
def get_vouchar_detials(column_list, doctype, docname): def get_vouchar_detials(column_list, doctype, docname):
column_list = json.loads(column_list)
for col in column_list:
sanitize_searchfield(col)
return frappe.db.sql(''' select {columns} from `tab{doctype}` where name=%s''' return frappe.db.sql(''' select {columns} from `tab{doctype}` where name=%s'''
.format(columns=", ".join(json.loads(column_list)), doctype=doctype), docname, as_dict=1)[0] .format(columns=", ".join(json.loads(column_list)), doctype=doctype), docname, as_dict=1)[0]

View File

@@ -38,7 +38,6 @@ class BankReconciliation(Document):
group by t2.account, t1.name group by t2.account, t1.name
order by t1.posting_date ASC, t1.name DESC order by t1.posting_date ASC, t1.name DESC
""".format(condition=condition), {"account": self.account, "from": self.from_date, "to": self.to_date}, as_dict=1) """.format(condition=condition), {"account": self.account, "from": self.from_date, "to": self.to_date}, as_dict=1)
condition = ''
if self.bank_account: if self.bank_account:
condition += 'and bank_account = %(bank_account)s' condition += 'and bank_account = %(bank_account)s'

View File

@@ -32,10 +32,12 @@ frappe.ui.form.on('C-Form Invoice Detail', {
invoice_no(frm, cdt, cdn) { invoice_no(frm, cdt, cdn) {
let d = frappe.get_doc(cdt, cdn); let d = frappe.get_doc(cdt, cdn);
frm.call('get_invoice_details', { if (d.invoice_no) {
invoice_no: d.invoice_no frm.call('get_invoice_details', {
}).then(r => { invoice_no: d.invoice_no
frappe.model.set_value(cdt, cdn, r.message); }).then(r => {
}); frappe.model.set_value(cdt, cdn, r.message);
});
}
} }
}); });

View File

@@ -124,11 +124,13 @@
], ],
"icon": "fa fa-money", "icon": "fa fa-money",
"idx": 1, "idx": 1,
"is_tree": 1,
"links": [], "links": [],
"modified": "2020-01-28 13:50:23.430434", "modified": "2020-03-18 18:26:01.540170",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Cost Center", "name": "Cost Center",
"nsm_parent_field": "parent_cost_center",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {

View File

@@ -18,7 +18,8 @@
"in_list_view": 1, "in_list_view": 1,
"label": "Invoice", "label": "Invoice",
"options": "Sales Invoice", "options": "Sales Invoice",
"reqd": 1 "reqd": 1,
"search_index": 1
}, },
{ {
"fetch_from": "sales_invoice.customer", "fetch_from": "sales_invoice.customer",
@@ -60,7 +61,7 @@
} }
], ],
"istable": 1, "istable": 1,
"modified": "2019-09-26 11:05:36.016772", "modified": "2020-02-20 16:16:20.724620",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Discounted Invoice", "name": "Discounted Invoice",

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

@@ -232,10 +232,13 @@ def update_outstanding_amt(account, party_type, party, against_voucher_type, aga
if bal < 0 and not on_cancel: if bal < 0 and not on_cancel:
frappe.throw(_("Outstanding for {0} cannot be less than zero ({1})").format(against_voucher, fmt_money(bal))) frappe.throw(_("Outstanding for {0} cannot be less than zero ({1})").format(against_voucher, fmt_money(bal)))
# Update outstanding amt on against voucher
if against_voucher_type in ["Sales Invoice", "Purchase Invoice", "Fees"]: if against_voucher_type in ["Sales Invoice", "Purchase Invoice", "Fees"]:
ref_doc = frappe.get_doc(against_voucher_type, against_voucher) ref_doc = frappe.get_doc(against_voucher_type, against_voucher)
ref_doc.db_set('outstanding_amount', bal)
# Didn't use db_set for optimisation purpose
ref_doc.outstanding_amount = bal
frappe.db.set_value(against_voucher_type, against_voucher, 'outstanding_amount', bal)
ref_doc.set_status(update=True) ref_doc.set_status(update=True)
def validate_frozen_account(account, adv_adj=None): def validate_frozen_account(account, adv_adj=None):
@@ -274,6 +277,9 @@ def update_against_account(voucher_type, voucher_no):
if d.against != new_against: if d.against != new_against:
frappe.db.set_value("GL Entry", d.name, "against", new_against) frappe.db.set_value("GL Entry", d.name, "against", new_against)
def on_doctype_update():
frappe.db.add_index("GL Entry", ["against_voucher_type", "against_voucher"])
frappe.db.add_index("GL Entry", ["voucher_type", "voucher_no"])
def rename_gle_sle_docs(): def rename_gle_sle_docs():
for doctype in ["GL Entry", "Stock Ledger Entry"]: for doctype in ["GL Entry", "Stock Ledger Entry"]:

View File

@@ -456,11 +456,12 @@ class JournalEntry(AccountsController):
def set_print_format_fields(self): def set_print_format_fields(self):
bank_amount = party_amount = total_amount = 0.0 bank_amount = party_amount = total_amount = 0.0
currency = bank_account_currency = party_account_currency = pay_to_recd_from= None currency = bank_account_currency = party_account_currency = pay_to_recd_from= None
party_type = None
for d in self.get('accounts'): for d in self.get('accounts'):
if d.party_type in ['Customer', 'Supplier'] and d.party: if d.party_type in ['Customer', 'Supplier'] and d.party:
party_type = d.party_type
if not pay_to_recd_from: if not pay_to_recd_from:
pay_to_recd_from = frappe.db.get_value(d.party_type, d.party, pay_to_recd_from = d.party
"customer_name" if d.party_type=="Customer" else "supplier_name")
if pay_to_recd_from and pay_to_recd_from == d.party: if pay_to_recd_from and pay_to_recd_from == d.party:
party_amount += (d.debit_in_account_currency or d.credit_in_account_currency) party_amount += (d.debit_in_account_currency or d.credit_in_account_currency)
@@ -470,8 +471,9 @@ class JournalEntry(AccountsController):
bank_amount += (d.debit_in_account_currency or d.credit_in_account_currency) bank_amount += (d.debit_in_account_currency or d.credit_in_account_currency)
bank_account_currency = d.account_currency bank_account_currency = d.account_currency
if pay_to_recd_from: if party_type and pay_to_recd_from:
self.pay_to_recd_from = pay_to_recd_from self.pay_to_recd_from = frappe.db.get_value(party_type, pay_to_recd_from,
"customer_name" if party_type=="Customer" else "supplier_name")
if bank_amount: if bank_amount:
total_amount = bank_amount total_amount = bank_amount
currency = bank_account_currency currency = bank_account_currency

View File

@@ -149,6 +149,49 @@ class TestPaymentEntry(unittest.TestCase):
outstanding_amount = flt(frappe.db.get_value("Sales Invoice", pi.name, "outstanding_amount")) outstanding_amount = flt(frappe.db.get_value("Sales Invoice", pi.name, "outstanding_amount"))
self.assertEqual(outstanding_amount, 0) self.assertEqual(outstanding_amount, 0)
def test_payment_against_sales_invoice_to_check_status(self):
si = create_sales_invoice(customer="_Test Customer USD", debit_to="_Test Receivable USD - _TC",
currency="USD", conversion_rate=50)
pe = get_payment_entry("Sales Invoice", si.name, bank_account="_Test Bank USD - _TC")
pe.reference_no = "1"
pe.reference_date = "2016-01-01"
pe.target_exchange_rate = 50
pe.insert()
pe.submit()
outstanding_amount, status = frappe.db.get_value("Sales Invoice", si.name, ["outstanding_amount", "status"])
self.assertEqual(flt(outstanding_amount), 0)
self.assertEqual(status, 'Paid')
pe.cancel()
outstanding_amount, status = frappe.db.get_value("Sales Invoice", si.name, ["outstanding_amount", "status"])
self.assertEqual(flt(outstanding_amount), 100)
self.assertEqual(status, 'Unpaid')
def test_payment_against_purchase_invoice_to_check_status(self):
pi = make_purchase_invoice(supplier="_Test Supplier USD", debit_to="_Test Payable USD - _TC",
currency="USD", conversion_rate=50)
pe = get_payment_entry("Purchase Invoice", pi.name, bank_account="_Test Bank USD - _TC")
pe.reference_no = "1"
pe.reference_date = "2016-01-01"
pe.source_exchange_rate = 50
pe.insert()
pe.submit()
outstanding_amount, status = frappe.db.get_value("Purchase Invoice", pi.name, ["outstanding_amount", "status"])
self.assertEqual(flt(outstanding_amount), 0)
self.assertEqual(status, 'Paid')
pe.cancel()
outstanding_amount, status = frappe.db.get_value("Purchase Invoice", pi.name, ["outstanding_amount", "status"])
self.assertEqual(flt(outstanding_amount), 250)
self.assertEqual(status, 'Unpaid')
def test_payment_entry_against_ec(self): def test_payment_entry_against_ec(self):
payable = frappe.get_cached_value('Company', "_Test Company", 'default_payable_account') payable = frappe.get_cached_value('Company', "_Test Company", 'default_payable_account')

View File

@@ -126,12 +126,12 @@ class PaymentRequest(Document):
return controller.get_payment_url(**{ return controller.get_payment_url(**{
"amount": flt(self.grand_total, self.precision("grand_total")), "amount": flt(self.grand_total, self.precision("grand_total")),
"title": data.company.encode("utf-8"), "title": frappe.as_unicode(data.company),
"description": self.subject.encode("utf-8"), "description": frappe.as_unicode(self.subject),
"reference_doctype": "Payment Request", "reference_doctype": "Payment Request",
"reference_docname": self.name, "reference_docname": self.name,
"payer_email": self.email_to or frappe.session.user, "payer_email": self.email_to or frappe.session.user,
"payer_name": frappe.safe_encode(data.customer_name), "payer_name": frappe.as_unicode(data.customer_name),
"order_id": self.name, "order_id": self.name,
"currency": self.currency "currency": self.currency
}) })
@@ -317,13 +317,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
}) })

View File

@@ -245,7 +245,7 @@ def filter_pricing_rules(args, pricing_rules, doc=None):
def validate_quantity_and_amount_for_suggestion(args, qty, amount, item_code, transaction_type): def validate_quantity_and_amount_for_suggestion(args, qty, amount, item_code, transaction_type):
fieldname, msg = '', '' fieldname, msg = '', ''
type_of_transaction = 'purcahse' if transaction_type == "buying" else "sale" type_of_transaction = 'purchase' if transaction_type == 'buying' else 'sale'
for field, value in {'min_qty': qty, 'min_amt': amount}.items(): for field, value in {'min_qty': qty, 'min_amt': amount}.items():
if (args.get(field) and value < args.get(field) if (args.get(field) and value < args.get(field)

View File

@@ -382,7 +382,7 @@ class PurchaseInvoice(BuyingController):
update_outstanding_amt(self.credit_to, "Supplier", self.supplier, update_outstanding_amt(self.credit_to, "Supplier", self.supplier,
self.doctype, self.return_against if cint(self.is_return) and self.return_against else self.name) self.doctype, self.return_against if cint(self.is_return) and self.return_against else self.name)
if repost_future_gle and cint(self.update_stock) and self.auto_accounting_for_stock: if (repost_future_gle or self.flags.repost_future_gle) and cint(self.update_stock) and self.auto_accounting_for_stock:
from erpnext.controllers.stock_controller import update_gl_entries_after from erpnext.controllers.stock_controller import update_gl_entries_after
items, warehouses = self.get_items_and_warehouses() items, warehouses = self.get_items_and_warehouses()
update_gl_entries_after(self.posting_date, self.posting_time, update_gl_entries_after(self.posting_date, self.posting_time,
@@ -1038,3 +1038,6 @@ def block_invoice(name, release_date, hold_comment=None):
def make_inter_company_sales_invoice(source_name, target_doc=None): def make_inter_company_sales_invoice(source_name, target_doc=None):
from erpnext.accounts.doctype.sales_invoice.sales_invoice import make_inter_company_transaction from erpnext.accounts.doctype.sales_invoice.sales_invoice import make_inter_company_transaction
return make_inter_company_transaction("Purchase Invoice", source_name, target_doc) return make_inter_company_transaction("Purchase Invoice", source_name, target_doc)
def on_doctype_update():
frappe.db.add_index("Purchase Invoice", ["supplier", "is_return", "return_against"])

View File

@@ -198,7 +198,6 @@
"fieldtype": "Link", "fieldtype": "Link",
"label": "UOM", "label": "UOM",
"options": "UOM", "options": "UOM",
"print_hide": 1,
"reqd": 1 "reqd": 1
}, },
{ {
@@ -761,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",
@@ -771,7 +770,7 @@
"idx": 1, "idx": 1,
"istable": 1, "istable": 1,
"links": [], "links": [],
"modified": "2019-12-04 12:23:17.046413", "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

@@ -207,7 +207,7 @@ def get_customers_list(pos_profile={}):
if pos_profile.get('customer_groups'): if pos_profile.get('customer_groups'):
# Get customers based on the customer groups defined in the POS profile # Get customers based on the customer groups defined in the POS profile
for d in pos_profile.get('customer_groups'): for d in pos_profile.get('customer_groups'):
customer_groups.extend([d.name for d in get_child_nodes('Customer Group', d.customer_group)]) customer_groups.extend([d.get('name') for d in get_child_nodes('Customer Group', d.get('customer_group'))])
cond = "customer_group in (%s)" % (', '.join(['%s'] * len(customer_groups))) cond = "customer_group in (%s)" % (', '.join(['%s'] * len(customer_groups)))
return frappe.db.sql(""" select name, customer_name, customer_group, return frappe.db.sql(""" select name, customer_name, customer_group,
@@ -387,7 +387,9 @@ def get_pricing_rule_data(doc):
@frappe.whitelist() @frappe.whitelist()
def make_invoice(doc_list={}, email_queue_list={}, customers_list={}): def make_invoice(pos_profile, doc_list={}, email_queue_list={}, customers_list={}):
import json
if isinstance(doc_list, string_types): if isinstance(doc_list, string_types):
doc_list = json.loads(doc_list) doc_list = json.loads(doc_list)
@@ -421,7 +423,11 @@ def make_invoice(doc_list={}, email_queue_list={}, customers_list={}):
name_list.append(name) name_list.append(name)
email_queue = make_email_queue(email_queue_list) email_queue = make_email_queue(email_queue_list)
customers = get_customers_list()
if isinstance(pos_profile, string_types):
pos_profile = json.loads(pos_profile)
customers = get_customers_list(pos_profile)
return { return {
'invoice': name_list, 'invoice': name_list,
'email_queue': email_queue, 'email_queue': email_queue,

View File

@@ -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"))
@@ -721,7 +725,7 @@ class SalesInvoice(SellingController):
update_outstanding_amt(self.debit_to, "Customer", self.customer, update_outstanding_amt(self.debit_to, "Customer", self.customer,
self.doctype, self.return_against if cint(self.is_return) and self.return_against else self.name) self.doctype, self.return_against if cint(self.is_return) and self.return_against else self.name)
if repost_future_gle and cint(self.update_stock) \ if (repost_future_gle or self.flags.repost_future_gle) and cint(self.update_stock) \
and cint(auto_accounting_for_stock): and cint(auto_accounting_for_stock):
items, warehouses = self.get_items_and_warehouses() items, warehouses = self.get_items_and_warehouses()
update_gl_entries_after(self.posting_date, self.posting_time, update_gl_entries_after(self.posting_date, self.posting_time,
@@ -1215,24 +1219,6 @@ class SalesInvoice(SellingController):
self.set_missing_values(for_validate = True) self.set_missing_values(for_validate = True)
def get_discounting_status(self):
status = None
if self.is_discounted:
invoice_discounting_list = frappe.db.sql("""
select status
from `tabInvoice Discounting` id, `tabDiscounted Invoice` d
where
id.name = d.parent
and d.sales_invoice=%s
and id.docstatus=1
and status in ('Disbursed', 'Settled')
""", self.name)
for d in invoice_discounting_list:
status = d[0]
if status == "Disbursed":
break
return status
def set_status(self, update=False, status=None, update_modified=True): def set_status(self, update=False, status=None, update_modified=True):
if self.is_new(): if self.is_new():
if self.get('amended_from'): if self.get('amended_from'):
@@ -1243,7 +1229,10 @@ class SalesInvoice(SellingController):
outstanding_amount = flt(self.outstanding_amount, precision) outstanding_amount = flt(self.outstanding_amount, precision)
due_date = getdate(self.due_date) due_date = getdate(self.due_date)
nowdate = getdate() nowdate = getdate()
discountng_status = self.get_discounting_status()
discounting_status = None
if self.is_discounted:
discountng_status = get_discounting_status(self.name)
if not status: if not status:
if self.docstatus == 2: if self.docstatus == 2:
@@ -1272,6 +1261,26 @@ class SalesInvoice(SellingController):
if update: if update:
self.db_set('status', self.status, update_modified = update_modified) self.db_set('status', self.status, update_modified = update_modified)
def get_discounting_status(sales_invoice):
status = None
invoice_discounting_list = frappe.db.sql("""
select status
from `tabInvoice Discounting` id, `tabDiscounted Invoice` d
where
id.name = d.parent
and d.sales_invoice=%s
and id.docstatus=1
and status in ('Disbursed', 'Settled')
""", sales_invoice)
for d in invoice_discounting_list:
status = d[0]
if status == "Disbursed":
break
return status
def validate_inter_company_party(doctype, party, company, inter_company_reference): def validate_inter_company_party(doctype, party, company, inter_company_reference):
if not party: if not party:
return return
@@ -1439,6 +1448,21 @@ def get_inter_company_details(doc, doctype):
"company": company "company": company
} }
def get_internal_party(parties, link_doctype, doc):
if len(parties) == 1:
party = parties[0].name
else:
# If more than one Internal Supplier/Customer, get supplier/customer on basis of address
if doc.get('company_address') or doc.get('shipping_address'):
party = frappe.db.get_value("Dynamic Link", {"parent": doc.get('company_address') or doc.get('shipping_address'),
"parenttype": "Address", "link_doctype": link_doctype}, "link_name")
if not party:
party = parties[0].name
else:
party = parties[0].name
return party
def validate_inter_company_transaction(doc, doctype): def validate_inter_company_transaction(doc, doctype):

View File

@@ -728,7 +728,7 @@ class TestSalesInvoice(unittest.TestCase):
def test_make_pos_invoice(self): def test_make_pos_invoice(self):
from erpnext.accounts.doctype.sales_invoice.pos import make_invoice from erpnext.accounts.doctype.sales_invoice.pos import make_invoice
make_pos_profile() pos_profile = make_pos_profile()
pr = make_purchase_receipt(company= "_Test Company with perpetual inventory",supplier_warehouse= "Work In Progress - TCP1", item_code= "_Test FG Item",warehouse= "Stores - TCP1",cost_center= "Main - TCP1") pr = make_purchase_receipt(company= "_Test Company with perpetual inventory",supplier_warehouse= "Work In Progress - TCP1", item_code= "_Test FG Item",warehouse= "Stores - TCP1",cost_center= "Main - TCP1")
pos = create_sales_invoice(company= "_Test Company with perpetual inventory", debit_to="Debtors - TCP1", item_code= "_Test FG Item", warehouse="Stores - TCP1", income_account = "Sales - TCP1", expense_account = "Cost of Goods Sold - TCP1", cost_center = "Main - TCP1", do_not_save=True) pos = create_sales_invoice(company= "_Test Company with perpetual inventory", debit_to="Debtors - TCP1", item_code= "_Test FG Item", warehouse="Stores - TCP1", income_account = "Sales - TCP1", expense_account = "Cost of Goods Sold - TCP1", cost_center = "Main - TCP1", do_not_save=True)
@@ -744,7 +744,7 @@ class TestSalesInvoice(unittest.TestCase):
pos.append("taxes", tax) pos.append("taxes", tax)
invoice_data = [{'09052016142': pos}] invoice_data = [{'09052016142': pos}]
si = make_invoice(invoice_data).get('invoice') si = make_invoice(pos_profile, invoice_data).get('invoice')
self.assertEqual(si[0], '09052016142') self.assertEqual(si[0], '09052016142')
sales_invoice = frappe.get_all('Sales Invoice', fields =["*"], filters = {'offline_pos_name': '09052016142', 'docstatus': 1}) sales_invoice = frappe.get_all('Sales Invoice', fields =["*"], filters = {'offline_pos_name': '09052016142', 'docstatus': 1})
@@ -762,7 +762,7 @@ class TestSalesInvoice(unittest.TestCase):
if allow_negative_stock: if allow_negative_stock:
frappe.db.set_value('Stock Settings', None, 'allow_negative_stock', 0) frappe.db.set_value('Stock Settings', None, 'allow_negative_stock', 0)
make_pos_profile() pos_profile = make_pos_profile()
timestamp = cint(time.time()) timestamp = cint(time.time())
item = make_item("_Test POS Item") item = make_item("_Test POS Item")
@@ -776,7 +776,7 @@ class TestSalesInvoice(unittest.TestCase):
{'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 330}] {'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 330}]
invoice_data = [{timestamp: pos}] invoice_data = [{timestamp: pos}]
si = make_invoice(invoice_data).get('invoice') si = make_invoice(pos_profile, invoice_data).get('invoice')
self.assertEqual(si[0], timestamp) self.assertEqual(si[0], timestamp)
sales_invoice = frappe.get_all('Sales Invoice', fields =["*"], filters = {'offline_pos_name': timestamp}) sales_invoice = frappe.get_all('Sales Invoice', fields =["*"], filters = {'offline_pos_name': timestamp})
@@ -785,7 +785,7 @@ class TestSalesInvoice(unittest.TestCase):
timestamp = cint(time.time()) timestamp = cint(time.time())
pos["offline_pos_name"] = timestamp pos["offline_pos_name"] = timestamp
invoice_data = [{timestamp: pos}] invoice_data = [{timestamp: pos}]
si1 = make_invoice(invoice_data).get('invoice') si1 = make_invoice(pos_profile, invoice_data).get('invoice')
self.assertEqual(si1[0], timestamp) self.assertEqual(si1[0], timestamp)
sales_invoice1 = frappe.get_all('Sales Invoice', fields =["*"], filters = {'offline_pos_name': timestamp}) sales_invoice1 = frappe.get_all('Sales Invoice', fields =["*"], filters = {'offline_pos_name': timestamp})

View File

@@ -136,12 +136,14 @@ def save_entries(gl_map, adv_adj, update_outstanding, from_repost=False):
def make_entry(args, adv_adj, update_outstanding, from_repost=False): def make_entry(args, adv_adj, update_outstanding, from_repost=False):
args.update({"doctype": "GL Entry"}) gle = frappe.new_doc("GL Entry")
gle = frappe.get_doc(args) gle.update(args)
gle.flags.ignore_permissions = 1 gle.flags.ignore_permissions = 1
gle.flags.from_repost = from_repost gle.flags.from_repost = from_repost
gle.insert() gle.validate()
gle.db_insert()
gle.run_method("on_update_with_args", adv_adj, update_outstanding, from_repost) gle.run_method("on_update_with_args", adv_adj, update_outstanding, from_repost)
gle.flags.ignore_validate = True
gle.submit() gle.submit()
def validate_account_for_perpetual_inventory(gl_map): def validate_account_for_perpetual_inventory(gl_map):

View File

@@ -1769,6 +1769,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
method: "erpnext.accounts.doctype.sales_invoice.pos.make_invoice", method: "erpnext.accounts.doctype.sales_invoice.pos.make_invoice",
freeze: true, freeze: true,
args: { args: {
pos_profile: me.pos_profile_data,
doc_list: me.si_docs, doc_list: me.si_docs,
email_queue_list: me.email_queue_list, email_queue_list: me.email_queue_list,
customers_list: me.customers_list customers_list: me.customers_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

@@ -7,7 +7,7 @@ from frappe import _, scrub
from frappe.utils import getdate, nowdate, flt, cint, formatdate, cstr, now, time_diff_in_seconds from frappe.utils import getdate, nowdate, flt, cint, formatdate, cstr, now, time_diff_in_seconds
from collections import OrderedDict from collections import OrderedDict
from erpnext.accounts.utils import get_currency_precision from erpnext.accounts.utils import get_currency_precision
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions, get_dimension_with_children
# This report gives a summary of all Outstanding Invoices considering the following # This report gives a summary of all Outstanding Invoices considering the following
@@ -603,7 +603,6 @@ class ReceivablePayableReport(object):
self.add_supplier_filters(conditions, values) self.add_supplier_filters(conditions, values)
self.add_accounting_dimensions_filters(conditions, values) self.add_accounting_dimensions_filters(conditions, values)
return " and ".join(conditions), values return " and ".join(conditions), values
def get_order_by_condition(self): def get_order_by_condition(self):
@@ -666,13 +665,16 @@ class ReceivablePayableReport(object):
doctype=doctype, lft=lft, rgt=rgt, key=key) doctype=doctype, lft=lft, rgt=rgt, key=key)
def add_accounting_dimensions_filters(self, conditions, values): def add_accounting_dimensions_filters(self, conditions, values):
accounting_dimensions = get_accounting_dimensions() accounting_dimensions = get_accounting_dimensions(as_list=False)
if accounting_dimensions: if accounting_dimensions:
for dimension in accounting_dimensions: for dimension in accounting_dimensions:
if self.filters.get(dimension): if self.filters.get(dimension.fieldname):
conditions.append("{0} = %s".format(dimension)) if frappe.get_cached_value('DocType', dimension.document_type, 'is_tree'):
values.append(self.filters.get(dimension)) self.filters[dimension.fieldname] = get_dimension_with_children(dimension.document_type,
self.filters.get(dimension.fieldname))
conditions.append("{0} in %s".format(dimension.fieldname))
values.append(tuple(self.filters.get(dimension.fieldname)))
def get_gle_balance(self, gle): def get_gle_balance(self, gle):
# get the balance of the GL (debit - credit) or reverse balance based on report type # get the balance of the GL (debit - credit) or reverse balance based on report type

View File

@@ -4,125 +4,136 @@
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) 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)) flt(row.cost_of_sold_asset) - flt(row.cost_of_scrapped_asset))
row.update(asset_depreciations.get(asset_category)) 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) + 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)) 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) - row.net_asset_value_as_on_from_date = (flt(row.cost_as_on_from_date) -
flt(row.accumulated_depreciation_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) - row.net_asset_value_as_on_to_date = (flt(row.cost_as_on_to_date) -
flt(row.accumulated_depreciation_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,
ifnull(sum(case when ds.schedule_date < %(from_date)s then
ds.depreciation_amount
else
0
end), 0) as accumulated_depreciation_as_on_from_date,
ifnull(sum(case when ifnull(a.disposal_date, 0) != 0 and a.disposal_date >= %(from_date)s
and a.disposal_date <= %(to_date)s and ds.schedule_date <= a.disposal_date then
ds.depreciation_amount
else
0
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
and (ifnull(a.disposal_date, 0) = 0 or ds.schedule_date <= a.disposal_date) then
ds.depreciation_amount
else
0
end), 0) as depreciation_amount_during_the_period
from `tabAsset` a, `tabDepreciation Schedule` ds
where a.docstatus=1 and a.company=%(company)s and a.purchase_date <= %(to_date)s and a.name = ds.parent
group by a.asset_category
union
SELECT a.asset_category,
ifnull(sum(case when ifnull(a.disposal_date, 0) != 0
and (a.disposal_date < %(from_date)s or a.disposal_date > %(to_date)s)
then
0
else
a.opening_accumulated_depreciation
end), 0) as accumulated_depreciation_as_on_from_date,
ifnull(sum(case when a.disposal_date >= %(from_date)s and a.disposal_date <= %(to_date)s then
a.opening_accumulated_depreciation
else
0
end), 0) as depreciation_eliminated_during_the_period,
0 as depreciation_amount_during_the_period
from `tabAsset` a
where a.docstatus=1 and a.company=%(company)s and a.purchase_date <= %(to_date)s
group by a.asset_category) as results
group by results.asset_category
""", {"to_date": filters.to_date, "from_date": filters.from_date, "company": filters.company}, as_dict=1)
def get_asset_costs(assets, filters):
asset_costs = frappe._dict()
for d in assets:
asset_costs.setdefault(d.asset_category, frappe._dict({
"cost_as_on_from_date": 0,
"cost_of_new_purchase": 0,
"cost_of_sold_asset": 0,
"cost_of_scrapped_asset": 0
}))
costs = asset_costs[d.asset_category]
if getdate(d.purchase_date) < getdate(filters.from_date):
if not d.disposal_date or getdate(d.disposal_date) >= getdate(filters.from_date):
costs.cost_as_on_from_date += flt(d.gross_purchase_amount)
else:
costs.cost_of_new_purchase += flt(d.gross_purchase_amount)
if d.disposal_date and getdate(d.disposal_date) >= getdate(filters.from_date) \
and getdate(d.disposal_date) <= getdate(filters.to_date):
if d.status == "Sold":
costs.cost_of_sold_asset += flt(d.gross_purchase_amount)
elif d.status == "Scrapped":
costs.cost_of_scrapped_asset += flt(d.gross_purchase_amount)
return asset_costs
def get_accumulated_depreciations(assets, filters):
asset_depreciations = frappe._dict()
for d in assets:
asset = frappe.get_doc("Asset", d.name)
if d.asset_category in asset_depreciations:
asset_depreciations[d.asset_category]['accumulated_depreciation_as_on_from_date'] += asset.opening_accumulated_depreciation
else:
asset_depreciations.setdefault(d.asset_category, frappe._dict({
"accumulated_depreciation_as_on_from_date": asset.opening_accumulated_depreciation,
"depreciation_amount_during_the_period": 0,
"depreciation_eliminated_during_the_period": 0
}))
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

@@ -16,7 +16,7 @@ from frappe import _
from frappe.utils import (flt, getdate, get_first_day, add_months, add_days, formatdate, cstr) from frappe.utils import (flt, getdate, get_first_day, add_months, add_days, formatdate, cstr)
from six import itervalues from six import itervalues
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions, get_dimension_with_children
def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_values=False, def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_values=False,
company=None, reset_period_on_fy_change=True): company=None, reset_period_on_fy_change=True):
@@ -389,7 +389,7 @@ def set_gl_entries_by_account(
def get_additional_conditions(from_date, ignore_closing_entries, filters): def get_additional_conditions(from_date, ignore_closing_entries, filters):
additional_conditions = [] additional_conditions = []
accounting_dimensions = get_accounting_dimensions() accounting_dimensions = get_accounting_dimensions(as_list=False)
if ignore_closing_entries: if ignore_closing_entries:
additional_conditions.append("ifnull(voucher_type, '')!='Period Closing Voucher'") additional_conditions.append("ifnull(voucher_type, '')!='Period Closing Voucher'")
@@ -415,8 +415,11 @@ def get_additional_conditions(from_date, ignore_closing_entries, filters):
if accounting_dimensions: if accounting_dimensions:
for dimension in accounting_dimensions: for dimension in accounting_dimensions:
if filters.get(dimension): if filters.get(dimension.fieldname):
additional_conditions.append("{0} in (%({0})s)".format(dimension)) 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))
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

@@ -2,7 +2,7 @@
<h4 class="text-center"> <h4 class="text-center">
{% if (filters.party_name) { %} {% if (filters.party_name) { %}
{%= filters.party_name %} {%= filters.party_name %}
{% } else if (filters.party && filters.show_name) { %} {% } else if (filters.party) { %}
{%= filters.party %} {%= filters.party %}
{% } else if (filters.account) { %} {% } else if (filters.account) { %}
{%= filters.account %} {%= filters.account %}

View File

@@ -10,7 +10,7 @@ from frappe import _, _dict
from erpnext.accounts.utils import get_account_currency from erpnext.accounts.utils import get_account_currency
from erpnext.accounts.report.financial_statements import get_cost_centers_with_children from erpnext.accounts.report.financial_statements import get_cost_centers_with_children
from six import iteritems from six import iteritems
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions, get_dimension_with_children
from collections import OrderedDict from collections import OrderedDict
def execute(filters=None): def execute(filters=None):
@@ -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}
@@ -194,12 +194,15 @@ def get_conditions(filters):
if match_conditions: if match_conditions:
conditions.append(match_conditions) conditions.append(match_conditions)
accounting_dimensions = get_accounting_dimensions() accounting_dimensions = get_accounting_dimensions(as_list=False)
if accounting_dimensions: if accounting_dimensions:
for dimension in accounting_dimensions: for dimension in accounting_dimensions:
if filters.get(dimension): if filters.get(dimension.fieldname):
conditions.append("{0} in (%({0})s)".format(dimension)) 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.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 ""
@@ -359,6 +362,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

@@ -54,8 +54,8 @@ def _execute(filters=None, additional_table_columns=None, additional_query_colum
'description': d.description, 'description': d.description,
'invoice': d.parent, 'invoice': d.parent,
'posting_date': d.posting_date, 'posting_date': d.posting_date,
'customer': d.supplier, 'supplier': d.supplier,
'customer_name': d.supplier_name 'supplier_name': d.supplier_name
} }
if additional_query_columns: if additional_query_columns:
@@ -201,7 +201,8 @@ def get_columns(additional_table_columns, filters):
{ {
'label': _('Mode Of Payment'), 'label': _('Mode Of Payment'),
'fieldname': 'mode_of_payment', 'fieldname': 'mode_of_payment',
'fieldtype': 'Data', 'fieldtype': 'Link',
'options': 'Mode of Payment',
'width': 120 'width': 120
}, },
{ {
@@ -309,6 +310,8 @@ def get_items(filters, additional_query_columns):
if additional_query_columns: if additional_query_columns:
additional_query_columns = ', ' + ', '.join(additional_query_columns) additional_query_columns = ', ' + ', '.join(additional_query_columns)
else:
additional_query_columns = ''
return frappe.db.sql(""" return frappe.db.sql("""
select select
@@ -320,7 +323,7 @@ def get_items(filters, additional_query_columns):
`tabPurchase Invoice Item`.`purchase_receipt`, `tabPurchase Invoice Item`.`po_detail`, `tabPurchase Invoice Item`.`purchase_receipt`, `tabPurchase Invoice Item`.`po_detail`,
`tabPurchase Invoice Item`.`expense_account`, `tabPurchase Invoice Item`.`stock_qty`, `tabPurchase Invoice Item`.`expense_account`, `tabPurchase Invoice Item`.`stock_qty`,
`tabPurchase Invoice Item`.`stock_uom`, `tabPurchase Invoice Item`.`base_net_amount`, `tabPurchase Invoice Item`.`stock_uom`, `tabPurchase Invoice Item`.`base_net_amount`,
`tabPurchase Invoice`.supplier_name, `tabPurchase Invoice`.mode_of_payment {0} `tabPurchase Invoice`.`supplier_name`, `tabPurchase Invoice`.`mode_of_payment` {0}
from `tabPurchase Invoice`, `tabPurchase Invoice Item` from `tabPurchase Invoice`, `tabPurchase Invoice Item`
where `tabPurchase Invoice`.name = `tabPurchase Invoice Item`.`parent` and where `tabPurchase Invoice`.name = `tabPurchase Invoice Item`.`parent` and
`tabPurchase Invoice`.docstatus = 1 %s `tabPurchase Invoice`.docstatus = 1 %s

View File

@@ -373,6 +373,8 @@ def get_items(filters, additional_query_columns):
if additional_query_columns: if additional_query_columns:
additional_query_columns = ', ' + ', '.join(additional_query_columns) additional_query_columns = ', ' + ', '.join(additional_query_columns)
else:
additional_query_columns = ''
return frappe.db.sql(""" return frappe.db.sql("""
select select

View File

@@ -6,7 +6,7 @@ import frappe
from frappe.utils import flt from frappe.utils import flt
from frappe import msgprint, _ from frappe import msgprint, _
from frappe.model.meta import get_field_precision from frappe.model.meta import get_field_precision
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions 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)
@@ -341,14 +341,18 @@ def get_conditions(filters):
where parent=`tabSales Invoice`.name where parent=`tabSales Invoice`.name
and ifnull(`tabSales Invoice Item`.item_group, '') = %(item_group)s)""" and ifnull(`tabSales Invoice Item`.item_group, '') = %(item_group)s)"""
accounting_dimensions = get_accounting_dimensions() accounting_dimensions = get_accounting_dimensions(as_list=False)
if accounting_dimensions: if accounting_dimensions:
for dimension in accounting_dimensions: for dimension in accounting_dimensions:
if filters.get(dimension): 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 += """ and exists(select name from `tabSales Invoice Item` conditions += """ and exists(select name from `tabSales Invoice Item`
where parent=`tabSales Invoice`.name where parent=`tabSales Invoice`.name
and ifnull(`tabSales Invoice Item`.{0}, '') = %({0})s)""".format(dimension) and ifnull(`tabSales Invoice Item`.{0}, '') in %({0})s)""".format(dimension.fieldname)
return conditions return conditions

View File

@@ -7,7 +7,7 @@ from frappe import _
from frappe.utils import flt, getdate, formatdate, cstr from frappe.utils import flt, getdate, formatdate, cstr
from erpnext.accounts.report.financial_statements \ from erpnext.accounts.report.financial_statements \
import filter_accounts, set_gl_entries_by_account, filter_out_zero_value_rows import filter_accounts, set_gl_entries_by_account, filter_out_zero_value_rows
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions, get_dimension_with_children
value_fields = ("opening_debit", "opening_credit", "debit", "credit", "closing_debit", "closing_credit") value_fields = ("opening_debit", "opening_credit", "debit", "credit", "closing_debit", "closing_credit")
@@ -109,7 +109,7 @@ def get_rootwise_opening_balances(filters, report_type):
additional_conditions += fb_conditions additional_conditions += fb_conditions
accounting_dimensions = get_accounting_dimensions() accounting_dimensions = get_accounting_dimensions(as_list=False)
query_filters = { query_filters = {
"company": filters.company, "company": filters.company,
@@ -122,11 +122,14 @@ def get_rootwise_opening_balances(filters, report_type):
if accounting_dimensions: if accounting_dimensions:
for dimension in accounting_dimensions: for dimension in accounting_dimensions:
if filters.get(dimension): if filters.get(dimension.fieldname):
additional_conditions += """ and {0} in (%({0})s) """.format(dimension) 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))
additional_conditions += "and {0} in %({0})s".format(dimension.fieldname)
query_filters.update({ query_filters.update({
dimension: filters.get(dimension) dimension.fieldname: filters.get(dimension.fieldname)
}) })
gle = frappe.db.sql(""" gle = frappe.db.sql("""

View File

@@ -139,12 +139,14 @@
"read_only": 1 "read_only": 1
} }
], ],
"is_tree": 1,
"links": [], "links": [],
"modified": "2020-01-28 13:52:22.513425", "modified": "2020-03-18 18:25:59.283057",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Assets", "module": "Assets",
"name": "Location", "name": "Location",
"name_case": "Title Case", "name_case": "Title Case",
"nsm_parent_field": "parent_location",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {

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

@@ -181,6 +181,11 @@ def get_data():
"name": "Payment Reconciliation", "name": "Payment Reconciliation",
"description": _("Match non-linked Invoices and Payments.") "description": _("Match non-linked Invoices and Payments.")
}, },
{
"type": "doctype",
"label": _("Invoice Discounting"),
"name": "Invoice Discounting",
},
{ {
"type": "doctype", "type": "doctype",
"label": _("Update Bank Transaction Dates"), "label": _("Update Bank Transaction Dates"),
@@ -189,8 +194,9 @@ def get_data():
}, },
{ {
"type": "doctype", "type": "doctype",
"label": _("Invoice Discounting"), "label": _("Bank Transaction"),
"name": "Invoice Discounting", "name": "Bank Transaction",
"doctype": "Bank Transaction"
}, },
{ {
"type": "report", "type": "report",

View File

@@ -44,6 +44,7 @@ class BuyingController(StockController):
self.validate_stock_or_nonstock_items() self.validate_stock_or_nonstock_items()
self.validate_warehouse() self.validate_warehouse()
self.set_supplier_address() self.set_supplier_address()
self.validate_asset_return()
if self.doctype=="Purchase Invoice": if self.doctype=="Purchase Invoice":
self.validate_purchase_receipt_if_update_stock() self.validate_purchase_receipt_if_update_stock()
@@ -100,6 +101,19 @@ class BuyingController(StockController):
d.category = 'Total' d.category = 'Total'
msgprint(_('Tax Category has been changed to "Total" because all the Items are non-stock items')) msgprint(_('Tax Category has been changed to "Total" because all the Items are non-stock items'))
def validate_asset_return(self):
if self.doctype not in ['Purchase Receipt', 'Purchase Invoice'] or not self.is_return:
return
purchase_doc_field = 'purchase_receipt' if self.doctype == 'Purchase Receipt' else 'purchase_invoice'
not_cancelled_asset = [d.name for d in frappe.db.get_all("Asset", {
purchase_doc_field: self.return_against,
"docstatus": 1
})]
if self.is_return and len(not_cancelled_asset):
frappe.throw(_("{} has submitted assets linked to it. You need to cancel the assets to create purchase return.".format(self.return_against)),
title=_("Not Allowed"))
def get_asset_items(self): def get_asset_items(self):
if self.doctype not in ['Purchase Order', 'Purchase Invoice', 'Purchase Receipt']: if self.doctype not in ['Purchase Order', 'Purchase Invoice', 'Purchase Receipt']:
return [] return []
@@ -644,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:
@@ -688,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:
@@ -717,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

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

@@ -44,17 +44,6 @@ status_map = {
["Closed", "eval:self.status=='Closed'"], ["Closed", "eval:self.status=='Closed'"],
["On Hold", "eval:self.status=='On Hold'"], ["On Hold", "eval:self.status=='On Hold'"],
], ],
"Purchase Invoice": [
["Draft", None],
["Submitted", "eval:self.docstatus==1"],
["Paid", "eval:self.outstanding_amount==0 and self.docstatus==1"],
["Return", "eval:self.is_return==1 and self.docstatus==1"],
["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})"],
["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"],
["Cancelled", "eval:self.docstatus==2"],
],
"Purchase Order": [ "Purchase Order": [
["Draft", None], ["Draft", None],
["To Receive and Bill", "eval:self.per_received < 100 and self.per_billed < 100 and self.docstatus == 1"], ["To Receive and Bill", "eval:self.per_received < 100 and self.per_billed < 100 and self.docstatus == 1"],
@@ -80,6 +69,17 @@ status_map = {
["Cancelled", "eval:self.docstatus==2"], ["Cancelled", "eval:self.docstatus==2"],
["Closed", "eval:self.status=='Closed'"], ["Closed", "eval:self.status=='Closed'"],
], ],
"Purchase Invoice": [
["Draft", None],
["Submitted", "eval:self.docstatus==1"],
["Paid", "eval:self.outstanding_amount==0 and self.docstatus==1"],
["Return", "eval:self.is_return==1 and self.docstatus==1"],
["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})"],
["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"],
["Cancelled", "eval:self.docstatus==2"],
],
"Material Request": [ "Material Request": [
["Draft", None], ["Draft", None],
["Stopped", "eval:self.status == 'Stopped'"], ["Stopped", "eval:self.status == 'Stopped'"],

View File

@@ -34,7 +34,7 @@ class StockController(AccountsController):
gl_entries = self.get_gl_entries(warehouse_account) gl_entries = self.get_gl_entries(warehouse_account)
make_gl_entries(gl_entries, from_repost=from_repost) make_gl_entries(gl_entries, from_repost=from_repost)
if repost_future_gle: if (repost_future_gle or self.flags.repost_future_gle):
items, warehouses = self.get_items_and_warehouses() items, warehouses = self.get_items_and_warehouses()
update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items, update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items,
warehouse_account, company=self.company) warehouse_account, company=self.company)
@@ -239,6 +239,10 @@ class StockController(AccountsController):
for d in self.items: for d in self.items:
if not d.batch_no: continue if not d.batch_no: continue
serial_nos = [sr.name for sr in frappe.get_all("Serial No", {'batch_no': d.batch_no})]
if serial_nos:
frappe.db.set_value("Serial No", { 'name': ['in', serial_nos] }, "batch_no", None)
d.batch_no = None d.batch_no = None
d.db_set("batch_no", None) d.db_set("batch_no", None)

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

@@ -6,18 +6,13 @@ from __future__ import unicode_literals
import frappe import frappe
from frappe.utils.make_random import get_random from frappe.utils.make_random import get_random
from erpnext.assets.doctype.asset.asset import make_purchase_invoice, make_sales_invoice from erpnext.assets.doctype.asset.asset import make_sales_invoice
from erpnext.assets.doctype.asset.depreciation import post_depreciation_entries, scrap_asset from erpnext.assets.doctype.asset.depreciation import post_depreciation_entries, scrap_asset
def work(): def work():
frappe.set_user(frappe.db.get_global('demo_accounts_user')) frappe.set_user(frappe.db.get_global('demo_accounts_user'))
asset_list = make_asset_purchase_entry()
if not asset_list:
# fixed_asset.work() already run
return
# Enable booking asset depreciation entry automatically # Enable booking asset depreciation entry automatically
frappe.db.set_value("Accounts Settings", None, "book_asset_depreciation_entry_automatically", 1) frappe.db.set_value("Accounts Settings", None, "book_asset_depreciation_entry_automatically", 1)
@@ -33,19 +28,6 @@ def work():
# Sell a random asset # Sell a random asset
sell_an_asset() sell_an_asset()
def make_asset_purchase_entry():
asset_list = frappe.get_all("Asset", filters={"purchase_invoice": ["in", ("", None)]},
fields=["name", "item_code", "gross_purchase_amount", "company", "purchase_date"])
# make purchase invoice
for asset in asset_list:
pi = make_purchase_invoice(asset.name, asset.item_code, asset.gross_purchase_amount,
asset.company, asset.purchase_date)
pi.supplier = get_random("Supplier")
pi.save()
pi.submit()
return asset_list
def sell_an_asset(): def sell_an_asset():
asset = get_random_asset() asset = get_random_asset()
@@ -56,6 +38,7 @@ def sell_an_asset():
si.save() si.save()
si.submit() si.submit()
def get_random_asset(): def get_random_asset():
return frappe.db.sql(""" select name, item_code, value_after_depreciation, gross_purchase_amount return frappe.db.sql(""" select name, item_code, value_after_depreciation, gross_purchase_amount
from `tabAsset` from `tabAsset`

View File

@@ -1,274 +1,91 @@
{ {
"allow_copy": 0, "actions": [],
"allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 1, "allow_rename": 1,
"autoname": "field:assessment_group_name", "autoname": "field:assessment_group_name",
"beta": 0,
"creation": "2016-08-04 04:42:48.319388", "creation": "2016-08-04 04:42:48.319388",
"custom": 0,
"docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
"document_type": "",
"editable_grid": 1, "editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"assessment_group_name",
"is_group",
"section_break_2",
"parent_assessment_group",
"lft",
"rgt",
"old_parent"
],
"fields": [ "fields": [
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "assessment_group_name", "fieldname": "assessment_group_name",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Assessment Group Name", "label": "Assessment Group 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, "reqd": 1,
"search_index": 0, "unique": 1
"set_only_once": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0, "default": "0",
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "is_group", "fieldname": "is_group",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "label": "Is Group"
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Is Group",
"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,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "section_break_2", "fieldname": "section_break_2",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 1, "hidden": 1
"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,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "parent_assessment_group", "fieldname": "parent_assessment_group",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Parent Assessment Group", "label": "Parent Assessment Group",
"length": 0,
"no_copy": 0,
"options": "Assessment Group", "options": "Assessment Group",
"permlevel": 0, "reqd": 1
"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,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "lft", "fieldname": "lft",
"fieldtype": "Int", "fieldtype": "Int",
"hidden": 0, "label": "lft"
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "lft",
"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,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "rgt", "fieldname": "rgt",
"fieldtype": "Int", "fieldtype": "Int",
"hidden": 0, "label": "rgt"
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "rgt",
"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,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "old_parent", "fieldname": "old_parent",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "old_parent", "label": "old_parent",
"length": 0, "options": "Assessment Group"
"no_copy": 0,
"options": "Assessment Group",
"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,
"unique": 0
} }
], ],
"has_web_view": 0, "is_tree": 1,
"hide_heading": 0, "links": [],
"hide_toolbar": 0, "modified": "2020-03-18 18:26:07.834596",
"idx": 0,
"image_view": 0,
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-11-10 19:09:25.366400",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Education", "module": "Education",
"name": "Assessment Group", "name": "Assessment Group",
"name_case": "", "nsm_parent_field": "parent_assessment_group",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
"email": 1, "email": 1,
"export": 1, "export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "Academics User", "role": "Academics User",
"set_user_permissions": 0,
"share": 1, "share": 1,
"submit": 0,
"write": 1 "write": 1
} }
], ],
"quick_entry": 1, "quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"restrict_to_domain": "Education", "restrict_to_domain": "Education",
"show_name_in_global_search": 0,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC", "sort_order": "DESC"
"track_changes": 0,
"track_seen": 0
} }

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

@@ -47,11 +47,12 @@ def _order(*args, **kwargs):
return "success" return "success"
if event == "created": if event == "created":
sys_lang = frappe.get_single("System Settings").language or 'en'
raw_billing_data = order.get("billing") raw_billing_data = order.get("billing")
customer_name = raw_billing_data.get("first_name") + " " + raw_billing_data.get("last_name") customer_name = raw_billing_data.get("first_name") + " " + raw_billing_data.get("last_name")
link_customer_and_address(raw_billing_data, customer_name) link_customer_and_address(raw_billing_data, customer_name)
link_items(order.get("line_items"), woocommerce_settings) link_items(order.get("line_items"), woocommerce_settings, sys_lang)
create_sales_order(order, woocommerce_settings, customer_name) create_sales_order(order, woocommerce_settings, customer_name, sys_lang)
def link_customer_and_address(raw_billing_data, customer_name): def link_customer_and_address(raw_billing_data, customer_name):
customer_woo_com_email = raw_billing_data.get("email") customer_woo_com_email = raw_billing_data.get("email")
@@ -100,7 +101,7 @@ def link_customer_and_address(raw_billing_data, customer_name):
frappe.rename_doc("Address", old_address_title, new_address_title) frappe.rename_doc("Address", old_address_title, new_address_title)
def link_items(items_list, woocommerce_settings): def link_items(items_list, woocommerce_settings, sys_lang):
for item_data in items_list: for item_data in items_list:
item_woo_com_id = item_data.get("product_id") item_woo_com_id = item_data.get("product_id")
@@ -112,14 +113,14 @@ def link_items(items_list, woocommerce_settings):
item = frappe.new_doc("Item") item = frappe.new_doc("Item")
item.item_name = item_data.get("name") item.item_name = item_data.get("name")
item.item_code = _("woocommerce - {0}").format(item_data.get("product_id")) item.item_code = _("woocommerce - {0}", sys_lang).format(item_data.get("product_id"))
item.woocommerce_id = item_data.get("product_id") item.woocommerce_id = item_data.get("product_id")
item.item_group = _("WooCommerce Products") item.item_group = _("WooCommerce Products", sys_lang)
item.stock_uom = woocommerce_settings.uom or _("Nos") item.stock_uom = woocommerce_settings.uom or _("Nos", sys_lang)
item.flags.ignore_mandatory = True item.flags.ignore_mandatory = True
item.save() item.save()
def create_sales_order(order, woocommerce_settings, customer_name): def create_sales_order(order, woocommerce_settings, customer_name, sys_lang):
new_sales_order = frappe.new_doc("Sales Order") new_sales_order = frappe.new_doc("Sales Order")
new_sales_order.customer = customer_name new_sales_order.customer = customer_name
@@ -133,14 +134,14 @@ def create_sales_order(order, woocommerce_settings, customer_name):
new_sales_order.company = woocommerce_settings.company new_sales_order.company = woocommerce_settings.company
set_items_in_sales_order(new_sales_order, woocommerce_settings, order) set_items_in_sales_order(new_sales_order, woocommerce_settings, order, sys_lang)
new_sales_order.flags.ignore_mandatory = True new_sales_order.flags.ignore_mandatory = True
new_sales_order.insert() new_sales_order.insert()
new_sales_order.submit() new_sales_order.submit()
frappe.db.commit() frappe.db.commit()
def set_items_in_sales_order(new_sales_order, woocommerce_settings, order): def set_items_in_sales_order(new_sales_order, woocommerce_settings, order, sys_lang):
company_abbr = frappe.db.get_value('Company', woocommerce_settings.company, 'abbr') company_abbr = frappe.db.get_value('Company', woocommerce_settings.company, 'abbr')
for item in order.get("line_items"): for item in order.get("line_items"):
@@ -154,10 +155,10 @@ def set_items_in_sales_order(new_sales_order, woocommerce_settings, order):
"item_name": found_item.item_name, "item_name": found_item.item_name,
"description": found_item.item_name, "description": found_item.item_name,
"delivery_date": new_sales_order.delivery_date, "delivery_date": new_sales_order.delivery_date,
"uom": woocommerce_settings.uom or _("Nos"), "uom": woocommerce_settings.uom or _("Nos", sys_lang),
"qty": item.get("quantity"), "qty": item.get("quantity"),
"rate": item.get("price"), "rate": item.get("price"),
"warehouse": woocommerce_settings.warehouse or _("Stores - {0}").format(company_abbr) "warehouse": woocommerce_settings.warehouse or _("Stores - {0}", sys_lang).format(company_abbr)
}) })
add_tax_details(new_sales_order, ordered_items_tax, "Ordered Item tax", woocommerce_settings.tax_account) add_tax_details(new_sales_order, ordered_items_tax, "Ordered Item tax", woocommerce_settings.tax_account)

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

@@ -1,807 +1,230 @@
{ {
"allow_copy": 0, "actions": [],
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 1, "allow_rename": 1,
"autoname": "field:template", "autoname": "field:template",
"beta": 1, "beta": 1,
"creation": "2017-10-05 14:59:55.438359", "creation": "2017-10-05 14:59:55.438359",
"custom": 0,
"description": "Procedure Template", "description": "Procedure Template",
"docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
"document_type": "Setup", "document_type": "Setup",
"editable_grid": 1, "editable_grid": 1,
"engine": "InnoDB", "engine": "InnoDB",
"field_order": [
"template",
"item",
"item_code",
"item_group",
"description",
"column_break_5",
"disabled",
"is_billable",
"rate",
"medical_department",
"consumables",
"consume_stock",
"items",
"sample_collection",
"sample",
"sample_uom",
"sample_qty",
"column_break_21",
"sample_details",
"change_in_item"
],
"fields": [ "fields": [
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "template", "fieldname": "template",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 1, "in_global_search": 1,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Template Name", "label": "Template Name",
"length": 0,
"no_copy": 0,
"options": "",
"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, "reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 1 "unique": 1
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "item_code", "fieldname": "item_code",
"fieldtype": "Link", "fieldtype": "Data",
"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": "Item Code", "label": "Item Code",
"length": 0,
"no_copy": 1,
"options": "Item", "options": "Item",
"permlevel": 0, "reqd": 1
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "item_group", "fieldname": "item_group",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 1, "in_standard_filter": 1,
"label": "Item Group", "label": "Item Group",
"length": 0,
"no_copy": 0,
"options": "Item Group", "options": "Item Group",
"permlevel": 0, "reqd": 1
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "medical_department", "fieldname": "medical_department",
"fieldtype": "Link", "fieldtype": "Link",
"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": "Medical Department", "label": "Medical Department",
"length": 0, "options": "Medical Department"
"no_copy": 0,
"options": "Medical Department",
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_5", "fieldname": "column_break_5",
"fieldtype": "Column Break", "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, "default": "0",
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "is_billable", "fieldname": "is_billable",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "label": "Is Billable"
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Is Billable",
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "is_billable", "depends_on": "is_billable",
"fieldname": "rate", "fieldname": "rate",
"fieldtype": "Float", "fieldtype": "Float",
"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": "Rate", "label": "Rate",
"length": 0, "mandatory_depends_on": "is_billable"
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "description", "fieldname": "description",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 1, "ignore_xss_filter": 1,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Description", "label": "Description",
"length": 0,
"no_copy": 1, "no_copy": 1,
"permlevel": 0, "reqd": 1
"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, "default": "0",
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "",
"fieldname": "section_break_9",
"fieldtype": "Section 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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "consume_stock", "fieldname": "consume_stock",
"fieldtype": "Check", "fieldtype": "Check",
"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": "Allow Stock Consumption", "label": "Allow Stock Consumption",
"length": 0, "search_index": 1
"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": 1,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.consume_stock == 1",
"fieldname": "consumables", "fieldname": "consumables",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "label": "Consumables"
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Consumables",
"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, "depends_on": "eval:doc.consume_stock == 1",
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "items", "fieldname": "items",
"fieldtype": "Table", "fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Items", "label": "Items",
"length": 0, "options": "Clinical Procedure Item"
"no_copy": 0,
"options": "Clinical Procedure Item",
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1, "collapsible": 1,
"columns": 0,
"depends_on": "",
"fieldname": "sample_collection", "fieldname": "sample_collection",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "label": "Sample Collection"
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Sample Collection",
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "sample", "fieldname": "sample",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Sample", "label": "Sample",
"length": 0, "options": "Lab Test Sample"
"no_copy": 0,
"options": "Lab Test Sample",
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_from": "sample.sample_uom", "fetch_from": "sample.sample_uom",
"fieldname": "sample_uom", "fieldname": "sample_uom",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "label": "UOM"
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "UOM",
"length": 0,
"no_copy": 0,
"options": "",
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "sample_qty", "fieldname": "sample_qty",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "label": "Quantity"
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Quantity",
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_21", "fieldname": "column_break_21",
"fieldtype": "Column Break", "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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "sample_details", "fieldname": "sample_details",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 1, "ignore_xss_filter": 1,
"in_filter": 0, "label": "Collection Details"
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Collection Details",
"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, "default": "0",
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "change_in_item", "fieldname": "change_in_item",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 1, "hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Change In Item", "label": "Change In Item",
"length": 0,
"no_copy": 1, "no_copy": 1,
"permlevel": 0,
"precision": "",
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0, "report_hide": 1
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 1,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0, "default": "0",
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "disabled", "fieldname": "disabled",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 1, "label": "Disabled"
"ignore_user_permissions": 0,
"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": 1,
"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
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "item", "fieldname": "item",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Item", "label": "Item",
"length": 0,
"no_copy": 1, "no_copy": 1,
"options": "Item", "options": "Item",
"permlevel": 0, "read_only": 1
"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-02-27 16:32:55.780893",
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2019-02-12 11:37:18.713344",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Healthcare", "module": "Healthcare",
"name": "Clinical Procedure Template", "name": "Clinical Procedure Template",
"name_case": "",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {
"amend": 0,
"cancel": 0,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
"email": 1, "email": 1,
"export": 1, "export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "System Manager", "role": "System Manager",
"set_user_permissions": 0,
"share": 1, "share": 1,
"submit": 0,
"write": 1 "write": 1
}, },
{ {
"amend": 0,
"cancel": 0,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
"email": 1, "email": 1,
"export": 1, "export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "Healthcare Administrator", "role": "Healthcare Administrator",
"set_user_permissions": 0,
"share": 1, "share": 1,
"submit": 0,
"write": 1 "write": 1
}, },
{ {
"amend": 0,
"cancel": 0,
"create": 0,
"delete": 0,
"email": 1, "email": 1,
"export": 1, "export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "Nursing User", "role": "Nursing User",
"set_user_permissions": 0, "share": 1
"share": 1,
"submit": 0,
"write": 0
}, },
{ {
"amend": 0,
"cancel": 0,
"create": 0,
"delete": 0,
"email": 1, "email": 1,
"export": 1, "export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "Physician", "role": "Physician",
"set_user_permissions": 0,
"share": 1, "share": 1,
"submit": 0,
"write": 1 "write": 1
} }
], ],
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"restrict_to_domain": "Healthcare", "restrict_to_domain": "Healthcare",
"search_fields": "template", "search_fields": "template",
"show_name_in_global_search": 0,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC", "sort_order": "DESC",
"title_field": "template", "title_field": "template",
"track_changes": 1, "track_changes": 1,
"track_seen": 1, "track_seen": 1
"track_views": 0
} }

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

@@ -1,542 +1,206 @@
{ {
"allow_copy": 0, "actions": [],
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 1, "allow_rename": 1,
"autoname": "field:healthcare_service_unit_name", "autoname": "field:healthcare_service_unit_name",
"beta": 1, "beta": 1,
"creation": "2016-09-21 13:48:14.731437", "creation": "2016-09-21 13:48:14.731437",
"custom": 0,
"description": "Healthcare Service Unit", "description": "Healthcare Service Unit",
"docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
"document_type": "Setup", "document_type": "Setup",
"editable_grid": 1, "editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"healthcare_service_unit_name",
"parent_healthcare_service_unit",
"is_group",
"service_unit_type",
"allow_appointments",
"overlap_appointments",
"inpatient_occupancy",
"occupancy_status",
"warehouse",
"company",
"lft",
"rgt",
"old_parent"
],
"fields": [ "fields": [
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "healthcare_service_unit_name", "fieldname": "healthcare_service_unit_name",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 1, "in_global_search": 1,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Service Unit", "label": "Service Unit",
"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, "reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 1 "unique": 1
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 1, "bold": 1,
"collapsible": 0,
"columns": 0,
"fieldname": "parent_healthcare_service_unit", "fieldname": "parent_healthcare_service_unit",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Parent Service Unit", "label": "Parent Service Unit",
"length": 0, "options": "Healthcare Service Unit"
"no_copy": 0,
"options": "Healthcare Service Unit",
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 1, "bold": 1,
"collapsible": 0,
"columns": 0,
"default": "0", "default": "0",
"depends_on": "eval:doc.inpatient_occupancy != 1 && doc.allow_appointments != 1", "depends_on": "eval:doc.inpatient_occupancy != 1 && doc.allow_appointments != 1",
"fieldname": "is_group", "fieldname": "is_group",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0, "label": "Is Group"
"label": "Is Group",
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 1, "bold": 1,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.is_group != 1", "depends_on": "eval:doc.is_group != 1",
"fieldname": "service_unit_type", "fieldname": "service_unit_type",
"fieldtype": "Link", "fieldtype": "Link",
"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": "Service Unit Type", "label": "Service Unit Type",
"length": 0, "options": "Healthcare Service Unit Type"
"no_copy": 0,
"options": "Healthcare Service Unit Type",
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 1, "bold": 1,
"collapsible": 0,
"columns": 0,
"default": "0", "default": "0",
"depends_on": "eval:doc.is_group != 1 && doc.inpatient_occupancy != 1", "depends_on": "eval:doc.is_group != 1 && doc.inpatient_occupancy != 1",
"fetch_from": "service_unit_type.allow_appointments", "fetch_from": "service_unit_type.allow_appointments",
"fieldname": "allow_appointments", "fieldname": "allow_appointments",
"fieldtype": "Check", "fieldtype": "Check",
"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": "Allow Appointments", "label": "Allow Appointments",
"length": 0,
"no_copy": 1, "no_copy": 1,
"permlevel": 0, "read_only": 1
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "0", "default": "0",
"depends_on": "eval:doc.is_group != 1 && doc.allow_appointments == 1 && doc.inpatient_occupany != 1", "depends_on": "eval:doc.is_group != 1 && doc.allow_appointments == 1 && doc.inpatient_occupany != 1",
"fetch_from": "service_unit_type.overlap_appointments", "fetch_from": "service_unit_type.overlap_appointments",
"fieldname": "overlap_appointments", "fieldname": "overlap_appointments",
"fieldtype": "Check", "fieldtype": "Check",
"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": "Allow Overlap", "label": "Allow Overlap",
"length": 0,
"no_copy": 1, "no_copy": 1,
"permlevel": 0, "read_only": 1
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 1, "bold": 1,
"collapsible": 0,
"columns": 0,
"default": "0", "default": "0",
"depends_on": "eval:doc.allow_appointments != 1 && doc.is_group != 1", "depends_on": "eval:doc.allow_appointments != 1 && doc.is_group != 1",
"fetch_from": "service_unit_type.inpatient_occupancy", "fetch_from": "service_unit_type.inpatient_occupancy",
"fieldname": "inpatient_occupancy", "fieldname": "inpatient_occupancy",
"fieldtype": "Check", "fieldtype": "Check",
"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": "Inpatient Occupancy", "label": "Inpatient Occupancy",
"length": 0,
"no_copy": 1, "no_copy": 1,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1, "read_only": 1,
"remember_last_selected_value": 0, "search_index": 1
"report_hide": 0,
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "",
"depends_on": "eval:doc.inpatient_occupancy == 1", "depends_on": "eval:doc.inpatient_occupancy == 1",
"fieldname": "occupancy_status", "fieldname": "occupancy_status",
"fieldtype": "Select", "fieldtype": "Select",
"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": "Occupancy Status", "label": "Occupancy Status",
"length": 0,
"no_copy": 1, "no_copy": 1,
"options": "Vacant\nOccupied", "options": "Vacant\nOccupied",
"permlevel": 0, "read_only": 1
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 1, "bold": 1,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.is_group != 1", "depends_on": "eval:doc.is_group != 1",
"fieldname": "warehouse", "fieldname": "warehouse",
"fieldtype": "Link", "fieldtype": "Link",
"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": "Warehouse", "label": "Warehouse",
"length": 0,
"no_copy": 1, "no_copy": 1,
"options": "Warehouse", "options": "Warehouse"
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "company", "fieldname": "company",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 1, "in_standard_filter": 1,
"label": "Company", "label": "Company",
"length": 0,
"no_copy": 0,
"options": "Company", "options": "Company",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 1, "remember_last_selected_value": 1,
"report_hide": 0,
"reqd": 1, "reqd": 1,
"search_index": 1, "search_index": 1
"set_only_once": 0,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "lft", "fieldname": "lft",
"fieldtype": "Int", "fieldtype": "Int",
"hidden": 1, "hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "lft", "label": "lft",
"length": 0,
"no_copy": 1, "no_copy": 1,
"permlevel": 0,
"precision": "",
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0, "search_index": 1
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "rgt", "fieldname": "rgt",
"fieldtype": "Int", "fieldtype": "Int",
"hidden": 1, "hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "rgt", "label": "rgt",
"length": 0,
"no_copy": 1, "no_copy": 1,
"permlevel": 0,
"precision": "",
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0, "search_index": 1
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "old_parent", "fieldname": "old_parent",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 1, "hidden": 1,
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Old Parent", "label": "Old Parent",
"length": 0,
"no_copy": 1, "no_copy": 1,
"options": "Healthcare Service Unit", "options": "Healthcare Service Unit",
"permlevel": 0,
"precision": "",
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0, "report_hide": 1
"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, "is_tree": 1,
"hide_heading": 0, "links": [],
"hide_toolbar": 0, "modified": "2020-03-18 18:26:06.360941",
"idx": 0,
"image_view": 0,
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-10-04 21:09:52.261882",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Healthcare", "module": "Healthcare",
"name": "Healthcare Service Unit", "name": "Healthcare Service Unit",
"name_case": "", "nsm_parent_field": "parent_healthcare_service_unit",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {
"amend": 0,
"cancel": 0,
"create": 0,
"delete": 0,
"email": 1, "email": 1,
"export": 1, "export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "Nursing User", "role": "Nursing User",
"set_user_permissions": 0, "share": 1
"share": 1,
"submit": 0,
"write": 0
}, },
{ {
"amend": 0,
"cancel": 0,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
"email": 1, "email": 1,
"export": 1, "export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "Healthcare Administrator", "role": "Healthcare Administrator",
"set_user_permissions": 0,
"share": 1, "share": 1,
"submit": 0,
"write": 1 "write": 1
}, },
{ {
"amend": 0,
"cancel": 0,
"create": 1, "create": 1,
"delete": 0,
"email": 1, "email": 1,
"export": 1, "export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "Physician", "role": "Physician",
"set_user_permissions": 0,
"share": 1, "share": 1,
"submit": 0,
"write": 1 "write": 1
} }
], ],
"quick_entry": 1, "quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"restrict_to_domain": "Healthcare", "restrict_to_domain": "Healthcare",
"search_fields": "healthcare_service_unit_name", "search_fields": "healthcare_service_unit_name",
"show_name_in_global_search": 0,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC", "sort_order": "DESC",
"title_field": "healthcare_service_unit_name", "title_field": "healthcare_service_unit_name",
"track_changes": 1, "track_changes": 1
"track_seen": 0,
"track_views": 0
} }

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"))
@@ -386,5 +392,5 @@ def get_procedure_prescribed(patient):
return frappe.db.sql("""select pp.name, pp.procedure, pp.parent, ct.practitioner, return frappe.db.sql("""select pp.name, pp.procedure, pp.parent, ct.practitioner,
ct.encounter_date, pp.practitioner, pp.date, pp.department ct.encounter_date, pp.practitioner, pp.date, pp.department
from `tabPatient Encounter` ct, `tabProcedure Prescription` pp from `tabPatient Encounter` ct, `tabProcedure Prescription` pp
where ct.patient='{0}' and pp.parent=ct.name and pp.appointment_booked=0 where ct.patient=%(patient)s and pp.parent=ct.name and pp.appointment_booked=0
order by ct.creation desc""".format(patient)) order by ct.creation desc""", {"patient": patient})

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",
"custom": 0,
"docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
"document_type": "",
"editable_grid": 1, "editable_grid": 1,
"engine": "InnoDB", "engine": "InnoDB",
"field_order": [
"disabled",
"schedule_details_section",
"schedule_name",
"time_slots"
],
"fields": [ "fields": [
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "schedule_name", "fieldname": "schedule_name",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 1, "ignore_xss_filter": 1,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Schedule Name", "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, "reqd": 1,
"search_index": 0, "unique": 1
"set_only_once": 0,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "time_slots", "fieldname": "time_slots",
"fieldtype": "Table", "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", "label": "Time Slots",
"length": 0, "options": "Healthcare Schedule Time Slot"
"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,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "disabled", "fieldname": "disabled",
"fieldtype": "Check", "fieldtype": "Check",
"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": "Disabled", "label": "Disabled",
"length": 0, "print_hide": 1
"no_copy": 0, },
"permlevel": 0, {
"precision": "", "fieldname": "schedule_details_section",
"print_hide": 1, "fieldtype": "Section Break",
"print_hide_if_no_value": 0, "label": "Schedule Details"
"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,
"idx": 0,
"image_view": 0,
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-06-29 14:55:34.795995",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Healthcare", "module": "Healthcare",
"name": "Practitioner Schedule", "name": "Practitioner Schedule",
"name_case": "",
"owner": "rmehta@gmail.com", "owner": "rmehta@gmail.com",
"permissions": [ "permissions": [
{ {
"amend": 0,
"cancel": 0,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
"email": 1, "email": 1,
"export": 1, "export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "Healthcare Administrator", "role": "Healthcare Administrator",
"set_user_permissions": 0,
"share": 1, "share": 1,
"submit": 0,
"write": 1 "write": 1
} }
], ],
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"restrict_to_domain": "Healthcare", "restrict_to_domain": "Healthcare",
"show_name_in_global_search": 1, "show_name_in_global_search": 1,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC", "sort_order": "DESC",
"track_changes": 1, "track_changes": 1
"track_seen": 0
} }

View File

@@ -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

@@ -39,19 +39,21 @@ class AdditionalSalary(Document):
return amount_per_day * no_of_days return amount_per_day * no_of_days
@frappe.whitelist() @frappe.whitelist()
def get_additional_salary_component(employee, start_date, end_date): def get_additional_salary_component(employee, start_date, end_date, component_type):
additional_components = frappe.db.sql(""" additional_components = frappe.db.sql("""
select salary_component, sum(amount) as amount, overwrite_salary_structure_amount, deduct_full_tax_on_selected_payroll_date select salary_component, sum(amount) as amount, overwrite_salary_structure_amount, deduct_full_tax_on_selected_payroll_date
from `tabAdditional Salary` from `tabAdditional Salary`
where employee=%(employee)s where employee=%(employee)s
and docstatus = 1 and docstatus = 1
and payroll_date between %(from_date)s and %(to_date)s and payroll_date between %(from_date)s and %(to_date)s
and type = %(component_type)s
group by salary_component, overwrite_salary_structure_amount group by salary_component, overwrite_salary_structure_amount
order by salary_component, overwrite_salary_structure_amount order by salary_component, overwrite_salary_structure_amount
""", { """, {
'employee': employee, 'employee': employee,
'from_date': start_date, 'from_date': start_date,
'to_date': end_date 'to_date': end_date,
'component_type': "Earning" if component_type == "earnings" else "Deduction"
}, as_dict=1) }, as_dict=1)
additional_components_list = [] additional_components_list = []

View File

@@ -1,569 +1,177 @@
{ {
"allow_copy": 0, "actions": [],
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 1, "allow_rename": 1,
"autoname": "",
"beta": 0,
"creation": "2013-02-05 11:48:26", "creation": "2013-02-05 11:48:26",
"custom": 0,
"docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
"document_type": "Setup", "document_type": "Setup",
"editable_grid": 0, "engine": "InnoDB",
"field_order": [
"department_name",
"parent_department",
"company",
"is_group",
"disabled",
"section_break_4",
"leave_block_list",
"leave_section",
"leave_approvers",
"expense_section",
"expense_approvers",
"lft",
"rgt",
"old_parent"
],
"fields": [ "fields": [
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "department_name", "fieldname": "department_name",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Department", "label": "Department",
"length": 0,
"no_copy": 0,
"oldfieldname": "department_name", "oldfieldname": "department_name",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"permlevel": 0, "reqd": 1
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "parent_department", "fieldname": "parent_department",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Parent Department", "label": "Parent Department",
"length": 0, "options": "Department"
"no_copy": 0,
"options": "Department",
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "company", "fieldname": "company",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 1, "in_standard_filter": 1,
"label": "Company", "label": "Company",
"length": 0,
"no_copy": 0,
"options": "Company", "options": "Company",
"permlevel": 0, "reqd": 1
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 1, "bold": 1,
"collapsible": 0, "default": "0",
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "is_group", "fieldname": "is_group",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0, "label": "Is Group"
"label": "Is Group",
"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, "default": "0",
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "disabled", "fieldname": "disabled",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "label": "Disabled"
"ignore_user_permissions": 0,
"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": 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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "section_break_4", "fieldname": "section_break_4",
"fieldtype": "Section Break", "fieldtype": "Section 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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "Days for which Holidays are blocked for this department.", "description": "Days for which Holidays are blocked for this department.",
"fetch_if_empty": 0,
"fieldname": "leave_block_list", "fieldname": "leave_block_list",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Leave Block List", "label": "Leave Block List",
"length": 0, "options": "Leave Block List"
"no_copy": 0,
"options": "Leave Block List",
"permlevel": 0,
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "leave_section", "fieldname": "leave_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "label": "Leave Approvers"
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Leave Approvers",
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "The first Leave Approver in the list will be set as the default Leave Approver.", "description": "The first Leave Approver in the list will be set as the default Leave Approver.",
"fetch_if_empty": 0,
"fieldname": "leave_approvers", "fieldname": "leave_approvers",
"fieldtype": "Table", "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": "Leave Approver", "label": "Leave Approver",
"length": 0, "options": "Department Approver"
"no_copy": 0,
"options": "Department Approver",
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "expense_section", "fieldname": "expense_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "label": "Expense Approvers"
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Expense Approvers",
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "The first Expense Approver in the list will be set as the default Expense Approver.", "description": "The first Expense Approver in the list will be set as the default Expense Approver.",
"fetch_if_empty": 0,
"fieldname": "expense_approvers", "fieldname": "expense_approvers",
"fieldtype": "Table", "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": "Expense Approver", "label": "Expense Approver",
"length": 0, "options": "Department Approver"
"no_copy": 0,
"options": "Department Approver",
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "lft", "fieldname": "lft",
"fieldtype": "Int", "fieldtype": "Int",
"hidden": 1, "hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "lft", "label": "lft",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0, "read_only": 1
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "rgt", "fieldname": "rgt",
"fieldtype": "Int", "fieldtype": "Int",
"hidden": 1, "hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "rgt", "label": "rgt",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0, "read_only": 1
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "old_parent", "fieldname": "old_parent",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 1, "hidden": 1,
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Old Parent", "label": "Old Parent",
"length": 0, "print_hide": 1
"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": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
} }
], ],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "fa fa-sitemap", "icon": "fa fa-sitemap",
"idx": 1, "idx": 1,
"image_view": 0, "is_tree": 1,
"in_create": 0, "links": [],
"is_submittable": 0, "modified": "2020-03-18 18:26:05.966022",
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2019-06-25 18:43:05.550387",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Department", "name": "Department",
"nsm_parent_field": "parent_department",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {
"amend": 0,
"cancel": 0,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
"email": 1, "email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "HR User", "role": "HR User",
"set_user_permissions": 0,
"share": 1, "share": 1,
"submit": 0,
"write": 1 "write": 1
}, },
{ {
"amend": 0,
"cancel": 0,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
"email": 1, "email": 1,
"export": 1, "export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "Academics User", "role": "Academics User",
"set_user_permissions": 0,
"share": 1, "share": 1,
"submit": 0,
"write": 1 "write": 1
}, },
{ {
"amend": 0,
"cancel": 0,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
"email": 1, "email": 1,
"export": 1, "export": 1,
"if_owner": 0,
"import": 1, "import": 1,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "HR Manager", "role": "HR Manager",
"set_user_permissions": 1, "set_user_permissions": 1,
"share": 1, "share": 1,
"submit": 0,
"write": 1 "write": 1
} }
], ],
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 1, "show_name_in_global_search": 1,
"sort_order": "ASC", "sort_field": "modified",
"track_changes": 0, "sort_order": "ASC"
"track_seen": 0,
"track_views": 0
} }

View File

@@ -48,12 +48,17 @@ def get_abbreviated_name(name, company):
@frappe.whitelist() @frappe.whitelist()
def get_children(doctype, parent=None, company=None, is_root=False): def get_children(doctype, parent=None, company=None, is_root=False):
condition = '' condition = ''
var_dict = {
"name": get_root_of("Department"),
"parent": parent,
"company": company,
}
if company == parent: if company == parent:
condition = "name='{0}'".format(get_root_of("Department")) condition = "name=%(name)s"
elif company: elif company:
condition = "parent_department='{0}' and company='{1}'".format(parent, company) condition = "parent_department=%(parent)s and company=%(company)s"
else: else:
condition = "parent_department = '{0}'".format(parent) condition = "parent_department = %(parent)s"
return frappe.db.sql(""" return frappe.db.sql("""
select select
@@ -62,7 +67,7 @@ def get_children(doctype, parent=None, company=None, is_root=False):
from `tab{doctype}` from `tab{doctype}`
where where
{condition} {condition}
order by name""".format(doctype=doctype, condition=condition), as_dict=1) order by name""".format(doctype=doctype, condition=condition), var_dict, as_dict=1)
@frappe.whitelist() @frappe.whitelist()
def add_node(): def add_node():

View File

@@ -190,6 +190,7 @@ def get_benefit_component_amount(employee, start_date, end_date, salary_componen
component_max_benefit, depends_on_payment_days = frappe.db.get_value("Salary Component", component_max_benefit, depends_on_payment_days = frappe.db.get_value("Salary Component",
salary_component, ["max_benefit_amount", "depends_on_payment_days"]) salary_component, ["max_benefit_amount", "depends_on_payment_days"])
benefit_amount = 0
if benefit_application: if benefit_application:
benefit_amount = frappe.db.get_value("Employee Benefit Application Detail", benefit_amount = frappe.db.get_value("Employee Benefit Application Detail",
{"parent": benefit_application[0][0], "earning_component": salary_component}, "amount") {"parent": benefit_application[0][0], "earning_component": salary_component}, "amount")

View File

@@ -70,7 +70,7 @@
"label": "Amount", "label": "Amount",
"oldfieldname": "tax_amount", "oldfieldname": "tax_amount",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"options": "currency" "options": "Company:company:default_currency"
}, },
{ {
"columns": 2, "columns": 2,
@@ -80,7 +80,7 @@
"label": "Total", "label": "Total",
"oldfieldname": "total", "oldfieldname": "total",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"options": "currency", "options": "Company:company:default_currency",
"read_only": 1 "read_only": 1
}, },
{ {

View File

@@ -1,332 +1,336 @@
{ {
"allow_import": 1, "actions": [],
"autoname": "naming_series:", "allow_import": 1,
"creation": "2013-02-20 11:18:11", "autoname": "naming_series:",
"description": "Apply / Approve Leaves", "creation": "2013-02-20 11:18:11",
"doctype": "DocType", "description": "Apply / Approve Leaves",
"document_type": "Document", "doctype": "DocType",
"engine": "InnoDB", "document_type": "Document",
"field_order": [ "engine": "InnoDB",
"naming_series", "field_order": [
"employee", "naming_series",
"employee_name", "employee",
"column_break_4", "employee_name",
"leave_type", "column_break_4",
"department", "leave_type",
"leave_balance", "department",
"section_break_5", "leave_balance",
"from_date", "section_break_5",
"to_date", "from_date",
"half_day", "to_date",
"half_day_date", "half_day",
"total_leave_days", "half_day_date",
"column_break1", "total_leave_days",
"description", "column_break1",
"section_break_7", "description",
"leave_approver", "section_break_7",
"leave_approver_name", "leave_approver",
"column_break_18", "leave_approver_name",
"status", "column_break_18",
"salary_slip", "status",
"sb10", "salary_slip",
"posting_date", "sb10",
"follow_via_email", "posting_date",
"color", "follow_via_email",
"column_break_17", "color",
"company", "column_break_17",
"letter_head", "company",
"amended_from" "letter_head",
], "amended_from"
"fields": [ ],
{ "fields": [
"fieldname": "naming_series", {
"fieldtype": "Select", "fieldname": "naming_series",
"label": "Series", "fieldtype": "Select",
"no_copy": 1, "label": "Series",
"options": "HR-LAP-.YYYY.-", "no_copy": 1,
"print_hide": 1, "options": "HR-LAP-.YYYY.-",
"reqd": 1, "print_hide": 1,
"set_only_once": 1 "reqd": 1,
}, "set_only_once": 1
{ },
"fieldname": "employee", {
"fieldtype": "Link", "fieldname": "employee",
"in_global_search": 1, "fieldtype": "Link",
"in_standard_filter": 1, "in_global_search": 1,
"label": "Employee", "in_standard_filter": 1,
"options": "Employee", "label": "Employee",
"reqd": 1, "options": "Employee",
"search_index": 1 "reqd": 1,
}, "search_index": 1
{ },
"fieldname": "employee_name", {
"fieldtype": "Data", "fieldname": "employee_name",
"in_global_search": 1, "fieldtype": "Data",
"label": "Employee Name", "in_global_search": 1,
"read_only": 1 "label": "Employee Name",
}, "read_only": 1
{ },
"fieldname": "column_break_4", {
"fieldtype": "Column Break" "fieldname": "column_break_4",
}, "fieldtype": "Column Break"
{ },
"fieldname": "leave_type", {
"fieldtype": "Link", "fieldname": "leave_type",
"ignore_user_permissions": 1, "fieldtype": "Link",
"in_standard_filter": 1, "ignore_user_permissions": 1,
"label": "Leave Type", "in_standard_filter": 1,
"options": "Leave Type", "label": "Leave Type",
"reqd": 1, "options": "Leave Type",
"search_index": 1 "reqd": 1,
}, "search_index": 1
{ },
"fetch_from": "employee.department", {
"fieldname": "department", "fetch_from": "employee.department",
"fieldtype": "Link", "fieldname": "department",
"label": "Department", "fieldtype": "Link",
"options": "Department", "label": "Department",
"read_only": 1 "options": "Department",
}, "read_only": 1
{ },
"fieldname": "leave_balance", {
"fieldtype": "Float", "fieldname": "leave_balance",
"label": "Leave Balance Before Application", "fieldtype": "Float",
"no_copy": 1, "label": "Leave Balance Before Application",
"read_only": 1 "no_copy": 1,
}, "read_only": 1
{ },
"fieldname": "section_break_5", {
"fieldtype": "Section Break" "fieldname": "section_break_5",
}, "fieldtype": "Section Break"
{ },
"fieldname": "from_date", {
"fieldtype": "Date", "fieldname": "from_date",
"in_list_view": 1, "fieldtype": "Date",
"label": "From Date", "in_list_view": 1,
"reqd": 1, "label": "From Date",
"search_index": 1 "reqd": 1,
}, "search_index": 1
{ },
"fieldname": "to_date", {
"fieldtype": "Date", "fieldname": "to_date",
"label": "To Date", "fieldtype": "Date",
"reqd": 1, "label": "To Date",
"search_index": 1 "reqd": 1,
}, "search_index": 1
{ },
"default": "0", {
"fieldname": "half_day", "default": "0",
"fieldtype": "Check", "fieldname": "half_day",
"label": "Half Day" "fieldtype": "Check",
}, "label": "Half Day"
{ },
"depends_on": "eval:doc.half_day && (doc.from_date != doc.to_date)", {
"fieldname": "half_day_date", "depends_on": "eval:doc.half_day && (doc.from_date != doc.to_date)",
"fieldtype": "Date", "fieldname": "half_day_date",
"label": "Half Day Date" "fieldtype": "Date",
}, "label": "Half Day Date"
{ },
"fieldname": "total_leave_days", {
"fieldtype": "Float", "fieldname": "total_leave_days",
"in_list_view": 1, "fieldtype": "Float",
"label": "Total Leave Days", "in_list_view": 1,
"no_copy": 1, "label": "Total Leave Days",
"precision": "1", "no_copy": 1,
"read_only": 1 "precision": "1",
}, "read_only": 1
{ },
"fieldname": "column_break1", {
"fieldtype": "Column Break", "fieldname": "column_break1",
"print_width": "50%", "fieldtype": "Column Break",
"width": "50%" "print_width": "50%",
}, "width": "50%"
{ },
"fieldname": "description", {
"fieldtype": "Small Text", "fieldname": "description",
"label": "Reason" "fieldtype": "Small Text",
}, "label": "Reason"
{ },
"fieldname": "section_break_7", {
"fieldtype": "Section Break" "fieldname": "section_break_7",
}, "fieldtype": "Section Break"
{ },
"fieldname": "leave_approver", {
"fieldtype": "Link", "fieldname": "leave_approver",
"label": "Leave Approver", "fieldtype": "Link",
"options": "User" "label": "Leave Approver",
}, "options": "User"
{ },
"fieldname": "leave_approver_name", {
"fieldtype": "Data", "fieldname": "leave_approver_name",
"label": "Leave Approver Name", "fieldtype": "Data",
"read_only": 1 "label": "Leave Approver Name",
}, "read_only": 1
{ },
"fieldname": "column_break_18", {
"fieldtype": "Column Break" "fieldname": "column_break_18",
}, "fieldtype": "Column Break"
{ },
"default": "Open", {
"fieldname": "status", "default": "Open",
"fieldtype": "Select", "fieldname": "status",
"in_standard_filter": 1, "fieldtype": "Select",
"label": "Status", "in_standard_filter": 1,
"no_copy": 1, "label": "Status",
"options": "Open\nApproved\nRejected\nCancelled" "no_copy": 1,
}, "options": "Open\nApproved\nRejected\nCancelled",
{ "permlevel": 1
"fieldname": "sb10", },
"fieldtype": "Section Break" {
}, "fieldname": "sb10",
{ "fieldtype": "Section Break"
"default": "Today", },
"fieldname": "posting_date", {
"fieldtype": "Date", "default": "Today",
"label": "Posting Date", "fieldname": "posting_date",
"no_copy": 1, "fieldtype": "Date",
"reqd": 1 "label": "Posting Date",
}, "no_copy": 1,
{ "reqd": 1
"fieldname": "company", },
"fieldtype": "Link", {
"label": "Company", "fieldname": "company",
"options": "Company", "fieldtype": "Link",
"remember_last_selected_value": 1, "label": "Company",
"reqd": 1 "options": "Company",
}, "read_only": 1,
{ "remember_last_selected_value": 1,
"allow_on_submit": 1, "reqd": 1
"default": "1", },
"fieldname": "follow_via_email", {
"fieldtype": "Check", "allow_on_submit": 1,
"label": "Follow via Email", "default": "1",
"print_hide": 1 "fieldname": "follow_via_email",
}, "fieldtype": "Check",
{ "label": "Follow via Email",
"fieldname": "column_break_17", "print_hide": 1
"fieldtype": "Column Break" },
}, {
{ "fieldname": "column_break_17",
"fieldname": "salary_slip", "fieldtype": "Column Break"
"fieldtype": "Link", },
"label": "Salary Slip", {
"options": "Salary Slip", "fieldname": "salary_slip",
"print_hide": 1 "fieldtype": "Link",
}, "label": "Salary Slip",
{ "options": "Salary Slip",
"allow_on_submit": 1, "print_hide": 1
"fieldname": "letter_head", },
"fieldtype": "Link", {
"ignore_user_permissions": 1, "allow_on_submit": 1,
"label": "Letter Head", "fieldname": "letter_head",
"options": "Letter Head", "fieldtype": "Link",
"print_hide": 1 "ignore_user_permissions": 1,
}, "label": "Letter Head",
{ "options": "Letter Head",
"allow_on_submit": 1, "print_hide": 1
"fieldname": "color", },
"fieldtype": "Color", {
"label": "Color", "allow_on_submit": 1,
"print_hide": 1 "fieldname": "color",
}, "fieldtype": "Color",
{ "label": "Color",
"fieldname": "amended_from", "print_hide": 1
"fieldtype": "Link", },
"ignore_user_permissions": 1, {
"label": "Amended From", "fieldname": "amended_from",
"no_copy": 1, "fieldtype": "Link",
"options": "Leave Application", "ignore_user_permissions": 1,
"print_hide": 1, "label": "Amended From",
"read_only": 1 "no_copy": 1,
} "options": "Leave Application",
], "print_hide": 1,
"icon": "fa fa-calendar", "read_only": 1
"idx": 1,
"is_submittable": 1,
"max_attachments": 3,
"modified": "2019-08-13 13:32:04.860848",
"modified_by": "Administrator",
"module": "HR",
"name": "Leave Application",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"email": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Employee",
"share": 1,
"write": 1
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "HR Manager",
"set_user_permissions": 1,
"share": 1,
"submit": 1,
"write": 1
},
{
"permlevel": 1,
"read": 1,
"role": "All"
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"delete": 1,
"email": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "HR User",
"set_user_permissions": 1,
"share": 1,
"submit": 1,
"write": 1
},
{
"amend": 1,
"cancel": 1,
"delete": 1,
"email": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Leave Approver",
"share": 1,
"submit": 1,
"write": 1
},
{
"permlevel": 1,
"read": 1,
"report": 1,
"role": "HR User",
"write": 1
},
{
"permlevel": 1,
"read": 1,
"report": 1,
"role": "Leave Approver",
"write": 1
}
],
"search_fields": "employee,employee_name,leave_type,from_date,to_date,total_leave_days",
"sort_field": "modified",
"sort_order": "DESC",
"timeline_field": "employee",
"title_field": "employee_name"
} }
],
"icon": "fa fa-calendar",
"idx": 1,
"is_submittable": 1,
"links": [],
"max_attachments": 3,
"modified": "2020-03-10 22:40:43.487721",
"modified_by": "Administrator",
"module": "HR",
"name": "Leave Application",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"email": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Employee",
"share": 1,
"write": 1
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "HR Manager",
"set_user_permissions": 1,
"share": 1,
"submit": 1,
"write": 1
},
{
"permlevel": 1,
"read": 1,
"role": "All"
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"delete": 1,
"email": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "HR User",
"set_user_permissions": 1,
"share": 1,
"submit": 1,
"write": 1
},
{
"amend": 1,
"cancel": 1,
"delete": 1,
"email": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Leave Approver",
"share": 1,
"submit": 1,
"write": 1
},
{
"permlevel": 1,
"read": 1,
"report": 1,
"role": "HR User",
"write": 1
},
{
"permlevel": 1,
"read": 1,
"report": 1,
"role": "Leave Approver",
"write": 1
}
],
"search_fields": "employee,employee_name,leave_type,from_date,to_date,total_leave_days",
"sort_field": "modified",
"sort_order": "DESC",
"timeline_field": "employee",
"title_field": "employee_name"
}

View File

@@ -366,7 +366,8 @@ class LeaveApplication(Document):
leaves=self.total_leave_days * -1, leaves=self.total_leave_days * -1,
from_date=self.from_date, from_date=self.from_date,
to_date=self.to_date, to_date=self.to_date,
is_lwp=lwp is_lwp=lwp,
holiday_list=get_holiday_list_for_employee(self.employee)
) )
create_leave_ledger_entry(self, args, submit) create_leave_ledger_entry(self, args, submit)
@@ -376,7 +377,9 @@ class LeaveApplication(Document):
from_date=self.from_date, from_date=self.from_date,
to_date=expiry_date, to_date=expiry_date,
leaves=(date_diff(expiry_date, self.from_date) + 1) * -1, leaves=(date_diff(expiry_date, self.from_date) + 1) * -1,
is_lwp=lwp is_lwp=lwp,
holiday_list=get_holiday_list_for_employee(self.employee),
) )
create_leave_ledger_entry(self, args, submit) create_leave_ledger_entry(self, args, submit)
@@ -402,7 +405,7 @@ def get_allocation_expiry(employee, leave_type, to_date, from_date):
return expiry[0]['to_date'] if expiry else None return expiry[0]['to_date'] if expiry else None
@frappe.whitelist() @frappe.whitelist()
def get_number_of_leave_days(employee, leave_type, from_date, to_date, half_day = None, half_day_date = None): def get_number_of_leave_days(employee, leave_type, from_date, to_date, half_day = None, half_day_date = None, holiday_list = None):
number_of_days = 0 number_of_days = 0
if cint(half_day) == 1: if cint(half_day) == 1:
if from_date == to_date: if from_date == to_date:
@@ -416,7 +419,7 @@ def get_number_of_leave_days(employee, leave_type, from_date, to_date, half_day
number_of_days = date_diff(to_date, from_date) + 1 number_of_days = date_diff(to_date, from_date) + 1
if not frappe.db.get_value("Leave Type", leave_type, "include_holiday"): if not frappe.db.get_value("Leave Type", leave_type, "include_holiday"):
number_of_days = flt(number_of_days) - flt(get_holidays(employee, from_date, to_date)) number_of_days = flt(number_of_days) - flt(get_holidays(employee, from_date, to_date, holiday_list=holiday_list))
return number_of_days return number_of_days
@frappe.whitelist() @frappe.whitelist()
@@ -567,7 +570,7 @@ def get_leaves_for_period(employee, leave_type, from_date, to_date):
{'name': leave_entry.transaction_name}, ['half_day_date']) {'name': leave_entry.transaction_name}, ['half_day_date'])
leave_days += get_number_of_leave_days(employee, leave_type, leave_days += get_number_of_leave_days(employee, leave_type,
leave_entry.from_date, leave_entry.to_date, half_day, half_day_date) * -1 leave_entry.from_date, leave_entry.to_date, half_day, half_day_date, holiday_list=leave_entry.holiday_list) * -1
return leave_days return leave_days
@@ -580,7 +583,7 @@ 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, 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
@@ -596,9 +599,10 @@ def get_leave_entries(employee, leave_type, from_date, to_date):
}, as_dict=1) }, as_dict=1)
@frappe.whitelist() @frappe.whitelist()
def get_holidays(employee, from_date, to_date): def get_holidays(employee, from_date, to_date, holiday_list = None):
'''get holidays between two dates for the given employee''' '''get holidays between two dates for the given employee'''
holiday_list = get_holiday_list_for_employee(employee) if not holiday_list:
holiday_list = get_holiday_list_for_employee(employee)
holidays = frappe.db.sql("""select count(distinct holiday_date) from `tabHoliday` h1, `tabHoliday List` h2 holidays = frappe.db.sql("""select count(distinct holiday_date) from `tabHoliday` h1, `tabHoliday List` h2
where h1.parent = h2.name and h1.holiday_date between %s and %s where h1.parent = h2.name and h1.holiday_date between %s and %s

View File

@@ -1,4 +1,5 @@
{ {
"actions": [],
"creation": "2019-05-09 15:47:39.760406", "creation": "2019-05-09 15:47:39.760406",
"doctype": "DocType", "doctype": "DocType",
"engine": "InnoDB", "engine": "InnoDB",
@@ -12,6 +13,7 @@
"column_break_7", "column_break_7",
"from_date", "from_date",
"to_date", "to_date",
"holiday_list",
"is_carry_forward", "is_carry_forward",
"is_expired", "is_expired",
"is_lwp", "is_lwp",
@@ -98,11 +100,18 @@
"fieldname": "is_lwp", "fieldname": "is_lwp",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Is Leave Without Pay" "label": "Is Leave Without Pay"
},
{
"fieldname": "holiday_list",
"fieldtype": "Link",
"label": "Holiday List",
"options": "Holiday List"
} }
], ],
"in_create": 1, "in_create": 1,
"is_submittable": 1, "is_submittable": 1,
"modified": "2019-08-20 14:40:04.130799", "links": [],
"modified": "2020-02-27 14:40:10.502605",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Leave Ledger Entry", "name": "Leave Ledger Entry",

View File

@@ -298,9 +298,11 @@ class SalarySlip(TransactionBase):
def calculate_net_pay(self): def calculate_net_pay(self):
if self.salary_structure: if self.salary_structure:
self.calculate_component_amounts() self.calculate_component_amounts("earnings")
self.gross_pay = self.get_component_totals("earnings") self.gross_pay = self.get_component_totals("earnings")
if self.salary_structure:
self.calculate_component_amounts("deductions")
self.total_deduction = self.get_component_totals("deductions") self.total_deduction = self.get_component_totals("deductions")
self.set_loan_repayment() self.set_loan_repayment()
@@ -308,25 +310,27 @@ class SalarySlip(TransactionBase):
self.net_pay = flt(self.gross_pay) - (flt(self.total_deduction) + flt(self.total_loan_repayment)) self.net_pay = flt(self.gross_pay) - (flt(self.total_deduction) + flt(self.total_loan_repayment))
self.rounded_total = rounded(self.net_pay) self.rounded_total = rounded(self.net_pay)
def calculate_component_amounts(self): def calculate_component_amounts(self, component_type):
if not getattr(self, '_salary_structure_doc', None): if not getattr(self, '_salary_structure_doc', None):
self._salary_structure_doc = frappe.get_doc('Salary Structure', self.salary_structure) self._salary_structure_doc = frappe.get_doc('Salary Structure', self.salary_structure)
payroll_period = get_payroll_period(self.start_date, self.end_date, self.company) payroll_period = get_payroll_period(self.start_date, self.end_date, self.company)
self.add_structure_components() self.add_structure_components(component_type)
self.add_employee_benefits(payroll_period) self.add_additional_salary_components(component_type)
self.add_additional_salary_components() if component_type == "earnings":
self.add_tax_components(payroll_period) self.add_employee_benefits(payroll_period)
self.set_component_amounts_based_on_payment_days() else:
self.add_tax_components(payroll_period)
def add_structure_components(self): self.set_component_amounts_based_on_payment_days(component_type)
def add_structure_components(self, component_type):
data = self.get_data_for_eval() data = self.get_data_for_eval()
for key in ('earnings', 'deductions'): for struct_row in self._salary_structure_doc.get(component_type):
for struct_row in self._salary_structure_doc.get(key): amount = self.eval_condition_and_formula(struct_row, data)
amount = self.eval_condition_and_formula(struct_row, data) if amount and struct_row.statistical_component == 0:
if amount and struct_row.statistical_component == 0: self.update_component_row(struct_row, amount, component_type)
self.update_component_row(struct_row, amount, key)
def get_data_for_eval(self): def get_data_for_eval(self):
'''Returns data for evaluating formula''' '''Returns data for evaluating formula'''
@@ -399,14 +403,15 @@ class SalarySlip(TransactionBase):
amount = last_benefit.amount amount = last_benefit.amount
self.update_component_row(frappe._dict(last_benefit.struct_row), amount, "earnings") self.update_component_row(frappe._dict(last_benefit.struct_row), amount, "earnings")
def add_additional_salary_components(self): def add_additional_salary_components(self, component_type):
additional_components = get_additional_salary_component(self.employee, self.start_date, self.end_date) additional_components = get_additional_salary_component(self.employee,
self.start_date, self.end_date, component_type)
if additional_components: if additional_components:
for additional_component in additional_components: for additional_component in additional_components:
amount = additional_component.amount amount = additional_component.amount
overwrite = additional_component.overwrite overwrite = additional_component.overwrite
key = "earnings" if additional_component.type == "Earning" else "deductions" self.update_component_row(frappe._dict(additional_component.struct_row), amount,
self.update_component_row(frappe._dict(additional_component.struct_row), amount, key, overwrite=overwrite) component_type, overwrite=overwrite)
def add_tax_components(self, payroll_period): def add_tax_components(self, payroll_period):
# Calculate variable_based_on_taxable_salary after all components updated in salary slip # Calculate variable_based_on_taxable_salary after all components updated in salary slip
@@ -735,7 +740,7 @@ class SalarySlip(TransactionBase):
total += d.amount total += d.amount
return total return total
def set_component_amounts_based_on_payment_days(self): def set_component_amounts_based_on_payment_days(self, component_type):
joining_date, relieving_date = frappe.get_cached_value("Employee", self.employee, joining_date, relieving_date = frappe.get_cached_value("Employee", self.employee,
["date_of_joining", "relieving_date"]) ["date_of_joining", "relieving_date"])
@@ -745,9 +750,8 @@ class SalarySlip(TransactionBase):
if not joining_date: if not joining_date:
frappe.throw(_("Please set the Date Of Joining for employee {0}").format(frappe.bold(self.employee_name))) frappe.throw(_("Please set the Date Of Joining for employee {0}").format(frappe.bold(self.employee_name)))
for component_type in ("earnings", "deductions"): for d in self.get(component_type):
for d in self.get(component_type): d.amount = self.get_amount_based_on_payment_days(d, joining_date, relieving_date)[0]
d.amount = self.get_amount_based_on_payment_days(d, joining_date, relieving_date)[0]
def set_loan_repayment(self): def set_loan_repayment(self):
self.set('loans', []) self.set('loans', [])

View File

@@ -25,7 +25,6 @@ class TestSalaryStructure(unittest.TestCase):
make_employee("test_employee@salary.com") make_employee("test_employee@salary.com")
make_employee("test_employee_2@salary.com") make_employee("test_employee_2@salary.com")
def make_holiday_list(self): def make_holiday_list(self):
if not frappe.db.get_value("Holiday List", "Salary Structure Test Holiday List"): if not frappe.db.get_value("Holiday List", "Salary Structure Test Holiday List"):
holiday_list = frappe.get_doc({ holiday_list = frappe.get_doc({
@@ -38,6 +37,29 @@ class TestSalaryStructure(unittest.TestCase):
holiday_list.get_weekly_off_dates() holiday_list.get_weekly_off_dates()
holiday_list.save() holiday_list.save()
def test_salary_structure_deduction_based_on_gross_pay(self):
emp = make_employee("test_employee_3@salary.com")
sal_struct = make_salary_structure("Salary Structure 2", "Monthly", dont_submit = True)
sal_struct.earnings = [sal_struct.earnings[0]]
sal_struct.earnings[0].amount_based_on_formula = 1
sal_struct.earnings[0].formula = "base"
sal_struct.deductions = [sal_struct.deductions[0]]
sal_struct.deductions[0].amount_based_on_formula = 1
sal_struct.deductions[0].condition = "gross_pay > 100"
sal_struct.deductions[0].formula = "gross_pay * 0.2"
sal_struct.submit()
assignment = create_salary_structure_assignment(emp, "Salary Structure 2")
ss = make_salary_slip(sal_struct.name, employee = emp)
self.assertEqual(assignment.base * 0.2, ss.deductions[0].amount)
def test_amount_totals(self): def test_amount_totals(self):
frappe.db.set_value("HR Settings", None, "include_holidays_in_total_working_days", 0) frappe.db.set_value("HR Settings", None, "include_holidays_in_total_working_days", 0)
sal_slip = frappe.get_value("Salary Slip", {"employee_name":"test_employee_2@salary.com"}) sal_slip = frappe.get_value("Salary Slip", {"employee_name":"test_employee_2@salary.com"})

View File

@@ -6,11 +6,14 @@ from __future__ import unicode_literals
import frappe import frappe
import unittest import unittest
from frappe.utils import nowdate,flt, cstr,random_string from frappe.utils import nowdate,flt, cstr,random_string
# test_records = frappe.get_test_records('Vehicle Log')
class TestVehicleLog(unittest.TestCase): class TestVehicleLog(unittest.TestCase):
def test_make_vehicle_log_and_syncing_of_odometer_value(self): def test_make_vehicle_log_and_syncing_of_odometer_value(self):
employee_id=frappe.db.sql("""select name from `tabEmployee` order by modified desc limit 1""")[0][0] employee_id = frappe.db.sql("""select name from `tabEmployee` where status='Active' order by modified desc limit 1""")
employee_id = employee_id[0][0] if employee_id else None
license_plate = get_vehicle(employee_id) license_plate = get_vehicle(employee_id)
vehicle_log = frappe.get_doc({ vehicle_log = frappe.get_doc({
"doctype": "Vehicle Log", "doctype": "Vehicle Log",
"license_plate": cstr(license_plate), "license_plate": cstr(license_plate),

View File

@@ -3,11 +3,6 @@
frappe.ui.form.on("Vehicle Log", { frappe.ui.form.on("Vehicle Log", {
refresh: function(frm) { refresh: function(frm) {
if(frm.doc.license_plate && frm.doc.__islocal){
frm.events.set_vehicle_details(frm);
}
if(frm.doc.docstatus == 1) { if(frm.doc.docstatus == 1) {
frm.add_custom_button(__('Expense Claim'), function() { frm.add_custom_button(__('Expense Claim'), function() {
frm.events.expense_claim(frm); frm.events.expense_claim(frm);
@@ -16,27 +11,6 @@ frappe.ui.form.on("Vehicle Log", {
} }
}, },
license_plate: function(frm) {
if(frm.doc.license_plate){
frm.events.set_vehicle_details(frm);
}
},
set_vehicle_details: function(frm) {
frappe.call({
method: "erpnext.hr.doctype.vehicle_log.vehicle_log.get_make_model",
args: {
license_plate: frm.doc.license_plate
},
callback: function(r) {
frappe.model.set_value(cur_frm.doctype, cur_frm.docname, "make", r.message[0]);
frappe.model.set_value(cur_frm.doctype, cur_frm.docname, "model", r.message[1]);
frappe.model.set_value(cur_frm.doctype, cur_frm.docname, "last_odometer", r.message[2]);
frappe.model.set_value(cur_frm.doctype, cur_frm.docname, "employee", r.message[3]);
}
});
},
expense_claim: function(frm){ expense_claim: function(frm){
frappe.call({ frappe.call({
method: "erpnext.hr.doctype.vehicle_log.vehicle_log.make_expense_claim", method: "erpnext.hr.doctype.vehicle_log.vehicle_log.make_expense_claim",

View File

@@ -1,5 +1,4 @@
{ {
"actions": [],
"autoname": "naming_series:", "autoname": "naming_series:",
"creation": "2016-09-03 14:14:51.788550", "creation": "2016-09-03 14:14:51.788550",
"doctype": "DocType", "doctype": "DocType",
@@ -56,6 +55,8 @@
"reqd": 1 "reqd": 1
}, },
{ {
"fetch_from": "license_plate.employee",
"fetch_if_empty": 1,
"fieldname": "employee", "fieldname": "employee",
"fieldtype": "Link", "fieldtype": "Link",
"in_list_view": 1, "in_list_view": 1,
@@ -73,11 +74,13 @@
"fieldtype": "Column Break" "fieldtype": "Column Break"
}, },
{ {
"fetch_from": "license_plate.model",
"fieldname": "model", "fieldname": "model",
"fieldtype": "Read Only", "fieldtype": "Read Only",
"label": "Model" "label": "Model"
}, },
{ {
"fetch_from": "license_plate.make",
"fieldname": "make", "fieldname": "make",
"fieldtype": "Read Only", "fieldtype": "Read Only",
"label": "Make" "label": "Make"
@@ -152,6 +155,7 @@
"read_only": 1 "read_only": 1
}, },
{ {
"fetch_from": "license_plate.last_odometer",
"fieldname": "last_odometer", "fieldname": "last_odometer",
"fieldtype": "Int", "fieldtype": "Int",
"label": "last Odometer Value ", "label": "last Odometer Value ",
@@ -164,8 +168,7 @@
} }
], ],
"is_submittable": 1, "is_submittable": 1,
"links": [], "modified": "2020-03-18 16:45:45.060761",
"modified": "2020-01-28 12:43:34.419647",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Vehicle Log", "name": "Vehicle Log",

View File

@@ -12,18 +12,7 @@ from frappe.model.document import Document
class VehicleLog(Document): class VehicleLog(Document):
def validate(self): def validate(self):
if flt(self.odometer) < flt(self.last_odometer): if flt(self.odometer) < flt(self.last_odometer):
frappe.throw(_("Current Odometer reading entered should be greater than initial Vehicle Odometer {0}").format(self.last_odometer)) frappe.throw(_("Current Odometer Value should be greater than Last Odometer Value {0}").format(self.last_odometer))
for service_detail in self.service_detail:
if (service_detail.service_item or service_detail.type or service_detail.frequency or service_detail.expense_amount):
if not (service_detail.service_item and service_detail.type and service_detail.frequency and service_detail.expense_amount):
frappe.throw(_("Service Item,Type,frequency and expense amount are required"))
def before_insert(self):
model_details = get_make_model(self.license_plate)
self.make = model_details[0]
self.model = model_details[1]
self.last_odometer = model_details[2]
self.employee = model_details[3]
def on_submit(self): def on_submit(self):
frappe.db.set_value("Vehicle", self.license_plate, "last_odometer", self.odometer) frappe.db.set_value("Vehicle", self.license_plate, "last_odometer", self.odometer)
@@ -34,35 +23,26 @@ class VehicleLog(Document):
updated_odometer_value = int(frappe.db.get_value("Vehicle", self.license_plate, "last_odometer")) - distance_travelled updated_odometer_value = int(frappe.db.get_value("Vehicle", self.license_plate, "last_odometer")) - distance_travelled
frappe.db.set_value("Vehicle", self.license_plate, "last_odometer", updated_odometer_value) frappe.db.set_value("Vehicle", self.license_plate, "last_odometer", updated_odometer_value)
@frappe.whitelist()
def get_make_model(license_plate):
vehicle=frappe.get_doc("Vehicle",license_plate)
return (vehicle.make, vehicle.model, vehicle.last_odometer, vehicle.employee)
@frappe.whitelist() @frappe.whitelist()
def make_expense_claim(docname): def make_expense_claim(docname):
def check_exp_claim_exists(): expense_claim = frappe.db.exists("Expense Claim", {"vehicle_log": docname})
exp_claim = frappe.db.sql("""select name from `tabExpense Claim` where vehicle_log=%s""",vehicle_log.name) if expense_claim:
return exp_claim[0][0] if exp_claim else "" frappe.throw(_("Expense Claim {0} already exists for the Vehicle Log").format(expense_claim))
def calc_service_exp():
total_exp_amt=0
exp_claim = check_exp_claim_exists()
if exp_claim:
frappe.throw(_("Expense Claim {0} already exists for the Vehicle Log").format(exp_claim))
for serdetail in vehicle_log.service_detail:
total_exp_amt = total_exp_amt + serdetail.expense_amount
return total_exp_amt
vehicle_log = frappe.get_doc("Vehicle Log", docname) vehicle_log = frappe.get_doc("Vehicle Log", docname)
service_expense = sum([flt(d.expense_amount) for d in vehicle_log.service_detail])
claim_amount = service_expense + flt(vehicle_log.price)
if not claim_amount:
frappe.throw(_("No additional expenses has been added"))
exp_claim = frappe.new_doc("Expense Claim") exp_claim = frappe.new_doc("Expense Claim")
exp_claim.employee=vehicle_log.employee exp_claim.employee = vehicle_log.employee
exp_claim.vehicle_log=vehicle_log.name exp_claim.vehicle_log = vehicle_log.name
exp_claim.remark=_("Expense Claim for Vehicle Log {0}").format(vehicle_log.name) exp_claim.remark = _("Expense Claim for Vehicle Log {0}").format(vehicle_log.name)
fuel_price=vehicle_log.price exp_claim.append("expenses", {
total_claim_amt=calc_service_exp() + fuel_price "expense_date": vehicle_log.date,
exp_claim.append("expenses",{ "description": _("Vehicle Expenses"),
"expense_date":vehicle_log.date, "amount": claim_amount
"description":_("Vehicle Expenses"),
"amount":total_claim_amt
}) })
return exp_claim.as_dict() return exp_claim.as_dict()

View File

@@ -1,153 +1,57 @@
{ {
"allow_copy": 0,
"allow_import": 0,
"allow_rename": 0,
"beta": 0,
"creation": "2016-09-03 19:20:14.561962", "creation": "2016-09-03 19:20:14.561962",
"custom": 0,
"docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
"document_type": "Document", "document_type": "Document",
"editable_grid": 1, "editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"service_item",
"type",
"frequency",
"expense_amount"
],
"fields": [ "fields": [
{ {
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "service_item", "fieldname": "service_item",
"fieldtype": "Select", "fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Service Item", "label": "Service Item",
"length": 0,
"no_copy": 0,
"options": "\nBrake Oil\nBrake Pad\nClutch Plate\nEngine Oil\nOil Change\nWheels", "options": "\nBrake Oil\nBrake Pad\nClutch Plate\nEngine Oil\nOil Change\nWheels",
"permlevel": 0, "reqd": 1
"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,
"unique": 0
}, },
{ {
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "type", "fieldname": "type",
"fieldtype": "Select", "fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Type", "label": "Type",
"length": 0,
"no_copy": 0,
"options": "\nInspection\nService\nChange", "options": "\nInspection\nService\nChange",
"permlevel": 0, "reqd": 1
"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,
"unique": 0
}, },
{ {
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "frequency", "fieldname": "frequency",
"fieldtype": "Select", "fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Frequency", "label": "Frequency",
"length": 0,
"no_copy": 0,
"options": "\nMileage\nMonthly\nQuarterly\nHalf Yearly\nYearly", "options": "\nMileage\nMonthly\nQuarterly\nHalf Yearly\nYearly",
"permlevel": 0, "reqd": 1
"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,
"unique": 0
}, },
{ {
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "expense_amount", "fieldname": "expense_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Expense", "label": "Expense",
"length": 0, "reqd": 1
"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,
"unique": 0
} }
], ],
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1, "istable": 1,
"max_attachments": 0, "modified": "2020-03-18 16:49:46.645004",
"modified": "2017-01-09 11:10:29.476907",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Vehicle Service", "name": "Vehicle Service",
"name_case": "",
"owner": "Administrator", "owner": "Administrator",
"permissions": [], "permissions": [],
"quick_entry": 1, "quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC", "sort_order": "DESC",
"track_changes": 1, "track_changes": 1
"track_seen": 0
} }

View File

@@ -13,7 +13,7 @@ def execute(filters=None):
conditions, filters = get_conditions(filters) conditions, filters = get_conditions(filters)
columns = get_columns(filters) columns = get_columns(filters)
att_map = get_attendance_list(conditions, filters) att_map = get_attendance_list(conditions, filters)
emp_map = get_employee_details() emp_map = get_employee_details(filters)
holiday_list = [emp_map[d]["holiday_list"] for d in emp_map if emp_map[d]["holiday_list"]] holiday_list = [emp_map[d]["holiday_list"] for d in emp_map if emp_map[d]["holiday_list"]]
default_holiday_list = frappe.get_cached_value('Company', filters.get("company"), "default_holiday_list") default_holiday_list = frappe.get_cached_value('Company', filters.get("company"), "default_holiday_list")
@@ -131,10 +131,10 @@ def get_conditions(filters):
return conditions, filters return conditions, filters
def get_employee_details(): def get_employee_details(filters):
emp_map = frappe._dict() emp_map = frappe._dict()
for d in frappe.db.sql("""select name, employee_name, designation, department, branch, company, for d in frappe.db.sql("""select name, employee_name, designation, department, branch, company,
holiday_list from tabEmployee""", as_dict=1): holiday_list from tabEmployee where company = "%s" """ % (filters.get("company")), as_dict=1):
emp_map.setdefault(d.name, d) emp_map.setdefault(d.name, d)
return emp_map return emp_map

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

@@ -487,6 +487,14 @@ class BOM(WebsiteGenerator):
self.scrap_material_cost = total_sm_cost self.scrap_material_cost = total_sm_cost
self.base_scrap_material_cost = base_total_sm_cost self.base_scrap_material_cost = base_total_sm_cost
def update_new_bom(self, old_bom, new_bom, rate):
for d in self.get("items"):
if d.bom_no != old_bom: continue
d.bom_no = new_bom
d.rate = rate
d.amount = (d.stock_qty or d.qty) * rate
def update_exploded_items(self): def update_exploded_items(self):
""" Update Flat BOM, following will be correct data""" """ Update Flat BOM, following will be correct data"""
self.get_exploded_items() self.get_exploded_items()
@@ -815,6 +823,10 @@ def add_operations_cost(stock_entry, work_order=None, expense_account=None):
def get_bom_diff(bom1, bom2): def get_bom_diff(bom1, bom2):
from frappe.model import table_fields from frappe.model import table_fields
if bom1 == bom2:
frappe.throw(_("BOM 1 {0} and BOM 2 {1} should not be same")
.format(frappe.bold(bom1), frappe.bold(bom2)))
doc1 = frappe.get_doc('BOM', bom1) doc1 = frappe.get_doc('BOM', bom1)
doc2 = frappe.get_doc('BOM', bom2) doc2 = frappe.get_doc('BOM', bom2)

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

@@ -14,10 +14,13 @@ import click
class BOMUpdateTool(Document): class BOMUpdateTool(Document):
def replace_bom(self): def replace_bom(self):
self.validate_bom() self.validate_bom()
self.update_new_bom()
unit_cost = get_new_bom_unit_cost(self.new_bom)
self.update_new_bom(unit_cost)
frappe.cache().delete_key('bom_children') frappe.cache().delete_key('bom_children')
bom_list = self.get_parent_boms(self.new_bom) bom_list = self.get_parent_boms(self.new_bom)
updated_bom = []
with click.progressbar(bom_list) as bom_list: with click.progressbar(bom_list) as bom_list:
pass pass
for bom in bom_list: for bom in bom_list:
@@ -26,7 +29,9 @@ class BOMUpdateTool(Document):
# this is only used for versioning and we do not want # this is only used for versioning and we do not want
# to make separate db calls by using load_doc_before_save # to make separate db calls by using load_doc_before_save
# which proves to be expensive while doing bulk replace # which proves to be expensive while doing bulk replace
bom_obj._doc_before_save = bom_obj.as_dict() bom_obj._doc_before_save = bom_obj
bom_obj.update_new_bom(self.current_bom, self.new_bom, unit_cost)
bom_obj.update_exploded_items()
bom_obj.calculate_cost() bom_obj.calculate_cost()
bom_obj.update_parent_cost() bom_obj.update_parent_cost()
bom_obj.db_update() bom_obj.db_update()
@@ -43,14 +48,10 @@ class BOMUpdateTool(Document):
!= frappe.db.get_value("BOM", self.new_bom, "item"): != frappe.db.get_value("BOM", self.new_bom, "item"):
frappe.throw(_("The selected BOMs are not for the same item")) frappe.throw(_("The selected BOMs are not for the same item"))
def update_new_bom(self): def update_new_bom(self, unit_cost):
new_bom_unitcost = frappe.db.sql("""SELECT `total_cost`/`quantity`
FROM `tabBOM` WHERE name = %s""", self.new_bom)
new_bom_unitcost = flt(new_bom_unitcost[0][0]) if new_bom_unitcost else 0
frappe.db.sql("""update `tabBOM Item` set bom_no=%s, frappe.db.sql("""update `tabBOM Item` set bom_no=%s,
rate=%s, amount=stock_qty*%s where bom_no = %s and docstatus < 2 and parenttype='BOM'""", rate=%s, amount=stock_qty*%s where bom_no = %s and docstatus < 2 and parenttype='BOM'""",
(self.new_bom, new_bom_unitcost, new_bom_unitcost, self.current_bom)) (self.new_bom, unit_cost, unit_cost, self.current_bom))
def get_parent_boms(self, bom, bom_list=[]): def get_parent_boms(self, bom, bom_list=[]):
data = frappe.db.sql("""SELECT DISTINCT parent FROM `tabBOM Item` data = frappe.db.sql("""SELECT DISTINCT parent FROM `tabBOM Item`
@@ -65,12 +66,18 @@ class BOMUpdateTool(Document):
return list(set(bom_list)) return list(set(bom_list))
def get_new_bom_unit_cost(bom):
new_bom_unitcost = frappe.db.sql("""SELECT `total_cost`/`quantity`
FROM `tabBOM` WHERE name = %s""", bom)
return flt(new_bom_unitcost[0][0]) if new_bom_unitcost else 0
@frappe.whitelist() @frappe.whitelist()
def enqueue_replace_bom(args): def enqueue_replace_bom(args):
if isinstance(args, string_types): if isinstance(args, string_types):
args = json.loads(args) args = json.loads(args)
frappe.enqueue("erpnext.manufacturing.doctype.bom_update_tool.bom_update_tool.replace_bom", args=args, timeout=4000) frappe.enqueue("erpnext.manufacturing.doctype.bom_update_tool.bom_update_tool.replace_bom", args=args, timeout=40000)
frappe.msgprint(_("Queued for replacing the BOM. It may take a few minutes.")) frappe.msgprint(_("Queued for replacing the BOM. It may take a few minutes."))
@frappe.whitelist() @frappe.whitelist()

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,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
"beta": 0,
"creation": "2019-03-08 23:56:43.187569", "creation": "2019-03-08 23:56:43.187569",
"custom": 0,
"docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
"document_type": "",
"editable_grid": 1, "editable_grid": 1,
"engine": "InnoDB", "engine": "InnoDB",
"field_order": [
"from_time",
"to_time",
"column_break_2",
"time_in_mins",
"completed_qty"
],
"fields": [ "fields": [
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "from_time", "fieldname": "from_time",
"fieldtype": "Datetime", "fieldtype": "Datetime",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0, "label": "From Time"
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "to_time", "fieldname": "to_time",
"fieldtype": "Datetime", "fieldtype": "Datetime",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0, "label": "To Time"
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_2", "fieldname": "column_break_2",
"fieldtype": "Column Break", "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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_if_empty": 0,
"fieldname": "time_in_mins", "fieldname": "time_in_mins",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Time In Mins", "label": "Time In Mins",
"length": 0, "read_only": 1
"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,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "0", "default": "0",
"fetch_if_empty": 0,
"fieldname": "completed_qty", "fieldname": "completed_qty",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Completed Qty", "label": "Completed Qty",
"length": 0, "reqd": 1
"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,
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1, "istable": 1,
"max_attachments": 0, "modified": "2019-12-03 12:56:02.285448",
"modified": "2019-03-10 17:08:46.504910",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Manufacturing", "module": "Manufacturing",
"name": "Job Card Time Log", "name": "Job Card Time Log",
"name_case": "",
"owner": "Administrator", "owner": "Administrator",
"permissions": [], "permissions": [],
"quick_entry": 1, "quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "ASC", "sort_order": "ASC",
"track_changes": 1, "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

@@ -14,6 +14,7 @@ from erpnext.stock.utils import get_bin
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
from erpnext.stock.doctype.item.test_item import make_item from erpnext.stock.doctype.item.test_item import make_item
from erpnext.manufacturing.doctype.production_plan.test_production_plan import make_bom from erpnext.manufacturing.doctype.production_plan.test_production_plan import make_bom
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse
class TestWorkOrder(unittest.TestCase): class TestWorkOrder(unittest.TestCase):
def setUp(self): def setUp(self):
@@ -82,6 +83,37 @@ class TestWorkOrder(unittest.TestCase):
wo_order.set_work_order_operations() wo_order.set_work_order_operations()
self.assertEqual(wo_order.planned_operating_cost, cost*2) self.assertEqual(wo_order.planned_operating_cost, cost*2)
def test_resered_qty_for_partial_completion(self):
item = "_Test Item"
warehouse = create_warehouse("Test Warehouse for reserved_qty - _TC")
bin1_at_start = get_bin(item, warehouse)
# reset to correct value
bin1_at_start.update_reserved_qty_for_production()
wo_order = make_wo_order_test_record(item="_Test FG Item", qty=2,
source_warehouse=warehouse, skip_transfer=1)
bin1_on_submit = get_bin(item, warehouse)
# reserved qty for production is updated
self.assertEqual(cint(bin1_at_start.reserved_qty_for_production) + 2,
cint(bin1_on_submit.reserved_qty_for_production))
test_stock_entry.make_stock_entry(item_code="_Test Item",
target=warehouse, qty=100, basic_rate=100)
test_stock_entry.make_stock_entry(item_code="_Test Item Home Desktop 100",
target=warehouse, qty=100, basic_rate=100)
s = frappe.get_doc(make_stock_entry(wo_order.name, "Manufacture", 1))
s.submit()
bin1_at_completion = get_bin(item, warehouse)
self.assertEqual(cint(bin1_at_completion.reserved_qty_for_production),
cint(bin1_on_submit.reserved_qty_for_production) - 1)
def test_production_item(self): def test_production_item(self):
wo_order = make_wo_order_test_record(item="_Test FG Item", qty=1, do_not_save=True) wo_order = make_wo_order_test_record(item="_Test FG Item", qty=1, do_not_save=True)
frappe.db.set_value("Item", "_Test FG Item", "end_of_life", "2000-1-1") frappe.db.set_value("Item", "_Test FG Item", "end_of_life", "2000-1-1")
@@ -368,7 +400,7 @@ def make_wo_order_test_record(**args):
wo_order.company = args.company or "_Test Company" wo_order.company = args.company or "_Test Company"
wo_order.stock_uom = args.stock_uom or "_Test UOM" wo_order.stock_uom = args.stock_uom or "_Test UOM"
wo_order.use_multi_level_bom=0 wo_order.use_multi_level_bom=0
wo_order.skip_transfer=1 wo_order.skip_transfer=args.skip_transfer or 0
wo_order.get_items_and_operations_from_bom() wo_order.get_items_and_operations_from_bom()
wo_order.sales_order = args.sales_order or None wo_order.sales_order = args.sales_order or None

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, {
@@ -429,6 +429,9 @@ class WorkOrder(Document):
update bin reserved_qty_for_production update bin reserved_qty_for_production
called from Stock Entry for production, after submit, cancel called from Stock Entry for production, after submit, cancel
''' '''
# calculate consumed qty based on submitted stock entries
self.update_consumed_qty_for_required_items()
if self.docstatus==1: if self.docstatus==1:
# calculate transferred qty based on submitted stock entries # calculate transferred qty based on submitted stock entries
self.update_transaferred_qty_for_required_items() self.update_transaferred_qty_for_required_items()
@@ -436,9 +439,6 @@ class WorkOrder(Document):
# update in bin # update in bin
self.update_reserved_qty_for_production() self.update_reserved_qty_for_production()
# calculate consumed qty based on submitted stock entries
self.update_consumed_qty_for_required_items()
def update_reserved_qty_for_production(self, items=None): def update_reserved_qty_for_production(self, items=None):
'''update reserved_qty_for_production in bins''' '''update reserved_qty_for_production in bins'''
for d in self.required_items: for d in self.required_items:
@@ -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']
} }
] ]
} }

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