mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
Compare commits
6 Commits
darkmode-u
...
v0.23.0-rc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f2ab6e8f0 | ||
|
|
f0fae7d148 | ||
|
|
e063597a80 | ||
|
|
9b3f6b22d1 | ||
|
|
0475ce136a | ||
|
|
987ad992a4 |
5
packages/server/src/i18n/en/customer.json
Normal file
5
packages/server/src/i18n/en/customer.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"type.business": "Business",
|
||||||
|
"type.individual": "Individual"
|
||||||
|
}
|
||||||
|
|
||||||
@@ -48,14 +48,30 @@ export class PaginationQueryBuilder<
|
|||||||
// No relations defined
|
// No relations defined
|
||||||
return this.delete();
|
return this.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only check HasManyRelation and ManyToManyRelation relations, as BelongsToOneRelation are just
|
||||||
|
// foreign key references and shouldn't prevent deletion. Only dependent records should block deletion.
|
||||||
|
const dependentRelationNames = relationNames.filter((name) => {
|
||||||
|
const relation = relationMappings[name];
|
||||||
|
return relation && (
|
||||||
|
relation.relation === Model.HasManyRelation ||
|
||||||
|
relation.relation === Model.ManyToManyRelation
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (dependentRelationNames.length === 0) {
|
||||||
|
// No dependent relations defined, safe to delete
|
||||||
|
return this.delete();
|
||||||
|
}
|
||||||
|
|
||||||
const recordQuery = this.clone();
|
const recordQuery = this.clone();
|
||||||
|
|
||||||
relationNames.forEach((relationName: string) => {
|
dependentRelationNames.forEach((relationName: string) => {
|
||||||
recordQuery.withGraphFetched(relationName);
|
recordQuery.withGraphFetched(relationName);
|
||||||
});
|
});
|
||||||
const record = await recordQuery;
|
const record = await recordQuery;
|
||||||
|
|
||||||
const hasRelations = relationNames.some((name) => {
|
const hasRelations = dependentRelationNames.some((name) => {
|
||||||
const val = record[name];
|
const val = record[name];
|
||||||
return Array.isArray(val) ? val.length > 0 : val != null;
|
return Array.isArray(val) ? val.length > 0 : val != null;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { BranchesSettingsService } from '../Branches/BranchesSettings';
|
|||||||
import { BillPaymentsController } from './BillPayments.controller';
|
import { BillPaymentsController } from './BillPayments.controller';
|
||||||
import { BillPaymentGLEntries } from './commands/BillPaymentGLEntries';
|
import { BillPaymentGLEntries } from './commands/BillPaymentGLEntries';
|
||||||
import { BillPaymentGLEntriesSubscriber } from './subscribers/BillPaymentGLEntriesSubscriber';
|
import { BillPaymentGLEntriesSubscriber } from './subscribers/BillPaymentGLEntriesSubscriber';
|
||||||
|
import { BillPaymentBillSyncSubscriber } from './subscribers/BillPaymentBillSyncSubscriber';
|
||||||
import { LedgerModule } from '../Ledger/Ledger.module';
|
import { LedgerModule } from '../Ledger/Ledger.module';
|
||||||
import { AccountsModule } from '../Accounts/Accounts.module';
|
import { AccountsModule } from '../Accounts/Accounts.module';
|
||||||
import { BillPaymentsExportable } from './queries/BillPaymentsExportable';
|
import { BillPaymentsExportable } from './queries/BillPaymentsExportable';
|
||||||
@@ -39,6 +40,7 @@ import { BillPaymentsPages } from './commands/BillPaymentsPages.service';
|
|||||||
TenancyContext,
|
TenancyContext,
|
||||||
BillPaymentGLEntries,
|
BillPaymentGLEntries,
|
||||||
BillPaymentGLEntriesSubscriber,
|
BillPaymentGLEntriesSubscriber,
|
||||||
|
BillPaymentBillSyncSubscriber,
|
||||||
BillPaymentsExportable,
|
BillPaymentsExportable,
|
||||||
BillPaymentsImportable,
|
BillPaymentsImportable,
|
||||||
GetBillPaymentsService,
|
GetBillPaymentsService,
|
||||||
@@ -52,4 +54,4 @@ import { BillPaymentsPages } from './commands/BillPaymentsPages.service';
|
|||||||
],
|
],
|
||||||
controllers: [BillPaymentsController],
|
controllers: [BillPaymentsController],
|
||||||
})
|
})
|
||||||
export class BillPaymentsModule {}
|
export class BillPaymentsModule { }
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export class CreateBillPaymentService {
|
|||||||
|
|
||||||
@Inject(BillPayment.name)
|
@Inject(BillPayment.name)
|
||||||
private readonly billPaymentModel: TenantModelProxy<typeof BillPayment>,
|
private readonly billPaymentModel: TenantModelProxy<typeof BillPayment>,
|
||||||
) {}
|
) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new bill payment transcations and store it to the storage
|
* Creates a new bill payment transcations and store it to the storage
|
||||||
@@ -103,11 +103,19 @@ export class CreateBillPaymentService {
|
|||||||
} as IBillPaymentCreatingPayload);
|
} as IBillPaymentCreatingPayload);
|
||||||
|
|
||||||
// Writes the bill payment graph to the storage.
|
// Writes the bill payment graph to the storage.
|
||||||
const billPayment = await this.billPaymentModel()
|
const insertedBillPayment = await this.billPaymentModel()
|
||||||
.query(trx)
|
.query(trx)
|
||||||
.insertGraphAndFetch({
|
.insertGraphAndFetch({
|
||||||
...billPaymentObj,
|
...billPaymentObj,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Fetch the bill payment with entries to ensure they're loaded for the subscriber.
|
||||||
|
const billPayment = await this.billPaymentModel()
|
||||||
|
.query(trx)
|
||||||
|
.withGraphFetched('entries')
|
||||||
|
.findById(insertedBillPayment.id)
|
||||||
|
.throwIfNotFound();
|
||||||
|
|
||||||
// Triggers `onBillPaymentCreated` event.
|
// Triggers `onBillPaymentCreated` event.
|
||||||
await this.eventPublisher.emitAsync(events.billPayment.onCreated, {
|
await this.eventPublisher.emitAsync(events.billPayment.onCreated, {
|
||||||
billPayment,
|
billPayment,
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export class EditBillPayment {
|
|||||||
|
|
||||||
@Inject(Vendor.name)
|
@Inject(Vendor.name)
|
||||||
private readonly vendorModel: TenantModelProxy<typeof Vendor>,
|
private readonly vendorModel: TenantModelProxy<typeof Vendor>,
|
||||||
) {}
|
) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edits the details of the given bill payment.
|
* Edits the details of the given bill payment.
|
||||||
@@ -116,12 +116,20 @@ export class EditBillPayment {
|
|||||||
} as IBillPaymentEditingPayload);
|
} as IBillPaymentEditingPayload);
|
||||||
|
|
||||||
// Edits the bill payment transaction graph on the storage.
|
// Edits the bill payment transaction graph on the storage.
|
||||||
const billPayment = await this.billPaymentModel()
|
await this.billPaymentModel()
|
||||||
.query(trx)
|
.query(trx)
|
||||||
.upsertGraphAndFetch({
|
.upsertGraph({
|
||||||
id: billPaymentId,
|
id: billPaymentId,
|
||||||
...billPaymentObj,
|
...billPaymentObj,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Fetch the bill payment with entries to ensure they're loaded for the subscriber.
|
||||||
|
const billPayment = await this.billPaymentModel()
|
||||||
|
.query(trx)
|
||||||
|
.withGraphFetched('entries')
|
||||||
|
.findById(billPaymentId)
|
||||||
|
.throwIfNotFound();
|
||||||
|
|
||||||
// Triggers `onBillPaymentEdited` event.
|
// Triggers `onBillPaymentEdited` event.
|
||||||
await this.eventPublisher.emitAsync(events.billPayment.onEdited, {
|
await this.eventPublisher.emitAsync(events.billPayment.onEdited, {
|
||||||
billPaymentId,
|
billPaymentId,
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ export class BillPaymentsExportable extends Exportable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the accounts data to exportable sheet.
|
* Retrieves the accounts data to exportable sheet.
|
||||||
* @param {number} tenantId
|
|
||||||
* @returns
|
|
||||||
*/
|
*/
|
||||||
public async exportable(query: any) {
|
public async exportable(query: any) {
|
||||||
const filterQuery = (builder) => {
|
const filterQuery = (builder) => {
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
import {
|
||||||
|
IBillPaymentEventCreatedPayload,
|
||||||
|
IBillPaymentEventDeletedPayload,
|
||||||
|
IBillPaymentEventEditedPayload,
|
||||||
|
} from '../types/BillPayments.types';
|
||||||
|
import { BillPaymentBillSync } from '../commands/BillPaymentBillSync.service';
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { OnEvent } from '@nestjs/event-emitter';
|
||||||
|
import { events } from '@/common/events/events';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class BillPaymentBillSyncSubscriber {
|
||||||
|
/**
|
||||||
|
* @param {BillPaymentBillSync} billPaymentBillSync - Bill payment bill sync service.
|
||||||
|
*/
|
||||||
|
constructor(private readonly billPaymentBillSync: BillPaymentBillSync) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle bill increment/decrement payment amount
|
||||||
|
* once created, edited or deleted.
|
||||||
|
*/
|
||||||
|
@OnEvent(events.billPayment.onCreated)
|
||||||
|
async handleBillIncrementPaymentOnceCreated({
|
||||||
|
billPayment,
|
||||||
|
trx,
|
||||||
|
}: IBillPaymentEventCreatedPayload) {
|
||||||
|
// Ensure entries are available - they should be included in insertGraphAndFetch
|
||||||
|
const entries = billPayment.entries || [];
|
||||||
|
await this.billPaymentBillSync.saveChangeBillsPaymentAmount(
|
||||||
|
entries.map((entry) => ({
|
||||||
|
billId: entry.billId,
|
||||||
|
paymentAmount: entry.paymentAmount,
|
||||||
|
})),
|
||||||
|
null,
|
||||||
|
trx,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle bill increment/decrement payment amount once edited.
|
||||||
|
*/
|
||||||
|
@OnEvent(events.billPayment.onEdited)
|
||||||
|
async handleBillIncrementPaymentOnceEdited({
|
||||||
|
billPayment,
|
||||||
|
oldBillPayment,
|
||||||
|
trx,
|
||||||
|
}: IBillPaymentEventEditedPayload) {
|
||||||
|
const entries = billPayment.entries || [];
|
||||||
|
const oldEntries = oldBillPayment?.entries || null;
|
||||||
|
|
||||||
|
await this.billPaymentBillSync.saveChangeBillsPaymentAmount(
|
||||||
|
entries.map((entry) => ({
|
||||||
|
billId: entry.billId,
|
||||||
|
paymentAmount: entry.paymentAmount,
|
||||||
|
})),
|
||||||
|
oldEntries,
|
||||||
|
trx,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle revert bills payment amount once bill payment deleted.
|
||||||
|
*/
|
||||||
|
@OnEvent(events.billPayment.onDeleted)
|
||||||
|
async handleBillDecrementPaymentAmount({
|
||||||
|
oldBillPayment,
|
||||||
|
trx,
|
||||||
|
}: IBillPaymentEventDeletedPayload) {
|
||||||
|
const oldEntries = oldBillPayment.entries || [];
|
||||||
|
|
||||||
|
await this.billPaymentBillSync.saveChangeBillsPaymentAmount(
|
||||||
|
oldEntries.map((entry) => ({
|
||||||
|
billId: entry.billId,
|
||||||
|
paymentAmount: 0,
|
||||||
|
})),
|
||||||
|
oldEntries,
|
||||||
|
trx,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,9 +7,13 @@ import { CreditNotesRefundsApplication } from './CreditNotesRefundsApplication.s
|
|||||||
import { CreditNoteRefundsController } from './CreditNoteRefunds.controller';
|
import { CreditNoteRefundsController } from './CreditNoteRefunds.controller';
|
||||||
import { CreditNotesModule } from '../CreditNotes/CreditNotes.module';
|
import { CreditNotesModule } from '../CreditNotes/CreditNotes.module';
|
||||||
import { GetCreditNoteRefundsService } from './queries/GetCreditNoteRefunds.service';
|
import { GetCreditNoteRefundsService } from './queries/GetCreditNoteRefunds.service';
|
||||||
|
import { RefundCreditNoteGLEntries } from './commands/RefundCreditNoteGLEntries';
|
||||||
|
import { RefundCreditNoteGLEntriesSubscriber } from '../CreditNotes/subscribers/RefundCreditNoteGLEntriesSubscriber';
|
||||||
|
import { LedgerModule } from '../Ledger/Ledger.module';
|
||||||
|
import { AccountsModule } from '../Accounts/Accounts.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [forwardRef(() => CreditNotesModule)],
|
imports: [forwardRef(() => CreditNotesModule), LedgerModule, AccountsModule],
|
||||||
providers: [
|
providers: [
|
||||||
CreateRefundCreditNoteService,
|
CreateRefundCreditNoteService,
|
||||||
DeleteRefundCreditNoteService,
|
DeleteRefundCreditNoteService,
|
||||||
@@ -17,8 +21,10 @@ import { GetCreditNoteRefundsService } from './queries/GetCreditNoteRefunds.serv
|
|||||||
RefundSyncCreditNoteBalanceService,
|
RefundSyncCreditNoteBalanceService,
|
||||||
CreditNotesRefundsApplication,
|
CreditNotesRefundsApplication,
|
||||||
GetCreditNoteRefundsService,
|
GetCreditNoteRefundsService,
|
||||||
|
RefundCreditNoteGLEntries,
|
||||||
|
RefundCreditNoteGLEntriesSubscriber,
|
||||||
],
|
],
|
||||||
exports: [RefundSyncCreditNoteBalanceService],
|
exports: [RefundSyncCreditNoteBalanceService],
|
||||||
controllers: [CreditNoteRefundsController],
|
controllers: [CreditNoteRefundsController],
|
||||||
})
|
})
|
||||||
export class CreditNoteRefundsModule {}
|
export class CreditNoteRefundsModule { }
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
import { FinancialSheet } from '../../common/FinancialSheet';
|
import { FinancialSheet } from '../../common/FinancialSheet';
|
||||||
import { JournalSheetRepository } from './JournalSheetRepository';
|
import { JournalSheetRepository } from './JournalSheetRepository';
|
||||||
import { ILedgerEntry } from '@/modules/Ledger/types/Ledger.types';
|
import { ILedgerEntry } from '@/modules/Ledger/types/Ledger.types';
|
||||||
|
import { getTransactionTypeLabel } from '@/modules/BankingTransactions/utils';
|
||||||
|
|
||||||
export class JournalSheet extends FinancialSheet {
|
export class JournalSheet extends FinancialSheet {
|
||||||
readonly query: IJournalReportQuery;
|
readonly query: IJournalReportQuery;
|
||||||
@@ -97,10 +98,13 @@ export class JournalSheet extends FinancialSheet {
|
|||||||
|
|
||||||
transactionType: groupEntry.transactionType,
|
transactionType: groupEntry.transactionType,
|
||||||
referenceId: groupEntry.transactionId,
|
referenceId: groupEntry.transactionId,
|
||||||
referenceTypeFormatted: this.i18n.t(groupEntry.transactionType),
|
referenceTypeFormatted: this.i18n.t(
|
||||||
|
getTransactionTypeLabel(
|
||||||
|
groupEntry.transactionType,
|
||||||
|
groupEntry.transactionSubType,
|
||||||
|
),
|
||||||
|
),
|
||||||
entries: this.entriesMapper(entriesGroup),
|
entries: this.entriesMapper(entriesGroup),
|
||||||
|
|
||||||
currencyCode: this.baseCurrency,
|
currencyCode: this.baseCurrency,
|
||||||
|
|
||||||
credit: totalCredit,
|
credit: totalCredit,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { SaleInvoice } from '@/modules/SaleInvoices/models/SaleInvoice';
|
|||||||
import { SaleReceipt } from '@/modules/SaleReceipts/models/SaleReceipt';
|
import { SaleReceipt } from '@/modules/SaleReceipts/models/SaleReceipt';
|
||||||
import { Item } from '@/modules/Items/models/Item';
|
import { Item } from '@/modules/Items/models/Item';
|
||||||
import { BaseModel } from '@/models/Model';
|
import { BaseModel } from '@/models/Model';
|
||||||
|
import { ItemEntry } from '@/modules/TransactionItemEntry/models/ItemEntry';
|
||||||
|
|
||||||
export class InventoryCostLotTracker extends BaseModel {
|
export class InventoryCostLotTracker extends BaseModel {
|
||||||
date: Date;
|
date: Date;
|
||||||
@@ -27,6 +28,7 @@ export class InventoryCostLotTracker extends BaseModel {
|
|||||||
warehouseId: number;
|
warehouseId: number;
|
||||||
|
|
||||||
item?: Item;
|
item?: Item;
|
||||||
|
itemEntry?: ItemEntry;
|
||||||
invoice?: SaleInvoice;
|
invoice?: SaleInvoice;
|
||||||
receipt?: SaleReceipt;
|
receipt?: SaleReceipt;
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export class InventoryCostSubscriber {
|
|||||||
private readonly itemsQuantitySync: InventoryItemsQuantitySyncService,
|
private readonly itemsQuantitySync: InventoryItemsQuantitySyncService,
|
||||||
private readonly inventoryService: InventoryComputeCostService,
|
private readonly inventoryService: InventoryComputeCostService,
|
||||||
private readonly importAls: ImportAls,
|
private readonly importAls: ImportAls,
|
||||||
) {}
|
) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sync inventory items quantity once inventory transactions created.
|
* Sync inventory items quantity once inventory transactions created.
|
||||||
@@ -60,7 +60,7 @@ export class InventoryCostSubscriber {
|
|||||||
* Marks items cost compute running state.
|
* Marks items cost compute running state.
|
||||||
*/
|
*/
|
||||||
@OnEvent(events.inventory.onInventoryTransactionsCreated)
|
@OnEvent(events.inventory.onInventoryTransactionsCreated)
|
||||||
async markGlobalSettingsComputeItems({}) {
|
async markGlobalSettingsComputeItems({ }) {
|
||||||
await this.inventoryService.markItemsCostComputeRunning(true);
|
await this.inventoryService.markItemsCostComputeRunning(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ export class InventoryCostSubscriber {
|
|||||||
* Marks items cost compute as completed.
|
* Marks items cost compute as completed.
|
||||||
*/
|
*/
|
||||||
@OnEvent(events.inventory.onInventoryCostEntriesWritten)
|
@OnEvent(events.inventory.onInventoryCostEntriesWritten)
|
||||||
async markGlobalSettingsComputeItemsCompeted({}) {
|
async markGlobalSettingsComputeItemsCompeted({ }) {
|
||||||
await this.inventoryService.markItemsCostComputeRunning(false);
|
await this.inventoryService.markItemsCostComputeRunning(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,15 +80,13 @@ export class InventoryCostSubscriber {
|
|||||||
itemId,
|
itemId,
|
||||||
startingDate,
|
startingDate,
|
||||||
}: IComputeItemCostJobCompletedPayload) {
|
}: IComputeItemCostJobCompletedPayload) {
|
||||||
// const dependsComputeJobs = await this.agenda.jobs({
|
// Convert startingDate to Date if it's a string
|
||||||
// name: 'compute-item-cost',
|
const startingDateObj = startingDate instanceof Date
|
||||||
// nextRunAt: { $ne: null },
|
? startingDate
|
||||||
// 'data.tenantId': tenantId,
|
: new Date(startingDate);
|
||||||
// });
|
|
||||||
// // There is no scheduled compute jobs waiting.
|
// Write GL entries for inventory cost lots after cost computation completes
|
||||||
// if (dependsComputeJobs.length === 0) {
|
await this.saleInvoicesCost.writeCostLotsGLEntries(startingDateObj);
|
||||||
// await this.saleInvoicesCost.scheduleWriteJournalEntries(startingDate);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ export class SaleInvoiceCostGLEntries {
|
|||||||
.modify('filterDateRange', startingDate)
|
.modify('filterDateRange', startingDate)
|
||||||
.orderBy('date', 'ASC')
|
.orderBy('date', 'ASC')
|
||||||
.withGraphFetched('invoice')
|
.withGraphFetched('invoice')
|
||||||
.withGraphFetched('item');
|
.withGraphFetched('item')
|
||||||
|
.withGraphFetched('itemEntry');
|
||||||
|
|
||||||
const ledger = this.getInventoryCostLotsLedger(inventoryCostLotTrans);
|
const ledger = this.getInventoryCostLotsLedger(inventoryCostLotTrans);
|
||||||
|
|
||||||
@@ -79,6 +80,9 @@ export class SaleInvoiceCostGLEntries {
|
|||||||
transactionType: inventoryCostLot.transactionType,
|
transactionType: inventoryCostLot.transactionType,
|
||||||
transactionId: inventoryCostLot.transactionId,
|
transactionId: inventoryCostLot.transactionId,
|
||||||
|
|
||||||
|
transactionNumber: inventoryCostLot.invoice.invoiceNo,
|
||||||
|
referenceNumber: inventoryCostLot.invoice.referenceNo,
|
||||||
|
|
||||||
date: inventoryCostLot.date,
|
date: inventoryCostLot.date,
|
||||||
indexGroup: 20,
|
indexGroup: 20,
|
||||||
costable: true,
|
costable: true,
|
||||||
@@ -105,6 +109,9 @@ export class SaleInvoiceCostGLEntries {
|
|||||||
const costAccountId =
|
const costAccountId =
|
||||||
inventoryCostLot.costAccountId || inventoryCostLot.item.costAccountId;
|
inventoryCostLot.costAccountId || inventoryCostLot.item.costAccountId;
|
||||||
|
|
||||||
|
// Get description from item entry if available
|
||||||
|
const description = inventoryCostLot.itemEntry?.description || null;
|
||||||
|
|
||||||
// XXX Debit - Cost account.
|
// XXX Debit - Cost account.
|
||||||
const costEntry = {
|
const costEntry = {
|
||||||
...commonEntry,
|
...commonEntry,
|
||||||
@@ -112,6 +119,7 @@ export class SaleInvoiceCostGLEntries {
|
|||||||
accountId: costAccountId,
|
accountId: costAccountId,
|
||||||
accountNormal: AccountNormal.DEBIT,
|
accountNormal: AccountNormal.DEBIT,
|
||||||
itemId: inventoryCostLot.itemId,
|
itemId: inventoryCostLot.itemId,
|
||||||
|
note: description,
|
||||||
index: getIndexIncrement(),
|
index: getIndexIncrement(),
|
||||||
};
|
};
|
||||||
// XXX Credit - Inventory account.
|
// XXX Credit - Inventory account.
|
||||||
@@ -121,6 +129,7 @@ export class SaleInvoiceCostGLEntries {
|
|||||||
accountId: inventoryCostLot.item.inventoryAccountId,
|
accountId: inventoryCostLot.item.inventoryAccountId,
|
||||||
accountNormal: AccountNormal.DEBIT,
|
accountNormal: AccountNormal.DEBIT,
|
||||||
itemId: inventoryCostLot.itemId,
|
itemId: inventoryCostLot.itemId,
|
||||||
|
note: description,
|
||||||
index: getIndexIncrement(),
|
index: getIndexIncrement(),
|
||||||
};
|
};
|
||||||
return [costEntry, inventoryEntry];
|
return [costEntry, inventoryEntry];
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { OnEvent } from '@nestjs/event-emitter';
|
||||||
|
import { events } from '@/common/events/events';
|
||||||
import { IInventoryCostLotsGLEntriesWriteEvent } from '@/modules/InventoryCost/types/InventoryCost.types';
|
import { IInventoryCostLotsGLEntriesWriteEvent } from '@/modules/InventoryCost/types/InventoryCost.types';
|
||||||
import { SaleInvoiceCostGLEntries } from '../SaleInvoiceCostGLEntries';
|
import { SaleInvoiceCostGLEntries } from '../SaleInvoiceCostGLEntries';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class InvoiceCostGLEntriesSubscriber {
|
export class InvoiceCostGLEntriesSubscriber {
|
||||||
constructor(private readonly invoiceCostEntries: SaleInvoiceCostGLEntries) {}
|
constructor(private readonly invoiceCostEntries: SaleInvoiceCostGLEntries) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes the invoices cost GL entries once the inventory cost lots be written.
|
* Writes the invoices cost GL entries once the inventory cost lots be written.
|
||||||
* @param {IInventoryCostLotsGLEntriesWriteEvent}
|
* @param {IInventoryCostLotsGLEntriesWriteEvent}
|
||||||
*/
|
*/
|
||||||
|
@OnEvent(events.inventory.onCostLotsGLEntriesWrite)
|
||||||
async writeInvoicesCostEntriesOnCostLotsWritten({
|
async writeInvoicesCostEntriesOnCostLotsWritten({
|
||||||
trx,
|
trx,
|
||||||
startingDate,
|
startingDate,
|
||||||
|
|||||||
@@ -6,15 +6,21 @@ import { VendorCreditsRefundApplication } from './VendorCreditsRefund.applicatio
|
|||||||
import { CreateRefundVendorCredit } from './commands/CreateRefundVendorCredit.service';
|
import { CreateRefundVendorCredit } from './commands/CreateRefundVendorCredit.service';
|
||||||
import { WarehousesModule } from '../Warehouses/Warehouses.module';
|
import { WarehousesModule } from '../Warehouses/Warehouses.module';
|
||||||
import { BranchesModule } from '../Branches/Branches.module';
|
import { BranchesModule } from '../Branches/Branches.module';
|
||||||
|
import { RefundVendorCreditGLEntries } from './commands/RefundVendorCreditGLEntries';
|
||||||
|
import { RefundVendorCreditGLEntriesSubscriber } from './subscribers/RefundVendorCreditGLEntriesSubscriber';
|
||||||
|
import { LedgerModule } from '../Ledger/Ledger.module';
|
||||||
|
import { AccountsModule } from '../Accounts/Accounts.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [WarehousesModule, BranchesModule],
|
imports: [WarehousesModule, BranchesModule, LedgerModule, AccountsModule],
|
||||||
providers: [
|
providers: [
|
||||||
GetRefundVendorCreditsService,
|
GetRefundVendorCreditsService,
|
||||||
DeleteRefundVendorCreditService,
|
DeleteRefundVendorCreditService,
|
||||||
CreateRefundVendorCredit,
|
CreateRefundVendorCredit,
|
||||||
VendorCreditsRefundApplication
|
VendorCreditsRefundApplication,
|
||||||
|
RefundVendorCreditGLEntries,
|
||||||
|
RefundVendorCreditGLEntriesSubscriber,
|
||||||
],
|
],
|
||||||
controllers: [VendorCreditsRefundController],
|
controllers: [VendorCreditsRefundController],
|
||||||
})
|
})
|
||||||
export class VendorCreditsRefundModule {}
|
export class VendorCreditsRefundModule { }
|
||||||
|
|||||||
@@ -1,159 +1,172 @@
|
|||||||
// import { Inject, Service } from 'typedi';
|
import { LedgerStorageService } from '@/modules/Ledger/LedgerStorage.service';
|
||||||
// import { Knex } from 'knex';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
// import { AccountNormal, ILedgerEntry } from '@/interfaces';
|
import { RefundVendorCredit } from '../models/RefundVendorCredit';
|
||||||
// import { IRefundVendorCredit } from '@/interfaces';
|
import { Ledger } from '@/modules/Ledger/Ledger';
|
||||||
// import JournalPosterService from '@/services/Sales/JournalPosterService';
|
import { Knex } from 'knex';
|
||||||
// import LedgerRepository from '@/services/Ledger/LedgerRepository';
|
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
|
||||||
// import HasTenancyService from '@/services/Tenancy/TenancyService';
|
import { Account } from '@/modules/Accounts/models/Account.model';
|
||||||
|
import { ILedgerEntry } from '@/modules/Ledger/types/Ledger.types';
|
||||||
|
import { AccountNormal } from '@/interfaces/Account';
|
||||||
|
import { AccountRepository } from '@/modules/Accounts/repositories/Account.repository';
|
||||||
|
|
||||||
// @Service()
|
@Injectable()
|
||||||
// export default class RefundVendorCreditGLEntries {
|
export class RefundVendorCreditGLEntries {
|
||||||
// @Inject()
|
constructor(
|
||||||
// private journalService: JournalPosterService;
|
private readonly ledgerStorage: LedgerStorageService,
|
||||||
|
private readonly accountRepository: AccountRepository,
|
||||||
|
|
||||||
// @Inject()
|
@Inject(Account.name)
|
||||||
// private ledgerRepository: LedgerRepository;
|
private readonly accountModel: TenantModelProxy<typeof Account>,
|
||||||
|
|
||||||
// @Inject()
|
@Inject(RefundVendorCredit.name)
|
||||||
// private tenancy: HasTenancyService;
|
private readonly refundVendorCreditModel: TenantModelProxy<
|
||||||
|
typeof RefundVendorCredit
|
||||||
|
>,
|
||||||
|
) { }
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Retrieves the refund credit common GL entry.
|
* Retrieves the refund vendor credit common GL entry.
|
||||||
// * @param {IRefundVendorCredit} refundCredit
|
* @param {RefundVendorCredit} refundVendorCredit
|
||||||
// */
|
* @returns
|
||||||
// private getRefundCreditGLCommonEntry = (
|
*/
|
||||||
// refundCredit: IRefundVendorCredit
|
private getRefundVendorCreditCommonGLEntry = (
|
||||||
// ) => {
|
refundVendorCredit: RefundVendorCredit,
|
||||||
// return {
|
) => {
|
||||||
// exchangeRate: refundCredit.exchangeRate,
|
const model = refundVendorCredit as any;
|
||||||
// currencyCode: refundCredit.currencyCode,
|
return {
|
||||||
|
currencyCode: refundVendorCredit.currencyCode,
|
||||||
|
exchangeRate: refundVendorCredit.exchangeRate,
|
||||||
|
|
||||||
// transactionType: 'RefundVendorCredit',
|
transactionType: 'RefundVendorCredit',
|
||||||
// transactionId: refundCredit.id,
|
transactionId: refundVendorCredit.id,
|
||||||
|
date: refundVendorCredit.date,
|
||||||
|
userId: refundVendorCredit.vendorCredit?.userId,
|
||||||
|
|
||||||
// date: refundCredit.date,
|
referenceNumber: refundVendorCredit.referenceNo,
|
||||||
// userId: refundCredit.userId,
|
|
||||||
// referenceNumber: refundCredit.referenceNo,
|
|
||||||
// createdAt: refundCredit.createdAt,
|
|
||||||
// indexGroup: 10,
|
|
||||||
|
|
||||||
// credit: 0,
|
createdAt: model.createdAt,
|
||||||
// debit: 0,
|
indexGroup: 10,
|
||||||
|
|
||||||
// note: refundCredit.description,
|
credit: 0,
|
||||||
// branchId: refundCredit.branchId,
|
debit: 0,
|
||||||
// };
|
|
||||||
// };
|
|
||||||
|
|
||||||
// /**
|
note: refundVendorCredit.description,
|
||||||
// * Retrieves the refund credit payable GL entry.
|
branchId: refundVendorCredit.branchId,
|
||||||
// * @param {IRefundVendorCredit} refundCredit
|
};
|
||||||
// * @param {number} APAccountId
|
};
|
||||||
// * @returns {ILedgerEntry}
|
|
||||||
// */
|
|
||||||
// private getRefundCreditGLPayableEntry = (
|
|
||||||
// refundCredit: IRefundVendorCredit,
|
|
||||||
// APAccountId: number
|
|
||||||
// ): ILedgerEntry => {
|
|
||||||
// const commonEntry = this.getRefundCreditGLCommonEntry(refundCredit);
|
|
||||||
|
|
||||||
// return {
|
/**
|
||||||
// ...commonEntry,
|
* Retrieves the refund vendor credit payable GL entry.
|
||||||
// credit: refundCredit.amount,
|
* @param {RefundVendorCredit} refundVendorCredit
|
||||||
// accountId: APAccountId,
|
* @param {number} APAccountId
|
||||||
// contactId: refundCredit.vendorCredit.vendorId,
|
* @returns {ILedgerEntry}
|
||||||
// index: 1,
|
*/
|
||||||
// accountNormal: AccountNormal.CREDIT,
|
private getRefundVendorCreditGLPayableEntry = (
|
||||||
// };
|
refundVendorCredit: RefundVendorCredit,
|
||||||
// };
|
APAccountId: number,
|
||||||
|
): ILedgerEntry => {
|
||||||
|
const commonEntry = this.getRefundVendorCreditCommonGLEntry(
|
||||||
|
refundVendorCredit,
|
||||||
|
);
|
||||||
|
|
||||||
// /**
|
return {
|
||||||
// * Retrieves the refund credit deposit GL entry.
|
...commonEntry,
|
||||||
// * @param {IRefundVendorCredit} refundCredit
|
credit: refundVendorCredit.amount,
|
||||||
// * @returns {ILedgerEntry}
|
accountId: APAccountId,
|
||||||
// */
|
contactId: refundVendorCredit.vendorCredit.vendorId,
|
||||||
// private getRefundCreditGLDepositEntry = (
|
index: 1,
|
||||||
// refundCredit: IRefundVendorCredit
|
accountNormal: AccountNormal.CREDIT,
|
||||||
// ): ILedgerEntry => {
|
};
|
||||||
// const commonEntry = this.getRefundCreditGLCommonEntry(refundCredit);
|
};
|
||||||
|
|
||||||
// return {
|
/**
|
||||||
// ...commonEntry,
|
* Retrieves the refund vendor credit deposit GL entry.
|
||||||
// debit: refundCredit.amount,
|
* @param {RefundVendorCredit} refundVendorCredit
|
||||||
// accountId: refundCredit.depositAccountId,
|
* @returns {ILedgerEntry}
|
||||||
// index: 2,
|
*/
|
||||||
// accountNormal: AccountNormal.DEBIT,
|
private getRefundVendorCreditGLDepositEntry = (
|
||||||
// };
|
refundVendorCredit: RefundVendorCredit,
|
||||||
// };
|
): ILedgerEntry => {
|
||||||
|
const commonEntry = this.getRefundVendorCreditCommonGLEntry(
|
||||||
|
refundVendorCredit,
|
||||||
|
);
|
||||||
|
|
||||||
// /**
|
return {
|
||||||
// * Retrieve refund vendor credit GL entries.
|
...commonEntry,
|
||||||
// * @param {IRefundVendorCredit} refundCredit
|
debit: refundVendorCredit.amount,
|
||||||
// * @param {number} APAccountId
|
accountId: refundVendorCredit.depositAccountId,
|
||||||
// * @returns {ILedgerEntry[]}
|
index: 2,
|
||||||
// */
|
accountNormal: AccountNormal.DEBIT,
|
||||||
// public getRefundCreditGLEntries = (
|
};
|
||||||
// refundCredit: IRefundVendorCredit,
|
};
|
||||||
// APAccountId: number
|
|
||||||
// ): ILedgerEntry[] => {
|
|
||||||
// const payableEntry = this.getRefundCreditGLPayableEntry(
|
|
||||||
// refundCredit,
|
|
||||||
// APAccountId
|
|
||||||
// );
|
|
||||||
// const depositEntry = this.getRefundCreditGLDepositEntry(refundCredit);
|
|
||||||
|
|
||||||
// return [payableEntry, depositEntry];
|
/**
|
||||||
// };
|
* Retrieve refund vendor credit GL entries.
|
||||||
|
* @param {RefundVendorCredit} refundVendorCredit
|
||||||
|
* @param {number} APAccountId
|
||||||
|
* @returns {ILedgerEntry[]}
|
||||||
|
*/
|
||||||
|
public getRefundVendorCreditGLEntries(
|
||||||
|
refundVendorCredit: RefundVendorCredit,
|
||||||
|
APAccountId: number,
|
||||||
|
): ILedgerEntry[] {
|
||||||
|
const payableEntry = this.getRefundVendorCreditGLPayableEntry(
|
||||||
|
refundVendorCredit,
|
||||||
|
APAccountId,
|
||||||
|
);
|
||||||
|
const depositEntry = this.getRefundVendorCreditGLDepositEntry(
|
||||||
|
refundVendorCredit,
|
||||||
|
);
|
||||||
|
|
||||||
// /**
|
return [payableEntry, depositEntry];
|
||||||
// * Saves refund credit note GL entries.
|
}
|
||||||
// * @param {number} tenantId
|
|
||||||
// * @param {IRefundVendorCredit} refundCredit -
|
|
||||||
// * @param {Knex.Transaction} trx -
|
|
||||||
// * @return {Promise<void>}
|
|
||||||
// */
|
|
||||||
// public saveRefundCreditGLEntries = async (
|
|
||||||
// tenantId: number,
|
|
||||||
// refundCreditId: number,
|
|
||||||
// trx?: Knex.Transaction
|
|
||||||
// ): Promise<void> => {
|
|
||||||
// const { Account, RefundVendorCredit } = this.tenancy.models(tenantId);
|
|
||||||
|
|
||||||
// // Retireve refund with associated vendor credit entity.
|
/**
|
||||||
// const refundCredit = await RefundVendorCredit.query()
|
* Creates refund vendor credit GL entries.
|
||||||
// .findById(refundCreditId)
|
* @param {number} refundVendorCreditId
|
||||||
// .withGraphFetched('vendorCredit');
|
* @param {Knex.Transaction} trx
|
||||||
|
*/
|
||||||
|
public createRefundVendorCreditGLEntries = async (
|
||||||
|
refundVendorCreditId: number,
|
||||||
|
trx?: Knex.Transaction,
|
||||||
|
) => {
|
||||||
|
// Retrieve the refund with associated vendor credit.
|
||||||
|
const refundVendorCredit = await this.refundVendorCreditModel()
|
||||||
|
.query(trx)
|
||||||
|
.findById(refundVendorCreditId)
|
||||||
|
.withGraphFetched('vendorCredit');
|
||||||
|
|
||||||
// const payableAccount = await Account.query().findOne(
|
// Retrieve the payable account (A/P) account based on the given currency.
|
||||||
// 'slug',
|
const APAccount = await this.accountRepository.findOrCreateAccountsPayable(
|
||||||
// 'accounts-payable'
|
refundVendorCredit.currencyCode,
|
||||||
// );
|
{},
|
||||||
// // Generates the GL entries of the given refund credit.
|
trx,
|
||||||
// const entries = this.getRefundCreditGLEntries(
|
);
|
||||||
// refundCredit,
|
|
||||||
// payableAccount.id
|
|
||||||
// );
|
|
||||||
// // Saves the ledegr to the storage.
|
|
||||||
// await this.ledgerRepository.saveLedgerEntries(tenantId, entries, trx);
|
|
||||||
// };
|
|
||||||
|
|
||||||
// /**
|
// Retrieve refund vendor credit GL entries.
|
||||||
// * Reverts refund credit note GL entries.
|
const refundGLEntries = this.getRefundVendorCreditGLEntries(
|
||||||
// * @param {number} tenantId
|
refundVendorCredit,
|
||||||
// * @param {number} refundCreditId
|
APAccount.id,
|
||||||
// * @param {Knex.Transaction} trx
|
);
|
||||||
// * @return {Promise<void>}
|
const ledger = new Ledger(refundGLEntries);
|
||||||
// */
|
|
||||||
// public revertRefundCreditGLEntries = async (
|
// Saves refund ledger entries.
|
||||||
// tenantId: number,
|
await this.ledgerStorage.commit(ledger, trx);
|
||||||
// refundCreditId: number,
|
};
|
||||||
// trx?: Knex.Transaction
|
|
||||||
// ) => {
|
/**
|
||||||
// await this.journalService.revertJournalTransactions(
|
* Reverts refund vendor credit GL entries.
|
||||||
// tenantId,
|
* @param {number} refundVendorCreditId
|
||||||
// refundCreditId,
|
* @param {Knex.Transaction} trx
|
||||||
// 'RefundVendorCredit',
|
*/
|
||||||
// trx
|
public revertRefundVendorCreditGLEntries = async (
|
||||||
// );
|
refundVendorCreditId: number,
|
||||||
// };
|
trx?: Knex.Transaction,
|
||||||
// }
|
) => {
|
||||||
|
await this.ledgerStorage.deleteByReference(
|
||||||
|
refundVendorCreditId,
|
||||||
|
'RefundVendorCredit',
|
||||||
|
trx,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import { events } from '@/common/events/events';
|
||||||
|
import { RefundVendorCreditGLEntries } from '../commands/RefundVendorCreditGLEntries';
|
||||||
|
import {
|
||||||
|
IRefundVendorCreditCreatedPayload,
|
||||||
|
IRefundVendorCreditDeletedPayload,
|
||||||
|
} from '../types/VendorCreditRefund.types';
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { OnEvent } from '@nestjs/event-emitter';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class RefundVendorCreditGLEntriesSubscriber {
|
||||||
|
constructor(
|
||||||
|
private readonly refundVendorCreditGLEntries: RefundVendorCreditGLEntries,
|
||||||
|
) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes refund vendor credit GL entries once the transaction created.
|
||||||
|
* @param {IRefundVendorCreditCreatedPayload} payload -
|
||||||
|
*/
|
||||||
|
@OnEvent(events.vendorCredit.onRefundCreated)
|
||||||
|
async writeRefundVendorCreditGLEntriesOnceCreated({
|
||||||
|
trx,
|
||||||
|
refundVendorCredit,
|
||||||
|
vendorCredit,
|
||||||
|
}: IRefundVendorCreditCreatedPayload) {
|
||||||
|
await this.refundVendorCreditGLEntries.createRefundVendorCreditGLEntries(
|
||||||
|
refundVendorCredit.id,
|
||||||
|
trx,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverts refund vendor credit GL entries once the transaction deleted.
|
||||||
|
* @param {IRefundVendorCreditDeletedPayload} payload -
|
||||||
|
*/
|
||||||
|
@OnEvent(events.vendorCredit.onRefundDeleted)
|
||||||
|
async revertRefundVendorCreditGLEntriesOnceDeleted({
|
||||||
|
trx,
|
||||||
|
refundCreditId,
|
||||||
|
oldRefundCredit,
|
||||||
|
}: IRefundVendorCreditDeletedPayload) {
|
||||||
|
await this.refundVendorCreditGLEntries.revertRefundVendorCreditGLEntries(
|
||||||
|
refundCreditId,
|
||||||
|
trx,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ import { Intent, Alert } from '@blueprintjs/core';
|
|||||||
import { queryCache } from 'react-query';
|
import { queryCache } from 'react-query';
|
||||||
import { AppToaster } from '@/components';
|
import { AppToaster } from '@/components';
|
||||||
|
|
||||||
import { withAccountsActions } from '@/containers/Accounts/withAccountsTableActions';
|
// import { withAccountsActions } from '@/containers/Accounts/withAccountsTableActions';
|
||||||
import { withAlertStoreConnect } from '@/containers/Alert/withAlertStoreConnect';
|
import { withAlertStoreConnect } from '@/containers/Alert/withAlertStoreConnect';
|
||||||
import { withAlertActions } from '@/containers/Alert/withAlertActions';
|
import { withAlertActions } from '@/containers/Alert/withAlertActions';
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ function AccountBulkInactivateAlert({
|
|||||||
|
|
||||||
closeAlert,
|
closeAlert,
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
const [isLoading, setLoading] = useState(false);
|
const [isLoading, setLoading] = useState(false);
|
||||||
const selectedRowsCount = 0;
|
const selectedRowsCount = 0;
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ function AccountBulkInactivateAlert({
|
|||||||
});
|
});
|
||||||
queryCache.invalidateQueries('accounts-table');
|
queryCache.invalidateQueries('accounts-table');
|
||||||
})
|
})
|
||||||
.catch((errors) => {})
|
.catch((errors) => { })
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
closeAlert(name);
|
closeAlert(name);
|
||||||
@@ -68,5 +68,5 @@ function AccountBulkInactivateAlert({
|
|||||||
export default compose(
|
export default compose(
|
||||||
withAlertStoreConnect(),
|
withAlertStoreConnect(),
|
||||||
withAlertActions,
|
withAlertActions,
|
||||||
withAccountsActions,
|
// withAccountsActions,
|
||||||
)(AccountBulkInactivateAlert);
|
)(AccountBulkInactivateAlert);
|
||||||
|
|||||||
@@ -70,16 +70,16 @@ function VendorCreditNoteForm({
|
|||||||
() => ({
|
() => ({
|
||||||
...(!isEmpty(vendorCredit)
|
...(!isEmpty(vendorCredit)
|
||||||
? {
|
? {
|
||||||
...transformToEditForm(vendorCredit),
|
...transformToEditForm(vendorCredit),
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
...defaultVendorsCreditNote,
|
...defaultVendorsCreditNote,
|
||||||
...(vendorcreditAutoIncrement && {
|
...(vendorcreditAutoIncrement && {
|
||||||
vendor_credit_number: vendorCreditNumber,
|
vendor_credit_number: vendorCreditNumber,
|
||||||
}),
|
|
||||||
currency_code: base_currency,
|
|
||||||
...newVendorCredit,
|
|
||||||
}),
|
}),
|
||||||
|
currency_code: base_currency,
|
||||||
|
...newVendorCredit,
|
||||||
|
}),
|
||||||
}),
|
}),
|
||||||
[vendorCredit, base_currency],
|
[vendorCredit, base_currency],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
VendorsSelect,
|
VendorsSelect,
|
||||||
Stack,
|
Stack,
|
||||||
FDateInput,
|
FDateInput,
|
||||||
|
FInputGroup,
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
import {
|
import {
|
||||||
vendorsFieldShouldUpdate,
|
vendorsFieldShouldUpdate,
|
||||||
@@ -74,6 +75,7 @@ function VendorCreditNoteFormHeaderFields({
|
|||||||
}) {
|
}) {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const fieldsClassName = getFieldsStyle(theme);
|
const fieldsClassName = getFieldsStyle(theme);
|
||||||
|
const { values } = useFormikContext();
|
||||||
|
|
||||||
// Handle vendor credit number changing.
|
// Handle vendor credit number changing.
|
||||||
const handleVendorCreditNumberChange = () => {
|
const handleVendorCreditNumberChange = () => {
|
||||||
@@ -81,10 +83,11 @@ function VendorCreditNoteFormHeaderFields({
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Handle vendor credit no. field blur.
|
// Handle vendor credit no. field blur.
|
||||||
const handleVendorCreditNoBlur = (form, field) => (event) => {
|
const handleVendorCreditNoBlur = (event) => {
|
||||||
const newValue = event.target.value;
|
const newValue = event.target.value;
|
||||||
|
const oldValue = values.vendor_credit_number;
|
||||||
|
|
||||||
if (field.value !== newValue && vendorcreditAutoIncrement) {
|
if (oldValue !== newValue && vendorcreditAutoIncrement) {
|
||||||
openDialog('vendor-credit-form', {
|
openDialog('vendor-credit-form', {
|
||||||
initialFormValues: {
|
initialFormValues: {
|
||||||
manualTransactionNo: newValue,
|
manualTransactionNo: newValue,
|
||||||
@@ -109,7 +112,6 @@ function VendorCreditNoteFormHeaderFields({
|
|||||||
name={'exchange_rate'}
|
name={'exchange_rate'}
|
||||||
formGroupProps={{ label: ' ', inline: true }}
|
formGroupProps={{ label: ' ', inline: true }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* ------- Vendor Credit date ------- */}
|
{/* ------- Vendor Credit date ------- */}
|
||||||
<FFormGroup
|
<FFormGroup
|
||||||
name={'vendor_credit_date'}
|
name={'vendor_credit_date'}
|
||||||
@@ -130,7 +132,6 @@ function VendorCreditNoteFormHeaderFields({
|
|||||||
</FFormGroup>
|
</FFormGroup>
|
||||||
|
|
||||||
{/* ----------- Vendor Credit No # ----------- */}
|
{/* ----------- Vendor Credit No # ----------- */}
|
||||||
|
|
||||||
<FFormGroup
|
<FFormGroup
|
||||||
name={'vendor_credit_number'}
|
name={'vendor_credit_number'}
|
||||||
label={<T id={'credit_note.label_credit_note'} />}
|
label={<T id={'credit_note.label_credit_note'} />}
|
||||||
@@ -163,7 +164,7 @@ function VendorCreditNoteFormHeaderFields({
|
|||||||
</FFormGroup>
|
</FFormGroup>
|
||||||
|
|
||||||
{/* ----------- Reference ----------- */}
|
{/* ----------- Reference ----------- */}
|
||||||
<FFormGroup label={<T id={'reference_no'} />} inline={true} fastField>
|
<FFormGroup name={'reference_no'} label={<T id={'reference_no'} />} inline={true} fastField>
|
||||||
<FInputGroup name={'reference_no'} minimal={true} fastField />
|
<FInputGroup name={'reference_no'} minimal={true} fastField />
|
||||||
</FFormGroup>
|
</FFormGroup>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ import { compose } from '@/utils';
|
|||||||
* Payment made actions bar.
|
* Payment made actions bar.
|
||||||
*/
|
*/
|
||||||
function PaymentMadeActionsBar({
|
function PaymentMadeActionsBar({
|
||||||
// #withPaymentMadesActions
|
// #withPaymentMadeActions
|
||||||
setPaymentMadesTableState,
|
setPaymentMadesTableState,
|
||||||
|
|
||||||
// #withPaymentMades
|
// #withPaymentMade
|
||||||
paymentMadesFilterConditions,
|
paymentMadesFilterConditions,
|
||||||
|
|
||||||
// #withSettings
|
// #withSettings
|
||||||
@@ -133,7 +133,7 @@ function PaymentMadeActionsBar({
|
|||||||
icon={<Icon icon={'trash-16'} iconSize={16} />}
|
icon={<Icon icon={'trash-16'} iconSize={16} />}
|
||||||
text={<T id={'delete'} />}
|
text={<T id={'delete'} />}
|
||||||
intent={Intent.DANGER}
|
intent={Intent.DANGER}
|
||||||
// onClick={handleBulkDelete}
|
// onClick={handleBulkDelete}
|
||||||
/>
|
/>
|
||||||
</If>
|
</If>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { PaymentMadesListProvider } from './PaymentMadesListProvider';
|
|||||||
import PaymentMadeActionsBar from './PaymentMadeActionsBar';
|
import PaymentMadeActionsBar from './PaymentMadeActionsBar';
|
||||||
import PaymentMadesTable from './PaymentMadesTable';
|
import PaymentMadesTable from './PaymentMadesTable';
|
||||||
|
|
||||||
import { withPaymentMades } from './withPaymentMade';
|
import { withPaymentMade } from './withPaymentMade';
|
||||||
import { withPaymentMadeActions } from './withPaymentMadeActions';
|
import { withPaymentMadeActions } from './withPaymentMadeActions';
|
||||||
|
|
||||||
import { compose, transformTableStateToQuery } from '@/utils';
|
import { compose, transformTableStateToQuery } from '@/utils';
|
||||||
@@ -17,7 +17,7 @@ import { compose, transformTableStateToQuery } from '@/utils';
|
|||||||
* Payment mades list.
|
* Payment mades list.
|
||||||
*/
|
*/
|
||||||
function PaymentMadeList({
|
function PaymentMadeList({
|
||||||
// #withPaymentMades
|
// #withPaymentMade
|
||||||
paymentMadesTableState,
|
paymentMadesTableState,
|
||||||
paymentsTableStateChanged,
|
paymentsTableStateChanged,
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ function PaymentMadeList({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
withPaymentMades(({ paymentMadesTableState, paymentsTableStateChanged }) => ({
|
withPaymentMade(({ paymentMadesTableState, paymentsTableStateChanged }) => ({
|
||||||
paymentMadesTableState,
|
paymentMadesTableState,
|
||||||
paymentsTableStateChanged,
|
paymentsTableStateChanged,
|
||||||
})),
|
})),
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { withPaymentMadeActions } from './withPaymentMadeActions';
|
|||||||
* Payment made views tabs.
|
* Payment made views tabs.
|
||||||
*/
|
*/
|
||||||
function PaymentMadeViewTabs({
|
function PaymentMadeViewTabs({
|
||||||
// #withPaymentMadesActions
|
// #withPaymentMadeActions
|
||||||
setPaymentMadesTableState,
|
setPaymentMadesTableState,
|
||||||
|
|
||||||
// #withPaymentMade
|
// #withPaymentMade
|
||||||
|
|||||||
@@ -54,6 +54,11 @@ export default defineConfig(({ mode }) => {
|
|||||||
target: env.VITE_API_PROXY_TARGET || 'http://localhost:3000',
|
target: env.VITE_API_PROXY_TARGET || 'http://localhost:3000',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
|
'/socket': {
|
||||||
|
target: env.VITE_API_PROXY_TARGET || 'http://localhost:3000',
|
||||||
|
changeOrigin: true,
|
||||||
|
ws: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
|
|||||||
Reference in New Issue
Block a user