Minor fixes in payroll entry and opening invoice tool

This commit is contained in:
Nabin Hait 2017-12-15 15:34:04 +05:30
parent 5a344576b8
commit 6a640b78c4
2 changed files with 15 additions and 28 deletions

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import _ from frappe import _, scrub
from frappe.utils import flt from frappe.utils import flt
from frappe.model.document import Document from frappe.model.document import Document
@ -68,27 +68,16 @@ class OpeningInvoiceCreationTool(Document):
for row in self.invoices: for row in self.invoices:
if not row.qty: if not row.qty:
row.qty = 1.0 row.qty = 1.0
if not row.party:
frappe.throw(mandatory_error_msg.format(
idx=row.idx,
field=_("Party"),
invoice_type=self.invoice_type
))
# set party type if not available # set party type if not available
if not row.party_type: if not row.party_type:
row.party_type = "Customer" if self.invoice_type == "Sales" else "Supplier" row.party_type = "Customer" if self.invoice_type == "Sales" else "Supplier"
if not row.posting_date: for d in ("Party", "Posting Date", "Outstanding Amount", "Due Date", "Temporary Opening Account"):
if not row.get(scrub(d)):
frappe.throw(mandatory_error_msg.format( frappe.throw(mandatory_error_msg.format(
idx=row.idx, idx=row.idx,
field=_("Party"), field=_(d),
invoice_type=self.invoice_type
))
if not row.outstanding_amount:
frappe.throw(mandatory_error_msg.format(
idx=row.idx,
field=_("Outstanding Amount"),
invoice_type=self.invoice_type invoice_type=self.invoice_type
)) ))

View File

@ -37,7 +37,7 @@ frappe.ui.form.on('Payroll Entry', {
if (!slip_status.draft && !slip_status.submitted) { if (!slip_status.draft && !slip_status.submitted) {
return; return;
} else { } else {
frm.add_custom_button("View Salary Slips", frm.add_custom_button(__("View Salary Slips"),
function() { function() {
frappe.set_route( frappe.set_route(
'List', 'Salary Slip', {posting_date: frm.doc.posting_date} 'List', 'Salary Slip', {posting_date: frm.doc.posting_date}
@ -47,13 +47,11 @@ frappe.ui.form.on('Payroll Entry', {
} }
if (slip_status.draft) { if (slip_status.draft) {
frm.add_custom_button("Submit Salary Slip", frm.add_custom_button(__("Submit Salary Slip"),
function() { function() {
submit_salary_slip(frm); submit_salary_slip(frm);
}, }
__('Make') ).addClass("btn-primary");
);
frm.page.set_inner_btn_group_as_primary(__('Make'));
} }
}, },
@ -182,7 +180,7 @@ frappe.ui.form.on('Payroll Entry', {
// Submit salary slips // Submit salary slips
const submit_salary_slip = function (frm) { const submit_salary_slip = function (frm) {
frappe.confirm(__('This will create a Journal Entry. Do you want to proceed?'), frappe.confirm(__('This will submit Salary Slips and create accrual Journal Entry. Do you want to proceed?'),
function() { function() {
frappe.call({ frappe.call({
method: 'submit_salary_slips', method: 'submit_salary_slips',
@ -190,7 +188,7 @@ const submit_salary_slip = function (frm) {
callback: function() {frm.events.refresh(frm);}, callback: function() {frm.events.refresh(frm);},
doc: frm.doc, doc: frm.doc,
freeze: true, freeze: true,
freeze_message: 'Creating Journal Entries...' freeze_message: 'Submitting Salary Slips and creating Journal Entry...'
}); });
}, },
function() { function() {