Merge branch 'develop' into patch-7

This commit is contained in:
Marica 2021-03-31 22:23:23 +05:30 committed by GitHub
commit bfc2590e3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 169 additions and 84 deletions

View File

@ -15,12 +15,14 @@ from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profi
test_dependencies = ["Item", "Cost Center"] test_dependencies = ["Item", "Cost Center"]
class TestBankTransaction(unittest.TestCase): class TestBankTransaction(unittest.TestCase):
def setUp(self): @classmethod
def setUpClass(cls):
make_pos_profile() make_pos_profile()
add_transactions() add_transactions()
add_vouchers() add_vouchers()
def tearDown(self): @classmethod
def tearDownClass(cls):
for bt in frappe.get_all("Bank Transaction"): for bt in frappe.get_all("Bank Transaction"):
doc = frappe.get_doc("Bank Transaction", bt.name) doc = frappe.get_doc("Bank Transaction", bt.name)
doc.cancel() doc.cancel()
@ -33,9 +35,6 @@ class TestBankTransaction(unittest.TestCase):
# Delete POS Profile # Delete POS Profile
frappe.db.sql("delete from `tabPOS Profile`") frappe.db.sql("delete from `tabPOS Profile`")
frappe.flags.test_bank_transactions_created = False
frappe.flags.test_payments_created = False
# This test checks if ERPNext is able to provide a linked payment for a bank transaction based on the amount of the bank transaction. # This test checks if ERPNext is able to provide a linked payment for a bank transaction based on the amount of the bank transaction.
def test_linked_payments(self): def test_linked_payments(self):
bank_transaction = frappe.get_doc("Bank Transaction", dict(description="Re 95282925234 FE/000002917 AT171513000281183046 Conrad Electronic")) bank_transaction = frappe.get_doc("Bank Transaction", dict(description="Re 95282925234 FE/000002917 AT171513000281183046 Conrad Electronic"))
@ -44,8 +43,8 @@ class TestBankTransaction(unittest.TestCase):
# This test validates a simple reconciliation leading to the clearance of the bank transaction and the payment # This test validates a simple reconciliation leading to the clearance of the bank transaction and the payment
def test_reconcile(self): def test_reconcile(self):
bank_transaction = frappe.get_doc("Bank Transaction", dict(description="1512567 BG/000002918 OPSKATTUZWXXX AT776000000098709837 Herr G")) bank_transaction = frappe.get_doc("Bank Transaction", dict(description="1512567 BG/000003025 OPSKATTUZWXXX AT776000000098709849 Herr G"))
payment = frappe.get_doc("Payment Entry", dict(party="Mr G", paid_amount=1200)) payment = frappe.get_doc("Payment Entry", dict(party="Mr G", paid_amount=1700))
vouchers = json.dumps([{ vouchers = json.dumps([{
"payment_doctype":"Payment Entry", "payment_doctype":"Payment Entry",
"payment_name":payment.name, "payment_name":payment.name,
@ -116,10 +115,6 @@ def create_bank_account(bank_name="Citi Bank", account_name="_Test Bank - _TC"):
pass pass
def add_transactions(): def add_transactions():
if frappe.flags.test_bank_transactions_created:
return
frappe.set_user("Administrator")
create_bank_account() create_bank_account()
doc = frappe.get_doc({ doc = frappe.get_doc({
@ -172,14 +167,8 @@ def add_transactions():
}).insert() }).insert()
doc.submit() doc.submit()
frappe.flags.test_bank_transactions_created = True
def add_vouchers(): def add_vouchers():
if frappe.flags.test_payments_created:
return
frappe.set_user("Administrator")
try: try:
frappe.get_doc({ frappe.get_doc({
"doctype": "Supplier", "doctype": "Supplier",
@ -272,13 +261,6 @@ def add_vouchers():
except frappe.DuplicateEntryError: except frappe.DuplicateEntryError:
pass pass
si = create_sales_invoice(customer="Fayva", qty=1, rate=109080)
pe = get_payment_entry("Sales Invoice", si.name, bank_account="_Test Bank - _TC")
pe.reference_no = "Fayva Oct 18"
pe.reference_date = "2018-10-29"
pe.insert()
pe.submit()
mode_of_payment = frappe.get_doc({ mode_of_payment = frappe.get_doc({
"doctype": "Mode of Payment", "doctype": "Mode of Payment",
"name": "Cash" "name": "Cash"
@ -291,14 +273,12 @@ def add_vouchers():
}) })
mode_of_payment.save() mode_of_payment.save()
si = create_sales_invoice(customer="Fayva", qty=1, rate=109080, do_not_submit=1) si = create_sales_invoice(customer="Fayva", qty=1, rate=109080, do_not_save=1)
si.is_pos = 1 si.is_pos = 1
si.append("payments", { si.append("payments", {
"mode_of_payment": "Cash", "mode_of_payment": "Cash",
"account": "_Test Bank - _TC", "account": "_Test Bank - _TC",
"amount": 109080 "amount": 109080
}) })
si.save() si.insert()
si.submit() si.submit()
frappe.flags.test_payments_created = True

View File

@ -1952,13 +1952,12 @@
"is_submittable": 1, "is_submittable": 1,
"links": [ "links": [
{ {
"custom": 1,
"group": "Reference", "group": "Reference",
"link_doctype": "POS Invoice", "link_doctype": "POS Invoice",
"link_fieldname": "consolidated_invoice" "link_fieldname": "consolidated_invoice"
} }
], ],
"modified": "2021-02-01 15:42:26.261540", "modified": "2021-03-31 15:42:26.261540",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Sales Invoice", "name": "Sales Invoice",

View File

@ -23,14 +23,9 @@ class TestPlaidSettings(unittest.TestCase):
doc.cancel() doc.cancel()
doc.delete() doc.delete()
for ba in frappe.get_all("Bank Account"): for doctype in ("Bank Account", "Bank Account Type", "Bank Account Subtype"):
frappe.get_doc("Bank Account", ba.name).delete() for d in frappe.get_all(doctype):
frappe.delete_doc(doctype, d.name, force=True)
for at in frappe.get_all("Bank Account Type"):
frappe.get_doc("Bank Account Type", at.name).delete()
for ast in frappe.get_all("Bank Account Subtype"):
frappe.get_doc("Bank Account Subtype", ast.name).delete()
def test_plaid_disabled(self): def test_plaid_disabled(self):
frappe.db.set_value("Plaid Settings", None, "enabled", 0) frappe.db.set_value("Plaid Settings", None, "enabled", 0)

View File

@ -181,7 +181,6 @@
"read_only": 1 "read_only": 1
}, },
{ {
"default": "Company:company:default_currency",
"depends_on": "eval:(doc.docstatus==1 || doc.employee)", "depends_on": "eval:(doc.docstatus==1 || doc.employee)",
"fieldname": "currency", "fieldname": "currency",
"fieldtype": "Link", "fieldtype": "Link",
@ -201,7 +200,7 @@
], ],
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2020-11-25 12:01:55.980721", "modified": "2021-03-31 14:42:47.321368",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Employee Advance", "name": "Employee Advance",

View File

@ -130,7 +130,6 @@
"read_only": 1 "read_only": 1
}, },
{ {
"default": "Company:company:default_currency",
"depends_on": "eval:(doc.docstatus==1 || doc.employee)", "depends_on": "eval:(doc.docstatus==1 || doc.employee)",
"fieldname": "currency", "fieldname": "currency",
"fieldtype": "Link", "fieldtype": "Link",
@ -155,7 +154,7 @@
], ],
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2020-11-25 11:56:06.777241", "modified": "2021-03-31 14:45:27.948207",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Leave Encashment", "name": "Leave Encashment",

View File

@ -25,6 +25,16 @@ frappe.ui.form.on('Production Plan', {
} }
}); });
frm.set_query('material_request', 'material_requests', function() {
return {
filters: {
material_request_type: "Manufacture",
docstatus: 1,
status: ["!=", "Stopped"],
}
};
});
frm.fields_dict['po_items'].grid.get_field('item_code').get_query = function(doc) { frm.fields_dict['po_items'].grid.get_field('item_code').get_query = function(doc) {
return { return {
query: "erpnext.controllers.queries.item_query", query: "erpnext.controllers.queries.item_query",

View File

@ -70,7 +70,7 @@ class ProductionPlan(Document):
from `tabMaterial Request` mr, `tabMaterial Request Item` mr_item from `tabMaterial Request` mr, `tabMaterial Request Item` mr_item
where mr_item.parent = mr.name where mr_item.parent = mr.name
and mr.material_request_type = "Manufacture" and mr.material_request_type = "Manufacture"
and mr.docstatus = 1 and mr.company = %(company)s and mr.docstatus = 1 and mr.status != "Stopped" and mr.company = %(company)s
and mr_item.qty > ifnull(mr_item.ordered_qty,0) {0} {1} and mr_item.qty > ifnull(mr_item.ordered_qty,0) {0} {1}
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
and bom.is_active = 1)) and bom.is_active = 1))

View File

@ -163,7 +163,6 @@
"read_only": 1 "read_only": 1
}, },
{ {
"default": "Company:company:default_currency",
"depends_on": "eval:(doc.docstatus==1 || doc.employee)", "depends_on": "eval:(doc.docstatus==1 || doc.employee)",
"fieldname": "currency", "fieldname": "currency",
"fieldtype": "Link", "fieldtype": "Link",
@ -176,7 +175,7 @@
], ],
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2020-10-20 17:51:13.419716", "modified": "2021-03-31 14:45:48.566756",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Payroll", "module": "Payroll",
"name": "Additional Salary", "name": "Additional Salary",

