Advertisement
Guest User

settlementCurrences

a guest
Dec 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. $scope.recalculateSettlementCurrences = function() {
  2.  
  3. $rootScope.doc.settlementsCurrencesReturn = {};
  4. $rootScope.doc.settlementsCurrencesPayment = {};
  5.  
  6. if(!($rootScope.initialized) || $rootScope.delegationsVariables == undefined) {
  7. // Nic nie robimy bo nie jest zainicjowane
  8. } else {
  9.  
  10. if($rootScope.delegationsVariables.currences == undefined) {
  11.  
  12. } else {
  13.  
  14.  
  15. //Leci po wszystkich walutach które są dostępne w dokumencie
  16. for(var i =0; i < $rootScope.delegationsVariables.currences.length; i++) {
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23. //Sprawdza czy w zaliczkach jest uzyta taka waluta
  24. if($rootScope.doc.advenceAmounts.hasOwnProperty($rootScope.delegationsVariables.currences[i])) {
  25.  
  26. //var tmpAdvence = $rootScope.doc.advenceAmounts[$rootScope.delegationsVariables.currences[i]];
  27.  
  28. var tmpAdvence = $rootScope.singleDelegations.getAdvenceAmountsToSettlementByCurrency($rootScope.delegationsVariables.currences[i]);
  29.  
  30. //Sprawdza czy w kosztach jest użyta taka waluta
  31. if($rootScope.doc.totalValues.hasOwnProperty($rootScope.delegationsVariables.currences[i])) {
  32.  
  33. //var tmpCost = $rootScope.doc.totalValues[$rootScope.delegationsVariables.currences[i]];
  34.  
  35. var tmpCost = $rootScope.singleDelegations.getCostsAmountsToSettlementByCurrency($rootScope.delegationsVariables.currences[i]);
  36.  
  37. if(tmpAdvence > tmpCost) {
  38.  
  39. var substraction = tmpAdvence - tmpCost;
  40.  
  41. $rootScope.doc.settlementsCurrencesReturn[$rootScope.delegationsVariables.currences[i]] = substraction;
  42.  
  43.  
  44. } else {
  45.  
  46. var substraction = tmpCost - tmpAdvence;
  47. $rootScope.doc.settlementsCurrencesPayment[$rootScope.delegationsVariables.currences[i]] = substraction;
  48.  
  49. }
  50.  
  51. } else {
  52.  
  53. //Jeśli ta waluta była tylko w zaliczkach to wrzuca do zwrotów
  54. //var tmpAdvence = $rootScope.doc.advenceAmounts[$rootScope.delegationsVariables.currences[i]];
  55. var tmpAdvence = $rootScope.singleDelegations.getAdvenceAmountsToSettlementByCurrency($rootScope.delegationsVariables.currences[i]);
  56.  
  57.  
  58. $rootScope.doc.settlementsCurrencesReturn[$rootScope.delegationsVariables.currences[i]] = tmpAdvence;
  59.  
  60. }
  61. }
  62. else {
  63.  
  64. //Jeśli nie było w zaliczkach to sprawdza w kosztach
  65. if($rootScope.doc.totalValues.hasOwnProperty($rootScope.delegationsVariables.currences[i])) {
  66.  
  67. //Jeśli jest tylko w kosztach to wrzuca do kosztów do wypłaty
  68. //var tmpCost = $rootScope.doc.totalValues[$rootScope.delegationsVariables.currences[i]];
  69. var tmpCost = $rootScope.singleDelegations.getCostsAmountsToSettlementByCurrency($rootScope.delegationsVariables.currences[i]);
  70.  
  71. $rootScope.doc.settlementsCurrencesPayment[$rootScope.delegationsVariables.currences[i]] = tmpCost;
  72.  
  73. }
  74.  
  75. }
  76.  
  77. }
  78.  
  79. //}
  80. }
  81. }
  82.  
  83. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement