mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-12 02:40:31 +00:00
Compare commits
25 Commits
feature/20
...
bugs-bashi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d42a1c67a | ||
|
|
339289be9f | ||
|
|
350d229e98 | ||
|
|
8152a16fd5 | ||
|
|
00aad6e35c | ||
|
|
30d8fdb4c0 | ||
|
|
872fc661ce | ||
|
|
054cd1fae4 | ||
|
|
7cb169bce9 | ||
|
|
f2663c4af3 | ||
|
|
6fea7779da | ||
|
|
c00af18327 | ||
|
|
37f0f4e227 | ||
|
|
8662c5899e | ||
|
|
a9a7cd8617 | ||
|
|
e50fc3b523 | ||
|
|
b294a72a26 | ||
|
|
62ae49941b | ||
|
|
31f5cbf335 | ||
|
|
b22328cff9 | ||
|
|
58f609353c | ||
|
|
8a2a8eed3b | ||
|
|
636d206b0e | ||
|
|
63922c391a | ||
|
|
6ecfe1ff12 |
@@ -167,6 +167,9 @@
|
||||
"**/*.(t|j)s"
|
||||
],
|
||||
"coverageDirectory": "../coverage",
|
||||
"testEnvironment": "node"
|
||||
"testEnvironment": "node",
|
||||
"moduleNameMapper": {
|
||||
"^@/(.*)$": "<rootDir>/$1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,27 @@
|
||||
// import { getTransactionsLockingSettingsSchema } from '@/api/controllers/TransactionsLocking/utils';
|
||||
import { chain, mapKeys } from 'lodash';
|
||||
|
||||
const getTransactionsLockingSettingsSchema = (modules: string[]) => {
|
||||
const moduleSchema = {
|
||||
active: { type: 'boolean' },
|
||||
lock_to_date: { type: 'date' },
|
||||
unlock_from_date: { type: 'date' },
|
||||
unlock_to_date: { type: 'date' },
|
||||
lock_reason: { type: 'string' },
|
||||
unlock_reason: { type: 'string' },
|
||||
};
|
||||
return chain(modules)
|
||||
.map((module: string) => {
|
||||
return mapKeys(moduleSchema, (value, key: string) => `${module}.${key}`);
|
||||
})
|
||||
.flattenDeep()
|
||||
.reduce((result, value) => {
|
||||
return {
|
||||
...result,
|
||||
...value,
|
||||
};
|
||||
}, {})
|
||||
.value();
|
||||
};
|
||||
|
||||
export const SettingsOptions = {
|
||||
organization: {
|
||||
@@ -223,12 +246,12 @@ export const SettingsOptions = {
|
||||
'locking-type': {
|
||||
type: 'string',
|
||||
},
|
||||
// ...getTransactionsLockingSettingsSchema([
|
||||
// 'all',
|
||||
// 'sales',
|
||||
// 'purchases',
|
||||
// 'financial',
|
||||
// ]),
|
||||
...getTransactionsLockingSettingsSchema([
|
||||
'all',
|
||||
'sales',
|
||||
'purchases',
|
||||
'financial',
|
||||
]),
|
||||
},
|
||||
features: {
|
||||
'multi-warehouses': {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"field.description": "Description",
|
||||
"field.slug": "Account slug",
|
||||
"field.code": "Account code",
|
||||
"field.code_hint": "Unique number to identify the account.",
|
||||
"field.root_type": "Root type",
|
||||
"field.normal": "Account normal",
|
||||
"field.normal.credit": "Credit",
|
||||
@@ -13,5 +14,6 @@
|
||||
"field.balance": "Balance",
|
||||
"field.bank_balance": "Bank Balance",
|
||||
"field.parent_account": "Parent Account",
|
||||
"field.created_at": "Created at"
|
||||
"field.created_at": "Created at",
|
||||
"field.account_hint": "Matches the account name or code."
|
||||
}
|
||||
|
||||
27
packages/server/src/i18n/en/bill.json
Normal file
27
packages/server/src/i18n/en/bill.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"field.vendor": "Vendor",
|
||||
"field.bill_number": "Bill No.",
|
||||
"field.bill_date": "Date",
|
||||
"field.due_date": "Due Date",
|
||||
"field.reference_no": "Reference No.",
|
||||
"field.exchange_rate": "Exchange Rate",
|
||||
"field.note": "Note",
|
||||
"field.open": "Open",
|
||||
"field.entries": "Entries",
|
||||
"field.item": "Item",
|
||||
"field.item_hint": "Matches the item name or code.",
|
||||
"field.rate": "Rate",
|
||||
"field.quantity": "Quantity",
|
||||
"field.description": "Line Description",
|
||||
"field.amount": "Amount",
|
||||
"field.payment_amount": "Payment Amount",
|
||||
"field.status": "Status",
|
||||
"field.status.paid": "Paid",
|
||||
"field.status.partially-paid": "Partially Paid",
|
||||
"field.status.overdue": "Overdue",
|
||||
"field.status.unpaid": "Unpaid",
|
||||
"field.status.opened": "Opened",
|
||||
"field.status.draft": "Draft",
|
||||
"field.created_at": "Created At"
|
||||
}
|
||||
|
||||
15
packages/server/src/i18n/en/bill_payment.json
Normal file
15
packages/server/src/i18n/en/bill_payment.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"field.vendor": "Vendor",
|
||||
"field.payment_date": "Payment Date",
|
||||
"field.payment_number": "Payment No.",
|
||||
"field.payment_account": "Payment Account",
|
||||
"field.exchange_rate": "Exchange Rate",
|
||||
"field.note": "Note",
|
||||
"field.reference": "Reference",
|
||||
"field.entries": "Entries",
|
||||
"field.entries.bill": "Bill",
|
||||
"field.entries.payment_amount": "Payment Amount",
|
||||
"field.payment_number_hint": "The payment number should be unique.",
|
||||
"field.bill_hint": "Matches the bill number."
|
||||
}
|
||||
|
||||
16
packages/server/src/i18n/en/credit_note.json
Normal file
16
packages/server/src/i18n/en/credit_note.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"field.customer": "Customer",
|
||||
"field.exchange_rate": "Exchange Rate",
|
||||
"field.credit_note_date": "Credit Note Date",
|
||||
"field.reference_no": "Reference No.",
|
||||
"field.note": "Note",
|
||||
"field.terms_conditions": "Terms & Conditions",
|
||||
"field.credit_note_number": "Credit Note Number",
|
||||
"field.open": "Open",
|
||||
"field.entries": "Entries",
|
||||
"field.item": "Item",
|
||||
"field.rate": "Rate",
|
||||
"field.quantity": "Quantity",
|
||||
"field.description": "Description"
|
||||
}
|
||||
|
||||
21
packages/server/src/i18n/en/estimate.json
Normal file
21
packages/server/src/i18n/en/estimate.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"field.customer": "Customer",
|
||||
"field.estimate_date": "Estimate Date",
|
||||
"field.expiration_date": "Expiration Date",
|
||||
"field.estimate_number": "Estimate No.",
|
||||
"field.reference_no": "Reference No.",
|
||||
"field.exchange_rate": "Exchange Rate",
|
||||
"field.currency": "Currency",
|
||||
"field.note": "Note",
|
||||
"field.terms_conditions": "Terms & Conditions",
|
||||
"field.delivered": "Delivered",
|
||||
"field.entries": "Entries",
|
||||
"field.amount": "Amount",
|
||||
"field.status": "Status",
|
||||
"field.status.draft": "Draft",
|
||||
"field.status.delivered": "Delivered",
|
||||
"field.status.rejected": "Rejected",
|
||||
"field.status.approved": "Approved",
|
||||
"field.created_at": "Created At"
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
"field.due_amount": "Due amount",
|
||||
"field.delivered": "Delivered",
|
||||
"field.item_name": "Item Name",
|
||||
"field.item_hint": "Matches the item name or code.",
|
||||
"field.rate": "Rate",
|
||||
"field.quantity": "Quantity",
|
||||
"field.description": "Description",
|
||||
@@ -38,5 +39,7 @@
|
||||
"field.status.draft": "Draft",
|
||||
"field.created_at": "Created at",
|
||||
"field.currency": "Currency",
|
||||
"field.entries": "Entries"
|
||||
"field.entries": "Entries",
|
||||
"field.branch": "Branch",
|
||||
"field.warehouse": "Warehouse"
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"field.quantity_on_hand": "Quantity on Hand",
|
||||
"field.note": "Note",
|
||||
"field.category": "Category",
|
||||
"field.category_hint": "Matches the category name.",
|
||||
"field.active": "Active",
|
||||
"field.created_at": "Created At"
|
||||
}
|
||||
|
||||
17
packages/server/src/i18n/en/payment_receive.json
Normal file
17
packages/server/src/i18n/en/payment_receive.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"field.customer": "Customer",
|
||||
"field.payment_date": "Payment Date",
|
||||
"field.amount": "Amount",
|
||||
"field.reference_no": "Reference No.",
|
||||
"field.deposit_account": "Deposit Account",
|
||||
"field.payment_receive_no": "Payment No.",
|
||||
"field.statement": "Statement",
|
||||
"field.entries": "Entries",
|
||||
"field.exchange_rate": "Exchange Rate",
|
||||
"field.invoice": "Invoice",
|
||||
"field.entries.payment_amount": "Payment Amount",
|
||||
"field.created_at": "Created At",
|
||||
"field.payment_no_hint": "The payment number should be unique.",
|
||||
"field.invoice_hint": "Matches the invoice number."
|
||||
}
|
||||
|
||||
@@ -10,5 +10,21 @@
|
||||
"paper.receipt_amount": "Receipt amount",
|
||||
"paper.total": "Total",
|
||||
"paper.balance_due": "Balance Due",
|
||||
"paper.payment_amount": "Payment Amount"
|
||||
"paper.payment_amount": "Payment Amount",
|
||||
|
||||
"field.receipt_date": "Receipt Date",
|
||||
"field.customer": "Customer",
|
||||
"field.deposit_account": "Deposit Account",
|
||||
"field.exchange_rate": "Exchange Rate",
|
||||
"field.receipt_number": "Receipt Number",
|
||||
"field.reference_no": "Reference No.",
|
||||
"field.closed": "Closed",
|
||||
"field.entries": "Entries",
|
||||
"field.statement": "Statement",
|
||||
"field.receipt_message": "Receipt Message",
|
||||
"field.amount": "Amount",
|
||||
"field.status": "Status",
|
||||
"field.status.draft": "Draft",
|
||||
"field.status.closed": "Closed",
|
||||
"field.created_at": "Created At"
|
||||
}
|
||||
@@ -2,5 +2,18 @@
|
||||
"view.draft": "Draft",
|
||||
"view.published": "Published",
|
||||
"view.open": "Open",
|
||||
"view.closed": "Closed"
|
||||
"view.closed": "Closed",
|
||||
|
||||
"field.vendor": "Vendor",
|
||||
"field.vendor_credit_number": "Vendor Credit No.",
|
||||
"field.vendor_credit_date": "Vendor Credit Date",
|
||||
"field.reference_no": "Reference No.",
|
||||
"field.exchange_rate": "Exchange Rate",
|
||||
"field.note": "Note",
|
||||
"field.open": "Open",
|
||||
"field.entries": "Entries",
|
||||
"field.item": "Item",
|
||||
"field.rate": "Rate",
|
||||
"field.quantity": "Quantity",
|
||||
"field.description": "Description"
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ export const AccountMeta = {
|
||||
minLength: 3,
|
||||
maxLength: 6,
|
||||
unique: true,
|
||||
importHint: 'Unique number to identify the account.',
|
||||
importHint: 'account.field.code_hint',
|
||||
},
|
||||
accountType: {
|
||||
name: 'account.field.type',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Knex } from 'knex';
|
||||
import * as yup from 'yup';
|
||||
import uniqid from 'uniqid';
|
||||
import * as uniqid from 'uniqid';
|
||||
import { Importable } from '../../Import/Importable';
|
||||
import { CreateUncategorizedTransactionService } from './CreateUncategorizedTransaction.service';
|
||||
import { ImportableContext } from '../../Import/interfaces';
|
||||
@@ -9,8 +9,10 @@ import { BankTransactionsSampleData } from '../../BankingTransactions/constants'
|
||||
import { Account } from '@/modules/Accounts/models/Account.model';
|
||||
import { CreateUncategorizedTransactionDTO } from '../types/BankingCategorize.types';
|
||||
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
|
||||
|
||||
import { ImportableService } from '../../Import/decorators/Import.decorator';
|
||||
import { UncategorizedBankTransaction } from '../../BankingTransactions/models/UncategorizedBankTransaction';
|
||||
@Injectable()
|
||||
@ImportableService({ name: UncategorizedBankTransaction.name })
|
||||
export class UncategorizedTransactionsImportable extends Importable {
|
||||
constructor(
|
||||
private readonly createUncategorizedTransaction: CreateUncategorizedTransactionService,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as moment from 'moment';
|
||||
import * as R from 'ramda';
|
||||
import { isEmpty, sumBy } from 'lodash';
|
||||
import { isEmpty, round, sumBy } from 'lodash';
|
||||
import { ERRORS, MatchedTransactionPOJO } from './types';
|
||||
import { ServiceError } from '../Items/ServiceError';
|
||||
|
||||
@@ -22,18 +22,24 @@ export const sortClosestMatchTransactions = (
|
||||
};
|
||||
|
||||
export const sumMatchTranasctions = (transactions: Array<any>) => {
|
||||
return transactions.reduce(
|
||||
(total, item) =>
|
||||
total +
|
||||
(item.transactionNormal === 'debit' ? 1 : -1) * parseFloat(item.amount),
|
||||
const total = transactions.reduce(
|
||||
(sum, item) => {
|
||||
const amount = parseFloat(item.amount) || 0;
|
||||
const multiplier = item.transactionNormal === 'debit' ? 1 : -1;
|
||||
return sum + multiplier * amount;
|
||||
},
|
||||
0
|
||||
);
|
||||
// Round to 2 decimal places to avoid floating-point precision issues
|
||||
return round(total, 2);
|
||||
};
|
||||
|
||||
export const sumUncategorizedTransactions = (
|
||||
uncategorizedTransactions: Array<any>
|
||||
) => {
|
||||
return sumBy(uncategorizedTransactions, 'amount');
|
||||
const total = sumBy(uncategorizedTransactions, 'amount');
|
||||
// Round to 2 decimal places to avoid floating-point precision issues
|
||||
return round(total, 2);
|
||||
};
|
||||
|
||||
export const validateUncategorizedTransactionsNotMatched = (
|
||||
|
||||
@@ -34,7 +34,7 @@ export class MatchBankTransactions {
|
||||
private readonly uncategorizedBankTransactionModel: TenantModelProxy<
|
||||
typeof UncategorizedBankTransaction
|
||||
>,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Validates the match bank transactions DTO.
|
||||
@@ -100,7 +100,10 @@ export class MatchBankTransactions {
|
||||
);
|
||||
// Validates the total given matching transcations whether is not equal
|
||||
// uncategorized transaction amount.
|
||||
if (totalUncategorizedTransactions !== totalMatchedTranasctions) {
|
||||
// Use tolerance-based comparison to handle floating-point precision issues
|
||||
const tolerance = 0.01; // Allow 0.01 difference for floating-point precision
|
||||
const difference = Math.abs(totalUncategorizedTransactions - totalMatchedTranasctions);
|
||||
if (difference > tolerance) {
|
||||
throw new ServiceError(ERRORS.TOTAL_MATCHING_TRANSACTIONS_INVALID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,24 +12,30 @@ export class MatchTransactionsTypes {
|
||||
private static registry: MatchTransactionsTypesRegistry;
|
||||
|
||||
/**
|
||||
* Consttuctor method.
|
||||
* Constructor method.
|
||||
*/
|
||||
constructor() {
|
||||
constructor(
|
||||
private readonly getMatchedInvoicesService: GetMatchedTransactionsByInvoices,
|
||||
private readonly getMatchedBillsService: GetMatchedTransactionsByBills,
|
||||
private readonly getMatchedExpensesService: GetMatchedTransactionsByExpenses,
|
||||
private readonly getMatchedManualJournalsService: GetMatchedTransactionsByManualJournals,
|
||||
private readonly getMatchedCashflowService: GetMatchedTransactionsByCashflow,
|
||||
) {
|
||||
this.boot();
|
||||
}
|
||||
|
||||
get registered() {
|
||||
return [
|
||||
{ type: 'SaleInvoice', service: GetMatchedTransactionsByInvoices },
|
||||
{ type: 'Bill', service: GetMatchedTransactionsByBills },
|
||||
{ type: 'Expense', service: GetMatchedTransactionsByExpenses },
|
||||
{ type: 'SaleInvoice', service: this.getMatchedInvoicesService },
|
||||
{ type: 'Bill', service: this.getMatchedBillsService },
|
||||
{ type: 'Expense', service: this.getMatchedExpensesService },
|
||||
{
|
||||
type: 'ManualJournal',
|
||||
service: GetMatchedTransactionsByManualJournals,
|
||||
service: this.getMatchedManualJournalsService,
|
||||
},
|
||||
{
|
||||
type: 'CashflowTransaction',
|
||||
service: GetMatchedTransactionsByCashflow,
|
||||
service: this.getMatchedCashflowService,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -50,14 +56,13 @@ export class MatchTransactionsTypes {
|
||||
* Boots all the registered importables.
|
||||
*/
|
||||
public boot() {
|
||||
if (!MatchTransactionsTypes.registry) {
|
||||
const instance = MatchTransactionsTypesRegistry.getInstance();
|
||||
const instance = MatchTransactionsTypesRegistry.getInstance();
|
||||
|
||||
this.registered.forEach((registered) => {
|
||||
// const serviceInstanace = Container.get(registered.service);
|
||||
// instance.register(registered.type, serviceInstanace);
|
||||
});
|
||||
MatchTransactionsTypes.registry = instance;
|
||||
}
|
||||
// Always register services to ensure they're available
|
||||
this.registered.forEach((registered) => {
|
||||
instance.register(registered.type, registered.service);
|
||||
});
|
||||
|
||||
MatchTransactionsTypes.registry = instance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,4 +83,4 @@ const models = [
|
||||
CreateBankTransactionService
|
||||
],
|
||||
})
|
||||
export class BankingTransactionsModule {}
|
||||
export class BankingTransactionsModule { }
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
export const UncategorizedBankTransactionMeta = {
|
||||
defaultFilterField: 'createdAt',
|
||||
defaultSort: {
|
||||
sortOrder: 'DESC',
|
||||
sortField: 'created_at',
|
||||
},
|
||||
importable: true,
|
||||
fields: {
|
||||
date: {
|
||||
name: 'Date',
|
||||
column: 'date',
|
||||
fieldType: 'date',
|
||||
},
|
||||
payee: {
|
||||
name: 'Payee',
|
||||
column: 'payee',
|
||||
fieldType: 'text',
|
||||
},
|
||||
description: {
|
||||
name: 'Description',
|
||||
column: 'description',
|
||||
fieldType: 'text',
|
||||
},
|
||||
referenceNo: {
|
||||
name: 'Reference No.',
|
||||
column: 'reference_no',
|
||||
fieldType: 'text',
|
||||
},
|
||||
amount: {
|
||||
name: 'Amount',
|
||||
column: 'Amount',
|
||||
fieldType: 'numeric',
|
||||
required: true,
|
||||
},
|
||||
account: {
|
||||
name: 'Account',
|
||||
column: 'account_id',
|
||||
fieldType: 'relation',
|
||||
to: { model: 'Account', to: 'id' },
|
||||
},
|
||||
createdAt: {
|
||||
name: 'Created At',
|
||||
column: 'createdAt',
|
||||
fieldType: 'date',
|
||||
importable: false,
|
||||
},
|
||||
},
|
||||
fields2: {
|
||||
date: {
|
||||
name: 'Date',
|
||||
fieldType: 'date',
|
||||
required: true,
|
||||
},
|
||||
payee: {
|
||||
name: 'Payee',
|
||||
fieldType: 'text',
|
||||
},
|
||||
description: {
|
||||
name: 'Description',
|
||||
fieldType: 'text',
|
||||
},
|
||||
referenceNo: {
|
||||
name: 'Reference No.',
|
||||
fieldType: 'text',
|
||||
},
|
||||
amount: {
|
||||
name: 'Amount',
|
||||
fieldType: 'number',
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -2,7 +2,10 @@
|
||||
import * as moment from 'moment';
|
||||
import { Model } from 'objection';
|
||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||
import { UncategorizedBankTransactionMeta } from './UncategorizedBankTransaction.meta';
|
||||
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
||||
|
||||
@InjectModelMeta(UncategorizedBankTransactionMeta)
|
||||
export class UncategorizedBankTransaction extends TenantBaseModel {
|
||||
readonly amount!: number;
|
||||
readonly date!: Date | string;
|
||||
|
||||
@@ -104,6 +104,12 @@ export class BillPaymentResponseDto {
|
||||
@ApiProperty({ description: 'The formatted amount', example: '100.00 USD' })
|
||||
formattedAmount: string;
|
||||
|
||||
@ApiProperty({ description: 'The formatted total', example: '100.00 USD' })
|
||||
formattedTotal: string;
|
||||
|
||||
@ApiProperty({ description: 'The formatted subtotal', example: '100.00 USD' })
|
||||
formattedSubtotal: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'The date when the payment was created',
|
||||
example: '2024-01-01T12:00:00Z',
|
||||
|
||||
@@ -167,7 +167,7 @@ export const BillPaymentMeta = {
|
||||
name: 'bill_payment.field.payment_number',
|
||||
fieldType: 'text',
|
||||
unique: true,
|
||||
importHint: 'The payment number should be unique.',
|
||||
importHint: 'bill_payment.field.payment_number_hint',
|
||||
},
|
||||
paymentAccountId: {
|
||||
name: 'bill_payment.field.payment_account',
|
||||
@@ -175,7 +175,7 @@ export const BillPaymentMeta = {
|
||||
relationModel: 'Account',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
required: true,
|
||||
importHint: 'Matches the account name or code.',
|
||||
importHint: 'account.field.account_hint',
|
||||
},
|
||||
exchangeRate: {
|
||||
name: 'bill_payment.field.exchange_rate',
|
||||
@@ -203,7 +203,7 @@ export const BillPaymentMeta = {
|
||||
relationModel: 'Bill',
|
||||
relationImportMatch: 'billNumber',
|
||||
required: true,
|
||||
importHint: 'Matches the bill number.',
|
||||
importHint: 'bill_payment.field.bill_hint',
|
||||
},
|
||||
paymentAmount: {
|
||||
name: 'bill_payment.field.entries.payment_amount',
|
||||
@@ -213,7 +213,7 @@ export const BillPaymentMeta = {
|
||||
},
|
||||
},
|
||||
branchId: {
|
||||
name: 'Branch',
|
||||
name: 'invoice.field.branch',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Branch',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
|
||||
@@ -13,6 +13,8 @@ export class BillPaymentTransformer extends Transformer {
|
||||
'formattedPaymentDate',
|
||||
'formattedCreatedAt',
|
||||
'formattedAmount',
|
||||
'formattedTotal',
|
||||
'formattedSubtotal',
|
||||
'entries',
|
||||
'attachments',
|
||||
];
|
||||
@@ -47,6 +49,29 @@ export class BillPaymentTransformer extends Transformer {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the formatted total.
|
||||
* @param {IBillPayment} billPayment
|
||||
* @returns {string}
|
||||
*/
|
||||
protected formattedTotal = (billPayment: BillPayment): string => {
|
||||
return this.formatNumber(billPayment.amount, {
|
||||
currencyCode: billPayment.currencyCode,
|
||||
money: true,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the formatted subtotal.
|
||||
* @param {IBillPayment} billPayment
|
||||
* @returns {string}
|
||||
*/
|
||||
protected formattedSubtotal = (billPayment: BillPayment): string => {
|
||||
return this.formatNumber(billPayment.amount, {
|
||||
currencyCode: billPayment.currencyCode,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retreives the bill payment entries.
|
||||
*/
|
||||
|
||||
@@ -184,76 +184,76 @@ export const BillMeta = {
|
||||
},
|
||||
fields2: {
|
||||
billNumber: {
|
||||
name: 'Bill No.',
|
||||
name: 'bill.field.bill_number',
|
||||
fieldType: 'text',
|
||||
required: true,
|
||||
},
|
||||
referenceNo: {
|
||||
name: 'Reference No.',
|
||||
name: 'bill.field.reference_no',
|
||||
fieldType: 'text',
|
||||
},
|
||||
billDate: {
|
||||
name: 'Date',
|
||||
name: 'bill.field.bill_date',
|
||||
fieldType: 'date',
|
||||
required: true,
|
||||
},
|
||||
dueDate: {
|
||||
name: 'Due Date',
|
||||
name: 'bill.field.due_date',
|
||||
fieldType: 'date',
|
||||
required: true,
|
||||
},
|
||||
vendorId: {
|
||||
name: 'Vendor',
|
||||
name: 'bill.field.vendor',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Contact',
|
||||
relationImportMatch: 'displayName',
|
||||
required: true,
|
||||
},
|
||||
exchangeRate: {
|
||||
name: 'Exchange Rate',
|
||||
name: 'bill.field.exchange_rate',
|
||||
fieldType: 'number',
|
||||
},
|
||||
note: {
|
||||
name: 'Note',
|
||||
name: 'bill.field.note',
|
||||
fieldType: 'text',
|
||||
},
|
||||
open: {
|
||||
name: 'Open',
|
||||
name: 'bill.field.open',
|
||||
fieldType: 'boolean',
|
||||
},
|
||||
entries: {
|
||||
name: 'Entries',
|
||||
name: 'bill.field.entries',
|
||||
fieldType: 'collection',
|
||||
collectionOf: 'object',
|
||||
collectionMinLength: 1,
|
||||
required: true,
|
||||
fields: {
|
||||
itemId: {
|
||||
name: 'Item',
|
||||
name: 'bill.field.item',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Item',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
required: true,
|
||||
importHint: 'Matches the item name or code.',
|
||||
importHint: 'bill.field.item_hint',
|
||||
},
|
||||
rate: {
|
||||
name: 'Rate',
|
||||
name: 'bill.field.rate',
|
||||
fieldType: 'number',
|
||||
required: true,
|
||||
},
|
||||
quantity: {
|
||||
name: 'Quantity',
|
||||
name: 'bill.field.quantity',
|
||||
fieldType: 'number',
|
||||
required: true,
|
||||
},
|
||||
description: {
|
||||
name: 'Line Description',
|
||||
name: 'bill.field.description',
|
||||
fieldType: 'text',
|
||||
},
|
||||
},
|
||||
},
|
||||
branchId: {
|
||||
name: 'Branch',
|
||||
name: 'invoice.field.branch',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Branch',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
@@ -261,7 +261,7 @@ export const BillMeta = {
|
||||
required: true,
|
||||
},
|
||||
warehouseId: {
|
||||
name: 'Warehouse',
|
||||
name: 'invoice.field.warehouse',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Warehouse',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
|
||||
@@ -94,6 +94,7 @@ export class BillTransformer extends Transformer {
|
||||
protected formattedDueAmount = (bill: Bill): string => {
|
||||
return this.formatNumber(bill.dueAmount, {
|
||||
currencyCode: bill.currencyCode,
|
||||
money: true,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -169,6 +170,7 @@ export class BillTransformer extends Transformer {
|
||||
protected totalFormatted = (bill: Bill): string => {
|
||||
return this.formatNumber(bill.total, {
|
||||
currencyCode: bill.currencyCode,
|
||||
money: true,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -164,73 +164,73 @@ export const CreditNoteMeta = {
|
||||
},
|
||||
fields2: {
|
||||
customerId: {
|
||||
name: 'Customer',
|
||||
name: 'credit_note.field.customer',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Contact',
|
||||
relationImportMatch: 'displayName',
|
||||
required: true,
|
||||
},
|
||||
exchangeRate: {
|
||||
name: 'Exchange Rate',
|
||||
name: 'credit_note.field.exchange_rate',
|
||||
fieldType: 'number',
|
||||
},
|
||||
creditNoteDate: {
|
||||
name: 'Credit Note Date',
|
||||
name: 'credit_note.field.credit_note_date',
|
||||
fieldType: 'date',
|
||||
required: true,
|
||||
},
|
||||
referenceNo: {
|
||||
name: 'Reference No.',
|
||||
name: 'credit_note.field.reference_no',
|
||||
fieldType: 'text',
|
||||
},
|
||||
note: {
|
||||
name: 'Note',
|
||||
name: 'credit_note.field.note',
|
||||
fieldType: 'text',
|
||||
},
|
||||
termsConditions: {
|
||||
name: 'Terms & Conditions',
|
||||
name: 'credit_note.field.terms_conditions',
|
||||
fieldType: 'text',
|
||||
},
|
||||
creditNoteNumber: {
|
||||
name: 'Credit Note Number',
|
||||
name: 'credit_note.field.credit_note_number',
|
||||
fieldType: 'text',
|
||||
},
|
||||
open: {
|
||||
name: 'Open',
|
||||
name: 'credit_note.field.open',
|
||||
fieldType: 'boolean',
|
||||
},
|
||||
entries: {
|
||||
name: 'Entries',
|
||||
name: 'credit_note.field.entries',
|
||||
fieldType: 'collection',
|
||||
collectionOf: 'object',
|
||||
collectionMinLength: 1,
|
||||
fields: {
|
||||
itemId: {
|
||||
name: 'Item',
|
||||
name: 'credit_note.field.item',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Item',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
required: true,
|
||||
importHint: 'Matches the item name or code.',
|
||||
importHint: 'invoice.field.item_hint',
|
||||
},
|
||||
rate: {
|
||||
name: 'Rate',
|
||||
name: 'credit_note.field.rate',
|
||||
fieldType: 'number',
|
||||
required: true,
|
||||
},
|
||||
quantity: {
|
||||
name: 'Quantity',
|
||||
name: 'credit_note.field.quantity',
|
||||
fieldType: 'number',
|
||||
required: true,
|
||||
},
|
||||
description: {
|
||||
name: 'Description',
|
||||
name: 'credit_note.field.description',
|
||||
fieldType: 'text',
|
||||
},
|
||||
},
|
||||
},
|
||||
branchId: {
|
||||
name: 'Branch',
|
||||
name: 'invoice.field.branch',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Branch',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
@@ -238,7 +238,7 @@ export const CreditNoteMeta = {
|
||||
required: true,
|
||||
},
|
||||
warehouseId: {
|
||||
name: 'Warehouse',
|
||||
name: 'invoice.field.warehouse',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Warehouse',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
|
||||
@@ -90,7 +90,7 @@ export class CreditNoteTransformer extends Transformer {
|
||||
* @returns {string}
|
||||
*/
|
||||
protected formattedSubtotal = (credit): string => {
|
||||
return this.formatNumber(credit.amount, { money: false });
|
||||
return this.formatNumber(credit.amount);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -130,7 +130,7 @@ export class CreditNoteTransformer extends Transformer {
|
||||
* @returns {string}
|
||||
*/
|
||||
protected adjustmentFormatted = (credit): string => {
|
||||
return this.formatMoney(credit.adjustment, {
|
||||
return this.formatNumber(credit.adjustment, {
|
||||
currencyCode: credit.currencyCode,
|
||||
excerptZero: true,
|
||||
});
|
||||
@@ -156,6 +156,7 @@ export class CreditNoteTransformer extends Transformer {
|
||||
protected totalFormatted = (credit): string => {
|
||||
return this.formatNumber(credit.total, {
|
||||
currencyCode: credit.currencyCode,
|
||||
money: true,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -167,6 +168,7 @@ export class CreditNoteTransformer extends Transformer {
|
||||
protected totalLocalFormatted = (credit): string => {
|
||||
return this.formatNumber(credit.totalLocal, {
|
||||
currencyCode: credit.currencyCode,
|
||||
money: true,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ import { ExpensesSampleData } from './constants';
|
||||
import { CreateExpense } from './commands/CreateExpense.service';
|
||||
import { CreateExpenseDto } from './dtos/Expense.dto';
|
||||
import { ImportableService } from '../Import/decorators/Import.decorator';
|
||||
import { ManualJournal } from '../ManualJournals/models/ManualJournal';
|
||||
import { Expense } from './models/Expense.model';
|
||||
|
||||
@Injectable()
|
||||
@ImportableService({ name: ManualJournal.name })
|
||||
@ImportableService({ name: Expense.name })
|
||||
export class ExpensesImportable extends Importable {
|
||||
constructor(private readonly createExpenseService: CreateExpense) {
|
||||
super();
|
||||
|
||||
@@ -135,7 +135,7 @@ export const ExpenseMeta = {
|
||||
relationModel: 'Account',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
required: true,
|
||||
importHint: 'Matches the account name or code.',
|
||||
importHint: 'account.field.account_hint',
|
||||
},
|
||||
referenceNo: {
|
||||
name: 'expense.field.reference_no',
|
||||
@@ -169,7 +169,7 @@ export const ExpenseMeta = {
|
||||
relationModel: 'Account',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
required: true,
|
||||
importHint: 'Matches the account name or code.',
|
||||
importHint: 'account.field.account_hint',
|
||||
},
|
||||
amount: {
|
||||
name: 'expense.field.amount',
|
||||
@@ -187,7 +187,7 @@ export const ExpenseMeta = {
|
||||
fieldType: 'boolean',
|
||||
},
|
||||
branchId: {
|
||||
name: 'Branch',
|
||||
name: 'invoice.field.branch',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Branch',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ChromiumlyTenancy } from '../ChromiumlyTenancy/ChromiumlyTenancy.service';
|
||||
import { TemplateInjectable } from '../TemplateInjectable/TemplateInjectable.service';
|
||||
import { renderExportResourceTableTemplateHtml } from '@bigcapital/pdf-templates';
|
||||
import { mapPdfRows } from './utils';
|
||||
|
||||
@Injectable()
|
||||
export class ExportPdf {
|
||||
constructor(
|
||||
private readonly templateInjectable: TemplateInjectable,
|
||||
private readonly chromiumlyTenancy: ChromiumlyTenancy,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Generates the pdf table sheet for the given data and columns.
|
||||
@@ -19,21 +18,18 @@ export class ExportPdf {
|
||||
* @returns
|
||||
*/
|
||||
public async pdf(
|
||||
columns: { accessor: string },
|
||||
columns: { accessor: string; name?: string; style?: string; group?: string }[],
|
||||
data: Record<string, any>,
|
||||
sheetTitle: string = '',
|
||||
sheetDescription: string = ''
|
||||
) {
|
||||
const rows = mapPdfRows(columns, data);
|
||||
|
||||
const htmlContent = await this.templateInjectable.render(
|
||||
'modules/export-resource-table',
|
||||
{
|
||||
table: { rows, columns },
|
||||
sheetTitle,
|
||||
sheetDescription,
|
||||
}
|
||||
);
|
||||
const htmlContent = renderExportResourceTableTemplateHtml({
|
||||
table: { rows, columns },
|
||||
sheetTitle,
|
||||
sheetDescription,
|
||||
});
|
||||
// Convert the HTML content to PDF
|
||||
return this.chromiumlyTenancy.convertHtmlContent(htmlContent, {
|
||||
margins: { top: 0.2, bottom: 0.2, left: 0.2, right: 0.2 },
|
||||
|
||||
@@ -211,7 +211,7 @@ export class InventoryValuationSheet extends FinancialSheet {
|
||||
* Detarmines whether the items post filter is active.
|
||||
*/
|
||||
private isItemsPostFilter = (): boolean => {
|
||||
return isEmpty(this.query.itemsIds);
|
||||
return !isEmpty(this.query.itemsIds);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,7 @@ export class InventoryValuationSheetService {
|
||||
private readonly inventoryValuationMeta: InventoryValuationMetaInjectable,
|
||||
private readonly eventPublisher: EventEmitter2,
|
||||
private readonly inventoryValuationSheetRepository: InventoryValuationSheetRepository,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Inventory valuation sheet.
|
||||
|
||||
@@ -172,7 +172,10 @@ export class TrialBalanceSheet extends FinancialSheet {
|
||||
private filterNoneTransactions = (
|
||||
accountNode: ITrialBalanceAccount
|
||||
): boolean => {
|
||||
return false === this.repository.totalAccountsLedger.isEmpty();
|
||||
const accountLedger = this.repository.totalAccountsLedger.whereAccountId(
|
||||
accountNode.id,
|
||||
);
|
||||
return !accountLedger.isEmpty();
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,7 @@ export class ImportFileCommon {
|
||||
private readonly importFileValidator: ImportFileDataValidator,
|
||||
private readonly resource: ResourceService,
|
||||
private readonly importableRegistry: ImportableRegistry,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Imports the given parsed data to the resource storage through registered importable service.
|
||||
|
||||
@@ -18,7 +18,7 @@ import { CurrencyParsingDTOs } from './_constants';
|
||||
export class ImportFileDataTransformer {
|
||||
constructor(
|
||||
private readonly resource: ResourceService,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Parses the given sheet data before passing to the service layer.
|
||||
@@ -55,9 +55,8 @@ export class ImportFileDataTransformer {
|
||||
|
||||
/**
|
||||
* Aggregates parsed data based on resource metadata configuration.
|
||||
* @param {number} tenantId
|
||||
* @param {string} resourceName
|
||||
* @param {Record<string, any>} parsedData
|
||||
* @param {string} resourceName - The resource name.
|
||||
* @param {Record<string, any>} parsedData - The parsed data to aggregate.
|
||||
* @returns {Record<string, any>[]}
|
||||
*/
|
||||
public aggregateParsedValues(
|
||||
@@ -110,8 +109,11 @@ export class ImportFileDataTransformer {
|
||||
valueDTOs: Record<string, any>[],
|
||||
trx?: Knex.Transaction
|
||||
): Promise<Record<string, any>[]> {
|
||||
// const tenantModels = this.tenancy.models(tenantId);
|
||||
const _valueParser = valueParser(fields, {}, trx);
|
||||
// Create a model resolver function that uses ResourceService
|
||||
const modelResolver = (modelName: string) => {
|
||||
return this.resource.getResourceModel(modelName)();
|
||||
};
|
||||
const _valueParser = valueParser(fields, modelResolver, trx);
|
||||
const _keyParser = parseKey(fields);
|
||||
|
||||
const parseAsync = async (valueDTO) => {
|
||||
|
||||
@@ -19,7 +19,8 @@ export class ImportFileDataValidator {
|
||||
|
||||
/**
|
||||
* Validates the given mapped DTOs and returns errors with their index.
|
||||
* @param {Record<string, any>} mappedDTOs
|
||||
* @param {ResourceMetaFieldsMap} importableFields - Already localized fields from ResourceService
|
||||
* @param {Record<string, any>} data
|
||||
* @returns {Promise<void | ImportInsertError[]>}
|
||||
*/
|
||||
public async validateData(
|
||||
|
||||
@@ -24,7 +24,7 @@ export class ImportFileUploadService {
|
||||
|
||||
@Inject(ImportModel.name)
|
||||
private readonly importModel: typeof ImportModel,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Imports the specified file for the given resource.
|
||||
@@ -84,7 +84,7 @@ export class ImportFileUploadService {
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
const _params = this.importFileCommon.transformParams(resource, params);
|
||||
const _params = await this.importFileCommon.transformParams(resource, params);
|
||||
const paramsStringified = JSON.stringify(_params);
|
||||
|
||||
const tenant = await this.tenancyContext.getTenant();
|
||||
|
||||
@@ -6,7 +6,7 @@ import { ContextIdFactory, ModuleRef } from '@nestjs/core';
|
||||
|
||||
@Injectable()
|
||||
export class ImportableRegistry {
|
||||
constructor(private readonly moduleRef: ModuleRef) {}
|
||||
constructor(private readonly moduleRef: ModuleRef) { }
|
||||
/**
|
||||
* Retrieves the importable service instance of the given resource name.
|
||||
* @param {string} name
|
||||
@@ -15,6 +15,12 @@ export class ImportableRegistry {
|
||||
public async getImportable(name: string) {
|
||||
const _name = this.sanitizeResourceName(name);
|
||||
const importable = getImportableService(_name);
|
||||
|
||||
if (!importable) {
|
||||
throw new Error(
|
||||
`No importable service found for resource "${_name}". Make sure the resource has an @ImportableService decorator registered.`,
|
||||
);
|
||||
}
|
||||
const contextId = ContextIdFactory.create();
|
||||
|
||||
const importableInstance = await this.moduleRef.resolve(importable, contextId, {
|
||||
|
||||
287
packages/server/src/modules/Import/_utils.spec.ts
Normal file
287
packages/server/src/modules/Import/_utils.spec.ts
Normal file
@@ -0,0 +1,287 @@
|
||||
import { aggregate } from './_utils';
|
||||
|
||||
describe('aggregate', () => {
|
||||
describe('basic aggregation', () => {
|
||||
it('should aggregate entries with matching comparator attribute', () => {
|
||||
const input = [
|
||||
{ id: 1, name: 'John', entries: ['entry1'] },
|
||||
{ id: 2, name: 'Jane', entries: ['entry2'] },
|
||||
{ id: 1, name: 'John', entries: ['entry3'] },
|
||||
];
|
||||
|
||||
const result = aggregate(input, 'id', 'entries');
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0]).toEqual({
|
||||
id: 1,
|
||||
name: 'John',
|
||||
entries: ['entry1', 'entry3'],
|
||||
});
|
||||
expect(result[1]).toEqual({
|
||||
id: 2,
|
||||
name: 'Jane',
|
||||
entries: ['entry2'],
|
||||
});
|
||||
});
|
||||
|
||||
it('should preserve order of first occurrence', () => {
|
||||
const input = [
|
||||
{ id: 2, entries: ['a'] },
|
||||
{ id: 1, entries: ['b'] },
|
||||
{ id: 2, entries: ['c'] },
|
||||
];
|
||||
|
||||
const result = aggregate(input, 'id', 'entries');
|
||||
|
||||
expect(result[0].id).toBe(2);
|
||||
expect(result[1].id).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('no matching entries', () => {
|
||||
it('should return all entries unchanged when no comparator matches', () => {
|
||||
const input = [
|
||||
{ id: 1, name: 'John', entries: ['entry1'] },
|
||||
{ id: 2, name: 'Jane', entries: ['entry2'] },
|
||||
{ id: 3, name: 'Bob', entries: ['entry3'] },
|
||||
];
|
||||
|
||||
const result = aggregate(input, 'id', 'entries');
|
||||
|
||||
expect(result).toHaveLength(3);
|
||||
expect(result).toEqual(input);
|
||||
});
|
||||
});
|
||||
|
||||
describe('edge cases', () => {
|
||||
it('should return empty array when input is empty', () => {
|
||||
const result = aggregate([], 'id', 'entries');
|
||||
|
||||
expect(result).toEqual([]);
|
||||
expect(result).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('should return single entry unchanged when input has one item', () => {
|
||||
const input = [{ id: 1, name: 'John', entries: ['entry1'] }];
|
||||
|
||||
const result = aggregate(input, 'id', 'entries');
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0]).toEqual({
|
||||
id: 1,
|
||||
name: 'John',
|
||||
entries: ['entry1'],
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle multiple entries with same comparator value', () => {
|
||||
const input = [
|
||||
{ id: 1, entries: ['a'] },
|
||||
{ id: 1, entries: ['b'] },
|
||||
{ id: 1, entries: ['c'] },
|
||||
{ id: 1, entries: ['d'] },
|
||||
];
|
||||
|
||||
const result = aggregate(input, 'id', 'entries');
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].entries).toEqual(['a', 'b', 'c', 'd']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('different comparator attributes', () => {
|
||||
it('should work with string comparator attribute', () => {
|
||||
const input = [
|
||||
{ name: 'Product A', category: 'Electronics', entries: ['item1'] },
|
||||
{ name: 'Product B', category: 'Books', entries: ['item2'] },
|
||||
{ name: 'Product C', category: 'Electronics', entries: ['item3'] },
|
||||
];
|
||||
|
||||
const result = aggregate(input, 'category', 'entries');
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0]).toEqual({
|
||||
name: 'Product A',
|
||||
category: 'Electronics',
|
||||
entries: ['item1', 'item3'],
|
||||
});
|
||||
expect(result[1]).toEqual({
|
||||
name: 'Product B',
|
||||
category: 'Books',
|
||||
entries: ['item2'],
|
||||
});
|
||||
});
|
||||
|
||||
it('should not aggregate items with undefined comparator values', () => {
|
||||
const input = [
|
||||
{ id: undefined, entries: ['a'] },
|
||||
{ id: 1, entries: ['b'] },
|
||||
{ id: undefined, entries: ['c'] },
|
||||
];
|
||||
|
||||
const result = aggregate(input, 'id', 'entries');
|
||||
|
||||
expect(result).toHaveLength(3);
|
||||
// Items with undefined id are NOT aggregated - each remains separate
|
||||
expect(result[0].entries).toEqual(['a']);
|
||||
expect(result[1].entries).toEqual(['b']);
|
||||
expect(result[2].entries).toEqual(['c']);
|
||||
});
|
||||
|
||||
it('should handle null comparator values separately', () => {
|
||||
const input = [
|
||||
{ id: null, entries: ['a'] },
|
||||
{ id: 1, entries: ['b'] },
|
||||
{ id: null, entries: ['c'] },
|
||||
];
|
||||
|
||||
const result = aggregate(input, 'id', 'entries');
|
||||
|
||||
expect(result).toHaveLength(3);
|
||||
expect(result[0].entries).toEqual(['a']);
|
||||
expect(result[1].entries).toEqual(['b']);
|
||||
expect(result[2].entries).toEqual(['c']);
|
||||
});
|
||||
|
||||
it('should not aggregate items missing the comparatorAttr property', () => {
|
||||
const input = [
|
||||
{ id: 1, entries: ['a'] },
|
||||
{ name: 'No ID', entries: ['b'] }, // missing 'id' property
|
||||
{ id: 1, entries: ['c'] },
|
||||
{ entries: ['d'] }, // also missing 'id' property
|
||||
];
|
||||
|
||||
const result = aggregate(input, 'id', 'entries');
|
||||
|
||||
// 3 entries: aggregated id:1, and two separate items without 'id' property
|
||||
expect(result).toHaveLength(3);
|
||||
// Items with id: 1 are aggregated
|
||||
expect(result[0]).toEqual({ id: 1, entries: ['a', 'c'] });
|
||||
// Items missing 'id' are NOT aggregated - each remains separate
|
||||
expect(result[1]).toEqual({ name: 'No ID', entries: ['b'] });
|
||||
expect(result[2]).toEqual({ entries: ['d'] });
|
||||
});
|
||||
});
|
||||
|
||||
describe('different group attributes', () => {
|
||||
it('should work with different groupOn attribute name', () => {
|
||||
const input = [
|
||||
{ id: 1, items: ['item1'] },
|
||||
{ id: 1, items: ['item2'] },
|
||||
{ id: 2, items: ['item3'] },
|
||||
];
|
||||
|
||||
const result = aggregate(input, 'id', 'items');
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0].items).toEqual(['item1', 'item2']);
|
||||
expect(result[1].items).toEqual(['item3']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('complex entries', () => {
|
||||
it('should aggregate entries containing objects', () => {
|
||||
const input = [
|
||||
{ invoiceId: 'INV-001', entries: [{ itemId: 1, quantity: 2 }] },
|
||||
{ invoiceId: 'INV-002', entries: [{ itemId: 2, quantity: 1 }] },
|
||||
{ invoiceId: 'INV-001', entries: [{ itemId: 3, quantity: 5 }] },
|
||||
];
|
||||
|
||||
const result = aggregate(input, 'invoiceId', 'entries');
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0].entries).toEqual([
|
||||
{ itemId: 1, quantity: 2 },
|
||||
{ itemId: 3, quantity: 5 },
|
||||
]);
|
||||
expect(result[1].entries).toEqual([{ itemId: 2, quantity: 1 }]);
|
||||
});
|
||||
|
||||
it('should aggregate entries with multiple items in each entry', () => {
|
||||
const input = [
|
||||
{ id: 1, entries: ['a', 'b'] },
|
||||
{ id: 1, entries: ['c', 'd'] },
|
||||
{ id: 2, entries: ['e'] },
|
||||
];
|
||||
|
||||
const result = aggregate(input, 'id', 'entries');
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0].entries).toEqual(['a', 'b', 'c', 'd']);
|
||||
expect(result[1].entries).toEqual(['e']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('numeric comparator values', () => {
|
||||
it('should correctly compare numeric values', () => {
|
||||
const input = [
|
||||
{ id: 1, entries: ['a'] },
|
||||
{ id: 2, entries: ['b'] },
|
||||
{ id: 1, entries: ['c'] },
|
||||
];
|
||||
|
||||
const result = aggregate(input, 'id', 'entries');
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result.find((r) => r.id === 1).entries).toEqual(['a', 'c']);
|
||||
expect(result.find((r) => r.id === 2).entries).toEqual(['b']);
|
||||
});
|
||||
|
||||
it('should treat 0 as a valid comparator value', () => {
|
||||
const input = [
|
||||
{ id: 0, entries: ['a'] },
|
||||
{ id: 1, entries: ['b'] },
|
||||
{ id: 0, entries: ['c'] },
|
||||
];
|
||||
|
||||
const result = aggregate(input, 'id', 'entries');
|
||||
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result[0].entries).toEqual(['a', 'c']);
|
||||
expect(result[1].entries).toEqual(['b']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('preserving other properties', () => {
|
||||
it('should preserve all properties from the first matching entry', () => {
|
||||
const input = [
|
||||
{ id: 1, name: 'First', extra: 'data1', entries: ['a'] },
|
||||
{ id: 1, name: 'Second', extra: 'data2', entries: ['b'] },
|
||||
];
|
||||
|
||||
const result = aggregate(input, 'id', 'entries');
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].name).toBe('First');
|
||||
expect(result[0].extra).toBe('data1');
|
||||
expect(result[0].entries).toEqual(['a', 'b']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('empty entries arrays', () => {
|
||||
it('should handle empty entries arrays', () => {
|
||||
const input = [
|
||||
{ id: 1, entries: [] },
|
||||
{ id: 1, entries: ['a'] },
|
||||
];
|
||||
|
||||
const result = aggregate(input, 'id', 'entries');
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].entries).toEqual(['a']);
|
||||
});
|
||||
|
||||
it('should handle all empty entries arrays', () => {
|
||||
const input = [
|
||||
{ id: 1, entries: [] },
|
||||
{ id: 1, entries: [] },
|
||||
];
|
||||
|
||||
const result = aggregate(input, 'id', 'entries');
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].entries).toEqual([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -253,28 +253,28 @@ export const getResourceColumns = (resourceColumns: {
|
||||
}) => {
|
||||
const mapColumn =
|
||||
(group: string) =>
|
||||
([fieldKey, { name, importHint, required, order, ...field }]: [
|
||||
string,
|
||||
IModelMetaField2,
|
||||
]) => {
|
||||
const extra: Record<string, any> = {};
|
||||
const key = fieldKey;
|
||||
([fieldKey, { name, importHint, required, order, ...field }]: [
|
||||
string,
|
||||
IModelMetaField2,
|
||||
]) => {
|
||||
const extra: Record<string, any> = {};
|
||||
const key = fieldKey;
|
||||
|
||||
if (group) {
|
||||
extra.group = group;
|
||||
}
|
||||
if (field.fieldType === 'collection') {
|
||||
extra.fields = mapColumns(field.fields, key);
|
||||
}
|
||||
return {
|
||||
key,
|
||||
name,
|
||||
required,
|
||||
hint: importHint,
|
||||
order,
|
||||
...extra,
|
||||
if (group) {
|
||||
extra.group = group;
|
||||
}
|
||||
if (field.fieldType === 'collection') {
|
||||
extra.fields = mapColumns(field.fields, key);
|
||||
}
|
||||
return {
|
||||
key,
|
||||
name,
|
||||
required,
|
||||
hint: importHint,
|
||||
order,
|
||||
...extra,
|
||||
};
|
||||
};
|
||||
};
|
||||
const sortColumn = (a, b) =>
|
||||
a.order && b.order ? a.order - b.order : a.order ? -1 : b.order ? 1 : 0;
|
||||
|
||||
@@ -284,52 +284,54 @@ export const getResourceColumns = (resourceColumns: {
|
||||
return R.compose(transformInputToGroupedFields, mapColumns)(resourceColumns);
|
||||
};
|
||||
|
||||
export type ModelResolver = (modelName: string) => any;
|
||||
|
||||
// Prases the given object value based on the field key type.
|
||||
export const valueParser =
|
||||
(fields: ResourceMetaFieldsMap, tenantModels: any, trx?: Knex.Transaction) =>
|
||||
async (value: any, key: string, group = '') => {
|
||||
let _value = value;
|
||||
(fields: ResourceMetaFieldsMap, modelResolver: ModelResolver, trx?: Knex.Transaction) =>
|
||||
async (value: any, key: string, group = '') => {
|
||||
let _value = value;
|
||||
|
||||
const fieldKey = key.includes('.') ? key.split('.')[0] : key;
|
||||
const field = group ? fields[group]?.fields[fieldKey] : fields[fieldKey];
|
||||
const fieldKey = key.includes('.') ? key.split('.')[0] : key;
|
||||
const field = group ? fields[group]?.fields[fieldKey] : fields[fieldKey];
|
||||
|
||||
// Parses the boolean value.
|
||||
if (field.fieldType === 'boolean') {
|
||||
_value = parseBoolean(value);
|
||||
// Parses the boolean value.
|
||||
if (field.fieldType === 'boolean') {
|
||||
_value = parseBoolean(value);
|
||||
|
||||
// Parses the enumeration value.
|
||||
} else if (field.fieldType === 'enumeration') {
|
||||
const option = get(field, 'options', []).find(
|
||||
(option) => option.label?.toLowerCase() === value?.toLowerCase(),
|
||||
);
|
||||
_value = get(option, 'key');
|
||||
// Parses the numeric value.
|
||||
} else if (field.fieldType === 'number') {
|
||||
_value = multiNumberParse(value);
|
||||
// Parses the relation value.
|
||||
} else if (field.fieldType === 'relation') {
|
||||
const RelationModel = tenantModels[field.relationModel];
|
||||
// Parses the enumeration value.
|
||||
} else if (field.fieldType === 'enumeration') {
|
||||
const option = get(field, 'options', []).find(
|
||||
(option) => option.label?.toLowerCase() === value?.toLowerCase(),
|
||||
);
|
||||
_value = get(option, 'key');
|
||||
// Parses the numeric value.
|
||||
} else if (field.fieldType === 'number') {
|
||||
_value = multiNumberParse(value);
|
||||
// Parses the relation value.
|
||||
} else if (field.fieldType === 'relation') {
|
||||
const RelationModel = modelResolver(field.relationModel);
|
||||
|
||||
if (!RelationModel) {
|
||||
throw new Error(`The relation model of ${key} field is not exist.`);
|
||||
}
|
||||
const relationQuery = RelationModel.query(trx);
|
||||
const relationKeys = castArray(field?.relationImportMatch);
|
||||
if (!RelationModel) {
|
||||
throw new Error(`The relation model of ${key} field is not exist.`);
|
||||
}
|
||||
const relationQuery = RelationModel.query(trx);
|
||||
const relationKeys = castArray(field?.relationImportMatch);
|
||||
|
||||
relationQuery.where(function () {
|
||||
relationKeys.forEach((relationKey: string) => {
|
||||
this.orWhereRaw('LOWER(??) = LOWER(?)', [relationKey, value]);
|
||||
relationQuery.where(function () {
|
||||
relationKeys.forEach((relationKey: string) => {
|
||||
this.orWhereRaw('LOWER(??) = LOWER(?)', [relationKey, value]);
|
||||
});
|
||||
});
|
||||
});
|
||||
const result = await relationQuery.first();
|
||||
_value = get(result, 'id');
|
||||
} else if (field.fieldType === 'collection') {
|
||||
const ObjectFieldKey = key.includes('.') ? key.split('.')[1] : key;
|
||||
const _valueParser = valueParser(fields, tenantModels);
|
||||
_value = await _valueParser(value, ObjectFieldKey, fieldKey);
|
||||
}
|
||||
return _value;
|
||||
};
|
||||
const result = await relationQuery.first();
|
||||
_value = get(result, 'id');
|
||||
} else if (field.fieldType === 'collection') {
|
||||
const ObjectFieldKey = key.includes('.') ? key.split('.')[1] : key;
|
||||
const _valueParser = valueParser(fields, modelResolver);
|
||||
_value = await _valueParser(value, ObjectFieldKey, fieldKey);
|
||||
}
|
||||
return _value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses the field key and detarmines the key path.
|
||||
@@ -402,12 +404,17 @@ export function aggregate(
|
||||
groupOn: string,
|
||||
): Array<Record<string, any>> {
|
||||
return input.reduce((acc, curr) => {
|
||||
// Skip aggregation if the current item doesn't have the comparator attribute
|
||||
if (curr[comparatorAttr] === undefined || curr[comparatorAttr] === null) {
|
||||
acc.push({ ...curr });
|
||||
return acc;
|
||||
}
|
||||
const existingEntry = acc.find(
|
||||
(entry) => entry[comparatorAttr] === curr[comparatorAttr],
|
||||
);
|
||||
|
||||
if (existingEntry) {
|
||||
existingEntry[groupOn].push(...curr.entries);
|
||||
existingEntry[groupOn].push(...curr[groupOn]);
|
||||
} else {
|
||||
acc.push({ ...curr });
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ export class InventoryComputeCostService {
|
||||
*/
|
||||
async scheduleComputeItemCost(itemId: number, startingDate: Date | string) {
|
||||
const debounceKey = `inventory-cost-compute-debounce:${itemId}`;
|
||||
const debounceTime = 1000 * 60; // 1 minute
|
||||
const debounceTime = 1000 * 10; // 10 seconds
|
||||
|
||||
// Generate a unique job ID or use a custom identifier
|
||||
const jobId = `task-${Date.now()}-${Math.random().toString(36).substring(2)}`;
|
||||
|
||||
@@ -2,7 +2,8 @@ import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { Processor, WorkerHost } from '@nestjs/bullmq';
|
||||
import { Scope } from '@nestjs/common';
|
||||
import { Job } from 'bullmq';
|
||||
import { ClsService } from 'nestjs-cls';
|
||||
import { ClsService, UseCls } from 'nestjs-cls';
|
||||
import * as moment from 'moment';
|
||||
import { TenantJobPayload } from '@/interfaces/Tenant';
|
||||
import { InventoryComputeCostService } from '../commands/InventoryComputeCost.service';
|
||||
import { events } from '@/common/events/events';
|
||||
@@ -14,7 +15,7 @@ import { Process } from '@nestjs/bull';
|
||||
|
||||
interface ComputeItemCostJobPayload extends TenantJobPayload {
|
||||
itemId: number;
|
||||
startingDate: Date;
|
||||
startingDate: Date | string;
|
||||
}
|
||||
@Processor({
|
||||
name: ComputeItemCostQueue,
|
||||
@@ -39,28 +40,34 @@ export class ComputeItemCostProcessor extends WorkerHost {
|
||||
* @param {Job<ComputeItemCostJobPayload>} job - The job to process
|
||||
*/
|
||||
@Process(ComputeItemCostQueueJob)
|
||||
@UseCls()
|
||||
async process(job: Job<ComputeItemCostJobPayload>) {
|
||||
const { itemId, startingDate, organizationId, userId } = job.data;
|
||||
|
||||
console.log(`Compute item cost for item ${itemId} started`);
|
||||
// Parse startingDate using moment to handle both Date and string formats
|
||||
const startingDateObj = moment(startingDate).toDate();
|
||||
|
||||
console.log(`[info] Compute item cost for item ${itemId} started`, {
|
||||
payload: job.data,
|
||||
jobId: job.id
|
||||
});
|
||||
this.clsService.set('organizationId', organizationId);
|
||||
this.clsService.set('userId', userId);
|
||||
|
||||
try {
|
||||
await this.inventoryComputeCostService.computeItemCost(
|
||||
startingDate,
|
||||
startingDateObj,
|
||||
itemId,
|
||||
);
|
||||
// Emit job completed event
|
||||
await this.eventEmitter.emitAsync(
|
||||
events.inventory.onComputeItemCostJobCompleted,
|
||||
{ startingDate, itemId, organizationId, userId },
|
||||
{ startingDate: startingDateObj, itemId, organizationId, userId },
|
||||
);
|
||||
|
||||
console.log(`Compute item cost for item ${itemId} completed`);
|
||||
console.log(`[info] Compute item cost for item ${itemId} completed successfully`);
|
||||
} catch (error) {
|
||||
console.error('Error computing item cost:', error);
|
||||
console.error(`[error] Error computing item cost for item ${itemId}:`, error);
|
||||
console.error('Error stack:', error instanceof Error ? error.stack : 'No stack trace');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,28 +267,28 @@ export const ItemMeta = {
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Account',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
importHint: 'Matches the account name or code.',
|
||||
importHint: 'account.field.account_hint',
|
||||
},
|
||||
sellAccountId: {
|
||||
name: 'item.field.sell_account',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Account',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
importHint: 'Matches the account name or code.',
|
||||
importHint: 'account.field.account_hint',
|
||||
},
|
||||
inventoryAccountId: {
|
||||
name: 'item.field.inventory_account',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Account',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
importHint: 'Matches the account name or code.',
|
||||
importHint: 'account.field.account_hint',
|
||||
},
|
||||
sellDescription: {
|
||||
name: 'Sell Description',
|
||||
name: 'item.field.sell_description',
|
||||
fieldType: 'text',
|
||||
},
|
||||
purchaseDescription: {
|
||||
name: 'Purchase Description',
|
||||
name: 'item.field.purchase_description',
|
||||
fieldType: 'text',
|
||||
},
|
||||
note: {
|
||||
@@ -300,7 +300,7 @@ export const ItemMeta = {
|
||||
fieldType: 'relation',
|
||||
relationModel: 'ItemCategory',
|
||||
relationImportMatch: ['name'],
|
||||
importHint: 'Matches the category name.',
|
||||
importHint: 'item.field.category_hint',
|
||||
},
|
||||
active: {
|
||||
name: 'item.field.active',
|
||||
|
||||
@@ -74,6 +74,9 @@ export class PaymentReceivedResponseDto {
|
||||
@ApiProperty({ description: 'The formatted amount', example: '100.00' })
|
||||
formattedAmount: string;
|
||||
|
||||
@ApiProperty({ description: 'The formatted total', example: '100.00 USD' })
|
||||
formattedTotal: string;
|
||||
|
||||
@ApiProperty({ description: 'The currency code', example: 'USD' })
|
||||
currencyCode: string;
|
||||
|
||||
|
||||
@@ -165,12 +165,12 @@ export const PaymentReceivedMeta = {
|
||||
relationModel: 'Account',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
required: true,
|
||||
importHint: 'Matches the account name or code.',
|
||||
importHint: 'account.field.account_hint',
|
||||
},
|
||||
paymentReceiveNo: {
|
||||
name: 'payment_receive.field.payment_receive_no',
|
||||
fieldType: 'text',
|
||||
importHint: 'The payment number should be unique.',
|
||||
importHint: 'payment_receive.field.payment_no_hint',
|
||||
},
|
||||
statement: {
|
||||
name: 'payment_receive.field.statement',
|
||||
@@ -189,7 +189,7 @@ export const PaymentReceivedMeta = {
|
||||
relationModel: 'SaleInvoice',
|
||||
relationImportMatch: 'invoiceNo',
|
||||
required: true,
|
||||
importHint: 'Matches the invoice number.',
|
||||
importHint: 'payment_receive.field.invoice_hint',
|
||||
},
|
||||
paymentAmount: {
|
||||
name: 'payment_receive.field.entries.payment_amount',
|
||||
@@ -199,7 +199,7 @@ export const PaymentReceivedMeta = {
|
||||
},
|
||||
},
|
||||
branchId: {
|
||||
name: 'Branch',
|
||||
name: 'invoice.field.branch',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Branch',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
|
||||
@@ -11,6 +11,7 @@ export class PaymentReceiveTransfromer extends Transformer {
|
||||
public includeAttributes = (): string[] => {
|
||||
return [
|
||||
'subtotalFormatted',
|
||||
'formatttedTotal',
|
||||
'formattedPaymentDate',
|
||||
'formattedCreatedAt',
|
||||
'formattedAmount',
|
||||
@@ -45,7 +46,18 @@ export class PaymentReceiveTransfromer extends Transformer {
|
||||
protected subtotalFormatted = (payment: PaymentReceived): string => {
|
||||
return this.formatNumber(payment.amount, {
|
||||
currencyCode: payment.currencyCode,
|
||||
money: false,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the formatted total.
|
||||
* @param {PaymentReceived} payment
|
||||
* @returns {string}
|
||||
*/
|
||||
protected formatttedTotal = (payment: PaymentReceived): string => {
|
||||
return this.formatNumber(payment.amount, {
|
||||
currencyCode: payment.currencyCode,
|
||||
money: true,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -66,7 +78,7 @@ export class PaymentReceiveTransfromer extends Transformer {
|
||||
* @returns {string}
|
||||
*/
|
||||
protected formattedExchangeRate = (payment: PaymentReceived): string => {
|
||||
return this.formatNumber(payment.exchangeRate, { money: false });
|
||||
return this.formatNumber(payment.exchangeRate);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ModuleRef } from '@nestjs/core';
|
||||
import { pickBy } from 'lodash';
|
||||
import { pickBy, mapValues } from 'lodash';
|
||||
import { I18nService } from 'nestjs-i18n';
|
||||
import { WarehousesSettings } from '../Warehouses/WarehousesSettings';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { BranchesSettingsService } from '../Branches/BranchesSettings';
|
||||
@@ -20,7 +21,8 @@ export class ResourceService {
|
||||
private readonly branchesSettings: BranchesSettingsService,
|
||||
private readonly warehousesSettings: WarehousesSettings,
|
||||
private readonly moduleRef: ModuleRef,
|
||||
) {}
|
||||
private readonly i18nService: I18nService,
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Retrieve resource model object.
|
||||
@@ -96,7 +98,45 @@ export class ResourceService {
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve the resource fields.
|
||||
* Localizes a single field by translating its name and importHint.
|
||||
* @param {IModelMetaField2} field - The field to localize.
|
||||
* @returns {IModelMetaField2} - The localized field.
|
||||
*/
|
||||
private localizeField(field: IModelMetaField2): IModelMetaField2 {
|
||||
const localizedField = {
|
||||
...field,
|
||||
name: this.i18nService.t(field.name, { defaultValue: field.name }),
|
||||
} as IModelMetaField2;
|
||||
|
||||
if (field.importHint) {
|
||||
localizedField.importHint = this.i18nService.t(field.importHint, {
|
||||
defaultValue: field.importHint,
|
||||
});
|
||||
}
|
||||
|
||||
// Recursively localize nested fields (for collection types)
|
||||
if (field.fields) {
|
||||
localizedField.fields = this.localizeFields(
|
||||
field.fields as unknown as Record<string, IModelMetaField2>,
|
||||
) as unknown as typeof field.fields;
|
||||
}
|
||||
|
||||
return localizedField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Localizes all fields in a fields map.
|
||||
* @param {Record<string, IModelMetaField2>} fields - The fields to localize.
|
||||
* @returns {Record<string, IModelMetaField2>} - The localized fields.
|
||||
*/
|
||||
private localizeFields(
|
||||
fields: Record<string, IModelMetaField2>,
|
||||
): Record<string, IModelMetaField2> {
|
||||
return mapValues(fields, (field) => this.localizeField(field));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the resource fields with localized names and hints.
|
||||
* @param {string} modelName
|
||||
* @returns {IModelMetaField2}
|
||||
*/
|
||||
@@ -104,8 +144,11 @@ export class ResourceService {
|
||||
[key: string]: IModelMetaField2;
|
||||
} {
|
||||
const meta = this.getResourceMeta(modelName);
|
||||
const filteredFields = this.filterSupportFeatures(meta.fields2);
|
||||
|
||||
return this.filterSupportFeatures(meta.fields2);
|
||||
return this.localizeFields(
|
||||
filteredFields as Record<string, IModelMetaField2>,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -191,52 +191,52 @@ export const SaleEstimateMeta = {
|
||||
},
|
||||
fields2: {
|
||||
customerId: {
|
||||
name: 'Customer',
|
||||
name: 'estimate.field.customer',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Contact',
|
||||
relationImportMatch: ['displayName'],
|
||||
required: true,
|
||||
},
|
||||
estimateDate: {
|
||||
name: 'Estimate Date',
|
||||
name: 'estimate.field.estimate_date',
|
||||
fieldType: 'date',
|
||||
required: true,
|
||||
},
|
||||
expirationDate: {
|
||||
name: 'Expiration Date',
|
||||
name: 'estimate.field.expiration_date',
|
||||
fieldType: 'date',
|
||||
required: true,
|
||||
},
|
||||
estimateNumber: {
|
||||
name: 'Estimate No.',
|
||||
name: 'estimate.field.estimate_number',
|
||||
fieldType: 'text',
|
||||
},
|
||||
reference: {
|
||||
name: 'Reference No.',
|
||||
name: 'estimate.field.reference_no',
|
||||
fieldType: 'text',
|
||||
},
|
||||
exchangeRate: {
|
||||
name: 'Exchange Rate',
|
||||
name: 'estimate.field.exchange_rate',
|
||||
fieldType: 'number',
|
||||
},
|
||||
currencyCode: {
|
||||
name: 'Currency',
|
||||
name: 'estimate.field.currency',
|
||||
fieldType: 'text',
|
||||
},
|
||||
note: {
|
||||
name: 'Note',
|
||||
name: 'estimate.field.note',
|
||||
fieldType: 'text',
|
||||
},
|
||||
termsConditions: {
|
||||
name: 'Terms & Conditions',
|
||||
name: 'estimate.field.terms_conditions',
|
||||
fieldType: 'text',
|
||||
},
|
||||
delivered: {
|
||||
name: 'Delivered',
|
||||
name: 'estimate.field.delivered',
|
||||
type: 'boolean',
|
||||
},
|
||||
entries: {
|
||||
name: 'Entries',
|
||||
name: 'estimate.field.entries',
|
||||
fieldType: 'collection',
|
||||
collectionOf: 'object',
|
||||
collectionMinLength: 1,
|
||||
@@ -248,7 +248,7 @@ export const SaleEstimateMeta = {
|
||||
relationModel: 'Item',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
required: true,
|
||||
importHint: 'Matches the item name or code.',
|
||||
importHint: 'invoice.field.item_hint',
|
||||
},
|
||||
rate: {
|
||||
name: 'invoice.field.rate',
|
||||
@@ -261,13 +261,13 @@ export const SaleEstimateMeta = {
|
||||
required: true,
|
||||
},
|
||||
description: {
|
||||
name: 'Line Description',
|
||||
name: 'invoice.field.description',
|
||||
fieldType: 'text',
|
||||
},
|
||||
},
|
||||
},
|
||||
branchId: {
|
||||
name: 'Branch',
|
||||
name: 'invoice.field.branch',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Branch',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
@@ -275,7 +275,7 @@ export const SaleEstimateMeta = {
|
||||
required: true,
|
||||
},
|
||||
warehouseId: {
|
||||
name: 'Warehouse',
|
||||
name: 'invoice.field.warehouse',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Warehouse',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
|
||||
@@ -17,7 +17,7 @@ export class SaleEstimateTransfromer extends Transformer {
|
||||
'formattedDeliveredAtDate',
|
||||
'formattedApprovedAtDate',
|
||||
'formattedRejectedAtDate',
|
||||
|
||||
|
||||
'discountAmountFormatted',
|
||||
'discountPercentageFormatted',
|
||||
'adjustmentFormatted',
|
||||
@@ -135,7 +135,7 @@ export class SaleEstimateTransfromer extends Transformer {
|
||||
* @returns {string}
|
||||
*/
|
||||
protected adjustmentFormatted = (estimate: SaleEstimate): string => {
|
||||
return this.formatMoney(estimate.adjustment, {
|
||||
return this.formatNumber(estimate.adjustment, {
|
||||
currencyCode: estimate.currencyCode,
|
||||
excerptZero: true,
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@ export class SaleInvoiceCostGLEntries {
|
||||
private readonly inventoryCostLotTracker: TenantModelProxy<
|
||||
typeof InventoryCostLotTracker
|
||||
>,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Writes journal entries from sales invoices.
|
||||
|
||||
@@ -5,10 +5,10 @@ import { Importable } from '@/modules/Import/Importable';
|
||||
import { CreateSaleInvoiceDto } from '../dtos/SaleInvoice.dto';
|
||||
import { SaleInvoicesSampleData } from '../constants';
|
||||
import { ImportableService } from '@/modules/Import/decorators/Import.decorator';
|
||||
import { ManualJournal } from '@/modules/ManualJournals/models/ManualJournal';
|
||||
import { SaleInvoice } from '../models/SaleInvoice';
|
||||
|
||||
@Injectable()
|
||||
@ImportableService({ name: ManualJournal.name })
|
||||
@ImportableService({ name: SaleInvoice.name })
|
||||
export class SaleInvoicesImportable extends Importable {
|
||||
constructor(private readonly createInvoiceService: CreateSaleInvoice) {
|
||||
super();
|
||||
|
||||
@@ -259,7 +259,7 @@ export const SaleInvoiceMeta = {
|
||||
relationModel: 'Item',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
required: true,
|
||||
importHint: 'Matches the item name or code.',
|
||||
importHint: 'invoice.field.item_hint',
|
||||
},
|
||||
rate: {
|
||||
name: 'invoice.field.rate',
|
||||
@@ -283,7 +283,7 @@ export const SaleInvoiceMeta = {
|
||||
printable: false,
|
||||
},
|
||||
branchId: {
|
||||
name: 'Branch',
|
||||
name: 'invoice.field.branch',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Branch',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
@@ -291,7 +291,7 @@ export const SaleInvoiceMeta = {
|
||||
required: true,
|
||||
},
|
||||
warehouseId: {
|
||||
name: 'Warehouse',
|
||||
name: 'invoice.field.warehouse',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Warehouse',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
|
||||
@@ -70,6 +70,7 @@ export class SaleInvoiceTransformer extends Transformer {
|
||||
protected dueAmountFormatted = (invoice: SaleInvoice): string => {
|
||||
return this.formatNumber(invoice.dueAmount, {
|
||||
currencyCode: invoice.currencyCode,
|
||||
money: true
|
||||
});
|
||||
};
|
||||
|
||||
@@ -113,7 +114,6 @@ export class SaleInvoiceTransformer extends Transformer {
|
||||
protected subtotalFormatted = (invoice: SaleInvoice): string => {
|
||||
return this.formatNumber(invoice.subtotal, {
|
||||
currencyCode: this.context.organization.baseCurrency,
|
||||
money: false,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -170,6 +170,7 @@ export class SaleInvoiceTransformer extends Transformer {
|
||||
protected totalFormatted = (invoice: SaleInvoice): string => {
|
||||
return this.formatNumber(invoice.total, {
|
||||
currencyCode: invoice.currencyCode,
|
||||
money: true
|
||||
});
|
||||
};
|
||||
|
||||
@@ -212,7 +213,7 @@ export class SaleInvoiceTransformer extends Transformer {
|
||||
* @returns {string}
|
||||
*/
|
||||
protected adjustmentFormatted = (invoice: SaleInvoice): string => {
|
||||
return this.formatMoney(invoice.adjustment, {
|
||||
return this.formatNumber(invoice.adjustment, {
|
||||
currencyCode: invoice.currencyCode,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import { events } from '@/common/events/events';
|
||||
|
||||
@Injectable()
|
||||
export class InvoiceGLEntriesSubscriber {
|
||||
constructor(public readonly saleInvoiceGLEntries: SaleInvoiceGLEntries) {}
|
||||
constructor(public readonly saleInvoiceGLEntries: SaleInvoiceGLEntries) { }
|
||||
|
||||
/**
|
||||
* Records journal entries of the non-inventory invoice.
|
||||
|
||||
@@ -186,42 +186,42 @@ export const SaleReceiptMeta = {
|
||||
},
|
||||
fields2: {
|
||||
receiptDate: {
|
||||
name: 'Receipt Date',
|
||||
name: 'receipt.field.receipt_date',
|
||||
fieldType: 'date',
|
||||
required: true,
|
||||
},
|
||||
customerId: {
|
||||
name: 'Customer',
|
||||
name: 'receipt.field.customer',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Contact',
|
||||
relationImportMatch: 'displayName',
|
||||
required: true,
|
||||
},
|
||||
depositAccountId: {
|
||||
name: 'Deposit Account',
|
||||
name: 'receipt.field.deposit_account',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Account',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
required: true,
|
||||
},
|
||||
exchangeRate: {
|
||||
name: 'Exchange Rate',
|
||||
name: 'receipt.field.exchange_rate',
|
||||
fieldType: 'number',
|
||||
},
|
||||
receiptNumber: {
|
||||
name: 'Receipt Number',
|
||||
name: 'receipt.field.receipt_number',
|
||||
fieldType: 'text',
|
||||
},
|
||||
referenceNo: {
|
||||
name: 'Reference No.',
|
||||
name: 'receipt.field.reference_no',
|
||||
fieldType: 'text',
|
||||
},
|
||||
closed: {
|
||||
name: 'Closed',
|
||||
name: 'receipt.field.closed',
|
||||
fieldType: 'boolean',
|
||||
},
|
||||
entries: {
|
||||
name: 'Entries',
|
||||
name: 'receipt.field.entries',
|
||||
fieldType: 'collection',
|
||||
collectionOf: 'object',
|
||||
collectionMinLength: 1,
|
||||
@@ -233,7 +233,7 @@ export const SaleReceiptMeta = {
|
||||
relationModel: 'Item',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
required: true,
|
||||
importHint: 'Matches the item name or code.',
|
||||
importHint: 'invoice.field.item_hint',
|
||||
},
|
||||
rate: {
|
||||
name: 'invoice.field.rate',
|
||||
@@ -252,15 +252,15 @@ export const SaleReceiptMeta = {
|
||||
},
|
||||
},
|
||||
statement: {
|
||||
name: 'Statement',
|
||||
name: 'receipt.field.statement',
|
||||
fieldType: 'text',
|
||||
},
|
||||
receiptMessage: {
|
||||
name: 'Receipt Message',
|
||||
name: 'receipt.field.receipt_message',
|
||||
fieldType: 'text',
|
||||
},
|
||||
branchId: {
|
||||
name: 'Branch',
|
||||
name: 'invoice.field.branch',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Branch',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
@@ -268,7 +268,7 @@ export const SaleReceiptMeta = {
|
||||
required: true,
|
||||
},
|
||||
warehouseId: {
|
||||
name: 'Warehouse',
|
||||
name: 'invoice.field.warehouse',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Warehouse',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
|
||||
@@ -107,4 +107,4 @@ const modelProviders = models.map((model) => RegisterTenancyModel(model));
|
||||
imports: [...modelProviders],
|
||||
exports: [...modelProviders],
|
||||
})
|
||||
export class TenancyModelsModule {}
|
||||
export class TenancyModelsModule { }
|
||||
|
||||
@@ -26,7 +26,7 @@ export class TransactionsLockingService {
|
||||
constructor(
|
||||
private readonly transactionsLockingRepo: TransactionsLockingRepository,
|
||||
private readonly eventPublisher: EventEmitter2,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Enable/disable all transacations locking.
|
||||
|
||||
@@ -203,6 +203,7 @@ export class Transformer<T = {}, ExtraContext = {}> {
|
||||
protected formatMoney(money, options?) {
|
||||
return formatNumber(money, {
|
||||
currencyCode: this.context.organization.baseCurrency,
|
||||
money: true,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -177,70 +177,70 @@ export const VendorCreditMeta = {
|
||||
},
|
||||
fields2: {
|
||||
vendorId: {
|
||||
name: 'Vendor',
|
||||
name: 'vendor_credit.field.vendor',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Contact',
|
||||
relationImportMatch: 'displayName',
|
||||
required: true,
|
||||
},
|
||||
exchangeRate: {
|
||||
name: 'Echange Rate',
|
||||
name: 'vendor_credit.field.exchange_rate',
|
||||
fieldType: 'text',
|
||||
},
|
||||
vendorCreditNumber: {
|
||||
name: 'Vendor Credit No.',
|
||||
name: 'vendor_credit.field.vendor_credit_number',
|
||||
fieldType: 'text',
|
||||
},
|
||||
referenceNo: {
|
||||
name: 'Refernece No.',
|
||||
name: 'vendor_credit.field.reference_no',
|
||||
fieldType: 'text',
|
||||
},
|
||||
vendorCreditDate: {
|
||||
name: 'Vendor Credit Date',
|
||||
name: 'vendor_credit.field.vendor_credit_date',
|
||||
fieldType: 'date',
|
||||
required: true,
|
||||
},
|
||||
note: {
|
||||
name: 'Note',
|
||||
name: 'vendor_credit.field.note',
|
||||
fieldType: 'text',
|
||||
},
|
||||
open: {
|
||||
name: 'Open',
|
||||
name: 'vendor_credit.field.open',
|
||||
fieldType: 'boolean',
|
||||
},
|
||||
entries: {
|
||||
name: 'Entries',
|
||||
name: 'vendor_credit.field.entries',
|
||||
fieldType: 'collection',
|
||||
collectionOf: 'object',
|
||||
collectionMinLength: 1,
|
||||
required: true,
|
||||
fields: {
|
||||
itemId: {
|
||||
name: 'Item Name',
|
||||
name: 'vendor_credit.field.item',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Item',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
required: true,
|
||||
importHint: 'Matches the item name or code.',
|
||||
importHint: 'invoice.field.item_hint',
|
||||
},
|
||||
rate: {
|
||||
name: 'Rate',
|
||||
name: 'vendor_credit.field.rate',
|
||||
fieldType: 'number',
|
||||
required: true,
|
||||
},
|
||||
quantity: {
|
||||
name: 'Quantity',
|
||||
name: 'vendor_credit.field.quantity',
|
||||
fieldType: 'number',
|
||||
required: true,
|
||||
},
|
||||
description: {
|
||||
name: 'Description',
|
||||
name: 'vendor_credit.field.description',
|
||||
fieldType: 'text',
|
||||
},
|
||||
},
|
||||
},
|
||||
branchId: {
|
||||
name: 'Branch',
|
||||
name: 'invoice.field.branch',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Branch',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
@@ -248,7 +248,7 @@ export const VendorCreditMeta = {
|
||||
required: true
|
||||
},
|
||||
warehouseId: {
|
||||
name: 'Warehouse',
|
||||
name: 'invoice.field.warehouse',
|
||||
fieldType: 'relation',
|
||||
relationModel: 'Warehouse',
|
||||
relationImportMatch: ['name', 'code'],
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"@bigcapital/utils": "*",
|
||||
"@blueprintjs-formik/core": "^0.3.7",
|
||||
"@blueprintjs-formik/datetime": "^0.4.0",
|
||||
"@blueprintjs-formik/select": "^0.3.5",
|
||||
"@blueprintjs-formik/select": "^0.4.5",
|
||||
"@blueprintjs/colors": "4.1.19",
|
||||
"@blueprintjs/core": "^4.20.2",
|
||||
"@blueprintjs/datetime": "^4.4.37",
|
||||
|
||||
@@ -96,7 +96,7 @@ export function AccountsMultiSelect({
|
||||
};
|
||||
|
||||
return (
|
||||
<FMultiSelect<AccountSelect>
|
||||
<FMultiSelect
|
||||
{...rest}
|
||||
items={filteredAccounts}
|
||||
valueAccessor={'id'}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { MenuItem } from '@blueprintjs/core';
|
||||
import { MenuItemNestedText, FSelect } from '@/components';
|
||||
import { accountPredicate } from './_components';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import { withDialogActions } from '@/containers/Dialog/withDialogActions';
|
||||
import { usePreprocessingAccounts } from './_hooks';
|
||||
|
||||
// Create new account renderer.
|
||||
|
||||
@@ -1,23 +1,34 @@
|
||||
// @ts-nocheck
|
||||
import React, { useCallback, useMemo } from 'react';
|
||||
import * as R from 'ramda';
|
||||
import React, { useCallback, ComponentType } from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import classNames from 'classnames';
|
||||
import { MenuItem } from '@blueprintjs/core';
|
||||
|
||||
import { CLASSES } from '@/constants/classes';
|
||||
import { ItemRenderer, ItemPredicate } from '@blueprintjs/select';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
import { FSuggest, Suggest, FormattedMessage as T } from '@/components';
|
||||
import { withDialogActions } from '@/containers/Dialog/withDialogActions';
|
||||
import { usePreprocessingAccounts } from './_hooks';
|
||||
|
||||
import {
|
||||
FSuggest,
|
||||
MenuItemNestedText,
|
||||
FormattedMessage as T,
|
||||
} from '@/components';
|
||||
import { nestedArrayToflatten, filterAccountsByQuery } from '@/utils';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
// Account interface
|
||||
interface Account {
|
||||
id: number;
|
||||
name: string;
|
||||
code: string;
|
||||
account_level?: number;
|
||||
account_type?: string;
|
||||
account_parent_type?: string;
|
||||
account_root_type?: string;
|
||||
account_normal?: string;
|
||||
}
|
||||
|
||||
// Types for renderers and predicates
|
||||
type AccountItemRenderer = ItemRenderer<Account>;
|
||||
type AccountItemPredicate = ItemPredicate<Account>;
|
||||
|
||||
// Create new account renderer.
|
||||
const createNewItemRenderer = (query, active, handleClick) => {
|
||||
const createNewItemRenderer = (
|
||||
query: string,
|
||||
active: boolean,
|
||||
handleClick: (event: React.MouseEvent<HTMLElement>) => void,
|
||||
): React.ReactElement => {
|
||||
return (
|
||||
<MenuItem
|
||||
icon="add"
|
||||
@@ -29,12 +40,17 @@ const createNewItemRenderer = (query, active, handleClick) => {
|
||||
};
|
||||
|
||||
// Create new item from the given query string.
|
||||
const createNewItemFromQuery = (name) => {
|
||||
const createNewItemFromQuery = (name: string): Partial<Account> => {
|
||||
return { name };
|
||||
};
|
||||
|
||||
// Filters accounts items.
|
||||
const filterAccountsPredicater = (query, account, _index, exactMatch) => {
|
||||
const filterAccountsPredicater: AccountItemPredicate = (
|
||||
query: string,
|
||||
account: Account,
|
||||
_index?: number,
|
||||
exactMatch?: boolean,
|
||||
): boolean => {
|
||||
const normalizedTitle = account.name.toLowerCase();
|
||||
const normalizedQuery = query.toLowerCase();
|
||||
|
||||
@@ -45,77 +61,139 @@ const filterAccountsPredicater = (query, account, _index, exactMatch) => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Accounts suggest field.
|
||||
*/
|
||||
function AccountsSuggestFieldRoot({
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
|
||||
// #ownProps
|
||||
accounts,
|
||||
defaultSelectText = intl.formatMessage({ id: 'select_account' }),
|
||||
|
||||
filterByParentTypes = [],
|
||||
filterByTypes = [],
|
||||
filterByNormal,
|
||||
filterByRootTypes = [],
|
||||
|
||||
allowCreate,
|
||||
|
||||
...suggestProps
|
||||
}) {
|
||||
const flattenAccounts = useMemo(
|
||||
() => nestedArrayToflatten(accounts),
|
||||
[accounts],
|
||||
);
|
||||
const filteredAccounts = useMemo(
|
||||
() =>
|
||||
filterAccountsByQuery(flattenAccounts, {
|
||||
filterByParentTypes,
|
||||
filterByTypes,
|
||||
filterByNormal,
|
||||
filterByRootTypes,
|
||||
}),
|
||||
[
|
||||
flattenAccounts,
|
||||
filterByParentTypes,
|
||||
filterByTypes,
|
||||
filterByNormal,
|
||||
filterByRootTypes,
|
||||
],
|
||||
);
|
||||
const handleCreateItemSelect = useCallback(
|
||||
(item) => {
|
||||
if (!item.id) {
|
||||
openDialog(DialogsName.AccountForm);
|
||||
}
|
||||
},
|
||||
[openDialog],
|
||||
);
|
||||
// Maybe inject new item props to select component.
|
||||
const maybeCreateNewItemRenderer = allowCreate ? createNewItemRenderer : null;
|
||||
const maybeCreateNewItemFromQuery = allowCreate
|
||||
? createNewItemFromQuery
|
||||
: null;
|
||||
|
||||
// Account item renderer for Suggest (non-Formik)
|
||||
const accountItemRenderer: AccountItemRenderer = (
|
||||
item: Account,
|
||||
{ handleClick, modifiers },
|
||||
): React.ReactElement | null => {
|
||||
if (!modifiers.matchesPredicate) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<FSuggest
|
||||
items={filteredAccounts}
|
||||
onCreateItemSelect={handleCreateItemSelect}
|
||||
valueAccessor="id"
|
||||
textAccessor="name"
|
||||
labelAccessor="code"
|
||||
inputProps={{ placeholder: defaultSelectText }}
|
||||
resetOnClose
|
||||
popoverProps={{ minimal: true, boundary: 'window' }}
|
||||
createNewItemRenderer={maybeCreateNewItemRenderer}
|
||||
createNewItemFromQuery={maybeCreateNewItemFromQuery}
|
||||
{...suggestProps}
|
||||
<MenuItem
|
||||
active={modifiers.active}
|
||||
disabled={modifiers.disabled}
|
||||
label={item.code}
|
||||
key={item.id}
|
||||
text={item.name}
|
||||
onClick={handleClick}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
// Input value renderer for Suggest (non-Formik)
|
||||
const inputValueRenderer = (item: Account | null): string => {
|
||||
if (item) {
|
||||
return item.name || '';
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
// Props specific to the HOC (excluding component's own props)
|
||||
interface AccountsSuggestFieldOwnProps {
|
||||
// #withDialogActions
|
||||
openDialog: (name: string, payload?: any) => void;
|
||||
|
||||
// #ownProps
|
||||
items: Account[];
|
||||
defaultSelectText?: string;
|
||||
filterByParentTypes?: string[];
|
||||
filterByTypes?: string[];
|
||||
filterByNormal?: string;
|
||||
filterByRootTypes?: string[];
|
||||
allowCreate?: boolean;
|
||||
}
|
||||
|
||||
export const AccountsSuggestField = R.compose(withDialogActions)(
|
||||
AccountsSuggestFieldRoot,
|
||||
// Props that the HOC provides to the wrapped component (should be omitted from external props)
|
||||
type ProvidedSuggestProps =
|
||||
| 'items'
|
||||
| 'itemPredicate'
|
||||
| 'onCreateItemSelect'
|
||||
| 'valueAccessor'
|
||||
| 'textAccessor'
|
||||
| 'labelAccessor'
|
||||
| 'resetOnClose'
|
||||
| 'createNewItemRenderer'
|
||||
| 'createNewItemFromQuery';
|
||||
|
||||
// Utility type to extract props from a component
|
||||
type ComponentProps<C> = C extends ComponentType<infer P> ? P : never;
|
||||
|
||||
/**
|
||||
* HOC for Accounts Suggest Field logic.
|
||||
* Returns a component that accepts the wrapped component's props minus the ones provided by the HOC.
|
||||
*/
|
||||
function withAccountsSuggestFieldLogic<C extends ComponentType<any>>(
|
||||
Component: C,
|
||||
): ComponentType<
|
||||
AccountsSuggestFieldOwnProps & Omit<ComponentProps<C>, ProvidedSuggestProps>
|
||||
> {
|
||||
return function AccountsSuggestFieldLogic({
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
|
||||
// #ownProps
|
||||
items,
|
||||
defaultSelectText = intl.formatMessage({ id: 'select_account' }),
|
||||
|
||||
filterByParentTypes = [],
|
||||
filterByTypes = [],
|
||||
filterByNormal,
|
||||
filterByRootTypes = [],
|
||||
|
||||
allowCreate,
|
||||
|
||||
// SuggestProps - props that will be passed to Suggest/FSuggest
|
||||
...suggestProps
|
||||
}: AccountsSuggestFieldOwnProps &
|
||||
Omit<ComponentProps<C>, ProvidedSuggestProps>) {
|
||||
const filteredAccounts = usePreprocessingAccounts(items, {
|
||||
filterByParentTypes,
|
||||
filterByTypes,
|
||||
filterByNormal: filterByNormal ? [filterByNormal] : [],
|
||||
filterByRootTypes,
|
||||
});
|
||||
const handleCreateItemSelect = useCallback(
|
||||
(item: Account | Partial<Account>) => {
|
||||
if (!('id' in item) || !item.id) {
|
||||
openDialog(DialogsName.AccountForm);
|
||||
}
|
||||
},
|
||||
[openDialog],
|
||||
);
|
||||
// Maybe inject new item props to select component.
|
||||
const maybeCreateNewItemRenderer = allowCreate
|
||||
? createNewItemRenderer
|
||||
: undefined;
|
||||
const maybeCreateNewItemFromQuery = allowCreate
|
||||
? createNewItemFromQuery
|
||||
: undefined;
|
||||
|
||||
// Build the SuggestProps to pass to the component
|
||||
const processedSuggestProps = {
|
||||
items: filteredAccounts,
|
||||
itemPredicate: filterAccountsPredicater,
|
||||
onCreateItemSelect: handleCreateItemSelect,
|
||||
valueAccessor: 'id' as const,
|
||||
textAccessor: 'name' as const,
|
||||
labelAccessor: 'code' as const,
|
||||
inputProps: { placeholder: defaultSelectText },
|
||||
resetOnClose: true,
|
||||
popoverProps: { minimal: true, boundary: 'window' as const },
|
||||
createNewItemRenderer: maybeCreateNewItemRenderer,
|
||||
createNewItemFromQuery: maybeCreateNewItemFromQuery,
|
||||
...suggestProps,
|
||||
} as ComponentProps<C>;
|
||||
|
||||
return <Component {...processedSuggestProps} />;
|
||||
};
|
||||
}
|
||||
const AccountsSuggestFieldWithLogic = withAccountsSuggestFieldLogic(Suggest);
|
||||
const FAccountsSuggestFieldWithLogic = withAccountsSuggestFieldLogic(FSuggest);
|
||||
|
||||
export const AccountsSuggestField = withDialogActions(
|
||||
AccountsSuggestFieldWithLogic,
|
||||
);
|
||||
export const FAccountsSuggestField = withDialogActions(
|
||||
FAccountsSuggestFieldWithLogic,
|
||||
);
|
||||
|
||||
@@ -11,7 +11,7 @@ import { AppIntlProvider } from './AppIntlProvider';
|
||||
import { useSplashLoading } from '@/hooks/state';
|
||||
|
||||
import { useWatchImmediate } from '../hooks';
|
||||
import withDashboardActions from '@/containers/Dashboard/withDashboardActions';
|
||||
import { withDashboardActions } from '@/containers/Dashboard/withDashboardActions';
|
||||
|
||||
const SUPPORTED_LOCALES = [
|
||||
{ name: 'English', value: 'en' },
|
||||
|
||||
@@ -20,12 +20,3 @@ export function BranchSelect({ branches, ...rest }) {
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} param0
|
||||
* @returns
|
||||
*/
|
||||
export function BranchSelectButton({ label, ...rest }) {
|
||||
return <Button text={label} {...rest} />;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import React, { useCallback } from 'react';
|
||||
import * as R from 'ramda';
|
||||
import { FMultiSelect } from '../Forms';
|
||||
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
|
||||
import { withDrawerActions } from '@/containers/Drawer/withDrawerActions';
|
||||
import { DRAWERS } from '@/constants/drawers';
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@ import React from 'react';
|
||||
import * as R from 'ramda';
|
||||
|
||||
import { ButtonLink } from '../Button';
|
||||
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
|
||||
import { withDrawerActions } from '@/containers/Drawer/withDrawerActions';
|
||||
import { DRAWERS } from '@/constants/drawers';
|
||||
|
||||
function CustomerDrawerLinkComponent({
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as R from 'ramda';
|
||||
import { useFormikContext } from 'formik';
|
||||
import { createNewItemFromQuery, createNewItemRenderer } from './utils';
|
||||
import { FSelect } from '../Forms';
|
||||
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
|
||||
import { withDrawerActions } from '@/containers/Drawer/withDrawerActions';
|
||||
import { useCreateAutofillListener } from '@/hooks/state/autofill';
|
||||
import { DRAWERS } from '@/constants/drawers';
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useHistory } from 'react-router-dom';
|
||||
|
||||
import { If, Icon } from '@/components';
|
||||
import { FormattedMessage as T } from '@/components';
|
||||
import withDashboard from '@/containers/Dashboard/withDashboard';
|
||||
import { withDashboard } from '@/containers/Dashboard/withDashboard';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
function DashboardBackLink({ dashboardBackLink, breadcrumbs }) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// @ts-nocheck
|
||||
import React, { useEffect, Suspense } from 'react';
|
||||
import { CLASSES } from '@/constants/classes';
|
||||
import withDashboardActions from '@/containers/Dashboard/withDashboardActions';
|
||||
import { withDashboardActions } from '@/containers/Dashboard/withDashboardActions';
|
||||
import { compose } from '@/utils';
|
||||
import { Spinner } from '@blueprintjs/core';
|
||||
|
||||
import withUniversalSearchActions from '@/containers/UniversalSearch/withUniversalSearchActions';
|
||||
import { withUniversalSearchActions } from '@/containers/UniversalSearch/withUniversalSearchActions';
|
||||
|
||||
/**
|
||||
* Dashboard pages wrapper.
|
||||
|
||||
@@ -3,7 +3,7 @@ import React, { useState, useRef } from 'react';
|
||||
import SplitPane from 'react-split-pane';
|
||||
import { debounce } from 'lodash';
|
||||
|
||||
import withDashboard from '@/containers/Dashboard/withDashboard';
|
||||
import { withDashboard } from '@/containers/Dashboard/withDashboard';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
function DashboardSplitPane({
|
||||
|
||||
@@ -21,10 +21,10 @@ import DashboardTopbarUser from '@/components/Dashboard/TopbarUser';
|
||||
import DashboardBreadcrumbs from '@/components/Dashboard/DashboardBreadcrumbs';
|
||||
import DashboardBackLink from '@/components/Dashboard/DashboardBackLink';
|
||||
|
||||
import withUniversalSearchActions from '@/containers/UniversalSearch/withUniversalSearchActions';
|
||||
import withDashboardActions from '@/containers/Dashboard/withDashboardActions';
|
||||
import withDashboard from '@/containers/Dashboard/withDashboard';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import { withUniversalSearchActions } from '@/containers/UniversalSearch/withUniversalSearchActions';
|
||||
import { withDashboardActions } from '@/containers/Dashboard/withDashboardActions';
|
||||
import { withDashboard } from '@/containers/Dashboard/withDashboard';
|
||||
import { withDialogActions } from '@/containers/Dialog/withDialogActions';
|
||||
|
||||
import QuickNewDropdown from '@/containers/QuickNewDropdown/QuickNewDropdown';
|
||||
import {
|
||||
|
||||
@@ -3,9 +3,9 @@ import React from 'react';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { getDashboardRoutes } from '@/routes/dashboard';
|
||||
import withDashboardActions from '@/containers/Dashboard/withDashboardActions';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import withUniversalSearchActions from '@/containers/UniversalSearch/withUniversalSearchActions';
|
||||
import { withDashboardActions } from '@/containers/Dashboard/withDashboardActions';
|
||||
import { withDialogActions } from '@/containers/Dialog/withDialogActions';
|
||||
import { withUniversalSearchActions } from '@/containers/UniversalSearch/withUniversalSearchActions';
|
||||
|
||||
import { compose } from '@/utils';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @ts-nocheck
|
||||
import * as R from 'ramda';
|
||||
import BigcapitalLoading from './BigcapitalLoading';
|
||||
import withDashboard from '@/containers/Dashboard/withDashboard';
|
||||
import { withDashboard } from '@/containers/Dashboard/withDashboard';
|
||||
|
||||
function SplashScreenComponent({ splashScreenLoading }) {
|
||||
return splashScreenLoading ? <BigcapitalLoading /> : null;
|
||||
|
||||
@@ -13,7 +13,7 @@ import { FormattedMessage as T } from '@/components';
|
||||
|
||||
import { useAuthActions } from '@/hooks/state';
|
||||
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import { withDialogActions } from '@/containers/Dialog/withDialogActions';
|
||||
|
||||
import { useAuthenticatedAccount } from '@/hooks/query';
|
||||
import { firstLettersArgs, compose } from '@/utils';
|
||||
|
||||
@@ -58,9 +58,9 @@ export default function AccountCellRenderer({
|
||||
{...formGroupProps}
|
||||
>
|
||||
<AccountsSuggestField
|
||||
accounts={accounts}
|
||||
onAccountSelected={handleAccountSelected}
|
||||
selectedAccountId={initialValue}
|
||||
items={accounts}
|
||||
onItemSelect={handleAccountSelected}
|
||||
selectedValue={initialValue}
|
||||
filterByRootTypes={filterAccountsByRootTypes}
|
||||
filterByTypes={filterAccountsByTypes}
|
||||
inputProps={{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import { Dialog } from '@blueprintjs/core';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import { withDialogActions } from '@/containers/Dialog/withDialogActions';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
import '@/style/components/Dialog/Dialog.scss';
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Position, Drawer } from '@blueprintjs/core';
|
||||
import '@/style/components/Drawer.scss';
|
||||
|
||||
import { DrawerProvider } from './DrawerProvider';
|
||||
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
|
||||
import { withDrawerActions } from '@/containers/Drawer/withDrawerActions';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@ import React from 'react';
|
||||
import { FormattedMessage as T } from '@/components';
|
||||
import { Classes, Icon, H4, Button } from '@blueprintjs/core';
|
||||
|
||||
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
|
||||
import { withDrawerActions } from '@/containers/Drawer/withDrawerActions';
|
||||
import { useDrawerContext } from './DrawerProvider';
|
||||
|
||||
import { compose } from '@/utils';
|
||||
|
||||
@@ -5,7 +5,7 @@ import * as R from 'ramda';
|
||||
import { DetailItem } from '@/components';
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
import withCurrentOrganization from '@/containers/Organization/withCurrentOrganization';
|
||||
import { withCurrentOrganization } from '@/containers/Organization/withCurrentOrganization';
|
||||
|
||||
/**
|
||||
* Detail exchange rate item.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import * as R from 'ramda';
|
||||
import withFeatureCan from './withFeatureCan';
|
||||
import { withFeatureCan } from './withFeatureCan';
|
||||
|
||||
function FeatureCanJSX({ feature, children, isFeatureCan }) {
|
||||
return isFeatureCan && children;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { getDashboardFeaturesSelector } from '@/store/dashboard/dashboard.selectors';
|
||||
|
||||
export default (mapState) => {
|
||||
export const withFeatureCan = (mapState) => {
|
||||
const featuresSelector = getDashboardFeaturesSelector();
|
||||
|
||||
const mapStateToProps = (state, props) => {
|
||||
|
||||
@@ -10,7 +10,16 @@ import {
|
||||
TextArea,
|
||||
HTMLSelect,
|
||||
} from '@blueprintjs-formik/core';
|
||||
import { MultiSelect, SuggestField } from '@blueprintjs-formik/select';
|
||||
import {
|
||||
MultiSelect,
|
||||
Suggest,
|
||||
Select,
|
||||
FormikMultiSelect,
|
||||
FormikSuggest,
|
||||
withFormikMultiSelect,
|
||||
withFormikSuggest,
|
||||
withFormikSelect,
|
||||
} from '@blueprintjs-formik/select';
|
||||
import { DateInput, TimezoneSelect } from '@blueprintjs-formik/datetime';
|
||||
import { FSelect } from './Select';
|
||||
|
||||
@@ -22,11 +31,17 @@ export {
|
||||
RadioGroup as FRadioGroup,
|
||||
Switch as FSwitch,
|
||||
FSelect,
|
||||
MultiSelect as FMultiSelect,
|
||||
FormikMultiSelect as FMultiSelect,
|
||||
EditableText as FEditableText,
|
||||
SuggestField as FSuggest,
|
||||
FormikSuggest as FSuggest,
|
||||
TextArea as FTextArea,
|
||||
DateInput as FDateInput,
|
||||
HTMLSelect as FHTMLSelect,
|
||||
TimezoneSelect as FTimezoneSelect,
|
||||
Suggest,
|
||||
MultiSelect,
|
||||
Select,
|
||||
withFormikSelect,
|
||||
withFormikMultiSelect,
|
||||
withFormikSuggest,
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import { Intent } from '@blueprintjs/core';
|
||||
import { Field, getIn } from 'formik';
|
||||
import { Field, FastField, getIn } from 'formik';
|
||||
import { CurrencyInput } from './MoneyInputGroup';
|
||||
|
||||
const fieldToMoneyInputGroup = ({
|
||||
@@ -32,6 +32,7 @@ function FieldToMoneyInputGroup({ ...props }) {
|
||||
return <CurrencyInput {...fieldToMoneyInputGroup(props)} />;
|
||||
}
|
||||
|
||||
export function FMoneyInputGroup({ ...props }) {
|
||||
return <Field {...props} component={FieldToMoneyInputGroup} />;
|
||||
export function FMoneyInputGroup({ fastField, ...props }) {
|
||||
const FieldComponent = fastField ? FastField : Field;
|
||||
return <FieldComponent {...props} component={FieldToMoneyInputGroup} />;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import { Button } from '@blueprintjs/core';
|
||||
import { Select } from '@blueprintjs-formik/select';
|
||||
import { FormikSelect } from '@blueprintjs-formik/select';
|
||||
import styled from 'styled-components';
|
||||
import clsx from 'classnames';
|
||||
|
||||
@@ -14,7 +14,7 @@ export function FSelect({ ...props }) {
|
||||
className={clsx({ 'is-selected': !!text }, props.className)}
|
||||
/>
|
||||
);
|
||||
return <Select input={input} fill={true} {...props} />;
|
||||
return <FormikSelect input={input} fill={true} {...props} />;
|
||||
}
|
||||
|
||||
export const SelectButton = styled(Button)`
|
||||
|
||||
@@ -3,8 +3,8 @@ import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
import { compose } from '@/utils';
|
||||
import withAuthentication from '@/containers/Authentication/withAuthentication';
|
||||
import withOrganization from '@/containers/Organization/withOrganization';
|
||||
import { withAuthentication } from '@/containers/Authentication/withAuthentication';
|
||||
import { withOrganization } from '@/containers/Organization/withOrganization';
|
||||
|
||||
/**
|
||||
* Ensures organization is not ready.
|
||||
|
||||
@@ -4,8 +4,8 @@ import { connect } from 'react-redux';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
import withAuthentication from '@/containers/Authentication/withAuthentication';
|
||||
import withOrganization from '@/containers/Organization/withOrganization';
|
||||
import { withAuthentication } from '@/containers/Authentication/withAuthentication';
|
||||
import { withOrganization } from '@/containers/Organization/withOrganization';
|
||||
|
||||
function EnsureOrganizationIsReady({
|
||||
// #ownProps
|
||||
|
||||
@@ -4,7 +4,7 @@ import { includes } from 'lodash';
|
||||
|
||||
import { compose } from '@/utils';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
import withSubscriptions from '@/containers/Subscriptions/withSubscriptions';
|
||||
import { withSubscriptions } from '@/containers/Subscriptions/withSubscriptions';
|
||||
|
||||
/**
|
||||
* Ensures the given subscription type is active or redirect to the given route.
|
||||
|
||||
@@ -4,7 +4,7 @@ import { includes } from 'lodash';
|
||||
|
||||
import { compose } from '@/utils';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
import withSubscriptions from '@/containers/Subscriptions/withSubscriptionss';
|
||||
import { withSubscriptions } from '@/containers/Subscriptions/withSubscriptionss';
|
||||
|
||||
/**
|
||||
* Ensures the given subscription type is active or redirect to the given route.
|
||||
|
||||
@@ -4,7 +4,7 @@ import { includes } from 'lodash';
|
||||
|
||||
import { compose } from '@/utils';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
import withSubscriptions from '@/containers/Subscriptions/withSubscriptionss';
|
||||
import { withSubscriptions } from '@/containers/Subscriptions/withSubscriptionss';
|
||||
|
||||
/**
|
||||
* Ensures the given subscription type is active or redirect to the given route.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import React from 'react';
|
||||
import * as R from 'ramda';
|
||||
import { FMultiSelect } from '@/components/Forms';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import { withDialogActions } from '@/containers/Dialog/withDialogActions';
|
||||
|
||||
/**
|
||||
* Items multi-select.
|
||||
|
||||
@@ -9,7 +9,7 @@ import { CLASSES } from '@/constants/classes';
|
||||
|
||||
import { FormattedMessage as T } from '@/components';
|
||||
|
||||
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
|
||||
import { withDrawerActions } from '@/containers/Drawer/withDrawerActions';
|
||||
|
||||
import { DRAWERS } from '@/constants/drawers';
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import PreferencesContentRoute from '@/components/Preferences/PreferencesContent
|
||||
import DashboardErrorBoundary from '@/components/Dashboard/DashboardErrorBoundary';
|
||||
import PreferencesSidebar from '@/components/Preferences/PreferencesSidebar';
|
||||
|
||||
import withDashboardActions from '@/containers/Dashboard/withDashboardActions';
|
||||
import { withDashboardActions } from '@/containers/Dashboard/withDashboardActions';
|
||||
|
||||
import '@/style/pages/Preferences/Page.scss';
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import CurrenciesActions from '@/containers/Preferences/Currencies/CurrenciesAct
|
||||
import WarehousesActions from '@/containers/Preferences/Warehouses/WarehousesActions';
|
||||
import BranchesActions from '@/containers/Preferences/Branches/BranchesActions';
|
||||
import ApiKeysActions from '@/containers/Preferences/ApiKeys/ApiKeysActions';
|
||||
import withDashboard from '@/containers/Dashboard/withDashboard';
|
||||
import { withDashboard } from '@/containers/Dashboard/withDashboard';
|
||||
|
||||
import { compose } from '@/utils';
|
||||
|
||||
|
||||
@@ -24,11 +24,19 @@ export const TD = styled.td`
|
||||
export const TRDarkSingleLine = styled(TR)`
|
||||
${TD} {
|
||||
border-bottom: 1px solid #000;
|
||||
|
||||
.bp4-dark & {
|
||||
border-bottom-color: var(--color-dark-gray5);
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const TRDarkDoubleLines = styled(TR)`
|
||||
${TD} {
|
||||
border-bottom: 3px double #000;
|
||||
|
||||
.bp4-dark & {
|
||||
border-bottom-color: var(--color-dark-gray5);
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as R from 'ramda';
|
||||
import intl from 'react-intl-universal';
|
||||
import { FSelect } from '@/components';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import { withDialogActions } from '@/containers/Dialog/withDialogActions';
|
||||
import { MenuItem } from '@blueprintjs/core';
|
||||
|
||||
// Create new account renderer.
|
||||
|
||||
@@ -3,7 +3,7 @@ import React from 'react';
|
||||
import * as R from 'ramda';
|
||||
|
||||
import { ButtonLink } from '../Button';
|
||||
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
|
||||
import { withDrawerActions } from '@/containers/Drawer/withDrawerActions';
|
||||
import { DRAWERS } from '@/constants/drawers';
|
||||
|
||||
function VendorDrawerLinkComponent({
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import React from 'react';
|
||||
import * as R from 'ramda';
|
||||
import { useFormikContext } from 'formik';
|
||||
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
|
||||
import { withDrawerActions } from '@/containers/Drawer/withDrawerActions';
|
||||
import { createNewItemFromQuery, createNewItemRenderer } from './utils';
|
||||
import { FSelect } from '../Forms';
|
||||
import { useCreateAutofillListener } from '@/hooks/state/autofill';
|
||||
|
||||
@@ -171,6 +171,15 @@ export const financialReportMenus = [
|
||||
subject: AbilitySubject.Report,
|
||||
ability: ReportsAction.READ_INVENTORY_ITEM_DETAILS,
|
||||
},
|
||||
{
|
||||
title: <T id={'inventory_valuation'} />,
|
||||
desc: (
|
||||
<T id={'summerize_your_transactions_for_each_inventory_item'} />
|
||||
),
|
||||
link: '/financial-reports/inventory-valuation',
|
||||
subject: AbilitySubject.Report,
|
||||
ability: ReportsAction.READ_INVENTORY_VALUATION_SUMMARY,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ export const TABLES = {
|
||||
EXPENSES: 'expenses',
|
||||
CASHFLOW_ACCOUNTS: 'cashflow_accounts',
|
||||
CASHFLOW_Transactions: 'cashflow_transactions',
|
||||
UNCATEGORIZED_CASHFLOW_TRANSACTION: 'UNCATEGORIZED_CASHFLOW_TRANSACTION',
|
||||
UNCATEGORIZED_BANK_TRANSACTION: 'UNCATEGORIZED_BANK_TRANSACTION',
|
||||
CREDIT_NOTES: 'credit_notes',
|
||||
VENDOR_CREDITS: 'vendor_credits',
|
||||
WAREHOUSE_TRANSFERS: 'warehouse_transfers',
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user