View File

@ -124,7 +124,6 @@
"read_only": 1 "read_only": 1
}, },
{ {
"default": "Company:company:default_currency",
"depends_on": "eval:(doc.docstatus==1 || doc.employee)", "depends_on": "eval:(doc.docstatus==1 || doc.employee)",
"fieldname": "currency", "fieldname": "currency",
"fieldtype": "Link", "fieldtype": "Link",
@ -148,7 +147,7 @@
], ],
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2020-12-14 15:52:08.566418", "modified": "2021-03-31 14:46:22.465521",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Payroll", "module": "Payroll",
"name": "Employee Benefit Application", "name": "Employee Benefit Application",

View File

@ -21,7 +21,6 @@ frappe.ui.form.on('Employee Benefit Claim', {
callback: function(r) { callback: function(r) {
if (r.message) { if (r.message) {
frm.set_value('currency', r.message); frm.set_value('currency', r.message);
frm.set_df_property('currency', 'hidden', 0);
} }
} }
}); });

View File

@ -125,10 +125,9 @@
"label": "Attachments" "label": "Attachments"
}, },
{ {
"default": "Company:company:default_currency", "depends_on": "eval: doc.employee",
"fieldname": "currency", "fieldname": "currency",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 1,
"label": "Currency", "label": "Currency",
"options": "Currency", "options": "Currency",
"read_only": 1, "read_only": 1,
@ -145,7 +144,7 @@
], ],
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2020-11-25 11:49:56.097352", "modified": "2021-03-31 15:51:51.489269",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Payroll", "module": "Payroll",
"name": "Employee Benefit Claim", "name": "Employee Benefit Claim",

