Discount Field in Sales Order
Steps
To represent discounts in One Portal user must set this steps:1.Create UDF.
Create UDF in SAP (ARGNS_PortalDiscount), for Marketing Lines, an add the UDF in the user panel connection.2.Define Querie in PORTAL
Define a querie and select the right DB for HANA.Identificator: qrprecio SELECT Select "Price" as precio FROM from "DISTRINANDO".ITM1 AS T1 inner join "DISTRINANDO".OCRD AS T2 on T1."PriceList" = T2."ListNum" WHERE where T1."ItemCode" = '{ItemCode}' and T2."CardCode" = '{CardCode}'
3.Define Querie in JS
3.1 Add Identificator in the head of JS
var mDiscountListChanged = [];
3.2 Add code inside function
function GetUOMAndDiscount(input)
3.3 Code: // FUNCION precio QueryObject = { pQueryIdentifier: 'qrprecio', pQueryParams: [] } QueryObject.pQueryParams.push({ Key: 'ItemCode', Value: $("#ItemCode" + input.attr('id')).val(), }); QueryObject.pQueryParams.push({ Key: 'CardCode', Value: $("#txtCodeVendor").val(), }); $.ajax({ url: "/QueryManager/GetQueryResult", async: false, type: "POST", data: JSON.stringify(QueryObject), dataType: "json", contentType: "application/json; charset=utf-8", success: function (data, textStatus, jqXHR) { var jsonObj = $.parseJSON(data); //console.log(jsonObj); if (data != "[]" && jsonObj[0].PRECIO != null && ($("#DiscPrcnt" + input.attr('id')).val() == "")) { var mPrecioConDescuento = $("#txt" + input.attr('id')).val(); var mDescuento = (1 - (mPrecioConDescuento / jsonObj[0].PRECIO)) * 100; mDescuento = mDescuento.toFixed(2) if(mDiscountListChanged[input.attr('id')] != null && mDiscountListChanged[input.attr('id')] != $("#DiscPrcnt" + input.attr('id')).val()) { return true; } $("#txt" + input.attr('id')).val(jsonObj[0].PRECIO); $("#DiscPrcnt" + input.attr('id')).val(mDescuento); $("#LINEUDF_U_ARGNS_Descuento" + input.attr('id')).val(mDescuento); mDiscountListChanged[input.attr('id')] = mDescuento; } } });
4. CODE IN PORTAL VIEWS
Is mandatory to remplace "_ItemsForm.cshtml" in SALES/VIEWS o avoid error representing the % discount.
Change Line "DiscPrcnt"
<td><input type="number" id='@mDiscPrcnt' class="form-control" value='@(item.DiscPrcnt != null ? (((UserView)Session["UserLogin"]).CompanyConnect.FormatNumberWithDecimals(Enums.Decimals.Percent, item.DiscPrcnt.Value)): "")' onchange="LineWasChanged('@item.LineNum');ChangeValue('@item.LineNum',true);" title="type "a""></td>