var Bizgaze; (function (Bizgaze) { let Apps; (function (Apps) { let Transact; (function (Transact) { let Infos; (function (Infos) { class OrderItem { static Instance() { if (this.instance === undefined) { this.instance = new OrderItem(); } return this.instance; } } Infos.OrderItem = OrderItem; class FoCItem { } Infos.FoCItem = FoCItem; class ValidOrderFoCItem { } Infos.ValidOrderFoCItem = ValidOrderFoCItem; class AppliedOffer { } Infos.AppliedOffer = AppliedOffer; class OrderTotals { } Infos.OrderTotals = OrderTotals; class UOMSchemaDetails { } Infos.UOMSchemaDetails = UOMSchemaDetails; class POSOrderItem { static Instance() { if (this.instance === undefined) { this.instance = new OrderItem(); } return this.instance; } } Infos.POSOrderItem = POSOrderItem; class Cart_Item { static Instance() { if (this.instance === undefined) { this.instance = new Cart_Item(); } return this.instance; } } Infos.Cart_Item = Cart_Item; class ValidFoCItem { } Infos.ValidFoCItem = ValidFoCItem; class RawMaterial { } Infos.RawMaterial = RawMaterial; class Operation { } Infos.Operation = Operation; })(Infos = Transact.Infos || (Transact.Infos = {})); })(Transact = Apps.Transact || (Apps.Transact = {})); })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {})); })(Bizgaze || (Bizgaze = {})); var Bizgaze; (function (Bizgaze) { let Apps; (function (Apps) { let Transact; (function (Transact) { let Components; (function (Components) { class OrderFilter extends Unibase.Platform.Core.BaseComponent { constructor() { super(...arguments); this.g_TagArray = []; this.g_ClearingTags = ""; this.g_ContainerId = ""; this.g_Tags = ""; this.g_OnlyFilters = false; this.g_TagCategoryId = 0; this.g_LobId = 0; } cssFiles() { return []; } jsFiles() { var jsFiles = ['apps/crm/lobs/managers/lobmanager.js', 'apps/transact/managers/inventory/itemmanager.js']; return jsFiles; } html(id, containerid) { var instance = this; instance.g_ContainerId = containerid; var html = `
`; return html; } load(id, containerid, callback) { var instance = this; instance.g_LobId = Number($(".txtAutoComplete_LobId").val()); instance.categoryTagItem(); if (id == "POS") { instance.g_order = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance(); instance.g_orderItem = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance(); } else { instance.g_order = Bizgaze.Apps.Transact.Controls.Order.Instance(); instance.g_orderItem = Bizgaze.Apps.Transact.Controls.OrderItems.Instance(); } if (isNaN(instance.g_LobId)) { instance.g_LobId = instance.g_order.g_LobId; } $('#btn_CancelFilter').click(function () { for (var i = 0; i < instance.g_TagArray.length; i++) { instance.g_ClearingTags += instance.g_TagArray[i].TagId + "|"; } instance.g_ClearingTags = instance.g_ClearingTags.replace(/\:$/, ''); instance.g_Tags = instance.g_ClearingTags; instance.filterItemsByTags(instance.g_ClearingTags, false); }); $('#btn_ClearFilter').click(function () { instance.g_orderItem.g_IsFilterApplied = false; instance.g_orderItem.g_FilteredTags = ''; instance.clearAll(); }); $('#btn_ApplyFilter').click(function () { instance.g_orderItem.g_IsFilterApplied = true; instance.showFilteredItems(); }); } bindCustomerTags(id = "") { var instance = this; if (id == "POS") { instance.g_order = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance(); instance.g_orderItem = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance(); } else { instance.g_order = Bizgaze.Apps.Transact.Controls.Order.Instance(); instance.g_orderItem = Bizgaze.Apps.Transact.Controls.OrderItems.Instance(); } var TagGroupId = instance.g_order.g_TagGroupId; var OrganizationId = instance.g_order.g_OrganizationId; Unibase.Platform.Forms.Managers.TagManager.Instance().GetTagsByRefId(OrganizationId, TagGroupId).then(function (response) { var data = response.result; var options = ''; var tags = ''; instance.g_TagArray = []; for (var i = 0; i < data.length; i++) { if (data[i] != undefined) { instance.g_TagArray.push({ TagId: data[i].TagId, TagName: data[i].TagName, ParentId: data[i].ParentRootId }); options += data[i].TagId + "|"; } } if (options != '') { options = options.replace(/\|$/, ''); tags = options; } if (tags != '') { tags = tags.replace(/\:$/, ''); } instance.g_Tags = tags; instance.filterItemsByTags(tags, true); if (Bizgaze.Apps.Transact.Components.OrderFilter.Instance().g_TagArray.length != 0) { $("#ItemLoadType option[value='1']").remove(); instance.g_OnlyFilters = true; } }); } addTagItem(TagGroupId) { var instance = this; if (TagGroupId != 0) { Unibase.Platform.Forms.Managers.TagManager.Instance().getTagParentsByCategoryId(Number(instance.g_TagCategoryId), TagGroupId).then(function (response) { var taghtml = ''; var disabled = ""; if (Bizgaze.Apps.Transact.Components.OrderFilter.Instance().g_OnlyFilters) { disabled = "disabled"; $("#btn_ApplyOrderFilter, #btn_ClearOrderFilter").addClass("hidden"); } for (var i = 0; i < response.result.length; i++) { var tagName = response.result[i].TagName; if (i % 2 == 0) { taghtml += '
'; } taghtml += '
'; taghtml += '
' + '' + '' + '
'; if (i % 2 == 1) { taghtml += '
'; } } if (response.result.length == 0) { taghtml += '' + '
No Tags Assigned For This Lob.
'; } $('.divTagList').html(taghtml); if (response.result.length != 0) { instance.refreshTags(); } }); } } refreshTags() { var instance = this; var y = 0; var lobid = $(".txtAutoComplete_lobid").val(); var categoryId = instance.g_TagCategoryId; var PARENTID = ""; let serviceurl = "apis/v4/unibase/platform/forms/autotagsforassignment"; serviceurl = _appsettings.server_url() + (serviceurl.startsWith('/') ? serviceurl : ('/' + serviceurl)); $(".lobTagItems").each(function () { var parentId = $(this).find(".hfTagCloud_ParentTagId-" + y).val(); PARENTID += parentId + ","; if (parentId != undefined) { var Tags = []; var Ids = []; if (instance.g_TagArray != undefined && instance.g_TagArray != '') { for (var i = 0; i < instance.g_TagArray.length; i++) { var Tag = instance.g_TagArray[i]; if (parentId == Tag.ParentId) { Tags.push({ id: Tag.TagId, text: Tag.TagName }); Ids.push(Tag.TagId); } } } var Parameters = [ { ColumnName: 'LobId', Value: lobid }, { ColumnName: 'CategoryId', Value: categoryId }, { ColumnName: 'ParentId', Value: PARENTID }, ]; var ColumnName = "", Value = ""; if (Parameters != null) { ColumnName = Parameters.map(function (item) { return item.ColumnName; }).toString(); Value = Parameters.map(function (item) { return item.Value + "|"; }).toString(); } $(".txtTagsSelect2_" + y).select2({ placeholder: "Select", data: Tags, ajax: { url: serviceurl, contentType: 'application/json', dataType: 'json', type: "POST", traditional: true, crossDomain: true, async: true, data: function (params) { var y = $(this).attr("id").replace("txtBizgazeNotifications_Tags_", ""); parentId = $(".hfTagCloud_ParentTagId-" + y).val(); var ParticipantsCount = new Array(); var Participants = ""; if ($(".txtTagsSelect2_" + Number($(this).attr('data-id'))).val().toString() != "") { var Participant = $(".txtTagsSelect2_" + Number($(this).attr('data-id'))).val().toString(); ParticipantsCount = Participant.split(','); for (var i = 0; i < ParticipantsCount.length; i++) { Participants += "|" + ParticipantsCount[i]; } Participants; } var Term = params.term != undefined ? params.term : ""; var postData = { DocPropertyId: 0, ColumnName: ColumnName, FormPropertyId: Number($(this).attr('data-id')), Value: Value, bindedData: Participants.substring(1, Participants.length), term: Term, TagGroupId: Number(instance.g_order.g_TagGroupId), TagCatagoryId: Number(categoryId), TagId: Number(parentId), }; return JSON.stringify(postData); }, processResults: function (data) { var json_data = JSON.parse(data.result); var cols = []; for (let i = 0; i < json_data.length; i++) { var ids = { id: json_data[i].Value, text: json_data[i].DisplayText }; cols.push(ids); } return { results: cols }; }, beforeSend: function (xhr) { if (Unibase.Platform.Membership.Infos.Identity.getCurrentUser() !== undefined && Unibase.Platform.Membership.Infos.Identity.getCurrentUser() !== null) { xhr.setRequestHeader('Authorization', 'Basic ' + Unibase.Platform.Membership.Infos.Identity.getCurrentUser().sessionId); xhr.setRequestHeader('geoposition', Unibase.Platform.Membership.Infos.Identity.getCurrentUser().latd + ':' + Unibase.Platform.Membership.Infos.Identity.getCurrentUser().lgId); } }, }, }); jQuery(".txtTagsSelect2_" + y).val(Ids).trigger('change'); } y++; }); y = 0; } categoryTagItem() { var instance = this; Unibase.Platform.Forms.Managers.TagManager.Instance().getTagCategoryByName("Items").then(function (response) { var data = response.result; instance.g_TagCategoryId = data.TagCategoryId; var TagGroupId = instance.g_order.g_TagGroupId; if (TagGroupId != null && TagGroupId != 0) { instance.addTagItem(TagGroupId); } }); } showFilteredItems() { var instance = this; var tags = ''; var select2Id = 0; instance.g_TagArray = []; $(".lobTagItems").each(function () { var data = $(this).find('#txtBizgazeNotifications_Tags_' + select2Id + '').select2('data'); var parentId = $(this).find(".hfTagCloud_ParentTagId-" + select2Id).val(); if (data.length > 0) { var options = ''; for (var i = 0; i < data.length; i++) { if (data[i] != '000' && data[i] != undefined) { instance.g_TagArray.push({ TagId: data[i].id, TagName: data[i].text, ParentId: parentId }); options += data[i].id + "|"; } } if (options != '') { options = options.replace(/\|$/, ''); tags += options + "|"; } } select2Id++; }); if (tags != '') { tags = tags.replace(/\:$/, ''); } instance.g_Tags = tags; instance.filterItemsByTags(tags, false); } clearAll() { var select2Id = 0; $(".lobTagItems").each(function () { $(this).find('#txtBizgazeNotifications_Tags_' + select2Id + '').val(null).trigger('change'); select2Id++; }); } filterItemsByTags(Tags, Ispagination) { var instance = this; instance.g_order.g_LoadOffersOnly = false; if (Tags == "" || Tags == null || Tags == undefined) { if (instance.g_order.g_IsPurchasePlanning) instance.g_orderItem.loadPurchasePlanItems(''); else instance.g_orderItem.loadItems($("#txt_SearchItem").val()); if (instance.g_ContainerId != "") { if ($('#' + instance.g_ContainerId).length > 0) { $('#' + instance.g_ContainerId).modal('hide'); } } $("#ItemLoadType").val(1); if (!Ispagination) { $('#' + instance.g_ContainerId).modal('hide'); $('#' + instance.g_ContainerId).remove(); } } else { var SearchTerm = $("#txt_SearchItem").val(); if (SearchTerm == "") SearchTerm = null; instance.g_orderItem.g_FilteredTags = Tags; var contactId = instance.g_order.g_OrganizationId; if (contactId == 0) contactId = instance.g_order.g_OrgContactId; instance.fileCacheHelper.loadJsFile("apps/transact/managers/inventory/itemmanager.js", function () { instance.g_Tags = Tags; instance.g_orderItem.loadItems($("#txt_SearchItem").val()); $("#ItemLoadType").append(''); $("#ItemLoadType").val(0); if (!Ispagination) { $('#' + instance.g_ContainerId).modal('hide'); $('#' + instance.g_ContainerId).remove(); } }); } } static Instance() { if (this.instance === undefined) { this.instance = new OrderFilter(); } return this.instance; } } Components.OrderFilter = OrderFilter; })(Components = Transact.Components || (Transact.Components = {})); })(Transact = Apps.Transact || (Apps.Transact = {})); })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {})); })(Bizgaze || (Bizgaze = {})); var Unibase; (function (Unibase) { let Platform; (function (Platform) { let Helpers; (function (Helpers) { class PrintHelper { printPopup(PrintHtml) { if (isMobileApp()) { Unibase.Platform.Helpers.MobileHelper.Instance().previewHtml(PrintHtml); } else { var mywindow = window.open('', 'my Print', 'height=400,width=850'); var content = 'Print'; content += PrintHtml; content += ""; content += ''; mywindow.document.write(content); } return true; } showPrintErrorModal() { bootbox.alert("Please configure print template"); } static Instance() { if (this.instance === null || this.instance === undefined) this.instance = new PrintHelper(); return this.instance; } } Helpers.PrintHelper = PrintHelper; })(Helpers = Platform.Helpers || (Platform.Helpers = {})); })(Platform = Unibase.Platform || (Unibase.Platform = {})); })(Unibase || (Unibase = {})); 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 = {})); var Bizgaze; (function (Bizgaze) { let Apps; (function (Apps) { let Transact; (function (Transact) { let Controls; (function (Controls) { class InvoiceItem extends Unibase.Platform.Core.BaseComponent { constructor() { super(...arguments); this.rowIndex = 0; this.itemIds = new Array(); this.dcItemIds = new Array(); this.SplitedInvoiceItemList = new Array(); this.deleted_invoiceItems = new Array(); this.invItemTaxAdjustmentList = new Array(); this.container = ""; this.AutoDc = false; this.OrderSettingId = 0; this.orderid = 0; this.dcid = 0; this.ClaimId = 0; this.TurnOver = 0; this.TaxRate = 0; this.ContactTcsEnable = false; this.EnableTenantTcs = false; this.PanAvailable = false; this.IswalkinCustomer = false; this.ManageInvoice = 2; this.ManageInvoiceTax = 2; this.UOMs = []; this.ChangedUOM = false; this.isOfferChargeApplied = false; } init(formpropertyid, prop, callback) { var instance = InvoiceItem.Instance(); Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/core/helpers/numberhelper/numberhelper.js", function () { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/invoicemanager.js", function () { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/paymentterms/paymenttermmanager.js", function () { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/offers/offermanager.js", function () { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("tenants/themes/compact/components/details/details.js", function () { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/forms/components/formviewer/formviewer.js", function () { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("libs/parsley/parsley.min.js", function () { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () { instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId); instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId); }); }); }); }); }); }); }); }); } loadControl(containerid, prop) { let instance = this; var html = '
Item Details
0
Item Name
Qty
Unit Price
Disc.
Total
'; $("#" + containerid).html(html); $('.advanced-opitions').on('click', function () { $('#change_taxgroup').val(null).trigger('change'); $('.advchange_taxgroup').toggleClass('hidden-element'); $('.advchange_taxgroup').find('.select2-selection__placeholder span').text('Select Tax Group'); }); InvoiceItem.instance.container = containerid; InvoiceItem.Instance().loadChangeTaxGroupAutoComplete(); } invoiceinit() { if (InvoiceItem.Instance().orderid != 0) { var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId; Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getorderbranchsettings(InvoiceItem.Instance().orderid).then(function (response) { if (response.result != null) { if (response.result.SettingValue == "Invoice First") { InvoiceItem.Instance().OrderSettingId = 2; } else if (response.result.SettingValue == "DC First" || response.result.SettingValue == "GRN First") { InvoiceItem.Instance().OrderSettingId = 1; } } }); } $(".dropdown_istaxinclusive option[value='false']").attr('selected', 'true'); $(".dropdown_paymentmethodid option[value='0']").attr('selected', 'true'); $(".nettotal").remove(); var VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1]; $("#" + VisibleContainerId).find(".btn_Save_Form").addClass("hidden"); var nettotal = '0.00'; if ($('.Title').siblings('.btn-group').length > 0) $('.Title').siblings('.btn-group').prepend(nettotal); else $('.Title').after('0.00'); $('.txtAutoComplete_paymenttermid').change(function () { InvoiceItem.Instance().LoadDueDays(); }); $('.date_journaldate').blur(function () { InvoiceItem.Instance().LoadDueDays(); if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "7") && $("#chk_tcsapplied").val() != undefined) InvoiceItem.Instance().GetCustomerTurnOver(); }); $('.date_journaldate').change(function () { var invdate = $('.date_journaldate').val().toString().split('/'); let todaydate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(), "").split('/'); var Invoicedate = new Date(Number(invdate[2]), Number(invdate[1]) - 1, Number(invdate[0])); var CurrentDate = new Date(Number(todaydate[2]), Number(todaydate[1]) - 1, Number(todaydate[0])); if (Invoicedate > CurrentDate) { bootbox.confirm("Are You Sure,You want to Continue with Future Invoice", function (result) { if (result) { InvoiceItem.Instance().GetAvailableWallets(Number($(".hdn_invoiceid").val())); } else { var f = new Date(); $('.date_journaldate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(f, "")); let date = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(f, ""); var tdate = moment(date, "DD/MM/YYYY").format("YYYY/MM/DD"); $('.hfdate_journaldate').val(tdate); InvoiceItem.Instance().GetAvailableWallets(Number($(".hdn_invoiceid").val())); } }); } else { InvoiceItem.Instance().GetAvailableWallets(Number($(".hdn_invoiceid").val())); } InvoiceItem.Instance().GetDiscounts(); }); $('.date_refdate').blur(function () { let refdate = $(".date_refdate").val(); if (refdate == "" || refdate == null) { var f = new Date(); $('.date_refdate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(f, "")); let date = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(f, ""); var tdate = moment(date, "DD/MM/YYYY").format("YYYY/MM/DD"); $('.hfdate_refdate').val(tdate); $(".divCustomProperties_refdate").children().addClass("floating-label-form-group-with-value"); } }); $(".section_Ebs").addClass("hidden"); $(".section_Details").addClass('hidden'); $(".section_ItemDetails").addClass('hidden'); $(".section_Ebs").addClass('hidden'); $(".section_InvoiceAmount").addClass('hidden'); $(".section_Description").addClass('hidden'); $(".section_BillingAndShippingDetails").addClass('hidden'); $(".section_AdvancedOptions").addClass("hidden"); $(".section_Description").addClass("hidden"); $(".section_Wallets").addClass("hidden"); $(".section_TCS").addClass("hidden"); $("#div_tcstaxrate").addClass("hidden"); $(".div_tcsadjustment").addClass("hidden"); $("#div_tcsamount").addClass("hidden"); $(".number_tcsamount").prop("disabled", true); $(".number_tdsamount").prop("disabled", true); $(".number_tdstaxrate").prop("disabled", true); $('#chk_excludefromcampaign').prop('checked', false); $(".txt_gstno").prop("disabled", true); $(".section_InvoiceAmount .card-header").first().text('Amount'); $(".hrefSection_MoreOptions").click(function () { if ($(".hrefSection_MoreOptions").text() == 'Less Options') { $(".hrefSection_MoreOptions").text('More Options'); $(".section_AdvancedOptions").addClass("hidden"); } else if ($(".hrefSection_MoreOptions").text() == 'More Options') { $(".hrefSection_MoreOptions").text('Less Options'); $(".section_AdvancedOptions").removeClass("hidden"); } }); if (Unibase.Platform.Membership.Infos.Identity.getCurrentUser().settings == null) { $(".txtAutoComplete_orgcontactid").prop("disabled", true); MessageHelper.Instance().showError("Please Configure Default Branch", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } else if (Unibase.Platform.Membership.Infos.Identity.getSetting("companyid") == null || Unibase.Platform.Membership.Infos.Identity.getSetting("companyid") == undefined) { $(".txtAutoComplete_orgcontactid").prop("disabled", true); MessageHelper.Instance().showError("Please Configure Default Branch", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } else { var companyId = Number(Unibase.Platform.Membership.Infos.Identity.getSetting("companyid")); if ($(".hdn_invoicetypeid").val() != "6" && $(".hdn_invoicetypeid").val() != "7") { var Parameters = [{ "ColumnName": "companyid", "Value": companyId }]; Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_orgcontactid"), Parameters); } } if ($(".hdn_invoiceid").val() == 0 && InvoiceItem.Instance().orderid == 0 && InvoiceItem.Instance().dcid == 0) { $(".txtAutoComplete_orgcontactid").change(function () { var orgid = Number($(".hfAutoCompleteId_orgcontactid").val()); if (orgid > 0) { if ($(".section_Details").hasClass('hidden')) { $(".section_Details").removeClass('hidden'); } if ($(".section_ItemDetails").hasClass('hidden')) { $(".section_ItemDetails").removeClass('hidden'); } if ($(".section_InvoiceAmount").hasClass('hidden')) { $(".section_InvoiceAmount").removeClass('hidden'); } if ($(".section_Description").hasClass('hidden')) { $(".section_Description").removeClass('hidden'); } if ($(".section_BillingAndShippingDetails").hasClass('hidden')) { $(".section_BillingAndShippingDetails").removeClass('hidden'); } if ($(".section_Wallets").hasClass('hidden')) { $(".section_Wallets").removeClass("hidden"); } if ($(".section_TCS").hasClass('hidden')) { $(".section_TCS").removeClass("hidden"); } var organiztionid = $(".hfAutoCompleteId_orgcontactid").val(); if (organiztionid != 0 && organiztionid != undefined && organiztionid != -1) { InvoiceItem.Instance().LoadContactDetails(); } $("#btn_Save").removeClass('hidden'); var VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1]; $("#" + VisibleContainerId).find(".btn_Save_Form").removeClass("hidden"); } }); } $('.dropdown_istaxinclusive').change(function () { var invItems = InvoiceItem.Instance().getInvoiceItems(); InvoiceItem.Instance().update_total(); InvoiceItem.Instance().TotalAdjustment(); }); if (Unibase.Platform.Membership.Infos.Identity.getCurrentUser().isAdmin == true) { InvoiceItem.Instance().ManageInvoice = 2; InvoiceItem.Instance().ManageInvoiceTax = 2; } else { Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().GetInvoicePermissions(Number($(".hdn_invoicetypeid").val())).then(function (response) { if (response.result.length > 0) { for (var i = 0; i < response.result.length; i++) { if (response.result[i].SettingName == Unibase.Platform.Apps.Enums.SettingType.Manage.toString()) { InvoiceItem.Instance().ManageInvoice = response.result[i].SettingValue; InvoiceItem.Instance().ManageInvoiceTax = response.result[i].SettingValue; } } } }); } if ($(".WalletItems").hasClass('show')) { $(".WalletItems").removeClass('show'); } let invoiceid = $(".hdn_invoiceid").val(); if (invoiceid == "0") { if (InvoiceItem.Instance().orderid != 0 || InvoiceItem.Instance().dcid != 0) InvoiceItem.Instance().getDcDetails(); $('#txt_Adjustment').keypress(function (event) { if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8) || (event.which == 45)) { } else { event.preventDefault(); } }).on('paste', function (event) { event.preventDefault(); }); } else { InvoiceItem.Instance().bindEditInvoiceDetails(invoiceid); } $('#change_taxgroup').change(function () { if ($('#change_taxgroup option:selected').val() != undefined && $('#change_taxgroup option:selected').val() != 0) { for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) { InvoiceItem.Instance().SplitedInvoiceItemList[i].taxGroupId = Number($('#change_taxgroup option:selected').val()); Controls.Invoices.SplitItem.Instance().update_TaxPercentage($('#change_taxgroup option:selected').val()); } $(".InvoiceItems").find(".item-row").each(function () { if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) { var TaxGroupId = Number($('#change_taxgroup option:selected').val()); var txtTaxGroup = $(this).find(".prodTax"); var hfProdTax = $(this).find(".hfProdTax"); hfProdTax.val(TaxGroupId); txtTaxGroup.empty(); txtTaxGroup.append(new Option($('#change_taxgroup option:selected').text(), TaxGroupId.toString(), true)); if (hfProdTax.val() != '') InvoiceItem.Instance().update_tax($(this), hfProdTax.val()); } }); } }); } addNetDiscountRow() { InvoiceItem.Instance().adddiscountrow(null, "", "", true); } getDcDetails() { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/invoicemanager.js", function () { var VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1]; $("#" + VisibleContainerId).find(".btn_Save_Form").removeClass("hidden"); $("#btn_Save").removeClass('hidden'); InvoiceItem.Instance().AutoDc = false; let url = ""; if (InvoiceItem.Instance().dcid != 0) { url = 'apis/v4/bizgaze/transact/dcs/getdc/dcid/' + InvoiceItem.Instance().dcid; } else { url = "apis/v4/bizgaze/transact/orders/getorderbyorderid/id/" + InvoiceItem.Instance().orderid; } Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getOrderDcDetails(url).then(function (response) { if (response.result != null) { if ($(".hdn_invoicetypeid").val() == "1") $("#div_FormName").text("Create Sales Invoice"); else if ($(".hdn_invoicetypeid").val() == "2") $("#div_FormName").text("Create Purchase Invoice"); if ($(".section_Details").hasClass('hidden')) { $(".section_Details").removeClass('hidden'); } if ($(".section_ItemDetails").hasClass('hidden')) { $(".section_ItemDetails").removeClass('hidden'); } if ($(".section_Ebs").hasClass('hidden')) { $(".section_Ebs").removeClass('hidden'); } if ($(".section_InvoiceAmount").hasClass('hidden')) { $(".section_InvoiceAmount").removeClass('hidden'); } if ($(".section_Description").hasClass('hidden')) { $(".section_Description").removeClass('hidden'); } if ($(".section_BillingAndShippingDetails ").hasClass('hidden')) { $(".section_BillingAndShippingDetails ").removeClass('hidden'); } if ($(".section_Wallets").hasClass('hidden')) { $(".section_Wallets").removeClass("hidden"); } if ($(".section_TCS").hasClass('hidden')) { $(".section_TCS").removeClass("hidden"); } let data = response.result; $(".txtAutoComplete_orgcontactid").empty(); if (data.OrgContactId == 0) { InvoiceItem.Instance().IswalkinCustomer = true; $(".hfAutoCompleteId_orgcontactid").val(data.OrganizationId); var selectedCompany = new Option(data.OrganizationName, data.OrganizationId, true); $(".txtAutoComplete_orgcontactid").append(selectedCompany); } else { InvoiceItem.Instance().IswalkinCustomer = false; $(".hfAutoCompleteId_orgcontactid").val(data.OrgContactId); var selectedCompany = new Option(data.OrganizationName + " - " + data.OrgContactName, data.OrgContactId, true); $(".txtAutoComplete_orgcontactid").append(selectedCompany); } if (data.CurrencyId != 0) { $(".hdn_currencyid").val(data.CurrencyId); $(".hdn_conversionrate").val(data.ConversionRate); } if (data.OrganizationId != 0) { $(".hdn_organizationid").val(data.OrganizationId); $("#hfInv_OrganizationName").val(data.OrganizationName); } else { Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getorgcontact(data.OrgContactId).then(function (response) { var data = response.result; if (response.result != null && data.OrganizationId != 0) { $(".hdn_organizationid").val(response.result.OrganizationId); $("#hfInv_OrganizationName").val(data.OrganizationName); } }); } $(".txt_gstno").val(response.result.GSTInNo); $(".txtAutoComplete_billfromaddressid").append(new Option(data.BillFromAddressName, data.BillFromAddressId, true)); $(".txtAutoComplete_shipfromaddressid").append(new Option(data.ShipFromAddressName, data.ShipFromAddressId, true)); if (InvoiceItem.Instance().orderid != 0 && InvoiceItem.Instance().dcid == 0) { $(".txtAutoComplete_billtoaddressid").append(new Option(data.BillingAddressName, data.BillingAddressId, true)); $(".txtAutoComplete_shiptoaddressid").append(new Option(data.ShippingAddressName, data.ShippingAddressId, true)); } else { $(".txtAutoComplete_billtoaddressid").append(new Option(data.BillToAddressName, data.BillToAddressId, true)); $(".txtAutoComplete_shiptoaddressid").append(new Option(data.ShipToAddressName, data.ShipToAddressId, true)); } if ((InvoiceItem.Instance().orderid != 0 || InvoiceItem.Instance().dcid != 0) && InvoiceItem.Instance().AutoDc == false) { $('.txtAutoComplete_billfromaddressid').prop('disabled', true); $('.txtAutoComplete_shipfromaddressid').prop('disabled', true); $('.txtAutoComplete_billtoaddressid').prop('disabled', true); $('.txtAutoComplete_shiptoaddressid').prop('disabled', true); } $(".txtAutoComplete_orgcontactid").prop('disabled', true); $('.hfAutoCompleteId_lobid').val(data.LobId); $('.txtAutoComplete_lobid').empty(); $('.txtAutoComplete_lobid').append(new Option(data.LobName, data.LobId, true)); $('.txtAutoComplete_lobid').prop('disabled', true); if (data.RefNo != "" && data.RefNo != null) { $(".txt_refno").val(data.RefNo); $(".div_refno").addClass("floating-label-form-group-with-value"); } else { $(".txt_refno").val(""); $(".div_refno").removeClass("floating-label-form-group-with-value"); } $('.txtAutoComplete_salespersonid').append(new Option(data.SalesPersonName, data.SalesPersonId, true)); $('.hfAutoCompleteId_salespersonid').val(data.SalesPersonId); if (InvoiceItem.Instance().orderid != 0 && InvoiceItem.Instance().orderid != undefined) { if (data.PaymentTermId != 0) { $('.hfAutoCompleteId_paymenttermid').val(data.PaymentTermId); $('.txtAutoComplete_paymenttermid').append(new Option(data.PaymentTermName, data.PaymentTermId, true)); InvoiceItem.Instance().LoadDueDays(); $(".txtAutoComplete_paymenttermid").prop('disabled', true); } $(".dropdown_paymentmethodid").val(data.PaymentMethodId); $(".dropdown_paymentmethodid").prop('disabled', true); if (data.BranchId != 0) $(".hdn_branchid").val(data.BranchId); $(".dropdown_istaxinclusive").val(data.IsTaxInclusive.toString()); $(".dropdown_istaxinclusive").prop('disabled', true); } if (data.Description != null && data.Description != "") $(".divCustomProperties_systemnotes").find("textarea").val(data.Description); else $(".divCustomProperties_systemnotes").find("textarea").val(""); $("#txt_AdjustmentAccountName").empty(); $("#hf_AdjustmentAccountId").val("0"); var Addr = $(".txtAutoComplete_billtoaddressid option:selected").val(); if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6") Addr = $(".txtAutoComplete_billfromaddressid option:selected").val(); InvoiceItem.Instance().bindSeries($(".txtAutoComplete_lobid option:selected").val(), Addr); InvoiceItem.Instance().bindAdjustmentAccount(data.LobId, Addr); InvoiceItem.Instance().getGSTNo(); var Address = $(".txtAutoComplete_billtoaddressid option:selected").val(); if ($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "7") Address = $(".txtAutoComplete_billfromaddressid option:selected").val(); Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () { Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getAddressByContactId(Address).then(function (response) { if (response.result != null) { if (response.result.GSTNO != "" && response.result.GSTNO != null) $(".txt_gstno").val(response.result.GSTNO); } }); }); if ((data.OrderId == 0 || data.OrderId == undefined) && (InvoiceItem.Instance().dcid != 0 && InvoiceItem.Instance().dcid != undefined)) { InvoiceItem.Instance().bindDefaultPaymentTerm(data.OrganizationId, data.LobId); } if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "7") && $("#chk_tcsapplied").val() != undefined) { $("#div_tcstaxrate").addClass("hidden"); $(".div_tcsadjustment").addClass("hidden"); $("#div_tcsamount").addClass("hidden"); $(".number_tcsamount").prop("disabled", true); InvoiceItem.Instance().GetCustomerTurnOver(); } InvoiceItem.Instance().GetAvailableWallets(0); InvoiceItem.Instance().loadOrderPendingItems(); InvoiceItem.Instance().IsCustomerIndustrial(data.LobId, data.OrganizationId); } }); }); } bindSeries(lobid, branchid) { Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getSeries($("#hf_FormInstalledAppId").val(), branchid, lobid).then(function (response) { if (response.result != null) { var seriesData = []; if (response.result.length > 0) { $(".txtSeriesAutoComplete_seriesid").empty(); for (let s = 0; s < response.result.length; s++) { let Series = response.result[s]; seriesData.push({ id: Series.SeriesId, text: Series.SeriesName, AddlData: Series.ManualNumbering }); } $('.txtSeriesAutoComplete_seriesid').select2({ data: seriesData, }); $(".txtSeriesAutoComplete_seriesid").val(response.result[0].SeriesId).trigger("change"); } else { Unibase.Platform.Series.Managers.SeriesManager.Instance().getActiveSeries(0, Number($("#hf_FormInstalledAppId").val())).then(function (response) { var data = response.result; if (data != null) { if (data.length != 0) { $(".txtSeriesAutoComplete_seriesid").empty(); for (var s = 0; s < data.length; s++) { let Series = data[s]; seriesData.push({ id: Series.SeriesId, text: Series.SeriesName, AddlData: Series.ManualNumbering }); } $('.txtSeriesAutoComplete_seriesid').select2({ data: seriesData, }); $(".txtSeriesAutoComplete_seriesid").val(data[0].SeriesId).trigger("change"); } } }); } } else { Unibase.Platform.Series.Managers.SeriesManager.Instance().getActiveSeries(0, Number($("#hf_FormInstalledAppId").val())).then(function (response) { var data = response.result; if (data != null) { if (data.length != 0) { $(".txtSeriesAutoComplete_seriesid").empty(); for (var s = 0; s < data.length; s++) { var Series = new Option(data[s].SeriesName, data[s].SeriesId.toString(), true); $(".txtSeriesAutoComplete_seriesid").append(Series); $(".txtSeriesAutoComplete_seriesid").val(data[s].SeriesId); } $(".txtSeriesAutoComplete_seriesid").val(data[0].SeriesId); } } }); } }); } bindAdjustmentAccount(lobid, branchid) { $('#hf_AdjustmentAccountId').val("0"); $('#txt_AdjustmentAccountName').empty(); Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/ledgers/ledgermanager.js", function () { Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().getLobLedgerSetting(lobid, branchid).then(function (response) { if (response.result != null && response.result != "") { $("#txt_AdjustmentAccountName").append(new Option(response.result.LedgerName, response.result.SettingValue1, true)); $("#hf_AdjustmentAccountId").val(response.result.SettingValue1); $("#txt_AdjustmentAccountName").val(response.result.SettingValue1); } }); }); } bindDefaultPaymentTerm(organizationid, lobid) { $('.hfAutoCompleteId_paymenttermid').val(0); $('.txtAutoComplete_paymenttermid').empty(); Bizgaze.Apps.Transact.Managers.PaymentTermManager.Instance().getPaymentTermByOrg(organizationid, lobid).then(function (response) { var paymentterm = response.result; if (paymentterm != null && paymentterm != "") { $('.hfAutoCompleteId_paymenttermid').val(paymentterm.PaymentTermId); $('.txtAutoComplete_paymenttermid').append(new Option(paymentterm.PaymentTermName, paymentterm.PaymentTermId, true)); if (paymentterm.DueDays != null && paymentterm.DueDays > 0) { var from = $('.date_journaldate').val().toString().split("/"); var f = new Date(Number(from[2]), Number(from[1]) - 1, Number(from[0])); var currentdate = f.setDate(f.getDate() + paymentterm.DueDays); $('.date_duedate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(currentdate, "")); let date = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(currentdate), ""); var tdate = moment(date, "DD/MM/YYYY").format("YYYY/MM/DD"); $('.hfdate_duedate').val(tdate); } } }); } LoadContactDetails() { Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getorganization($(".hfAutoCompleteId_orgcontactid").val()).then(function (response) { if (response.result != null && response.result != "") { if (response.result.CurrencyId != 0) { $(".hdn_currencyid").val(response.result.CurrencyId); $(".hdn_conversionrate").val(response.result.ConversionRate); } if (response.result.OrganizationTypeId == 1) InvoiceItem.Instance().IswalkinCustomer = false; else InvoiceItem.Instance().IswalkinCustomer = true; InvoiceItem.Instance().LoadSpocDetails($(".hfAutoCompleteId_orgcontactid").val()); } else { InvoiceItem.Instance().IswalkinCustomer = false; InvoiceItem.Instance().LoadSpocDetails($(".hfAutoCompleteId_orgcontactid").val()); } }); } LoadSpocDetails(contactid) { if ($('.hdn_invoicetypeid').val() == "1" || $('.hdn_invoicetypeid').val() == "6" || $('.hdn_invoicetypeid').val() == "4") { $('.txtAutoComplete_billtoaddressid').empty(); $('.txtAutoComplete_shiptoaddressid').empty(); } else { $('.txtAutoComplete_billfromaddressid').empty(); $('.txtAutoComplete_shipfromaddressid').empty(); } if ($(".hdn_invoiceid").val() == "0") { $(".txtAutoComplete_LobId").empty(); $(".hfAutoCompleteId_LobId").empty(); } $(".txtAutoComplete_salespersonid").empty(); $(".hfAutoCompleteId_salespersoid").empty(); if (InvoiceItem.Instance().IswalkinCustomer == true) { Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getorganization(contactid).then(function (response) { if (response.result != null) { $(".hdn_organizationid").val(response.result.OrganizationId); $("#hfInv_OrganizationName").val(response.result.OrganizationName); if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "7") && $("#chk_tcsapplied").val() != undefined) { InvoiceItem.Instance().GetCustomerTurnOver(); } $.when(InvoiceItem.Instance().loadAddressAutoCompletes(response.result.OrganizationId)).then(function () { InvoiceItem.Instance().BindAddressDetails(response.result.OrganizationId); InvoiceItem.Instance().GetAvailableWallets(0); }); } }); } else { Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getorgcontact(contactid).then(function (response) { var data = response.result; if (response.result != null && data.OrganizationId != 0) { $(".hdn_organizationid").val(response.result.OrganizationId); $("#hfInv_OrganizationName").val(data.OrganizationName); if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "7") && $("#chk_tcsapplied").val() != undefined) { InvoiceItem.Instance().GetCustomerTurnOver(); } $.when(InvoiceItem.Instance().loadAddressAutoCompletes(response.result.OrganizationId)).then(function () { InvoiceItem.Instance().BindAddressDetails(response.result.OrganizationId); InvoiceItem.Instance().GetAvailableWallets(0); }); } }); } } GetJournalAlloc(invoiceId) { Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getJournalAllocs(invoiceId).then(function (response) { if (response.result.length > 0) $(".txtAutoComplete_orgcontactid").prop("disabled", true); }); } formatDate(date) { var datearray = date.split("/"); var newdate = datearray[1] + '/' + datearray[0] + '/' + datearray[2]; var d = new Date(newdate), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear(); if (month.length < 2) month = '0' + month; if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; return [year, month, day].join('-'); } GetAvailableWallets(invoiceid) { var ContactId = $(".hdn_organizationid").val(); var invoiceId = 0; if (invoiceid != 0 && $('#hfInv_IsRetun').val() != "1") { invoiceId = Number($(".hdn_invoiceid").val()); } if (invoiceId != 0) InvoiceItem.Instance().GetJournalAlloc(invoiceId); var invoicedate = $('.date_journaldate').val(); var invdate = InvoiceItem.Instance().formatDate(invoicedate); var lobId = $(".txtAutoComplete_lobid").val(); if (lobId == null || lobId == undefined) lobId = 0; Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getJournalWallets(invdate, invoiceId, ContactId, Number($(".hdn_invoicetypeid").val()), lobId).then(function (response) { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/controls/payments/wallet.component.js", function () { if (response.result != null) { Bizgaze.Apps.Transact.Controls.Wallet.Instance().loadInvoiceWallets(response.result); } }); }); } BindAddressDetails(orgid) { let branchid = Number(Unibase.Platform.Membership.Infos.Identity.getSetting("branchid")); Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getbranche(branchid).then(function (responce) { if (responce.result != null) { if (responce.result.DefaultWarehouseId != 0) var ShipTo = new Option(responce.result.DefaultWarehouseName, responce.result.DefaultWarehouseId, true); else var ShipTo = new Option(responce.result.BranchName, responce.result.BranchId, true); var BillTo = new Option(responce.result.BranchName, responce.result.BranchId, true); if ($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "7") { $(".txtAutoComplete_shiptoaddressid").append(ShipTo); $(".txtAutoComplete_billtoaddressid").append(BillTo); $(".txtAutoComplete_billtoaddressid").change(function () { InvoiceItem.Instance().bindSeries($(".txtAutoComplete_lobid").val(), $(".txtAutoComplete_billtoaddressid").val()); InvoiceItem.Instance().bindAdjustmentAccount($(".txtAutoComplete_lobid").val(), responce.result.BranchId); }); } else { $(".txtAutoComplete_shipfromaddressid").append(ShipTo); $(".txtAutoComplete_billfromaddressid").append(BillTo); $(".txtAutoComplete_billfromaddressid").change(function () { InvoiceItem.Instance().bindSeries($(".txtAutoComplete_lobid").val(), $(".txtAutoComplete_billfromaddressid").val()); InvoiceItem.Instance().bindAdjustmentAccount($(".txtAutoComplete_lobid").val(), responce.result.BranchId); }); } } }); this.fileCacheHelper.loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () { Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getAddressByContactId(orgid).then(function (response) { if (response.result != null && response.result != "") { var ShipTo = new Option(response.result.AddressName, response.result.ContactAddressId, true); var BillTo = new Option(response.result.AddressName, response.result.ContactAddressId, true); if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "4") { $(".txtAutoComplete_shiptoaddressid").append(ShipTo); $(".txtAutoComplete_billtoaddressid").append(BillTo); $(".txtAutoComplete_billtoaddressid").change(function () { $.when(InvoiceItem.Instance().loadLobAndSp()).then(function () { InvoiceItem.Instance().BindLoB(); }); }); InvoiceItem.Instance().getGSTNo(); } else { $(".txtAutoComplete_shipfromaddressid").append(ShipTo); $(".txtAutoComplete_billfromaddressid").append(BillTo); $(".txtAutoComplete_billfromaddressid").change(function () { $.when(InvoiceItem.Instance().loadLobAndSp()).then(function () { InvoiceItem.Instance().BindLoB(); }); }); InvoiceItem.Instance().getGSTNo(); } if (response.result.GSTNO != "" && response.result.GSTNO != null) $(".txt_gstno").val(response.result.GSTNO); $.when(InvoiceItem.Instance().loadLobAndSp()).then(function () { InvoiceItem.Instance().BindLoB(); }); } else { MessageHelper.Instance().showError("Please assign billing address and shipping address", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); } }); }); } getGSTNo() { var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId; var gstno = $(".txt_gstno").val(); if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length > 0 && Number($(".hdn_invoiceid").val()) != 0) { gstno = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_gstno").Value; } $(".txt_gstno").parent().addClass("floating-label-form-group-with-value"); if (gstno != null && gstno != "") { $(".txt_gstno").val(gstno); } else $(".txt_gstno").val("GSTIN not Assigned"); if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "4") { $(".txtAutoComplete_billtoaddressid").change(function () { Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getAddressById(Number($(".txtAutoComplete_billtoaddressid").val())).then(function (ress) { if (ress.result != null) { if (ress.result.GSTNO != "" && ress.result.GSTNO != null) $(".txt_gstno").val(ress.result.GSTNO); } }); }); } else { $(".txtAutoComplete_billfromaddressid").change(function () { Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getAddressById(Number($(".txtAutoComplete_billfromaddressid").val())).then(function (ress) { if (ress.result != null) { if (ress.result.GSTNO != "" && ress.result.GSTNO != null) $(".txt_gstno").val(ress.result.GSTNO); } }); }); } } loadLobAndSp() { var AddressId = $(".txtAutoComplete_billfromaddressid option:selected").val(); if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "4") AddressId = $(".txtAutoComplete_billtoaddressid option:selected").val(); var lobParameters = [{ "ColumnName": "contactaddressid", "Value": AddressId, }]; Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_lobid"), lobParameters); Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/orders/ordermanager.js", function () { var SpParameters = [{ "ColumnName": "contactaddressid", "Value": AddressId, }]; Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_salespersonid"), null); }); } BindLoB() { $(".txtAutoComplete_lobid").empty(); $('#hf_AdjustmentAccountId').val("0"); $('#txt_AdjustmentAccountName').empty(); if ($(".hdn_invoiceid").val() == "0") { $(".InvoiceItems").find(".item-addedrow").remove(); InvoiceItem.Instance().SplitedInvoiceItemList = new Array(); InvoiceItem.Instance().itemIds = [0]; InvoiceItem.Instance().dcItemIds = [0]; $("#txt_Adjustment").val("0"); $("#span_Adjustment").text("0"); InvoiceItem.Instance().update_total(); InvoiceItem.Instance().TotalAdjustment(); } var AddressId = $(".txtAutoComplete_billfromaddressid option:selected").val(); if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6") AddressId = $(".txtAutoComplete_billtoaddressid option:selected").val(); this.fileCacheHelper.loadJsFile("apps/crm/lobs/managers/lobmanager.js", function () { if (AddressId == undefined) { AddressId = 0; } Bizgaze.Apps.CRM.Lobs.Managers.LobManager.Instance().getLobsByAddressId(Number(AddressId)).then(function (response) { if (response.message != '') { Unibase.Platform.Forms.Components.FormViewer.Instance().showError(response.message); } if (response.result != "" && response.result != null) { if (response.result.length == 1) { var LoB = new Option(response.result[0].LobName, response.result[0].LobId, true); $(".txtAutoComplete_lobid").append(LoB); $(".txtAutoComplete_lobid").val(response.result[0].LobId); InvoiceItem.Instance().BindSalesPerson(AddressId); InvoiceItem.Instance().bindDefaultPaymentTerm($(".hdn_organizationid").val(), response.result[0].LobId); var Addr = $(".txtAutoComplete_billtoaddressid option:selected").val(); if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6") Addr = $(".txtAutoComplete_billfromaddressid option:selected").val(); InvoiceItem.Instance().bindSeries($(".txtAutoComplete_lobid option:selected").val(), Addr); InvoiceItem.Instance().bindAdjustmentAccount(response.result[0].LobId, Addr); } } }); }); $(".txtAutoComplete_lobid").change(function () { InvoiceItem.Instance().bindDefaultPaymentTerm($(".hdn_organizationid").val(), $(".txtAutoComplete_lobid option:selected").val()); var Address = $(".txtAutoComplete_billtoaddressid option:selected").val(); var Billto = $(".txtAutoComplete_billfromaddressid option:selected").val(); if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6") { Address = $(".txtAutoComplete_billfromaddressid option:selected").val(); Billto = $(".txtAutoComplete_billtoaddressid option:selected").val(); } InvoiceItem.Instance().BindSalesPerson(Billto); InvoiceItem.Instance().bindSeries($(".txtAutoComplete_lobid option:selected").val(), Address); InvoiceItem.Instance().bindAdjustmentAccount($(".txtAutoComplete_lobid option:selected").val(), Address); $(".InvoiceItems").find(".item-addedrow").remove(); InvoiceItem.Instance().SplitedInvoiceItemList = new Array(); InvoiceItem.Instance().itemIds = [0]; InvoiceItem.Instance().dcItemIds = [0]; $("#txt_Adjustment").val("0"); InvoiceItem.Instance().update_total(); InvoiceItem.Instance().TotalAdjustment(); InvoiceItem.Instance().GetAvailableWallets(0); }); } BindSalesPerson(AddressId) { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () { Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getManagerDetails(Number($(".txtAutoComplete_lobid option:selected").val()), AddressId).then(function (response) { if (response.result != null) { var SalesPerson = new Option(response.result.ManagerName, response.result.EmployeeId, true); $(".txtAutoComplete_salespersonid").empty(); $(".txtAutoComplete_salespersonid").append(SalesPerson); $(".txtAutoComplete_salespersonid").val(response.result.EmployeeId); } else { $(".txtAutoComplete_salespersonid").empty(); $(".txtAutoComplete_salespersonid").val(0); $(".txtAutoComplete_salespersonid").text(""); } }); }); } LoadDueDays() { if (InvoiceItem.Instance().dcid != 0 && InvoiceItem.Instance().AutoDc == false && InvoiceItem.Instance().OrderSettingId != 2) { var invdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerDate($('.date_journaldate').val()); if (InvoiceItem.Instance().DcDate != undefined) { var date = InvoiceItem.Instance().DcDate.toString(); var dcdate = moment(date, "DD/MM/YYYY").format("YYYY/MM/DD"); if (invdate < dcdate) { var dctext = "DC"; if ($('.hdn_invoicetypeid').val() == "2") dctext = "GRN"; MessageHelper.Instance().showError("Invoice Date should not be less than " + dctext + " Date", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); } } } Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/paymentterms/paymenttermmanager.js", function () { Bizgaze.Apps.Transact.Managers.PaymentTermManager.Instance().getPaymentTerm(Number($('.hfAutoCompleteId_paymenttermid').val())).then(function (result) { if (result.result != null) { if (result.result.DueDays > 0) { if ($('.date_journaldate').val() == "") { let todaydate = Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate(); $('.date_duedate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(todaydate), "")); $('.hfdate_duedate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(todaydate), "")); } else { var from = $('.date_journaldate').val().toString().split('/'); var f = new Date(Number(from[2]), Number(from[1]) - 1, Number(from[0])); var currentdate = f.setDate(f.getDate() + result.result.DueDays); var currentdate1 = f.setDate(f.getDate() + result.result.DueDays + 1); $('.date_duedate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(currentdate), "")); let date = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(currentdate), ""); var tdate = moment(date, "DD/MM/YYYY").format("YYYY/MM/DD"); $('.hfdate_duedate').val(tdate); } } } }); }); } loadAddressAutoCompletes(organizationid) { var ToAddressParameters = [{ "ColumnName": "contactid", "Value": organizationid, }]; let invoicetypeid = $(".hdn_invoicetypeid").val(); if (invoicetypeid == "1" || invoicetypeid == "4" || invoicetypeid == "6") { Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_billtoaddressid"), ToAddressParameters); Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_shiptoaddressid"), ToAddressParameters); $(".txtAutoComplete_billtoaddressid").change(function () { if (Number($(".hdn_invoiceid").val()) == 0) { $.when(InvoiceItem.Instance().loadLobAndSp()).then(function () { InvoiceItem.Instance().BindLoB(); }); } }); } else { Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_billfromaddressid"), ToAddressParameters); Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_shipfromaddressid"), ToAddressParameters); $(".txtAutoComplete_billfromaddressid").change(function () { $.when(InvoiceItem.Instance().loadLobAndSp()).then(function () { InvoiceItem.Instance().BindLoB(); }); }); } var FromAddressParameters = [{ "ColumnName": "companyid", "Value": Number(Unibase.Platform.Membership.Infos.Identity.getSetting("companyid")) }]; if (invoicetypeid == "1" || invoicetypeid == "4" || invoicetypeid == "6") { Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_billfromaddressid"), FromAddressParameters); Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_shipfromaddressid"), FromAddressParameters); } else { Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_billtoaddressid"), FromAddressParameters); Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_shiptoaddressid"), FromAddressParameters); } } loadControlSettings(controlsettingjson, formpropertyid) { var instance = InvoiceItem.Instance(); $("#btnInvoiceItem").off().click(function () { let lobid = $(".hfAutoCompleteId_lobid").val(); if (lobid == undefined || lobid == "" || lobid == "0") { MessageHelper.Instance().showError("Please Select LoB", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } else InvoiceItem.instance.addRow(); }); $("#btndiscountItem").off().click(function () { InvoiceItem.Instance().adddiscountrow(null, "", "", false); }); instance.itemIds = new Array(); instance.dcItemIds = new Array(); instance.itemIds.push(0); instance.dcItemIds.push(0); instance.SplitedInvoiceItemList = new Array(); instance.deleted_invoiceItems = new Array(); instance.invItemTaxAdjustmentList = new Array(); instance.AutoDc = false; instance.OrderSettingId = 0; instance.orderid = 0; instance.dcid = 0; instance.IswalkinCustomer = false; $('.inv_hdnfiels').empty(); var d = "
"; $(".section_CompanyDetails").prepend(d); var hiddenfileds = "" + "" + ""; $('.inv_hdnfiels').append(hiddenfileds); $(".hdn_branchid").val(Unibase.Platform.Membership.Infos.Identity.getSetting("branchid")); var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId; for (let obj of Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters) { if (obj.Key === "hf_" + InstalledAppId + "_orderid") { InvoiceItem.Instance().orderid = Number(Number(obj.Value)); $(".hdn_orderid").val(Number(obj.Value)); if (Number(obj.Value) != 0) { for (let ob of Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters) { if (ob.Key === "hf_" + InstalledAppId + "_branchid") $(".hdn_branchid").val(ob.Value); } } } if (obj.Key === "hf_" + InstalledAppId + "_dcid") { InvoiceItem.instance.dcid = Number(obj.Value); $(".hdn_dcid").val(Number(obj.Value)); } if (obj.Key === "hf_" + InstalledAppId + "_claimid") { InvoiceItem.instance.ClaimId = Number(obj.Value); } if (obj.Key === "hf_" + InstalledAppId + "_dcdate") { InvoiceItem.instance.DcDate = obj.Value; } } if ((InvoiceItem.instance.dcid == 0 || InvoiceItem.instance.dcid == undefined) && (InvoiceItem.instance.dcid == 0 || InvoiceItem.instance.dcid == undefined)) { instance.AutoDc = true; } InvoiceItem.Instance().invoiceinit(); $("#txt_taxAajustment").blur(function () { InvoiceItem.Instance().update_total(); InvoiceItem.Instance().TotalAdjustment(); }); $("#txt_assessableadjustment").blur(function () { InvoiceItem.Instance().update_total(); InvoiceItem.Instance().TotalAdjustment(); }); $(document).ready(function (e) { if (Number($("#hf_pk_value").val()) != 0 && $("#chk_tdsapplied").is(":checked")) { $(".divCustomProperties_tdstaxcodeid").removeClass('hidden'); $(".divCustomProperties_tdstaxrate").removeClass('hidden'); $(".divCustomProperties_tdsamount").removeClass('hidden'); } else { $(".divCustomProperties_tdstaxcodeid").addClass('hidden'); $(".divCustomProperties_tdstaxrate").addClass('hidden'); $(".divCustomProperties_tdsamount").addClass('hidden'); } $("#chk_tdsapplied").removeAttr("onclick"); $("#chk_tdsapplied").change(function () { if ($(this).prop('checked') == false) { $(".txtAutoComplete_tdstaxcodeid").val(0); $(".txtAutoComplete_tdstaxcodeid").text(""); $(".number_tdstaxrate").val(0); $(".divCustomProperties_tdstaxcodeid").addClass('hidden'); $(".divCustomProperties_tdstaxrate").addClass('hidden'); $(".divCustomProperties_tdsamount").addClass('hidden'); $("#chk_tcsapplied").removeAttr("disabled"); $("#hdnchk_tdsapplied").val("false"); } else { $("#div_tcstaxrate").addClass("hidden"); $(".div_tcsadjustment").addClass("hidden"); $("#div_tcsamount").addClass("hidden"); $('#chk_tcsapplied').prop('checked', false); $('#chk_tcsapplied').attr('disabled', "true"); $(".divCustomProperties_tdstaxcodeid").removeClass('hidden'); $(".divCustomProperties_tdstaxrate").removeClass('hidden'); $(".divCustomProperties_tdsamount").removeClass('hidden'); $("#chk_tcsapplied").attr("disabled"); $("#hdnchk_tdsapplied").val("true"); } InvoiceItem.Instance().update_total(); }); $(".txtAutoComplete_tdstaxcodeid").change(function () { $(".number_tdstaxrate").val(Number($(".txtAutoComplete_tdstaxcodeid").attr('data-addldata'))); InvoiceItem.Instance().update_total(); }); }); } loadPropertySettings(propertysettings, formpropertyid) { } bindEditFormDetails(formpropertyid, propval, DocPropertyName) { } bindEditInvoiceDetails(invoiceid) { var VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1]; $("#" + VisibleContainerId).find(".btn_Save_Form").removeClass("hidden"); if ($('.hdn_invoicetypeid').val() == "1" && $("#hf_AppSettingName").val() == "Create Return") { $('#hfInv_IsRetun').val(1); $('.hdn_invoicetypeid').val("3"); $(".txtSeriesAutoComplete_seriesid").prop("disabled", false); $("#div_FormName").text("Create Sales Return"); $(".txtAutoComplete_orgcontactid").prop("disabled", true); $(".hdn_journalno").val(0); } else if ($('.hdn_invoicetypeid').val() == "2" && $("#hf_AppSettingName").val() == "Create Return") { $('#hfInv_IsRetun').val(1); $('.hdn_invoicetypeid').val("4"); $(".txtSeriesAutoComplete_seriesid").prop("disabled", false); $("#div_FormName").text("Create Purchase Return"); $(".txtAutoComplete_orgcontactid").prop("disabled", true); $(".hdn_journalno").val(0); } let invoicetypeid = $('.hdn_invoicetypeid').val(); Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/invoicemanager.js", function () { Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceDetails(invoiceid).then(function (result) { var data = result.result; var companyId = Number(Unibase.Platform.Membership.Infos.Identity.getSetting("companyid")); var Parameters = []; if ($(".hdn_invoicetypeid").val() != "6" && $(".hdn_invoicetypeid").val() != "7") Parameters = [{ "ColumnName": "companyid", "Value": companyId }]; Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_orgcontactid"), Parameters); InvoiceItem.Instance().AutoDc = data.AutoDc; if (data.OrgContactId == 0) { InvoiceItem.Instance().IswalkinCustomer = true; $(".hfAutoCompleteId_orgcontactid").val(data.OrganizationId); var selectedCompany = new Option(data.OrganizationName, data.OrganizationId, true); } else { InvoiceItem.Instance().IswalkinCustomer = false; if (data.OrgContactName == null) data.OrgContactName = ""; $(".hfAutoCompleteId_orgcontactid").val(data.OrgContactId); var selectedCompany = new Option(data.OrganizationName + " - " + data.OrgContactName, data.OrgContactId, true); } $(".txtAutoComplete_orgcontactid").empty(); $(".txtAutoComplete_orgcontactid").append(selectedCompany); if ($(".section_Details").hasClass('hidden')) { $(".section_Details").removeClass('hidden'); } if ($(".section_ItemDetails").hasClass('hidden')) { $(".section_ItemDetails").removeClass('hidden'); } if ($(".section_Ebs").hasClass('hidden')) { $(".section_Ebs").removeClass('hidden'); } if ($(".section_InvoiceAmount").hasClass('hidden')) { $(".section_InvoiceAmount").removeClass('hidden'); } if ($(".section_Description").hasClass('hidden')) { $(".section_Description").removeClass('hidden'); } if ($(".section_BillingAndShippingDetails").hasClass('hidden')) { $(".section_BillingAndShippingDetails").removeClass('hidden'); } if ($(".section_Wallets").hasClass('hidden')) { $(".section_Wallets").removeClass("hidden"); } if ($(".section_TCS").hasClass('hidden')) { $(".section_TCS").removeClass("hidden"); } $("#btn_Save").removeClass('hidden'); $(".txtAutoComplete_lobid").prop("disabled", true); $(".txtAutoComplete_orgcontactid").prop("disabled", true); if ($('#hfInv_IsRetun').val() == "1" && ($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4")) { let todaydate = Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate(); $('.date_journaldate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(todaydate), "")); var tdate = moment(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(todaydate), ""), "DD/MM/YYYY").format("YYYY/MM/DD"); $('.hfdate_journaldate').val(tdate); $('.date_duedate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(todaydate), "")); $('.hfdate_duedate').val(tdate); InvoiceItem.Instance().LoadDueDays(); } else { $('.date_journaldate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(data.InvoiceDate, "")); let date = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(data.InvoiceDate), ""); var tdate = moment(date, "DD/MM/YYYY").format("YYYY/MM/DD"); $('.hfdate_journaldate').val(tdate); $('.date_duedate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(data.DueDate, "")); var date1 = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(data.DueDate), ""); tdate = moment(date1, "DD/MM/YYYY").format("YYYY/MM/DD"); $('.hfdate_duedate').val(tdate); } $('.date_refdate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(data.RefDate, "")); date1 = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(data.RefDate), ""); tdate = moment(date1, "DD/MM/YYYY").format("YYYY/MM/DD"); $('.hfdate_refdate').val(tdate); $.when(Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().loadAddressAutoCompletes(data.OrganizationId)).then(function (response) { $(".txtAutoComplete_billfromaddressid").empty(); $(".txtAutoComplete_billtoaddressid").empty(); $(".txtAutoComplete_shiptoaddressid").empty(); $(".txtAutoComplete_shipfromaddressid").empty(); if ($('.hdn_invoicetypeid').val() == "1" || $('.hdn_invoicetypeid').val() == "4" || $('.hdn_invoicetypeid').val() == "6") { $(".hfAutoCompleteId_billfromaddressid").val(data.BillFromAddressId); $(".txtAutoComplete_billfromaddressid").append(new Option(data.BillFromAddressName, data.BillFromAddressId, true)); $(".hfAutoCompleteId_billtoaddressid").val(data.BillToAddressId); $(".txtAutoComplete_billtoaddressid").append(new Option(data.BillToAddressName, data.BillToAddressId, true)); $(".hfAutoCompleteId_shiptoaddressid").val(data.ShipToAddressId); $(".txtAutoComplete_shiptoaddressid").append(new Option(data.ShipToAddressName, data.ShipToAddressId, true)); $(".hfAutoCompleteId_shipfromaddressid").val(data.ShipFromAddressId); $(".txtAutoComplete_shipfromaddressid").append(new Option(data.ShipFromAddressName, data.ShipFromAddressId, true)); } else { $(".hfAutoCompleteId_billfromaddressid").val(data.BillToAddressId); $(".txtAutoComplete_billfromaddressid").append(new Option(data.BillToAddressName, data.BillToAddressId, true)); $(".hfAutoCompleteId_billtoaddressid").val(data.BillFromAddressId); $(".txtAutoComplete_billtoaddressid").append(new Option(data.BillFromAddressName, data.BillFromAddressId, true)); $(".hfAutoCompleteId_shiptoaddressid").val(data.ShipFromAddressId); $(".txtAutoComplete_shiptoaddressid").append(new Option(data.ShipFromAddressName, data.ShipFromAddressId, true)); $(".hfAutoCompleteId_shipfromaddressid").val(data.ShipToAddressId); $(".txtAutoComplete_shipfromaddressid").append(new Option(data.ShipToAddressName, data.ShipToAddressId, true)); } InvoiceItem.Instance().loadLobAndSp(); InvoiceItem.Instance().getGSTNo(); $('.txtAutoComplete_lobid').empty(); $(".txtAutoComplete_lobid").append(new Option(data.LobName, data.LobId, true)); $(".hfAutoCompleteId_lobid").val(data.LobId); $('.txtAutoComplete_salespersonid').empty(); $('.txtAutoComplete_salespersonid').append(new Option(data.SalesPersonName, data.SalesPersonId, true)); $('.hfAutoCompleteId_salespersonid').val(data.SalesPersonId); $('hdn_OrganizationId').val(data.OrganizationId); $("#hfInv_OrganizationName").val(data.OrganizationName); $('.txtAutoComplete_paymenttermid').empty(); $('.hfAutoCompleteId_paymenttermid').val(data.PaymentTermId); $('.txtAutoComplete_paymenttermid').append(new Option(data.PaymentTermName, data.PaymentTermId, true)); if (data.SeriesId != 0 && $('#hfInv_IsRetun').val() != "1") { $(".txtSeriesAutoComplete_seriesid").empty(); $(".hfSeriesAutoCompleteId_seriesid").val(0); $(".txtSeriesAutoComplete_seriesid").append(new Option(data.SeriesName, data.SeriesId, true)); $(".hfSeriesAutoCompleteId_seriesid").val(data.SeriesId); } else { $(".txtSeriesAutoComplete_seriesid").prop("disabled", false); if (data.SeriesId == 0 && data.InvoiceNo != null && data.InvoiceNo != "") { $(".isManualSeries_seriesid").prop("checked", true); $(".TextManualSeries").val(data.InvoiceNo); } else { var Addr = $(".txtAutoComplete_billtoaddressid option:selected").val(); if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6") Addr = $(".txtAutoComplete_billfromaddressid option:selected").val(); InvoiceItem.Instance().bindSeries($(".txtAutoComplete_lobid option:selected").val(), Addr); } } if (($('#hfInv_IsRetun').val() != "1") && ($('.hdn_invoicetypeid').val() == "4" || $('.hdn_invoicetypeid').val() == "7" || $('.hdn_invoicetypeid').val() == "6" || $('.hdn_invoicetypeid').val() == "3")) { $(".txtSeriesAutoComplete_seriesid").prop("disabled", true); } if (data.RefNo != "" && data.RefNo != null) $(".txt_refno").val(data.RefNo); $(".hdn_refinvoiceid").val(data.RefInvoiceId); if ($('#hfInv_IsRetun').val() == "1" && ($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4")) $(".txt_refno").val(data.InvoiceNo); if (data.AdjustmentAccountId != 0) { $("#txt_AdjustmentAccountName").append(new Option(data.AdjustmentAccountName, data.AdjustmentAccountId, true)); $("#txt_AdjustmentAccountName").val(data.AdjustmentAccountId); $("#hf_AdjustmentAccountId").val(data.AdjustmentAccountId); } if (data.AdjustmentAccountId == 0) $('#txt_AdjustmentAccountName').empty(); if (data.AutoAdjustment == true) { $('#chk_AutoAdjustment').prop('checked', true); $('#txt_Adjustment').prop("disabled", true); $(".span_AdjustmentAccountName").removeClass('hidden'); $("#txt_AdjustmentAccountName").addClass('required'); } else { $('#chk_AutoAdjustment').prop('checked', false); $('#txt_Adjustment').prop("disabled", false); $("#txt_AdjustmentAccountName").removeClass('required'); $(".span_AdjustmentAccountName").addClass('hidden'); } $('#txt_Adjustment').val(data.Adjustment); if (data.Adjustment != 0) { $('.span_AdjustmentAccountName').removeClass('hidden'); $("#txt_AdjustmentAccountName").addClass('required'); } else { $('.span_AdjustmentAccountName').addClass('hidden'); $("#txt_AdjustmentAccountName").removeClass('required'); } if (data.InvoiceStatusId == 6) { $('#btnInvoiceItem').hide(); } var Iswalkincustomer = false; var contactid = data.OrgContactId; if (data.OrgContactId == 0) { Iswalkincustomer = true; contactid = data.OrganizationId; } InvoiceItem.Instance().IsCustomerIndustrial(data.LobId, data.OrganizationId); $(".chk_excludefromcampaign").prop("checked", data.ExcludeFromCampaign); $("#hfId_istaxinclusive").val(data.IsTaxInclusive); InvoiceItem.Instance().isOfferChargeApplied = data.IsOfferChargeApplied; $(".dropdown_istaxinclusive").val(data.IsTaxInclusive.toString()); $(".dropdown_paymentmethodid").val(data.PaymentMethodId); InvoiceItem.Instance().GetAvailableWallets(data.InvoiceId); InvoiceItem.Instance().loadOrderPendingItems(); }); $(".txtAutoComplete_orgcontactid").change(function () { InvoiceItem.Instance().LoadContactDetails(); }); if (data.GSTNO != "" && data.GSTNO != null) $(".txt_gstno").val(data.GSTNO); Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getCustomerTurnOver($(".hdn_organizationid").val(), $(".hdn_invoiceid").val(), InvoiceItem.Instance().formatDate($(".date_journaldate").val()), $(".hdn_invoicetypeid").val()).then(function (res) { if (res.result != null) { InvoiceItem.Instance().TurnOver = res.result.TurnOver; InvoiceItem.Instance().ContactTcsEnable = res.result.Enable; InvoiceItem.Instance().EnableTenantTcs = res.result.EnableTenantTcs; InvoiceItem.Instance().PanAvailable = res.result.PanAvailable; InvoiceItem.Instance().TaxRate = res.result.TaxRate; $(".hdn_tcstaxcodeaccountid").val(res.result.TCSTaxCodeAccountId); $(".hdn_tcstaxcodeid").val(res.result.TCSTaxCodeId); if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2") { if (InvoiceItem.Instance().ContactTcsEnable == true && InvoiceItem.Instance().EnableTenantTcs == true && data.TcsApplied == true) { $("#chk_tcsapplied").prop("checked", true); $("#hdnchk_tcsapplied").val("true"); $("#div_tcstaxrate").removeClass("hidden"); $(".div_tcsadjustment").removeClass("hidden"); $("#div_tcsamount").removeClass("hidden"); $(".number_tcsamount").prop("disabled", true); } } } }); $("chk_tcsapplies").prop("checked", data.TcsApplied); $(".hdn_tcstaxcodeid").val(data.TcsTaxCodeId); $(".hdn_tcstaxcodeaccountid").val(data.TcsTaxCodeAccountId); $(".number_tcstaxrate").val(data.TcsTaxRate); $(".number_tcstaxrate").prop("disabled", true); $(".txt_tcsadjustment").val(data.TcsAdjustment); $(".number_tcsamount").val(data.TcsAmount); $(".number_tcsamount").prop("disabled", true); $(".number_tdsamount").prop("disabled", true); $(".number_tdstaxrate").prop("disabled", true); InvoiceItem.Instance().ContactTcsEnable = data.TcsApplied; InvoiceItem.Instance().TaxRate = data.TcsTaxRate; if (data.TcsApplied == true) { $("#div_tcstaxrate").removeClass("hidden"); $(".div_tcsadjustment").removeClass("hidden"); $("#div_tcsamount").removeClass("hidden"); } else { $("#div_tcstaxrate").addClass("hidden"); $(".div_tcsadjustment").addClass("hidden"); $("#div_tcsamount").addClass("hidden"); } $("#chk_tcsapplied").unbind(); $("#chk_tcsapplied").change(function () { if ($('#chk_AutoAdjustment').prop("checked") == true) { $("#txt_Adjustment").val(0); $(".hdn_adjustment").val(0); } if ($(this).prop('checked') == true) { $(".divCustomProperties_tdstaxrate").addClass("hidden"); $(".divCustomProperties_tdsamount").addClass("hidden"); $(".divCustomProperties_tdstaxcodeid").addClass("hidden"); $(".chk_tdsapplied").attr("disabled"); $('#chk_tdsapplied').prop('checked', false); } else { $(".chk_tdsapplied").removeAttr("disabled"); } $(".div_tcsadjustment").addClass("floating-label-form-group-with-value"); if ($(this).prop('checked') == true && InvoiceItem.Instance().EnableTenantTcs == false && ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4")) { MessageHelper.Instance().showError("Please Submit TCS Declaration", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); $("#hdnchk_tcsapplied").val("false"); $('#chk_tcsapplied').prop('checked', false); } else { if ($(this).prop('checked') == true && $(".hdn_invoicetypeid").val() == "1") { bootbox.confirm("Confirm if sale value is > 50,00,000 for this customer.In this current Financial Year.", function (result) { if (result) { $("#div_tcstaxrate").removeClass("hidden"); $(".div_tcsadjustment").removeClass("hidden"); $("#div_tcsamount").removeClass("hidden"); InvoiceItem.Instance().update_total(); InvoiceItem.Instance().TotalAdjustment(); } else { $("#div_tcstaxrate").addClass("hidden"); $(".div_tcsadjustment").addClass("hidden"); $("#div_tcsamount").addClass("hidden"); $('#chk_tcsapplied').prop('checked', false); InvoiceItem.Instance().update_total(); InvoiceItem.Instance().TotalAdjustment(); } }); } else if ($(this).prop('checked') == true) { $("#div_tcstaxrate").removeClass("hidden"); $(".div_tcsadjustment").removeClass("hidden"); $("#div_tcsamount").removeClass("hidden"); $("#chk_tdsapplied").removeAttr("disabled"); InvoiceItem.Instance().update_total(); InvoiceItem.Instance().TotalAdjustment(); } else if ($(this).prop('checked') == false) { $("#div_tcstaxrate").addClass("hidden"); $(".div_tcsadjustment").addClass("hidden"); $("#div_tcsamount").addClass("hidden"); $(".number_tcstaxrate").val(data.TcsTaxRate); $(".number_tcstaxrate").prop("disabled", true); $(".txt_tcsadjustment").val(data.TcsAdjustment); $(".number_tcsamount").val(data.TcsAmount); $(".number_tcsamount").prop("disabled", true); InvoiceItem.Instance().update_total(); InvoiceItem.Instance().TotalAdjustment(); } } }); if ($("#chk_tdsapplied").prop('checked') == false) { $(".divCustomProperties_tdstaxrate").addClass("hidden"); $(".divCustomProperties_tdsamount").addClass("hidden"); $(".divCustomProperties_tdstaxcodeid").addClass("hidden"); } else $("#chk_tcsapplied").attr("disabled"); $(".txt_tcsadjustment").unbind(); $(".txt_tcsadjustment").blur(function () { InvoiceItem.Instance().update_total(); InvoiceItem.Instance().TotalAdjustment(); }); }); }); } loadOrderPendingItems() { var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId; let instance = this; let invoiceid = $(".hdn_invoiceid").val(); var orderid = $(".hdn_orderid").val(); var Dcid = $(".hdn_dcid").val(); var fromOrder = false; var items = []; var Invoiceitem = []; $(".item-addedrow").remove(); var url = ""; if (Dcid != 0 && Dcid != undefined && orderid == 0) { fromOrder = false; url = "apis/v4/bizgaze/transact/Dc/getpendingdcitemsforinvoice/dcid/" + Dcid; } if (Dcid == 0 || Dcid == undefined || InvoiceItem.Instance().OrderSettingId == 2) { if (orderid != "0" && orderid != undefined) { fromOrder = true; url = "apis/v4/bizgaze/transact/Orders/getpendingitemsforinvoice/orderid/" + orderid + "/ismergeorder/false"; } } else if (Dcid != 0 && Dcid != undefined) { fromOrder = false; url = "apis/v4/bizgaze/transact/Dc/getpendingdcitemsforinvoice/dcid/" + Dcid; } if (invoiceid != 0 && invoiceid != undefined && invoiceid != "null") { fromOrder = false; if ($('#hfInv_IsRetun').val() == "1") { if ($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") url = "apis/v4/bizgaze/transact/invoices/getinvoiceitemsbyinvoiceid/invoiceid/" + invoiceid + "/isreturn/true/itemid/0"; } else url = "apis/v4/bizgaze/transact/invoices/getinvoiceitemsbyinvoiceid/invoiceid/" + invoiceid + "/isreturn/false/itemid/0"; } if (url != "") { Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceItems(url).then(function (response) { var oldTaxId = 0; var totalQty = 0; if (response.result != null && response.result.length > 0) instance.ShowOrHideSaveBtn(false); for (var i = 0; i < response.result.length; i++) { var item = response.result[i]; var invoiceItemId = 0; totalQty += item.Quantity; if (invoiceid != "0" && invoiceid != undefined && invoiceid != "null") { invoiceItemId = item.InvoiceItemId; item.IsOfferChargeApplied = InvoiceItem.Instance().isOfferChargeApplied; } InvoiceItem.Instance().isOfferChargeApplied = true; $(".hdn_isofferchargeapplied").val('true'); var refInvoiceItemId = 0; if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && $("#hf_AppSettingName").val() == "Create Return") refInvoiceItemId = item.InvoiceItemId; if (i == 0) oldTaxId = item.TaxGroupId; if (oldTaxId != item.TaxGroupId && i != 0) $('#addDiscount').addClass('hidden'); var maxQty = 0; if (item.OrderItemPendingQty > 0) maxQty = item.OrderItemPendingQty; var pendingQuantity = item.OrderItemPendingQty > 0 ? item.OrderItemPendingQty : 0; if (invoiceItemId != 0) { maxQty = item.Quantity + pendingQuantity; if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4")) maxQty = item.Quantity; } if (item.DcItemId == undefined) item.DcItemId = 0; if (item.TaxAdjustment == undefined) item.TaxAdjustment = 0; if (item.AssesableAdjustment == undefined) item.AssesableAdjustment = 0; if (item.IsFoc == undefined) item.IsFoc = false; if (item.OfferItemId == undefined) item.OfferItemId = 0; if (item.DiscountPercent == undefined) item.DiscountPercent = 0; if (item.DiscountValue == undefined) item.DiscountValue = 0; if (item.IsSpecialPrice == undefined) item.IsSpecialPrice = false; if (item.MrpId == 0) item.EnableMRP = false; var itemRow = { orderItemId: item.OrderItemId, invoiceItemId: invoiceItemId, itemName: item.ItemName, itemId: item.ItemId, itemSKU: item.ItemSKU, unitName: item.UnitName, packSize: item.PackSize, packCount: item.PackCount, packs: item.Packs, quantity: item.Quantity, availPacks: item.AvailablePacks, availQty: item.AvailableQty, listPrice: 0, description: item.Description, taxGroupName: item.TaxGroupName, taxGroupId: item.TaxGroupId, isTaxInclusive: $("#hfId_istaxinclusive").val(), addlDiscountPercent: item.DiscountPercent, addlDiscountValue: item.DiscountAmount, creditNote: 0, priceListId: 0, batchId: 0, unitPrice: item.UnitPrice, invoiceallocations: null, exciseInvoiceItem: null, accountId: item.LedgerId, accountName: item.LedgerName, walletId: 0, Adjustment: 0, IsFoc: item.IsFoc, TariffNo: "", exciseAmount: item.ExciseAmount, discountName: "", discountId: 0, refNo: item.RefNo, DiscountGroupId: item.DiscountGroupId, DiscountGroupName: item.DiscountGroupName, ExchangeItem: item.ExchangeDC, maxQty: maxQty, RefInvoiceItemId: refInvoiceItemId, MrpId: item.MrpId, taxAdjustment: item.TaxAdjustment, assesableAdjustment: item.AssesableAdjustment, inventoryTypeId: item.InventoryTypeId, IsBoMItem: item.IsBoMItem, dcItemId: item.DcItemId, TotalRowAmount: 0, TotalDiscount: 0, BatchId: item.BatchId, OfferItemId: item.OfferItemId, AlternateUnitId: item.AlternateUnitId, DefaultSize: item.DefaultSize, ParentBOMItemId: item.ParentBOMItemId, IsSpecialPrice: item.IsSpecialPrice, IsMultipleUOMs: item.IsMultipleUOMs, MultipleUoms: item.MultipleUOMs, IsManualUOM: item.IsManualUOM, ConversionQuantity: item.ConversionQuantity, AlternateUnitName: item.AlternateUnitName, }; var EnableMrp = item.EnableMRP; var EnableBatch = item.EnableBatch; if (item.IsFoc == true) Invoiceitem.push(itemRow); else if (item.DcItemId != 0 && EnableMrp != true && EnableBatch != true) Invoiceitem.push(itemRow); else if (item.InvoiceItemId == 0) { if (InvoiceItem.Instance().orderid != 0 && Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_ordertypeid").Value) == 2 && EnableMrp != true && EnableBatch != true) Invoiceitem.push(itemRow); } else if (item.InvoiceItemId == 0) { if (InvoiceItem.Instance().orderid != 0 && Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_ordertypeid").Value) == 1 && ((EnableMrp != true && EnableBatch != true) || Number(item.AvailableQty) <= 0)) Invoiceitem.push(itemRow); } else if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4") && ((EnableMrp != true && EnableBatch != true))) Invoiceitem.push(itemRow); else if (($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3") && EnableMrp != true && EnableBatch != true) Invoiceitem.push(itemRow); else if ($(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "7") Invoiceitem.push(itemRow); else { if (item.InventoryTypeId != 5 && item.InventoryTypeId != 6 && item.InventoryTypeId != 7) { var total = Number((itemRow.quantity * itemRow.unitPrice) + itemRow.exciseAmount + itemRow.Adjustment + itemRow.assesableAdjustment); var nonexcise = total - itemRow.exciseAmount; var disc = ((nonexcise * itemRow.addlDiscountPercent) / 100) + (itemRow.quantity * itemRow.addlDiscountValue); var Rowtotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(total - disc, 3); InvoiceItem.Instance().SplitedInvoiceItemList.push({ orderItemId: item.OrderItemId, invoiceItemId: invoiceItemId, itemName: item.ItemName, itemId: item.ItemId, itemSKU: item.ItemSKU, unitName: item.UnitName, packSize: item.PackSize, packCount: item.PackCount, packs: item.Packs, quantity: item.Quantity, availPacks: item.AvailablePacks, availQty: item.AvailableQty, listPrice: 0, description: item.Description, taxGroupName: item.TaxGroupName, taxGroupId: item.TaxGroupId, isTaxInclusive: $("#hfId_istaxinclusive").val(), addlDiscountPercent: item.DiscountPercent, addlDiscountValue: item.DiscountAmount, creditNote: 0, priceListId: 0, batchId: 0, unitPrice: item.UnitPrice, invoiceallocations: null, exciseInvoiceItem: null, accountId: item.LedgerId, accountName: item.LedgerName, walletId: 0, Adjustment: 0, IsFoc: 0, TariffNo: "", exciseAmount: item.ExciseAmount, discountName: "", discountId: 0, refNo: item.RefNo, DiscountGroupId: item.DiscountGroupId, DiscountGroupName: item.DiscountGroupName, ExchangeItem: item.ExchangeDC, maxQty: maxQty, RefInvoiceItemId: refInvoiceItemId, MrpId: item.MrpId, taxAdjustment: item.TaxAdjustment, assesableAdjustment: item.AssesableAdjustment, inventoryTypeId: item.InventoryTypeId, IsBoMItem: item.IsBoMItem, dcItemId: item.DcItemId, TotalRowAmount: Rowtotal, TotalDiscount: disc, BatchId: item.BatchId, TotalAmount: Rowtotal, ParentBOMItemId: item.ParentBOMItemId }); if (items.length != 0 && items.find(x => x.itemId == item.ItemId) != undefined) { var multipleExist = items.find(x => x.itemId == item.ItemId); multipleExist.quantity += itemRow.quantity; var RowTotal = 0; var rowtotal = Number((itemRow.quantity * itemRow.unitPrice) + itemRow.exciseAmount + itemRow.Adjustment + itemRow.assesableAdjustment); var nonexiceamount = rowtotal - itemRow.exciseAmount; var discount = ((nonexiceamount * itemRow.addlDiscountPercent) / 100) + (itemRow.quantity * itemRow.addlDiscountValue); discount = Number(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discount, 3)); RowTotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowtotal - discount, 3); multipleExist.TotalRowAmount = Number(multipleExist.TotalRowAmount) + Number(RowTotal); multipleExist.TotalDiscount = Number(multipleExist.TotalDiscount) + Number(discount); if (InvoiceItem.Instance().OrderSettingId == 1) { var Qty = Number(maxQty); multipleExist.maxQty = Qty + Number(multipleExist.maxQty); } else { var Qty = Number(item.Quantity); multipleExist.maxQty = Qty + Number(multipleExist.maxQty); } } else { var RowTotal = 0; var rowtotal = Number((itemRow.quantity * itemRow.unitPrice) + itemRow.exciseAmount + itemRow.Adjustment + itemRow.assesableAdjustment); var nonexiceamount = rowtotal - itemRow.exciseAmount; var discount = ((nonexiceamount * itemRow.addlDiscountPercent) / 100) + (itemRow.quantity * itemRow.addlDiscountValue); discount = Number(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discount, 3)); RowTotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowtotal - discount, 3); itemRow.TotalRowAmount = Number(itemRow.TotalRowAmount) + Number(RowTotal); itemRow.TotalDiscount = Number(discount); items.push(itemRow); } } else { Invoiceitem.push(itemRow); } } $.each(item.InvItemTaxAdjustments, function (e) { var data = $(this); var rowData = data[0]; InvoiceItem.Instance().invItemTaxAdjustmentList.push(rowData); }); } for (let j1 = 0; j1 < items.length; j1++) { let j = items[j1]; var emptyRow = { orderItemId: j.orderItemId, invoiceItemId: 0, itemName: j.itemName, itemId: j.itemId, itemSKU: j.itemSKU, unitName: "", packSize: 0, packCount: 0, packs: 0, quantity: j.quantity, availPacks: 0, availQty: j.availQty, listPrice: 0, description: "", taxGroupName: j.taxGroupName, taxGroupId: j.taxGroupId, isTaxInclusive: $("#hf_istaxinclusive").val(), addlDiscountPercent: 0, addlDiscountValue: j.addlDiscountValue, creditNote: 0, priceListId: 0, batchId: 0, unitPrice: j.unitPrice, invoiceallocations: null, exciseInvoiceItem: null, accountId: j.accountId, accountName: j.accountName, walletId: 0, Adjustment: 0, IsFoc: j.IsFoc, TariffNo: "", exciseAmount: 0, discountName: "", discountId: 0, refNo: "", DiscountGroupId: 0, DiscountGroupName: '', RefInvoiceItemId: 0, MrpId: j.MrpId, taxAdjustment: 0, assesableAdjustment: 0, inventoryTypeId: 0, dcItemId: 0, TotalRowAmount: j.TotalRowAmount, BatchId: j.BatchId, maxQty: j.maxQty, TotalDiscount: j.TotalDiscount, ParentBOMItemId: j.ParentBOMItemId, IsSpecialPrice: j.IsSpecialPrice }; if (j.dcItemId != 0) InvoiceItem.Instance().dcItemIds.push(j.dcItemId); InvoiceItem.Instance().addDataRow(emptyRow, true); if (items.length - 1 == j1) { if (invoiceid != 0) instance.GetDiscounts(); instance.ShowOrHideSaveBtn(true); } } for (let k1 = 0; k1 < Invoiceitem.length; k1++) { let k = Invoiceitem[k1]; if (k.dcItemId != 0) InvoiceItem.Instance().dcItemIds.push(k.dcItemId); InvoiceItem.Instance().addDataRow(k, false); if (Invoiceitem.length - 1 == k1) { if (invoiceid != 0) instance.GetDiscounts(); instance.ShowOrHideSaveBtn(true); } } $("#totalinvoiceqty").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalQty, 2)); }); } } getwalletinvoiceditems() { var JournalAlloc = new Array(); $("#tbl_WalletItems").find(".walletitem-addedrow").each(function () { JournalAlloc.push({ journalAllocId: $(this).find(".journalAllocId").val(), RefAllocId: $(this).find(".refAllocId").val(), JournalId: $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_Invoiceid").val(), AdjustedAmount: Number($(this).find(".hfAdjustedAmount").val()), TotalAmount: Number($(this).find(".totalAmount").text()), IsWallet: true, CurrentAmount: Number($(this).find(".currentAmount").val()), }); }); return JournalAlloc; } ShowOrHideSaveBtn(IsShow) { let instance = this; if (!IsShow) { instance.navigationHelper.showLoading(); $("#btnDynamicSave").prop("disabled", true); } else { instance.navigationHelper.hideLoading(); $("#btnDynamicSave").prop("disabled", false); } } getInvoiceItems() { var invItemList = new Array(); $(".InvoiceItems").find(".item-row").each(function () { if (!$(this).hasClass('SplitItem')) { if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) { let ParentBOMItemId = $(this).find(".hf_ParentBOMItemId").val(); if (ParentBOMItemId == null) ParentBOMItemId = 0; var invoicetermid = $(this).find(".invoiceTermId").val(); var invoiceitemid = Number($(this).find(".selectedInvoiceItemId").val()); var refInvoiceitemid = Number($(this).find(".refInvoiceItemId").val()); var orderItemId = Number($(this).find(".orderItemId").val()); var ItemId = Number($(this).find(".selectedItemId").val()); var packs = 0; var prodprice = Number($(this).find(".prodPrice").val()); var quantity = Number($(this).find(".prodQuantity").val()); var prodpricelist = 0; var description = $(this).find(".prodDesc").val(); var MrpId = Number($(this).find(".hfMrpId").val()); var discountAmount = 0; var discountPercent = 0; var rowTotal = Number($(this).find(".prodTotalPrice").text()); if (($(".hdn_invoicetypeid").val() == "2") && invoiceitemid != 0) { rowTotal = Number($(this).find(".hfRowTotalwithAdjustment").val()); } var Quantity = Number($(this).find(".prodQuantity").val()); var ConversionQuantity = Quantity; let SelectedUnitId = 0; let DefaultSize = 0; let AlternateSize = 0; if ($(this).find(".hf_IsMultipleUOM").val() == "true" && $(".hdn_invoicetypeid").val() == "1") { let ItemId = Number($(this).find(".selectedItemId").val()); SelectedUnitId = Number($(this).find(".ddl_MultipleUOMs").val()); if (SelectedUnitId != 0 && SelectedUnitId != 1) { var Uom = InvoiceItem.Instance().UOMs.find(x => x.ItemId == ItemId); var SelectedUOM = Uom.MultipleUOMs.find(x => x.SchemaDetailId == SelectedUnitId); DefaultSize = SelectedUOM.DefaultSize; AlternateSize = SelectedUOM.AlternateSize; ConversionQuantity = Number(Quantity) * (AlternateSize / DefaultSize); } } else if ($(this).find(".hf_IsManualUOM").val() == "true" && $(".hdn_invoicetypeid").val() == "1") { SelectedUnitId = Number($(this).find(".hf_AlternateUnitId").val()); ConversionQuantity = Number($(this).find(".hf_ConversionQuantity").val()); } if (($(this).find(".btnInvoice_DiscType option:selected").text().trim() == 'Val' || $(this).find(".btnInvoice_DiscType option:selected").text().trim() == 'Mul') && $(this).find('.inv_txtaddldiscount').val() != '' && $(this).find('.inv_txtaddldiscount').val() != undefined) { discountAmount = Number($(this).find('.inv_txtaddldiscount').val()); } else if ($(this).find(".btnInvoice_DiscType option:selected").text().trim() == '%' && $(this).find('.inv_txtaddldiscount').val() != '' && $(this).find('.inv_txtaddldiscount').val() != undefined) { discountPercent = Number($(this).find('.inv_txtaddldiscount').val()); } var TaxGroupId = Number($(this).find(".hfProdTax").val()); let accountid = Number($(this).find(".txt_Account").val()); let foc = ($(this).find(".hf_IsFoc").val() == 'true'); invItemList.push({ InvoiceItemId: invoiceitemid, OrderItemId: orderItemId, ItemId: ItemId, Packs: packs, TaxGroupId: TaxGroupId, Description: description, PriceListId: prodpricelist, UnitPrice: prodprice, DiscountAmount: discountAmount, DiscountPercent: discountPercent, IsTaxInclusive: Boolean($('.dropdown_istaxinclusive').val()), AccountId: accountid, Adjustment: Number($(this).find(".hfRowTotalAdjustment").val()), TotalAmount: Number(rowTotal), Quantity: Number(Quantity), ExciseAmount: 0, RefNo: $(this).find(".refNo").val(), DiscountGroupId: Number($(this).find("#hfProdDiscountGroupId").val()), RefInvoiceItemId: Number(refInvoiceitemid), MrpId: Number(MrpId), DcItemId: Number($(this).find(".dcItemId").val()), BatchId: 0, IsFoc: foc, OfferItemId: ($(this).find(".hfOfferedItemId").val() == null || $(this).find(".hfOfferedItemId").val() == undefined) ? 0 : Number($(this).find(".hfOfferedItemId").val()), AlternateUnitId: SelectedUnitId, DefaultSize: DefaultSize, ParentBOMItemId: Number(ParentBOMItemId), ConversionQuantity: Number(ConversionQuantity) }); } } }); for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) { if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && $('#hfInv_IsRetun').val() == "1") { InvoiceItem.Instance().SplitedInvoiceItemList[i].invoiceItemId = 0; } invItemList.push({ InvoiceItemId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].invoiceItemId), OrderItemId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].orderItemId), ItemId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId), TaxGroupId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].taxGroupId), Description: InvoiceItem.Instance().SplitedInvoiceItemList[i].description, PriceListId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].priceListId), UnitPrice: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].unitPrice), DiscountAmount: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].addlDiscountValue), DiscountPercent: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].addlDiscountPercent), IsTaxInclusive: Boolean($('.dropdown_istaxinclusive').val()), AccountId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].accountId), Adjustment: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].Adjustment), TotalAmount: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].TotalAmount), Quantity: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity), ExciseAmount: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].exciseAmount), RefNo: InvoiceItem.Instance().SplitedInvoiceItemList[i].refNo, DiscountGroupId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].DiscountGroupId), RefInvoiceItemId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].RefInvoiceItemId), MrpId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].MrpId) == -1 ? 0 : Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].MrpId), DcItemId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].dcItemId), BatchId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].BatchId), IsFoc: false, OfferItemId: 0, }); } $(".InvoiceItems").find(".discount-row").each(function () { if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) { var rowname = "discount-row"; var appliedOnWhole = false; var totalElement = $(this).find(".netdiscount-row-total"); if (totalElement.length != 0) { appliedOnWhole = true; rowname = "netdiscount-row"; } var invoicechargeid = $(this).find(".selectedInvoiceChargeId").val(); var ItemId = $(this).find(".hfSelectedChargeId").val(); var chargeTypeId = $(this).find(".hdnChargeTypeId").val(); var ledgerId = $(this).find(".hdnChargeLedgerId").val(); var percent = $(this).find(".percentage").val(); var value = $(this).find(".fixedvalue").val(); var desc = $(this).find(".discountDesc").val(); var totalamount = $(this).find("." + rowname + "-total").html(); invItemList.push({ InvoiceItemId: $(this).find(".selectedInvoiceItemId").val() == undefined ? 0 : Number($(this).find(".selectedInvoiceItemId").val()), OrderItemId: 0, ItemId: Number(ItemId), Packs: 0, TaxGroupId: Number($(this).find(".hfProdTax").val()), Description: $(this).find(".discountDesc").val(), PriceListId: 0, UnitPrice: 0, DiscountAmount: Number($(this).find(".fixedvalue").val()), DiscountPercent: Number($(this).find(".percentage").val()), IsTaxInclusive: Boolean($('.dropdown_istaxinclusive').val()), AccountId: Number($(this).find(".hf_Account").val()), RowDiscount: Number(totalamount), SendToWallet: 0, Adjustment: 0, TotalAmount: 0, Quantity: 1, ExciseAmount: 0, RefNo: "", DiscountGroupId: 0, RefInvoiceItemId: 0, MrpId: 0, BatchId: 0, DcItemId: Number($(this).find(".dcItemId").val()), IsFoc: false, OfferItemId: 0, }); } }); $(".netdiscount-row").each(function () { var rowname = ""; var appliedOnWhole = false; var totalElement = $(this).find(".netdiscount-row-total"); if (totalElement.length != 0) { appliedOnWhole = true; rowname = "netdiscount-row"; } if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) { var invoicechargeid = $(this).find(".selectedInvoiceChargeId").val(); var ItemId = $(this).find(".hfSelectedChargeId").val(); var chargeTypeId = $(this).find(".hdnChargeTypeId").val(); var ledgerId = $(this).find(".hdnChargeLedgerId").val(); var percent = $(this).find(".percentage").val(); var value = $(this).find(".fixedvalue").val(); var desc = $(this).find(".discountDesc").val(); var totalamount = $(this).find("." + rowname + "-total").html(); invItemList.push({ InvoiceItemId: $(this).find(".selectedInvoiceItemId").val() == undefined ? 0 : Number($(this).find(".selectedInvoiceItemId").val()), OrderItemId: 0, ItemId: Number(ItemId), Packs: 0, TaxGroupId: Number($(this).find(".hfProdTax").val()), Description: $(this).find(".discountDesc").val(), PriceListId: 0, UnitPrice: 0, DiscountAmount: Number($(this).find(".fixedvalue").val()), DiscountPercent: Number($(this).find(".percentage").val()), IsTaxInclusive: Boolean($('.dropdown_istaxinclusive').val()), AccountId: Number($(this).find(".hf_Account").val()), RowDiscount: Number(totalamount), SendToWallet: 0, Adjustment: 0, TotalAmount: 0, Quantity: 1, ExciseAmount: 0, RefNo: "", DiscountGroupId: 0, RefInvoiceItemId: 0, MrpId: 0, BatchId: 0, DcItemId: Number($(this).find(".dcItemId").val()), IsFoc: false, OfferItemId: 0, }); } }); $(".expense-row").each(function () { var rowname = ""; var appliedOnWhole = false; var totalElement = $(this).find(".expense-row-total"); if (totalElement.length != 0) { appliedOnWhole = true; rowname = "expense-row"; } if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) { var invoicechargeid = $(this).find(".selectedInvoiceChargeId").val(); var ItemId = $(this).find(".hfSelectedChargeId").val(); var chargeTypeId = $(this).find(".hdnChargeTypeId").val(); var ledgerId = $(this).find(".hdnChargeLedgerId").val(); var percent = $(this).find(".percentage").val(); var value = $(this).find(".fixedvalue").val(); var desc = $(this).find(".discountDesc").val(); var totalamount = $(this).find("." + rowname + "-total").html(); if (Number($(this).find(".expfixedvalue").val()) != 0 || Number($(this).find(".exppercentage").val()) != 0) { invItemList.push({ InvoiceItemId: $(this).find(".selectedInvoiceItemId").val() == undefined ? 0 : Number($(this).find(".selectedInvoiceItemId").val()), OrderItemId: 0, ItemId: Number(ItemId), Packs: 0, TaxGroupId: Number($(this).find(".hfProdTax").val()), Description: $(this).find(".expenseDesc").val(), PriceListId: 0, UnitPrice: 0, DiscountAmount: -Number($(this).find(".expfixedvalue").val()), DiscountPercent: -Number($(this).find(".exppercentage").val()), IsTaxInclusive: Boolean($('.dropdown_istaxinclusive').val()), AccountId: Number($(this).find(".hf_Account").val()), RowDiscount: -Number(totalamount), SendToWallet: 0, Adjustment: 0, TotalAmount: 0, Quantity: 1, ExciseAmount: 0, RefNo: "", DiscountGroupId: 0, RefInvoiceItemId: 0, MrpId: 0, BatchId: 0, DcItemId: Number($(this).find(".dcItemId").val()), IsFoc: false, OfferItemId: 0, }); } } }); return invItemList; } getCharges() { var ChargeList = new Array(); var chargeIndex = 0; InvoiceItem.Instance().update_discount_total(); InvoiceItem.Instance().update_expense_total(); $(".discount-row,.netdiscount-row").each(function () { if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) { var rowname = "discount-row"; var appliedOnWhole = false; var totalElement = $(this).find(".netdiscount-row-total"); if (totalElement.length != 0) { appliedOnWhole = true; rowname = "netdiscount-row"; } if ($(this).find(".hfSelectedChargeId").val() != "" && $(this).find(".hfSelectedChargeId").val() != "0") { var invoicechargeid = $(this).find(".selectedInvoiceChargeId").val(); chargeIndex += 1; var ChargeId = $(this).find(".hfSelectedChargeId").val(); var chargeTypeId = $(this).find(".hdnChargeTypeId").val(); var ledgerId = $(this).find(".hf_Account").val(); var percent = $(this).find(".percentage").val(); var value = $(this).find(".fixedvalue").val(); var desc = $(this).find(".discountDesc").val(); var totalamount = $(this).find("." + rowname + "-total").html(); ChargeList.push({ InvoiceChargeId: Number(invoicechargeid), ChargeId: Number(ChargeId), ChargeTypeId: Number(chargeTypeId), ChargeIndex: chargeIndex, Percentage: Number(percent), FixedAmount: Number(value), ApplyWhole: appliedOnWhole, Description: desc, TotalAmount: Number(totalamount), LedgerId: Number(ledgerId), TaxGroupId: Number($(this).find(".hfProdTax").val()) }); } } }); $(".expense-row").each(function () { if ($(this).find(".selectedItemId").val() != undefined) { if ($(this).find(".hfSelectedChargeId").val() != "" && $(this).find(".hfSelectedChargeId").val() != "0") { var invoicechargeid = $(this).find(".selectedInvoiceChargeId").val(); let ChargeId = $(this).find(".hfSelectedChargeId").val(); var chargeTypeId = $(this).find(".hdnChargeTypeId").val(); var percent = $(this).find(".exppercentage").val(); var value = $(this).find(".expfixedvalue").val(); var desc = $(this).find(".expenseDesc").val(); var totalamount = $(this).find(".expense-row-total").html(); var ledgerId = $(this).find(".hf_Account").val(); if (Number(value) != 0 || Number(percent)) { ChargeList.push({ InvoiceChargeId: Number(invoicechargeid), ChargeId: Number(ChargeId), ChargeTypeId: Number(chargeTypeId), Percentage: Number(percent), FixedAmount: Number(value), ApplyWhole: true, Description: desc, TotalAmount: Number(totalamount), LedgerId: Number(ledgerId), TaxGroupId: Number($(this).find(".hfProdTax").val()) }); } } } }); return ChargeList; } getobj() { var item = Number($(".selectedItemId").val()); var inventorytypeid = 0; var AdjustmentAccountId = 0; var isqtyavail = true; Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/inventory/itemmanager.js", function () { Bizgaze.Apps.Transact.Managers.ItemManager.Instance().getItem(item).then(function (response) { inventorytypeid = response.result.InventoryTypeId; $(".InvoiceItems").find(".remove_item").remove(); InvoiceItem.Instance().update_total(); InvoiceItem.Instance().TotalAdjustment(); if ($("#chk_tcsapplied").prop("checked") == true && ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && InvoiceItem.Instance().EnableTenantTcs == false) { MessageHelper.Instance().showError("Please Submit TCS Declaration", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); $(".InvoiceItems").append("
"); return false; } var CompanyName = $(".txtAutoComplete_orgcontactid").text(); if (CompanyName == "") { $(".hfAutoCompleteId_orgcontactid").val(0); } var Adjustment = $('#txt_Adjustment').val(); if ($('#chk_AutoAdjustment').is(':checked')) { if ($('#hf_AdjustmentAccountId').val() == 0) { MessageHelper.Instance().showError("Please Select Adjustment Account", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } InvoiceItem.Instance().TotalAdjustment(); Adjustment = $('#txt_Adjustment').val(); AdjustmentAccountId = Number($("#txt_AdjustmentAccountName").val()); } }); }); if ($('#chk_AutoAdjustment').is(':checked')) { if ($('#hf_AdjustmentAccountId').val() == 0) { MessageHelper.Instance().showError("Please Select Adjustment Account", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } else AdjustmentAccountId = Number($("#txt_AdjustmentAccountName").val()); } let isemptyrow = false; let rownotexist = true; let itemarray = []; let emptysplitrow = false; let itemname = ""; var IsUnitPriceZero = false; $(".InvoiceItems").find(".item-addedrow").each(function () { rownotexist = false; if (!$(this).hasClass('SplitItem')) { if ($(this).find(".selectedItemId").val() == undefined || $(this).find(".selectedItemId").val() == 0) { isemptyrow = true; } if ($(this).find(".hfProdTax").val() == "0" || $(this).find(".hf_Account").val() == "0") { itemarray.push($(this)); } if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4") && (InvoiceItem.Instance().AutoDc == true || InvoiceItem.Instance().OrderSettingId == 2)) { inventorytypeid = Number($(this).find("#inventorytypeid").val()); if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) { if ((Number($(this).find('.prodQuantity').val()) > Number($(this).find('.prodAvail').text())) && $(".hdn_invoiceid").val() == "0" && inventorytypeid != 2) { isqtyavail = false; } else { let Qty = Number($(this).find('.prodQuantity').val()); let AvQty = Number($(this).find('.prodAvail').text()) + Number($(this).find('.Qty').val()); if (Qty > AvQty && inventorytypeid != 2) isqtyavail = false; } } } } else { if (InvoiceItem.Instance().SplitedInvoiceItemList.find(x => x.itemId == Number($(this).find(".selectedItemId").val()))) { } else { emptysplitrow = true; itemname = $(this).find(".prodName").text(); } } var UnitPrice = Number($(this).find(".prodPrice").val()); if (UnitPrice == 0 && $(this).find(".hf_IsBOM").val() == "false" && $(this).find(".hf_IsFoc").val() == "false") { IsUnitPriceZero = true; } }); if (!isqtyavail) { MessageHelper.Instance().showError("Please check available quantity", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } if (isemptyrow) { MessageHelper.Instance().showError("Please Select Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } if (rownotexist) { MessageHelper.Instance().showError("Please Add Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } if (emptysplitrow) { MessageHelper.Instance().showError("Please Select Mrp/Batch for the Item: " + itemname, $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } let couponitemrow = false; $(".addednetdiscount-row").each(function () { if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) { if (($(this).find(".percentage").val() == "0" || $(this).find(".percentage").val() == "") && ($(this).find(".fixedvalue").val() == 0 || $(this).find(".fixedvalue").val() == "")) isemptyrow = true; } if ($(this).find(".selectedItemId").val() == "0" || $(this).find(".selectedItemId").val() == undefined) couponitemrow = true; }); if (isemptyrow) { MessageHelper.Instance().showError("Please enter percentage or value for coupon item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } let expenseitemrow = false; $(".addedexpense-row").each(function () { if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) { if (($(this).find(".exppercentage").val() == "0" || $(this).find(".exppercentage").val() == "") && ($(this).find(".expfixedvalue").val() == 0 || $(this).find(".expfixedvalue").val() == "")) isemptyrow = true; } if ($(this).find(".selectedItemId").val() == "0" || $(this).find(".selectedItemId").val() == undefined) expenseitemrow = true; }); if (isemptyrow) { MessageHelper.Instance().showError("Please enter percentage or value for Expense Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } if (IsUnitPriceZero) { MessageHelper.Instance().showError("Item UnitPrice should not be zero.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } if (couponitemrow) { MessageHelper.Instance().showError("Please Select Coupon Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } if (expenseitemrow) { MessageHelper.Instance().showError("Please Select Expense Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } var wallets = InvoiceItem.Instance().getwalletinvoiceditems(); var invItems = InvoiceItem.Instance().getInvoiceItems(); if (invItems.length == 0) { MessageHelper.Instance().showError("You Should Add atleast One Item.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } else { var qtyresult = invItems.find(x => x.AccountId == 0) ? true : false; if (qtyresult == true) { for (var i = 0; i < itemarray.length; i++) { itemarray[i].find(".div_MoreDetails").removeClass("hidden"); } MessageHelper.Instance().showError("Account Not Configured for the item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } var qty = invItems.find(x => x.Quantity == 0) ? true : false; if (qty == true) { MessageHelper.Instance().showError("Item quantity should not be zero.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } var TaxGroup = invItems.find(x => x.TaxGroupId == 0) ? true : false; if (TaxGroup == true) { for (var i = 0; i < itemarray.length; i++) { itemarray[i].find(".div_MoreDetails").removeClass("hidden"); } MessageHelper.Instance().showError("TaxGroup Not Configured for the item.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } } var billingAddressId = $(".hfAutoCompleteId_billtoaddressid").val(); if (billingAddressId == null) billingAddressId = $("#hfId_billtoaddressid").val(); var invoiceid = $(".hdn_invoiceid").val(); let refInvoiceId = 0; if ($(".hdn_refinvoiceid").val() != undefined && Number($(".hdn_refinvoiceid").val()) != 0) refInvoiceId = Number($(".hdn_refinvoiceid").val()); if (invoiceid == undefined) invoiceid = 0; if (($(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "3") && $("#hf_AppSettingName").val() == "Create Return") { invoiceid = 0; if (refInvoiceId == 0) { refInvoiceId = Number($(".hdn_invoiceid").val()); $(".hdn_refinvoiceid").val($(".hdn_invoiceid").val()); } $(".hdn_invoiceid").val("0"); $(".hdn_journalno").val("0"); } let orgcontactid = $(".txtAutoComplete_orgcontactid").val(); var dcid = InvoiceItem.Instance().dcid; if (invoiceid == 0 && ($(".hdn_invoicetypeid").val() == '3' || $(".hdn_invoicetypeid").val() == '4' || $(".hdn_invoicetypeid").val() == '7' || $(".hdn_invoicetypeid").val() == '6')) { dcid = 0; } var orderid = InvoiceItem.Instance().orderid; if (orderid == undefined || orderid == 0) { orderid = 0; } var ClaimId = InvoiceItem.Instance().ClaimId; if (ClaimId == undefined || ClaimId == 0) { ClaimId = 0; } else orderid = ClaimId; var branchid = 0; $(".txt_RefNo").val() == "null" ? $(".txt_RefNo").val("") : $(".txt_refno").val(); var description = $(".divCustomProperties_systemnotes").find("textarea").val(); if ($('.txt_tcsadjustment').val() == "") $('.txt_tcsadjustment').val(0); if (Number($(".nettotal").html()) < 0) { MessageHelper.Instance().showError("Invoice value should not be less than 0", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } var InvoiceObject = { TotalAmount: Number($(".nettotal").html()), InvoiceItems: invItems, InvoiceCharges: InvoiceItem.Instance().getCharges(), AutoAdjustment: Boolean($('#chk_AutoAdjustment').is(':checked')), AutoDc: InvoiceItem.Instance().AutoDc, InvItemTaxAdjustments: InvoiceItem.Instance().invItemTaxAdjustmentList, JournalAlloc: wallets, AdjustmentAccountId: Number($("#txt_AdjustmentAccountName").val()), InvoiceId: Number(invoiceid), RefInvoiceId: Number(refInvoiceId), OrgContactId: Number(orgcontactid), DeletedInvoiceId: InvoiceItem.Instance().deleted_invoiceItems, IsOfferChargeApplied: InvoiceItem.Instance().isOfferChargeApplied, }; return InvoiceObject; } saveInvoice() { $(".InvoiceItems").find(".remove_item").remove(); InvoiceItem.Instance().update_total(); InvoiceItem.Instance().TotalAdjustment(); var inventorytypeid = 0; var AdjustmentAccountId = 0; var item = Number($(".selectedItemId").val()); Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/inventory/itemmanager.js", function () { Bizgaze.Apps.Transact.Managers.ItemManager.Instance().getItem(item).then(function (response) { inventorytypeid = response.result.InventoryTypeId; if ($("#chk_tcsapplied").prop("checked") == true && ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && InvoiceItem.Instance().EnableTenantTcs == false) { MessageHelper.Instance().showError("Please Submit TCS Declaration", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); $(".InvoiceItems").append("
"); return false; } var CompanyName = $(".txtAutoComplete_orgcontactid").text(); if (CompanyName == "") { $(".hfAutoCompleteId_orgcontactid").val(0); } if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4") && (InvoiceItem.Instance().AutoDc == true || InvoiceItem.Instance().OrderSettingId == 2)) { var isqtyavail = true; $(".InvoiceItems").find(".item-addedrow").each(function () { if (!$(this).hasClass('SplitItem')) { if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) { if (Number($(this).find('.prodQuantity').val()) > Number($(this).find('.prodAvail').text()) && inventorytypeid != 2) { isqtyavail = false; } } } }); if (!isqtyavail) { MessageHelper.Instance().showError("Please check available quantity", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } } }); }); var Adjustment = $('#txt_Adjustment').val(); var AdjustmentAccountId = 0; if ($('#chk_AutoAdjustment').is(':checked')) { if ($('#hf_AdjustmentAccountId').val() == 0) { MessageHelper.Instance().showError("Please Select Adjustment Account", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } InvoiceItem.Instance().TotalAdjustment(); Adjustment = $('#txt_Adjustment').val(); AdjustmentAccountId = Number($("#txt_AdjustmentAccountName").val()); } if (Number($('#txt_Adjustment').val()) != 0) { if ($('#hf_AdjustmentAccountId').val() == 0) { MessageHelper.Instance().showError("Please Select Adjustment Account", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } else AdjustmentAccountId = Number($("#txt_AdjustmentAccountName").val()); } let isemptyrow = false; let rownotexist = true; let itemarray = []; let emptysplitrow = false; let itemname = ""; $(".InvoiceItems").find(".item-addedrow").each(function () { rownotexist = false; if (!$(this).hasClass('SplitItem')) { if ($(this).find(".selectedItemId").val() == undefined || $(this).find(".selectedItemId").val() == 0) { isemptyrow = true; } if ($(this).find(".hfProdTax").val() == "0" || $(this).find(".hf_Account").val() == "0") { itemarray.push($(this)); } } else { if (InvoiceItem.Instance().SplitedInvoiceItemList.find(x => x.itemId == Number($(this).find(".selectedItemId").val()))) { } else { emptysplitrow = true; itemname = $(this).find(".prodName").text(); } } }); if (isemptyrow) { MessageHelper.Instance().showError("Please Select Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } if (rownotexist) { MessageHelper.Instance().showError("Please Add Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } if (emptysplitrow) { MessageHelper.Instance().showError("Please Select Mrp/Batch for the Item: " + itemname, $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } let couponitemrow = false; $(".addednetdiscount-row").each(function () { if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) { if (($(this).find(".percentage").val() == "0" || $(this).find(".percentage").val() == "") && ($(this).find(".fixedvalue").val() == 0 || $(this).find(".fixedvalue").val() == "")) isemptyrow = true; } if ($(this).find(".selectedItemId").val() == "0" || $(this).find(".selectedItemId").val() == undefined) couponitemrow = true; }); if (isemptyrow) { MessageHelper.Instance().showError("Please enter percentage or value for coupon item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } if (couponitemrow) { MessageHelper.Instance().showError("Please Select Coupon Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } let expenseitemrow = false; $(".addedexpense-row").each(function () { if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) { if (($(this).find(".exppercentage").val() == "0" || $(this).find(".exppercentage").val() == "") && ($(this).find(".expfixedvalue").val() == 0 || $(this).find(".expfixedvalue").val() == "")) isemptyrow = true; } if ($(this).find(".selectedItemId").val() == "0" || $(this).find(".selectedItemId").val() == undefined) expenseitemrow = true; }); if (isemptyrow) { MessageHelper.Instance().showError("Please enter percentage or value for Expense Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } if (expenseitemrow) { MessageHelper.Instance().showError("Please Select Expense Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } var wallets = InvoiceItem.Instance().getwalletinvoiceditems(); var invItems = InvoiceItem.Instance().getInvoiceItems(); if (invItems.length == 0) { MessageHelper.Instance().showError("You Should Add atleast One Item.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } else { var qtyresult = invItems.find(x => x.AccountId == 0) ? true : false; if (qtyresult == true) { for (var i = 0; i < itemarray.length; i++) { itemarray[i].find(".div_MoreDetails").removeClass("hidden"); } MessageHelper.Instance().showError("Account Not Configured for the item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } var qty = invItems.find(x => x.Quantity == 0) ? true : false; if (qty == true) { MessageHelper.Instance().showError("Item quantity should not be zero.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } var TaxGroup = invItems.find(x => x.TaxGroupId == 0) ? true : false; if (TaxGroup == true) { for (var i = 0; i < itemarray.length; i++) { itemarray[i].find(".div_MoreDetails").removeClass("hidden"); } MessageHelper.Instance().showError("TaxGroup Not Configured for the item.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } } var PaymentTermName = $(".txtAutoComplete_paymentiermid").text(); var billingAddressId = $(".hfAutoCompleteId_billtoaddressid").val(); if (billingAddressId == null) billingAddressId = $("#hfId_billtoaddressid").val(); var invoiceid = $(".hdn_invoiceid").val(); let refInvoiceId = 0; if (invoiceid == undefined) invoiceid = 0; if (($(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "3") && $("#hf_AppSettingName").val() == "Create Return") { invoiceid = 0; refInvoiceId = Number($(".hdn_invoiceid").val()); $(".hdn_refinvoiceid").val($(".hdn_invoiceid").val()); $(".hdn_invoiceid").val("0"); $(".hdn_journalno").val("0"); } let orgcontactid = $(".txtAutoComplete_orgcontactid").val(); var dcid = InvoiceItem.Instance().dcid; if (invoiceid == 0 && ($(".hdn_invoicetypeid").val() == '3' || $(".hdn_invoicetypeid").val() == '4' || $(".hdn_invoicetypeid").val() == '7' || $(".hdn_invoicetypeid").val() == '6')) { dcid = 0; } var orderid = InvoiceItem.Instance().orderid; if (orderid == undefined || orderid == 0) { orderid = 0; } var ClaimId = InvoiceItem.Instance().ClaimId; if (ClaimId == undefined || ClaimId == 0) { ClaimId = 0; } else orderid = ClaimId; var branchid = 0; if ((ClaimId != 0 || orderid != 0) && InvoiceItem.Instance().dcid == 0) for (let obj of Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters) { if (obj.Key === "hf_" + $("#hfLayout_InstalledPageId").val() + "_branchid") branchid = InvoiceItem.Instance().orderid = Number(obj.Value); } else branchid = Number(Unibase.Platform.Membership.Infos.Identity.getSetting("branchid")); $(".txt_RefNo").val() == "null" ? $(".txt_RefNo").val("") : $(".txt_refno").val(); var description = $(".divCustomProperties_systemnotes").find("textarea").val(); if ($('.txt_tcsadjustment').val() == "") $('.txt_tcsadjustment').val(0); var InvoiceObject = { PaymentTermName: PaymentTermName, BranchId: branchid, TotalAmount: Number($(".nettotal").html()), InvoiceItems: invItems, InvoiceCharges: InvoiceItem.Instance().getCharges(), AutoAdjustment: Boolean($('#chk_AutoAdjustment').is(':checked')), AutoDc: InvoiceItem.Instance().AutoDc, InvItemTaxAdjustments: InvoiceItem.Instance().invItemTaxAdjustmentList, JournalAlloc: wallets, AdjustmentAccountId: Number($("#txt_AdjustmentAccountName").val()), InvoiceId: Number(invoiceid), RefInvoiceId: Number(refInvoiceId), OrgContactid: orgcontactid, DeletedInvoiceId: InvoiceItem.Instance().deleted_invoiceItems, IsOfferChargeApplied: InvoiceItem.Instance().isOfferChargeApplied, }; return InvoiceObject; } addRow() { let isemptyrow = false; $(".InvoiceItems").find(".item-addedrow").each(function () { if (!$(this).hasClass('SplitItem')) { if ($(this).find(".selectedItemId").val() == undefined || $(this).find(".selectedItemId").val() == 0) { isemptyrow = true; } } }); if (isemptyrow) { MessageHelper.Instance().showError("Please Select Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id')); return false; } var emptyRow = { orderItemId: 0, invoiceItemId: 0, itemName: "", itemId: 0, itemSKU: "", unitName: "", packSize: 0, packCount: 0, packs: 0, quantity: 0, availPacks: 0, availQty: 0, listPrice: 0, description: "", taxGroupName: "", taxGroupId: 0, isTaxInclusive: $("#hf_istaxinclusive").val(), addlDiscountPercent: 0, addlDiscountValue: 0, creditNote: 0, priceListId: 0, batchId: 0, unitPrice: 0, invoiceallocations: null, exciseInvoiceItem: null, accountId: 0, accountName: "", walletId: 0, Adjustment: 0, IsFoc: false, TariffNo: "", exciseAmount: 0, discountName: "", discountId: 0, refNo: "", DiscountGroupId: 0, DiscountGroupName: '', RefInvoiceItemId: 0, MrpId: 0, taxAdjustment: 0, assesableAdjustment: 0, inventoryTypeId: 0, dcItemId: 0, TotalRowAmount: 0, maxQty: 0, OfferItemId: 0 }; InvoiceItem.instance.addDataRow(emptyRow, false); } addDataRow(row, IsSplitItem) { Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("tenants/themes/compact/components/details/details.js", function () { }); this.rowIndex = $(".InvoiceItems").find(".item-addedrow").length + 1; var bg = ""; if (row.packSize == 0) row.packSize = 1; if (row.packCount == 0) row.packCount = 1; if (row.quantity == 0) row.quantity = row.packCount * row.packs * row.packSize; var price = row.unitPrice; if (row.unitPrice == 0) price = row.listPrice; var currenttaxgroupid = 0; if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && $('#hfInv_IsRetun').val() == "1") { row.invoiceallocations = null; row.invoiceItemId = 0; } if ($('#hfInv_IsRetun').val() == "1") row.invoiceItemId = 0; var zeroBilled = ""; if (price == 0) zeroBilled = "bg-danger"; var zeroQtyText = ""; var zeroQtyDiv = "bg-light"; let invoiceid = $(".hdn_invoiceid").val(); if (invoiceid == "0") { if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4") && row.itemId != 0 && row.IsFoc == false) { if (row.availQty == 0) { row.quantity = 0; zeroQtyText = "text-danger"; zeroQtyDiv = "bg-danger"; } else if (row.availQty < row.quantity) { row.quantity = row.availQty; } } } var readonlyQty = ""; var ManageInvoice = 2; var AutoDc = false; var ManageInvoiceTax = 2; var readonlyPrice = ""; var readonlyDisc = ""; var readonlyTax = ""; if (ManageInvoice == 1 && AutoDc == false) { readonlyQty = "readonly"; readonlyPrice = "readonly"; readonlyDisc = "readonly"; readonlyTax = "disabled"; } if ($('.hdn_invoicetypeid').val() == "1" && ManageInvoiceTax == 1 && AutoDc == false) { readonlyTax = "readonly"; } if (row.inventoryTypeId == "2") { readonlyQty = ""; readonlyPrice = ""; } var activeDiscVal = ""; var activeDiscPercent = ""; var activeDiscMul = ""; var activeDiscText = ""; var discValue = 0; if (row.addlDiscountPercent > 0) { discValue = row.addlDiscountPercent; activeDiscPercent = "active"; activeDiscText = "%"; } else if (row.addlDiscountValue > 0 && row.DiscountGroupId > 0) { discValue = row.addlDiscountValue; activeDiscMul = "active"; activeDiscText = "Mul"; } else { discValue = row.addlDiscountValue; activeDiscVal = "active"; activeDiscText = "Val"; } var itemNameClass = "floating-label-form-group"; if (row.invoiceItemId != 0) itemNameClass = ""; var mt = ""; if (row.invoiceItemId != 0) { mt = "mt-5"; } if (row.orderItemId != 0) { mt = "mt-10"; } let AlternateUnitId = row.AlternateUnitId; let DefaultSize = row.DefaultSize; if (AlternateUnitId == undefined) { AlternateUnitId = 0; } if (row.ParentBOMItemId == null) row.ParentBOMItemId = 0; if (row.inventoryTypeId != 5 && row.inventoryTypeId != 6 && row.inventoryTypeId != 7) { var IsBom = ""; if (row.IsBoMItem == true && row.IsBoMItem != undefined) { IsBom = "hidden"; } var isbomitem = false; if (row.ParentBOMItemId != 0) isbomitem = true; var html = '
' + '
' + '
' + '
' + 'Item Name' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + ''; if (row.IsFoc == true) { html += ''; } html += '
' + ' '; if (row.invoiceItemId != 0) { var itemName = row.itemSKU + ' - ' + row.itemName; if (row.ExchangeItem) itemName = '(Exchange) ' + row.itemSKU + ' - ' + row.itemName; html += '' + itemName + ''; } else { var itemName = ""; if (row.ExchangeItem) itemName = '(Exchange) ' + row.itemName; else if (row.itemName != "" && row.itemSKU != "") { itemName = row.itemSKU + '-' + row.itemName; html += '' + itemName + ''; } else if (row.itemName != "") { itemName = row.itemName; html += '' + itemName + ''; } else { html += ''; } } html += '
' + '
' + '
' + '
' + 'Qty' + '' + '
' + '
' + '
' + '
Unit Price'; var readonly = ""; html += ''; html += '
' + '' + '
' + '
' + 'Disc.' + '' + '' + '' + '' + '
' + '' + '
' + '' + '
' + '
' + '
' + '
' + '
' + '' + '' + '' + ''; if (($(".hdn_invoicetypeid").val() == "2") && invoiceid != 0) { html += ''; html += ''; } else { html += '

Total:0.00

'; } html += '
' + '
' + '

' + ' ' + '
' + '