View File

@ -75,7 +75,6 @@
"reqd": 1 "reqd": 1
}, },
{ {
"default": "Company:company:default_currency",
"depends_on": "eval:(doc.docstatus==1 || doc.employee)", "depends_on": "eval:(doc.docstatus==1 || doc.employee)",
"fieldname": "currency", "fieldname": "currency",
"fieldtype": "Link", "fieldtype": "Link",
@ -95,7 +94,7 @@
], ],
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2020-10-20 17:22:16.468042", "modified": "2021-03-31 14:48:00.919839",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Payroll", "module": "Payroll",
"name": "Employee Incentive", "name": "Employee Incentive",

View File

@ -47,5 +47,26 @@ frappe.ui.form.on('Employee Tax Exemption Declaration', {
}); });
}).addClass("btn-primary"); }).addClass("btn-primary");
} }
},
employee: function(frm) {
if (frm.doc.employee) {
frm.trigger('get_employee_currency');
}
},
get_employee_currency: function(frm) {
frappe.call({
method: "erpnext.payroll.doctype.salary_structure_assignment.salary_structure_assignment.get_employee_currency",
args: {
employee: frm.doc.employee,
},
callback: function(r) {
if (r.message) {
frm.set_value('currency', r.message);
frm.refresh_fields();
}
}
});
} }
}); });

