12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381 |
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var Bizgaze;
- (function (Bizgaze) {
- let Apps;
- (function (Apps) {
- let Transact;
- (function (Transact) {
- let Controls;
- (function (Controls) {
- class Pos extends Unibase.Platform.Core.BaseComponent {
- constructor() {
- super(...arguments);
- this.userCart = [];
- this.userCartDiscount = [];
- this.userCartTax = [];
- this.selectedItemsArray = [];
- this.offerItemsArray = [];
- this.itemImage = [];
- this.isBootBoxRendered = false;
- this.allEventsExecuted = false;
- this.IswalkinCustomer = false;
- this.EnableTenantTcs = false;
- this.TurnOver = 0;
- this.TaxRate = 0;
- this.ContactTcsEnable = false;
- this.PanAvailable = false;
- this.totalDiscountValue = 0;
- this.totalTaxAmount = 0;
- this.selectedPlanArray = [];
- this.cartInst = Bizgaze.Apps.Transact.Controls.CartItem.Instance();
- this.isKeyboard = false;
- this.offerPriceList = [];
- this.offerItemPriceAdded = false;
- this.isCheckoutMode = false;
- }
- init(formpropertyid, prop, callback) {
- var instance = this;
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(['platform/core/helpers/numberhelper/numberhelper.js', 'apps/transact/managers/invoicemanager.js', 'apps/transact/managers/paymentterms/paymenttermmanager.js', 'apps/transact/managers/offers/offermanager.js', 'tenants/themes/compact/components/details/details.js', 'platform/forms/components/formviewer/formviewer.js', 'libs/parsley/parsley.min.js', 'apps/transact/components/invoices/itemofferselection.js', 'apps/transact/controls/orders/orderitems.component.js', 'apps/transact/controls/orders/order.component.js', 'apps/transact/controls/payments/wallet.component.js', 'apps/transact/controls/invoices/cartitem.component.js', 'libs/kioskboard/kioskboard.min.js'], function () {
- instance.isdraft = false;
- instance.invoiceid = $(".hdn_invoiceid").val();
- if (instance.invoiceid != "0") {
- instance.bindEditInvoiceDetails(instance.invoiceid);
- }
- });
- }
- loadControl(containerid, prop) {
- this.fileCacheHelper.loadJsFile("apps/transact/managers/invoicemanager.js", () => {
- this.containerId = containerid;
- });
- this.fileCacheHelper.loadCssFiles(["apps/transact/controls/invoices/pos-styles.css", "libs/kioskboard/kioskboard.min.css"], () => { });
- }
- setProductDetails(html, containerid) {
- var accountId = 0;
- var branchId = Unibase.Platform.Membership.Infos.Identity.currentUser.settings.find(x => x.settingName == 'branchid').settingValue;
- $(".hdn_branchid").val(branchId);
- this.contactId = $(".hdn_organizationid").val();
- const formParentEl = $('.simple-scroll-bar.formviewer_id');
- const modalHeaderHeight = formParentEl.siblings('.modal-header').outerHeight(true);
- const modalFooterHeight = formParentEl.siblings('.modal-footer').outerHeight(true);
- formParentEl.addClass('pos-modal-body').css('height', `calc(100% - ${modalHeaderHeight + modalFooterHeight}px)`);
- this.lobId = $(".txtAutoComplete_lobid").val();
- if (this.lobId != undefined && this.lobId != 0) {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getproductsbyLobid(this.lobId).then((responce) => {
- var taxInclusive = true;
- if (responce.result.length > 0) {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getItemsUnitPriceByProductId(responce.result[0].ProductId, this.contactId, null).then((res) => {
- if (res.result.length > 0) {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/ledgers/ledgermanager.js", () => {
- Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().getLobLedgerSetting(this.lobId, branchId).then((response) => {
- accountId = response.result.SettingValue1;
- this.updateDataArray(res.result, accountId);
- this.dataBeforeSearch = res.result;
- this.resBeforeSearch = res;
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getpricebyProductId("a", this.lobId, responce.result[0].ProductId).then((data) => {
- html = `<div class='card section-products-items border-0 mb-0 shadow-none'><div class='card-body row m-0 pa-0'>${this.createProductsGroup(responce.result)}`;
- $("#" + containerid).html(html);
- this.allEventsExecuted = false;
- this.itemInfoElement = null;
- this.productContainerElement = null;
- this.productInfoElement = null;
- this.cartInfoElement = null;
- $(".products-container .products-container-body").append(this.createItemsList(res.result, false, false));
- !this.allEventsExecuted && this.eventListeners();
- this.initializeCarousel();
- this.initializeKeyBoard();
- this.applyCartBodyHeight();
- });
- });
- });
- }
- else {
- html = `<div class='card section-products-items'><div class='card-body row m-0 pa-0'>${this.createProductsGroup(responce.result)}</div></div>`;
- $("#" + containerid).html(html);
- this.allEventsExecuted = false;
- this.itemInfoElement = null;
- this.productContainerElement = null;
- this.productInfoElement = null;
- this.cartInfoElement = null;
- $(".products-container .products-container-body").append(this.createItemsList(res.result, false, true));
- $('#poscart_details').find('.Section').first().find(".card-body").first().append(Bizgaze.Apps.Transact.Controls.CartItem.Instance().getCartHtml());
- !this.allEventsExecuted && this.eventListeners();
- this.initializeCarousel();
- this.initializeKeyBoard();
- this.applyCartBodyHeight();
- $(".btn_Save_Form").hide();
- $(".btnSection_CardPayment").removeClass("btn-primary");
- $(".btnSection_CardPayment").addClass("btn-dark");
- }
- });
- }
- else {
- html = `<div class='card section-products-items'><div class='card-body row m-0 pa-0'>${this.createProductsGroup(responce.result)}</div></div>`;
- $("#" + containerid).html(html);
- this.allEventsExecuted = false;
- this.itemInfoElement = null;
- this.productContainerElement = null;
- this.productInfoElement = null;
- this.cartInfoElement = null;
- $(".products-container .products-container-body").append(this.createItemsList(responce.result, false, true));
- $('#poscart_details').find('.Section').first().find(".card-body").first().append(Bizgaze.Apps.Transact.Controls.CartItem.Instance().getCartHtml());
- this.initializeKeyBoard();
- this.applyCartBodyHeight();
- !this.allEventsExecuted && this.eventListeners();
- }
- });
- }
- else {
- this.renderSampleTemplate();
- }
- }
- initializeCarousel() {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadFile({
- FileName: 'libs/owl.carousel/owl.carousel.min.js',
- FileType: Unibase.Platform.Helpers.FileType.Js
- }, function () {
- $('.products-container-data').owlCarousel({
- items: 5,
- margin: 10,
- autoplay: false,
- nav: true,
- });
- });
- }
- initializeKeyBoard() {
- let kioskboard = `KioskBoard.Init({
- keysArrayOfObjects: null,
- keysJsonUrl: 'libs/kioskboard/kioskboard-keys-english.json',
- specialCharactersObject: null,
- language: 'en',
- theme: 'Material',
- capsLockActive: true,
- allowRealKeyboard: false,
- allowMobileKeyboard: false,
- cssAnimations: false,
- cssAnimationsStyle: 'slide',
- keysAllowSpacebar: true,
- keysSpacebarText: 'Space',
- keysFontFamily: 'sans-serif',
- keysFontSize: '22px',
- keysFontWeight: 'normal',
- keysIconSize: '25px',
- autoScroll: true,
- });
- KioskBoard.Run('.virtual-keyboard');
- `;
- eval(kioskboard);
- }
- runVirtualKeyboard() {
- let kioskboardRun = `KioskBoard.Run('.virtual-keyboard');`;
- eval(kioskboardRun);
- }
- applyCartBodyHeight() {
- let cartParentEl = $('#poscart_details .cart-container');
- let cartHeaderHeight = cartParentEl.find('.card-header').outerHeight(true);
- let cartFooterHeight = cartParentEl.find('.cart-footer').outerHeight(true);
- let deductHeight = cartHeaderHeight + cartFooterHeight;
- cartParentEl.find('.cart-body').css('height', `calc(100% - ${deductHeight}px)`);
- }
- renderSampleTemplate() {
- let html = `<div class="section_ItemDetails card products-container section-products-items">
- <div class="card-header"> Item Details </div>
- <div class="card-body products-container-body pl-0 py-0">
- <div class="row products-container-data">
- <p class=""> Please select the LOB to show info...</p>
- </div>
- </div>
- </div>`;
- $("#" + this.containerId).html(html);
- !this.allEventsExecuted && this.eventListeners();
- }
- totalDiscount() {
- this.totalDiscount;
- for (var i = 0; i < this.userCart.length; i++) {
- let itemId = this.userCart[i].itemId;
- let itemPrice = this.userCart[i].itemPrice;
- let itemDiscount = this.userCart[i].discountValue * this.userCart[i].quantity;
- if (itemPrice > 0) {
- this.totalDiscountValue = this.totalDiscountValue + itemDiscount;
- }
- }
- }
- getOfferDetails(itemDetails, focItemId) {
- var price = (itemDetails.quantity * itemDetails.itemPrice).toFixed(2);
- var orderItems = [];
- var instance = this;
- var result;
- orderItems.push({
- ItemId: Number(itemDetails.itemId),
- Quantity: Number(parseFloat(itemDetails.quantity).toFixed(2)),
- RowTotal: Number(price),
- });
- var data = {
- OrderItems: orderItems,
- ContactId: Number(instance.contactId),
- ApplyType: 1,
- };
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getOffersByItemIdWithPrice(data).then((response) => {
- if (response.result != null && response.result != "") {
- for (var i = 0; i < response.result.length; i++) {
- var result = response.result[i];
- var offer = response.result[i].Offer;
- var index = this.userCart.findIndex(x => x.itemId == itemDetails.itemId);
- var discount = "";
- if (offer.DiscountType == 1) {
- if (index != -1) {
- discount = offer.PayoutValue;
- this.userCart[index].discountValue = offer.PayoutValue;
- this.userCart[index].discountRate = parseFloat(((offer.PayoutValue / (itemDetails.itemPrice * itemDetails.quantity)) * 100).toString()).toFixed(0);
- }
- }
- else if (offer.DiscountType == 2) {
- var discountPercentage = offer.PayoutPercent;
- discount = parseFloat(((itemDetails.itemPrice) * (discountPercentage / 100)).toString()).toFixed(2);
- if (index != -1) {
- this.userCart[index].discountValue = discount;
- this.userCart[index].discountRate = offer.PayoutPercent;
- }
- }
- else if (offer.DiscountType == 3) {
- if (index != -1) {
- this.userCart[index].discountValue = offer.OPayoutValue;
- discount = offer.OPayoutValue;
- }
- }
- let cartContainerItemElement = document.querySelector(".cart-container [data-itemId='" + itemDetails.itemId + "'][data-productId='" + itemDetails.productId + "']");
- if (cartContainerItemElement) {
- $(cartContainerItemElement).find('.item-discount').removeClass("d-none");
- $(cartContainerItemElement).find('.item-discount').text(" - (" + this.userCart[index].discountRate + "%)");
- $(cartContainerItemElement).find(".total-accessible-price").text((((itemDetails.quantity * itemDetails.itemPrice) - Number(discount)).toFixed(2)).toString());
- }
- this.userCart[index].accessibleAmount = parseFloat((itemDetails.itemPrice - Number(discount)).toString()).toFixed(2);
- if (offer.ItemVolumePayouts.length > 0) {
- for (var j = 0; j < offer.ItemVolumePayouts.length; j++) {
- var offerItem = offer.ItemVolumePayouts[j];
- if (itemDetails.quantity >= offerItem.Recur) {
- var imageurl = offerItem.ImageUrl;
- if (imageurl != null && imageurl != undefined && imageurl != "") {
- var image = imageurl.split("~");
- var imageIndex = this.itemImage.findIndex(x => x.itemId == offerItem.ItemId);
- if (imageIndex == -1) {
- this.itemImage.push({ "itemId": offerItem.ItemId, "image": image[1] });
- }
- }
- var _itemDetails = result.ItemDetails;
- var unitprice = _itemDetails.find(x => x.ItemId == offerItem.ItemId);
- var price = unitprice.UnitPrice;
- var tax = unitprice.TaxRate;
- var focValue = ((offerItem.Discount / 100) * price).toString();
- var discountItemPrice = Number(parseFloat(focValue).toFixed(2));
- var effectivePrice = price - discountItemPrice;
- var index = this.userCart.findIndex(x => x.offerrefid == itemDetails.itemId && x.itemId == offerItem.ItemId && x.productId == 0);
- if (index == -1) {
- if (focItemId != null && focItemId != undefined && focItemId != 0) {
- if (offerItem.ItemId == focItemId) {
- this.userCart.push({ lobId: this.lobId, productId: 0, itemId: offerItem.ItemId, quantity: offerItem.Quantity, itemPrice: price, itemName: offerItem.ItemName, totalPrice: 0, offerrefid: itemDetails.itemId, isFOC: true, taxAmmount: 0, discountValue: discountItemPrice, discountRate: offerItem.Discount, accessibleAmount: effectivePrice, incentiveName: offer.IncentiveName });
- }
- }
- else {
- var offerItems = this.userCart.filter(x => x.offerrefid == itemDetails.itemId);
- if (offerItems.length > 0) {
- for (var k = 0; k < offerItems.length; k++) {
- if (offerItems[k].itemId == offerItem.ItemId) {
- this.userCart.push({ lobId: this.lobId, productId: 0, itemId: offerItem.ItemId, quantity: offerItem.Quantity, itemPrice: price, itemName: offerItem.ItemName, totalPrice: 0, offerrefid: itemDetails.itemId, isFOC: true, taxAmmount: 0, discountValue: discountItemPrice, discountRate: offerItem.Discount, accessibleAmount: effectivePrice, incentiveName: offer.IncentiveName });
- }
- }
- }
- else {
- if (!offerItem.IsFoC) {
- this.userCart.push({ lobId: this.lobId, productId: 0, itemId: offerItem.ItemId, quantity: offerItem.Quantity, itemPrice: price, itemName: offerItem.ItemName, totalPrice: 0, offerrefid: itemDetails.itemId, isFOC: true, taxAmmount: 0, discountValue: discountItemPrice, discountRate: offerItem.Discount, accessibleAmount: effectivePrice, incentiveName: offer.IncentiveName });
- }
- }
- }
- }
- else {
- this.userCart[index].quantity = parseInt(offerItem.Quantity);
- }
- this.cartInst.updateCartContainerHtml(offerItem.ItemId, 0);
- }
- }
- }
- else {
- var offerItemIndex = this.userCart.findIndex(x => x.offerrefid == itemDetails.itemId && x.incentiveName != offer.IncentiveName);
- if (offerItemIndex != -1) {
- this.removeItemFromItemCartAndUsercart(this.userCart[offerItemIndex].productId, this.userCart[offerItemIndex].itemId);
- }
- }
- }
- }
- });
- return result;
- }
- totalPrice(cartArrayList) {
- var total;
- var grandTotal = 0;
- for (var i = 0; i < cartArrayList.length; i++) {
- if (cartArrayList[i].isFOC) {
- total = cartArrayList[i].accessibleAmount * cartArrayList[i].quantity;
- }
- else {
- total = cartArrayList[i].itemPrice * cartArrayList[i].quantity;
- }
- grandTotal = grandTotal + total;
- }
- return grandTotal;
- }
- updateDataArray(itemsArray, accountId) {
- return __awaiter(this, void 0, void 0, function* () {
- var instance = this;
- for (var i = 0; i < itemsArray.length; i++) {
- var index = instance.selectedItemsArray.find(x => x.itemId == itemsArray[i].ItemId);
- if (index == undefined) {
- itemsArray[i].AccountId = 0;
- itemsArray[i].TaxGroupId = 0;
- instance.selectedItemsArray.push({ "UnitPrice": itemsArray[i].UnitPrice, "UnitName": itemsArray[i].UnitName, "UnitId": itemsArray[i].UnitId, "TaxAmount": itemsArray[i].TaxRate, "StatusId": itemsArray[i].StatusId, "SKU": itemsArray[i].SKU, "ProductName": itemsArray[i].ProductName, "productId": itemsArray[i].ProductId, "LobId": itemsArray[i].LobId, "itemId": itemsArray[i].ItemId, "actualPrice": itemsArray[i].UnitPrice - itemsArray[i].TaxRate, "taxGroupId": itemsArray[i].TaxGroupId, "accountId": itemsArray[i].AccountId, "accountName": itemsArray[i].AccountName, "isOfferAvailable": itemsArray[i].IsOfferAvailable, "isFocAvailable": itemsArray[i].IsFocAvailable, "itemName": itemsArray[i].ItemName });
- }
- }
- });
- }
- getLobAccountId(branchId) {
- return __awaiter(this, void 0, void 0, function* () {
- var accountId = 0;
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/ledgers/ledgermanager.js", () => {
- Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().getLobLedgerSetting(this.lobId, branchId).then((response) => {
- accountId = response.result.SettingValue1;
- });
- });
- return accountId;
- });
- }
- eventListeners() {
- if (!this.productContainerElement) {
- var timer;
- $("#txtSearchItem").unbind().on('change', () => {
- var delay = 1500;
- window.clearTimeout(timer);
- timer = window.setTimeout(() => {
- var searchtext = $("#txtSearchItem").val();
- if (searchtext != "") {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getItemsUnitPriceByProductId(0, this.contactId, searchtext).then((response) => {
- this.refreshItems(response, "");
- this.allEventsExecuted = false;
- this.eventListeners();
- });
- }
- else {
- this.refreshItems(this.resBeforeSearch, this.dataBeforeSearch);
- this.allEventsExecuted = false;
- this.eventListeners();
- }
- }, delay);
- });
- $(".txtAutoComplete_lobid").change(() => {
- });
- $("[id^=btn_CloseForm_]").click(() => {
- $(".section-products-items").remove();
- $("body").off("mousedown", "body", this.eventListeners);
- this.userCart = [];
- this.productContainerElement = null;
- this.itemInfoElement = null;
- this.productInfoElement = null;
- this.allEventsExecuted = false;
- this.isCheckoutMode = false;
- });
- $("#btnDynamicSave").prop('disabled', true);
- $(".txt_cashamount").change(() => {
- var totalstring = $("#grand_total_checkout").text();
- var total = parseFloat(totalstring);
- var ammountstring = $(".txt_cashamount").val();
- var ammount = parseFloat(ammountstring);
- if (ammount > total) {
- $("#btnDynamicSave").prop('disabled', false);
- }
- });
- $(".txt_cashamount").on('click', () => {
- this.isKeyboard = true;
- });
- var cash = $(".txt_cashamount").val();
- if (cash == "") {
- $("#btnDynamicSave").prop('disabled', true);
- }
- else {
- $("#btnDynamicSave").prop('disabled', false);
- }
- $(".btnSection_AddItems").click(() => {
- this.isCheckoutMode = false;
- $(".section_ContactInformation").hide();
- $(".section_PaymentInformation").hide();
- $(".section_CompanyDetails ").hide();
- $(".section_Items").show();
- $("#btn_SaveAsDraft").hide();
- $(".btn_Save_Form").hide();
- $('#billDetailsWrap').addClass('d-none');
- $('.cart-checkout-btn').removeClass('d-none');
- var lengnth = Bizgaze.Apps.Transact.Controls.Pos.Instance().userCart.length;
- if (lengnth == 0) {
- $('.cart-checkout-btn').addClass('d-none');
- }
- else {
- $('.cart-checkout-btn').removeClass('d-none');
- }
- this.applyCartBodyHeight();
- $(".txt_cashamount").val("");
- $(".txt_change").val("");
- });
- $(".btn_Save_Form").hide();
- $(".btn_SaveAsDraft").hide();
- var ammountstring = $(".txt_cashamount").val();
- var ammount = parseInt(ammountstring.toString());
- if (ammount > 0) {
- $(".div_cashamount").show();
- $(".div_change").show();
- }
- else {
- $(".div_cashamount").hide();
- $(".div_change").hide();
- }
- $(".divCustomProperties_upitypeid").removeClass('col-sm-12').hide();
- $(".divCustomProperties_voucherno").hide();
- $(".btnSection_CashPayment").click(() => {
- $(".div_cashamount").toggle();
- $(".div_change").toggle();
- $(".divCustomProperties_upitypeid").hide();
- $(".hdn_iscash").val("true");
- $(".hdn_iscard").val("false");
- $(".hdn_isupi").val("false");
- $("#btnDynamicSave").prop('disabled', true);
- });
- $(".btnSection_CardPayment").click(() => {
- $(".div_cashamount").hide();
- $(".div_change").hide();
- $(".txt_cashamount").val("0");
- $(".txt_change").val("0");
- $(".divCustomProperties_upitypeid").hide();
- $(".hdn_iscash").val("false");
- $(".hdn_iscard").val("true");
- $(".hdn_isupi").val("false");
- $("#btnDynamicSave").prop('disabled', false);
- });
- $(".btnSection_UpiPayment").click(() => {
- $(".div_cashamount").hide();
- $(".div_change").hide();
- $(".txt_cashamount").val("0");
- $(".txt_change").val("0");
- $(".divCustomProperties_upitypeid").toggle();
- $(".hdn_iscash").val("false");
- $(".hdn_iscard").val("false");
- $(".hdn_isupi").val("true");
- });
- $(".chk_isvoucher").click(() => {
- $(".divCustomProperties_voucherno").toggle();
- });
- if ($('.products-container-body').is(':visible')) {
- $(".section_ContactInformation").hide();
- $(".section_PaymentInformation").addClass('mb-0').hide();
- }
- this.productContainerElement = document.querySelector(".products-container .products-container-data");
- $('.products-container').on('click', '.group-name,.item-name', function () {
- let element = this;
- if (element.offsetWidth < element.scrollWidth) {
- $(this).popover('toggle');
- }
- });
- $('#pos_details').on('click', 'input:visible', function () {
- setTimeout(function () {
- if ($('#KioskBoard-VirtualKeyboard').is(':visible')) {
- let keyboardHeight = $('#KioskBoard-VirtualKeyboard').outerHeight(true);
- let posHeight = $('#pos_details').outerHeight(true);
- $('#pos_details').css('height', `${posHeight - (keyboardHeight - 70)}px`);
- }
- }, 100);
- });
- let parentEl = $('.pos_container');
- parentEl.find('#txtPhn_phonenumber,.txt_cashamount,.txt_change').addClass('virtual-keyboard').attr('data-kioskboard-type', 'numpad');
- parentEl.find('.txt_contactname').addClass('virtual-keyboard').attr({ 'data-kioskboard-type': 'keyboard', 'data-kioskboard-specialcharacters': 'false' });
- parentEl.find('.txt_contactemail').addClass('virtual-keyboard').attr({ 'data-kioskboard-type': 'all', 'data-kioskboard-specialcharacters': 'true' });
- const paymentSectionEl = $('.section_PaymentInformation');
- const paymentCardBodyRow = paymentSectionEl.find('.card-body .row').first();
- paymentCardBodyRow.addClass('mx-0').prepend('<div id="posPaymentModes" class="pos-payment-modes col-xl-3 col-lg-4 col-md-6"></div><div id="posPaymentDetails" class="pos-payment-details col-xl-9 col-lg-8 col-md-6"></div>');
- paymentSectionEl.find('#divSectionProperties_CashPayment,#divSectionProperties_CardPayment,#divSectionProperties_UpiPayment').removeClass('col-sm-4').detach().appendTo('#posPaymentModes');
- paymentCardBodyRow.find('.divCustomProperties').removeClass('col-sm-6').detach().appendTo('#posPaymentDetails');
- $('#posPaymentModes').find('.divSectionProperties').removeClass('mt-10').addClass('my-1').find('.btn').removeClass('btn-primary mt-20 text-white').addClass('w-100');
- $('#posPaymentModes').find('.btn.type-control').click(function () {
- $('#posPaymentModes').find('.btn.type-control').removeClass('active');
- $(this).addClass('active');
- });
- $('.btnSection_CashPayment').trigger('click');
- $(".btnSection_AddItems").removeClass('mt-20');
- }
- if (!this.productInfoElement) {
- this.productInfoElement = document.querySelector(".products-container .product-info");
- if (true) {
- $(".pos_container").mousedown((e) => {
- let virtualkeybord = e.target.closest(".kioskboard-row-numpad");
- let currentProductCard = e.target.closest(".product-info");
- let itemCard_clst = e.target.closest(".item-data");
- let btn_decrement_clst = e.target.closest(".item-decrement-btn");
- let btn_increment_clst = e.target.closest(".item-increment-btn");
- let btn_decrement = e.target.classList.contains(".item-decrement-btn");
- let btn_increment = e.target.classList.contains(".item-increment-btn");
- let cartInfo_clst = e.target.closest(".cart-item-info");
- let offerInfo = e.target.classList.contains(".item-offer-msg");
- if ($('#KioskBoard-VirtualKeyboard').is(':visible')) {
- $('#pos_details').css('height', `auto`);
- }
- if (currentProductCard) {
- let taxInclusive = true;
- var branchId = Unibase.Platform.Membership.Infos.Identity.currentUser.settings.find(x => x.settingName == 'branchid').settingValue;
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getItemsUnitPriceByProductId(currentProductCard.id, this.contactId, null).then((res) => {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/ledgers/ledgermanager.js", () => {
- Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().getLobLedgerSetting(this.lobId, branchId).then((response) => {
- var accountId = response.result.SettingValue1;
- this.updateDataArray(res.result, accountId);
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getpricebyProductId("a", this.lobId, currentProductCard.id).then((data) => {
- this.refreshItems(res, data.result);
- this.dataBeforeSearch = data.result;
- $(".products-container").find(".border-primary")[0].classList.remove("border-primary");
- currentProductCard.classList.add("border-2");
- currentProductCard.classList.add("border-primary");
- });
- });
- });
- });
- }
- else if ((itemCard_clst && (btn_decrement_clst || btn_increment_clst)) || (btn_decrement || btn_increment)) {
- this.setCart_ItemsContainers(itemCard_clst, e);
- }
- else if ((cartInfo_clst && (btn_decrement_clst || btn_increment_clst)) || (btn_decrement || btn_increment)) {
- let productId = parseInt(cartInfo_clst.dataset.productid);
- let itemId = parseInt(cartInfo_clst.dataset.itemid);
- let itemContainerCardElement = document.querySelector(".items-container [id='" + itemId + "']");
- let cartItem = document.querySelector(".cart-container [data-itemId='" + itemId + "'][data-productId='" + productId + "']");
- this.updateItemContainerSpinnerOnMDown(cartInfo_clst, e, false);
- (itemContainerCardElement) && this.updateItemContainerSpinnerOnMDown(itemContainerCardElement, e, true);
- !this.isBootBoxRendered && this.updateUserCart(cartItem, true);
- !this.isBootBoxRendered && this.cartInst.updateCartContainerHtml(itemId, productId);
- }
- else if (cartInfo_clst) {
- if (e.target.classList.contains("item-remove-btn") || e.target.closest(".item-remove-btn")) {
- let itemId = cartInfo_clst.dataset.itemid;
- let productId = cartInfo_clst.dataset.productid;
- this.renderDeleteItemDialog(productId, itemId);
- }
- }
- if (virtualkeybord == null && this.isKeyboard == true) {
- this.isKeyboard = false;
- var totalstring = $("#grand_total_checkout").text();
- var total = parseFloat(totalstring);
- var ammountstring = $(".txt_cashamount").val();
- var ammount = 0;
- if (ammountstring != "") {
- var ammount = parseFloat(ammountstring);
- }
- if (ammount < total) {
- $("#btnDynamicSave").prop('disabled', true);
- var diffAmt = Math.abs(ammount - total);
- setTimeout(() => {
- Unibase.Platform.Forms.Components.FormViewer.Instance().showError(" Rs " + parseFloat(diffAmt).toFixed(2) + " is Shortfall for Completion of the Payment");
- }, 200);
- $("#Bizgaze-messageInfo").fadeOut('fast');
- $(".txt_change").val("");
- }
- else if (ammount >= total) {
- $("#btnDynamicSave").prop('disabled', false);
- var changeAmt = ammount - total;
- $(".txt_change").val(parseFloat(changeAmt).toFixed(2));
- }
- }
- !this.allEventsExecuted && this.eventListeners();
- });
- }
- }
- if (!this.itemInfoElement) {
- this.itemInfoElement = document.querySelector(".products-container .item-info");
- if (this.itemInfoElement) {
- $(".item-quantity").change((e) => {
- let cartInfo_clst = e.target.closest(".item-info");
- this.setCart_ItemsContainers(cartInfo_clst, e);
- });
- }
- }
- if (!this.cartInfoElement) {
- this.cartInfoElement = document.querySelector(".cart-container .cart-item-info");
- if (this.cartInfoElement) {
- $(".cart-checkout-btn").click(() => {
- this.isCheckoutMode = true;
- var totalstring = $("#grand_total_checkout").text();
- ;
- var total = parseInt(totalstring);
- if (total > 0) {
- $(".section_ContactInformation").show();
- $(".section_PaymentInformation").show();
- $(".section_CompanyDetails ").hide();
- $(".section_Items").hide();
- $(".btn_Save_Form").show();
- $("#btn_SaveAsDraft").show();
- $('#billDetailsWrap').removeClass('d-none');
- $('.cart-checkout-btn').addClass('d-none');
- this.applyCartBodyHeight();
- }
- });
- }
- }
- $("#btnDynamicSave").click(() => {
- var instance = this;
- Bizgaze.Apps.Transact.Controls.Pos.Instance().userCart = [];
- Bizgaze.Apps.Transact.Controls.Pos.Instance().productContainerElement = null;
- Bizgaze.Apps.Transact.Controls.Pos.Instance().itemInfoElement = null;
- Bizgaze.Apps.Transact.Controls.Pos.Instance().productInfoElement = null;
- Bizgaze.Apps.Transact.Controls.Pos.Instance().allEventsExecuted = false;
- this.isCheckoutMode = false;
- });
- if (this.productContainerElement && this.productInfoElement && this.itemInfoElement && this.cartInfoElement)
- this.allEventsExecuted = true;
- }
- saveASDraft() {
- Bizgaze.Apps.Transact.Controls.Pos.Instance().isdraft = true;
- let detailContainer = "#" + Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
- $(".hdn_isdraft").val("true");
- var isDraft = $(".hdn_isdraft").val();
- if (isDraft == "true") {
- Bizgaze.Apps.Transact.Controls.Pos.Instance().isdraft = true;
- }
- else {
- Bizgaze.Apps.Transact.Controls.Pos.Instance().isdraft = false;
- }
- var cash = $(".txt_cashamount").val();
- if (cash == "") {
- $(".txt_cashamount").val("0");
- $(".txt_change").val("0");
- }
- $(detailContainer).find("#btnDynamicSave").click();
- }
- ;
- setCart_ItemsContainers(itemCard_clst, e) {
- let itemPriceElement = itemCard_clst.querySelector(".prodPrice");
- let itemPriceValue = parseInt(itemPriceElement.innerText);
- if (itemPriceValue > 0) {
- let productElement = document.querySelector(".products-container .border-primary").closest(".product-info");
- this.updateItemContainerSpinnerOnMDown(itemCard_clst, e, true);
- this.updateUserCart(itemCard_clst, false);
- let offeritem = this.userCart.filter(x => x.itemId == parseInt(itemCard_clst.id));
- offeritem.find(x => x.offerId != 0);
- this.cartInst.updateCartContainerHtml(parseInt(itemCard_clst.id), parseInt(productElement.id));
- }
- }
- updateCheckoutPrice() {
- if (this.invoiceid == 0) {
- this.totalTaxAmount = 0;
- }
- this.totalDiscountAmount = 0;
- this.totalAdjustmentAmmount = 0;
- for (var i = 0; i < this.userCart.length; i++) {
- let tax = parseFloat(this.userCart[i].taxAmmount);
- let actualAmount = (parseFloat(this.userCart[i].itemPrice)) * this.userCart[i].quantity;
- this.totalTaxAmount += (actualAmount) * (tax / 100);
- this.totalDiscountAmount += parseFloat(this.userCart[i].discountValue) * this.userCart[i].quantity;
- }
- $("#total_taxprice").text(parseFloat(this.totalTaxAmount).toFixed(2));
- $("#total_discountprice").text(parseFloat(this.totalDiscountAmount).toFixed(2));
- let totalVal = 0;
- var totalSum = this.totalPrice(this.userCart);
- let adjustmentprice = (Number(totalSum) - (Number(this.totalTaxAmount))).toFixed(2);
- $("#total_adjustmentprice").text(parseFloat(adjustmentprice).toFixed(2));
- $('.cart-checkout-btn .total-price').text(parseFloat(totalSum.toString()).toFixed(2));
- if (totalSum == 0) {
- $('.cart-checkout-btn').addClass('d-none');
- }
- else {
- if (!this.isCheckoutMode) {
- $('.cart-checkout-btn').removeClass('d-none');
- }
- }
- }
- updateItemContainerSpinnerOnMDown(itemCard_clst, e, isItemContainer, quantity) {
- let itemQantityElement;
- if (!isItemContainer) {
- itemQantityElement = $(itemCard_clst).find(".item-quantity");
- }
- else {
- itemQantityElement = $(itemCard_clst).find(".item-quantity");
- }
- let itemQantityValue = parseInt(itemQantityElement.val() || itemQantityElement.text());
- if (e != null) {
- if (e.target.closest(".item-decrement-btn")) {
- if (itemQantityValue == 1 && !isItemContainer) {
- this.renderDeleteItemDialog(parseInt(itemCard_clst.dataset.productid), parseInt(itemCard_clst.dataset.itemid));
- this.isBootBoxRendered = true;
- }
- else if (itemQantityValue == 1) {
- !this.isBootBoxRendered && this.renderDeleteItemDialog(parseInt(document.querySelector(".products-container .border-primary").id), parseInt(itemCard_clst.id));
- this.totalPrice(this.userCart);
- }
- else {
- if (itemQantityValue) {
- itemQantityElement.val((itemQantityValue - 1).toString());
- itemQantityElement.text((itemQantityValue - 1).toString());
- }
- else
- itemQantityElement.val("0");
- this.totalPrice(this.userCart);
- }
- }
- else if (e.target.closest(".item-increment-btn")) {
- if (itemQantityValue) {
- itemQantityElement.val((itemQantityValue + 1).toString());
- itemQantityElement.text((itemQantityValue + 1).toString());
- }
- else
- itemQantityElement.val("1");
- this.totalPrice(this.userCart);
- }
- }
- else if (quantity > 0) {
- itemQantityElement.val((quantity).toString());
- }
- }
- renderDeleteItemDialog(productId, itemId) {
- bootbox.confirm("Are you sure you want delete this Item ?", (result) => {
- let cartItem = document.querySelector(".cart-container [data-itemId='" + itemId + "'][data-productId='" + productId + "']");
- if (result) {
- this.removeItemFromItemCartAndUsercart(productId, itemId);
- var offeritems = this.userCart.filter(x => x.offerrefid == itemId);
- if (offeritems != null) {
- for (var i = 0; i < offeritems.length; i++) {
- this.removeItemFromItemCartAndUsercart(offeritems[i].productId, offeritems[i].itemId);
- }
- }
- }
- this.isBootBoxRendered = false;
- });
- }
- removeItemFromItemCartAndUsercart(productId, itemId) {
- this.removeCartItemFromCartContainer(productId, itemId);
- this.removeItemFromCart(parseInt(productId), parseInt(itemId));
- let itemhtml = document.getElementById(itemId);
- (itemhtml) && (itemhtml.querySelector(".item-quantity").value = "0");
- }
- removeItemFromCart(productId, itemId) {
- var ins = Bizgaze.Apps.Transact.Controls.Pos.Instance();
- let index = ins.userCart.findIndex(x => x.productId == productId && x.itemId == itemId);
- if (index != -1) {
- ins.userCart.splice(index, 1);
- this.updateCartItemsOnDelete();
- this.updateCheckoutPrice();
- }
- if (index == 0) {
- $(".total-pay-price-wrap").remove();
- $(".bill-details").remove();
- }
- }
- updateUserCart(itemCard, isCartItem) {
- let itemId;
- let productId;
- let productElement = document.querySelector(".products-container .border-primary").closest(".product-info");
- let itemPrice = parseFloat(itemCard.querySelector(".item-price").textContent).toFixed(2);
- let itemName = itemCard.querySelector(".item-name").textContent;
- let itemQantityElement = itemCard.querySelector(".item-quantity");
- var totalPrice = this.totalPrice(this.userCart);
- let discount = parseFloat(itemCard.querySelector(".discount_amount").value);
- let taxAmount = parseFloat(itemCard.querySelector(".item-tax-amount").value);
- (isCartItem) ? productId = parseInt(itemCard.dataset.productid) : productId = parseInt(productElement.id);
- (isCartItem) ? itemId = parseInt(itemCard.dataset.itemid) : itemId = parseInt(itemCard.id);
- ;
- let index = this.userCart.findIndex(x => x.itemId == itemId && x.productId == productId);
- if (index == -1) {
- var item = this.selectedItemsArray.find(x => x.itemId == itemId);
- var taxIndex = this.selectedItemsArray.findIndex(x => x.itemId == itemId && x.productId == productId);
- var taxAmmount = 0;
- if (taxIndex != -1) {
- taxAmmount = this.selectedItemsArray[taxIndex].TaxAmount;
- }
- if (item != null && item.isOfferAvailable) {
- this.userCart.push({ lobId: this.lobId, productId: productId, itemId: itemId, quantity: parseInt(itemQantityElement.value), itemPrice: itemPrice, itemName: itemName, totalPrice: totalPrice, offerrefid: 0, isFOC: false, discountValue: 0, taxAmmount: taxAmmount, accessibleAmount: itemPrice });
- var itemDetails = this.userCart.find(x => x.itemId == itemId);
- var offer = this.getOfferDetails(itemDetails);
- }
- else {
- this.userCart.push({ lobId: this.lobId, productId: productId, itemId: itemId, quantity: parseInt(itemQantityElement.value), itemPrice: itemPrice, itemName: itemName, totalPrice: totalPrice, offerrefid: 0, isFOC: false, discountValue: 0, taxAmmount: taxAmmount, accessibleAmount: itemPrice });
- }
- }
- else {
- this.userCart[index].quantity = parseInt(itemQantityElement.value);
- var itemDetails = this.userCart.find(x => x.itemId == itemId);
- var offer = this.getOfferDetails(itemDetails);
- }
- }
- updateCheckoutPageList() {
- if (this.invoiceid == 0) {
- this.totalTaxAmount = 0;
- }
- this.totalDiscountAmount = 0;
- this.totalAdjustmentAmmount = 0;
- for (var i = 0; i < this.userCart.length; i++) {
- let tax = this.userCart[i].taxAmmount;
- let actualAmount = (this.userCart[i].itemPrice - this.userCart[i].discountValue) * this.userCart[i].quantity;
- this.totalTaxAmount += (actualAmount) * (tax / 100);
- let taxammount = (actualAmount) * (tax / 100);
- this.totalDiscountAmount += this.userCart[i].discountValue * this.userCart[i].quantity;
- this.totalAdjustmentAmmount += ((actualAmount) - (taxammount));
- }
- }
- removeCartItemFromCartContainer(productId, itemId) {
- let cartItem = document.querySelector(".cart-container [data-itemId='" + itemId + "'][data-productId='" + productId + "']");
- (cartItem) && cartItem.remove();
- }
- updateCartItemsOnDelete() {
- let cartItemsEle = document.querySelector(".cart-container #cart-quantity");
- let firstEle = cartItemsEle.firstElementChild.outerHTML;
- firstEle += this.userCart.length + " Items";
- cartItemsEle.innerHTML = firstEle;
- }
- createProductsGroup(list) {
- let html = "";
- for (var i = 0; i < list.length; i++) {
- html += this.getProductsHtml(list[i]);
- if (i == 0)
- html = this.initialSelectedEffect(list[i], html);
- }
- return `<div class="col-12 px-0 products-container">
- <div class="card-body products-container-body">
- <div class="item-search-wrap"><input type="text" maxlength="50" class="form-control virtual-keyboard" id="txtSearchItem" value="" data-kioskboard-type="all" data-kioskboard-specialcharacters="false" data-isdynamic="false" placeholder="Search" data-placeholder="Search" data-label="Search"><i class="fa fa-search item-search-icon biz-highlight-bg-color"></i></div>
- <div class="products-container-data owl-carousel owl-theme mx-0" id="productsCarousel">
- ${html}
- </div>
- </div>
- </div>
- <div class="panel panel-default" style="padding-bottom: 10px;" id="invoiceitem">
- <input type="hidden" id="hdn_customcontrol" class="value-control" value="Bizgaze.Apps.Transact.Controls.Pos.Instance().loaddata();" />
- <input type="hidden" id="hdninvoiceitem" class="" value="" data-isdynamic="true" data-propdoctypename="" /></div>
- </div>`;
- }
- getProductsHtml(productGroupDetails) {
- var imageurl = productGroupDetails.UploadImage;
- var image = "";
- if (imageurl != null && imageurl != undefined && imageurl != "") {
- image = imageurl.split("~");
- this.productImage = image[1];
- }
- return `<div class="card product-info" id="${productGroupDetails.ProductId}"><div class="product-img-wrapper"><img src="${this.productImage}" class="product-img"></div><span class="group-name" tabindex="0" data-trigger="focus" data-placement="top" data-content="${productGroupDetails.ProductName}">${productGroupDetails.ProductName}</span></div>`;
- }
- loaddata() {
- var instance = this;
- var itemarray = [];
- var itemsarray = [];
- var totalAmount = 0;
- var branchId = Unibase.Platform.Membership.Infos.Identity.currentUser.settings.find(x => x.settingName == 'branchid').settingValue;
- for (var i = 0; i < instance.userCart.length; i++) {
- var data = instance.selectedItemsArray.find(x => x.productId == instance.userCart[i].productId && x.itemId == instance.userCart[i].itemId);
- if (data != undefined) {
- totalAmount = totalAmount + Number(instance.userCart[i].itemPrice);
- itemsarray.push({ "ItemId": instance.userCart[i].itemId, "UnitPrice": Number(instance.userCart[i].itemPrice), "istaxinclusive": true, "AccountId": data.accountId, "TotalAmount": Number(instance.userCart[i].itemPrice), "Quantity": instance.userCart[i].quantity, "DiscountAmount": instance.userCart[i].discountValue, "DiscountType": 1 });
- }
- else {
- totalAmount = totalAmount + Number(instance.userCart[i].itemPrice);
- itemsarray.push({ "ItemId": instance.userCart[i].itemId, "UnitPrice": Number(instance.userCart[i].itemPrice), "istaxinclusive": true, "AccountId": 0, "TotalAmount": Number(instance.userCart[i].itemPrice), "Quantity": instance.userCart[i].quantity, "DiscountAmount": instance.userCart[i].discountValue, "DiscountType": 1 });
- }
- }
- var InvoiceObject = {
- TotalAmount: Number(totalAmount),
- InvoiceItems: itemsarray,
- InvoiceCharges: [],
- AutoAdjustment: false,
- AutoDc: false,
- InvItemTaxAdjustments: [],
- JournalAlloc: [],
- AdjustmentAccountId: 0,
- InvoiceId: Number($(".hdn_invoiceid").val()),
- RefInvoiceId: 0,
- OrgContactId: branchId,
- DeletedInvoiceId: [],
- };
- return InvoiceObject;
- }
- createItemsList(itemsList, getRows, getHeader) {
- let html = "";
- for (var i = 0; i < itemsList.length; i++)
- html += this.createItemHtml(itemsList[i]);
- if (getRows)
- return html;
- else if (getHeader) {
- return `<div data-simplebar class="simple-scroll-bar items-container" id="itemsContainer">
- <div class="items-data">
- No items to display...
- </div>
- </div>`;
- }
- return `<div data-simplebar class="simple-scroll-bar items-container" id="itemsContainer">
- <div class="items-data">
- ${html}
- </div>
- </div>`;
- }
- createItemHtml(itemsDetails) {
- let index = this.userCart.findIndex(x => x.itemId == itemsDetails.ItemId);
- let items = this.userCart.filter(x => x.itemId == itemsDetails.ItemId);
- if (index != -1) {
- var quantity = this.userCart.find(x => x.itemId == itemsDetails.ItemId);
- if (items.length) {
- let chargableItem = items.find(x => x.isFOC == false);
- if (!chargableItem)
- itemsDetails["quantity"] = 0;
- else
- itemsDetails["quantity"] = quantity.quantity;
- }
- else
- itemsDetails["quantity"] = quantity.quantity;
- }
- else {
- itemsDetails["quantity"] = 0;
- }
- var imageurl = itemsDetails.ImageUrl;
- var image = "";
- if (imageurl != null && imageurl != undefined && imageurl != "") {
- image = imageurl.split("~");
- var imageIndex = this.itemImage.findIndex(x => x.itemId == itemsDetails.ItemId);
- if (imageIndex == -1) {
- this.itemImage.push({ "itemId": itemsDetails.ItemId, "image": image[1] });
- }
- image = image[1];
- }
- var offerString = "";
- if (itemsDetails.IsOfferAvailable || itemsDetails.IsFocAvailable) {
- offerString = '<div class="item-offer-msg"><span class="badge badge-primary"><i class="las la-tag mr-1 font-12"></i>Offer</span></div>';
- }
- return `<div class="item-data item-info" id="${itemsDetails.ItemId}" data-offerrefid="${itemsDetails.OfferRefId}">
- ` + offerString + `
- <div class="item-img-wrapper">
- <img src="${image}" class="item-img">
- </div>
- <div class="item-details-wrapper">
- <input class="item-tax-amount hidden" style="" value ="${itemsDetails.TaxAmount}">
- <input class="discount_amount d-none hidden" value="${itemsDetails.DiscountAmount}">
-
- <p class="item-name" tabindex="0" data-trigger="focus" data-placement="top" data-content="${itemsDetails.ItemName}">${itemsDetails.ItemName}</p>
- <div class="item-meta">
- <div class="item-price-wrapper">
- <span class="item-price prodPrice">${parseFloat(itemsDetails.UnitPrice).toFixed(2)}</span>
- </div>
- <div class="cart-counter">
- <a class="item-decrement-btn control-btn" href="javascript:;"><i class="las la-minus"></i></a>
- <input type="number" min="0" value="${itemsDetails.quantity}" class="prodQuantity item-quantity virtual-keyboard" data-kioskboard-type="numpad">
- <a class="item-increment-btn control-btn" href="javascript:;"><i class="las la-plus"></i></a>
- </div>
- </div>
- </div>
- </div>`;
- }
- refreshItems(res, data) {
- let html;
- if (res.result.length > 0)
- html = this.createItemsList(res.result, true);
- else if (res.result.length == 0)
- html = "No items to display...";
- $(".items-container .items-data").empty().append(html);
- $(".item-offer-msg").click(() => {
- var instance = this;
- var itemId;
- var itemDetails;
- Unibase.Platform.Helpers.NavigationHelper.Instance().popup(0, "", Bizgaze.Apps.Transact.Components.Invoices.ItemOfferSelection.Instance(), function () {
- itemId = document.getElementsByClassName("item-offer-msg")[0].parentElement.id;
- itemDetails = instance.selectedItemsArray.find(x => x.itemId == itemId);
- Bizgaze.Apps.Transact.Components.Invoices.ItemOfferSelection.Instance().LoadOfferItems(Number(instance.contactId), Number(itemId), itemDetails.itemName, 1, null, "Pos");
- }, Unibase.Platform.Helpers.Size.Large);
- });
- }
- initialSelectedEffect(product, htmlstr) {
- let index = htmlstr.indexOf("card");
- return htmlstr.substring(0, index + 4) + " border-2 border-primary " + htmlstr.substring(index + 4, htmlstr.length);
- }
- bindContactName() {
- var instance = this;
- Unibase.Platform.Forms.Managers.TagManager.Instance().GetTagItemsByUserId(Unibase.Platform.Membership.Infos.Identity.getCurrentUser().userId).then(function (response) {
- if (response.result.length == 1) {
- instance.fileCacheHelper.loadJsFile("apps/crm/lobs/managers/lobmanager.js", function () {
- Bizgaze.Apps.CRM.Lobs.Managers.LobManager.Instance().getLobByTagGroupId(response.result[0].TagGroupId).then(function (res) {
- let LobId = res.result.LobId;
- Bizgaze.Apps.CRM.Lobs.Managers.LobManager.Instance().getLobByLobId(LobId).then(function (result) {
- if (result.result != null) {
- if (result.result.DefaultContactId != 0) {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () {
- Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getOrgContact(result.result.DefaultContactId).then(function (response) {
- if (response.result != null) {
- let items = Bizgaze.Apps.Transact.Controls.Pos.Instance();
- var _Name = new Option(response.result.OrgContactName, response.result.OrgContactId.toString(), false, false);
- $(".txtAutoComplete_orgcontactid").append(_Name).trigger("change");
- $(".hfAutoCompleteId_orgcontactid").val(response.result.OrgContactId);
- instance.LoadContactDetails();
- }
- });
- });
- }
- }
- });
- });
- });
- }
- });
- $("#btnDynamicSave").after('<a href="javascript:;" id="btn_SaveAsDraft" class="btn btn-yellow btn_POSSaveAsDraft btn-sm" onclick="Bizgaze.Apps.Transact.Controls.Pos.Instance().saveASDraft();;" style="display:none" >Save as Draft</a>');
- $(".hdn_isdraft").val("false");
- }
- LoadContactDetails() {
- var instance = this;
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getorganization($(".hfAutoCompleteId_orgcontactid").val()).then(function (response) {
- if (response.result != null && response.result != "") {
- if (response.result.OrganizationTypeId == 1)
- instance.IswalkinCustomer = false;
- else
- instance.IswalkinCustomer = true;
- instance.LoadSpocDetails($(".hfAutoCompleteId_orgcontactid").val());
- }
- else {
- instance.IswalkinCustomer = false;
- instance.LoadSpocDetails($(".hfAutoCompleteId_orgcontactid").val());
- }
- });
- }
- LoadSpocDetails(contactid) {
- var instance = this;
- 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 (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) {
- instance.GetCustomerTurnOver();
- }
- $.when(instance.loadAddressAutoCompletes(response.result.OrganizationId)).then(function () {
- instance.BindAddressDetails(response.result.OrganizationId);
- 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) {
- instance.GetCustomerTurnOver();
- }
- $.when(instance.loadAddressAutoCompletes(response.result.OrganizationId)).then(function () {
- instance.BindAddressDetails(response.result.OrganizationId);
- instance.GetAvailableWallets(0);
- });
- }
- });
- }
- }
- GetCustomerTurnOver() {
- var instance = this;
- $(".txt_tcsadjustment").val("0");
- $("#chk_tcsapplied").unbind();
- $(".number_tcsamount").prop("disabled", true);
- $(".div_tcsadjustment").addClass("floating-label-form-group-with-value");
- $("#chk_tcsapplied").change(function () {
- if ($(this).prop('checked') == true && instance.EnableTenantTcs == false && ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2" || $(".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 ($('#chk_AutoAdjustment').prop("checked") == true) {
- $("#txt_Adjustment").val(0);
- $(".hdn_adjustment").val(0);
- }
- 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");
- instance.update_total();
- instance.TotalAdjustment();
- }
- else {
- $("#div_tcstaxrate").addClass("hidden");
- $(".div_tcsadjustment").addClass("hidden");
- $("#div_tcsamount").addClass("hidden");
- $('#chk_tcsapplied').prop('checked', false);
- $("#hdnchk_tcsapplied").val("false");
- instance.update_total();
- instance.TotalAdjustment();
- }
- });
- }
- else if ($(this).prop('checked') == true) {
- $("#div_tcstaxrate").removeClass("hidden");
- $(".div_tcsadjustment").removeClass("hidden");
- $("#div_tcsamount").removeClass("hidden");
- instance.update_total();
- instance.TotalAdjustment();
- }
- else {
- $("#div_tcstaxrate").addClass("hidden");
- $(".div_tcsadjustment").addClass("hidden");
- $("#div_tcsamount").addClass("hidden");
- instance.update_total();
- instance.TotalAdjustment();
- }
- }
- });
- $(".txt_tcsadjustment").unbind();
- $(".txt_tcsadjustment").blur(function () {
- if ($('#chk_AutoAdjustment').prop("checked") == true) {
- $("#txt_Adjustment").val(0);
- $(".hdn_adjustment").val(0);
- }
- instance.update_total();
- instance.TotalAdjustment();
- });
- $("#div_tcstaxrate").addClass("hidden");
- $(".div_tcsadjustment").addClass("hidden");
- $("#div_tcsamount").addClass("hidden");
- $("#chk_tcsapplied").prop("checked", false);
- $("#chk_tcsapplied").prop("disabled", false);
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getCustomerTurnOver($(".hdn_organizationid").val(), $(".hdn_invoiceid").val(), Pos.Instance().formatDate($(".date_journaldate").val()), $(".hdn_invoicetypeid").val()).then(function (response) {
- if (response.result != null) {
- $(".number_tcstaxrate").val(response.result.TaxRate);
- if (response.result.TCSTaxCodeId != 0) {
- $(".hdn_tcstaxcodeid").val(response.result.TCSTaxCodeId);
- $(".hdn_tcstaxcodeaccountid").val(response.result.TCSTaxCodeAccountId);
- $(".number_tcstaxrate").prop("disabled", true);
- }
- instance.TurnOver = response.result.TurnOver;
- instance.ContactTcsEnable = response.result.Enable;
- instance.EnableTenantTcs = response.result.EnableTenantTcs;
- instance.PanAvailable = response.result.PanAvailable;
- instance.TaxRate = response.result.TaxRate;
- if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2") {
- if (instance.ContactTcsEnable == true && instance.EnableTenantTcs == true) {
- $("#chk_tcsapplied").prop("checked", true);
- if ($(".hdn_invoicetypeid").val() == "1")
- $("#chk_tcsapplied").prop("disabled", "disabled");
- $("#hdnchk_tcsapplied").val("true");
- $("#div_tcstaxrate").removeClass("hidden");
- $(".div_tcsadjustment").removeClass("hidden");
- $("#div_tcsamount").removeClass("hidden");
- $(".number_tcsamount").prop("disabled", true);
- }
- else if (instance.TurnOver > 5000000 && $(".hdn_invoicetypeid").val() == "1") {
- $("#chk_tcsapplied").prop("checked", true);
- $("#chk_tcsapplied").prop("disabled", "disabled");
- $("#hdnchk_tcsapplied").val("true");
- $("#div_tcstaxrate").removeClass("hidden");
- $(".div_tcsadjustment").removeClass("hidden");
- $("#div_tcsamount").removeClass("hidden");
- $(".number_tcsamount").prop("disabled", true);
- }
- }
- else if ($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "7") {
- $("#chk_tcsapplied").prop("checked", false);
- $("#hdnchk_tcsapplied").val("false");
- $("#div_tcstaxrate").addClass("hidden");
- $(".div_tcsadjustment").addClass("hidden");
- $("#div_tcsamount").addClass("hidden");
- }
- if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && $('#hfInv_RefInvoiceId').val() == 0 && $("#hf_AppSettingName").val() == "Create Return") {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceDetails(($(".hdn_invoicetypeid").val())).then(function (res) {
- if (res.result != null && res.result != "") {
- instance.TaxRate = res.result.TcsTaxRate;
- $(".number_tcstaxrate").val(res.result.TcsTaxRate);
- $(".hdn_tcstaxcodeid").val(response.result.TcsTaxCodeId);
- if (res.result.TcsTaxCodeId != 0) {
- $(".number_tcstaxrate").prop("disabled", true);
- }
- $(".number_tcsamount").prop("disabled", true);
- }
- });
- }
- }
- });
- }
- loadAddressAutoCompletes(organizationid) {
- var instance = this;
- 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 () {
- $.when(instance.loadLobAndSp()).then(function () {
- 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(instance.loadLobAndSp()).then(function () {
- 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);
- }
- }
- BindAddressDetails(orgid) {
- var instance = this;
- 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 () {
- instance.bindSeries($(".txtAutoComplete_lobid").val(), $(".txtAutoComplete_billtoaddressid"));
- instance.bindAdjustmentAccount($(".txtAutoComplete_lobid").val(), responce.result.BranchId);
- });
- }
- else {
- $(".txtAutoComplete_shipfromaddressid").append(ShipTo);
- $(".txtAutoComplete_billfromaddressid").append(BillTo);
- $(".txtAutoComplete_billfromaddressid").change(function () {
- instance.bindSeries($(".txtAutoComplete_lobid").val(), $(".txtAutoComplete_billfromaddressid"));
- 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(instance.loadLobAndSp()).then(function () {
- instance.BindLoB();
- });
- });
- instance.getGSTNo();
- }
- else {
- $(".txtAutoComplete_shipfromaddressid").append(ShipTo);
- $(".txtAutoComplete_billfromaddressid").append(BillTo);
- $(".txtAutoComplete_billfromaddressid").change(function () {
- $.when(instance.loadLobAndSp()).then(function () {
- instance.BindLoB();
- });
- });
- instance.getGSTNo();
- }
- if (response.result.GSTNO != "" && response.result.GSTNO != null)
- $(".txt_gstno").val(response.result.GSTNO);
- $.when(instance.loadLobAndSp()).then(function () {
- instance.BindLoB();
- });
- }
- else {
- MessageHelper.Instance().showError("Please assign billing address and shipping address", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
- }
- });
- });
- }
- GetAvailableWallets(invoiceid) {
- var instance = this;
- var ContactId = $(".hdn_organizationid").val();
- var invoiceId = 0;
- if (invoiceid != 0 && $('#hfInv_IsRetun').val() != "1") {
- invoiceId = Number($(".hdn_invoiceid").val());
- }
- if (invoiceId != 0)
- instance.GetJournalAlloc(invoiceId);
- var invoicedate = $('.date_journaldate').val();
- var invdate = instance.formatDate(invoicedate);
- var lobid = $(".txtAutoComplete_lobid").val();
- 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);
- }
- });
- });
- }
- update_total() {
- var instance = this;
- var totalAmount = 0;
- var totalDiscountAmount = 0;
- var totalNonDiscountedAmount = 0;
- var totalTaxAmount = 0;
- var totalTaxAdjustment = 0;
- var totalAsseableAdjustment = 0;
- var totalQty = 0;
- var totalDiscountPercent = 0;
- var totalDiscountValue = 0;
- var totalAddlDiscountPercent = 0;
- var totalAddlDiscountValue = 0;
- var totalExpensePercent = 0;
- var totalExpenseValue = 0;
- var addexpenserow_total = 0;
- $('.expense-row-total').each(function (i) {
- var expense_row_total = Number($(this).html());
- addexpenserow_total += expense_row_total;
- });
- var ConsumedWalletValue = 0;
- var totalTaxPercent = 0;
- var totalTaxValue = 0;
- var totalCreditNote = 0;
- var adddiscountrow_total = 0;
- var netadddiscountrow_total = ConsumedWalletValue;
- $('.discount-row-total').each(function (i) {
- var discount_row_total = Number($(this).html());
- adddiscountrow_total += discount_row_total;
- });
- $('.netdiscount-row-total').each(function (i) {
- var discount_row_total = Number($(this).html());
- netadddiscountrow_total += discount_row_total;
- });
- var itemdiscount_total = 0;
- var totalLineAmount_total = 0;
- $('.hfRowTotal').each(function (i) {
- var element = $(this).parents(".item-row");
- if (!element.hasClass('SplitItem')) {
- var totalLineAmount = Number($(this).val());
- if (!isNaN(totalLineAmount))
- totalLineAmount_total += Number(totalLineAmount);
- var discountPercent = 0;
- var discountValue = 0;
- var quantity = Number(element.find(".prodQuantity").val());
- var unitPrice = Number(element.find(".prodPrice").val());
- var exciseAmount = Number(element.find(".exciseAmount").val());
- if (isNaN(exciseAmount))
- exciseAmount = 0;
- var nonexciseAmount = totalLineAmount - exciseAmount;
- if (element.find(".btnInvoice_DiscType option:selected").text().trim() == 'Val' && element.find('.inv_txtaddldiscount').val() != '' && element.find('.inv_txtaddldiscount').val() != undefined) {
- discountValue = Number(element.find('.inv_txtaddldiscount').val());
- }
- else if (element.find(".btnInvoice_DiscType option:selected").text().trim() == '%' && element.find('.inv_txtaddldiscount').val() != '' && element.find('.inv_txtaddldiscount').val() != undefined) {
- discountPercent = Number(element.find('.inv_txtaddldiscount').val());
- }
- else if (element.find(".btnInvoice_DiscType option:selected").text().trim() == 'Mul') {
- if (element.find('#hfProdDiscountList').val() != '' || element.find('#hfProdDiscountApplyTypes').val() != '') {
- var discountsArray = element.find('#hfProdDiscountList').val().toString().split(',');
- var applyTypes = element.find('#hfProdDiscountApplyTypes').val().toString().split(',');
- var price = Number(unitPrice) * Number(quantity);
- var currentAmount = Number(unitPrice) * Number(quantity);
- $.each(discountsArray, function (j) {
- var percent = discountsArray[j];
- var applyType = applyTypes[j];
- var discount = 0;
- if (applyType == 'NET' || applyType == '1') {
- discount = Number(price) * Number(percent) / 100;
- currentAmount -= Number(discount);
- }
- else {
- discount = Number(currentAmount) * Number(percent) / 100;
- currentAmount -= Number(discount);
- }
- discountValue += Number(discount);
- });
- element.find('.inv_txtaddldiscount').val(discountValue);
- }
- else {
- discountValue = Number(element.find('.inv_txtaddldiscount').val());
- }
- }
- if (!isNaN(discountPercent))
- totalDiscountPercent += Number(discountPercent);
- if (!isNaN(discountValue))
- totalAddlDiscountValue += Number(discountValue);
- var discountAmount = 0;
- discountAmount = (Number(nonexciseAmount) * Number(discountPercent) / 100)
- + (Number(quantity) * Number(discountValue));
- discountAmount = Number(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discountAmount, 2));
- itemdiscount_total += discountAmount;
- var discountedAmount = Number(totalLineAmount) - Number(discountAmount);
- totalDiscountAmount += Number(discountAmount);
- element.find(".hfDiscountedAmount").val(discountAmount);
- if ($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "7") {
- element.find(".txtRowTotalwithAdjustment").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalLineAmount - discountAmount, 2));
- }
- else
- element.find(".prodTotalPrice").html(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalLineAmount - discountAmount, 2).toString());
- }
- });
- }
- TotalAdjustment() {
- if ($('#chk_AutoAdjustment').is(':checked')) {
- var total = $('.nettotal').text();
- var splitTotal = total.split('.');
- var AdjustmentValue = 0;
- var splitedAdjestment = 0;
- $("#txt_Adjustment").val(0);
- $(".hdn_adjustment").val(0);
- if (!isNaN(Number($('#txt_Adjustment').val()))) {
- AdjustmentValue = Number($('#txt_Adjustment').val());
- }
- if (Number(splitTotal[1]) > 0) {
- if (Number(splitTotal[1]) >= 50) {
- splitedAdjestment = (100 - Number(splitTotal[1])) / 100;
- AdjustmentValue += splitedAdjestment;
- $('#txt_Adjustment').val(Number(AdjustmentValue).toFixed(2)).blur();
- $(".hdn_adjustment").val($('#txt_Adjustment').val());
- $("#span_Adjustment").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(AdjustmentValue, 2));
- $('.nettotal').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber((Number(total) + AdjustmentValue), 2));
- }
- else {
- splitedAdjestment = Number(splitTotal[1]) / 100;
- AdjustmentValue -= splitedAdjestment;
- $('#txt_Adjustment').val(Number(AdjustmentValue).toFixed(2));
- $(".hdn_adjustment").val($('#txt_Adjustment').val());
- $("#span_Adjustment").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(AdjustmentValue, 2));
- $('.nettotal').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber((Number(total) + AdjustmentValue), 2));
- }
- }
- }
- else {
- $("#span_Adjustment").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number($('#txt_Adjustment').val()), 2));
- $('.nettotal').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber((Number($('.nettotal').text()) + Number($('#txt_Adjustment').val())), 2));
- }
- }
- 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() {
- var instance = this;
- $(".txtAutoComplete_lobid").empty();
- $('#hf_AdjustmentAccountId').val("0");
- $('#txt_AdjustmentAccountName').empty();
- if ($(".hdn_invoiceid").val() == "0") {
- $(".InvoiceItems").find(".item-addedrow").remove();
- instance.SplitedInvoiceItemList = new Array();
- instance.itemIds = [0];
- instance.itemIds = [0];
- $("#txt_Adjustment").val("0");
- $("#span_Adjustment").text("0");
- instance.update_total();
- 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 () {
- Bizgaze.Apps.CRM.Lobs.Managers.LobManager.Instance().getLobsByAddressId(Number(AddressId)).then(function (response) {
- let items = Bizgaze.Apps.Transact.Controls.Pos.Instance();
- 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);
- !items.productContainerElement && items.setProductDetails("", items.containerId);
- instance.BindSalesPerson(AddressId);
- 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();
- instance.bindSeries($(".txtAutoComplete_lobid option:selected").val(), Addr);
- instance.bindAdjustmentAccount(response.result[0].LobId, Addr);
- }
- }
- else {
- $(".section_CartItems").remove();
- items.renderSampleTemplate();
- items.productContainerElement = null;
- items.productInfoElement = null;
- items.allEventsExecuted = false;
- }
- });
- });
- $(".txtAutoComplete_lobid").change(function () {
- 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();
- }
- instance.BindSalesPerson(Billto);
- instance.bindSeries($(".txtAutoComplete_lobid option:selected").val(), Address);
- instance.bindAdjustmentAccount($(".txtAutoComplete_lobid option:selected").val(), Address);
- $(".InvoiceItems").find(".item-addedrow").remove();
- instance.SplitedInvoiceItemList = new Array();
- instance.itemIds = [0];
- instance.dcItemIds = [0];
- $("#txt_Adjustment").val("0");
- instance.update_total();
- instance.TotalAdjustment();
- });
- }
- bindSeries(lobid, branchid) {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getSeries($("#hf_FormInstalledAppId").val(), lobid, branchid).then(function (response) {
- if (response.result != null) {
- if (response.result.length > 0) {
- $(".txtSeriesAutoComplete_seriesid").empty();
- $(".txtSeriesAutoComplete_seriesid").append(new Option(response.result[0].SeriesName, response.result[0].SeriesId.toString(), true));
- $(".txtSeriesAutoComplete_seriesid").val(response.result[0].SeriesId);
- }
- 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);
- }
- }
- });
- }
- }
- 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);
- }
- });
- });
- }
- getGSTNo() {
- var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- var gstno = "";
- 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;
- }
- 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);
- }
- });
- });
- }
- }
- 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('-');
- }
- 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);
- }
- });
- });
- }
- bindDefaultPaymentTerm(organizationid, lobid) {
- $('.hfAutoCompleteId_paymenttermid').val(0);
- $('.txtAutoComplete_paymenttermid').empty();
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/paymentterms/paymenttermmanager.js", function () {
- 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);
- }
- }
- });
- });
- }
- loadControlSettings(controlsettingjson, formpropertyid) {
- }
- loadPropertySettings(propertysettings, formpropertyid) {
- }
- bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
- this.bindEditInvoiceDetails(propval);
- }
- bindEditInvoiceDetails(invoiceid) {
- var instance = this;
- $(".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 = [{ "ColumnName": "companyid", "Value": companyId }];
- Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_orgcontactid"), Parameters);
- if (data.OrgContactId == 0) {
- instance.IswalkinCustomer = true;
- $(".hfAutoCompleteId_orgcontactid").val(data.OrganizationId);
- var selectedCompany = new Option(data.OrganizationName, data.OrganizationId, true);
- }
- else {
- instance.IswalkinCustomer = false;
- $(".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_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);
- $('.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(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.ShipFromAddressId, true));
- }
- instance.loadLobAndSp();
- 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();
- 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);
- 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.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;
- }
- $(".chk_excludefromcampaign").prop("checked", data.ExcludeFromCampaign);
- $("#hfId_istaxinclusive").val(data.IsTaxInclusive);
- $(".dropdown_istaxinclusive").val(data.IsTaxInclusive.toString());
- $(".dropdown_paymentmethodid").val(data.PaymentMethodId);
- instance.GetAvailableWallets(data.InvoiceId);
- instance.loadOrderPendingItems();
- });
- $(".txtAutoComplete_orgcontactid").change(function () {
- 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(), instance.formatDate($(".date_journaldate").val()), $(".hdn_invoicetypeid").val()).then(function (res) {
- if (res.result != null) {
- instance.TurnOver = res.result.TurnOver;
- instance.ContactTcsEnable = res.result.Enable;
- instance.EnableTenantTcs = res.result.EnableTenantTcs;
- instance.PanAvailable = res.result.PanAvailable;
- instance.TaxRate = data.TcsTaxRate;
- if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2") {
- if (instance.ContactTcsEnable == true && instance.EnableTenantTcs == true) {
- $("#chk_tcsapplied").prop("checked", true);
- if ($(".hdn_invoicetypeid").val() == "1")
- $("#chk_tcsapplied").prop("disabled", "disabled");
- $("#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);
- instance.ContactTcsEnable = data.TcsApplied;
- 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);
- }
- $(".div_tcsadjustment").addClass("floating-label-form-group-with-value");
- if ($(this).prop('checked') == true && instance.EnableTenantTcs == false && ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2" || $(".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");
- instance.update_total();
- instance.TotalAdjustment();
- }
- else {
- $("#div_tcstaxrate").addClass("hidden");
- $(".div_tcsadjustment").addClass("hidden");
- $("#div_tcsamount").addClass("hidden");
- $('#chk_tcsapplied').prop('checked', false);
- instance.update_total();
- instance.TotalAdjustment();
- }
- });
- }
- else if ($(this).prop('checked') == true) {
- $("#div_tcstaxrate").removeClass("hidden");
- $(".div_tcsadjustment").removeClass("hidden");
- $("#div_tcsamount").removeClass("hidden");
- instance.update_total();
- 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);
- instance.update_total();
- instance.TotalAdjustment();
- }
- }
- });
- $(".txt_tcsadjustment").unbind();
- $(".txt_tcsadjustment").blur(function () {
- instance.update_total();
- instance.TotalAdjustment();
- });
- });
- });
- }
- SaveAsDraft() {
- let InstalledAppId = Unibase.Platform.Forms.Components.FormViewer.instance.InstalledAppId;
- let RefStatusId = Bizgaze.Apps.Transact.Enums.InvoiceStatus.Draft;
- Unibase.Platform.Apps.Managers.StageManager.Instance().getStagesByInstalledAppandRefStatus(InstalledAppId, RefStatusId).then(function (response) {
- $(".hdn_stageid").val(response.result.StageId);
- $("#btnDynamicSave").click();
- });
- }
- loadOrderPendingItems() {
- var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- var 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 || 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;
- 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;
- 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 (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;
- 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,
- TaxAmount: item.TaxAmount,
- DiscountAmount: item.DiscountAmount,
- };
- 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 (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 (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) || (Number(item.AvailableQty) <= 0)))
- 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);
- 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 (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);
- }
- }
- var isFOC = false;
- if (itemRow.unitPrice == 0) {
- isFOC = true;
- }
- var taxamount = itemRow.TaxAmount / itemRow.quantity;
- instance.userCart.push({ lobId: 0, productId: 0, itemId: itemRow.itemId, quantity: itemRow.quantity, itemPrice: itemRow.unitPrice, itemName: itemRow.itemName, isFOC: isFOC, taxAmmount: taxamount, discountValue: itemRow.DiscountAmount });
- instance.updateCheckoutPageList();
- instance.cartInst.updateCartContainerHtml(itemRow.itemId, 0);
- }
- for (const j of items) {
- 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
- };
- }
- $("#totalinvoiceqty").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalQty, 2));
- });
- }
- }
- Print(id) {
- var templateid = "0";
- if (Bizgaze.Apps.Transact.Controls.Pos.Instance().isdraft == false) {
- Pos.Instance().fileCacheHelper.loadJsFile("apps/transact/managers/invoicemanager.js", function () {
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceDetails(id).then(function (response) {
- if (response.result != null) {
- var invoiceresponse = response.result;
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().updateinvoiceseries(id, invoiceresponse.SeriesId, 0, invoiceresponse.TemplateId).then(function (data) {
- if (data.status == 2) {
- MessageHelper.Instance().showError(data.message, 'bizgaze_CreateErrorMessages');
- return false;
- }
- else {
- var detailobj = Unibase.Themes.Providers.DetailHelper.DetailInstance();
- detailobj._recordId = Unibase.Themes.Providers.DetailHelper.recordId;
- detailobj._installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- detailobj._containerId = detailobj._containerId;
- detailobj.loadPortlets(detailobj);
- Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getprintinvoice(id, true, true).then(function (data) {
- var resp = data.result;
- Pos.Instance().printPopup(resp);
- var printhtml = '<div id="divPrint hidden"><span class="printDataN">' + resp.Html + '</span></div >';
- }, function (response) {
- MessageHelper.Instance().showError(response.responseText, "");
- });
- }
- });
- }
- });
- });
- }
- }
- applyOffer(selectedItemArray) {
- var totalPrice = this.totalPrice(this.userCart);
- if (selectedItemArray != null) {
- for (var i = 0; i < selectedItemArray.length; i++) {
- var item = this.selectedItemsArray.find(x => x.itemId == selectedItemArray[i].ItemId);
- var focItemId = selectedItemArray.map(x => x.focItemId);
- var index = this.userCart.findIndex(x => x.itemId == item.itemId && x.productId == item.productId);
- if (index == -1) {
- this.userCart.push({ lobId: this.lobId, productId: item.productId, itemId: item.itemId, quantity: selectedItemArray[i].Volume, itemPrice: item.UnitPrice, itemName: item.itemName, totalPrice: totalPrice, offerrefid: 0, isFOC: false, discountValue: 0, taxAmmount: item.TaxAmount });
- item = this.userCart.find(x => x.itemId == item.itemId && x.productId == item.productId);
- }
- else {
- var offerIndex = this.userCart.findIndex(x => x.offerrefid == item.itemId && x.itemId == selectedItemArray[i].focItemId);
- if (offerIndex == -1) {
- this.removeItemFromItemCartAndUsercart(item.productId, item.itemId);
- var offeritems = this.userCart.filter(x => x.offerrefid == item.itemId);
- if (offeritems != null) {
- for (var j = 0; j < offeritems.length; j++) {
- this.removeItemFromItemCartAndUsercart(offeritems[j].productId, offeritems[j].itemId);
- }
- }
- this.userCart.push({ lobId: this.lobId, productId: item.productId, itemId: item.itemId, quantity: selectedItemArray[i].Volume, itemPrice: item.UnitPrice, itemName: item.itemName, totalPrice: totalPrice, offerrefid: 0, isFOC: false, discountValue: 0, taxAmmount: item.taxAmmount });
- item = this.userCart.find(x => x.itemId == item.itemId && x.productId == item.productId);
- }
- }
- var element = document.getElementById(item.itemId);
- this.updateItemContainerSpinnerOnMDown(element, null, true, item.quantity);
- this.getOfferDetails(item, focItemId);
- this.cartInst.updateCartContainerHtml(item.itemid, item.productId);
- }
- }
- else if (this.offerItemsArray.length > 0) {
- }
- }
- printPopup(data) {
- var mywindow = window.open('', 'my Print', 'height=400,width=850');
- var content = '<html><head><title>Print</title><link rel="stylesheet" href="lib/bizgaze/print.css" /><link rel="stylesheet" href="lib/bootstrap/bootstrap-theme.min.css" /></head><body>';
- content += data.Html;
- content += "<script>print();</script>";
- content += '</body></html>';
- mywindow.document.write(content);
- return true;
- }
- static Instance() {
- if (this._instance === undefined) {
- this._instance = new Pos();
- }
- return this._instance;
- }
- }
- Controls.Pos = Pos;
- })(Controls = Transact.Controls || (Transact.Controls = {}));
- })(Transact = Apps.Transact || (Apps.Transact = {}));
- })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
- })(Bizgaze || (Bizgaze = {}));
|