Skip to content

Commit

Permalink
Merge branch 'develop' into refactor/stock/report/item-price-stock-re…
Browse files Browse the repository at this point in the history
…port
  • Loading branch information
s-aga-r authored Sep 26, 2022
2 parents 22299d2 + d84fd6c commit 9a1fa53
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
QueryPaymentLedger,
get_outstanding_invoices,
reconcile_against_document,
update_reference_in_payment_entry,
)
from erpnext.controllers.accounts_controller import get_advance_payment_entries

Expand Down Expand Up @@ -212,6 +213,23 @@ def add_invoice_entries(self, non_reconciled_invoices):
inv.currency = entry.get("currency")
inv.outstanding_amount = flt(entry.get("outstanding_amount"))

def get_difference_amount(self, allocated_entry):
if allocated_entry.get("reference_type") != "Payment Entry":
return

dr_or_cr = (
"credit_in_account_currency"
if erpnext.get_party_account_type(self.party_type) == "Receivable"
else "debit_in_account_currency"
)

row = self.get_payment_details(allocated_entry, dr_or_cr)

doc = frappe.get_doc(allocated_entry.reference_type, allocated_entry.reference_name)
update_reference_in_payment_entry(row, doc, do_not_save=True)

return doc.difference_amount

@frappe.whitelist()
def allocate_entries(self, args):
self.validate_entries()
Expand All @@ -227,12 +245,16 @@ def allocate_entries(self, args):
res = self.get_allocated_entry(pay, inv, pay["amount"])
inv["outstanding_amount"] = flt(inv.get("outstanding_amount")) - flt(pay.get("amount"))
pay["amount"] = 0

res.difference_amount = self.get_difference_amount(res)

if pay.get("amount") == 0:
entries.append(res)
break
elif inv.get("outstanding_amount") == 0:
entries.append(res)
continue

else:
break

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ def adjust_account(data, period_list, consolidated=False):
for d in data:
for period in period_list:
key = period if consolidated else period.key
d[key] = totals[d["account"]]
d["total"] = totals[d["account"]]
return data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ frappe.query_reports["Opportunity Summary by Sales Stage"] = {
},
{
fieldname: "opportunity_source",
label: __("Oppoturnity Source"),
label: __("Opportunity Source"),
fieldtype: "Link",
options: "Lead Source",
},
Expand All @@ -62,4 +62,4 @@ frappe.query_reports["Opportunity Summary by Sales Stage"] = {
default: frappe.defaults.get_user_default("Company")
}
]
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def get_chart_data(job_card_details, filters):
open_job_cards.append(periodic_data.get("Open").get(d))
completed.append(periodic_data.get("Completed").get(d))

datasets.append({"name": "Open", "values": open_job_cards})
datasets.append({"name": "Completed", "values": completed})
datasets.append({"name": _("Open"), "values": open_job_cards})
datasets.append({"name": _("Completed"), "values": completed})

chart = {"data": {"labels": labels, "datasets": datasets}, "type": "bar"}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def get_chart_based_on_status(data):
for d in data:
status_wise_data[d.status] += 1

labels = [_(label) for label in labels]
values = [status_wise_data[label] for label in labels]

chart = {
Expand All @@ -95,7 +96,7 @@ def get_chart_based_on_status(data):


def get_chart_based_on_age(data):
labels = ["0-30 Days", "30-60 Days", "60-90 Days", "90 Above"]
labels = [_("0-30 Days"), _("30-60 Days"), _("60-90 Days"), _("90 Above")]

age_wise_data = {"0-30 Days": 0, "30-60 Days": 0, "60-90 Days": 0, "90 Above": 0}

Expand Down Expand Up @@ -135,8 +136,8 @@ def get_chart_based_on_qty(data, filters):
pending.append(periodic_data.get("Pending").get(d))
completed.append(periodic_data.get("Completed").get(d))

datasets.append({"name": "Pending", "values": pending})
datasets.append({"name": "Completed", "values": completed})
datasets.append({"name": _("Pending"), "values": pending})
datasets.append({"name": _("Completed"), "values": completed})

chart = {
"data": {"labels": labels, "datasets": datasets},
Expand Down
6 changes: 3 additions & 3 deletions erpnext/projects/report/project_summary/project_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def get_chart_data(data):
"data": {
"labels": labels[:30],
"datasets": [
{"name": "Overdue", "values": overdue[:30]},
{"name": "Completed", "values": completed[:30]},
{"name": "Total Tasks", "values": total[:30]},
{"name": _("Overdue"), "values": overdue[:30]},
{"name": _("Completed"), "values": completed[:30]},
{"name": _("Total Tasks"), "values": total[:30]},
],
},
"type": "bar",
Expand Down
2 changes: 1 addition & 1 deletion erpnext/public/js/help_links.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ frappe.help.help_links["List/Item"] = [
label: "Item Valuation",
url:
docsUrl +
"user/manual/en/stock/articles/item-valuation-fifo-and-moving-average",
"user/manual/en/stock/articles/calculation-of-valuation-rate-in-fifo-and-moving-average",
},
];

Expand Down
24 changes: 22 additions & 2 deletions erpnext/public/js/utils/barcode_scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
this.items_table_name = opts.items_table_name || "items";
this.items_table = this.frm.doc[this.items_table_name];

// optional sound name to play when scan either fails or passes.
// see https://frappeframework.com/docs/v14/user/en/python-api/hooks#sounds
this.success_sound = opts.play_success_sound;
this.fail_sound = opts.play_fail_sound;

// any API that takes `search_value` as input and returns dictionary as follows
// {
// item_code: "HORSESHOE", // present if any item was found
Expand Down Expand Up @@ -54,19 +59,24 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
if (!data || Object.keys(data).length === 0) {
this.show_alert(__("Cannot find Item with this Barcode"), "red");
this.clean_up();
this.play_fail_sound();
reject();
return;
}

me.update_table(data).then(row => {
row ? resolve(row) : reject();
this.play_success_sound();
resolve(row);
}).catch(() => {
this.play_fail_sound();
reject();
});
});
});
}

update_table(data) {
return new Promise(resolve => {
return new Promise((resolve, reject) => {
let cur_grid = this.frm.fields_dict[this.items_table_name].grid;

const {item_code, barcode, batch_no, serial_no, uom} = data;
Expand All @@ -77,6 +87,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
if (this.dont_allow_new_row) {
this.show_alert(__("Maximum quantity scanned for item {0}.", [item_code]), "red");
this.clean_up();
reject();
return;
}

Expand All @@ -88,6 +99,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {

if (this.is_duplicate_serial_no(row, serial_no)) {
this.clean_up();
reject();
return;
}

Expand Down Expand Up @@ -219,6 +231,14 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
return this.items_table.find((d) => !d.item_code);
}

play_success_sound() {
this.success_sound && frappe.utils.play_sound(this.success_sound);
}

play_fail_sound() {
this.fail_sound && frappe.utils.play_sound(this.fail_sound);
}

clean_up() {
this.scan_barcode_field.set_value("");
refresh_field(this.items_table_name);
Expand Down

0 comments on commit 9a1fa53

Please sign in to comment.