View File

@ -108,7 +108,7 @@
"read_only": 1 "read_only": 1
}, },
{ {
"default": "Company:company:default_currency", "depends_on": "eval: doc.employee",
"fieldname": "currency", "fieldname": "currency",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Currency", "label": "Currency",
@ -119,7 +119,7 @@
], ],
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2020-10-20 16:42:24.493761", "modified": "2021-03-31 20:41:57.387749",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Payroll", "module": "Payroll",
"name": "Employee Tax Exemption Declaration", "name": "Employee Tax Exemption Declaration",

View File

@ -58,5 +58,26 @@ frappe.ui.form.on('Employee Tax Exemption Proof Submission', {
currency: function(frm) { currency: function(frm) {
frm.refresh_fields(); frm.refresh_fields();
} },
employee: function(frm) {
if (frm.doc.employee) {
frm.trigger('get_employee_currency');
}
},
get_employee_currency: function(frm) {
frappe.call({
method: "erpnext.payroll.doctype.salary_structure_assignment.salary_structure_assignment.get_employee_currency",
args: {
employee: frm.doc.employee,
},
callback: function(r) {
if (r.message) {
frm.set_value('currency', r.message);
frm.refresh_fields();
}
}
});
},
}); });

View File

@ -131,7 +131,7 @@
"read_only": 1 "read_only": 1
}, },
{ {
"default": "Company:company:default_currency", "depends_on": "eval: doc.employee",
"fieldname": "currency", "fieldname": "currency",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Currency", "label": "Currency",
@ -142,7 +142,7 @@
], ],
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2020-10-20 16:47:03.410020", "modified": "2021-03-31 20:48:32.639885",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Payroll", "module": "Payroll",
"name": "Employee Tax Exemption Proof Submission", "name": "Employee Tax Exemption Proof Submission",

View File

@ -93,7 +93,7 @@
"options": "Income Tax Slab Other Charges" "options": "Income Tax Slab Other Charges"
}, },
{ {
"default": "Company:company:default_currency", "fetch_from": "company.default_currency",
"fieldname": "currency", "fieldname": "currency",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Currency", "label": "Currency",
@ -104,7 +104,7 @@
], ],
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2020-10-19 13:54:24.728075", "modified": "2021-03-31 20:53:33.323712",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Payroll", "module": "Payroll",
"name": "Income Tax Slab", "name": "Income Tax Slab",

View File

@ -93,7 +93,6 @@
"reqd": 1 "reqd": 1
}, },
{ {
"default": "Company:company:default_currency",
"depends_on": "eval:(doc.docstatus==1 || doc.employee)", "depends_on": "eval:(doc.docstatus==1 || doc.employee)",
"fieldname": "currency", "fieldname": "currency",
"fieldtype": "Link", "fieldtype": "Link",
@ -106,7 +105,7 @@
], ],
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2020-10-20 17:27:47.003134", "modified": "2021-03-31 14:50:29.401020",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Payroll", "module": "Payroll",
"name": "Retention Bonus", "name": "Retention Bonus",

View File

