mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
refactor(nestjs): export module
This commit is contained in:
8
packages/server/src/common/constants/http.constants.ts
Normal file
8
packages/server/src/common/constants/http.constants.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
export const ACCEPT_TYPE = {
|
||||||
|
APPLICATION_PDF: 'application/pdf',
|
||||||
|
APPLICATION_JSON: 'application/json',
|
||||||
|
APPLICATION_JSON_TABLE: 'application/json+table',
|
||||||
|
APPLICATION_XLSX: 'application/xlsx',
|
||||||
|
APPLICATION_CSV: 'application/csv',
|
||||||
|
APPLICATION_TEXT_HTML: 'application/json+html',
|
||||||
|
};
|
||||||
@@ -17,6 +17,7 @@ import { RegisterTenancyModel } from '../Tenancy/TenancyModels/Tenancy.module';
|
|||||||
import { BankAccount } from '../BankingTransactions/models/BankAccount';
|
import { BankAccount } from '../BankingTransactions/models/BankAccount';
|
||||||
import { GetAccountsService } from './GetAccounts.service';
|
import { GetAccountsService } from './GetAccounts.service';
|
||||||
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
||||||
|
import { AccountsExportable } from './AccountsExportable.service';
|
||||||
// import { GetAccountsService } from './GetAccounts.service';
|
// import { GetAccountsService } from './GetAccounts.service';
|
||||||
|
|
||||||
const models = [RegisterTenancyModel(BankAccount)];
|
const models = [RegisterTenancyModel(BankAccount)];
|
||||||
@@ -38,6 +39,7 @@ const models = [RegisterTenancyModel(BankAccount)];
|
|||||||
GetAccountTypesService,
|
GetAccountTypesService,
|
||||||
GetAccountTransactionsService,
|
GetAccountTransactionsService,
|
||||||
GetAccountsService,
|
GetAccountsService,
|
||||||
|
AccountsExportable
|
||||||
],
|
],
|
||||||
exports: [AccountRepository, CreateAccountService, ...models],
|
exports: [AccountRepository, CreateAccountService, ...models],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,8 +2,16 @@ import { AccountsApplication } from './AccountsApplication.service';
|
|||||||
import { Exportable } from '../Export/Exportable';
|
import { Exportable } from '../Export/Exportable';
|
||||||
import { EXPORT_SIZE_LIMIT } from '../Export/constants';
|
import { EXPORT_SIZE_LIMIT } from '../Export/constants';
|
||||||
import { IAccountsFilter, IAccountsStructureType } from './Accounts.types';
|
import { IAccountsFilter, IAccountsStructureType } from './Accounts.types';
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { ExportableService } from '../Export/decorators/ExportableModel.decorator';
|
||||||
|
import { Account } from './models/Account.model';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
@ExportableService({ name: Account.name })
|
||||||
export class AccountsExportable extends Exportable {
|
export class AccountsExportable extends Exportable {
|
||||||
|
/**
|
||||||
|
* @param {AccountsApplication} accountsApplication
|
||||||
|
*/
|
||||||
constructor(private readonly accountsApplication: AccountsApplication) {
|
constructor(private readonly accountsApplication: AccountsApplication) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,13 @@ import { Model } from 'objection';
|
|||||||
import { PlaidItem } from '@/modules/BankingPlaid/models/PlaidItem';
|
import { PlaidItem } from '@/modules/BankingPlaid/models/PlaidItem';
|
||||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||||
import { flatToNestedArray } from '@/utils/flat-to-nested-array';
|
import { flatToNestedArray } from '@/utils/flat-to-nested-array';
|
||||||
|
import { ExportableModel } from '../../Export/decorators/ExportableModel.decorator';
|
||||||
// import AccountSettings from './Account.Settings';
|
// import AccountSettings from './Account.Settings';
|
||||||
// import { DEFAULT_VIEWS } from '@/modules/Accounts/constants';
|
// import { DEFAULT_VIEWS } from '@/modules/Accounts/constants';
|
||||||
// import { buildFilterQuery, buildSortColumnQuery } from '@/lib/ViewRolesBuilder';
|
// import { buildFilterQuery, buildSortColumnQuery } from '@/lib/ViewRolesBuilder';
|
||||||
// import { flatToNestedArray } from 'utils';
|
// import { flatToNestedArray } from 'utils';
|
||||||
|
|
||||||
|
@ExportableModel()
|
||||||
export class Account extends TenantBaseModel {
|
export class Account extends TenantBaseModel {
|
||||||
public name!: string;
|
public name!: string;
|
||||||
public slug!: string;
|
public slug!: string;
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ import { TenancyModule } from '../Tenancy/Tenancy.module';
|
|||||||
import { LoopsModule } from '../Loops/Loops.module';
|
import { LoopsModule } from '../Loops/Loops.module';
|
||||||
import { AttachmentsModule } from '../Attachments/Attachment.module';
|
import { AttachmentsModule } from '../Attachments/Attachment.module';
|
||||||
import { S3Module } from '../S3/S3.module';
|
import { S3Module } from '../S3/S3.module';
|
||||||
|
import { ExportModule } from '../Export/Export.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -192,7 +193,8 @@ import { S3Module } from '../S3/S3.module';
|
|||||||
PaymentServicesModule,
|
PaymentServicesModule,
|
||||||
LoopsModule,
|
LoopsModule,
|
||||||
AttachmentsModule,
|
AttachmentsModule,
|
||||||
S3Module
|
S3Module,
|
||||||
|
ExportModule
|
||||||
],
|
],
|
||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
providers: [
|
providers: [
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { BillPaymentGLEntries } from './commands/BillPaymentGLEntries';
|
|||||||
import { BillPaymentGLEntriesSubscriber } from './subscribers/BillPaymentGLEntriesSubscriber';
|
import { BillPaymentGLEntriesSubscriber } from './subscribers/BillPaymentGLEntriesSubscriber';
|
||||||
import { LedgerModule } from '../Ledger/Ledger.module';
|
import { LedgerModule } from '../Ledger/Ledger.module';
|
||||||
import { AccountsModule } from '../Accounts/Accounts.module';
|
import { AccountsModule } from '../Accounts/Accounts.module';
|
||||||
|
import { BillPaymentsExportable } from './queries/BillPaymentsExportable';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [LedgerModule, AccountsModule],
|
imports: [LedgerModule, AccountsModule],
|
||||||
@@ -34,6 +35,7 @@ import { AccountsModule } from '../Accounts/Accounts.module';
|
|||||||
TenancyContext,
|
TenancyContext,
|
||||||
BillPaymentGLEntries,
|
BillPaymentGLEntries,
|
||||||
BillPaymentGLEntriesSubscriber,
|
BillPaymentGLEntriesSubscriber,
|
||||||
|
BillPaymentsExportable
|
||||||
],
|
],
|
||||||
exports: [BillPaymentValidators, CreateBillPaymentService],
|
exports: [BillPaymentValidators, CreateBillPaymentService],
|
||||||
controllers: [BillPaymentsController],
|
controllers: [BillPaymentsController],
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ export class BillPaymentsApplication {
|
|||||||
private deleteBillPaymentService: DeleteBillPayment,
|
private deleteBillPaymentService: DeleteBillPayment,
|
||||||
private getBillPaymentService: GetBillPayment,
|
private getBillPaymentService: GetBillPayment,
|
||||||
private getPaymentBillsService: GetPaymentBills,
|
private getPaymentBillsService: GetPaymentBills,
|
||||||
// private getBillPaymentsService: GetBillPayments,
|
private getBillPaymentsService: GetBillPayments,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a bill payment with associated GL entries.
|
* Creates a bill payment with associated GL entries.
|
||||||
* @param {IBillPaymentDTO} billPaymentDTO
|
* @param {IBillPaymentDTO} billPaymentDTO - Create bill payment dto.
|
||||||
* @returns {Promise<IBillPayment>}
|
* @returns {Promise<IBillPayment>}
|
||||||
*/
|
*/
|
||||||
public createBillPayment(billPaymentDTO: CreateBillPaymentDto) {
|
public createBillPayment(billPaymentDTO: CreateBillPaymentDto) {
|
||||||
@@ -34,7 +34,7 @@ export class BillPaymentsApplication {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delets the given bill payment with associated GL entries.
|
* Delets the given bill payment with associated GL entries.
|
||||||
* @param {number} billPaymentId
|
* @param {number} billPaymentId - Bill payment id.
|
||||||
*/
|
*/
|
||||||
public deleteBillPayment(billPaymentId: number) {
|
public deleteBillPayment(billPaymentId: number) {
|
||||||
return this.deleteBillPaymentService.deleteBillPayment(billPaymentId);
|
return this.deleteBillPaymentService.deleteBillPayment(billPaymentId);
|
||||||
@@ -58,13 +58,10 @@ export class BillPaymentsApplication {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves bill payments list.
|
* Retrieves bill payments list.
|
||||||
* @param {number} tenantId
|
|
||||||
* @param filterDTO
|
|
||||||
* @returns
|
|
||||||
*/
|
*/
|
||||||
// public getBillPayments(filterDTO: IBillPaymentsFilter) {
|
public getBillPayments(filterDTO: IBillPaymentsFilter) {
|
||||||
// return this.getBillPaymentsService.getBillPayments(filterDTO);
|
return this.getBillPaymentsService.getBillPayments(filterDTO);
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve specific bill payment.
|
* Retrieve specific bill payment.
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
// import { Inject, Service } from 'typedi';
|
|
||||||
// import { Exportable } from '@/services/Export/Exportable';
|
|
||||||
// import { BillPaymentsApplication } from './BillPaymentsApplication';
|
|
||||||
// import { EXPORT_SIZE_LIMIT } from '@/services/Export/constants';
|
|
||||||
|
|
||||||
// @Service()
|
|
||||||
// export class BillPaymentExportable extends Exportable {
|
|
||||||
// @Inject()
|
|
||||||
// private billPaymentsApplication: BillPaymentsApplication;
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Retrieves the accounts data to exportable sheet.
|
|
||||||
// * @param {number} tenantId
|
|
||||||
// * @returns
|
|
||||||
// */
|
|
||||||
// public exportable(tenantId: number, query: any) {
|
|
||||||
// const filterQuery = (builder) => {
|
|
||||||
// builder.withGraphFetched('entries.bill');
|
|
||||||
// builder.withGraphFetched('branch');
|
|
||||||
// };
|
|
||||||
// const parsedQuery = {
|
|
||||||
// sortOrder: 'desc',
|
|
||||||
// columnSortBy: 'created_at',
|
|
||||||
// ...query,
|
|
||||||
// page: 1,
|
|
||||||
// pageSize: EXPORT_SIZE_LIMIT,
|
|
||||||
// filterQuery
|
|
||||||
// } as any;
|
|
||||||
|
|
||||||
// return this.billPaymentsApplication
|
|
||||||
// .getBillPayments(tenantId, parsedQuery)
|
|
||||||
// .then((output) => output.billPayments);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import { Injectable } from "@nestjs/common";
|
||||||
|
import { BillPaymentsApplication } from "../BillPaymentsApplication.service";
|
||||||
|
import { Exportable } from "@/modules/Export/Exportable";
|
||||||
|
import { EXPORT_SIZE_LIMIT } from "@/modules/Export/constants";
|
||||||
|
import { ExportableService } from "@/modules/Export/decorators/ExportableModel.decorator";
|
||||||
|
import { BillPayment } from "../models/BillPayment";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
@ExportableService({ name: BillPayment.name })
|
||||||
|
export class BillPaymentsExportable extends Exportable {
|
||||||
|
constructor(
|
||||||
|
private readonly billPaymentsApplication: BillPaymentsApplication
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the accounts data to exportable sheet.
|
||||||
|
* @param {number} tenantId
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
public exportable(query: any) {
|
||||||
|
const filterQuery = (builder) => {
|
||||||
|
builder.withGraphFetched('entries.bill');
|
||||||
|
builder.withGraphFetched('branch');
|
||||||
|
};
|
||||||
|
const parsedQuery = {
|
||||||
|
sortOrder: 'desc',
|
||||||
|
columnSortBy: 'created_at',
|
||||||
|
...query,
|
||||||
|
page: 1,
|
||||||
|
pageSize: EXPORT_SIZE_LIMIT,
|
||||||
|
filterQuery
|
||||||
|
} as any;
|
||||||
|
|
||||||
|
return [];
|
||||||
|
|
||||||
|
// return this.billPaymentsApplication
|
||||||
|
// .billPayments(tenantId, parsedQuery)
|
||||||
|
// .then((output) => output.billPayments);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,6 +26,7 @@ import { BillInventoryTransactions } from './commands/BillInventoryTransactions'
|
|||||||
import { GetBillsService } from './queries/GetBills.service';
|
import { GetBillsService } from './queries/GetBills.service';
|
||||||
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
||||||
import { InventoryCostModule } from '../InventoryCost/InventoryCost.module';
|
import { InventoryCostModule } from '../InventoryCost/InventoryCost.module';
|
||||||
|
import { BillsExportable } from './commands/BillsExportable';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -57,6 +58,7 @@ import { InventoryCostModule } from '../InventoryCost/InventoryCost.module';
|
|||||||
BillGLEntriesSubscriber,
|
BillGLEntriesSubscriber,
|
||||||
BillInventoryTransactions,
|
BillInventoryTransactions,
|
||||||
BillWriteInventoryTransactionsSubscriber,
|
BillWriteInventoryTransactionsSubscriber,
|
||||||
|
BillsExportable
|
||||||
],
|
],
|
||||||
controllers: [BillsController],
|
controllers: [BillsController],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,37 +1,35 @@
|
|||||||
// import { Inject, Service } from 'typedi';
|
import { Knex } from 'knex';
|
||||||
// import { Knex } from 'knex';
|
import { BillsApplication } from '../Bills.application';
|
||||||
// import { IBillsFilter } from '@/interfaces';
|
import { Injectable } from '@nestjs/common';
|
||||||
// import { Exportable } from '@/services/Export/Exportable';
|
import { Exportable } from '@/modules/Export/Exportable';
|
||||||
// import { BillsApplication } from '../Bills.application';
|
import { IBillsFilter } from '../Bills.types';
|
||||||
// import { EXPORT_SIZE_LIMIT } from '@/services/Export/constants';
|
import { EXPORT_SIZE_LIMIT } from '@/modules/Export/constants';
|
||||||
// import Objection from 'objection';
|
|
||||||
|
|
||||||
// @Service()
|
@Injectable()
|
||||||
// export class BillsExportable extends Exportable {
|
export class BillsExportable extends Exportable {
|
||||||
// @Inject()
|
constructor(private readonly billsApplication: BillsApplication) {
|
||||||
// private billsApplication: BillsApplication;
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Retrieves the accounts data to exportable sheet.
|
* Retrieves the accounts data to exportable sheet.
|
||||||
// * @param {number} tenantId
|
*/
|
||||||
// * @returns
|
public exportable(query: IBillsFilter) {
|
||||||
// */
|
const filterQuery = (query) => {
|
||||||
// public exportable(tenantId: number, query: IBillsFilter) {
|
query.withGraphFetched('branch');
|
||||||
// const filterQuery = (query) => {
|
query.withGraphFetched('warehouse');
|
||||||
// query.withGraphFetched('branch');
|
};
|
||||||
// query.withGraphFetched('warehouse');
|
const parsedQuery = {
|
||||||
// };
|
sortOrder: 'desc',
|
||||||
// const parsedQuery = {
|
columnSortBy: 'created_at',
|
||||||
// sortOrder: 'desc',
|
...query,
|
||||||
// columnSortBy: 'created_at',
|
page: 1,
|
||||||
// ...query,
|
pageSize: EXPORT_SIZE_LIMIT,
|
||||||
// page: 1,
|
filterQuery,
|
||||||
// pageSize: EXPORT_SIZE_LIMIT,
|
} as IBillsFilter;
|
||||||
// filterQuery,
|
|
||||||
// } as IBillsFilter;
|
|
||||||
|
|
||||||
// return this.billsApplication
|
return this.billsApplication
|
||||||
// .getBills(tenantId, parsedQuery)
|
.getBills(parsedQuery)
|
||||||
// .then((output) => output.bills);
|
.then((output) => output.bills);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ import { BillLandedCost } from '@/modules/BillLandedCosts/models/BillLandedCost'
|
|||||||
import { DiscountType } from '@/common/types/Discount';
|
import { DiscountType } from '@/common/types/Discount';
|
||||||
import type { Knex, QueryBuilder } from 'knex';
|
import type { Knex, QueryBuilder } from 'knex';
|
||||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||||
|
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||||
|
|
||||||
|
@ExportableModel()
|
||||||
export class Bill extends TenantBaseModel {
|
export class Bill extends TenantBaseModel {
|
||||||
public amount: number;
|
public amount: number;
|
||||||
public paymentAmount: number;
|
public paymentAmount: number;
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ export class GetBillPayments {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the specific bill associated payment transactions.
|
* Retrieve the specific bill associated payment transactions.
|
||||||
* @param {number} billId
|
* @param {number} billId - Bill id.
|
||||||
* @returns {}
|
|
||||||
*/
|
*/
|
||||||
public getBillPayments = async (billId: number) => {
|
public getBillPayments = async (billId: number) => {
|
||||||
const billsEntries = await this.billPaymentEntryModel
|
const billsEntries = await this.billPaymentEntryModel
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import { LedgerModule } from '../Ledger/Ledger.module';
|
|||||||
import { AccountsModule } from '../Accounts/Accounts.module';
|
import { AccountsModule } from '../Accounts/Accounts.module';
|
||||||
import { GetCreditNotesService } from './queries/GetCreditNotes.service';
|
import { GetCreditNotesService } from './queries/GetCreditNotes.service';
|
||||||
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
||||||
|
import { CreditNotesExportable } from './commands/CreditNotesExportable';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -53,6 +54,7 @@ import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
|||||||
CreditNoteBrandingTemplate,
|
CreditNoteBrandingTemplate,
|
||||||
CreditNoteGLEntries,
|
CreditNoteGLEntries,
|
||||||
CreditNoteGLEntriesSubscriber,
|
CreditNoteGLEntriesSubscriber,
|
||||||
|
CreditNotesExportable
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
CreateCreditNoteService,
|
CreateCreditNoteService,
|
||||||
|
|||||||
@@ -1,35 +1,34 @@
|
|||||||
// import { Inject, Service } from 'typedi';
|
import { Exportable } from '@/modules/Export/Exportable';
|
||||||
// import { ICreditNotesQueryDTO } from '@/interfaces';
|
import { CreditNoteApplication } from '../CreditNoteApplication.service';
|
||||||
// import { Exportable } from '@/services/Export/Exportable';
|
import { Injectable } from '@nestjs/common';
|
||||||
// import ListCreditNotes from '../ListCreditNotes';
|
import { ICreditNotesQueryDTO } from '../types/CreditNotes.types';
|
||||||
|
|
||||||
// @Service()
|
@Injectable()
|
||||||
// export class CreditNotesExportable extends Exportable {
|
export class CreditNotesExportable extends Exportable {
|
||||||
// @Inject()
|
constructor(private readonly creditNotesApp: CreditNoteApplication) {
|
||||||
// private getCreditNotes: ListCreditNotes;
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Retrieves the accounts data to exportable sheet.
|
* Retrieves the accounts data to exportable sheet.
|
||||||
// * @param {number} tenantId -
|
* @param {IVendorCreditsQueryDTO} query -
|
||||||
// * @param {IVendorCreditsQueryDTO} query -
|
*/
|
||||||
// * @returns {}
|
public exportable(query: ICreditNotesQueryDTO) {
|
||||||
// */
|
const filterQuery = (query) => {
|
||||||
// public exportable(tenantId: number, query: ICreditNotesQueryDTO) {
|
query.withGraphFetched('branch');
|
||||||
// const filterQuery = (query) => {
|
query.withGraphFetched('warehouse');
|
||||||
// query.withGraphFetched('branch');
|
};
|
||||||
// query.withGraphFetched('warehouse');
|
const parsedQuery = {
|
||||||
// };
|
sortOrder: 'desc',
|
||||||
// const parsedQuery = {
|
columnSortBy: 'created_at',
|
||||||
// sortOrder: 'desc',
|
...query,
|
||||||
// columnSortBy: 'created_at',
|
page: 1,
|
||||||
// ...query,
|
pageSize: 12000,
|
||||||
// page: 1,
|
filterQuery,
|
||||||
// pageSize: 12000,
|
} as ICreditNotesQueryDTO;
|
||||||
// filterQuery,
|
|
||||||
// } as ICreditNotesQueryDTO;
|
|
||||||
|
|
||||||
// return this.getCreditNotes
|
return this.creditNotesApp
|
||||||
// .getCreditNotesList(tenantId, parsedQuery)
|
.getCreditNotes(parsedQuery)
|
||||||
// .then((output) => output.creditNotes);
|
.then((output) => output.creditNotes);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ import { DiscountType } from '@/common/types/Discount';
|
|||||||
import { BaseModel } from '@/models/Model';
|
import { BaseModel } from '@/models/Model';
|
||||||
import { Branch } from '@/modules/Branches/models/Branch.model';
|
import { Branch } from '@/modules/Branches/models/Branch.model';
|
||||||
import { Customer } from '@/modules/Customers/models/Customer';
|
import { Customer } from '@/modules/Customers/models/Customer';
|
||||||
|
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||||
import { ItemEntry } from '@/modules/TransactionItemEntry/models/ItemEntry';
|
import { ItemEntry } from '@/modules/TransactionItemEntry/models/ItemEntry';
|
||||||
import { Warehouse } from '@/modules/Warehouses/models/Warehouse.model';
|
import { Warehouse } from '@/modules/Warehouses/models/Warehouse.model';
|
||||||
import { mixin, Model, raw } from 'objection';
|
import { mixin, Model, raw } from 'objection';
|
||||||
|
|
||||||
|
@ExportableModel()
|
||||||
export class CreditNote extends TenantBaseModel {
|
export class CreditNote extends TenantBaseModel {
|
||||||
public amount: number;
|
public amount: number;
|
||||||
public exchangeRate: number;
|
public exchangeRate: number;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { CreateEditCustomerDTO } from './commands/CreateEditCustomerDTO.service'
|
|||||||
import { CustomersController } from './Customers.controller';
|
import { CustomersController } from './Customers.controller';
|
||||||
import { CustomersApplication } from './CustomersApplication.service';
|
import { CustomersApplication } from './CustomersApplication.service';
|
||||||
import { DeleteCustomer } from './commands/DeleteCustomer.service';
|
import { DeleteCustomer } from './commands/DeleteCustomer.service';
|
||||||
|
import { CustomersExportable } from './CustomersExportable';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [TenancyDatabaseModule],
|
imports: [TenancyDatabaseModule],
|
||||||
@@ -29,7 +30,8 @@ import { DeleteCustomer } from './commands/DeleteCustomer.service';
|
|||||||
DeleteCustomer,
|
DeleteCustomer,
|
||||||
TenancyContext,
|
TenancyContext,
|
||||||
TransformerInjectable,
|
TransformerInjectable,
|
||||||
GetCustomerService
|
GetCustomerService,
|
||||||
|
CustomersExportable
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class CustomersModule {}
|
export class CustomersModule {}
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ import { CreateCustomer } from './commands/CreateCustomer.service';
|
|||||||
import { EditCustomer } from './commands/EditCustomer.service';
|
import { EditCustomer } from './commands/EditCustomer.service';
|
||||||
import { DeleteCustomer } from './commands/DeleteCustomer.service';
|
import { DeleteCustomer } from './commands/DeleteCustomer.service';
|
||||||
import { EditOpeningBalanceCustomer } from './commands/EditOpeningBalanceCustomer.service';
|
import { EditOpeningBalanceCustomer } from './commands/EditOpeningBalanceCustomer.service';
|
||||||
import { ICustomerOpeningBalanceEditDTO } from './types/Customers.types';
|
import { ICustomerOpeningBalanceEditDTO, ICustomersFilter } from './types/Customers.types';
|
||||||
import { CreateCustomerDto } from './dtos/CreateCustomer.dto';
|
import { CreateCustomerDto } from './dtos/CreateCustomer.dto';
|
||||||
import { EditCustomerDto } from './dtos/EditCustomer.dto';
|
import { EditCustomerDto } from './dtos/EditCustomer.dto';
|
||||||
|
import { GetCustomers } from './queries/GetCustomers.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CustomersApplication {
|
export class CustomersApplication {
|
||||||
@@ -16,13 +17,12 @@ export class CustomersApplication {
|
|||||||
private editCustomerService: EditCustomer,
|
private editCustomerService: EditCustomer,
|
||||||
private deleteCustomerService: DeleteCustomer,
|
private deleteCustomerService: DeleteCustomer,
|
||||||
private editOpeningBalanceService: EditOpeningBalanceCustomer,
|
private editOpeningBalanceService: EditOpeningBalanceCustomer,
|
||||||
// private getCustomersService: GetCustomers,
|
private getCustomersService: GetCustomers,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the given customer details.
|
* Retrieves the given customer details.
|
||||||
* @param {number} tenantId
|
* @param {number} customerId - Customer id.
|
||||||
* @param {number} customerId
|
|
||||||
*/
|
*/
|
||||||
public getCustomer = (customerId: number) => {
|
public getCustomer = (customerId: number) => {
|
||||||
return this.getCustomerService.getCustomer(customerId);
|
return this.getCustomerService.getCustomer(customerId);
|
||||||
@@ -30,7 +30,7 @@ export class CustomersApplication {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new customer.
|
* Creates a new customer.
|
||||||
* @param {ICustomerNewDTO} customerDTO
|
* @param {ICustomerNewDTO} customerDTO - Create customer dto.
|
||||||
* @returns {Promise<ICustomer>}
|
* @returns {Promise<ICustomer>}
|
||||||
*/
|
*/
|
||||||
public createCustomer = (customerDTO: CreateCustomerDto) => {
|
public createCustomer = (customerDTO: CreateCustomerDto) => {
|
||||||
@@ -49,9 +49,7 @@ export class CustomersApplication {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the given customer and associated transactions.
|
* Deletes the given customer and associated transactions.
|
||||||
* @param {number} tenantId
|
* @param {number} customerId - Customer id.
|
||||||
* @param {number} customerId
|
|
||||||
* @param {ISystemUser} authorizedUser
|
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
public deleteCustomer = (customerId: number) => {
|
public deleteCustomer = (customerId: number) => {
|
||||||
@@ -60,9 +58,8 @@ export class CustomersApplication {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the opening balance of the given customer.
|
* Changes the opening balance of the given customer.
|
||||||
* @param {number} tenantId
|
* @param {number} customerId - Customer id.
|
||||||
* @param {number} customerId
|
* @param {Date|string} openingBalanceEditDTO - Opening balance edit dto.
|
||||||
* @param {Date|string} openingBalanceEditDTO
|
|
||||||
* @returns {Promise<ICustomer>}
|
* @returns {Promise<ICustomer>}
|
||||||
*/
|
*/
|
||||||
public editOpeningBalance = (
|
public editOpeningBalance = (
|
||||||
@@ -77,10 +74,9 @@ export class CustomersApplication {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve customers paginated list.
|
* Retrieve customers paginated list.
|
||||||
* @param {number} tenantId - Tenant id.
|
|
||||||
* @param {ICustomersFilter} filter - Cusotmers filter.
|
* @param {ICustomersFilter} filter - Cusotmers filter.
|
||||||
*/
|
*/
|
||||||
// public getCustomers = (filterDTO: ICustomersFilter) => {
|
public getCustomers = (filterDTO: ICustomersFilter) => {
|
||||||
// return this.getCustomersService.getCustomersList(filterDTO);
|
return this.getCustomersService.getCustomersList(filterDTO);
|
||||||
// };
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,34 @@
|
|||||||
// import { Inject, Service } from 'typedi';
|
import { Injectable } from '@nestjs/common';
|
||||||
// import { IItemsFilter } from '@/interfaces';
|
import { CustomersApplication } from './CustomersApplication.service';
|
||||||
// import { CustomersApplication } from './CustomersApplication';
|
import { IItemsFilter } from '../Items/types/Items.types';
|
||||||
// import { Exportable } from '@/services/Export/Exportable';
|
import { EXPORT_SIZE_LIMIT } from '../Export/constants';
|
||||||
// import { EXPORT_SIZE_LIMIT } from '@/services/Export/constants';
|
import { Exportable } from '../Export/Exportable';
|
||||||
|
import { ICustomersFilter } from './types/Customers.types';
|
||||||
|
import { ExportableService } from '../Export/decorators/ExportableModel.decorator';
|
||||||
|
import { Customer } from './models/Customer';
|
||||||
|
|
||||||
// @Service()
|
@Injectable()
|
||||||
// export class CustomersExportable extends Exportable {
|
@ExportableService({ name: Customer.name })
|
||||||
// @Inject()
|
export class CustomersExportable extends Exportable {
|
||||||
// private customersApplication: CustomersApplication;
|
constructor(private readonly customersApplication: CustomersApplication) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Retrieves the accounts data to exportable sheet.
|
* Retrieves the accounts data to exportable sheet.
|
||||||
// * @param {number} tenantId
|
* @param {ICustomersFilter} query - Customers query.
|
||||||
// * @returns
|
*/
|
||||||
// */
|
public exportable(query: ICustomersFilter) {
|
||||||
// public exportable(tenantId: number, query: IItemsFilter) {
|
const parsedQuery = {
|
||||||
// const parsedQuery = {
|
sortOrder: 'DESC',
|
||||||
// sortOrder: 'DESC',
|
columnSortBy: 'created_at',
|
||||||
// columnSortBy: 'created_at',
|
...query,
|
||||||
// ...query,
|
page: 1,
|
||||||
// page: 1,
|
pageSize: EXPORT_SIZE_LIMIT,
|
||||||
// pageSize: EXPORT_SIZE_LIMIT,
|
} as IItemsFilter;
|
||||||
// } as IItemsFilter;
|
|
||||||
|
|
||||||
// return this.customersApplication
|
return this.customersApplication
|
||||||
// .getCustomers(tenantId, parsedQuery)
|
.getCustomers(parsedQuery)
|
||||||
// .then((output) => output.customers);
|
.then((output) => output.customers);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import { LedgerModule } from '../Ledger/Ledger.module';
|
|||||||
import { BranchesModule } from '../Branches/Branches.module';
|
import { BranchesModule } from '../Branches/Branches.module';
|
||||||
import { GetExpensesService } from './queries/GetExpenses.service';
|
import { GetExpensesService } from './queries/GetExpenses.service';
|
||||||
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
||||||
|
import { ExpensesExportable } from './ExpensesExportable';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [LedgerModule, BranchesModule, DynamicListModule],
|
imports: [LedgerModule, BranchesModule, DynamicListModule],
|
||||||
@@ -37,6 +38,7 @@ import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
|||||||
ExpenseGLEntriesStorageService,
|
ExpenseGLEntriesStorageService,
|
||||||
ExpenseGLEntriesService,
|
ExpenseGLEntriesService,
|
||||||
GetExpensesService,
|
GetExpensesService,
|
||||||
|
ExpensesExportable
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class ExpensesModule {}
|
export class ExpensesModule {}
|
||||||
|
|||||||
@@ -1,34 +1,38 @@
|
|||||||
// import { Inject, Service } from 'typedi';
|
import { Exportable } from '../Export/Exportable';
|
||||||
// import { Exportable } from '../Export/Exportable';
|
import { ExpensesApplication } from './ExpensesApplication.service';
|
||||||
// import { IExpensesFilter } from '@/interfaces';
|
import { EXPORT_SIZE_LIMIT } from '../Export/constants';
|
||||||
// import { ExpensesApplication } from './ExpensesApplication.service';
|
import { Injectable } from '@nestjs/common';
|
||||||
// import { EXPORT_SIZE_LIMIT } from '../Export/constants';
|
import { IExpensesFilter } from './Expenses.types';
|
||||||
|
import { ExportableService } from '../Export/decorators/ExportableModel.decorator';
|
||||||
|
import { Expense } from './models/Expense.model';
|
||||||
|
|
||||||
// @Service()
|
@Injectable()
|
||||||
// export class ExpensesExportable extends Exportable {
|
@ExportableService({ name: Expense.name })
|
||||||
// @Inject()
|
export class ExpensesExportable extends Exportable {
|
||||||
// private expensesApplication: ExpensesApplication;
|
constructor(
|
||||||
|
private readonly expensesApplication: ExpensesApplication,
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Retrieves the accounts data to exportable sheet.
|
* Retrieves the accounts data to exportable sheet.
|
||||||
// * @param {number} tenantId
|
*/
|
||||||
// * @returns
|
public exportable(query: IExpensesFilter) {
|
||||||
// */
|
const filterQuery = (query) => {
|
||||||
// public exportable(tenantId: number, query: IExpensesFilter) {
|
query.withGraphFetched('branch');
|
||||||
// const filterQuery = (query) => {
|
};
|
||||||
// query.withGraphFetched('branch');
|
const parsedQuery = {
|
||||||
// };
|
sortOrder: 'desc',
|
||||||
// const parsedQuery = {
|
columnSortBy: 'created_at',
|
||||||
// sortOrder: 'desc',
|
...query,
|
||||||
// columnSortBy: 'created_at',
|
page: 1,
|
||||||
// ...query,
|
pageSize: EXPORT_SIZE_LIMIT,
|
||||||
// page: 1,
|
filterQuery,
|
||||||
// pageSize: EXPORT_SIZE_LIMIT,
|
} as IExpensesFilter;
|
||||||
// filterQuery,
|
|
||||||
// } as IExpensesFilter;
|
|
||||||
|
|
||||||
// return this.expensesApplication
|
return this.expensesApplication
|
||||||
// .getExpenses(tenantId, parsedQuery)
|
.getExpenses(parsedQuery)
|
||||||
// .then((output) => output.expenses);
|
.then((output) => output.expenses);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ import * as moment from 'moment';
|
|||||||
import { ExpenseCategory } from './ExpenseCategory.model';
|
import { ExpenseCategory } from './ExpenseCategory.model';
|
||||||
import { Account } from '@/modules/Accounts/models/Account.model';
|
import { Account } from '@/modules/Accounts/models/Account.model';
|
||||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||||
|
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||||
|
|
||||||
|
@ExportableModel()
|
||||||
export class Expense extends TenantBaseModel {
|
export class Expense extends TenantBaseModel {
|
||||||
totalAmount!: number;
|
totalAmount!: number;
|
||||||
currencyCode!: string;
|
currencyCode!: string;
|
||||||
|
|||||||
@@ -1,20 +1,24 @@
|
|||||||
import { Response } from 'express';
|
import { Response } from 'express';
|
||||||
import { convertAcceptFormatToFormat } from './_utils';
|
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||||
import { Controller, Headers, Query, Res } from '@nestjs/common';
|
import { Controller, Get, Headers, Query, Res } from '@nestjs/common';
|
||||||
|
import { AcceptType } from '@/constants/accept-type';
|
||||||
import { ExportQuery } from './dtos/ExportQuery.dto';
|
import { ExportQuery } from './dtos/ExportQuery.dto';
|
||||||
import { ExportResourceService } from './ExportService';
|
import { ExportResourceService } from './ExportService';
|
||||||
import { AcceptType } from '@/constants/accept-type';
|
import { convertAcceptFormatToFormat } from './Export.utils';
|
||||||
|
|
||||||
@Controller('/export')
|
@Controller('/export')
|
||||||
|
@ApiTags('export')
|
||||||
export class ExportController {
|
export class ExportController {
|
||||||
constructor(private readonly exportResourceApp: ExportResourceService) {}
|
constructor(private readonly exportResourceApp: ExportResourceService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
@ApiOperation({ summary: 'Retrieves exported the given resource.' })
|
||||||
async export(
|
async export(
|
||||||
@Query() query: ExportQuery,
|
@Query() query: ExportQuery,
|
||||||
@Res() res: Response,
|
@Res() res: Response,
|
||||||
@Headers('accept') acceptHeader: string,
|
@Headers('accept') acceptHeader: string,
|
||||||
) {
|
) {
|
||||||
const applicationFormat = convertAcceptFormatToFormat(acceptType);
|
const applicationFormat = convertAcceptFormatToFormat(acceptHeader);
|
||||||
|
|
||||||
const data = await this.exportResourceApp.export(
|
const data = await this.exportResourceApp.export(
|
||||||
query.resource,
|
query.resource,
|
||||||
|
|||||||
13
packages/server/src/modules/Export/Export.utils.ts
Normal file
13
packages/server/src/modules/Export/Export.utils.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { ACCEPT_TYPE } from '@/common/constants/http.constants';
|
||||||
|
import { ExportFormat } from './common';
|
||||||
|
|
||||||
|
export const convertAcceptFormatToFormat = (accept: string): ExportFormat => {
|
||||||
|
switch (accept) {
|
||||||
|
case ACCEPT_TYPE.APPLICATION_CSV:
|
||||||
|
return ExportFormat.Csv;
|
||||||
|
case ACCEPT_TYPE.APPLICATION_PDF:
|
||||||
|
return ExportFormat.Pdf;
|
||||||
|
case ACCEPT_TYPE.APPLICATION_XLSX:
|
||||||
|
return ExportFormat.Xlsx;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,22 +1,3 @@
|
|||||||
// import Container, { Service } from 'typedi';
|
|
||||||
// import { AccountsExportable } from '../Accounts/AccountsExportable';
|
|
||||||
// import { ExportableRegistry } from './ExportRegistery';
|
|
||||||
// import { ItemsExportable } from '../Items/ItemsExportable';
|
|
||||||
// import { CustomersExportable } from '../Contacts/Customers/CustomersExportable';
|
|
||||||
// import { VendorsExportable } from '../Contacts/Vendors/VendorsExportable';
|
|
||||||
// import { ExpensesExportable } from '../Expenses/ExpensesExportable';
|
|
||||||
// import { SaleInvoicesExportable } from '../Sales/Invoices/SaleInvoicesExportable';
|
|
||||||
// import { SaleEstimatesExportable } from '../Sales/Estimates/SaleEstimatesExportable';
|
|
||||||
// import { SaleReceiptsExportable } from '../Sales/Receipts/SaleReceiptsExportable';
|
|
||||||
// import { BillsExportable } from '../Purchases/Bills/BillsExportable';
|
|
||||||
// import { PaymentsReceivedExportable } from '../Sales/PaymentReceived/PaymentsReceivedExportable';
|
|
||||||
// import { BillPaymentExportable } from '../Purchases/BillPayments/BillPaymentExportable';
|
|
||||||
// import { ManualJournalsExportable } from '../ManualJournals/ManualJournalExportable';
|
|
||||||
// import { CreditNotesExportable } from '../CreditNotes/CreditNotesExportable';
|
|
||||||
// import { VendorCreditsExportable } from '../Purchases/VendorCredits/VendorCreditsExportable';
|
|
||||||
// import { ItemCategoriesExportable } from '../ItemCategories/ItemCategoriesExportable';
|
|
||||||
// import { TaxRatesExportable } from '../TaxRates/TaxRatesExportable';
|
|
||||||
|
|
||||||
import { Injectable } from "@nestjs/common";
|
import { Injectable } from "@nestjs/common";
|
||||||
import { ExportableRegistry } from "./ExportRegistery";
|
import { ExportableRegistry } from "./ExportRegistery";
|
||||||
import { AccountsExportable } from "../Accounts/AccountsExportable.service";
|
import { AccountsExportable } from "../Accounts/AccountsExportable.service";
|
||||||
@@ -33,7 +14,7 @@ export class ExportableResources {
|
|||||||
* Importable instances.
|
* Importable instances.
|
||||||
*/
|
*/
|
||||||
private importables = [
|
private importables = [
|
||||||
{ resource: 'Account', exportable: AccountsExportable },
|
// { resource: 'Account', exportable: AccountsExportable },
|
||||||
// { resource: 'Item', exportable: ItemsExportable },
|
// { resource: 'Item', exportable: ItemsExportable },
|
||||||
// { resource: 'ItemCategory', exportable: ItemCategoriesExportable },
|
// { resource: 'ItemCategory', exportable: ItemCategoriesExportable },
|
||||||
// { resource: 'Customer', exportable: CustomersExportable },
|
// { resource: 'Customer', exportable: CustomersExportable },
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ export class ExportResourceService {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param {string} resourceName
|
* @param {string} resourceName
|
||||||
* @param {ExportFormat} format
|
* @param {ExportFormat} format
|
||||||
* @returns
|
* @returns
|
||||||
@@ -46,15 +45,14 @@ export class ExportResourceService {
|
|||||||
format: ExportFormat = ExportFormat.Csv
|
format: ExportFormat = ExportFormat.Csv
|
||||||
) {
|
) {
|
||||||
const resource = sanitizeResourceName(resourceName);
|
const resource = sanitizeResourceName(resourceName);
|
||||||
const resourceMeta = this.getResourceMeta(tenantId, resource);
|
const resourceMeta = this.getResourceMeta(resource);
|
||||||
const resourceColumns = this.resourceService.getResourceColumns(
|
const resourceColumns = this.resourceService.getResourceColumns(
|
||||||
tenantId,
|
|
||||||
resource
|
resource
|
||||||
);
|
);
|
||||||
this.validateResourceMeta(resourceMeta);
|
this.validateResourceMeta(resourceMeta);
|
||||||
|
|
||||||
const data = await this.getExportableData(tenantId, resource);
|
const data = await this.getExportableData(resource);
|
||||||
const transformed = this.transformExportedData(tenantId, resource, data);
|
const transformed = this.transformExportedData(resource, data);
|
||||||
|
|
||||||
// Returns the csv, xlsx format.
|
// Returns the csv, xlsx format.
|
||||||
if (format === ExportFormat.Csv || format === ExportFormat.Xlsx) {
|
if (format === ExportFormat.Csv || format === ExportFormat.Xlsx) {
|
||||||
@@ -67,7 +65,6 @@ export class ExportResourceService {
|
|||||||
const printableColumns = this.getPrintableColumns(resourceMeta);
|
const printableColumns = this.getPrintableColumns(resourceMeta);
|
||||||
|
|
||||||
return this.exportPdf.pdf(
|
return this.exportPdf.pdf(
|
||||||
tenantId,
|
|
||||||
printableColumns,
|
printableColumns,
|
||||||
transformed,
|
transformed,
|
||||||
resourceMeta?.print?.pageTitle
|
resourceMeta?.print?.pageTitle
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export class Exportable {
|
|||||||
*/
|
*/
|
||||||
public async exportable(
|
public async exportable(
|
||||||
query: Record<string, any>,
|
query: Record<string, any>,
|
||||||
): Promise<Array<Record<string, any>>> {
|
): Promise<any> {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
const exportableModels = new Map<string, boolean>();
|
||||||
|
const exportableService = new Map<string, any>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decorator that marks a model as exportable and registers its metadata.
|
||||||
|
* @param metadata Model metadata configuration for export
|
||||||
|
*/
|
||||||
|
export function ExportableModel() {
|
||||||
|
return function (target: any) {
|
||||||
|
const modelName = target.name;
|
||||||
|
exportableModels.set(modelName, true);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ExportableService({ name }: { name: string }) {
|
||||||
|
return function (target: any) {
|
||||||
|
exportableService.set(name, target);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the registered exportable model metadata
|
||||||
|
* @param modelName Name of the model class
|
||||||
|
*/
|
||||||
|
export function getExportableModelMeta(modelName: string): boolean | undefined {
|
||||||
|
return exportableModels.get(modelName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function getExportableService(modelName: string) {
|
||||||
|
return exportableService.get(modelName);
|
||||||
|
}
|
||||||
@@ -20,9 +20,9 @@ import {
|
|||||||
} from 'lodash';
|
} from 'lodash';
|
||||||
import pluralize from 'pluralize';
|
import pluralize from 'pluralize';
|
||||||
import { ResourceMetaFieldsMap } from './interfaces';
|
import { ResourceMetaFieldsMap } from './interfaces';
|
||||||
import { IModelMetaField, IModelMetaField2 } from '@/interfaces';
|
|
||||||
import { ServiceError } from '@/exceptions';
|
|
||||||
import { multiNumberParse } from '@/utils/multi-number-parse';
|
import { multiNumberParse } from '@/utils/multi-number-parse';
|
||||||
|
import { ServiceError } from '../Items/ServiceError';
|
||||||
|
import { IModelMetaField, IModelMetaField2 } from '@/interfaces/Model';
|
||||||
|
|
||||||
export const ERRORS = {
|
export const ERRORS = {
|
||||||
RESOURCE_NOT_IMPORTABLE: 'RESOURCE_NOT_IMPORTABLE',
|
RESOURCE_NOT_IMPORTABLE: 'RESOURCE_NOT_IMPORTABLE',
|
||||||
@@ -336,7 +336,7 @@ export const valueParser =
|
|||||||
* @param {string} key - Mapped key path. formats: `group.key` or `key`.
|
* @param {string} key - Mapped key path. formats: `group.key` or `key`.
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
export const parseKey: R.Curry<string> = R.curry(
|
export const parseKey = R.curry(
|
||||||
(fields: { [key: string]: IModelMetaField2 }, key: string) => {
|
(fields: { [key: string]: IModelMetaField2 }, key: string) => {
|
||||||
const fieldKey = getFieldKey(key);
|
const fieldKey = getFieldKey(key);
|
||||||
const field = fields[fieldKey];
|
const field = fields[fieldKey];
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export class Import extends BaseModel {
|
|||||||
mapping!: string;
|
mapping!: string;
|
||||||
columns!: string;
|
columns!: string;
|
||||||
params!: string;
|
params!: string;
|
||||||
|
importId!: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table name.
|
* Table name.
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
// import { Inject, Service } from 'typedi';
|
import { Injectable } from '@nestjs/common';
|
||||||
// import { Exportable } from '../Export/Exportable';
|
import { Exportable } from '../Export/Exportable';
|
||||||
// import { IAccountsFilter, IAccountsStructureType } from '@/interfaces';
|
import { ItemCategoryApplication } from './ItemCategory.application';
|
||||||
// import ItemCategoriesService from './ItemCategoriesService';
|
import { IItemCategoriesFilter } from './ItemCategory.interfaces';
|
||||||
|
import { ExportableService } from '../Export/decorators/ExportableModel.decorator';
|
||||||
|
import { ItemCategory } from './models/ItemCategory.model';
|
||||||
|
|
||||||
// @Service()
|
@Injectable()
|
||||||
// export class ItemCategoriesExportable extends Exportable {
|
@ExportableService({ name: ItemCategory.name })
|
||||||
// @Inject()
|
export class ItemCategoriesExportable extends Exportable {
|
||||||
// private itemCategoriesApplication: ItemCategoriesService;
|
constructor(private readonly itemCategoryApp: ItemCategoryApplication) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Retrieves the accounts data to exportable sheet.
|
* Retrieves the accounts data to exportable sheet.
|
||||||
// * @param {number} tenantId
|
* @param {number} tenantId
|
||||||
// * @returns
|
* @returns
|
||||||
// */
|
*/
|
||||||
// public exportable(tenantId: number, query: IAccountsFilter) {
|
public exportable(query: Partial<IItemCategoriesFilter>) {
|
||||||
// const parsedQuery = {
|
const parsedQuery = {
|
||||||
// sortOrder: 'desc',
|
...query
|
||||||
// columnSortBy: 'created_at',
|
} as IItemCategoriesFilter;
|
||||||
// inactiveMode: false,
|
|
||||||
// ...query,
|
|
||||||
// structure: IAccountsStructureType.Flat,
|
|
||||||
// } as IAccountsFilter;
|
|
||||||
|
|
||||||
// return this.itemCategoriesApplication
|
return this.itemCategoryApp
|
||||||
// .getItemCategoriesList(tenantId, parsedQuery, {})
|
.getItemCategories(parsedQuery)
|
||||||
// .then((output) => output.itemCategories);
|
.then((output) => output.itemCategories);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { TransformerInjectable } from '../Transformer/TransformerInjectable.serv
|
|||||||
import { TenancyContext } from '../Tenancy/TenancyContext.service';
|
import { TenancyContext } from '../Tenancy/TenancyContext.service';
|
||||||
import { GetItemCategoriesService } from './queries/GetItemCategories.service';
|
import { GetItemCategoriesService } from './queries/GetItemCategories.service';
|
||||||
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
||||||
|
import { ItemCategoriesExportable } from './ItemCategoriesExportable';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [TenancyDatabaseModule, DynamicListModule],
|
imports: [TenancyDatabaseModule, DynamicListModule],
|
||||||
@@ -23,6 +24,7 @@ import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
|||||||
DeleteItemCategoryService,
|
DeleteItemCategoryService,
|
||||||
ItemCategoryApplication,
|
ItemCategoryApplication,
|
||||||
CommandItemCategoryValidatorService,
|
CommandItemCategoryValidatorService,
|
||||||
|
ItemCategoriesExportable,
|
||||||
TransformerInjectable,
|
TransformerInjectable,
|
||||||
TenancyContext,
|
TenancyContext,
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||||
import { Model } from 'objection';
|
import { Model } from 'objection';
|
||||||
|
|
||||||
|
@ExportableModel()
|
||||||
export class ItemCategory extends TenantBaseModel {
|
export class ItemCategory extends TenantBaseModel {
|
||||||
name!: string;
|
name!: string;
|
||||||
description!: string;
|
description!: string;
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { Warehouse } from '@/modules/Warehouses/models/Warehouse.model';
|
import { Warehouse } from '@/modules/Warehouses/models/Warehouse.model';
|
||||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||||
import { Model } from 'objection';
|
import { Model } from 'objection';
|
||||||
|
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||||
|
|
||||||
|
@ExportableModel()
|
||||||
export class Item extends TenantBaseModel {
|
export class Item extends TenantBaseModel {
|
||||||
public readonly quantityOnHand: number;
|
public readonly quantityOnHand: number;
|
||||||
public readonly name: string;
|
public readonly name: string;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { GetManualJournal } from './queries/GetManualJournal.service';
|
|||||||
import { ManualJournalWriteGLSubscriber } from './commands/ManualJournalGLEntriesSubscriber';
|
import { ManualJournalWriteGLSubscriber } from './commands/ManualJournalGLEntriesSubscriber';
|
||||||
import { ManualJournalGLEntries } from './commands/ManualJournalGLEntries';
|
import { ManualJournalGLEntries } from './commands/ManualJournalGLEntries';
|
||||||
import { LedgerModule } from '../Ledger/Ledger.module';
|
import { LedgerModule } from '../Ledger/Ledger.module';
|
||||||
|
import { ManualJournalsExportable } from './commands/ManualJournalExportable';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [BranchesModule, LedgerModule],
|
imports: [BranchesModule, LedgerModule],
|
||||||
@@ -33,7 +34,8 @@ import { LedgerModule } from '../Ledger/Ledger.module';
|
|||||||
ManualJournalsApplication,
|
ManualJournalsApplication,
|
||||||
GetManualJournal,
|
GetManualJournal,
|
||||||
ManualJournalGLEntries,
|
ManualJournalGLEntries,
|
||||||
ManualJournalWriteGLSubscriber
|
ManualJournalWriteGLSubscriber,
|
||||||
|
ManualJournalsExportable
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class ManualJournalsModule {}
|
export class ManualJournalsModule {}
|
||||||
|
|||||||
@@ -4,8 +4,12 @@ import { EditManualJournal } from './commands/EditManualJournal.service';
|
|||||||
import { PublishManualJournal } from './commands/PublishManualJournal.service';
|
import { PublishManualJournal } from './commands/PublishManualJournal.service';
|
||||||
import { GetManualJournal } from './queries/GetManualJournal.service';
|
import { GetManualJournal } from './queries/GetManualJournal.service';
|
||||||
import { DeleteManualJournalService } from './commands/DeleteManualJournal.service';
|
import { DeleteManualJournalService } from './commands/DeleteManualJournal.service';
|
||||||
import { IManualJournalDTO, } from './types/ManualJournals.types';
|
import { IManualJournalsFilter } from './types/ManualJournals.types';
|
||||||
import { CreateManualJournalDto, EditManualJournalDto } from './dtos/ManualJournal.dto';
|
import {
|
||||||
|
CreateManualJournalDto,
|
||||||
|
EditManualJournalDto,
|
||||||
|
} from './dtos/ManualJournal.dto';
|
||||||
|
import { GetManualJournals } from './queries/GetManualJournals.service';
|
||||||
// import { GetManualJournals } from './queries/GetManualJournals';
|
// import { GetManualJournals } from './queries/GetManualJournals';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -16,7 +20,7 @@ export class ManualJournalsApplication {
|
|||||||
private deleteManualJournalService: DeleteManualJournalService,
|
private deleteManualJournalService: DeleteManualJournalService,
|
||||||
private publishManualJournalService: PublishManualJournal,
|
private publishManualJournalService: PublishManualJournal,
|
||||||
private getManualJournalService: GetManualJournal,
|
private getManualJournalService: GetManualJournal,
|
||||||
// private getManualJournalsService: GetManualJournals,
|
private getManualJournalsService: GetManualJournals,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,9 +54,7 @@ export class ManualJournalsApplication {
|
|||||||
* @return {Promise<void>}
|
* @return {Promise<void>}
|
||||||
*/
|
*/
|
||||||
public deleteManualJournal = (manualJournalId: number) => {
|
public deleteManualJournal = (manualJournalId: number) => {
|
||||||
return this.deleteManualJournalService.deleteManualJournal(
|
return this.deleteManualJournalService.deleteManualJournal(manualJournalId);
|
||||||
manualJournalId,
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,23 +70,16 @@ export class ManualJournalsApplication {
|
|||||||
/**
|
/**
|
||||||
* Retrieves the specific manual journal.
|
* Retrieves the specific manual journal.
|
||||||
* @param {number} manualJournalId
|
* @param {number} manualJournalId
|
||||||
* @returns
|
|
||||||
*/
|
*/
|
||||||
public getManualJournal = (manualJournalId: number) => {
|
public getManualJournal = (manualJournalId: number) => {
|
||||||
return this.getManualJournalService.getManualJournal(
|
return this.getManualJournalService.getManualJournal(manualJournalId);
|
||||||
manualJournalId,
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the paginated manual journals.
|
* Retrieves the paginated manual journals.
|
||||||
* @param {number} tenantId
|
|
||||||
* @param {IManualJournalsFilter} filterDTO
|
* @param {IManualJournalsFilter} filterDTO
|
||||||
* @returns
|
|
||||||
*/
|
*/
|
||||||
// public getManualJournals = (
|
public getManualJournals = (filterDTO: IManualJournalsFilter) => {
|
||||||
// filterDTO: IManualJournalsFilter,
|
return this.getManualJournalsService.getManualJournals(filterDTO);
|
||||||
// ) => {
|
};
|
||||||
// // return this.getManualJournalsService.getManualJournals(filterDTO);
|
|
||||||
// };
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,31 @@
|
|||||||
// import { Inject, Service } from 'typedi';
|
import { Exportable } from '../../Export/Exportable';
|
||||||
// import { IManualJournalsFilter } from '@/interfaces';
|
import { EXPORT_SIZE_LIMIT } from '../../Export/constants';
|
||||||
// import { Exportable } from '../../Export/Exportable';
|
import { Injectable } from '@nestjs/common';
|
||||||
// import { ManualJournalsApplication } from '../ManualJournalsApplication';
|
import { IManualJournalsFilter } from '../types/ManualJournals.types';
|
||||||
// import { EXPORT_SIZE_LIMIT } from '../../Export/constants';
|
import { ManualJournalsApplication } from '../ManualJournalsApplication.service';
|
||||||
|
|
||||||
// @Service()
|
@Injectable()
|
||||||
// export class ManualJournalsExportable extends Exportable {
|
export class ManualJournalsExportable extends Exportable {
|
||||||
// @Inject()
|
constructor(
|
||||||
// private manualJournalsApplication: ManualJournalsApplication;
|
private readonly manualJournalsApplication: ManualJournalsApplication,
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Retrieves the manual journals data to exportable sheet.
|
* Retrieves the manual journals data to exportable sheet.
|
||||||
// * @param {number} tenantId
|
*/
|
||||||
// * @returns
|
public exportable(query: IManualJournalsFilter) {
|
||||||
// */
|
const parsedQuery = {
|
||||||
// public exportable(tenantId: number, query: IManualJournalsFilter) {
|
sortOrder: 'desc',
|
||||||
// const parsedQuery = {
|
columnSortBy: 'created_at',
|
||||||
// sortOrder: 'desc',
|
...query,
|
||||||
// columnSortBy: 'created_at',
|
page: 1,
|
||||||
// ...query,
|
pageSize: EXPORT_SIZE_LIMIT,
|
||||||
// page: 1,
|
} as IManualJournalsFilter;
|
||||||
// pageSize: EXPORT_SIZE_LIMIT,
|
|
||||||
// } as IManualJournalsFilter;
|
|
||||||
|
|
||||||
// return this.manualJournalsApplication
|
return this.manualJournalsApplication
|
||||||
// .getManualJournals(tenantId, parsedQuery)
|
.getManualJournals(parsedQuery)
|
||||||
// .then((output) => output.manualJournals);
|
.then((output) => output.manualJournals);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import { Model, mixin } from 'objection';
|
|||||||
import { ManualJournalEntry } from './ManualJournalEntry';
|
import { ManualJournalEntry } from './ManualJournalEntry';
|
||||||
import { Document } from '@/modules/ChromiumlyTenancy/models/Document';
|
import { Document } from '@/modules/ChromiumlyTenancy/models/Document';
|
||||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||||
|
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||||
|
|
||||||
|
@ExportableModel()
|
||||||
export class ManualJournal extends TenantBaseModel {
|
export class ManualJournal extends TenantBaseModel {
|
||||||
date: Date;
|
date: Date;
|
||||||
journalNumber: string;
|
journalNumber: string;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import { MailModule } from '../Mail/Mail.module';
|
|||||||
import { SendPaymentReceivedMailProcessor } from './processors/PaymentReceivedMailNotification.processor';
|
import { SendPaymentReceivedMailProcessor } from './processors/PaymentReceivedMailNotification.processor';
|
||||||
import { BullModule } from '@nestjs/bull';
|
import { BullModule } from '@nestjs/bull';
|
||||||
import { SEND_PAYMENT_RECEIVED_MAIL_QUEUE } from './constants';
|
import { SEND_PAYMENT_RECEIVED_MAIL_QUEUE } from './constants';
|
||||||
|
import { PaymentsReceivedExportable } from './commands/PaymentsReceivedExportable';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
controllers: [PaymentReceivesController],
|
controllers: [PaymentReceivesController],
|
||||||
@@ -59,6 +60,7 @@ import { SEND_PAYMENT_RECEIVED_MAIL_QUEUE } from './constants';
|
|||||||
GetPaymentsReceivedService,
|
GetPaymentsReceivedService,
|
||||||
SendPaymentReceiveMailNotification,
|
SendPaymentReceiveMailNotification,
|
||||||
SendPaymentReceivedMailProcessor,
|
SendPaymentReceivedMailProcessor,
|
||||||
|
PaymentsReceivedExportable
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
PaymentReceivesApplication,
|
PaymentReceivesApplication,
|
||||||
|
|||||||
@@ -1,39 +1,34 @@
|
|||||||
// import { Inject, Service } from 'typedi';
|
import { Injectable } from '@nestjs/common';
|
||||||
// import { IAccountsStructureType, IPaymentsReceivedFilter } from '@/interfaces';
|
import { PaymentReceivesApplication } from '../PaymentReceived.application';
|
||||||
// import { Exportable } from '@/services/Export/Exportable';
|
import { IPaymentsReceivedFilter } from '../types/PaymentReceived.types';
|
||||||
// import { PaymentReceivesApplication } from './PaymentReceived.application';
|
import { EXPORT_SIZE_LIMIT } from '@/modules/Export/constants';
|
||||||
// import { EXPORT_SIZE_LIMIT } from '@/services/Export/constants';
|
import { Exportable } from '@/modules/Export/Exportable';
|
||||||
|
|
||||||
// @Service()
|
@Injectable()
|
||||||
// export class PaymentsReceivedExportable extends Exportable {
|
export class PaymentsReceivedExportable extends Exportable {
|
||||||
// @Inject()
|
constructor(private readonly paymentReceivedApp: PaymentReceivesApplication) {
|
||||||
// private paymentReceivedApp: PaymentReceivesApplication;
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Retrieves the accounts data to exportable sheet.
|
* Retrieves the accounts data to exportable sheet.
|
||||||
// * @param {number} tenantId
|
* @param {number} tenantId
|
||||||
// * @param {IPaymentsReceivedFilter} query -
|
* @param {IPaymentsReceivedFilter} query -
|
||||||
// * @returns
|
* @returns
|
||||||
// */
|
*/
|
||||||
// public exportable(tenantId: number, query: IPaymentsReceivedFilter) {
|
public exportable(query: IPaymentsReceivedFilter) {
|
||||||
// const filterQuery = (builder) => {
|
const filterQuery = (builder) => {
|
||||||
// builder.withGraphFetched('entries.invoice');
|
builder.withGraphFetched('entries.invoice');
|
||||||
// builder.withGraphFetched('branch');
|
builder.withGraphFetched('branch');
|
||||||
// };
|
};
|
||||||
|
const parsedQuery = {
|
||||||
// const parsedQuery = {
|
page: 1,
|
||||||
// sortOrder: 'desc',
|
pageSize: EXPORT_SIZE_LIMIT,
|
||||||
// columnSortBy: 'created_at',
|
filterQuery,
|
||||||
// inactiveMode: false,
|
...query
|
||||||
// ...query,
|
};
|
||||||
// structure: IAccountsStructureType.Flat,
|
return this.paymentReceivedApp
|
||||||
// page: 1,
|
.getPaymentsReceived(parsedQuery)
|
||||||
// pageSize: EXPORT_SIZE_LIMIT,
|
.then((output) => output.paymentReceives);
|
||||||
// filterQuery,
|
}
|
||||||
// } as IPaymentsReceivedFilter;
|
}
|
||||||
|
|
||||||
// return this.paymentReceivedApp
|
|
||||||
// .getPaymentReceives(tenantId, parsedQuery)
|
|
||||||
// .then((output) => output.paymentReceives);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { Model } from 'objection';
|
import { Model } from 'objection';
|
||||||
import { PaymentReceivedEntry } from './PaymentReceivedEntry';
|
import { PaymentReceivedEntry } from './PaymentReceivedEntry';
|
||||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||||
|
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||||
|
|
||||||
|
@ExportableModel()
|
||||||
export class PaymentReceived extends TenantBaseModel {
|
export class PaymentReceived extends TenantBaseModel {
|
||||||
customerId: number;
|
customerId: number;
|
||||||
paymentDate: string;
|
paymentDate: string;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import { TemplateInjectableModule } from '../TemplateInjectable/TemplateInjectab
|
|||||||
import { SaleEstimatePdfTemplate } from '../SaleInvoices/queries/SaleEstimatePdfTemplate.service';
|
import { SaleEstimatePdfTemplate } from '../SaleInvoices/queries/SaleEstimatePdfTemplate.service';
|
||||||
import { PdfTemplatesModule } from '../PdfTemplate/PdfTemplates.module';
|
import { PdfTemplatesModule } from '../PdfTemplate/PdfTemplates.module';
|
||||||
import { SendSaleEstimateMailQueue } from './types/SaleEstimates.types';
|
import { SendSaleEstimateMailQueue } from './types/SaleEstimates.types';
|
||||||
|
import { SaleEstimatesExportable } from './SaleEstimatesExportable';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -74,7 +75,8 @@ import { SendSaleEstimateMailQueue } from './types/SaleEstimates.types';
|
|||||||
SaleEstimatesApplication,
|
SaleEstimatesApplication,
|
||||||
SendSaleEstimateMail,
|
SendSaleEstimateMail,
|
||||||
GetSaleEstimatePdf,
|
GetSaleEstimatePdf,
|
||||||
SaleEstimatePdfTemplate
|
SaleEstimatePdfTemplate,
|
||||||
|
SaleEstimatesExportable
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class SaleEstimatesModule {}
|
export class SaleEstimatesModule {}
|
||||||
|
|||||||
@@ -1,35 +1,38 @@
|
|||||||
// import { Inject, Service } from 'typedi';
|
import { Injectable } from '@nestjs/common';
|
||||||
// import { ISalesInvoicesFilter } from '@/interfaces';
|
import { EXPORT_SIZE_LIMIT } from '../Export/constants';
|
||||||
// import { Exportable } from '@/services/Export/Exportable';
|
import { Exportable } from '../Export/Exportable';
|
||||||
// import { SaleEstimatesApplication } from './SaleEstimates.application';
|
import { ISalesInvoicesFilter } from '../SaleInvoices/SaleInvoice.types';
|
||||||
// import { EXPORT_SIZE_LIMIT } from '@/services/Export/constants';
|
import { SaleEstimatesApplication } from './SaleEstimates.application';
|
||||||
|
import { ISalesEstimatesFilter } from './types/SaleEstimates.types';
|
||||||
|
|
||||||
// @Service()
|
@Injectable()
|
||||||
// export class SaleEstimatesExportable extends Exportable {
|
export class SaleEstimatesExportable extends Exportable {
|
||||||
// @Inject()
|
constructor(
|
||||||
// private saleEstimatesApplication: SaleEstimatesApplication;
|
private readonly saleEstimatesApplication: SaleEstimatesApplication,
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Retrieves the accounts data to exportable sheet.
|
* Retrieves the accounts data to exportable sheet.
|
||||||
// * @param {number} tenantId
|
* @param {ISalesEstimatesFilter} query -
|
||||||
// * @returns
|
*/
|
||||||
// */
|
public exportable(query: ISalesEstimatesFilter) {
|
||||||
// public exportable(tenantId: number, query: ISalesInvoicesFilter) {
|
const filterQuery = (query) => {
|
||||||
// const filterQuery = (query) => {
|
query.withGraphFetched('branch');
|
||||||
// query.withGraphFetched('branch');
|
query.withGraphFetched('warehouse');
|
||||||
// query.withGraphFetched('warehouse');
|
};
|
||||||
// };
|
const parsedQuery = {
|
||||||
// const parsedQuery = {
|
sortOrder: 'desc',
|
||||||
// sortOrder: 'desc',
|
columnSortBy: 'created_at',
|
||||||
// columnSortBy: 'created_at',
|
...query,
|
||||||
// ...query,
|
page: 1,
|
||||||
// page: 1,
|
pageSize: EXPORT_SIZE_LIMIT,
|
||||||
// pageSize: EXPORT_SIZE_LIMIT,
|
filterQuery,
|
||||||
// filterQuery,
|
} as ISalesInvoicesFilter;
|
||||||
// } as ISalesInvoicesFilter;
|
|
||||||
|
|
||||||
// return this.saleEstimatesApplication
|
return this.saleEstimatesApplication
|
||||||
// .getSaleEstimates(tenantId, parsedQuery)
|
.getSaleEstimates(parsedQuery)
|
||||||
// .then((output) => output.salesEstimates);
|
.then((output) => output.salesEstimates);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ import * as moment from 'moment';
|
|||||||
import { Model } from 'objection';
|
import { Model } from 'objection';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||||
|
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||||
|
|
||||||
@Injectable()
|
@ExportableModel()
|
||||||
export class SaleEstimate extends TenantBaseModel {
|
export class SaleEstimate extends TenantBaseModel {
|
||||||
exchangeRate!: number;
|
exchangeRate!: number;
|
||||||
amount!: number;
|
amount!: number;
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ import { SaleInvoiceCostGLEntries } from './SaleInvoiceCostGLEntries';
|
|||||||
import { InvoicePaymentsGLEntriesRewrite } from './InvoicePaymentsGLRewrite';
|
import { InvoicePaymentsGLEntriesRewrite } from './InvoicePaymentsGLRewrite';
|
||||||
import { PaymentsReceivedModule } from '../PaymentReceived/PaymentsReceived.module';
|
import { PaymentsReceivedModule } from '../PaymentReceived/PaymentsReceived.module';
|
||||||
import { SaleInvoicesCost } from './SalesInvoicesCost';
|
import { SaleInvoicesCost } from './SalesInvoicesCost';
|
||||||
|
import { SaleInvoicesExportable } from './commands/SaleInvoicesExportable';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -118,6 +119,7 @@ import { SaleInvoicesCost } from './SalesInvoicesCost';
|
|||||||
SaleInvoiceWriteInventoryTransactionsSubscriber,
|
SaleInvoiceWriteInventoryTransactionsSubscriber,
|
||||||
InvoicePaymentsGLEntriesRewrite,
|
InvoicePaymentsGLEntriesRewrite,
|
||||||
SaleInvoicesCost,
|
SaleInvoicesCost,
|
||||||
|
SaleInvoicesExportable
|
||||||
],
|
],
|
||||||
exports: [GetSaleInvoice, SaleInvoicesCost, SaleInvoicePdf],
|
exports: [GetSaleInvoice, SaleInvoicesCost, SaleInvoicePdf],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,35 +1,39 @@
|
|||||||
// import { Inject, Service } from 'typedi';
|
import { Exportable } from '@/modules/Export/Exportable';
|
||||||
// import { ISalesInvoicesFilter } from '@/interfaces';
|
import { Injectable } from '@nestjs/common';
|
||||||
// import { SaleInvoiceApplication } from './SaleInvoices.application';
|
import { SaleInvoiceApplication } from '../SaleInvoices.application';
|
||||||
// import { Exportable } from '@/services/Export/Exportable';
|
import { ISalesInvoicesFilter } from '../SaleInvoice.types';
|
||||||
// import { EXPORT_SIZE_LIMIT } from '@/services/Export/constants';
|
import { EXPORT_SIZE_LIMIT } from '@/modules/Export/constants';
|
||||||
|
import { ExportableService } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||||
|
import { SaleInvoice } from '../models/SaleInvoice';
|
||||||
|
|
||||||
// @Service()
|
@Injectable()
|
||||||
// export class SaleInvoicesExportable extends Exportable {
|
@ExportableService({ name: SaleInvoice.name })
|
||||||
// @Inject()
|
export class SaleInvoicesExportable extends Exportable{
|
||||||
// private saleInvoicesApplication: SaleInvoiceApplication;
|
constructor(
|
||||||
|
private readonly saleInvoicesApplication: SaleInvoiceApplication,
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Retrieves the accounts data to exportable sheet.
|
* Retrieves the accounts data to exportable sheet.
|
||||||
// * @param {number} tenantId
|
*/
|
||||||
// * @returns
|
public exportable(query: ISalesInvoicesFilter) {
|
||||||
// */
|
const filterQuery = (query) => {
|
||||||
// public exportable(tenantId: number, query: ISalesInvoicesFilter) {
|
query.withGraphFetched('branch');
|
||||||
// const filterQuery = (query) => {
|
query.withGraphFetched('warehouse');
|
||||||
// query.withGraphFetched('branch');
|
};
|
||||||
// query.withGraphFetched('warehouse');
|
const parsedQuery = {
|
||||||
// };
|
sortOrder: 'desc',
|
||||||
// const parsedQuery = {
|
columnSortBy: 'created_at',
|
||||||
// sortOrder: 'desc',
|
...query,
|
||||||
// columnSortBy: 'created_at',
|
page: 1,
|
||||||
// ...query,
|
pageSize: EXPORT_SIZE_LIMIT,
|
||||||
// page: 1,
|
filterQuery,
|
||||||
// pageSize: EXPORT_SIZE_LIMIT,
|
} as ISalesInvoicesFilter;
|
||||||
// filterQuery,
|
|
||||||
// } as ISalesInvoicesFilter;
|
|
||||||
|
|
||||||
// return this.saleInvoicesApplication
|
return this.saleInvoicesApplication
|
||||||
// .getSaleInvoices(tenantId, parsedQuery)
|
.getSaleInvoices(parsedQuery)
|
||||||
// .then((output) => output.salesInvoices);
|
.then((output) => output.salesInvoices);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
|||||||
import { PaymentIntegrationTransactionLink } from '../SaleInvoice.types';
|
import { PaymentIntegrationTransactionLink } from '../SaleInvoice.types';
|
||||||
import { TransactionPaymentServiceEntry } from '@/modules/PaymentServices/models/TransactionPaymentServiceEntry.model';
|
import { TransactionPaymentServiceEntry } from '@/modules/PaymentServices/models/TransactionPaymentServiceEntry.model';
|
||||||
import { InjectAttachable } from '@/modules/Attachments/decorators/InjectAttachable.decorator';
|
import { InjectAttachable } from '@/modules/Attachments/decorators/InjectAttachable.decorator';
|
||||||
|
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||||
|
|
||||||
@InjectAttachable()
|
@InjectAttachable()
|
||||||
|
@ExportableModel()
|
||||||
export class SaleInvoice extends TenantBaseModel{
|
export class SaleInvoice extends TenantBaseModel{
|
||||||
public taxAmountWithheld: number;
|
public taxAmountWithheld: number;
|
||||||
public balance: number;
|
public balance: number;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import { MailNotificationModule } from '../MailNotification/MailNotification.mod
|
|||||||
import { SendSaleReceiptMailProcess } from './processes/SendSaleReceiptMail.process';
|
import { SendSaleReceiptMailProcess } from './processes/SendSaleReceiptMail.process';
|
||||||
import { MailModule } from '../Mail/Mail.module';
|
import { MailModule } from '../Mail/Mail.module';
|
||||||
import { SendSaleReceiptMailQueue } from './constants';
|
import { SendSaleReceiptMailQueue } from './constants';
|
||||||
|
import { SaleReceiptsExportable } from './commands/SaleReceiptsExportable';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
controllers: [SaleReceiptsController],
|
controllers: [SaleReceiptsController],
|
||||||
@@ -75,6 +76,7 @@ import { SendSaleReceiptMailQueue } from './constants';
|
|||||||
SaleReceiptInventoryTransactions,
|
SaleReceiptInventoryTransactions,
|
||||||
SaleReceiptInventoryTransactionsSubscriber,
|
SaleReceiptInventoryTransactionsSubscriber,
|
||||||
SendSaleReceiptMailProcess,
|
SendSaleReceiptMailProcess,
|
||||||
|
SaleReceiptsExportable
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class SaleReceiptsModule {}
|
export class SaleReceiptsModule {}
|
||||||
|
|||||||
@@ -1,35 +1,35 @@
|
|||||||
// import { Inject, Service } from 'typedi';
|
import { Exportable } from '@/modules/Export/Exportable';
|
||||||
// import { ISalesReceiptsFilter } from '@/interfaces';
|
import { Injectable } from '@nestjs/common';
|
||||||
// import { Exportable } from '@/services/Export/Exportable';
|
import { SaleReceiptApplication } from '../SaleReceiptApplication.service';
|
||||||
// import { SaleReceiptApplication } from './SaleReceiptApplication';
|
import { ISalesReceiptsFilter } from '../types/SaleReceipts.types';
|
||||||
// import { EXPORT_SIZE_LIMIT } from '@/services/Export/constants';
|
import { EXPORT_SIZE_LIMIT } from '@/modules/Export/constants';
|
||||||
|
|
||||||
// @Service()
|
@Injectable()
|
||||||
// export class SaleReceiptsExportable extends Exportable {
|
export class SaleReceiptsExportable extends Exportable {
|
||||||
// @Inject()
|
constructor(private readonly saleReceiptsApp: SaleReceiptApplication) {
|
||||||
// private saleReceiptsApp: SaleReceiptApplication;
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Retrieves the accounts data to exportable sheet.
|
* Retrieves the accounts data to exportable sheet.
|
||||||
// * @param {number} tenantId
|
* @param {ISalesReceiptsFilter} query -
|
||||||
// * @returns
|
*/
|
||||||
// */
|
public exportable(query: ISalesReceiptsFilter) {
|
||||||
// public exportable(tenantId: number, query: ISalesReceiptsFilter) {
|
const filterQuery = (query) => {
|
||||||
// const filterQuery = (query) => {
|
query.withGraphFetched('branch');
|
||||||
// query.withGraphFetched('branch');
|
query.withGraphFetched('warehouse');
|
||||||
// query.withGraphFetched('warehouse');
|
};
|
||||||
// };
|
const parsedQuery = {
|
||||||
// const parsedQuery = {
|
sortOrder: 'desc',
|
||||||
// sortOrder: 'desc',
|
columnSortBy: 'created_at',
|
||||||
// columnSortBy: 'created_at',
|
...query,
|
||||||
// ...query,
|
page: 1,
|
||||||
// page: 1,
|
pageSize: EXPORT_SIZE_LIMIT,
|
||||||
// pageSize: EXPORT_SIZE_LIMIT,
|
filterQuery,
|
||||||
// filterQuery,
|
} as ISalesReceiptsFilter;
|
||||||
// } as ISalesReceiptsFilter;
|
|
||||||
|
|
||||||
// return this.saleReceiptsApp
|
return this.saleReceiptsApp
|
||||||
// .getSaleReceipts(tenantId, parsedQuery)
|
.getSaleReceipts(parsedQuery)
|
||||||
// .then((output) => output.data);
|
.then((output) => output.data);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { MetadataModelMixin } from '@/modules/DynamicListing/models/MetadataMode
|
|||||||
import { ResourceableModelMixin } from '@/modules/Resource/models/ResourcableModel';
|
import { ResourceableModelMixin } from '@/modules/Resource/models/ResourcableModel';
|
||||||
import { CustomViewBaseModelMixin } from '@/modules/CustomViews/CustomViewBaseModel';
|
import { CustomViewBaseModelMixin } from '@/modules/CustomViews/CustomViewBaseModel';
|
||||||
import { SearchableBaseModelMixin } from '@/modules/DynamicListing/models/SearchableBaseModel';
|
import { SearchableBaseModelMixin } from '@/modules/DynamicListing/models/SearchableBaseModel';
|
||||||
|
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||||
|
|
||||||
const ExtendedModel = R.pipe(
|
const ExtendedModel = R.pipe(
|
||||||
CustomViewBaseModelMixin,
|
CustomViewBaseModelMixin,
|
||||||
@@ -20,6 +21,7 @@ const ExtendedModel = R.pipe(
|
|||||||
MetadataModelMixin,
|
MetadataModelMixin,
|
||||||
)(BaseModel);
|
)(BaseModel);
|
||||||
|
|
||||||
|
@ExportableModel()
|
||||||
export class SaleReceipt extends ExtendedModel {
|
export class SaleReceipt extends ExtendedModel {
|
||||||
public amount!: number;
|
public amount!: number;
|
||||||
public exchangeRate!: number;
|
public exchangeRate!: number;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import { WriteTaxTransactionsItemEntries } from './WriteTaxTransactionsItemEntri
|
|||||||
import { SyncItemTaxRateOnEditTaxRate } from './SyncItemTaxRateOnEditTaxRate';
|
import { SyncItemTaxRateOnEditTaxRate } from './SyncItemTaxRateOnEditTaxRate';
|
||||||
import { RegisterTenancyModel } from '../Tenancy/TenancyModels/Tenancy.module';
|
import { RegisterTenancyModel } from '../Tenancy/TenancyModels/Tenancy.module';
|
||||||
import { TaxRateTransaction } from './models/TaxRateTransaction.model';
|
import { TaxRateTransaction } from './models/TaxRateTransaction.model';
|
||||||
|
import { TaxRatesExportable } from './TaxRatesExportable';
|
||||||
|
|
||||||
const models = [RegisterTenancyModel(TaxRateTransaction)];
|
const models = [RegisterTenancyModel(TaxRateTransaction)];
|
||||||
|
|
||||||
@@ -47,6 +48,7 @@ const models = [RegisterTenancyModel(TaxRateTransaction)];
|
|||||||
SyncItemTaxRateOnEditTaxSubscriber,
|
SyncItemTaxRateOnEditTaxSubscriber,
|
||||||
WriteTaxTransactionsItemEntries,
|
WriteTaxTransactionsItemEntries,
|
||||||
SyncItemTaxRateOnEditTaxRate,
|
SyncItemTaxRateOnEditTaxRate,
|
||||||
|
TaxRatesExportable
|
||||||
],
|
],
|
||||||
exports: [ItemEntriesTaxTransactions, ...models],
|
exports: [ItemEntriesTaxTransactions, ...models],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
// import { Inject, Service } from 'typedi';
|
import { ExportableService } from '../Export/decorators/ExportableModel.decorator';
|
||||||
// import { Exportable } from '../Export/Exportable';
|
import { Exportable } from '../Export/Exportable';
|
||||||
// import { TaxRatesApplication } from './TaxRate.application';
|
import { TaxRateModel } from './models/TaxRate.model';
|
||||||
|
import { TaxRatesApplication } from './TaxRate.application';
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
// @Service()
|
@Injectable()
|
||||||
// export class TaxRatesExportable extends Exportable {
|
@ExportableService({ name: TaxRateModel.name })
|
||||||
// @Inject()
|
export class TaxRatesExportable extends Exportable {
|
||||||
// private taxRatesApplication: TaxRatesApplication;
|
constructor(private readonly taxRatesApplication: TaxRatesApplication) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Retrieves the accounts data to exportable sheet.
|
* Retrieves the accounts data to exportable sheet.
|
||||||
// * @param {number} tenantId
|
*/
|
||||||
// * @returns
|
public exportable() {
|
||||||
// */
|
return this.taxRatesApplication.getTaxRates();
|
||||||
// public exportable(tenantId: number) {
|
}
|
||||||
// return this.taxRatesApplication.getTaxRates(tenantId);
|
}
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import { mixin, Model, raw } from 'objection';
|
|||||||
// import TaxRateMeta from './TaxRate.settings';
|
// import TaxRateMeta from './TaxRate.settings';
|
||||||
// import ModelSetting from './ModelSetting';
|
// import ModelSetting from './ModelSetting';
|
||||||
import { BaseModel } from '@/models/Model';
|
import { BaseModel } from '@/models/Model';
|
||||||
|
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||||
|
|
||||||
|
@ExportableModel()
|
||||||
export class TaxRateModel extends BaseModel {
|
export class TaxRateModel extends BaseModel {
|
||||||
active!: boolean;
|
active!: boolean;
|
||||||
code!: string;
|
code!: string;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import { VendorCreditInventoryTransactions } from './commands/VendorCreditInvent
|
|||||||
import { GetVendorCreditsService } from './queries/GetVendorCredits.service';
|
import { GetVendorCreditsService } from './queries/GetVendorCredits.service';
|
||||||
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
||||||
import { InventoryCostModule } from '../InventoryCost/InventoryCost.module';
|
import { InventoryCostModule } from '../InventoryCost/InventoryCost.module';
|
||||||
|
import { VendorCreditsExportable } from './commands/VendorCreditsExportable';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -54,7 +55,8 @@ import { InventoryCostModule } from '../InventoryCost/InventoryCost.module';
|
|||||||
VendorCreditGLEntries,
|
VendorCreditGLEntries,
|
||||||
VendorCreditGlEntriesSubscriber,
|
VendorCreditGlEntriesSubscriber,
|
||||||
VendorCreditInventoryTransactions,
|
VendorCreditInventoryTransactions,
|
||||||
VendorCreditInventoryTransactionsSubscriber
|
VendorCreditInventoryTransactionsSubscriber,
|
||||||
|
VendorCreditsExportable
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
CreateVendorCreditService,
|
CreateVendorCreditService,
|
||||||
|
|||||||
@@ -1,36 +1,38 @@
|
|||||||
// import { Inject, Service } from 'typedi';
|
import { Injectable } from '@nestjs/common';
|
||||||
// import { IVendorCreditsQueryDTO } from '@/interfaces';
|
import { VendorCreditsApplicationService } from '../VendorCreditsApplication.service';
|
||||||
// import ListVendorCredits from '../queries/ListVendorCredits';
|
import { Exportable } from '@/modules/Export/Exportable';
|
||||||
// import { Exportable } from '@/services/Export/Exportable';
|
import { IVendorCreditsQueryDTO } from '../types/VendorCredit.types';
|
||||||
// import { QueryBuilder } from 'knex';
|
import { ExportableService } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||||
|
import { VendorCredit } from '../models/VendorCredit';
|
||||||
|
|
||||||
// @Service()
|
@Injectable()
|
||||||
// export class VendorCreditsExportable extends Exportable {
|
@ExportableService({ name: VendorCredit.name })
|
||||||
// @Inject()
|
export class VendorCreditsExportable extends Exportable {
|
||||||
// private getVendorCredits: ListVendorCredits;
|
constructor(
|
||||||
|
private readonly vendorCreditsApp: VendorCreditsApplicationService,
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Retrieves the vendor credits data to exportable sheet.
|
* Retrieves the vendor credits data to exportable sheet.
|
||||||
// * @param {number} tenantId -
|
*/
|
||||||
// * @param {IVendorCreditsQueryDTO} query -
|
public exportable(query: IVendorCreditsQueryDTO) {
|
||||||
// * @returns {}
|
const filterQuery = (query) => {
|
||||||
// */
|
query.withGraphFetched('branch');
|
||||||
// public exportable(tenantId: number, query: IVendorCreditsQueryDTO) {
|
query.withGraphFetched('warehouse');
|
||||||
// const filterQuery = (query) => {
|
};
|
||||||
// query.withGraphFetched('branch');
|
const parsedQuery = {
|
||||||
// query.withGraphFetched('warehouse');
|
sortOrder: 'desc',
|
||||||
// };
|
columnSortBy: 'created_at',
|
||||||
// const parsedQuery = {
|
...query,
|
||||||
// sortOrder: 'desc',
|
page: 1,
|
||||||
// columnSortBy: 'created_at',
|
pageSize: 12000,
|
||||||
// ...query,
|
filterQuery,
|
||||||
// page: 1,
|
} as IVendorCreditsQueryDTO;
|
||||||
// pageSize: 12000,
|
|
||||||
// filterQuery,
|
|
||||||
// } as IVendorCreditsQueryDTO;
|
|
||||||
|
|
||||||
// return this.getVendorCredits
|
return this.vendorCreditsApp
|
||||||
// .getVendorCredits(tenantId, parsedQuery)
|
.getVendorCredits(parsedQuery)
|
||||||
// .then((output) => output.vendorCredits);
|
.then((output) => output.vendorCredits);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import { Branch } from '@/modules/Branches/models/Branch.model';
|
|||||||
import { ItemEntry } from '@/modules/TransactionItemEntry/models/ItemEntry';
|
import { ItemEntry } from '@/modules/TransactionItemEntry/models/ItemEntry';
|
||||||
import { DiscountType } from '@/common/types/Discount';
|
import { DiscountType } from '@/common/types/Discount';
|
||||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||||
|
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||||
|
|
||||||
|
@ExportableModel()
|
||||||
export class VendorCredit extends TenantBaseModel {
|
export class VendorCredit extends TenantBaseModel {
|
||||||
vendorId: number;
|
vendorId: number;
|
||||||
amount: number;
|
amount: number;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { TenancyContext } from '../Tenancy/TenancyContext.service';
|
|||||||
import { VendorsController } from './Vendors.controller';
|
import { VendorsController } from './Vendors.controller';
|
||||||
import { GetVendorsService } from './queries/GetVendors.service';
|
import { GetVendorsService } from './queries/GetVendors.service';
|
||||||
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
||||||
|
import { VendorsExportable } from './VendorsExportable';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [TenancyDatabaseModule, DynamicListModule],
|
imports: [TenancyDatabaseModule, DynamicListModule],
|
||||||
@@ -31,6 +32,7 @@ import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
|||||||
VendorsApplication,
|
VendorsApplication,
|
||||||
TransformerInjectable,
|
TransformerInjectable,
|
||||||
TenancyContext,
|
TenancyContext,
|
||||||
|
VendorsExportable
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class VendorsModule {}
|
export class VendorsModule {}
|
||||||
|
|||||||
@@ -1,30 +1,34 @@
|
|||||||
// import { Inject, Service } from 'typedi';
|
import { Injectable } from '@nestjs/common';
|
||||||
// import { IItemsFilter } from '@/interfaces';
|
import { VendorsApplication } from './VendorsApplication.service';
|
||||||
// import { Exportable } from '@/services/Export/Exportable';
|
import { Exportable } from '../Export/Exportable';
|
||||||
// import { VendorsApplication } from './VendorsApplication';
|
import { IVendorsFilter } from './types/Vendors.types';
|
||||||
// import { EXPORT_SIZE_LIMIT } from '@/services/Export/constants';
|
import { EXPORT_SIZE_LIMIT } from '../Export/constants';
|
||||||
|
import { ExportableService } from '../Export/decorators/ExportableModel.decorator';
|
||||||
|
import { Vendor } from './models/Vendor';
|
||||||
|
|
||||||
// @Service()
|
@Injectable()
|
||||||
// export class VendorsExportable extends Exportable {
|
@ExportableService({ name: Vendor.name })
|
||||||
// @Inject()
|
export class VendorsExportable extends Exportable {
|
||||||
// private vendorsApplication: VendorsApplication;
|
constructor(
|
||||||
|
private readonly vendorsApplication: VendorsApplication,
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Retrieves the accounts data to exportable sheet.
|
* Retrieves the vendors data to exportable sheet.
|
||||||
// * @param {number} tenantId
|
*/
|
||||||
// * @returns
|
public exportable(query: IVendorsFilter) {
|
||||||
// */
|
const parsedQuery = {
|
||||||
// public exportable(tenantId: number, query: IItemsFilter) {
|
sortOrder: 'DESC',
|
||||||
// const parsedQuery = {
|
columnSortBy: 'created_at',
|
||||||
// sortOrder: 'DESC',
|
...query,
|
||||||
// columnSortBy: 'created_at',
|
page: 1,
|
||||||
// ...query,
|
pageSize: EXPORT_SIZE_LIMIT,
|
||||||
// page: 1,
|
} as IVendorsFilter;
|
||||||
// pageSize: EXPORT_SIZE_LIMIT,
|
|
||||||
// } as IItemsFilter;
|
|
||||||
|
|
||||||
// return this.vendorsApplication
|
return this.vendorsApplication
|
||||||
// .getVendors(tenantId, parsedQuery)
|
.getVendors(parsedQuery)
|
||||||
// .then((output) => output.vendors);
|
.then((output) => output.vendors);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { Model, mixin } from 'objection';
|
|||||||
// import ModelSearchable from './ModelSearchable';
|
// import ModelSearchable from './ModelSearchable';
|
||||||
import { BaseModel } from '@/models/Model';
|
import { BaseModel } from '@/models/Model';
|
||||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||||
|
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||||
|
|
||||||
// class VendorQueryBuilder extends PaginationQueryBuilder {
|
// class VendorQueryBuilder extends PaginationQueryBuilder {
|
||||||
// constructor(...args) {
|
// constructor(...args) {
|
||||||
@@ -21,6 +22,7 @@ import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@ExportableModel()
|
||||||
export class Vendor extends TenantBaseModel {
|
export class Vendor extends TenantBaseModel {
|
||||||
contactService: string;
|
contactService: string;
|
||||||
contactType: string;
|
contactType: string;
|
||||||
|
|||||||
131
packages/server/src/utils/multi-number-parse.ts
Normal file
131
packages/server/src/utils/multi-number-parse.ts
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
// @ts-nocheck
|
||||||
|
const validGrouping = (integerPart, sep) =>
|
||||||
|
integerPart.split(sep).reduce((acc, group, idx) => {
|
||||||
|
if (idx > 0) {
|
||||||
|
return acc && group.length === 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc && group.length;
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
export const multiNumberParse = (number: number | string, standardDecSep = '.') => {
|
||||||
|
// if it's a number already, this is going to be easy...
|
||||||
|
if (typeof number === 'number') {
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check validity of parameters
|
||||||
|
if (!number || typeof number !== 'string') {
|
||||||
|
throw new TypeError('number must be a string');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof standardDecSep !== 'string' || standardDecSep.length !== 1) {
|
||||||
|
throw new TypeError('standardDecSep must be a single character string');
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if negative
|
||||||
|
const negative = number[0] === '-';
|
||||||
|
|
||||||
|
// strip unnecessary chars
|
||||||
|
const stripped = number
|
||||||
|
// get rid of trailing non-numbers
|
||||||
|
.replace(/[^\d]+$/, '')
|
||||||
|
// get rid of the signal
|
||||||
|
.slice(negative ? 1 : 0);
|
||||||
|
|
||||||
|
// analyze separators
|
||||||
|
const separators = (stripped.match(/[^\d]/g) || []).reduce(
|
||||||
|
(acc, sep, idx) => {
|
||||||
|
const sepChr = `str_${sep.codePointAt(0)}`;
|
||||||
|
const cnt = ((acc[sepChr] || {}).cnt || 0) + 1;
|
||||||
|
|
||||||
|
return {
|
||||||
|
...acc,
|
||||||
|
[sepChr]: {
|
||||||
|
sep,
|
||||||
|
cnt,
|
||||||
|
lastIdx: idx,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
|
||||||
|
// check correctness of separators
|
||||||
|
const sepKeys = Object.keys(separators);
|
||||||
|
|
||||||
|
if (!sepKeys.length) {
|
||||||
|
// no separator, that's easy-peasy
|
||||||
|
return parseInt(stripped, 10) * (negative ? -1 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sepKeys.length > 2) {
|
||||||
|
// there's more than 2 separators, that's wrong
|
||||||
|
return Number.NaN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sepKeys.length > 1) {
|
||||||
|
// there's two separators, that's ok by now
|
||||||
|
let sep1 = separators[sepKeys[0]];
|
||||||
|
let sep2 = separators[sepKeys[1]];
|
||||||
|
|
||||||
|
if (sep1.lastIdx > sep2.lastIdx) {
|
||||||
|
// swap
|
||||||
|
[sep1, sep2] = [sep2, sep1];
|
||||||
|
}
|
||||||
|
|
||||||
|
// if more than one separator appears more than once, that's wrong
|
||||||
|
if (sep1.cnt > 1 && sep2.cnt > 1) {
|
||||||
|
return Number.NaN;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if the last separator is the single one
|
||||||
|
if (sep2.cnt > 1) {
|
||||||
|
return Number.NaN;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check the groupings
|
||||||
|
const [integerPart] = stripped.split(sep2.sep);
|
||||||
|
|
||||||
|
if (!validGrouping(integerPart, sep1.sep)) {
|
||||||
|
return Number.NaN;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ok, we got here! let's handle it
|
||||||
|
return (
|
||||||
|
parseFloat(stripped.split(sep1.sep).join('').replace(sep2.sep, '.')) *
|
||||||
|
(negative ? -1 : 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ok, only one separator, which is nice
|
||||||
|
const sep = separators[sepKeys[0]];
|
||||||
|
|
||||||
|
if (sep.cnt > 1) {
|
||||||
|
// there's more than one separator, which means it's integer
|
||||||
|
// let's check the groupings
|
||||||
|
if (!validGrouping(stripped, sep.sep)) {
|
||||||
|
return Number.NaN;
|
||||||
|
}
|
||||||
|
|
||||||
|
// it's valid, let's return an integer
|
||||||
|
return parseInt(stripped.split(sep.sep).join(''), 10) * (negative ? -1 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// just one separator, let's check last group
|
||||||
|
const groups = stripped.split(sep.sep);
|
||||||
|
|
||||||
|
if (groups[groups.length - 1].length === 3) {
|
||||||
|
// ok, we're in ambiguous territory here
|
||||||
|
|
||||||
|
if (sep.sep !== standardDecSep) {
|
||||||
|
// it's an integer
|
||||||
|
return (
|
||||||
|
parseInt(stripped.split(sep.sep).join(''), 10) * (negative ? -1 : 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// well, it looks like it's a simple float
|
||||||
|
return parseFloat(stripped.replace(sep.sep, '.')) * (negative ? -1 : 1);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user