Multicurrency Controllers

I’m working on a contribution and looking for the multicurrency controller(s) but they seem to be baked into taxes_and_totals.py and the “items” table schema that occurs in a bunch of doctypes. Is there another place I should be looking? I guess more specifically, I’m looking for a method that fetches the conversion rate and rounding equation, I’d like those pieces to be consistent across ERPNext.

3 Likes

“Is there another place I should be looking?”

imo no you are on target taxes_and_totals.py - and also too transaction.js that extends it - together implement multi-currency

Many thanks for shilgod’s insight Quotation Item triggers - #6 by schilgod

That ahha moment how jQuery.extend() | jQuery API Documentation aparently interfaces and extends a python object with a js object with this statement really escapes me:

erpnext.TransactionController = erpnext.taxes_and_totals.extend({

jquery.extend - An object that will receive the new properties if additional objects are passed in or that will extend the jQuery namespace if it is the sole argument.

1 Like

@clarkej, sorry, I need to put one correction here!

It’s not jquery.extend

This feature rely on: John Resig - Simple JavaScript Inheritance

It’s an old intent to implement inheritance, using classes into JavaScript, instead of the prototyping method.

2 Likes

@max_morais_dmm thanks for the correction.

@clarkej apologies, my bad.

good catch thanks very much you both for your help - so then you are saying

erpnext.TransactionController = erpnext.taxes_and_totals.extend({

in fact extends this

and not the (controller template) py - I surely overlooked that.

edit:

So how ERPNext uses the model view controller MVC triad, the js implements the client-side form ‘view’

erpnext/erpnext/public/js/controllers at develop · frappe/erpnext · GitHub

So that when a user makes a request from a form web page, a controller is responsible for returning the response to that request:

erpnext/erpnext/controllers at develop · frappe/erpnext · GitHub

And that interaction involves consulting the ‘model’ for (master or transaction) state data.