1(function ($) { 2 $.ETC = $.ETC || {}; 3 $.ETC.CE = $.ETC.CE || {}; 4 5 $.ETC.CE.ContractItemInfo = { 6 ContractItem_initForm: function (frm, data) 7 { 8 var onSubjectChanged = function (frm, e, val) 9 { 10 if (val != null) 11 { 12 $("#Model_SubjectType option:selected").attr('selected',null); 13 $("#Model_SubjectType option[value=" + val.Type + "]").attr('selected','selected'); 14 switch (val.Type) 15 { 16 case 0: 17 $("#Model_SubjectTypeText").text("ТоваÑ"); 18 break; 19 case 1: 20 $("#Model_SubjectTypeText").text("РабоÑа"); 21 break; 22 case 2: 23 $("#Model_SubjectTypeText").text("УÑлÑга"); 24 break; 25 } 26 } 27 }; 28 var onSpecificationChanged = function (frm, e, val) 29 { 30 debugger; 31 if (val != null) 32 { 33 var selected = 0; 34 $("#Model_SubjectType option:selected").attr('selected',null); 35 switch (val.Type) 36 { 37 case 'Goods': 38 $("#Model_SubjectTypeText").text("ТоваÑ"); 39 selected = 1; 40 break; 41 case 'Works': 42 $("#Model_SubjectTypeText").text("РабоÑа"); 43 selected = 2; 44 break; 45 case 'Services': 46 $("#Model_SubjectTypeText").text("УÑлÑга"); 47 selected = 3; 48 break; 49 } 50 $("#Model_SubjectType option[value=" + selected + "]").attr('selected','selected'); 51 52 $("#Model_DwadKey").text(val.DWADKey !== null ? val.DWADKey : '') 53 $("#Model_DwadVersion").text(val.DWADVersion !== null ? val.DWADVersion : '') 54 $("#Model_DwadGroup").text(val.DWADGroupName !== null ? val.DWADGroupName : '') 55 $("#Model_DwadName").text(val.DWADDisplayName !== null ? val.DWADDisplayName : '') 56 } 57 }; 58 59 var onTaxPercentTypeChanged = function (frm, e, val) 60 { 61 frm.TaxPercent = getTaxPercent(val); 62 63 if (!frm.OnInit) 64 { 65 var quantity = getValue(frm, "Quantity"); 66 var price = getValue(frm, "Price"); 67 var sum = round(price * quantity * plusTax(), 2); 68 69 setValue(frm, "Sum", sum); 70 } 71 }; 72 73 function getTaxPercent(val) 74 { 75 if (val != null) 76 { 77 switch(val) 78 { 79 case "1": 80 return 0; 81 case "2": 82 return 0.10; 83 case "4": 84 return 0.12; 85 case "8": 86 return 0.13; 87 case "16": 88 return 0.18; 89 case "32": 90 return 0.20; 91 case "64": 92 return 0.24; 93 } 94 } 95 return 0; 96 } 97 98 var onPriceChanged = function (frm, e, price) 99 { 100 if (!isEmpty(price) && !frm.OnInit) 101 { 102 var quantity = getValue(frm, "Quantity"); 103 var sum = getValue(frm, "Sum"); 104 105 if (isEmpty(quantity) && !isEmpty(sum)) 106 { 107 quantity = round(sum * mitusTax() / price, 5); 108 setValue(frm, "Quantity", quantity); 109 } 110 else 111 { 112 sum = round(price * quantity * plusTax(), 2); 113 setValue(frm, "Sum", sum); 114 } 115 } 116 }; 117 118 var onQuantityChanged = function (frm, e, quantity) 119 { 120 if (!isEmpty(quantity) && !frm.OnInit) 121 { 122 var price = getValue(frm, "Price"); 123 var sum = getValue(frm, "Sum"); 124 125 if (isEmpty(price) && !isEmpty(sum)) 126 { 127 price = round(sum * mitusTax() / quantity, 2); 128 setValue(frm, "Price", price); 129 } 130 else 131 { 132 sum = round(price * quantity * plusTax(), 2); 133 setValue(frm, "Sum", sum); 134 } 135 } 136 }; 137 138 var onSumChanged = function (frm, e, sum) 139 { 140 if (!isEmpty(sum) && !frm.OnInit) 141 { 142 var price = getValue(frm, "Price"); 143 var quantity = getValue(frm, "Quantity"); 144 145 if (isEmpty(price) && !isEmpty(quantity)) 146 { 147 price = round(sum * mitusTax() / quantity, 2); 148 setValue(frm, "Price", price); 149 } 150 else if (!isEmpty(price) && isEmpty(quantity)) 151 { 152 quantity = round(sum * mitusTax() / price, 5); 153 setValue(frm, "Quantity", quantity); 154 } 155 else if (!isEmpty(price)) 156 { 157 quantity = round(sum * mitusTax() / price, 5); 158 setValue(frm, "Quantity", quantity); 159 } 160 } 161 }; 162 163 function round(val, decimals) 164 { 165 var d = 10 * decimals; 166 return Math.round(val * d) / d; 167 } 168 169 function mitusTax(val) 170 { 171 if (val == null) 172 val = frm.TaxPercent; 173 return 1 - val; 174 } 175 176 function plusTax(val) 177 { 178 if (val == null) 179 val = frm.TaxPercent; 180 return 1 + val; 181 } 182 183 function isEmpty(value) { 184 return (value == undefined || value == 0); 185 } 186 187 function getValue(frm, str) { 188 return $("#Model_" + str).valToNumber(); 189 } 190 191 function setValue(frm, str, value) { 192 return $("#Model_" + str).val($.formatNumber(value + '')); 193 } 194 195 frm.OnInit = true; 196 frm.TaxPercent = 0; 197 $.ETC.EventContainer.init( 198 frm.container 199 .data('init', data) // пÑедваÑиÑелÑÐ½Ð°Ñ Ð¸Ð½Ð¸ÑиализаÑÐ¸Ñ ÑоÑÑоÑÐ½Ð¸Ñ 200 .on("OnSubjectChanged", function (e, value) { onSubjectChanged(frm, e, value); }) 201 .on("OnSpecificationChanged", function (e, value) { onSpecificationChanged(frm, e, value); })
202 .on('OnPriceChanged', function (e, code) { onPriceChanged(frm, e, code); }) 203 .on('OnQuantityChanged', function (e, code) { onQuantityChanged(frm, e, code); }) 204 .on('OnSumChanged', function (e, code) { onSumChanged(frm, e, code); }) 205 .on("OnTaxPercentTypeChanged", function (e, value) { onTaxPercentTypeChanged(frm, e, value); }) 206 ); 207 frm.OnInit = false; 208 } 209 }; 210})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.