@ -500,7 +500,6 @@
"fieldtype": "Column Break" "fieldtype": "Column Break"
}, },
{ {
"default": "Company:company:default_currency",
"depends_on": "eval:(doc.docstatus==1 || doc.salary_structure)", "depends_on": "eval:(doc.docstatus==1 || doc.salary_structure)",
"fetch_from": "salary_structure.currency", "fetch_from": "salary_structure.currency",
"fieldname": "currency", "fieldname": "currency",
@ -632,7 +631,7 @@
"idx": 9, "idx": 9,
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2021-02-19 11:48:05.383945", "modified": "2021-03-31 15:39:28.817166",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Payroll", "module": "Payroll",
"name": "Salary Slip", "name": "Salary Slip",

View File

@ -232,7 +232,7 @@
"idx": 1, "idx": 1,
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2020-09-30 11:30:32.190798", "modified": "2021-03-31 15:41:12.342380",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Payroll", "module": "Payroll",
"name": "Salary Structure", "name": "Salary Structure",

View File

@ -125,7 +125,6 @@
"options": "Income Tax Slab" "options": "Income Tax Slab"
}, },
{ {
"default": "Company:company:default_currency",
"depends_on": "eval:(doc.docstatus==1 || doc.salary_structure)", "depends_on": "eval:(doc.docstatus==1 || doc.salary_structure)",
"fetch_from": "salary_structure.currency", "fetch_from": "salary_structure.currency",
"fieldname": "currency", "fieldname": "currency",
@ -146,7 +145,7 @@
], ],
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2020-11-30 18:07:48.251311", "modified": "2021-03-31 15:49:36.361253",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Payroll", "module": "Payroll",
"name": "Salary Structure Assignment", "name": "Salary Structure Assignment",

View File

