Skip to content

Commit

Permalink
Merge branch 'develop' into reload-currency-exchange-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra authored Dec 6, 2022
2 parents 06e094b + d0478ec commit 5853b80
Show file tree
Hide file tree
Showing 31 changed files with 402 additions and 167 deletions.
28 changes: 22 additions & 6 deletions erpnext/accounts/doctype/bank_clearance/bank_clearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ frappe.ui.form.on("Bank Clearance", {

refresh: function(frm) {
frm.disable_save();

if (frm.doc.account && frm.doc.from_date && frm.doc.to_date) {
frm.add_custom_button(__('Get Payment Entries'), () =>
frm.trigger("get_payment_entries")
);

frm.change_custom_button_type('Get Payment Entries', null, 'primary');
}
},

update_clearance_date: function(frm) {
Expand All @@ -46,22 +54,30 @@ frappe.ui.form.on("Bank Clearance", {
callback: function(r, rt) {
frm.refresh_field("payment_entries");
frm.refresh_fields();

if (!frm.doc.payment_entries.length) {
frm.change_custom_button_type('Get Payment Entries', null, 'primary');
frm.change_custom_button_type('Update Clearance Date', null, 'default');
}
}
});
},

get_payment_entries: function(frm) {
return frappe.call({
method: "get_payment_entries",
doc: frm.doc,
callback: function(r, rt) {
frm.refresh_field("payment_entries");
frm.refresh_fields();

$(frm.fields_dict.payment_entries.wrapper).find("[data-fieldname=amount]").each(function(i,v){
if (i !=0){
$(v).addClass("text-right")
}
})
if (frm.doc.payment_entries.length) {
frm.add_custom_button(__('Update Clearance Date'), () =>
frm.trigger("update_clearance_date")
);

frm.change_custom_button_type('Get Payment Entries', null, 'default');
frm.change_custom_button_type('Update Clearance Date', null, 'primary');
}
}
});
}
Expand Down
29 changes: 6 additions & 23 deletions erpnext/accounts/doctype/bank_clearance/bank_clearance.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"actions": [],
"allow_copy": 1,
"creation": "2013-01-10 16:34:05",
"doctype": "DocType",
Expand All @@ -13,11 +14,8 @@
"bank_account",
"include_reconciled_entries",
"include_pos_transactions",
"get_payment_entries",
"section_break_10",
"payment_entries",
"update_clearance_date",
"total_amount"
"payment_entries"
],
"fields": [
{
Expand Down Expand Up @@ -76,11 +74,6 @@
"fieldtype": "Check",
"label": "Include POS Transactions"
},
{
"fieldname": "get_payment_entries",
"fieldtype": "Button",
"label": "Get Payment Entries"
},
{
"fieldname": "section_break_10",
"fieldtype": "Section Break"
Expand All @@ -91,25 +84,14 @@
"fieldtype": "Table",
"label": "Payment Entries",
"options": "Bank Clearance Detail"
},
{
"fieldname": "update_clearance_date",
"fieldtype": "Button",
"label": "Update Clearance Date"
},
{
"fieldname": "total_amount",
"fieldtype": "Currency",
"label": "Total Amount",
"options": "account_currency",
"read_only": 1
}
],
"hide_toolbar": 1,
"icon": "fa fa-check",
"idx": 1,
"issingle": 1,
"modified": "2020-04-06 16:12:06.628008",
"links": [],
"modified": "2022-11-28 17:24:13.008692",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Bank Clearance",
Expand All @@ -126,5 +108,6 @@
"quick_entry": 1,
"read_only": 1,
"sort_field": "modified",
"sort_order": "ASC"
"sort_order": "ASC",
"states": []
}
2 changes: 0 additions & 2 deletions erpnext/accounts/doctype/bank_clearance/bank_clearance.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ def get_payment_entries(self):
)

self.set("payment_entries", [])
self.total_amount = 0.0
default_currency = erpnext.get_default_currency()

for d in entries:
Expand All @@ -198,7 +197,6 @@ def get_payment_entries(self):
d.pop("debit")
d.pop("account_currency")
row.update(d)
self.total_amount += flt(amount)

@frappe.whitelist()
def update_clearance_date(self):
Expand Down
49 changes: 49 additions & 0 deletions erpnext/accounts/doctype/pos_invoice/pos_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,46 @@
frappe.provide("erpnext.accounts");

