var Bizgaze; (function (Bizgaze) { let Apps; (function (Apps) { let Transact; (function (Transact) { let Components; (function (Components) { let Invoices; (function (Invoices) { class ItemOfferSelection extends Unibase.Platform.Core.BaseComponent { constructor() { super(...arguments); this.Bizgaze_Transact_Selected_Plan = new Array(); this.g_Selected_Plan = new Array(); this.OfferIds = []; } jsFiles() { return ['platform/core/helpers/numberhelper/numberhelper.js', 'apps/transact/managers/invoicemanager.js', 'apps/transact/controls/invoices/pos.component.js']; } cssFiles() { return []; } html() { let html = '
'; return html; } load(item) { var instance = this; instance.Bizgaze_Transact_Selected_Plan = new Array(); $(".btn_close").click(function () { instance.navigationHelper.closePopUp(); }); } PlanSelection(Volume, value, DiscountType, PlanVolumeId, ItemId, len, focItemId) { var instance = this; $('.Plan_Vlm_row').css('background-color', ''); $('#spn_Quantity').text(Volume); $("#frm_Bizgazetransact_ItemOfferSelection").find("#btn_Apply").removeAttr("style").removeClass("disabled"); instance.Bizgaze_Transact_Selected_Plan = new Array(); instance.Bizgaze_Transact_Selected_Plan.push({ Volume: Volume, value: value, DiscountType: DiscountType, PlanVolumeId: PlanVolumeId, ItemId: ItemId, focItemId: focItemId }); instance.g_Selected_Plan.push({ Volume: Volume, value: value, DiscountType: DiscountType, PlanVolumeId: PlanVolumeId, ItemId: ItemId, focItemId: focItemId }); } LoadOfferItems(OrganizationId, ItemId, ItemName, InvoiceApplyType, element, Type) { var instance = this; instance.Bizgaze_Transact_Selected_Plan = new Array(); $('#sg_item').text(ItemName); ItemOfferSelection.Instance().GetPlanVolume(OrganizationId, ItemId, InvoiceApplyType, Type); $('#btn_Apply').click(function () { if (Type == 'Invoice') { ItemOfferSelection.Instance().Apply(element); } else if (Type == 'Order') { instance.navigationHelper.closePopUp(); if (instance.Bizgaze_Transact_Selected_Plan.length > 0) { Bizgaze.Apps.Transact.Controls.OrderItems.Instance().applyOffer(instance.Bizgaze_Transact_Selected_Plan); } } else if (Type == 'Estimate') { instance.navigationHelper.closePopUp(); if (instance.Bizgaze_Transact_Selected_Plan.length > 0) { Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().applyOffer(instance.Bizgaze_Transact_Selected_Plan); } } else if (Type == 'Opportunity') { instance.navigationHelper.closePopUp(); if (instance.Bizgaze_Transact_Selected_Plan.length > 0) { Bizgaze.Apps.Transact.Controls.OpportunityItem.Instance().applyOffer(instance.Bizgaze_Transact_Selected_Plan); } } else if (Type == 'POS_Order') { let elem = $(".variant-addeditem-" + ItemId); let html = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().getInventoryDesign(ItemId, false, 0, 0, "ApplyOffer"); $(elem).find(".InventoryTypesTextboxes").html(html); Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().allItemEvents(elem); instance.navigationHelper.closePopUp(); if (instance.Bizgaze_Transact_Selected_Plan.length > 0) { Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().applyOffer(instance.Bizgaze_Transact_Selected_Plan); } } else if (Type == 'Pos') { instance.navigationHelper.closePopUp(); if (instance.Bizgaze_Transact_Selected_Plan.length > 0) { Bizgaze.Apps.Transact.Controls.Pos.Instance().applyOffer(instance.Bizgaze_Transact_Selected_Plan); } } }); } GetPlanVolume(OrganizationId, ItemId, InvoiceApplyType, Type) { let instance = this; Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getPlanVolume(ItemId, OrganizationId, InvoiceApplyType).then(function (result) { instance.OfferIds = []; for (var i = 0; i < result.result.length; i++) { ItemOfferSelection.Instance().ShowItemOffers(result.result[i], ItemId, Type); } }); } ShowItemOffers(data, ItemId, Type) { let instance = this; var value; if (data.DiscountType == 1) { value = data.PayoutValue; } else { if (data.DiscountType == 2) { value = data.PayoutPercent; } else { if (data.DiscountType == 3) { value = data.OPayoutValue; } } } var len = $('.Plan_Vlm_row').length; var html_header = '
' + data.OfferName + ' - ' + data.SchemeName + '
'; var html = '
' + data.PlanName + '
'; let offerIndex = instance.OfferIds.findIndex(x => x.OfferId == data.OfferId); if (offerIndex == -1) { instance.OfferIds.push({ OfferId: data.OfferId }); html = html_header + html + html_body; html += '
'; $('.Offer_Header:last').after(html); } else { html += html_body; $('#Offer_Header_' + data.OfferId).append(html); } var ss = data.PlanName; $("#li_Pln_Vlm" + len).click(function () { let Clicked_Id = $(this).attr("id"); var focElement = document.getElementById("li_Pln_Vlm" + len); var focItemIdElement = focElement.querySelector(".selectedfocitem"); var focItemId = "0"; if (focItemIdElement != null) { focItemId = focItemIdElement.id; } let checkstatus = $(this).find("u").text(); let AppliedPlanVolumeId = $(this).parents(".Card_Plan_Vlm_row").attr("id").replace("Card_Plan_Vlm_row_", ""); if (checkstatus == "Apply") { $(".Card_Plan_Vlm_row").removeAttr("style"); var offerItemIndex = instance.Bizgaze_Transact_Selected_Plan.findIndex(x => x.ItemId == ItemId); if (offerItemIndex != -1) { instance.Bizgaze_Transact_Selected_Plan.splice(offerItemIndex, 1); } var sp_ItemIndex = instance.g_Selected_Plan.findIndex(x => x.ItemId == ItemId); if (offerItemIndex != -1) { instance.g_Selected_Plan.splice(sp_ItemIndex, 1); } $(".Plan_Vlm_row").find(".offers_applied").find("u").text("Apply").addClass("text-primary").removeClass("text-danger"); instance.HighlightAppliedPlans(AppliedPlanVolumeId, ItemId, true); ItemOfferSelection.Instance().PlanSelection(data.Volume, value, data.DiscountType, data.PlanVolumeId, ItemId, len, Number(focItemId)); } else { var msg = 'Do you what to remove Applied Offer'; bootbox.confirm({ message: msg, closeButton: false, buttons: { confirm: { label: 'Remove', className: 'btn-success' }, cancel: { label: 'Cancel', className: 'btn-danger' } }, callback: function (result) { if (result) { instance.UnHighlightPlan(AppliedPlanVolumeId, ItemId, Type); $("#spn_Quantity").text(""); } else { $('#modal_popup_EditLineItem').modal('hide'); bootbox.hideAll(); return false; } } }); } }); if (value > 0) { $("#div_PlanVlm_" + len).find('#spn_Discount').text(value); if (data.DiscountType == 2) { $("#div_PlanVlm_" + len).find('#spn_DiscountType').text(" %"); } else { if (data.DiscountType == 1) $("#div_PlanVlm_" + len).find('#spn_DiscountType').text(" Val"); if (data.DiscountType == 3) { $("#div_PlanVlm_" + len).find('#spn_DiscountType').text(" Fixed Val"); } } } else { $("#div_PlanVlm_" + len).find('.spn_off').addClass("hidden"); } if (data.ItemVolumePayouts.length > 0) { html = '
'; $('#div_PlanVlm_' + len).after(html); for (var i = 0; i < data.ItemVolumePayouts.length; i++) { ItemOfferSelection.Instance().AddFoCItem(data.ItemVolumePayouts[i], len, Type, ItemId); } } if (Type == "POS_Order") { let CartItem_Index = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().g_CartItems_New.findIndex(x => x.ItemId == ItemId); if (CartItem_Index != -1) { let AppliedPlanVolumeId = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().g_CartItems_New[CartItem_Index].AppliedPlanVolumeId; if (AppliedPlanVolumeId != 0) { instance.HighlightAppliedPlans(AppliedPlanVolumeId, ItemId, false); } } } else if (Type == "Order") { let IsCart = false; if ($("#ulOrder_Cart").is(":visible")) { IsCart = true; } Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_AppliedOffers = Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_AppliedOffers.filter(x => x.ItemId != ItemId); var sp_ItemIndex = instance.g_Selected_Plan.findIndex(x => x.ItemId == ItemId); if (sp_ItemIndex != -1) { let selectedPlan = instance.g_Selected_Plan[sp_ItemIndex]; Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_AppliedOffers.push({ ItemId: selectedPlan.ItemId, OfferId: 0, PlanId: 0, PlanVolumeId: selectedPlan.PlanVolumeId, IsSelected: true }); } let AppliedOffers = Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_AppliedOffers.filter(x => x.ItemId == ItemId); for (var ao = 0; ao < AppliedOffers.length; ao++) { let AppliedPlanVolumeId = AppliedOffers[ao].PlanVolumeId; let IsSelected = AppliedOffers[ao].IsSelected; instance.HighlightAppliedPlans(AppliedPlanVolumeId, ItemId, IsSelected); } } else if (Type == "Estimate") { let IsCart = false; if ($("#ulOrder_Cart").is(":visible")) { IsCart = true; } if (!IsCart && !Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_FromContinueShopping) { Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_AppliedOffers = Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_AppliedOffers.filter(x => x.ItemId != ItemId); var sp_ItemIndex = instance.g_Selected_Plan.findIndex(x => x.ItemId == ItemId); if (sp_ItemIndex != -1) { let selectedPlan = instance.g_Selected_Plan[sp_ItemIndex]; Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_AppliedOffers.push({ ItemId: selectedPlan.ItemId, OfferId: 0, PlanId: 0, PlanVolumeId: selectedPlan.PlanVolumeId, IsSelected: true }); } } let AppliedOffers = Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_AppliedOffers.filter(x => x.ItemId == ItemId); for (var ao = 0; ao < AppliedOffers.length; ao++) { let AppliedPlanVolumeId = AppliedOffers[ao].PlanVolumeId; let IsSelected = AppliedOffers[ao].IsSelected; instance.HighlightAppliedPlans(AppliedPlanVolumeId, ItemId, IsSelected); } } } HighlightAppliedPlans(AppliedPlanVolumeId, ItemId, IsSelected) { let instance = this; if (IsSelected) { $(".Card_Plan_Vlm_row_" + AppliedPlanVolumeId).css("background-color", "lavender"); var checkoffer = $(".Plan_Vlm_row_" + AppliedPlanVolumeId).find(".offers_applied").attr("id"); $("#" + checkoffer).find("u").text("Remove").removeClass('text-sucess').addClass('text-danger'); var sp_ItemIndex = instance.g_Selected_Plan.findIndex(x => x.ItemId == ItemId); if (sp_ItemIndex != -1) { let selectedPlan = instance.g_Selected_Plan[sp_ItemIndex]; instance.Bizgaze_Transact_Selected_Plan.push({ Volume: selectedPlan.Volume, value: selectedPlan.value, DiscountType: selectedPlan.DiscountType, PlanVolumeId: AppliedPlanVolumeId, ItemId: ItemId, focItemId: selectedPlan.focItemId }); } } else { $(".Card_Plan_Vlm_row_" + AppliedPlanVolumeId).css("background-color", "lightgoldenrodyellow"); $(".Card_Plan_Vlm_row_" + AppliedPlanVolumeId).find("u").text("Apply").addClass('text-sucess').removeClass('text-danger'); } $("#frm_Bizgazetransact_ItemOfferSelection").find("#btn_Apply").removeAttr("style").removeClass("disabled"); } UnHighlightPlan(AppliedPlanVolumeId, ItemId, Type) { let instance = this; $(".Card_Plan_Vlm_row_" + AppliedPlanVolumeId).find("u").text("Apply").addClass('text-sucess').removeClass('text-danger'); $(".Card_Plan_Vlm_row_" + AppliedPlanVolumeId).removeAttr("style"); var offerItemIndex = instance.Bizgaze_Transact_Selected_Plan.findIndex(x => x.ItemId == ItemId && x.PlanVolumeId == AppliedPlanVolumeId); if (offerItemIndex != -1) { instance.Bizgaze_Transact_Selected_Plan.splice(offerItemIndex, 1); } var sp_ItemIndex = instance.g_Selected_Plan.findIndex(x => x.ItemId == ItemId && x.PlanVolumeId == AppliedPlanVolumeId); if (offerItemIndex != -1) { instance.g_Selected_Plan.splice(sp_ItemIndex, 1); } if (Type == "Order") { var appliedoffers_ItemIndex = Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_AppliedOffers.findIndex(x => x.ItemId == ItemId && x.PlanVolumeId == AppliedPlanVolumeId); if (appliedoffers_ItemIndex != -1) { Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_AppliedOffers.splice(appliedoffers_ItemIndex, 1); } } if (Type == "Estimate") { var appliedoffers_ItemIndex = Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_AppliedOffers.findIndex(x => x.ItemId == ItemId && x.PlanVolumeId == AppliedPlanVolumeId); if (appliedoffers_ItemIndex != -1) { Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_AppliedOffers.splice(appliedoffers_ItemIndex, 1); } } } AddFoCItem(FocItem, len, Type, RefItemId) { var html = '
' + FocItem.Discount + '% off on purchase of every ' + FocItem.Recur + ' Quantity
' + FocItem.Quantity + ' x ' + FocItem.ItemName + '
' + '
'; $('#div_Foc_' + len).before(html); var seen = ''; $('.plan_Name').each(function () { var see = $(this).text(); if (seen.match(see)) { $(this).remove(); } else { seen = seen + $(this).text(); } }); if (Type == "Order") { var ValidFocItemIndex = Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_ValidFocItems.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemIds == RefItemId); if (!FocItem.IsFoC) { $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true); $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).attr("disabled", "true"); } else if (FocItem.IsFoC && ValidFocItemIndex != -1) { $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true); } $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).change(function () { var Checked = $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked"); var FocItemIndex = Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_ValidFocItems.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemIds.toString().indexOf(RefItemId) != -1); if (Checked) { if (FocItemIndex == -1) { Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_ValidFocItems.push({ ItemId: FocItem.ItemId, RefItemIds: RefItemId }); } } else { if (FocItemIndex != -1) { Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_ValidFocItems.splice(FocItemIndex, 1); } } }); } if (Type == "Estimate") { var ValidFocItemIndex = Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_ValidFocItems.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemIds == RefItemId); if (!FocItem.IsFoC) { $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true); $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).attr("disabled", "true"); } else if (FocItem.IsFoC && ValidFocItemIndex != -1) { $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true); } $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).change(function () { var Checked = $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked"); var FocItemIndex = Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_ValidFocItems.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemIds.toString().indexOf(RefItemId) != -1); if (Checked) { if (FocItemIndex == -1) { Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_ValidFocItems.push({ ItemId: FocItem.ItemId, RefItemIds: RefItemId }); } } else { if (FocItemIndex != -1) { Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_ValidFocItems.splice(FocItemIndex, 1); } } }); } if (Type == "POS_Order") { var ValidFocItemIndex = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().g_ValidFocItems.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemIds.indexOf(RefItemId) != -1); if (!FocItem.IsFoC) { $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true); $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).attr("disabled", "true"); } else if (FocItem.IsFoC && ValidFocItemIndex != -1) { $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true); } $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).change(function () { var Checked = $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked"); var FocItemIndex = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().g_ValidFocItems.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemIds.indexOf(RefItemId) != -1); if (Checked) { if (FocItemIndex == -1) { Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().g_ValidFocItems.push({ ItemId: FocItem.ItemId, RefItemIds: RefItemId }); } } else { if (FocItemIndex != -1) { Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().g_ValidFocItems.splice(FocItemIndex, 1); } } }); } if (Type == "Pos") { var ValidFocItemIndex = Bizgaze.Apps.Transact.Controls.Pos.Instance().offerItemsArray.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemId == RefItemId); if (!FocItem.IsFoC) { $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true); $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).attr("disabled", "true").addClass("opacity-30"); } else if (FocItem.IsFoC && ValidFocItemIndex != -1) { $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true); } $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).change(function () { var Checked = $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked"); var FocItemIndex = Bizgaze.Apps.Transact.Controls.Pos.Instance().offerItemsArray.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemId == RefItemId); if (Checked) { if (FocItemIndex == -1) { Bizgaze.Apps.Transact.Controls.Pos.Instance().offerItemsArray.push({ ItemId: FocItem.ItemId, RefItemId: RefItemId }); } } }); } } Apply(element) { let instance = this; instance.navigationHelper.closePopUp(); ItemOfferSelection.Instance().ApplyOffer(instance.Bizgaze_Transact_Selected_Plan, element); } AddSpliItem(element) { var array = { orderItemId: 0, invoiceItemId: 0, itemId: element.find('.selectedItemId').val(), packSize: 0, packCount: 0, packs: 0, quantity: 0, availPacks: 0, availQty: 0, Description: "", isTaxInclusive: $("#hfIsTaxInclusive").val(), addlDiscountPercent: 0, addlDiscountValue: 0, creditNote: 0, priceListId: element.find('.hf_PriceList').val(), invoiceallocations: null, exciseInvoiceItem: null, walletId: 0, Adjustment: 0, IsFoc: 0, TariffNo: "", exciseAmount: 0, discountName: "", discountId: 0, description: "", RefNo: "", DiscountGroupId: 0, DiscountGroupName: '', RefInvoiceItemId: 0, taxAdjustment: element.find('.hfItemTaxAdjsutmentVal').val(), assesableAdjustment: element.find('.hfItemAssesableAdjustmentVal').val(), inventoryTypeId: 0, dcItemId: element.find('.dcItemId').val(), ExchangeItem: element.find('.IsExchangeItem').val(), unitPrice: element.find('.prodPrice').val(), taxGroupId: element.find(".hfProdTax").val(), BatchId: 0, MrpId: 0, SerialId: 0, Name: '', maxQty: 0, accountId: element.find(".hf_Account").val(), accountName: element.find(".txt_AccountName").val(), taxGroupName: element.find(".txtProdTax").val(), }; return array; } AddItemRowToSplitArray(Item, element, Quantity) { var DcType = 2; var BranchId = $(".txtAutoComplete_shiptoaddressid").val(); if ($('.hdn_invoicetypeid').val() == '1' || $('.hdn_invoicetypeid').val() == '4' || $('.hdn_invoicetypeid').val() == '5') { BranchId = $(".txtAutoComplete_shipfromaddressid").val(); } if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "5") { DcType = 1; } Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getItemSetting(Item, BranchId, DcType).then(function (result) { var EnableMrp = result.result.EnableMRP; var EnableBatch = result.result.EnableBatchNo; var Info = []; if (EnableMrp == true) { Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getMrps(element.find(".selectedItemId").val(), DcType, BranchId).then(function (res) { Info = res.result; }); } if (EnableBatch == true) { Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getBatches(element.find(".selectedItemId").val(), DcType, BranchId).then(function (res) { Info = res.result; }); } if (Info.length > 0) { var TotalQuantity = 0; var TotalDisc = 0; var TotalAmount = 0; if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "5") { var itemQty = Quantity; for (var x = 0; x < Info.length; x++) { if (itemQty > 0) { var itemrow = ItemOfferSelection.Instance().AddSpliItem(element); let Qty = 0; if (EnableMrp == true) { itemrow.MrpId = Info[x].MrpId; itemrow.Name = Info[x].Mrp + ' ( ' + Info[x].MrpQuantity + ' ) '; Qty = Info[x].MrpQuantity; } else if (EnableBatch == true) { itemrow.BatchId = Info[x].BatchId; itemrow.Name = Info[0].BatchNo; Qty = Info[0].BatchQuantity; } if (Qty > itemQty) { itemrow.quantity = itemQty; itemQty = itemQty - Info[x].Quantity; } else { itemrow.quantity = Qty; itemQty = itemQty - Qty; } Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList.push(itemrow); TotalQuantity += Number(itemrow.quantity); var discount = 0; var qyt = Number(itemrow.quantity); var price = Number(itemrow.unitPrice); var excamt = Number(itemrow.exciseAmount); var assesableAdjustment = Number(itemrow.assesableAdjustment); var ItemAdjustment = Number(itemrow.Adjustment); var discountAmount = Number(itemrow.addlDiscountValue); var discountPercent = Number(itemrow.addlDiscountPercent); discount = (((qyt * price) + assesableAdjustment + ItemAdjustment - excamt) * Number(discountPercent) / 100) + (Number(qyt) * Number(discountAmount)); discount = Number(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discount, 3)); TotalDisc += discount; var rowtotal = Number((qyt * price) + excamt + ItemAdjustment + assesableAdjustment); var RowTotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowtotal - discount, 3); TotalAmount += RowTotal; } } } else { var itemrow = ItemOfferSelection.Instance().AddSpliItem(element); if (EnableMrp == true) { itemrow.MrpId = Info[0].MrpId; itemrow.Name = Info[0].Mrp + ' ( ' + Info[0].Quantity + ' ) '; } else if (EnableBatch == true) { itemrow.BatchId = Info[0].BatchId; itemrow.Name = Info[0].BatchNo; } itemrow.quantity = Quantity; Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList.push(itemrow); TotalQuantity += Number(itemrow.quantity); var discount = 0; var qyt = Number(itemrow.quantity); var price = Number(itemrow.unitPrice); var excamt = Number(itemrow.exciseAmount); var assesableAdjustment = Number(itemrow.assesableAdjustment); var ItemAdjustment = Number(itemrow.Adjustment); var discountAmount = Number(itemrow.addlDiscountValue); var discountPercent = Number(itemrow.addlDiscountPercent); discount = (((qyt * price) + assesableAdjustment + ItemAdjustment - excamt) * Number(discountPercent) / 100) + (Number(qyt) * Number(discountAmount)); discount = Number(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discount, 3)); TotalDisc += discount; var rowtotal = Number((qyt * price) + excamt + ItemAdjustment + assesableAdjustment); var RowTotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowtotal - discount, 3); TotalAmount += RowTotal; } if (EnableMrp == true) element.find('.spn_InvoiceItem').text("View MRP"); else element.find('.spn_InvoiceItem').text("View Batch"); element.find('.prodQuantity').val(); element.find('.prodQuantity').val(TotalQuantity); element.find('#inv_txtdiscount').val(); element.find('#inv_txtdiscount').val(TotalDisc); if ($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "6") { element.find(".txtRowTotalwithAdjustment").val(); element.find(".txtRowTotalwithAdjustment").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(TotalAmount, 3)); } else { element.find('.prodTotalPrice').text(''); element.find('.prodTotalPrice').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(TotalAmount, 3)); } Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().GetPlanItems(element.find(".selectedItemId").val(), element.find('.prodQuantity').val(), element); } }); } ApplyOffer(Item, element) { if (element.hasClass('SplitItem')) { var Qty = Number(element.find(".prodQuantity").val()); if (Qty == 0) { ItemOfferSelection.Instance().AddItemRowToSplitArray(Item, element, Item[0].Volume); Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().update_total(); } else if (Qty < Item[0].Volume) { var ItemQty = Item[0].Volume - Qty; ItemOfferSelection.Instance().AddItemRowToSplitArray(Item, element, ItemQty); Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().update_row_total(element, true); } else { Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().GetPlanItems(element.find(".selectedItemId").val(), Qty, element); Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().update_row_total(element, true); } } else { element.find(".prodQuantity").val(Item[0].Volume); Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().GetPlanItems(element.find(".selectedItemId").val(), element.find(".prodQuantity").val(), element); Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().update_row_total(element, true); } } static Instance() { if (this.instance === undefined) { this.instance = new Bizgaze.Apps.Transact.Components.Invoices.ItemOfferSelection(); } return this.instance; } } Invoices.ItemOfferSelection = ItemOfferSelection; })(Invoices = Components.Invoices || (Components.Invoices = {})); })(Components = Transact.Components || (Transact.Components = {})); })(Transact = Apps.Transact || (Apps.Transact = {})); })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {})); })(Bizgaze || (Bizgaze = {}));