mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-23 16:19:49 +00:00
fox: journal sheet
This commit is contained in:
@@ -20,5 +20,6 @@
|
|||||||
"vendor_credit": "Vendor Credit",
|
"vendor_credit": "Vendor Credit",
|
||||||
"refund_credit_note": "Refund Credit Note",
|
"refund_credit_note": "Refund Credit Note",
|
||||||
"refund_vendor_credit": "Refund Vendor Credit",
|
"refund_vendor_credit": "Refund Vendor Credit",
|
||||||
"landed_cost": "Landed Cost"
|
"landed_cost": "Landed Cost",
|
||||||
|
"payment_made": "Payment made"
|
||||||
}
|
}
|
||||||
@@ -9,14 +9,19 @@ import {
|
|||||||
ApiTags,
|
ApiTags,
|
||||||
} from '@nestjs/swagger';
|
} from '@nestjs/swagger';
|
||||||
import { JournalSheetQueryDto } from './JournalSheetQuery.dto';
|
import { JournalSheetQueryDto } from './JournalSheetQuery.dto';
|
||||||
|
import { JournalSheetResponseExample } from './JournalSheet.swagger';
|
||||||
|
|
||||||
@Controller('/reports/journal')
|
@Controller('/reports/journal')
|
||||||
@ApiTags('Reports')
|
@ApiTags('Reports')
|
||||||
export class JournalSheetController {
|
export class JournalSheetController {
|
||||||
constructor(private readonly journalSheetApp: JournalSheetApplication) {}
|
constructor(private readonly journalSheetApp: JournalSheetApplication) {}
|
||||||
|
|
||||||
@Get('/')
|
@Get()
|
||||||
@ApiResponse({ status: 200, description: 'Journal report' })
|
@ApiResponse({
|
||||||
|
status: 200,
|
||||||
|
description: 'Journal report',
|
||||||
|
example: JournalSheetResponseExample,
|
||||||
|
})
|
||||||
@ApiOperation({ summary: 'Journal report' })
|
@ApiOperation({ summary: 'Journal report' })
|
||||||
@ApiProduces(
|
@ApiProduces(
|
||||||
AcceptType.ApplicationJson,
|
AcceptType.ApplicationJson,
|
||||||
|
|||||||
@@ -0,0 +1,280 @@
|
|||||||
|
export const JournalSheetResponseExample = {
|
||||||
|
query: {
|
||||||
|
from_date: '2025-06-01',
|
||||||
|
to_date: '2025-06-21',
|
||||||
|
from_range: null,
|
||||||
|
to_range: null,
|
||||||
|
accounts_ids: [],
|
||||||
|
number_format: {
|
||||||
|
no_cents: false,
|
||||||
|
divide_on1000: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
date: '2025-05-24T22:00:00.000Z',
|
||||||
|
date_formatted: '2025 May 25',
|
||||||
|
transaction_type: 'Expense',
|
||||||
|
reference_id: 1000,
|
||||||
|
reference_type_formatted: 'Expense',
|
||||||
|
entries: [
|
||||||
|
{
|
||||||
|
index: 1,
|
||||||
|
note: null,
|
||||||
|
account_name: 'Prepaid Expenses',
|
||||||
|
account_code: '100010',
|
||||||
|
transaction_number: null,
|
||||||
|
formatted_credit: '123,123.00',
|
||||||
|
formatted_debit: '',
|
||||||
|
credit: 123123,
|
||||||
|
debit: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
index: 2,
|
||||||
|
note: '',
|
||||||
|
account_name: 'Exchange Gain or Loss',
|
||||||
|
account_code: '40005',
|
||||||
|
transaction_number: null,
|
||||||
|
formatted_credit: '',
|
||||||
|
formatted_debit: '123,123.00',
|
||||||
|
credit: 0,
|
||||||
|
debit: 123123,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
credit: 123123,
|
||||||
|
debit: 123123,
|
||||||
|
formatted_credit: '$123,123.00',
|
||||||
|
formatted_debit: '$123,123.00',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2025-06-09T22:00:00.000Z',
|
||||||
|
date_formatted: '2025 Jun 10',
|
||||||
|
transaction_type: 'BillPayment',
|
||||||
|
reference_id: 3,
|
||||||
|
reference_type_formatted: 'BillPayment',
|
||||||
|
entries: [
|
||||||
|
{
|
||||||
|
index: 1,
|
||||||
|
note: null,
|
||||||
|
contact_name: 'business',
|
||||||
|
contact_type: 'customer',
|
||||||
|
account_name: 'Accounts Payable (A/P)',
|
||||||
|
account_code: '20001',
|
||||||
|
transaction_number: '',
|
||||||
|
formatted_credit: '',
|
||||||
|
formatted_debit: '500.00',
|
||||||
|
credit: 0,
|
||||||
|
debit: 500,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
index: 2,
|
||||||
|
note: null,
|
||||||
|
account_name: 'Bank Account',
|
||||||
|
account_code: '10001',
|
||||||
|
transaction_number: '',
|
||||||
|
formatted_credit: '500.00',
|
||||||
|
formatted_debit: '',
|
||||||
|
credit: 500,
|
||||||
|
debit: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
credit: 500,
|
||||||
|
debit: 500,
|
||||||
|
formatted_credit: '$500.00',
|
||||||
|
formatted_debit: '$500.00',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2025-06-09T22:00:00.000Z',
|
||||||
|
date_formatted: '2025 Jun 10',
|
||||||
|
transaction_type: 'VendorCredit',
|
||||||
|
reference_id: 3,
|
||||||
|
reference_type_formatted: 'VendorCredit',
|
||||||
|
entries: [
|
||||||
|
{
|
||||||
|
index: 1,
|
||||||
|
note: null,
|
||||||
|
contact_name: 'business',
|
||||||
|
contact_type: 'customer',
|
||||||
|
account_name: 'Accounts Payable (A/P)',
|
||||||
|
account_code: '20001',
|
||||||
|
transaction_number: 'VC-00001',
|
||||||
|
formatted_credit: '',
|
||||||
|
formatted_debit: '100.00',
|
||||||
|
credit: 0,
|
||||||
|
debit: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
index: 2,
|
||||||
|
note: null,
|
||||||
|
account_name: 'Cost of Goods Sold',
|
||||||
|
account_code: '40002',
|
||||||
|
transaction_number: 'VC-00001',
|
||||||
|
formatted_credit: '100.00',
|
||||||
|
formatted_debit: '',
|
||||||
|
credit: 100,
|
||||||
|
debit: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
credit: 100,
|
||||||
|
debit: 100,
|
||||||
|
formatted_credit: '$100.00',
|
||||||
|
formatted_debit: '$100.00',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2025-06-09T22:00:00.000Z',
|
||||||
|
date_formatted: '2025 Jun 10',
|
||||||
|
transaction_type: 'VendorCredit',
|
||||||
|
reference_id: 4,
|
||||||
|
reference_type_formatted: 'VendorCredit',
|
||||||
|
entries: [
|
||||||
|
{
|
||||||
|
index: 1,
|
||||||
|
note: null,
|
||||||
|
contact_name: 'business',
|
||||||
|
contact_type: 'customer',
|
||||||
|
account_name: 'Accounts Payable (A/P)',
|
||||||
|
account_code: '20001',
|
||||||
|
transaction_number: 'VC-00001',
|
||||||
|
formatted_credit: '',
|
||||||
|
formatted_debit: '100.00',
|
||||||
|
credit: 0,
|
||||||
|
debit: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
index: 2,
|
||||||
|
note: null,
|
||||||
|
account_name: 'Cost of Goods Sold',
|
||||||
|
account_code: '40002',
|
||||||
|
transaction_number: 'VC-00001',
|
||||||
|
formatted_credit: '100.00',
|
||||||
|
formatted_debit: '',
|
||||||
|
credit: 100,
|
||||||
|
debit: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
credit: 100,
|
||||||
|
debit: 100,
|
||||||
|
formatted_credit: '$100.00',
|
||||||
|
formatted_debit: '$100.00',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2025-06-09T22:00:00.000Z',
|
||||||
|
date_formatted: '2025 Jun 10',
|
||||||
|
transaction_type: 'Bill',
|
||||||
|
reference_id: 4,
|
||||||
|
reference_type_formatted: 'Bill',
|
||||||
|
entries: [
|
||||||
|
{
|
||||||
|
index: 1,
|
||||||
|
note: null,
|
||||||
|
contact_name: 'business',
|
||||||
|
contact_type: 'customer',
|
||||||
|
account_name: 'Accounts Payable (A/P)',
|
||||||
|
account_code: '20001',
|
||||||
|
transaction_number: null,
|
||||||
|
formatted_credit: '1,000.00',
|
||||||
|
formatted_debit: '',
|
||||||
|
credit: 1000,
|
||||||
|
debit: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
index: 1,
|
||||||
|
note: null,
|
||||||
|
account_name: 'Cost of Goods Sold',
|
||||||
|
account_code: '40002',
|
||||||
|
transaction_number: null,
|
||||||
|
formatted_credit: '',
|
||||||
|
formatted_debit: '1,000.00',
|
||||||
|
credit: 0,
|
||||||
|
debit: 1000,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
credit: 1000,
|
||||||
|
debit: 1000,
|
||||||
|
formatted_credit: '$1,000.00',
|
||||||
|
formatted_debit: '$1,000.00',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2025-06-09T22:00:00.000Z',
|
||||||
|
date_formatted: '2025 Jun 10',
|
||||||
|
transaction_type: 'Bill',
|
||||||
|
reference_id: 5,
|
||||||
|
reference_type_formatted: 'Bill',
|
||||||
|
entries: [
|
||||||
|
{
|
||||||
|
index: 1,
|
||||||
|
note: null,
|
||||||
|
contact_name: 'business',
|
||||||
|
contact_type: 'customer',
|
||||||
|
account_name: 'Accounts Payable (A/P)',
|
||||||
|
account_code: '20001',
|
||||||
|
transaction_number: null,
|
||||||
|
formatted_credit: '1,000.00',
|
||||||
|
formatted_debit: '',
|
||||||
|
credit: 1000,
|
||||||
|
debit: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
index: 1,
|
||||||
|
note: null,
|
||||||
|
account_name: 'Inventory Asset',
|
||||||
|
account_code: '10008',
|
||||||
|
transaction_number: null,
|
||||||
|
formatted_credit: '',
|
||||||
|
formatted_debit: '1,000.00',
|
||||||
|
credit: 0,
|
||||||
|
debit: 1000,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
credit: 1000,
|
||||||
|
debit: 1000,
|
||||||
|
formatted_credit: '$1,000.00',
|
||||||
|
formatted_debit: '$1,000.00',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date: '2025-06-15T22:00:00.000Z',
|
||||||
|
date_formatted: '2025 Jun 16',
|
||||||
|
transaction_type: 'Journal',
|
||||||
|
reference_id: 1017,
|
||||||
|
reference_type_formatted: 'Journal',
|
||||||
|
entries: [
|
||||||
|
{
|
||||||
|
index: 1,
|
||||||
|
note: '',
|
||||||
|
account_name: 'Loan',
|
||||||
|
account_code: '20003',
|
||||||
|
transaction_number: 'REF',
|
||||||
|
formatted_credit: '',
|
||||||
|
formatted_debit: '10,000.00',
|
||||||
|
credit: 0,
|
||||||
|
debit: 10000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
index: 2,
|
||||||
|
note: '',
|
||||||
|
account_name: 'Depreciation Expense',
|
||||||
|
account_code: '40007',
|
||||||
|
transaction_number: 'REF',
|
||||||
|
formatted_credit: '10,000.00',
|
||||||
|
formatted_debit: '',
|
||||||
|
credit: 10000,
|
||||||
|
debit: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
credit: 10000,
|
||||||
|
debit: 10000,
|
||||||
|
formatted_credit: '$10,000.00',
|
||||||
|
formatted_debit: '$10,000.00',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
organization_name: 'BIGCAPITAL, INC',
|
||||||
|
base_currency: 'USD',
|
||||||
|
date_format: 'DD MMM yyyy',
|
||||||
|
is_cost_compute_running: false,
|
||||||
|
sheet_name: '',
|
||||||
|
formatted_date_range: 'From 2025/06/01 | To 2025/06/21',
|
||||||
|
formatted_from_date: '2025/06/01',
|
||||||
|
formatted_to_date: '2025/06/21',
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -118,7 +118,7 @@ export class JournalSheet extends FinancialSheet {
|
|||||||
*/
|
*/
|
||||||
entriesWalker(entries: ILedgerEntry[]): IJournalReportEntriesGroup[] {
|
entriesWalker(entries: ILedgerEntry[]): IJournalReportEntriesGroup[] {
|
||||||
return chain(entries)
|
return chain(entries)
|
||||||
.groupBy((entry) => `${entry.referenceId}-${entry.referenceType}`)
|
.groupBy((entry) => `${entry.transactionId}-${entry.transactionType}`)
|
||||||
.map((entriesGroup: ILedgerEntry[], key: string) => {
|
.map((entriesGroup: ILedgerEntry[], key: string) => {
|
||||||
const headEntry = head(entriesGroup);
|
const headEntry = head(entriesGroup);
|
||||||
return this.entriesGroupsMapper(entriesGroup, headEntry);
|
return this.entriesGroupsMapper(entriesGroup, headEntry);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export class JournalSheetService {
|
|||||||
private readonly journalSheetMeta: JournalSheetMeta,
|
private readonly journalSheetMeta: JournalSheetMeta,
|
||||||
private readonly journalRepository: JournalSheetRepository,
|
private readonly journalRepository: JournalSheetRepository,
|
||||||
private readonly eventPublisher: EventEmitter2,
|
private readonly eventPublisher: EventEmitter2,
|
||||||
private readonly i18n: I18nService
|
private readonly i18n: I18nService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user