@ -1167,6 +1167,11 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
this.calculate_net_weight(); this.calculate_net_weight();
} }
// for handling customization not to fetch price list rate
if(frappe.flags.dont_fetch_price_list_rate) {
return
}
if (!dont_fetch_price_list_rate && if (!dont_fetch_price_list_rate &&
frappe.meta.has_field(doc.doctype, "price_list_currency")) { frappe.meta.has_field(doc.doctype, "price_list_currency")) {
this.apply_price_list(item, true); this.apply_price_list(item, true);

View File

@ -109,7 +109,7 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td>{{__("Suppliies made to Composition Taxable Persons")}}</td> <td>{{__("Supplies made to Composition Taxable Persons")}}</td>
<td class="right"> <td class="right">
{% for row in data.inter_sup.comp_details %} {% for row in data.inter_sup.comp_details %}
{% if row %} {% if row %}

View File

@ -172,7 +172,6 @@ class GSTR3BReport(Document):
self.json_output = frappe.as_json(self.report_dict) self.json_output = frappe.as_json(self.report_dict)
def set_inward_nil_exempt(self, inward_nil_exempt): def set_inward_nil_exempt(self, inward_nil_exempt):
self.report_dict["inward_sup"]["isup_details"][0]["inter"] = flt(inward_nil_exempt.get("gst").get("inter"), 2) self.report_dict["inward_sup"]["isup_details"][0]["inter"] = flt(inward_nil_exempt.get("gst").get("inter"), 2)
self.report_dict["inward_sup"]["isup_details"][0]["intra"] = flt(inward_nil_exempt.get("gst").get("intra"), 2) self.report_dict["inward_sup"]["isup_details"][0]["intra"] = flt(inward_nil_exempt.get("gst").get("intra"), 2)
self.report_dict["inward_sup"]["isup_details"][1]["inter"] = flt(inward_nil_exempt.get("non_gst").get("inter"), 2) self.report_dict["inward_sup"]["isup_details"][1]["inter"] = flt(inward_nil_exempt.get("non_gst").get("inter"), 2)
@ -238,7 +237,6 @@ class GSTR3BReport(Document):
self.report_dict[supply_type][supply_category]["txval"] += flt(txval, 2) self.report_dict[supply_type][supply_category]["txval"] += flt(txval, 2)
def set_inter_state_supply(self, inter_state_supply): def set_inter_state_supply(self, inter_state_supply):
osup_det = self.report_dict["sup_details"]["osup_det"] osup_det = self.report_dict["sup_details"]["osup_det"]
for key, value in iteritems(inter_state_supply): for key, value in iteritems(inter_state_supply):
@ -352,10 +350,18 @@ class GSTR3BReport(Document):
inward_nil_exempt = frappe.db.sql(""" select p.place_of_supply, sum(i.base_amount) as base_amount, inward_nil_exempt = frappe.db.sql(""" select p.place_of_supply, sum(i.base_amount) as base_amount,
i.is_nil_exempt, i.is_non_gst from `tabPurchase Invoice` p , `tabPurchase Invoice Item` i i.is_nil_exempt, i.is_non_gst from `tabPurchase Invoice` p , `tabPurchase Invoice Item` i
where p.docstatus = 1 and p.name = i.parent where p.docstatus = 1 and p.name = i.parent
and p.gst_category != 'Registered Composition'
and (i.is_nil_exempt = 1 or i.is_non_gst = 1) and and (i.is_nil_exempt = 1 or i.is_non_gst = 1) and
month(p.posting_date) = %s and year(p.posting_date) = %s and p.company = %s and p.company_gstin = %s month(p.posting_date) = %s and year(p.posting_date) = %s and p.company = %s and p.company_gstin = %s
group by p.place_of_supply, i.is_nil_exempt, i.is_non_gst""", (self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1) group by p.place_of_supply, i.is_nil_exempt, i.is_non_gst""", (self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1)
inward_nil_exempt += frappe.db.sql("""SELECT sum(base_net_total) as base_amount, gst_category, place_of_supply
FROM `tabPurchase Invoice`
WHERE docstatus = 1 and gst_category = 'Registered Composition'
and month(posting_date) = %s and year(posting_date) = %s
and company = %s and company_gstin = %s
group by place_of_supply""", (self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1)
inward_nil_exempt_details = { inward_nil_exempt_details = {
"gst": { "gst": {
"intra": 0.0, "intra": 0.0,
@ -369,9 +375,11 @@ class GSTR3BReport(Document):
for d in inward_nil_exempt: for d in inward_nil_exempt:
if d.place_of_supply: if d.place_of_supply:
if d.is_nil_exempt == 1 and state == d.place_of_supply.split("-")[1]: if (d.is_nil_exempt == 1 or d.get('gst_category') == 'Registered Composition') \
and state == d.place_of_supply.split("-")[1]:
inward_nil_exempt_details["gst"]["intra"] += d.base_amount inward_nil_exempt_details["gst"]["intra"] += d.base_amount
elif d.is_nil_exempt == 1 and state != d.place_of_supply.split("-")[1]: elif (d.is_nil_exempt == 1 or d.get('gst_category') == 'Registered Composition') \
and state != d.place_of_supply.split("-")[1]:
inward_nil_exempt_details["gst"]["inter"] += d.base_amount inward_nil_exempt_details["gst"]["inter"] += d.base_amount
elif d.is_non_gst == 1 and state == d.place_of_supply.split("-")[1]: elif d.is_non_gst == 1 and state == d.place_of_supply.split("-")[1]:
inward_nil_exempt_details["non_gst"]["intra"] += d.base_amount inward_nil_exempt_details["non_gst"]["intra"] += d.base_amount

View File

@ -64,7 +64,7 @@ class TestGSTR3BReport(unittest.TestCase):
self.assertEqual(output["sup_details"]["osup_zero"]["iamt"], 18), self.assertEqual(output["sup_details"]["osup_zero"]["iamt"], 18),
self.assertEqual(output["inter_sup"]["unreg_details"][0]["iamt"], 18), self.assertEqual(output["inter_sup"]["unreg_details"][0]["iamt"], 18),
self.assertEqual(output["sup_details"]["osup_nil_exmp"]["txval"], 100), self.assertEqual(output["sup_details"]["osup_nil_exmp"]["txval"], 100),
self.assertEqual(output["inward_sup"]["isup_details"][0]["inter"], 250) self.assertEqual(output["inward_sup"]["isup_details"][0]["intra"], 250)
self.assertEqual(output["itc_elg"]["itc_avl"][4]["samt"], 22.50) self.assertEqual(output["itc_elg"]["itc_avl"][4]["samt"], 22.50)
self.assertEqual(output["itc_elg"]["itc_avl"][4]["camt"], 22.50) self.assertEqual(output["itc_elg"]["itc_avl"][4]["camt"], 22.50)
@ -228,6 +228,19 @@ def create_purchase_invoices():
pi1.submit() pi1.submit()
pi2 = make_purchase_invoice(company="_Test Company GST",
customer = '_Test Registered Supplier',
currency = 'INR',
item = 'Milk',
warehouse = 'Finished Goods - _GST',
expense_account = 'Cost of Goods Sold - _GST',
cost_center = 'Main - _GST',
rate=250,
qty=1,
do_not_save=1
)
pi2.submit()
def make_suppliers(): def make_suppliers():
if not frappe.db.exists("Supplier", "_Test Registered Supplier"): if not frappe.db.exists("Supplier", "_Test Registered Supplier"):
frappe.get_doc({ frappe.get_doc({

View File

@ -44,7 +44,7 @@ class Gstr2Report(Gstr1Report):
for inv, items_based_on_rate in self.items_based_on_tax_rate.items(): for inv, items_based_on_rate in self.items_based_on_tax_rate.items():
invoice_details = self.invoices.get(inv) invoice_details = self.invoices.get(inv)
for rate, items in items_based_on_rate.items(): for rate, items in items_based_on_rate.items():
if rate: if rate or invoice_details.get('gst_category') == 'Registered Composition':
if inv not in self.igst_invoices: if inv not in self.igst_invoices:
rate = rate / 2 rate = rate / 2
row, taxable_value = self.get_row_data_for_invoice(inv, invoice_details, rate, items) row, taxable_value = self.get_row_data_for_invoice(inv, invoice_details, rate, items)
@ -86,7 +86,7 @@ class Gstr2Report(Gstr1Report):
conditions += opts[1] conditions += opts[1]
if self.filters.get("type_of_business") == "B2B": if self.filters.get("type_of_business") == "B2B":
conditions += "and ifnull(gst_category, '') in ('Registered Regular', 'Deemed Export', 'SEZ') and is_return != 1 " conditions += "and ifnull(gst_category, '') in ('Registered Regular', 'Deemed Export', 'SEZ', 'Registered Composition') and is_return != 1 "
elif self.filters.get("type_of_business") == "CDNR": elif self.filters.get("type_of_business") == "CDNR":
conditions += """ and is_return = 1 """ conditions += """ and is_return = 1 """

View File

@ -779,6 +779,7 @@ def get_events(start, end, filters=None):
@frappe.whitelist() @frappe.whitelist()
def make_purchase_order_for_default_supplier(source_name, selected_items=None, target_doc=None): def make_purchase_order_for_default_supplier(source_name, selected_items=None, target_doc=None):
"""Creates Purchase Order for each Supplier. Returns a list of doc objects."""
if not selected_items: return if not selected_items: return
if isinstance(selected_items, string_types): if isinstance(selected_items, string_types):
@ -821,15 +822,16 @@ def make_purchase_order_for_default_supplier(source_name, selected_items=None, t
target.stock_qty = (flt(source.stock_qty) - flt(source.ordered_qty)) target.stock_qty = (flt(source.stock_qty) - flt(source.ordered_qty))
target.project = source_parent.project target.project = source_parent.project
suppliers = [item.get('supplier') for item in selected_items if item.get('supplier') and item.get('supplier')] suppliers = [item.get('supplier') for item in selected_items if item.get('supplier')]
suppliers = list(set(suppliers)) suppliers = list(dict.fromkeys(suppliers)) # remove duplicates while preserving order
items_to_map = [item.get('item_code') for item in selected_items if item.get('item_code') and item.get('item_code')] items_to_map = [item.get('item_code') for item in selected_items if item.get('item_code')]
items_to_map = list(set(items_to_map)) items_to_map = list(set(items_to_map))
if not suppliers: if not suppliers:
frappe.throw(_("Please set a Supplier against the Items to be considered in the Purchase Order.")) frappe.throw(_("Please set a Supplier against the Items to be considered in the Purchase Order."))
purchase_orders = []
for supplier in suppliers: for supplier in suppliers:
doc = get_mapped_doc("Sales Order", source_name, { doc = get_mapped_doc("Sales Order", source_name, {
"Sales Order": { "Sales Order": {
@ -873,7 +875,9 @@ def make_purchase_order_for_default_supplier(source_name, selected_items=None, t
doc.insert() doc.insert()
frappe.db.commit() frappe.db.commit()
return doc purchase_orders.append(doc)
return purchase_orders
@frappe.whitelist() @frappe.whitelist()
def make_purchase_order(source_name, selected_items=None, target_doc=None): def make_purchase_order(source_name, selected_items=None, target_doc=None):

View File

@ -762,7 +762,7 @@ class TestSalesOrder(unittest.TestCase):
so = make_sales_order(item_list=so_items, do_not_submit=True) so = make_sales_order(item_list=so_items, do_not_submit=True)
so.submit() so.submit()
po = make_purchase_order_for_default_supplier(so.name, selected_items=[so_items[0]]) po = make_purchase_order_for_default_supplier(so.name, selected_items=[so_items[0]])[0]
po.submit() po.submit()
dn = create_dn_against_so(so.name, delivered_qty=2) dn = create_dn_against_so(so.name, delivered_qty=2)
@ -844,7 +844,7 @@ class TestSalesOrder(unittest.TestCase):
so.submit() so.submit()
# create po for only one item # create po for only one item
po1 = make_purchase_order_for_default_supplier(so.name, selected_items=[so_items[0]]) po1 = make_purchase_order_for_default_supplier(so.name, selected_items=[so_items[0]])[0]
po1.submit() po1.submit()
self.assertEqual(so.customer, po1.customer) self.assertEqual(so.customer, po1.customer)
@ -854,7 +854,7 @@ class TestSalesOrder(unittest.TestCase):
self.assertEqual(len(po1.items), 1) self.assertEqual(len(po1.items), 1)
# create po for remaining item # create po for remaining item
po2 = make_purchase_order_for_default_supplier(so.name, selected_items=[so_items[1]]) po2 = make_purchase_order_for_default_supplier(so.name, selected_items=[so_items[1]])[0]
po2.submit() po2.submit()
# teardown # teardown
@ -865,6 +865,45 @@ class TestSalesOrder(unittest.TestCase):
so.load_from_db() so.load_from_db()
so.cancel() so.cancel()
def test_drop_shipping_full_for_default_suppliers(self):
"""Test if multiple POs are generated in one go against different default suppliers."""
from erpnext.selling.doctype.sales_order.sales_order import make_purchase_order_for_default_supplier
if not frappe.db.exists("Item", "_Test Item for Drop Shipping 1"):
make_item("_Test Item for Drop Shipping 1", {"is_stock_item": 1, "delivered_by_supplier": 1})
if not frappe.db.exists("Item", "_Test Item for Drop Shipping 2"):
make_item("_Test Item for Drop Shipping 2", {"is_stock_item": 1, "delivered_by_supplier": 1})
so_items = [
{
"item_code": "_Test Item for Drop Shipping 1",
"warehouse": "",
"qty": 2,
"rate": 400,
"delivered_by_supplier": 1,
"supplier": '_Test Supplier'
},
{
"item_code": "_Test Item for Drop Shipping 2",
"warehouse": "",
"qty": 2,
"rate": 400,
"delivered_by_supplier": 1,
"supplier": '_Test Supplier 1'
}
]
# create so and po
so = make_sales_order(item_list=so_items, do_not_submit=True)
so.submit()
purchase_orders = make_purchase_order_for_default_supplier(so.name, selected_items=so_items)
self.assertEqual(len(purchase_orders), 2)
self.assertEqual(purchase_orders[0].supplier, '_Test Supplier')
self.assertEqual(purchase_orders[1].supplier, '_Test Supplier 1')
def test_reserved_qty_for_closing_so(self): def test_reserved_qty_for_closing_so(self):
bin = frappe.get_all("Bin", filters={"item_code": "_Test Item", "warehouse": "_Test Warehouse - _TC"}, bin = frappe.get_all("Bin", filters={"item_code": "_Test Item", "warehouse": "_Test Warehouse - _TC"},
fields=["reserved_qty"]) fields=["reserved_qty"])

View File

@ -101,7 +101,7 @@ class DeliveryNote(SellingController):
for f in fieldname: for f in fieldname:
toggle_print_hide(self.meta if key == "parent" else item_meta, f) toggle_print_hide(self.meta if key == "parent" else item_meta, f)
super(DeliveryNote, self).before_print() super(DeliveryNote, self).before_print(settings)
def set_actual_qty(self): def set_actual_qty(self):
for d in self.get('items'): for d in self.get('items'):