Built files from Bizgaze WebServer
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

item.component.js 59KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881
  1. var Unibase;
  2. (function (Unibase) {
  3. let Forms;
  4. (function (Forms) {
  5. let Controls;
  6. (function (Controls) {
  7. class ItemDetails extends Unibase.Platform.Core.BaseComponent {
  8. constructor() {
  9. super(...arguments);
  10. this.rowIndex = 0;
  11. this.deletedItems = new Array();
  12. this.itemIds = new Array();
  13. this.SplitedInvoiceItemList = new Array();
  14. this.deleted_invoiceItems = new Array();
  15. this.container = "";
  16. }
  17. init(formpropertyid, prop, callback) {
  18. var instance = ItemDetails.Instance();
  19. instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
  20. instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
  21. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/controls/itemdetails/item.mrp.js", function () {
  22. });
  23. }
  24. loadControl(containerid, prop) {
  25. var html = '<div class="section_ItemDetails card"><div class="card-header">Item Details</div><div class="card-body"><div class="row"><div id="control-container-100691780039438" class="control-group divCustomProperties divCustomProperties_InvoiceItemEntity controldata_0 col-sm-12 " data-size="12" data-propertyname="null" data-propertyid="0" data-doctypeid="0" data-level="0" data-doctypetable="null" data-doctypename="InvoiceItemEntity" data-isdefault="false" data-rowindex="13" data-formpropertyid="100691780039438" data-controlname="InvoiceItems" data-validatename="InvoiceItems"><div class="panel panel-default" style="padding-bottom:10px" id="invoiceitem"><input type="hidden" id="hdninvoiceitem" class="" value="" data-isdynamic="true" data-propdoctypename=""><div class="" style="padding-bottom:10px"> <div id="tbl_InvoiceItems" class="col-sm-12 d-none d-md-block "><div class="row lineheight wrapper-sm" style="border-bottom: 2px solid grey;"><div class="col-sm-4 min-padding"><strong class="ml-10">Item Name</strong></div><div class="col-sm-2 text-center"><strong class="">Qty</strong></div><div class="col-sm-2 text-center min-padding"><strong>Unit Price</strong></div><div class="col-sm-2 text-center min-padding"><strong>Disc.</strong></div><div class="col-sm-2 text-right min-padding"><strong>Total</strong></div></div></div></div><div class="panel-body InvoiceItems"><div class="item-row added-row InvoiceitemRow-0 "></div><div class="discount-row hidden"></div></div></div><a href="javascript:;" class="default pull-left" title="Add Item" data-original-title="Add Item"><span class="pull-right btn" style="text-decoration:underline;color:deepskyblue" id="btnInvoiceItem"> Add Item</span></a></div></div></div></div>';
  26. $("#" + containerid).html(html);
  27. $("#btnInvoiceItem").off().click(function () {
  28. ItemDetails.instance.AddRow();
  29. });
  30. ItemDetails.instance.container = containerid;
  31. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("tenants/themes/default/components/details/details.js", function () {
  32. });
  33. }
  34. loadControlSettings(controlsettingjson, formpropertyid) {
  35. return null;
  36. }
  37. loadPropertySettings(propertysettings, formpropertyid) {
  38. return null;
  39. }
  40. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  41. return null;
  42. }
  43. AddRow() {
  44. var emptyRow = {
  45. orderItemId: 0,
  46. invoiceItemId: 0,
  47. itemName: "",
  48. itemId: 0,
  49. itemSKU: "",
  50. unitName: "",
  51. packSize: 0,
  52. packCount: 0,
  53. packs: 0,
  54. quantity: 0,
  55. availPacks: 0,
  56. availQty: 0,
  57. listPrice: 0,
  58. description: "",
  59. taxGroupName: "",
  60. taxGroupId: 0,
  61. isTaxInclusive: $("#hfIsTaxInclusive").val(),
  62. addlDiscountPercent: 0,
  63. addlDiscountValue: 0,
  64. creditNote: 0,
  65. priceListId: 0,
  66. batchId: 0,
  67. unitPrice: 0,
  68. invoiceallocations: null,
  69. exciseInvoiceItem: null,
  70. accountId: 0,
  71. accountName: "",
  72. walletId: 0,
  73. Adjustment: 0,
  74. IsFoc: false,
  75. TariffNo: "",
  76. exciseAmount: 0,
  77. discountName: "",
  78. discountId: 0,
  79. _description: "",
  80. refNo: "",
  81. DiscountGroupId: 0,
  82. DiscountGroupName: '',
  83. RefInvoiceItemId: 0,
  84. MrpId: 0,
  85. taxAdjustment: 0,
  86. assesableAdjustment: 0,
  87. inventoryTypeId: 0,
  88. dcItemId: 0,
  89. TotalRowAmount: 0,
  90. maxQty: 0,
  91. };
  92. this.addDataRow(emptyRow);
  93. }
  94. addDataRow(row) {
  95. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("tenants/themes/default/components/details/details.js", function () {
  96. });
  97. this.rowIndex = $(".InvoiceItems").find(".item-addedrow").length + 1;
  98. var bg = "";
  99. if (row.packSize == 0)
  100. row.packSize = 1;
  101. if (row.packCount == 0)
  102. row.packCount = 1;
  103. if (row.quantity == 0)
  104. row.quantity = row.packCount * row.packs * row.packSize;
  105. var price = row.unitPrice;
  106. if (row.unitPrice == 0)
  107. price = row.listPrice;
  108. var currenttaxgroupid = 0;
  109. if ($("#hfInv_Invoicetype").val() == "PurchaseReturn" || $("#hfInv_Invoicetype").val() == "SalesReturn")
  110. row.invoiceallocations = null;
  111. if ($('#hfInv_IsRetun').val() == 1)
  112. row.invoiceItemId = 0;
  113. var zeroBilled = "";
  114. if (price == 0)
  115. zeroBilled = "bg-danger";
  116. var zeroQtyText = "";
  117. var zeroQtyDiv = "bg-light";
  118. var recordId = Unibase.Themes.Providers.Detail_Settings.Instance().RecordId;
  119. if (recordId == 0 || recordId == undefined) {
  120. if ($('#hfInv_IsRetun').val() == 1 && row.itemId != 0 && ($('#hfInv_Invoicetype').val() == 'Sales' || $('#hfInv_Invoicetype').val() == 'PurchaseReturn')) {
  121. if (row.availQty == 0) {
  122. row.quantity = 0;
  123. zeroQtyText = "text-danger";
  124. zeroQtyDiv = "bg-danger";
  125. }
  126. else if (row.availQty < row.quantity) {
  127. row.quantity = row.availQty;
  128. }
  129. }
  130. }
  131. var readonlyQty = "";
  132. if (($("#hfDcId").val() != "0" || $("#hfDcId").val() == "") && recordId == 0) {
  133. readonlyQty = "readonly";
  134. }
  135. var ManageInvoice = 2;
  136. var AutoDc = false;
  137. var ManageInvoiceTax = 2;
  138. var readonlyPrice = "";
  139. var readonlyDisc = "";
  140. var readonlyTax = "";
  141. if (ManageInvoice == 1 && AutoDc == false) {
  142. readonlyQty = "readonly";
  143. readonlyPrice = "readonly";
  144. readonlyDisc = "readonly";
  145. readonlyTax = "disabled";
  146. }
  147. if ($('#hfInv_Invoicetype').val() == "Sales" && ManageInvoiceTax == 1 && AutoDc == false) {
  148. readonlyTax = "readonly";
  149. }
  150. if (row.inventoryTypeId == "2") {
  151. readonlyQty = "";
  152. readonlyPrice = "";
  153. }
  154. var activeDiscVal = "";
  155. var activeDiscPercent = "";
  156. var activeDiscMul = "";
  157. var activeDiscText = "";
  158. var discValue = 0;
  159. if (row.addlDiscountPercent > 0) {
  160. discValue = row.addlDiscountPercent;
  161. activeDiscPercent = "active";
  162. activeDiscText = "%";
  163. }
  164. else if (row.addlDiscountValue > 0 && row.DiscountGroupId > 0) {
  165. discValue = row.addlDiscountValue;
  166. activeDiscMul = "active";
  167. activeDiscText = "Mul";
  168. }
  169. else {
  170. discValue = row.addlDiscountValue;
  171. activeDiscVal = "active";
  172. activeDiscText = "Val";
  173. }
  174. var itemNameClass = "floating-label-form-group";
  175. if (row.invoiceItemId != 0)
  176. itemNameClass = "";
  177. var mt = "";
  178. if (row.invoiceItemId != 0) {
  179. mt = "mt-5";
  180. }
  181. if (row.orderItemId != 0) {
  182. mt = "mt-10";
  183. }
  184. if (row.inventoryTypeId != 5 && row.inventoryTypeId != 6 && row.inventoryTypeId != 7) {
  185. var IsBom = "";
  186. if (row.IsBoMItem == true && row.IsBoMItem != undefined) {
  187. IsBom = "hidden";
  188. }
  189. var html = '<div id="div_itemAddedRow_' + this.rowIndex + '" class="item-row item-addedrow ' + bg + ' form-group">' +
  190. '<div class="row ' + IsBom + ' divItemRow_' + row.itemId + ' ">' +
  191. '<div class="col-sm-4">' +
  192. '<div class=" item-name min-padding" style="margin-left:20px;">' +
  193. '<lable for="lbl_itemname" class="d-md-none">Item Name</lable>' +
  194. '<input type="hidden" class="rowIndex" value="' + this.rowIndex + '" />' +
  195. '<input type="hidden" class="orderItemId" value="' + row.orderItemId + '" />' +
  196. '<input type="hidden" class="dcItemId" value="' + row.dcItemId + '" />' +
  197. '<input type="hidden" class="selectedInvoiceItemId" value="' + row.invoiceItemId + '" />' +
  198. '<input type="hidden" class="refInvoiceItemId" value="' + row.RefInvoiceItemId + '" />' +
  199. '<input type="hidden" class="selectedItemId" id="hf_txtitem_' + this.rowIndex + '" value="' + row.itemId + '" />' +
  200. '<input type="hidden" id="selectedItemId" value="' + row.itemId + '" />' +
  201. '<input type="hidden" class="hfMrpId" value="' + row.MrpId + '" />' +
  202. '<input type="hidden" class="offerapplied" value="0" />' +
  203. '<input type="hidden" class="refNo" value="' + row.refNo + '"/>' +
  204. '<input type="hidden" class="description" value="' + row.description + '"/>' +
  205. '<input type="hidden" class="IsExchangeItem" value="' + row.ExchangeItem + '" />' +
  206. '<input type="hidden" class="maxQty" value="' + row.maxQty + '" />' +
  207. '<input type="hidden" class="hfAccountId" value="' + row.accountId + '"/>' +
  208. '<input type="hidden" class="hfItemTaxAdjsutmentVal" value="' + row.taxAdjustment + '" />' +
  209. '<input type="hidden" class="hfItemAssesableAdjustmentVal" value="' + row.assesableAdjustment + '" />' +
  210. '<input type="hidden" class="hfoldItemId" value="' + row.itemId + '"/>' +
  211. '<input type="hidden" class="hf_IsFoc" value="' + row.IsFoc + '"/>';
  212. if (row.IsFoc == true) {
  213. html += '<input type="hidden" class="hfOfferedItemId" value="' + row.OfferItemId + '"/>';
  214. }
  215. html += '<div class="' + mt + '">' +
  216. '<a class="no-border bg-white delete" href = "javascript:;" title = "Remove row" style = "" > <i class="fa fa-trash-o fa-lg mt-15 mr-2" style="margin-left:-25px;color:red"></i></a>';
  217. if (row.invoiceItemId != 0) {
  218. var itemName = row.itemSKU + ' - ' + row.itemName;
  219. if (row.ExchangeItem)
  220. itemName = '(Exchange) ' + row.itemSKU + ' - ' + row.itemName;
  221. html += '<a class="default prodName-link mt-10 ItemName" href="javascript:;">' + itemName + '</a>';
  222. }
  223. else {
  224. var itemName = "";
  225. if (row.ExchangeItem)
  226. itemName = '(Exchange) ' + row.itemName;
  227. else if (itemName != "" && row.itemSKU != "") {
  228. itemName = row.itemSKU + '-' + row.itemName;
  229. html += '<a class="default prodName-link mt-10 ItemName" href="javascript:;">' + itemName + '</a>';
  230. }
  231. else if (itemName != "") {
  232. itemName = row.itemName;
  233. html += '<a class="default prodName-link mt-10 ItemName" href="javascript:;">' + itemName + '</a>';
  234. }
  235. else {
  236. html += '<select class="form-control prodName" value="" id="txt_item_' + this.rowIndex + '" placeholder=" Select the item to Invoice" style="width:100%;" id="txtItem"></select>';
  237. }
  238. }
  239. html += '</div>' +
  240. '</div></div>' +
  241. '<div class="col-sm-2 input-group pr-0">' +
  242. '<div class="col-sm-1 pl-0"><a class="btn btn-sm btn_offer hidden"><span class="badge badge-sm bg-danger count mt-20" style="color:white;margin-left:-30px">offer</span></a></div>' +
  243. '<div class="col-sm-10 pl-0">' +
  244. '<div class="floating-label-form-group text-center">' +
  245. '<lable for="lbl_qty" class="d-md-none">Qty</lable>' +
  246. '<input type="text" class="prodQuantity text-center ' + zeroQtyText + ' form-control" placeholder="0.00" value="' + row.quantity + '" ' + readonlyQty + ' />' +
  247. '</div>' +
  248. '</div>' +
  249. '</div>' +
  250. '<div class="col-sm-2 div_UnitPrice">' +
  251. '<div class="floating-label-form-group min-padding text-center"><lable for="lbl_unitprice" class="d-md-none">Unit Price</lable>';
  252. var readonly = "";
  253. html += '<input type="text" class="prodPrice text-center form-control" placeholder="0.00" value="' + price + '" ' + readonlyPrice + ' />';
  254. html += '</div></div>' +
  255. '<div class="col-sm-2 div_SplitInvoiceItem hidden"><div class="mt-20 text-center"><a href="javascript:;" class="mr-10"><span id="spn_InvoiceItem_' + this.rowIndex + '" class="spn_InvoiceItem" style="text-decoration:underline;">Select</span></a></div></div>' +
  256. '<div class="col-sm-2 div_Discount"> ' +
  257. '<div class="floating-label-form-group text-center">' +
  258. '<lable for="lbl_disc" class="d-md-none">Disc.</lable>' +
  259. '<input type="hidden" id="hfProdDiscountGroupId" value="' + row.DiscountGroupId + '" />' +
  260. '<input type="hidden" id="hfProdDiscountGroupName" value="' + row.DiscountGroupName + '" />' +
  261. '<input type="hidden" id="hfProdDiscountList" value="" />' +
  262. '<input type="hidden" id="hfProdDiscountApplyTypes" value="" />' +
  263. '<div class="input-group">' +
  264. '<input type="text" id="inv_txtdiscount" placeholder="0.00" class="form-control inv_txtaddldiscount" value="' + discValue + '" ' + readonlyDisc + '>' +
  265. '<div class="input-group-btn">' +
  266. '<select class="btnInvoice_DiscType btn_inv_DiscType mt-10 border-blue"><option value="Val">Val</option><option value="%">%</option></select>' +
  267. '</div>' +
  268. '</div>' +
  269. '</div>' +
  270. '</div>' +
  271. '<div class="col-sm-2">' +
  272. '<input type="hidden" class="hfDiscountedAmount" value="0" />' +
  273. '<input type="hidden" class="hfRowTotalAdjustment" value="' + row.Adjustment + '" />' +
  274. '<input type="hidden" class="hfAssesableAdjustment" value="" />' +
  275. '<input type="hidden" class="hfTaxAdjustment" value="" />';
  276. if ($("#hfInv_Invoicetype").val() == "Purchase" || $("#hfInv_Invoicetype").val() == "PurchaseReturn" || $("#hfInv_Invoicetype").val() == "DebitNote") {
  277. html += '<a href="javascript:;" class=Adjustmentrow><input type="text" class="hfRowTotalwithAdjustment form-control txtRowTotalwithAdjustment text-right" value="0" style="color:#5ba8fb;cursor:pointer" disabled/></a>';
  278. html += '<a href="javascript:;" class="hidden" onclick="javascript:_bizgazetransact_invoice_edit.editInvItemTaxAllocs(' + row.invoiceItemId + ',' + row.taxGroupId + ',' + row.itemId + ',' + row.orderItemId + ')"><input type="text" style="color:#5ba8fb;text-decoration:underline;cursor:pointer" class="hfRowTotal form-control txtRowTotal text-right" value="0" /></a>';
  279. }
  280. else {
  281. html += '<p class="pull-right mt-10 mr-15 text-center"><lable for="lbl_disc" class="d-md-none">Total:</lable><strong><input type="hidden" class="hfRowTotal" value="0" /><span class="prodTotalPrice">0.00</span></strong></p>';
  282. }
  283. html += '</div>' +
  284. '</div><div class="hidden div_MoreDetails clear mt-5 ' + zeroQtyDiv + '">' +
  285. '<div class="row ml-5 mr-5">' +
  286. '<div class="col-sm-3">' +
  287. '<div class="floating-label-form-group form-group floating-label focus">' +
  288. '<label for="from_lbl_Description" id="lbl_Description">Description</label>' +
  289. '<input type="text" id="txt_Description" data-isdynamic="false" class="form-control floating-label-control " data-placeholder="Enter Description" placeholder="Description" data-label="Description"/>' +
  290. '</div>' +
  291. '</div>' +
  292. '<div class="col-sm-3">' +
  293. '<div class="floating-label-form-group-with-value">' +
  294. '<label for="from_lbl_Output" id="lbl_Output">Tax Group<span class="text-danger">*</span></label>' +
  295. '<div class="input-group">';
  296. if (row.taxGroupId != 0) {
  297. html += '<select type="text" data-isdynamic="false" class="form-control ui-autocomplete prodTax required ' + readonlyTax + '" value="' + row.taxGroupName + '" data-placeholder="Output @ 18%" placeholder="Output" data-label="Output" style="width:100%;" data-required="true"></select>' +
  298. '<input type="hidden" id="hfProdTaxPercent_' + this.rowIndex + '" class="hfProdTaxPercent" value="0" />' +
  299. '<input type="hidden" id="hfProdTax_' + this.rowIndex + '" class="hfProdTax hidden" value="' + row.taxGroupId + '"/>' +
  300. '<input type="hidden" class="txtProdTax hidden" value="' + row.taxGroupName + '"/>';
  301. }
  302. else {
  303. html += '<select type="text" data-isdynamic="false" class="form-control text-control required select2-hidden-accessible prodTax required ' + readonlyTax + '" id="txt_prodTax_' + this.rowIndex + '" data-placeholder="Output @ 18%" placeholder="Output" data-label="Output" style="width:100%;" data-required="true" id="prodTax"></select>' +
  304. '<input type="hidden" id="hfProdTaxPercent_' + this.rowIndex + '" class="hfProdTaxPercent" value="0" />' +
  305. '<input type="hidden" id="hfProdTax_' + this.rowIndex + '" class="hfProdTax hidden" value="0"/>' +
  306. '<input type="hidden" class="txtProdTax hidden" value=""/>';
  307. }
  308. html += '</div>' +
  309. '</div>' +
  310. '</div>' +
  311. '<div class="col-sm-3">' +
  312. '<div class="floating-label-form-group-with-value">' +
  313. '<label for="from_lbl_Account" id="lbl_Account">Account<span class="text-danger">*</span></label>';
  314. if (row.accountId != 0) {
  315. html += '<select data-isdynamic="false" class="form-control txt_Account required ' + readonlyTax + '" data-placeholder="Account Number" placeholder="Account" data-label="Account" value="' + row.accountName + '" id="txt_Account_' + this.rowIndex + '" style="width:100%;" data-required="true"></select>' +
  316. '<input type="hidden" id="hf_Account_' + this.rowIndex + '" class="hf_Account" value="' + row.accountId + '" />' +
  317. '<input type="hidden" id="txt_AccountName_' + this.rowIndex + '" class="txt_AccountName" value="' + row.accountName + '"/>';
  318. }
  319. else {
  320. html += '<select data-isdynamic="false" class="form-control text-control required select2-hidden-accessible txt_Account required ' + readonlyTax + '" data-placeholder="Account Number" placeholder="Account" id="txt_Account_' + this.rowIndex + '" data-label="Account" style="width:100%;" data-required="true"></select>' +
  321. '<input type="hidden" id="hf_Account_' + this.rowIndex + '" class="hf_Account" value="0" />' +
  322. '<input type="hidden" id="txt_AccountName_' + this.rowIndex + '" class="txt_AccountName" value=""/>';
  323. }
  324. html += '</div>' +
  325. '</div>' +
  326. '<div class="col-sm-3 mt-40 text-right">' +
  327. '<label for="from_lbl_Avalilability" id="lbl_Avalilability"><b>Availability: &ensp;&ensp;</b></label>' +
  328. '<span class=" prodAvail">' + row.availQty + '</span>' +
  329. '</div>' +
  330. '</div>' +
  331. '<div class="row">' +
  332. '<div class="col-sm-12">' +
  333. '<div class="col-sm-3 form-group div_Mrp hidden">' +
  334. '<div class="floating-label-form-group floating-label focus">' +
  335. '<input type="hidden" class="hf_PriceList" value="' + row.priceListId + '" />' +
  336. '<label for="from_lbl_MRP" id="lbl_MRP">MRP</label>' +
  337. '<input type="text" data-isdynamic="false" class="form-control floating-label-control txt_MRP" data-placeholder="53" placeholder="MRP" data-label="MRP" />' +
  338. '</div>' +
  339. '</div>' +
  340. '</div>' +
  341. '<div class="orderitemlist"></div>' +
  342. '</div><div class="accountRow"></div>';
  343. $(".item-row:last").after(html);
  344. var element = $(".item-addedrow:last");
  345. $("#spn_InvoiceItem_" + this.rowIndex).click(function () {
  346. ItemDetails.Instance().loadMrp(element);
  347. });
  348. ItemDetails.instance.itemsAutoComplete(element);
  349. $('.inv_txtaddldiscount').keypress(function (event) {
  350. if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
  351. }
  352. else {
  353. event.preventDefault();
  354. }
  355. }).on('paste', function (event) {
  356. event.preventDefault();
  357. });
  358. $('.prodQuantity').keypress(function (event) {
  359. if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
  360. }
  361. else {
  362. event.preventDefault();
  363. }
  364. }).on('paste', function (event) {
  365. event.preventDefault();
  366. });
  367. $('.prodPrice').keypress(function (event) {
  368. if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
  369. }
  370. else {
  371. event.preventDefault();
  372. }
  373. }).on('paste', function (event) {
  374. event.preventDefault();
  375. });
  376. ItemDetails.Instance().RemoveItem(element);
  377. element.find(".btnInvoice_DiscType option[value='" + activeDiscText + "']").prop("selected", true);
  378. element.find(".prodPrice,.prodQuantity,.inv_txtaddldiscount").focusin(function () {
  379. if (element.find($(".prodName")).val() != null || element.find($(".ItemName")).val() != null) {
  380. $(".div_MoreDetails").addClass("hidden");
  381. element.find(".div_MoreDetails").removeClass("hidden");
  382. }
  383. });
  384. element.find(".prodName").focusin(function () {
  385. $(".divMoreDetails").addClass("hidden");
  386. });
  387. if (row.description != null && row.description != '' && row.description != 'null')
  388. element.find('#txt_Description').val(row.description);
  389. element.find("#inv_txtdiscount").change(function () {
  390. if (!element.hasClass('SplitItem')) {
  391. if (element.find(".btnInvoice_DiscType").val() == "%") {
  392. if (Number(element.find("#inv_txtdiscount").val()) > 100) {
  393. element.find("#inv_txtdiscount").val("100");
  394. }
  395. }
  396. }
  397. });
  398. if (!element.hasClass('SplitItem')) {
  399. }
  400. if (row.TotalRowAmount != 0) {
  401. if ($("#hfInv_Invoicetype").val() == "Purchase" || $("#hfInv_Invoicetype").val() == "PurchaseReturn" || $("#hfInv_Invoicetype").val() == "DebitNote") {
  402. element.find(".hfRowTotalwithAdjustment").val();
  403. }
  404. else {
  405. element.find('.prodTotalPrice').text('');
  406. }
  407. }
  408. if (row.TotalDiscount != 0 && row.TotalDiscount != undefined)
  409. if (row.invoiceItemId != "0" && ($("#hfInv_Invoicetype").val() == "Purchase" || $("#hfInv_Invoicetype").val() == "SalesReturn" || $("#hfInv_Invoicetype").val() == "DebitNote")) {
  410. var x = element.find('.hfRowTotalwithAdjustment');
  411. element.find('.AdjustmentRow').click(function () {
  412. });
  413. }
  414. if (row.IsFoc == true) {
  415. element.find('.delete').addClass('hidden');
  416. element.find('.prodQuantity').prop('readonly', 'readonly');
  417. element.find('.prodPrice').prop('readonly', 'readonly');
  418. element.find("#inv_txtdiscount").prop('readonly', 'readonly');
  419. element.find(".btnInvoice_DiscType").prop('disabled', true);
  420. element.find('.prodQuantity').css('cursor', 'not-allowed');
  421. element.find('.prodPrice').css('cursor', 'not-allowed');
  422. element.find("#inv_txtdiscount").css('cursor', 'not-allowed');
  423. }
  424. }
  425. else {
  426. var element = $(".discount-addedrow:last");
  427. if (row.inventoryTypeId == 7) {
  428. element = $(".netdiscount-addedrow:last");
  429. }
  430. else {
  431. }
  432. }
  433. }
  434. loadMrp(element) {
  435. var instance = this;
  436. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/controls/itemdetails/item.mrp.js", function () {
  437. instance.navigationHelper.popup(0, "", Unibase.Forms.Controls.MRPDetails.Instance(), null, Unibase.Platform.Helpers.Size.Large);
  438. Controls.MRPDetails.element = element;
  439. Unibase.Forms.Controls.MRPDetails.Instance().init(element, "", 2);
  440. });
  441. }
  442. loadTaxGroupAutoComplete(element) {
  443. var txtTaxGroup = element.find(".prodTax");
  444. var hfProdTax = element.find(".hfProdTax");
  445. var hfAccount = element.find(".hf_Account");
  446. var txtAccount = element.find(".txt_Account");
  447. var accid = element.find(".hf_Account").val();
  448. var taxgrpid = element.find(".hfProdTax").val();
  449. var taxgrptext = element.find(".txtProdTax").val();
  450. var acctext = element.find(".txt_AccountName").val();
  451. var applytype = "Sales";
  452. var url = _appsettings.server_url() + '/apis/v4/unibase/platform/forms/getformsautocomplete';
  453. AutoCompleteHelper.getHelper().Create("#txt_prodTax_" + this.rowIndex, hfProdTax, url, function (response) {
  454. var data = response;
  455. });
  456. var url = _appsettings.server_url() + '/apis/v4/unibase/platform/forms/getformsautocomplete';
  457. AutoCompleteHelper.getHelper().Create("#txt_Account_" + this.rowIndex, hfAccount, url, function (response) {
  458. var data = response;
  459. });
  460. if (taxgrpid != 0) {
  461. $("#hf_TaxGroupId").val(taxgrpid);
  462. if ($("#ddl_TaxGroupId option[value='" + taxgrpid + "']").attr("selected", "selected").length == 0) {
  463. $("#ddl_TaxGroupId").append(new Option(taxgrptext, taxgrpid, true));
  464. }
  465. else {
  466. $("#ddl_TaxGroupId option[value='" + taxgrpid + "']").attr("selected", "selected");
  467. }
  468. }
  469. if (accid != 0) {
  470. $("#hf_AccountId").val(accid);
  471. if ($("#ddl_AccountId option[value='" + accid + "']").attr("selected", "selected").length == 0) {
  472. $("#ddl_AccountId").append(new Option(acctext, accid, true));
  473. }
  474. else {
  475. $("#ddl_AccountId option[value='" + accid + "']").attr("selected", "selected");
  476. }
  477. }
  478. }
  479. update_total() {
  480. var totalAmount = 0;
  481. var totalDiscountAmount = 0;
  482. var totalNonDiscountedAmount = 0;
  483. var totalTaxAmount = 0;
  484. var totalTaxAdjustment = 0;
  485. var totalAsseableAdjustment = 0;
  486. var totalQty = 0;
  487. var totalDiscountPercent = 0;
  488. var totalDiscountValue = 0;
  489. var totalAddlDiscountPercent = 0;
  490. var totalAddlDiscountValue = 0;
  491. var totalExpensePercent = 0;
  492. var totalExpenseValue = 0;
  493. var addexpenserow_total = 0;
  494. $('.expenserow-total').each(function (i) {
  495. var expense_row_total = Number($(this).html());
  496. addexpenserow_total += expense_row_total;
  497. });
  498. var ConsumedWalletValue = 0;
  499. var totalTaxPercent = 0;
  500. var totalTaxValue = 0;
  501. var totalCreditNote = 0;
  502. var adddiscountrow_total = 0;
  503. var netadddiscountrow_total = ConsumedWalletValue;
  504. $('.discount-row-total').each(function (i) {
  505. var discount_row_total = Number($(this).html());
  506. adddiscountrow_total += discount_row_total;
  507. });
  508. $('.netdiscount-row-total').each(function (i) {
  509. var discount_row_total = Number($(this).html());
  510. netadddiscountrow_total += discount_row_total;
  511. });
  512. var itemdiscount_total = 0;
  513. var totalLineAmount_total = 0;
  514. $('.hfRowTotal').each(function (i) {
  515. var element = $(this).parents(".item-row");
  516. if (!element.hasClass('SplitItem')) {
  517. var totalLineAmount = Number($(this).val());
  518. if (!isNaN(totalLineAmount))
  519. totalLineAmount_total += Number(totalLineAmount);
  520. var discountPercent = 0;
  521. var discountValue = 0;
  522. var quantity = Number(element.find(".prodQuantity").val());
  523. var unitPrice = Number(element.find(".prodPrice").val());
  524. var exciseAmount = Number(element.find(".exciseAmount").val());
  525. if (isNaN(exciseAmount))
  526. exciseAmount = 0;
  527. var nonexciseAmount = totalLineAmount - exciseAmount;
  528. if (element.find(".btnInvoice_DiscType option:selected").text().trim() == 'Val' && element.find('.inv_txtaddldiscount').val() != '' && element.find('.inv_txtaddldiscount').val() != undefined) {
  529. discountValue = Number(element.find('.inv_txtaddldiscount').val());
  530. }
  531. else if (element.find(".btnInvoice_DiscType option:selected").text().trim() == '%' && element.find('.inv_txtaddldiscount').val() != '' && element.find('.inv_txtaddldiscount').val() != undefined) {
  532. discountPercent = Number(element.find('.inv_txtaddldiscount').val());
  533. }
  534. else if (element.find(".btnInvoice_DiscType option:selected").text().trim() == 'Mul') {
  535. if (element.find('#hfProdDiscountList').val() != '' || element.find('#hfProdDiscountApplyTypes').val() != '') {
  536. var discountsArray = element.find('#hfProdDiscountList').val().toString().split(',');
  537. var applyTypes = element.find('#hfProdDiscountApplyTypes').val().toString().split(',');
  538. var price = Number(unitPrice) * Number(quantity);
  539. var currentAmount = Number(unitPrice) * Number(quantity);
  540. $.each(discountsArray, function (j) {
  541. var percent = discountsArray[j];
  542. var applyType = applyTypes[j];
  543. var discount = 0;
  544. if (applyType == 'NET' || applyType == '1') {
  545. discount = Number(price) * Number(percent) / 100;
  546. currentAmount -= Number(discount);
  547. }
  548. else {
  549. discount = Number(currentAmount) * Number(percent) / 100;
  550. currentAmount -= Number(discount);
  551. }
  552. discountValue += Number(discount);
  553. });
  554. element.find('.inv_txtaddldiscount').val(discountValue);
  555. }
  556. else {
  557. discountValue = Number(element.find('.inv_txtaddldiscount').val());
  558. }
  559. }
  560. if (!isNaN(discountPercent))
  561. totalDiscountPercent += Number(discountPercent);
  562. if (!isNaN(discountValue))
  563. totalAddlDiscountValue += Number(discountValue);
  564. var discountAmount = 0;
  565. discountAmount = (Number(nonexciseAmount) * Number(discountPercent) / 100)
  566. + (Number(quantity) * Number(discountValue));
  567. itemdiscount_total += discountAmount;
  568. var discountedAmount = Number(totalLineAmount) - Number(discountAmount);
  569. totalDiscountAmount += Number(discountAmount);
  570. element.find(".hfDiscountedAmount").val(discountAmount);
  571. if ($("#hfInv_Invoicetype").val() == "Purchase" || $("#hfInv_Invoicetype").val() == "PurchaseReturn" || $("#hfInv_Invoicetype").val() == "DebitNote") {
  572. element.find(".txtRowTotalwithAdjustment").val(totalLineAmount - discountAmount);
  573. }
  574. else
  575. element.find(".prodTotalPrice").html((totalLineAmount - discountAmount).toString());
  576. }
  577. });
  578. if (this.SplitedInvoiceItemList.length > 0) {
  579. for (var i = 0; i < this.SplitedInvoiceItemList.length; i++) {
  580. var totalline_Amount = Number(this.SplitedInvoiceItemList[i].quantity * this.SplitedInvoiceItemList[i].unitPrice);
  581. var discountAmount = 0;
  582. var nonexciseAmount = totalline_Amount - Number(this.SplitedInvoiceItemList[i].exciseAmount);
  583. discountAmount = (Number(nonexciseAmount) * Number(this.SplitedInvoiceItemList[i].addlDiscountPercent) / 100)
  584. + (Number(this.SplitedInvoiceItemList[i].quantity) * Number(this.SplitedInvoiceItemList[i].addlDiscountValue));
  585. discountAmount = Number(discountAmount);
  586. totalLineAmount_total += Number(this.SplitedInvoiceItemList[i].quantity * this.SplitedInvoiceItemList[i].unitPrice);
  587. itemdiscount_total += discountAmount;
  588. totalDiscountAmount += discountAmount;
  589. }
  590. }
  591. var overalldiscountpercent = 0;
  592. if (adddiscountrow_total != 0) {
  593. overalldiscountpercent = (100 * Number(adddiscountrow_total)) / Number(totalLineAmount_total);
  594. overalldiscountpercent = Number(overalldiscountpercent);
  595. $("#hfOverallDiscountPercent").val(overalldiscountpercent);
  596. }
  597. var taxAmounts = [];
  598. $('.hfRowTotal').each(function (i) {
  599. var element = $(this).parents(".item-row");
  600. if (!element.hasClass('SplitItem')) {
  601. var totalLineAmount = Number($(this).val());
  602. var quantity = element.find(".prodQuantity").val();
  603. if (!isNaN(totalLineAmount))
  604. totalNonDiscountedAmount += Number(totalLineAmount);
  605. discountAmount = Number(element.find(".hfDiscountedAmount").val()) + (Number(totalLineAmount) * Number(overalldiscountpercent) / 100);
  606. var assesableAmount = totalLineAmount - discountAmount;
  607. assesableAmount = Number(assesableAmount);
  608. var taxPercents = element.find(".hfProdTaxPercent").val();
  609. if (taxPercents != undefined)
  610. var taxpercentarray = taxPercents.toString().split(',');
  611. var taxValue = 0;
  612. var assesableAdjustment = Number(element.find('.hfItemAssesableAdjustmentVal').val());
  613. var taxAdjustment = Number(element.find('.hfItemTaxAdjsutmentVal').val());
  614. if (!isNaN(taxAdjustment))
  615. totalTaxAdjustment += Number(taxAdjustment);
  616. if (!isNaN(assesableAdjustment))
  617. totalAsseableAdjustment += Number(assesableAdjustment);
  618. var cumlTax = 0;
  619. var cumtaxtotal = 0;
  620. if ($("#hfId_IsTaxInclusive").val() == "true") {
  621. for (var i = 0; i < taxpercentarray.length; i++) {
  622. var taxPercentModel1 = taxpercentarray[i];
  623. var taxPercentM1 = Number(taxPercentModel1.split(":"));
  624. if (!isNaN(taxPercentM1[1]))
  625. cumlTax += Number(taxPercentM1[1]);
  626. }
  627. var currentAmt = Number((Number(assesableAmount) * 100) / (100 + Number(cumlTax)));
  628. cumtaxtotal = (Number(assesableAmount) - Number(currentAmt));
  629. }
  630. if (taxpercentarray != undefined) {
  631. for (var i = 0; i < taxpercentarray.length; i++) {
  632. var taxPercentModel = taxpercentarray[i];
  633. var taxPercentM = taxPercentModel.split(":");
  634. var ledgerid = taxPercentM[0];
  635. var taxPercent = Number(taxPercentM[1]);
  636. var taxAmt = 0;
  637. if ($("#hfId_IsTaxInclusive").val() == "true") {
  638. taxAmt = Number((taxPercent * cumtaxtotal) / cumlTax);
  639. }
  640. else {
  641. var tax = (Number(assesableAmount) * Number(taxPercent) / 100);
  642. taxAmt = Number(tax);
  643. }
  644. var ledgerexists = false;
  645. $.map(taxAmounts, function (e, i) {
  646. if (e.LedgerId == ledgerid) {
  647. ledgerexists = true;
  648. taxAmounts[i].TaxAmount += taxAmt;
  649. }
  650. });
  651. if (!ledgerexists) {
  652. taxAmounts.push({
  653. LedgerId: ledgerid,
  654. TaxAmount: taxAmt,
  655. });
  656. }
  657. }
  658. }
  659. totalAmount += Number(totalLineAmount);
  660. totalQty += Number(quantity);
  661. }
  662. });
  663. if (this.SplitedInvoiceItemList.length > 0) {
  664. for (var i = 0; i < this.SplitedInvoiceItemList.length; i++) {
  665. var TotalLineAmount = Number(this.SplitedInvoiceItemList[i].quantity * this.SplitedInvoiceItemList[i].unitPrice);
  666. var quantiy = Number(this.SplitedInvoiceItemList[i].quantity);
  667. if (!isNaN(TotalLineAmount))
  668. totalNonDiscountedAmount += Number(TotalLineAmount);
  669. var discountAmount = Number(this.SplitedInvoiceItemList[i].addlDiscountValue) + (Number(TotalLineAmount) * Number(this.SplitedInvoiceItemList[i].addlDiscountPercent) / 100);
  670. var assesableAmount = TotalLineAmount - discountAmount;
  671. assesableAmount = Number(assesableAmount);
  672. var taxPercents = '';
  673. var instance = this;
  674. if (this.SplitedInvoiceItemList[i].TaxPercent == undefined || this.SplitedInvoiceItemList[i].TaxPercent == 0) {
  675. var element = "";
  676. $(".SplitItem").each(function () {
  677. if ($(this).find(".selectedItemId").val() == instance.SplitedInvoiceItemList[i].itemId) {
  678. element = $(this);
  679. taxPercents = element.find('.hfProdTaxPercent').val();
  680. }
  681. });
  682. }
  683. else
  684. taxPercents = instance.SplitedInvoiceItemList[i].TaxPercent;
  685. if (taxPercents != undefined && taxPercents != '')
  686. var taxpercentarray = taxPercents.split(',');
  687. var assesableAdjustment = instance.SplitedInvoiceItemList[i].assesableAdjustment;
  688. var taxAdjustment = instance.SplitedInvoiceItemList[i].taxAdjustment;
  689. if (!isNaN(taxAdjustment))
  690. totalTaxAdjustment += Number(taxAdjustment);
  691. if (!isNaN(assesableAdjustment))
  692. totalAsseableAdjustment += Number(assesableAdjustment);
  693. var cumlTax = 0;
  694. var cumtaxtotal = 0;
  695. if ($("#hfId_IsTaxInclusive").val() == "true") {
  696. for (var j = 0; j < taxpercentarray.length; j++) {
  697. var taxPercentModel1 = taxpercentarray[j];
  698. var taxPercentM1 = taxPercentModel1.split(":");
  699. if (!isNaN(taxPercentM1[1]))
  700. cumlTax += Number(taxPercentM1[1]);
  701. }
  702. var currentAmt = Number((Number(assesableAmount) * 100) / (100 + Number(cumlTax)));
  703. cumtaxtotal = (Number(assesableAmount) - Number(currentAmt));
  704. }
  705. if (taxpercentarray != undefined) {
  706. for (var k = 0; k < taxpercentarray.length; k++) {
  707. var taxPercentModel = taxpercentarray[k];
  708. var taxPercentM = taxPercentModel.split(":");
  709. var ledgerid = taxPercentM[0];
  710. var taxPercent = taxPercentM[1];
  711. var taxAmt = 0;
  712. if ($("#hfId_IsTaxInclusive").val() == "true") {
  713. taxAmt = Number((taxPercent * cumtaxtotal) / cumlTax);
  714. }
  715. else {
  716. var tax = (Number(assesableAmount) * Number(taxPercent) / 100);
  717. taxAmt = Number(tax);
  718. }
  719. var ledgerexists = false;
  720. $.map(taxAmounts, function (e, m) {
  721. if (e.LedgerId == ledgerid) {
  722. ledgerexists = true;
  723. taxAmounts[m].TaxAmount += taxAmt;
  724. }
  725. });
  726. if (!ledgerexists) {
  727. taxAmounts.push({
  728. LedgerId: ledgerid,
  729. TaxAmount: taxAmt,
  730. });
  731. }
  732. }
  733. }
  734. totalAmount += Number(TotalLineAmount);
  735. totalQty += Number(quantiy);
  736. }
  737. }
  738. var taxAmount = 0;
  739. var taxAdjustment = 0;
  740. for (var i = 0; i < taxAmounts.length; i++) {
  741. if (!isNaN(taxAmounts[i].TaxAmount)) {
  742. taxAmount += Number(taxAmounts[i].TaxAmount);
  743. }
  744. }
  745. if (!isNaN(totalTaxAdjustment))
  746. totalTaxAdjustment = totalTaxAdjustment;
  747. if (!isNaN(totalAsseableAdjustment)) {
  748. totalAsseableAdjustment = totalAsseableAdjustment;
  749. }
  750. else {
  751. totalAsseableAdjustment = 0;
  752. }
  753. if (!isNaN(totalAsseableAdjustment))
  754. totalAmount += Number(totalAsseableAdjustment);
  755. totalTaxAmount = Number(taxAmount) + Number(totalTaxAdjustment);
  756. totalDiscountAmount += adddiscountrow_total;
  757. var totaltax = totalTaxAmount;
  758. var grosstotal = totalAmount;
  759. var creditnotes = 0;
  760. var assessableadjustment = 0;
  761. if (!isNaN(Number($("#txt_AssessableAdjustment").val())))
  762. assessableadjustment = Number($("#txt_AssessableAdjustment").val());
  763. var subtotal = grosstotal - totalDiscountAmount + assessableadjustment;
  764. subtotal = subtotal;
  765. var overalldiscount = 0;
  766. var taxadjustment = 0;
  767. if (!isNaN(Number($('#txt_TaxAdjustment').val()))) {
  768. taxadjustment = Number($('#txt_TaxAdjustment').val());
  769. }
  770. totaltax = Number(totaltax) + Number(taxadjustment);
  771. $('#totalTax').html(totaltax);
  772. $('#grosstotal').html(grosstotal);
  773. $('#totalItemDiscount').html(itemdiscount_total);
  774. $('#totalDiscount').html(totalDiscountAmount);
  775. $("#totalinvoiceqty").html(totalQty);
  776. var expense = 0;
  777. if (!isNaN(Number($('#txtOverallExpenseAmount').val()))) {
  778. expense = Number($('#txtOverallExpenseAmount').val());
  779. $("#totalexpense").text(expense);
  780. }
  781. var adjustment = 0;
  782. if (!isNaN(Number($('#txt_Adjustment').val()))) {
  783. adjustment = Number($('#txt_Adjustment').val());
  784. $("#span_Adjustment").text(adjustment);
  785. }
  786. var nettotal = Number(subtotal) + Number(addexpenserow_total) - Number(overalldiscount) - Number(netadddiscountrow_total) + Number(adjustment);
  787. if ($("#hfId_IsTaxInclusive").val() == "false")
  788. nettotal += Number(totaltax);
  789. if ($("#hfId_IsTaxInclusive").val() == "true") {
  790. subtotal = Number(subtotal) - Number(totalTaxAmount);
  791. }
  792. $('#subtotal').html(subtotal);
  793. $('.nettotal').html(nettotal);
  794. ItemDetails.Instance().totalAdjustment();
  795. }
  796. totalAdjustment() {
  797. if ($('#chk_AutoAdjustment').is(':checked')) {
  798. var total = $('.nettotal').text();
  799. var splitTotal = total.split('.');
  800. var AdjustmentValue = 0;
  801. var splitedAdjestment = 0;
  802. if (!isNaN(Number($('#txt_Adjustment').val()))) {
  803. AdjustmentValue = Number($('#txt_Adjustment').val());
  804. }
  805. if (Number(splitTotal[1]) > 0) {
  806. if (Number(splitTotal[1]) >= 50) {
  807. splitedAdjestment = (100 - Number(splitTotal[1])) / 100;
  808. AdjustmentValue += splitedAdjestment;
  809. $('#txt_Adjustment').val(Number(AdjustmentValue).toFixed(2)).blur();
  810. }
  811. else {
  812. splitedAdjestment = Number(splitTotal[1]) / 100;
  813. AdjustmentValue -= splitedAdjestment;
  814. $('#txt_Adjustment').val(Number(AdjustmentValue).toFixed(2)).blur();
  815. }
  816. }
  817. }
  818. }
  819. itemsAutoComplete(element) {
  820. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("tenants/themes/default/components/details/details.js", function () {
  821. });
  822. var txtAutoSearchCtrl = element.find(".prodName");
  823. var hdnOrderItemId = element.find(".orderItemId");
  824. var hdnDcItemId = element.find(".dcItemId");
  825. var hdnSelectedItemId = element.find(".selectedItemId");
  826. if (hdnSelectedItemId.val() != 0 && hdnSelectedItemId.val() != "") {
  827. this.itemIds.push(hdnSelectedItemId.val());
  828. element.find(".hfoldItemId").val(hdnSelectedItemId.val());
  829. }
  830. this.itemIds = [];
  831. var hdnAutoId = hdnSelectedItemId;
  832. var orderid = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_OrderId").val();
  833. var dcid = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_DcId").val();
  834. var invoiceid = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_InvoiceId").val();
  835. if (invoiceid == undefined || invoiceid == "null")
  836. invoiceid = 0;
  837. var url = "";
  838. var OrdersettingId = 0;
  839. var url = _appsettings.server_url() + '/apis/v4/unibase/transact/items/getitems/itemids/' + ',' + '/lobid/' + 100284890000001;
  840. AutoCompleteHelper.getHelper().Create("#txt_item_" + this.rowIndex, "#hf_txtitem_" + this.rowIndex, url, function (response) {
  841. var data = response;
  842. ItemDetails.Instance().update_total();
  843. });
  844. element.find(".div_SplitInvoiceItem").removeClass("hidden");
  845. ItemDetails.instance.loadTaxGroupAutoComplete(element);
  846. }
  847. RemoveItem(element) {
  848. var rowIndex = element.find(".rowIndex").val();
  849. element.find(".delete").on('click', function () {
  850. var _this = element.find(".delete");
  851. var invoiceitemid = _this.parents('.item-row').find(".selectedInvoiceItemId").val();
  852. _this.parents('.item-row').remove();
  853. var count = 1;
  854. $(".InvoiceItems").find(".item-addedrow").each(function () {
  855. $(this).find(".rowIndex").val(count);
  856. $(this).find(".selectedItemId").attr("id", "hf_txtitem_" + count);
  857. $(this).find(".prodName").attr("id", "txt_item_" + count);
  858. $(this).attr("id", "div_itemAddedRow_" + count);
  859. count++;
  860. });
  861. });
  862. }
  863. deleteRow(rowid, itemid) {
  864. var ids = this.deletedItems.push(itemid);
  865. ItemDetails.instance.deleteInvoiceItem(ids);
  866. }
  867. deleteInvoiceItem(invItemIds) {
  868. for (var i = 0; i < invItemIds.length; i++) {
  869. }
  870. }
  871. static Instance() {
  872. if (this.instance === undefined) {
  873. this.instance = new ItemDetails();
  874. }
  875. return this.instance;
  876. }
  877. }
  878. Controls.ItemDetails = ItemDetails;
  879. })(Controls = Forms.Controls || (Forms.Controls = {}));
  880. })(Forms = Unibase.Forms || (Unibase.Forms = {}));
  881. })(Unibase || (Unibase = {}));