123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- var Bizgaze;
- (function (Bizgaze) {
- let Apps;
- (function (Apps) {
- let Transact;
- (function (Transact) {
- let Controls;
- (function (Controls) {
- class ManagePrice extends Unibase.Platform.Core.BaseComponent {
- constructor() {
- super(...arguments);
- this.EstimateId = 0;
- this.EstimateTypeId = Bizgaze.Apps.Transact.Controls.Estimate.Instance().g_EstimateTypeId;
- this.containerid = "";
- }
- init() {
- var instance = this;
- instance.navigationHelper.popup(0, "", Bizgaze.Apps.Transact.Controls.ManagePrice.Instance(), null, Unibase.Platform.Helpers.Size.DockLeft);
- }
- jsFiles() {
- return ["apps/transact/managers/estimates/estimatemanager.js", "apps/transact/managers/orders/ordermanager.js", "apps/transact/enums/enum.js"];
- }
- cssFiles() {
- return [];
- }
- html(id, containerid) {
- let instance = this;
- instance.EstimateTypeId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_estimatetypeid").Value);
- let html;
- if (instance.EstimateTypeId == Bizgaze.Apps.Transact.Enums.OrderType.SalesContract || instance.EstimateTypeId == Bizgaze.Apps.Transact.Enums.OrderType.PurchaseContract) {
- html = '<header class="header bg-white"><strong class="text-dark Title">Manage Price</strong><div class="btn-group ml-auto"><a class="btn btn-sm"><i class="ti-help-alt" title = "help" href = "" target = "_blank"></i></a></div></header>' +
- '<div class="scrollable"><div id="estimateitem_errormessage"></div><div id = "divContainer" class="table table-responsive mt-10" style = "overflow-x:auto;width:auto"><div class="wrapper" ><div class="bg-white" ><table border="0" cellpadding = "0" cellspacing = "0" class="result-set" id = "estimateItems" style = "overflow-x:auto;width:100%;"><thead class="thead-light"><tr>' +
- '<th style="width:auto" > Item Name - SKU</th><th class="pl-40">Qty</th><th> Discount </th><th> Contract Price </th></tr></thead><tbody id = "tblbody"></tbody></table></div></div></div></div>' +
- '<footer class="bg-white modal-footer pa-10"><a href = "javascript:;" id = "btn_manageprice_Close" class="btn btn-light btn-sm mr-auto">Close</a><a href = "javascript:;" id ="btn_Manageprice_Save" class="btn btn-primary btn-sm pull-right btn">Save</a></footer>';
- }
- else {
- html = '<header class="header bg-white"><strong class="text-dark Title">Manage Price</strong><div class="btn-group ml-auto"><a class="btn btn-sm"><i class="ti-help-alt" title = "help" href = "" target = "_blank"></i></a></div></header>' +
- '<div class="scrollable"><div id="estimateitem_errormessage"></div><div id = "divContainer" class="table table-responsive mt-10" style = "overflow-x:auto;width:auto"><div class="wrapper" ><div class="bg-white" ><table border="0" cellpadding = "0" cellspacing = "0" class="result-set" id = "estimateItems" style = "overflow-x:auto;width:100%;"><thead class="thead-light"><tr>' +
- '<th style="width:auto" > Item Name - SKU</th><th class="pl-40">Qty</th><th> Discount </th><th> Exp Price </th><th> Quoted Price </th></tr></thead><tbody id = "tblbody"></tbody></table></div></div></div></div>' +
- '<footer class="bg-white modal-footer pa-10"><a href = "javascript:;" id = "btn_manageprice_Close" class="btn btn-light btn-sm mr-auto">Close</a><a href = "javascript:;" id ="btn_Manageprice_Save" class="btn btn-primary btn-sm pull-right btn">Save</a></footer>';
- }
- return html;
- }
- load(id, containerid, callback) {
- var instance = this;
- instance.containerid = containerid;
- instance.EstimateTypeId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_estimatetypeid").Value);
- $("#btn_manageprice_Close").click(function () {
- $('#' + containerid).modal('hide');
- $('#' + containerid).remove();
- });
- $("#btn_Manageprice_Save").click(function () {
- Bizgaze.Apps.Transact.Controls.ManagePrice.Instance().save();
- });
- instance.getEstimateItems();
- }
- getEstimateItems() {
- var instance = this;
- instance.EstimateId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_estimateid").Value);
- Bizgaze.Apps.Transact.Managers.EstimateManager.Instance().getEstimateItems(instance.EstimateId).then(function (response) {
- var html = '';
- let TextBox;
- if (instance.EstimateTypeId == Bizgaze.Apps.Transact.Enums.OrderType.SalesContract || instance.EstimateTypeId == Bizgaze.Apps.Transact.Enums.OrderType.PurchaseContract) {
- TextBox;
- }
- else {
- TextBox = '<td data-label="ExpectedPrice" class="tbd" ><input type="text" class="form - control text - center editexpprice" style="width: 100px; height: 31px; " onkeypress="Bizgaze.Apps.Transact.Controls.ManagePrice.Instance().isNumberKey(event)" id="expprice" value=';
- }
- for (var i = 0; i < response.result.length; i++) {
- var data = response.result[i];
- if (data.ExchangeDC)
- return false;
- var discount = data.DiscountValue;
- var valDiscType = 'selected';
- var perDiscType = '';
- if (data.DiscountPercent != 0) {
- discount = data.DiscountPercent;
- perDiscType = 'selected';
- valDiscType = '';
- }
- html = '<tr class="value-row bg-white Estimate-Item" id="estitem' + i + '" style="">' +
- '<td class="tbd" data-label="ItemName" style="text-align:left;width:28%" class="text-sm ItemName m-l-xs">' + data.ItemName + '-' + data.SKU +
- '<input type="hidden" id="hf_ItemId" value=' + data.ItemId + '>' +
- '<input type ="hidden" id ="hf_EstimateItemId" value =' + data.EstimateItemId + '>' +
- '<input type ="hidden" id ="hf_ItemTax" value =' + data.ItemTax + '>' +
- '<input type ="hidden" id ="hf_TaxTotal" value =' + data.TaxTotal + '>' +
- '<input type ="hidden" id ="hf_RowTotal" value =' + data.RowTotal + '></td>' +
- '<td data-label="Quantity" class="text-center" style="text-align:center; width:auto;height:26px;font-size:13px" ><input type="text" class="form-control text-center editQuantity" style="width:80px; height: 35px;" onkeypress="return Bizgaze.Apps.Transact.Controls.ManagePrice.Instance().isNumberKey(event)" onchange="Bizgaze.Apps.Transact.Controls.ManagePrice.Instance().RefreshValueSummary($(estitem' + i + '));" id="Quantity" value=' + data.Quantity + '><input type ="hidden" id ="hf_Quantity" value =' + data.Quantity + ' ></td>' +
- '<td style="text-align:center; width:auto;height:26px;font-size:13px">' +
- '<div class="input-group flex-nowrap">' +
- '<input type="text" id="Ord_txtdiscount" placeholder="Discount" style="width:55px; height:35px;" data-isdynamic="false" onchange="Bizgaze.Apps.Transact.Controls.ManagePrice.Instance().RefreshValueSummary($(estitem' + i + '))";data-placeholder="0.00" data-label="Discount" class="form-control ord_txtaddldiscount floating-label-control" value="' + discount + '">' +
- '<input type="hidden" id="hfOrder_DiscountGroupId" value="0" />' +
- '<div class="input-group-btn">' +
- '<select class="btnOrder_DiscType form-control" style="width:70px; height:35px;" onchange="Bizgaze.Apps.Transact.Controls.ManagePrice.Instance().RefreshValueSummary($(estitem' + i + '))"><option value="2" ' + valDiscType + '>Val</option><option value="1" ' + perDiscType + '>%</option></select>' +
- '</div>' +
- '</div>' +
- '</div></td>' +
- TextBox + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(data.ExpectedPrice, 2) + '><input type ="hidden" id ="hf_ExpectedPrice" value =' + data.ExpectedPrice + ' ></td>' +
- '<td data-label="UnitPrice" style="width:auto;font-size:13px;text-align:center;" class="tbd"><input type="text" class="form-control text-center editQuotedPrice" style="width:100px; height: 35px;"onchange="Bizgaze.Apps.Transact.Controls.ManagePrice.Instance().RefreshValueSummary($(estitem' + i + '));" onkeypress="return Bizgaze.Apps.Transact.Controls.ManagePrice.Instance().isNumberKey(event)" id="QuotedPrice" value=' + Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(data.UnitPrice, 2) + '><input type ="hidden" id ="hf_UnitPrice" value =' + data.UnitPrice + ' ><span class="pull-right text-danger Uprice-error"></span></td></tr>';
- $("#tblbody").append(html);
- $("#Ord_txtdiscount").on("keyup", function () {
- if ($(".btnOrder_DiscType").val() == 1 && $("#Ord_txtdiscount").val() > 100) {
- instance.PercentAlert();
- }
- });
- }
- });
- }
- isNumberKey(evt) {
- if (evt.which != 8 && evt.which != 0 && (evt.which < 48 || evt.which > 57)) {
- return false;
- }
- return true;
- }
- RefreshValueSummary(element) {
- var instance = this;
- var disc = Number(element.find("#Ord_txtdiscount").val());
- var ItemId = Number(element.find("#hf_ItemId").val());
- var discType = Number(element.find(".btnOrder_DiscType").val());
- var Qty = Number(element.find(".editQuantity").val());
- var Unitprice = Number(element.find(".editQuotedPrice").val());
- var rowTotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber((Qty * Unitprice), 2);
- element.find("#hf_RowTotal").val(rowTotal);
- var aftrdiscamnt = rowTotal;
- if (disc > 0) {
- if (discType == 1) {
- var discperAmnt = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number(Unitprice * (disc / 100)), 2);
- Unitprice -= discperAmnt;
- aftrdiscamnt = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber((Qty * Unitprice), 2);
- }
- else {
- Unitprice -= disc;
- aftrdiscamnt = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber((Qty * Unitprice), 2);
- }
- }
- var estimateType = Bizgaze.Apps.Transact.Enums.OrderType[instance.EstimateTypeId];
- var billingAddressId = Unibase.Platform.Membership.Infos.Identity.getSetting("branchid");
- var BillToAddressId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_billingaddressid").Value);
- Bizgaze.Apps.Transact.Managers.OrderManager.Instance().getItemTaxDetails(ItemId, aftrdiscamnt, estimateType, billingAddressId, BillToAddressId, $('#chkCFormNoRequired').is(':checked'), false).then(function (response) {
- if (response.result != null) {
- element.find("#hf_TaxTotal").val(response.result.TaxAmount);
- }
- });
- }
- GetPriceDetails() {
- var instance = this;
- var ManagedPrices = new Array();
- $("#tblbody").find(".value-row").each(function () {
- var a = this;
- if ($('.Estimate-Item').find("#hf_EstimateItemId").val() != undefined) {
- var hf_ExpectedPrice = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number($(a).find("#hf_ExpectedPrice").val()), 2);
- var hf_UnitPrice = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number($(this).find("#hf_UnitPrice").val()), 2);
- var QuotedPrice = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number($(this).find("#QuotedPrice").val()), 2);
- var discval = 0.00;
- var discper = 0.00;
- if ($(this).find(".btnOrder_DiscType").val() == 1) {
- discval = 0;
- discper = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number($(this).find("#Ord_txtdiscount").val()), 2);
- }
- else {
- discper = 0;
- discval = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number($(this).find("#Ord_txtdiscount").val()), 2);
- }
- var expprice = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number($(this).find("#expprice").val()), 2);
- var hf_Quantity = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number($(this).find("#hf_Quantity").val()), 2);
- var Quantity = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number($(this).find("#Quantity").val()), 2);
- var Taxamnt = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number($(this).find("#hf_TaxTotal").val()), 2);
- ManagedPrices.push({
- EstimateItemId: Number($(this).find("#hf_EstimateItemId").val()), ItemId: Number($(this).find("#hf_ItemId").val()),
- DiscountValue: Number(discval), DiscountPercent: Number(discper), ExpectedPrice: Number(expprice), UnitPrice: Number(QuotedPrice), Quantity: Number(Quantity), RowTotal: Number($(this).find("#hf_RowTotal").val()), TaxTotal: Number(Taxamnt)
- });
- }
- });
- return ManagedPrices;
- }
- Amounts() {
- var TotalAmount = 0.0;
- var TaxAmount = 0.0;
- var Amounts = new Array();
- $("#estimateItems").find(".Estimate-Item").each(function () {
- TotalAmount += Number($(this).find("#hf_RowTotal").val());
- TaxAmount += Number($(this).find("#hf_TaxTotal").val());
- });
- Amounts.push({ TotalAmount: TotalAmount, TaxAmount: TaxAmount });
- return Amounts;
- }
- save() {
- var instance = this;
- if ($(".btnOrder_DiscType").val() == 1 && $("#Ord_txtdiscount").val() > 100) {
- instance.PercentAlert();
- }
- else {
- var EstimateItems = instance.GetPriceDetails();
- if (instance.EstimateTypeId == Bizgaze.Apps.Transact.Enums.OrderType.SalesContract || instance.EstimateTypeId == Bizgaze.Apps.Transact.Enums.OrderType.PurchaseContract) {
- for (var i = 0; i < EstimateItems.length; i++) {
- EstimateItems[i].ExpectedPrice = 0;
- }
- ;
- }
- var Amounts = instance.Amounts();
- var TotalAmount = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Amounts[0].TotalAmount, 2);
- var TaxAmount = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Amounts[0].TaxAmount, 2);
- var postData = {
- EstimateId: instance.EstimateId,
- TotalAmount: Number(TotalAmount),
- TaxAmount: Number(TaxAmount),
- EstimateItems: EstimateItems,
- IsManagePrice: true,
- RefNo: "",
- };
- Bizgaze.Apps.Transact.Managers.EstimateManager.Instance().managePrice(postData).then(function (response) {
- let result = response.result;
- if (result != null) {
- $('#' + instance.containerid).modal('hide');
- $('#' + instance.containerid).remove();
- var detailInstance = Unibase.Themes.Compact.Components.Details.Instance();
- var panel = "#" + detailInstance._containerId;
- var obj = Unibase.Themes.Compact.Components.Details.Instance();
- obj._recordId = Unibase.Themes.Providers.DetailHelper.recordId;
- obj._installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- detailInstance.loadAppDefaultWidget(obj, panel, detailInstance._containerId, function () {
- detailInstance.loadDefaultWidgets(obj._installedAppId, panel);
- detailInstance.LoadApprovals(obj._recordId, obj._installedAppId);
- });
- MessageHelper.Instance().showSuccess(response.message, '');
- }
- else {
- MessageHelper.Instance().showError(response.message, 'estimateitem_errormessage');
- }
- });
- }
- }
- PercentAlert() {
- bootbox.alert("Discount percentage must be less then 100");
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new ManagePrice();
- }
- return this.instance;
- }
- }
- Controls.ManagePrice = ManagePrice;
- })(Controls = Transact.Controls || (Transact.Controls = {}));
- })(Transact = Apps.Transact || (Apps.Transact = {}));
- })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
- })(Bizgaze || (Bizgaze = {}));
|