fix: calculate total billing amount on fetching timesheets
- show timesheet billing amounts in doc currency
This commit is contained in:
		
							parent
							
								
									8a407f1ec3
								
							
						
					
					
						commit
						a7d0dbb085
					
				| @ -820,7 +820,7 @@ frappe.ui.form.on('Sales Invoice', { | ||||
| 	}, | ||||
| 
 | ||||
| 	add_timesheet_row: function(frm, row, exchange_rate) { | ||||
| 		frm.add_child('timesheets',{ | ||||
| 		frm.add_child('timesheets', { | ||||
| 			'activity_type': row.activity_type, | ||||
| 			'description': row.description, | ||||
| 			'time_sheet': row.parent, | ||||
| @ -828,7 +828,8 @@ frappe.ui.form.on('Sales Invoice', { | ||||
| 			'billing_amount': flt(row.billing_amount) * flt(exchange_rate), | ||||
| 			'timesheet_detail': row.name | ||||
| 		}); | ||||
| 		frm.refresh_field('timesheets') | ||||
| 		frm.refresh_field('timesheets'); | ||||
| 		calculate_total_billing_amount(frm); | ||||
| 	}, | ||||
| 
 | ||||
| 	refresh: function(frm) { | ||||
| @ -871,36 +872,32 @@ frappe.ui.form.on('Sales Invoice', { | ||||
| 								project: data.project | ||||
| 							}, | ||||
| 							callback: function(r) { | ||||
| 								if(!r.exc) { | ||||
| 									if(r.message.length > 0) { | ||||
| 										frm.clear_table('timesheets') | ||||
| 										r.message.forEach((d) => { | ||||
| 											let exchange_rate = 1.0; | ||||
| 											if (frm.doc.currency != d.currency) { | ||||
| 												frappe.call({ | ||||
| 													method: "erpnext.setup.utils.get_exchange_rate", | ||||
| 													args: { | ||||
| 														from_currency: d.currency, | ||||
| 														to_currency: frm.doc.currency | ||||
| 													}, | ||||
| 													callback: function(r) { | ||||
| 														if (r.message) { | ||||
| 															exchange_rate = r.message; | ||||
| 															frm.events.add_timesheet_row(frm, d, exchange_rate); | ||||
| 														} | ||||
| 								if (!r.exc && r.message.length > 0) { | ||||
| 									frm.clear_table('timesheets') | ||||
| 									r.message.forEach((d) => { | ||||
| 										let exchange_rate = 1.0; | ||||
| 										if (frm.doc.currency != d.currency) { | ||||
| 											frappe.call({ | ||||
| 												method: 'erpnext.setup.utils.get_exchange_rate', | ||||
| 												args: { | ||||
| 													from_currency: d.currency, | ||||
| 													to_currency: frm.doc.currency | ||||
| 												}, | ||||
| 												callback: function(r) { | ||||
| 													if (r.message) { | ||||
| 														exchange_rate = r.message; | ||||
| 														frm.events.add_timesheet_row(frm, d, exchange_rate); | ||||
| 													} | ||||
| 												}); | ||||
| 											} | ||||
| 											else { | ||||
| 												frm.events.add_timesheet_row(frm, d, exchange_rate); | ||||
| 											} | ||||
| 										}); | ||||
| 									} | ||||
| 									else { | ||||
| 										frappe.msgprint(__('No Timesheet Found.')) | ||||
| 									} | ||||
| 									d.hide(); | ||||
| 												} | ||||
| 											}); | ||||
| 										} else { | ||||
| 											frm.events.add_timesheet_row(frm, d, exchange_rate); | ||||
| 										} | ||||
| 									}); | ||||
| 								} else { | ||||
| 									frappe.msgprint(__('No Timesheets found with the selected filters.')) | ||||
| 								} | ||||
| 								d.hide(); | ||||
| 							} | ||||
| 						}); | ||||
| 					}, | ||||
|  | ||||
| @ -772,6 +772,7 @@ | ||||
|    "hide_days": 1, | ||||
|    "hide_seconds": 1, | ||||
|    "label": "Total Billing Amount", | ||||
|    "options": "currency", | ||||
|    "print_hide": 1, | ||||
|    "read_only": 1 | ||||
|   }, | ||||
| @ -1960,7 +1961,7 @@ | ||||
|    "label": "Is Debit Note" | ||||
|   }, | ||||
|   { | ||||
|    "default": 0, | ||||
|    "default": "0", | ||||
|    "depends_on": "grand_total", | ||||
|    "fieldname": "disable_rounded_total", | ||||
|    "fieldtype": "Check", | ||||
| @ -1977,7 +1978,7 @@ | ||||
|    "link_fieldname": "consolidated_invoice" | ||||
|   } | ||||
|  ], | ||||
|  "modified": "2021-05-13 17:53:26.185370", | ||||
|  "modified": "2021-05-20 22:48:33.988881", | ||||
|  "modified_by": "Administrator", | ||||
|  "module": "Accounts", | ||||
|  "name": "Sales Invoice", | ||||
|  | ||||
| @ -34,6 +34,7 @@ | ||||
|    "fieldtype": "Currency", | ||||
|    "in_list_view": 1, | ||||
|    "label": "Billing Amount", | ||||
|    "options": "currency", | ||||
|    "read_only": 1 | ||||
|   }, | ||||
|   { | ||||
| @ -64,7 +65,7 @@ | ||||
|  ], | ||||
|  "istable": 1, | ||||
|  "links": [], | ||||
|  "modified": "2021-05-13 16:52:32.995266", | ||||
|  "modified": "2021-05-20 22:33:57.234846", | ||||
|  "modified_by": "Administrator", | ||||
|  "module": "Accounts", | ||||
|  "name": "Sales Invoice Timesheet", | ||||
|  | ||||
| @ -342,9 +342,9 @@ def get_activity_cost(employee=None, activity_type=None, currency=None): | ||||
| 		rate = frappe.db.get_values("Activity Type", {"activity_type": activity_type}, | ||||
| 			["costing_rate", "billing_rate"], as_dict=True) | ||||
| 		if rate and currency and currency!=base_currency: | ||||
| 			exchnage_rate = get_exchange_rate(base_currency, currency) | ||||
| 			rate[0]["costing_rate"] = rate[0]["costing_rate"] * exchnage_rate | ||||
| 			rate[0]["billing_rate"] = rate[0]["billing_rate"] * exchnage_rate | ||||
| 			exchange_rate = get_exchange_rate(base_currency, currency) | ||||
| 			rate[0]["costing_rate"] = rate[0]["costing_rate"] * exchange_rate | ||||
| 			rate[0]["billing_rate"] = rate[0]["billing_rate"] * exchange_rate | ||||
| 
 | ||||
| 	return rate[0] if rate else {} | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user