Update Gross Price in Article Edit View. Fixes #31
This commit is contained in:
		
							
								
								
									
										15
									
								
								prototype/src/main/resources/static/js/editViewUpdateTax.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								prototype/src/main/resources/static/js/editViewUpdateTax.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
			
		||||
document.addEventListener("DOMContentLoaded", function() {
 | 
			
		||||
    let priceElm = document.getElementById("price");
 | 
			
		||||
    let priceGrossElm = document.getElementById("priceGross");
 | 
			
		||||
    let vatPercent = parseInt(document.getElementById("vatPercent").value);
 | 
			
		||||
 | 
			
		||||
    let updateFn = () => {
 | 
			
		||||
       let net = Math.floor(priceElm.value*100);
 | 
			
		||||
       let vat = Math.floor((net * vatPercent) / 100);
 | 
			
		||||
       let gross = net + vat;
 | 
			
		||||
 | 
			
		||||
       priceGrossElm.innerText = (gross / 100.0).toFixed(2).replace("\\.", ",");
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    priceElm.onchange = updateFn;
 | 
			
		||||
});
 | 
			
		||||
@ -5,6 +5,7 @@
 | 
			
		||||
      <meta name="viewport" content="width=device-width, initial-scale=0.75, user-scalable=no">
 | 
			
		||||
      <title>Bearbeiten: Artikel</title>
 | 
			
		||||
      <script th:src="@{/js/filterTable.js}"></script>
 | 
			
		||||
      <script th:src="@{/js/editViewUpdateTax.js}"></script>
 | 
			
		||||
      <link rel="stylesheet" th:href="@{/css/ecom.css}"/>
 | 
			
		||||
   </head>
 | 
			
		||||
   <body>
 | 
			
		||||
@ -50,8 +51,9 @@
 | 
			
		||||
                     <input class="" type="number" id="price" step="0.01" name="price_netto" required
 | 
			
		||||
                            th:value="${ArticleID.price_netto}"/> EUR <br/>
 | 
			
		||||
                     (<span th:text="${ArticleID.vatPercent}"></span>% Mwst.)
 | 
			
		||||
                     <input type="hidden" id="vatPercent" name="vatPercent" th:value="${ArticleID.vatPercent}"/>
 | 
			
		||||
                     <!-- Info von article ref--> <br/>
 | 
			
		||||
                     = <span th:text="${ArticleID.price}"></span> EUR Brutto
 | 
			
		||||
                     = <span id="priceGross" th:text="${ArticleID.price}"></span> EUR Brutto
 | 
			
		||||
                  </p>
 | 
			
		||||
                  <p>
 | 
			
		||||
                     <label for="reorderMaxPrice">Maximaler Einkaufspreis (Netto)</label>
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user