erpnext.selling.POSInvoiceController = class POSInvoiceController extends erpnext.selling.SellingController {
settings = {};

setup(doc) {
this.setup_posting_date_time_check();
super.setup(doc);
}

company() {
erpnext.accounts.dimensions.update_dimension(this.frm, this.frm.doctype);
this.frm.set_value("set_warehouse", "");
this.frm.set_value("taxes_and_charges", "");
}

onload(doc) {
super.onload();
this.frm.ignore_doctypes_on_cancel_all = ['POS Invoice Merge Log', 'POS Closing Entry'];

if(doc.__islocal && doc.is_pos && frappe.get_route_str() !== 'point-of-sale') {
this.frm.script_manager.trigger("is_pos");
this.frm.refresh_fields();
}

this.frm.set_query("set_warehouse", function(doc) {
return {
filters: {
company: doc.company ? doc.company : '',
}
}
});

erpnext.accounts.dimensions.setup_dimension_filters(this.frm, this.frm.doctype);
}

onload_post_render(frm) {
this.pos_profile(frm);
}

refresh(doc) {
super.refresh();

if (doc.docstatus == 1 && !doc.is_return) {
this.frm.add_custom_button(__('Return'), this.make_sales_return, __('Create'));
this.frm.page.set_inner_btn_group_as_primary(__('Create'));
Expand All @@ -36,6 +54,18 @@ erpnext.selling.POSInvoiceController = class POSInvoiceController extends erpnex
this.frm.return_print_format = "Sales Invoice Return";
this.frm.set_value('consolidated_invoice', '');
}

this.frm.set_query("customer", (function () {
const customer_groups = this.settings?.customer_groups;

if (!customer_groups?.length) return {};

return {
filters: {
customer_group: ["in", customer_groups],
}
}
}).bind(this));
}

is_pos() {
Expand Down Expand Up @@ -88,6 +118,25 @@ erpnext.selling.POSInvoiceController = class POSInvoiceController extends erpnex
});
}

pos_profile(frm) {
if (!frm.pos_profile || frm.pos_profile == '') {
this.update_customer_groups_settings([]);
return;
}

frappe.call({
method: "erpnext.selling.page.point_of_sale.point_of_sale.get_pos_profile_data",
args: { "pos_profile": frm.pos_profile },
callback: ({ message: profile }) => {
this.update_customer_groups_settings(profile?.customer_groups);
},
});
}

update_customer_groups_settings(customer_groups) {
this.settings.customer_groups = customer_groups?.map((group) => group.name)
}

amount(){
this.write_off_outstanding_amount_automatically()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"discount_amount",
"base_rate_with_margin",
"sec_break2",
"apply_tds",
"rate",
"amount",
"item_tax_template",
Expand All @@ -50,6 +49,7 @@
"pricing_rules",
"stock_uom_rate",
"is_free_item",
"apply_tds",
"section_break_22",
"net_rate",
"net_amount",
Expand Down Expand Up @@ -871,16 +871,16 @@
"read_only": 1
},
{
"default": "1",
"fieldname": "apply_tds",
"fieldtype": "Check",
"label": "Apply TDS"
"default": "1",
"fieldname": "apply_tds",
"fieldtype": "Check",
"label": "Apply TDS"
}
],
"idx": 1,
"istable": 1,
"links": [],
"modified": "2022-10-26 16:05:37.304788",
"modified": "2022-11-29 13:01:20.438217",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice Item",
Expand Down
3 changes: 2 additions & 1 deletion erpnext/accounts/doctype/sales_invoice/sales_invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@
"fieldtype": "Table",
"hide_days": 1,
"hide_seconds": 1,
"label": "Sales Taxes and Charges",
"oldfieldname": "other_charges",
"oldfieldtype": "Table",
"options": "Sales Taxes and Charges"
Expand Down Expand Up @@ -2133,7 +2134,7 @@
"link_fieldname": "consolidated_invoice"
}
],
"modified": "2022-11-17 17:17:10.883487",
"modified": "2022-12-05 16:18:14.532114",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@ def execute(filters=None):
filters.naming_series = frappe.db.get_single_value("Buying Settings", "supp_master_name")

columns = get_columns(filters)
tds_docs, tds_accounts, tax_category_map, journal_entry_party_map = get_tds_docs(filters)

res = get_result(filters, tds_docs, tds_accounts, tax_category_map, journal_entry_party_map)
(
tds_docs,
tds_accounts,
tax_category_map,
journal_entry_party_map,
invoice_total_map,
) = get_tds_docs(filters)

res = get_result(
filters, tds_docs, tds_accounts, tax_category_map, journal_entry_party_map, invoice_total_map
)
final_result = group_by_supplier_and_category(res)

return columns, final_result
Expand Down
Loading

0 comments on commit 5853b80

Please sign in to comment.