-
-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: export purchases by items to csv/xlsx (#327)
- Loading branch information
Showing
17 changed files
with
672 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { INumberFormatQuery } from './FinancialStatements'; | ||
import { IFinancialTable } from './Table'; | ||
|
||
export interface IPurchasesByItemsReportQuery { | ||
fromDate: Date | string; | ||
toDate: Date | string; | ||
itemsIds: number[]; | ||
numberFormat: INumberFormatQuery; | ||
noneTransactions: boolean; | ||
onlyActive: boolean; | ||
} | ||
|
||
export interface IPurchasesByItemsSheetMeta { | ||
organizationName: string; | ||
baseCurrency: string; | ||
} | ||
|
||
export interface IPurchasesByItemsItem { | ||
id: number; | ||
name: string; | ||
code: string; | ||
quantitySold: number; | ||
soldCost: number; | ||
averageSellPrice: number; | ||
|
||
quantitySoldFormatted: string; | ||
soldCostFormatted: string; | ||
averageSellPriceFormatted: string; | ||
currencyCode: string; | ||
} | ||
|
||
export interface IPurchasesByItemsTotal { | ||
quantitySold: number; | ||
soldCost: number; | ||
quantitySoldFormatted: string; | ||
soldCostFormatted: string; | ||
currencyCode: string; | ||
} | ||
|
||
export type IPurchasesByItemsSheetData = { | ||
items: IPurchasesByItemsItem[]; | ||
total: IPurchasesByItemsTotal; | ||
}; | ||
|
||
export interface IPurchasesByItemsSheet { | ||
data: IPurchasesByItemsSheetData; | ||
query: IPurchasesByItemsReportQuery; | ||
meta: IPurchasesByItemsSheetMeta; | ||
} | ||
|
||
export interface IPurchasesByItemsTable extends IFinancialTable { | ||
query: IPurchasesByItemsReportQuery; | ||
meta: IPurchasesByItemsSheetMeta; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...s/server/src/services/FinancialStatements/PurchasesByItems/PurchasesByItemsApplication.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { Service, Inject } from 'typedi'; | ||
import { PurchasesByItemsExport } from './PurchasesByItemsExport'; | ||
import { | ||
IPurchasesByItemsReportQuery, | ||
IPurchasesByItemsSheet, | ||
IPurchasesByItemsTable, | ||
} from '@/interfaces/PurchasesByItemsSheet'; | ||
import { PurchasesByItemsTableInjectable } from './PurchasesByItemsTableInjectable'; | ||
import { PurchasesByItemsService } from './PurchasesByItemsService'; | ||
|
||
@Service() | ||
export class PurcahsesByItemsApplication { | ||
@Inject() | ||
private purchasesByItemsSheet: PurchasesByItemsService; | ||
|
||
@Inject() | ||
private purchasesByItemsTable: PurchasesByItemsTableInjectable; | ||
|
||
@Inject() | ||
private purchasesByItemsExport: PurchasesByItemsExport; | ||
|
||
/** | ||
* Retrieves the purchases by items in json format. | ||
* @param {number} tenantId | ||
* @param {IPurchasesByItemsReportQuery} query | ||
* @returns | ||
*/ | ||
public sheet( | ||
tenantId: number, | ||
query: IPurchasesByItemsReportQuery | ||
): Promise<IPurchasesByItemsSheet> { | ||
return this.purchasesByItemsSheet.purchasesByItems(tenantId, query); | ||
} | ||
|
||
/** | ||
* Retrieves the purchases by items in table format. | ||
* @param {number} tenantId | ||
* @param {IPurchasesByItemsReportQuery} query | ||
* @returns {Promise<IPurchasesByItemsTable>} | ||
*/ | ||
public table( | ||
tenantId: number, | ||
query: IPurchasesByItemsReportQuery | ||
): Promise<IPurchasesByItemsTable> { | ||
return this.purchasesByItemsTable.table(tenantId, query); | ||
} | ||
|
||
/** | ||
* Retrieves the purchases by items in csv format. | ||
* @param {number} tenantId | ||
* @param {IPurchasesByItemsReportQuery} query | ||
* @returns {Promise<string>} | ||
*/ | ||
public csv( | ||
tenantId: number, | ||
query: IPurchasesByItemsReportQuery | ||
): Promise<string> { | ||
return this.purchasesByItemsExport.csv(tenantId, query); | ||
} | ||
|
||
/** | ||
* Retrieves the purchases by items in xlsx format. | ||
* @param {number} tenantId | ||
* @param {IPurchasesByItemsReportQuery} query | ||
* @returns {Promise<Buffer>} | ||
*/ | ||
public xlsx( | ||
tenantId: number, | ||
query: IPurchasesByItemsReportQuery | ||
): Promise<Buffer> { | ||
return this.purchasesByItemsExport.xlsx(tenantId, query); | ||
} | ||
} |
Oops, something went wrong.