various fixes on margin :

- fix on sortorder
- fix for credit notes
- fix for total