mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
refactor: reports to nestjs
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import * as R from 'ramda';
|
||||
import { isEmpty, sumBy } from 'lodash';
|
||||
import { ERRORS, MatchedTransactionPOJO } from './types';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as R from 'ramda';
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { first, sumBy } from 'lodash';
|
||||
import { PromisePool } from '@supercharge/promise-pool';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable global-require */
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { Model } from 'objection';
|
||||
// import TenantModel from 'models/TenantModel';
|
||||
// import ModelSettings from './ModelSetting';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { omit, sumBy } from 'lodash';
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import * as R from 'ramda';
|
||||
import * as composeAsync from 'async/compose';
|
||||
import { formatDateFields } from '@/utils/format-date-fields';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { ERRORS } from '../Bills.constants';
|
||||
import { BillsValidators } from './BillsValidators.service';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { defaultTo, omit, isEmpty } from 'lodash';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { TenancyContext } from '@/modules/Tenancy/TenancyContext.service';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// @ts-nocheck
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import * as R from 'ramda';
|
||||
import { IFilterRole, IDynamicFilter } from './DynamicFilter.types';
|
||||
import { Parser } from '@/libs/logic-evaluation/Parser';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Model, raw } from 'objection';
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { ExpenseCategory } from './ExpenseCategory.model';
|
||||
import { Account } from '@/modules/Accounts/models/Account.model';
|
||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { IDateRange, IFinancialDatePeriodsUnit } from '../types/Report.types';
|
||||
import { GConstructor } from '@/common/types/Constructor';
|
||||
import { FinancialSheet } from './FinancialSheet';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { ITableColumn, ITableColumnAccessor } from '../types/Table.types';
|
||||
import { IDateRange } from '../types/Report.types';
|
||||
import { Constructor, GConstructor } from '@/common/types/Constructor';
|
||||
import { GConstructor } from '@/common/types/Constructor';
|
||||
import { I18nService } from 'nestjs-i18n';
|
||||
import { FinancialSheet } from './FinancialSheet';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { ITableColumn, ITableColumnAccessor } from '../types/Table.types';
|
||||
import { IDateRange } from '../types/Report.types';
|
||||
import { GConstructor } from '@/common/types/Constructor';
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import { IARAgingSummaryQuery } from './ARAgingSummary.types';
|
||||
import { Get, Headers } from '@nestjs/common';
|
||||
import { Controller, Get, Headers } from '@nestjs/common';
|
||||
import { Query, Res } from '@nestjs/common';
|
||||
import { ARAgingSummaryApplication } from './ARAgingSummaryApplication';
|
||||
import { AcceptType } from '@/constants/accept-type';
|
||||
import { Response } from 'express';
|
||||
import { PublicRoute } from '@/modules/Auth/Jwt.guard';
|
||||
|
||||
@Controller('reports/receivable-aging-summary')
|
||||
@PublicRoute()
|
||||
export class ARAgingSummaryController {
|
||||
constructor(private readonly ARAgingSummaryApp: ARAgingSummaryApplication) {}
|
||||
|
||||
|
||||
@@ -7,9 +7,12 @@ import { AgingSummaryModule } from '../AgingSummary/AgingSummary.module';
|
||||
import { ARAgingSummaryRepository } from './ARAgingSummaryRepository';
|
||||
import { ARAgingSummaryApplication } from './ARAgingSummaryApplication';
|
||||
import { ARAgingSummaryController } from './ARAgingSummary.controller';
|
||||
import { ARAgingSummaryMeta } from './ARAgingSummaryMeta';
|
||||
import { FinancialSheetCommonModule } from '../../common/FinancialSheetCommon.module';
|
||||
import { TenancyContext } from '@/modules/Tenancy/TenancyContext.service';
|
||||
|
||||
@Module({
|
||||
imports: [AgingSummaryModule],
|
||||
imports: [AgingSummaryModule, FinancialSheetCommonModule],
|
||||
controllers: [ARAgingSummaryController],
|
||||
providers: [
|
||||
ARAgingSummaryTableInjectable,
|
||||
@@ -18,6 +21,8 @@ import { ARAgingSummaryController } from './ARAgingSummary.controller';
|
||||
ARAgingSummaryPdfInjectable,
|
||||
ARAgingSummaryRepository,
|
||||
ARAgingSummaryApplication,
|
||||
ARAgingSummaryMeta,
|
||||
TenancyContext,
|
||||
],
|
||||
})
|
||||
export class ARAgingSummaryModule {}
|
||||
|
||||
@@ -16,7 +16,7 @@ export class ARAgingSummaryApplication {
|
||||
|
||||
/**
|
||||
* Retrieve the A/R aging summary sheet.
|
||||
* @param {IAPAgingSummaryQuery} query
|
||||
* @param {IARAgingSummaryQuery} query
|
||||
*/
|
||||
public sheet(query: IARAgingSummaryQuery) {
|
||||
return this.ARAgingSummarySheet.ARAgingSummary(query);
|
||||
@@ -24,7 +24,6 @@ export class ARAgingSummaryApplication {
|
||||
|
||||
/**
|
||||
* Retrieve the A/R aging summary in table format.
|
||||
* @param {number} tenantId
|
||||
* @param {IAPAgingSummaryQuery} query
|
||||
*/
|
||||
public table(query: IARAgingSummaryQuery) {
|
||||
@@ -33,7 +32,6 @@ export class ARAgingSummaryApplication {
|
||||
|
||||
/**
|
||||
* Retrieve the A/R aging summary in XLSX format.
|
||||
* @param {number} tenantId
|
||||
* @param {IAPAgingSummaryQuery} query
|
||||
*/
|
||||
public xlsx(query: IARAgingSummaryQuery) {
|
||||
@@ -42,7 +40,6 @@ export class ARAgingSummaryApplication {
|
||||
|
||||
/**
|
||||
* Retrieve the A/R aging summary in CSV format.
|
||||
* @param {number} tenantId
|
||||
* @param {IAPAgingSummaryQuery} query
|
||||
*/
|
||||
public csv(query: IARAgingSummaryQuery) {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { isEmpty, groupBy } from 'lodash';
|
||||
import { Customer } from '@/modules/Customers/models/Customer';
|
||||
import { SaleInvoice } from '@/modules/SaleInvoices/models/SaleInvoice';
|
||||
import { ModelObject } from 'objection';
|
||||
import { IARAgingSummaryQuery } from './ARAgingSummary.types';
|
||||
import { TenancyContext } from '@/modules/Tenancy/TenancyContext.service';
|
||||
import { Inject } from '@nestjs/common';
|
||||
|
||||
export class ARAgingSummaryRepository {
|
||||
@Inject(TenancyContext)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
import * as moment from 'moment';
|
||||
|
||||
|
||||
export const getARAgingSummaryDefaultQuery = () => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as moment from 'moment';
|
||||
import { IAgingPeriod } from './AgingSummary.types';
|
||||
import { FinancialSheet } from '../../common/FinancialSheet';
|
||||
|
||||
export abstract class AgingReport extends FinancialSheet {
|
||||
export class AgingReport extends FinancialSheet {
|
||||
/**
|
||||
* Retrieve the aging periods range.
|
||||
* @param {string} asDay
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AgingSummaryMeta } from './AgingSummaryMeta';
|
||||
import { FinancialSheetCommonModule } from '../../common/FinancialSheetCommon.module';
|
||||
|
||||
@Module({
|
||||
imports: [FinancialSheetCommonModule],
|
||||
exports: [AgingSummaryMeta],
|
||||
providers: [AgingSummaryMeta],
|
||||
})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { FinancialSheetMeta } from '../../common/FinancialSheetMeta';
|
||||
import { IAgingSummaryMeta, IAgingSummaryQuery } from './AgingSummary.types';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import {
|
||||
ICustomerBalanceSummaryMeta,
|
||||
ICustomerBalanceSummaryQuery,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as moment from 'moment';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import {
|
||||
IGeneralLedgerMeta,
|
||||
IGeneralLedgerSheetQuery,
|
||||
} from './GeneralLedger.types';
|
||||
import moment from 'moment';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { FinancialSheetMeta } from '../../common/FinancialSheetMeta';
|
||||
|
||||
@Injectable()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import * as R from 'ramda';
|
||||
import {
|
||||
IGeneralLedgerSheetQuery,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ModelObject, raw } from 'objection';
|
||||
import { isEmpty } from 'lodash';
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { IInventoryDetailsQuery } from './InventoryItemDetails.types';
|
||||
import { Item } from '@/modules/Items/models/Item';
|
||||
import { InventoryTransaction } from '@/modules/InventoryCost/models/InventoryTransaction';
|
||||
|
||||
@@ -5,14 +5,23 @@ import { InventoryValuationMetaInjectable } from './InventoryValuationSheetMeta'
|
||||
import { InventoryValuationController } from './InventoryValuation.controller';
|
||||
import { InventoryValuationSheetService } from './InventoryValuationSheetService';
|
||||
import { InventoryValuationSheetApplication } from './InventoryValuationSheetApplication';
|
||||
import { FinancialSheetCommonModule } from '../../common/FinancialSheetCommon.module';
|
||||
import { InventoryValuationSheetRepository } from './InventoryValuationSheetRepository';
|
||||
import { InventoryValuationSheetExportable } from './InventoryValuationSheetExportable';
|
||||
import { InventoryCostModule } from '@/modules/InventoryCost/InventoryCost.module';
|
||||
import { TenancyContext } from '@/modules/Tenancy/TenancyContext.service';
|
||||
|
||||
@Module({
|
||||
imports: [FinancialSheetCommonModule, InventoryCostModule],
|
||||
providers: [
|
||||
InventoryValuationSheetPdf,
|
||||
InventoryValuationSheetTableInjectable,
|
||||
InventoryValuationMetaInjectable,
|
||||
InventoryValuationSheetService,
|
||||
InventoryValuationSheetApplication,
|
||||
InventoryValuationSheetRepository,
|
||||
InventoryValuationSheetExportable,
|
||||
TenancyContext
|
||||
],
|
||||
controllers: [InventoryValuationController],
|
||||
exports: [InventoryValuationSheetApplication],
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import * as moment from 'moment';
|
||||
|
||||
export enum ROW_TYPE {
|
||||
ITEM = 'ITEM',
|
||||
TOTAL = 'TOTAL',
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
import moment from 'moment';
|
||||
import { FinancialSheetMeta } from '../../common/FinancialSheetMeta';
|
||||
import { ISalesByItemsReportQuery, ISalesByItemsSheetMeta } from './SalesByItems.types';
|
||||
import * as moment from 'moment';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { I18nService } from 'nestjs-i18n';
|
||||
import { FinancialSheetMeta } from '../../common/FinancialSheetMeta';
|
||||
import {
|
||||
ISalesByItemsReportQuery,
|
||||
ISalesByItemsSheetMeta,
|
||||
} from './SalesByItems.types';
|
||||
|
||||
@Injectable()
|
||||
export class SalesByItemsMeta {
|
||||
constructor(
|
||||
private financialSheetMeta: FinancialSheetMeta,
|
||||
private i18n: I18nService,
|
||||
) {}
|
||||
constructor(private financialSheetMeta: FinancialSheetMeta) {}
|
||||
|
||||
/**
|
||||
* Retrieve the sales by items meta.
|
||||
* @returns {IBalanceSheetMeta}
|
||||
*/
|
||||
public async meta(
|
||||
query: ISalesByItemsReportQuery
|
||||
query: ISalesByItemsReportQuery,
|
||||
): Promise<ISalesByItemsSheetMeta> {
|
||||
const commonMeta = await this.financialSheetMeta.meta();
|
||||
const formattedToDate = moment(query.toDate).format('YYYY/MM/DD');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import * as R from 'ramda';
|
||||
import { ITransactionsByContactsContact } from './TransactionsByContact.types';
|
||||
import { ITableRow } from '../../types/Table.types';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import bluebird from 'bluebird';
|
||||
import { deleteImportFile } from './_utils';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as Yup from 'yup';
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import * as R from 'ramda';
|
||||
import { Knex } from 'knex';
|
||||
import fs from 'fs/promises';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Model } from 'objection';
|
||||
import { castArray } from 'lodash';
|
||||
import moment, { unitOfTime } from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { unitOfTime } from 'moment';
|
||||
import { SaleInvoice } from '@/modules/SaleInvoices/models/SaleInvoice';
|
||||
import { SaleReceipt } from '@/modules/SaleReceipts/models/SaleReceipt';
|
||||
import { Item } from '@/modules/Items/models/Item';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as moment from 'moment';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { Knex } from 'knex';
|
||||
import moment from 'moment';
|
||||
import { SaleEstimate } from '../models/SaleEstimate';
|
||||
import { events } from '@/common/events/events';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Knex } from 'knex';
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { Model } from 'objection';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { Knex } from 'knex';
|
||||
import {
|
||||
ISaleReceiptEventClosedPayload,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common';
|
||||
import * as R from 'ramda';
|
||||
import { sumBy, omit } from 'lodash';
|
||||
import * as composeAsync from 'async/compose';
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { SaleReceiptIncrement } from './SaleReceiptIncrement.service';
|
||||
import { ItemsEntriesService } from '@/modules/Items/ItemsEntries.service';
|
||||
import { BranchTransactionDTOTransformer } from '@/modules/Branches/integrations/BranchTransactionDTOTransform';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import moment, { unitOfTime } from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { unitOfTime } from 'moment';
|
||||
|
||||
export class SubscriptionPeriod {
|
||||
private start: Date;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Model, mixin } from 'objection';
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { SubscriptionPeriod } from '../SubscriptionPeriod';
|
||||
import { SystemModel } from '@/modules/System/models/SystemModel';
|
||||
import { SubscriptionPaymentStatus } from '@/interfaces/SubscriptionPlan';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import moment, { MomentInput } from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { MomentInput } from 'moment';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { TransactionsLockingGroup } from '../types/TransactionsLocking.types';
|
||||
import { TransactionsLockingRepository } from '../TransactionsLockingRepository';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { omit } from 'lodash';
|
||||
import * as R from 'ramda';
|
||||
import { ERRORS } from '../constants';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import moment from 'moment';
|
||||
import * as moment from 'moment';
|
||||
import { defaultTo, isEmpty } from 'lodash';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { IVendorEditDTO, IVendorNewDTO } from '../types/Vendors.types';
|
||||
|
||||
@@ -2,5 +2,6 @@ export const transformToMapKeyValue = <T, K extends string | number>(
|
||||
collection: T[],
|
||||
key: keyof T,
|
||||
): Map<K, T> => {
|
||||
// @ts-ignore
|
||||
return new Map(collection.map((item) => [item[key], item]));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user