{ "version": 3, "sources": ["src/app/core/services/client/client-list.service.ts"], "sourcesContent": ["import { Injectable } from '@angular/core';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport { Observable } from 'rxjs';\r\nimport { BaseService } from '../base.service';\r\nimport { Client } from '@app/models/dashboard/client';\r\nimport { ApiAuthUrls } from '@app/core/utils/url-enums/auth.enum';\r\nimport { ClientListFilter } from '@app/models/dashboard/client-list-filter';\r\nimport moment from 'moment';\r\nimport { VATThreshold } from '@app/models/vat/vat-threshold';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class ClientListService extends BaseService {\r\n\r\n constructor(private http: HttpClient) {\r\n super();\r\n }\r\n\r\n\r\n updateCustomizeFieldsInDB() {\r\n const customisations = JSON.parse(localStorage.getItem('customisations'));\r\n let clientDashBoardCustomisedFields = '';\r\n let clientDashboardStickyFilterOptions = '';\r\n if (customisations && customisations.clientDashboardStickyFilterOptions) {\r\n clientDashboardStickyFilterOptions = customisations.clientDashboardStickyFilterOptions;\r\n } else {\r\n clientDashboardStickyFilterOptions = JSON.stringify({\r\n packages: [],\r\n nominalCodes: [],\r\n accountStatus: [],\r\n bankFeeds: [],\r\n lastBankRecStartDate: '',\r\n lastBankRecEndDate: '',\r\n vatReturnStartDate: '',\r\n vatReturnEndDate: '',\r\n accountPeriodStartDate: '',\r\n accountPeriodEndDate: '',\r\n clientManager: 0,\r\n clientGroup: 0,\r\n registeredIn : -1,\r\n itsaRegistered : -1,\r\n paidBy: [],\r\n licenseExpiryStartDate: '',\r\n licenseExpiryEndDate: '',\r\n loginBy: 0,\r\n fromLastLoginDate:'',\r\n toLastLoginDate:''\r\n });\r\n }\r\n\r\n if (customisations && customisations.clientDashBoardCustomisedFields) {\r\n clientDashBoardCustomisedFields = customisations.clientDashBoardCustomisedFields.toString();\r\n } else {\r\n clientDashBoardCustomisedFields = '';\r\n }\r\n\r\n\r\n const selectedSettings: { clientDashBoardCustomisedFields: string, clientDashboardStickyFilterOptions: string } = {\r\n clientDashBoardCustomisedFields,\r\n clientDashboardStickyFilterOptions\r\n };\r\n return this.http.put(\r\n `${this.API_URL}/settings/customisations`,\r\n JSON.stringify(selectedSettings),\r\n this.httpOptions\r\n );\r\n }\r\n\r\n getCustomizedStickyFilters() {\r\n const defaultFiltersOnError = {\r\n packages: [],\r\n nominalCodes: [],\r\n accountStatus: [],\r\n bankFeeds: [],\r\n lastBankRecStartDate: '',\r\n lastBankRecEndDate: '',\r\n vatReturnStartDate: '',\r\n vatReturnEndDate: '',\r\n accountPeriodStartDate: '',\r\n accountPeriodEndDate: '',\r\n clientManager: 0,\r\n clientGroup: 0,\r\n vatRegisteredInClients : [],\r\n registeredIn : -1,\r\n itsaRegistered : -1,\r\n paidBy: [],\r\n licenseExpiryStartDate: '',\r\n licenseExpiryEndDate: '',\r\n loginBy: 0,\r\n fromLastLoginDate:'',\r\n toLastLoginDate:''\r\n };\r\n let customisations;\r\n try {\r\n customisations = JSON.parse(localStorage.getItem('customisations'));\r\n } catch { }\r\n\r\n if (customisations && customisations.clientDashboardStickyFilterOptions) {\r\n try {\r\n return JSON.parse(customisations.clientDashboardStickyFilterOptions);\r\n } catch {\r\n return defaultFiltersOnError;\r\n }\r\n } else {\r\n return defaultFiltersOnError;\r\n }\r\n\r\n }\r\n\r\n getCustomizedFields() {\r\n let customisations;\r\n try {\r\n customisations = JSON.parse(localStorage.getItem('customisations'));\r\n } catch { }\r\n if (customisations && customisations.clientDashBoardCustomisedFields) {\r\n return customisations.clientDashBoardCustomisedFields.split(',');\r\n } else {\r\n return [];\r\n }\r\n }\r\n\r\n redirectToKashFlow(client) {\r\n return this.http.post(\r\n `${this.API_URL}/clients/${client.clientId}/session`, {}\r\n );\r\n }\r\n\r\n getVatThresholdStatus() {\r\n const headers = { 'content-type': 'application/json' }\r\n return this.http.post(this.API_URL + '/settings/single?keyName=VATThresholdNotification&value=0', { 'headers': headers });\r\n }\r\n\r\n getClients(\r\n partnerId: number,\r\n sortColumn: string,\r\n sortDirection: string,\r\n searchText: string = '',\r\n batchNumber: number,\r\n filterSet: ClientListFilter,\r\n isExport?: boolean,\r\n ): Observable {\r\n\r\n let packages = '';\r\n let accountType = '';\r\n let registeredIn = '';\r\n let nominalSet = '';\r\n let partnerManagerId = 0;\r\n let partnerGroupId = 0;\r\n let bankfeeds = '';\r\n let lastbankrecstartdate = '';\r\n let lastbankrecenddate = '';\r\n let vatreturnstartdate = '';\r\n let vatreturnenddate = '';\r\n let accountingperiodstartdate = '';\r\n let accountingperiodenddate = '';\r\n let itsaRegistered = '';\r\n let paidBy = '';\r\n let licenseExpiryStartDate = '';\r\n let licenseExpiryEndDate = '';\r\n let loginBy = ''\r\n let fromLastLoginDate = '';\r\n let toLastLoginDate = '';\r\n\r\n packages = filterSet.packages.toString();\r\n\r\n //To get package values based on selected packages\r\n let selectedPackageValues = Array.from(packages.split(\",\"));\r\n let updatedPackageValues = selectedPackageValues.map(this.getPackage)\r\n packages = encodeURIComponent(updatedPackageValues.join());\r\n\r\n accountType = filterSet.accountStatus.toString();\r\n nominalSet = filterSet.nominalCodes.toString();\r\n registeredIn = (filterSet.registeredIn != null && filterSet.registeredIn !== undefined) ? filterSet.registeredIn.toString() : \"-1\";\r\n itsaRegistered=(filterSet.itsaRegistered != null && filterSet.itsaRegistered !== undefined) ? filterSet.itsaRegistered.toString() : \"-1\";\r\n loginBy = (filterSet.loginBy != null && filterSet.loginBy !== undefined) ? filterSet.loginBy.toString() : \"0\";\r\n\r\n partnerManagerId = filterSet.clientManager ? filterSet.clientManager : null;\r\n partnerGroupId = filterSet.clientGroup ? filterSet.clientGroup : null;\r\n\r\n bankfeeds = filterSet.bankFeeds.toString();\r\n lastbankrecstartdate = this.formatDate(filterSet.lastBankRecStartDate);\r\n lastbankrecenddate = this.formatDate(filterSet.lastBankRecEndDate);\r\n vatreturnstartdate = this.formatDate(filterSet.vatReturnStartDate);\r\n vatreturnenddate = this.formatDate(filterSet.vatReturnEndDate);\r\n accountingperiodstartdate = this.formatDate(filterSet.accountPeriodStartDate);\r\n accountingperiodenddate = this.formatDate(filterSet.accountPeriodEndDate);\r\n paidBy = filterSet.paidBy === undefined? '' : filterSet.paidBy.toString();\r\n licenseExpiryStartDate = this.formatDate(filterSet.licenseExpiryStartDate);\r\n licenseExpiryEndDate = this.formatDate(filterSet.licenseExpiryEndDate);\r\n fromLastLoginDate = this.formatDate(filterSet.fromLastLoginDate);\r\n toLastLoginDate = this.formatDate(filterSet.toLastLoginDate);\r\n \r\n sortColumn = sortColumn === 'packageDescription' ? 'package' : sortColumn;\r\n sortColumn = sortColumn === 'lastBankReconciliation' ? 'reconciliationDate' : sortColumn;\r\n sortColumn = sortColumn === 'lastBankReconciliation' ? 'reconciliationDate' : sortColumn;\r\n sortColumn = sortColumn === 'vatReturnDueDate' ? 'vatReturnDate' : sortColumn;\r\n sortColumn = sortColumn === 'subscriptionExpiryDate' ? 'licenseExpiryDate' : sortColumn;\r\n sortColumn = sortColumn === 'accountStatusDescription' ? 'accountStatus' : sortColumn;\r\n sortColumn = sortColumn === 'registeredInDescription' ? 'registeredIn' : sortColumn;\r\n if (isExport) {\r\n // tslint:disable-next-line:max-line-length\r\n return this.http.get(`${this.API_URL}/${ApiAuthUrls.getClients}?sortColumn=${sortColumn}&sortDirection=${sortDirection}&searchText=${searchText}®isteredIn=${registeredIn}&package=${packages}&accountType=${accountType}&nominalSet=${nominalSet}&partnerManagerId=${partnerManagerId}&partnerGroupId=${partnerGroupId}&batchNumber=${batchNumber}&bankfeeds=${bankfeeds}&lastbankrecstartdate=${lastbankrecstartdate}&lastbankrecenddate=${lastbankrecenddate}&vatreturnstartdate=${vatreturnstartdate}&vatreturnenddate=${vatreturnenddate}&accountingperiodstartdate=${accountingperiodstartdate}&accountingperiodenddate=${accountingperiodenddate}&isExport=${isExport}&itsaRegistered=${itsaRegistered}&paidBy=${paidBy}&expiryStartDate=${licenseExpiryStartDate}&expiryEndDate=${licenseExpiryEndDate}&loginBy=${loginBy}&fromLastLoginDate=${fromLastLoginDate}&toLastLoginDate=${toLastLoginDate}`\r\n );\r\n } else {\r\n // tslint:disable-next-line:max-line-length\r\n return this.http.get(`${this.API_URL}/${ApiAuthUrls.getClients}?sortColumn=${sortColumn}&sortDirection=${sortDirection}&searchText=${searchText}®isteredIn=${registeredIn}&package=${packages}&accountType=${accountType}&nominalSet=${nominalSet}&partnerManagerId=${partnerManagerId}&partnerGroupId=${partnerGroupId}&batchNumber=${batchNumber}&bankfeeds=${bankfeeds}&lastbankrecstartdate=${lastbankrecstartdate}&lastbankrecenddate=${lastbankrecenddate}&vatreturnstartdate=${vatreturnstartdate}&vatreturnenddate=${vatreturnenddate}&accountingperiodstartdate=${accountingperiodstartdate}&accountingperiodenddate=${accountingperiodenddate}&itsaRegistered=${itsaRegistered}&paidBy=${paidBy}&expiryStartDate=${licenseExpiryStartDate}&expiryEndDate=${licenseExpiryEndDate}&loginBy=${loginBy}&fromLastLoginDate=${fromLastLoginDate}&toLastLoginDate=${toLastLoginDate}`\r\n );\r\n }\r\n }\r\n\r\n formatDate(_date) {\r\n return _date ? moment(_date).format('YYYY-MM-DD') : _date;\r\n }\r\n\r\n\r\n getSearchAutoFillData(\r\n partnerId: number,\r\n searchText: string\r\n ) {\r\n return this.http.get(\r\n `${this.API_URL}/${\r\n ApiAuthUrls.getClients}/${partnerId}/search?searchText=${searchText}`\r\n );\r\n }\r\n\r\n getVatRegisteredClients(\r\n sortDirection: string,\r\n searchText: string = '',\r\n batchNumber: number\r\n ): Observable {\r\n // tslint:disable-next-line:max-line-length\r\n return this.http.get(`${this.API_URL}/${ApiAuthUrls.getClients}?sortDirection=${sortDirection}&searchText=${searchText}&batchNumber=${batchNumber}&vatregistered=1`);\r\n }\r\n\r\n getNonMtdVatRegisteredClients(\r\n sortDirection: string,\r\n searchText: string = '',\r\n batchNumber: number\r\n ): Observable {\r\n return this.http.get(`${this.API_URL}/${ApiAuthUrls.getClients}?sortDirection=${sortDirection}\r\n &searchText=${searchText}&batchNumber=${batchNumber}&vatregistered=1&nonmtdclientsonly=true`);\r\n }\r\n\r\n getVatThresholdClients(\r\n searchText: string = '',\r\n batchNumber: number,\r\n sortColumn: string ='',\r\n sortDirection: string='',\r\n vatThreshold:string=''\r\n ): Observable {\r\n return this.http.get(`${this.API_URL}/${ApiAuthUrls.vatThreshold}?searchText=${searchText}&batchNumber=${batchNumber}&sortColumn=${sortColumn}&sortDirection=${sortDirection}&vatThreshold=${vatThreshold}`);\r\n }\r\n getPackage(packages) {\r\n switch (packages) {\r\n case \"2\": return \"Starter\";\r\n case \"3\": return \"Business\";\r\n case \"4\": return \"Business + Payroll\";\r\n case \"13\": return \"IRIS Elements Cashbook\";\r\n default: return \"\";\r\n }\r\n }\r\n}\r\n"], "mappings": ";;;;;;;;;;;;;AAOA,oBAAmB;AAMZ,IAAM,oBAAN,MAAMA,2BAA0B,YAAW;EAEhD,YAAoB,MAAgB;AAClC,UAAK;AADa,SAAA,OAAA;EAEpB;EAGA,4BAAyB;AACvB,UAAM,iBAAiB,KAAK,MAAM,aAAa,QAAQ,gBAAgB,CAAC;AACxE,QAAI,kCAAkC;AACtC,QAAI,qCAAqC;AACzC,QAAI,kBAAkB,eAAe,oCAAoC;AACvE,2CAAqC,eAAe;IACtD,OAAO;AACL,2CAAqC,KAAK,UAAU;QAClD,UAAU,CAAA;QACV,cAAc,CAAA;QACd,eAAe,CAAA;QACf,WAAW,CAAA;QACX,sBAAsB;QACtB,oBAAoB;QACpB,oBAAoB;QACpB,kBAAkB;QAClB,wBAAwB;QACxB,sBAAsB;QACtB,eAAe;QACf,aAAa;QACb,cAAe;QACf,gBAAiB;QACjB,QAAQ,CAAA;QACR,wBAAwB;QACxB,sBAAsB;QACtB,SAAS;QACT,mBAAkB;QAClB,iBAAgB;OACjB;IACH;AAEA,QAAI,kBAAkB,eAAe,iCAAiC;AACpE,wCAAkC,eAAe,gCAAgC,SAAQ;IAC3F,OAAO;AACL,wCAAkC;IACpC;AAGA,UAAM,mBAA4G;MAChH;MACA;;AAEF,W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