Skip to content

Commit

Permalink
fix : Added new Fields in Jewellery Receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
Keerthana-ck committed Feb 26, 2024
1 parent 5138a1c commit 5c68fc9
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
"net_weight",
"column_break_juco",
"stone",
"unit_stone_charge",
"stone_charge",
"amount_without_making_charge",
"making_chargein_percentage",
"making_charge",
"amount",
"has_stone"
Expand Down Expand Up @@ -81,9 +84,10 @@
},
{
"fieldname": "making_charge",
"fieldtype": "Percent",
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Making Charge",
"read_only": 1,
"reqd": 1
},
{
Expand All @@ -99,12 +103,29 @@
"fieldtype": "Check",
"hidden": 1,
"label": "has Stone"
},
{
"fieldname": "amount_without_making_charge",
"fieldtype": "Currency",
"label": "Amount Without Making Charge",
"read_only": 1
},
{
"fieldname": "making_chargein_percentage",
"fieldtype": "Percent",
"label": "Making Charge(In Percentage)"
},
{
"default": "3000",
"fieldname": "unit_stone_charge",
"fieldtype": "Int",
"label": "Unit Stone Charge"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2024-02-22 14:58:10.281266",
"modified": "2024-02-26 14:46:45.162826",
"modified_by": "Administrator",
"module": "AuMMS",
"name": "Jewellery Item Receipt",
Expand Down
36 changes: 24 additions & 12 deletions aumms/aumms/doctype/jewellery_receipt/jewellery_receipt.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ frappe.ui.form.on("Jewellery Receipt", {
});
},
refresh:function(frm) {
// show only customers whose territory is set to India
frm.set_query('stone', () => {
return {
filters: {
Expand Down Expand Up @@ -62,25 +61,38 @@ frappe.ui.form.on("Jewellery Item Receipt", {
if (frm.doc.has_stone) {
let net_weight = d.gold_weight + d.stone_weight;
frappe.model.set_value(cdt, cdn, 'net_weight', net_weight);
let stone_charge = d.unit_stone_charge * d.stone_weight;
frappe.model.set_value(cdt, cdn, 'stone_charge', stone_charge)
}frm.fields_dict.item_details.grid.toggle_enable('has_stone', frm.doc.has_stone);frm.fields_dict.item_details.grid.toggle_enable('has_stone', frm.doc.has_stone);
},
gold_weight: function(frm, cdt, cdn) {
let d = locals[cdt][cdn];
if (!frm.doc.has_stone) {
let net_weight = d.gold_weight;
frappe.model.set_value(cdt, cdn, 'net_weight', net_weight);
let d = locals[cdt][cdn];
if (!frm.doc.has_stone) {
let net_weight = d.gold_weight;
frappe.model.set_value(cdt, cdn, 'net_weight', net_weight);
let amount_without_making_charge = (d.gold_weight * frm.doc.board_rate)
frappe.model.set_value(cdt, cdn, 'amount_without_making_charge', amount_without_making_charge);
}
},
making_chargein_percentage: function(frm, cdt, cdn) {
let d = locals[cdt][cdn];
if (d.amount_without_making_charge && d.making_chargein_percentage) {
let making_charge = d.amount_without_making_charge * (d.making_chargein_percentage / 100); // Calculate the specified percentage of amount_without_making_charge
frappe.model.set_value(cdt, cdn, 'making_charge', making_charge);
}
},
making_charge: function(frm, cdt, cdn) {
let d = locals[cdt][cdn];
if (frm.doc.has_stone) {

let amount = ((d.gold_weight * frm.doc.board_rate) + d.stone_charge )* (1+(d.making_charge/100));
if (d.making_charge) {
let amount = d.amount_without_making_charge + d.making_charge
frappe.model.set_value(cdt, cdn, 'amount', amount);
}
if (!frm.doc.has_stone){
let amount = (d.gold_weight * frm.doc.board_rate) * (1+(d.making_charge/100));
frappe.model.set_value(cdt, cdn, 'amount', amount);
}
},
stone_charge : function(frm, cdt, cdn){
let d = locals[cdt][cdn];
if (frm.doc.has_stone){
let amount_without_making_charge = (d.gold_weight * frm.doc.board_rate) + d.stone_charge
frappe.model.set_value(cdt, cdn, 'amount_without_making_charge', amount_without_making_charge);
}
}
});
5 changes: 3 additions & 2 deletions aumms/aumms/doctype/jewellery_receipt/jewellery_receipt.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"reqd": 1
},
{
"default": "Today",
"fieldname": "date",
"fieldtype": "Date",
"label": "Date",
Expand Down Expand Up @@ -118,13 +119,13 @@
"default": "0",
"fieldname": "is_fix",
"fieldtype": "Check",
"label": "Is Fix"
"label": "Fixed Charge"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2024-02-19 09:57:16.557567",
"modified": "2024-02-26 13:59:56.968963",
"modified_by": "Administrator",
"module": "AuMMS",
"name": "Jewellery Receipt",
Expand Down
28 changes: 24 additions & 4 deletions aumms/aumms/doctype/jewellery_receipt/jewellery_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ def on_submit(self):
self.create_purchase_receipt()

def validate_date(self):
today_date = today()
if self.date != today_date:
frappe.throw('Please select today\'s date')

self.calculate_item_details()

def create_item(self):
for item_detail in self.get("item_details"):
Expand Down Expand Up @@ -89,3 +86,26 @@ def create_purchase_receipt(self):
purchase_receipt.submit()

frappe.msgprint('Purchase Receipt created.', indicator="green", alert=1)


def calculate_item_details(self):
for item_detail in self.get("item_details"):
if self.has_stone:
if item_detail.stone_weight:
item_detail.net_weight = item_detail.gold_weight + item_detail.stone_weight
if item_detail.unit_stone_charge:
item_detail.stone_charge = item_detail.unit_stone_charge * item_detail.stone_weight
else:
item_detail.net_weight = item_detail.gold_weight
if self.board_rate:
if self.has_stone:
item_detail.amount_without_making_charge = (item_detail.gold_weight * self.board_rate) + item_detail.stone_charge
else:
item_detail.amount_without_making_charge = item_detail.gold_weight * self.board_rate

if item_detail.amount_without_making_charge:
item_detail.making_charge = item_detail.amount_without_making_charge * (item_detail.making_chargein_percentage / 100)

if item_detail.making_charge:
item_detail.amount = item_detail.amount_without_making_charge + item_detail.making_charge
frappe.db.commit()

0 comments on commit 5c68fc9

Please sign in to comment.