mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-11 10:20:30 +00:00
Compare commits
1 Commits
v0.23.0-rc
...
bugs-bashi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d42a1c67a |
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"type.business": "Business",
|
||||
"type.individual": "Individual"
|
||||
}
|
||||
|
||||
@@ -48,30 +48,14 @@ export class PaginationQueryBuilder<
|
||||
// No relations defined
|
||||
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();
|
||||
|
||||
dependentRelationNames.forEach((relationName: string) => {
|
||||
relationNames.forEach((relationName: string) => {
|
||||
recordQuery.withGraphFetched(relationName);
|
||||
});
|
||||
const record = await recordQuery;
|
||||
|
||||
const hasRelations = dependentRelationNames.some((name) => {
|
||||
const hasRelations = relationNames.some((name) => {
|
||||
const val = record[name];
|
||||
return Array.isArray(val) ? val.length > 0 : val != null;
|
||||
});
|
||||
|
||||
@@ -14,7 +14,6 @@ import { BranchesSettingsService } from '../Branches/BranchesSettings';
|
||||
import { BillPaymentsController } from './BillPayments.controller';
|
||||
import { BillPaymentGLEntries } from './commands/BillPaymentGLEntries';
|
||||
import { BillPaymentGLEntriesSubscriber } from './subscribers/BillPaymentGLEntriesSubscriber';
|
||||
import { BillPaymentBillSyncSubscriber } from './subscribers/BillPaymentBillSyncSubscriber';
|
||||
import { LedgerModule } from '../Ledger/Ledger.module';
|
||||
import { AccountsModule } from '../Accounts/Accounts.module';
|
||||
import { BillPaymentsExportable } from './queries/BillPaymentsExportable';
|
||||
@@ -40,7 +39,6 @@ import { BillPaymentsPages } from './commands/BillPaymentsPages.service';
|
||||
TenancyContext,
|
||||
BillPaymentGLEntries,
|
||||
BillPaymentGLEntriesSubscriber,
|
||||
BillPaymentBillSyncSubscriber,
|
||||
BillPaymentsExportable,
|
||||
BillPaymentsImportable,
|
||||
GetBillPaymentsService,
|
||||
@@ -54,4 +52,4 @@ import { BillPaymentsPages } from './commands/BillPaymentsPages.service';
|
||||
],
|
||||
controllers: [BillPaymentsController],
|
||||
})
|
||||
export class BillPaymentsModule { }
|
||||
export class BillPaymentsModule {}
|
||||
|
||||
@@ -38,7 +38,7 @@ export class CreateBillPaymentService {
|
||||
|
||||
@Inject(BillPayment.name)
|
||||
private readonly billPaymentModel: TenantModelProxy<typeof BillPayment>,
|
||||
) { }
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Creates a new bill payment transcations and store it to the storage
|
||||
@@ -103,19 +103,11 @@ export class CreateBillPaymentService {
|
||||
} as IBillPaymentCreatingPayload);
|
||||
|
||||
// Writes the bill payment graph to the storage.
|
||||
const insertedBillPayment = await this.billPaymentModel()
|
||||
const billPayment = await this.billPaymentModel()
|
||||
.query(trx)
|
||||
.insertGraphAndFetch({
|
||||
...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.
|
||||
await this.eventPublisher.emitAsync(events.billPayment.onCreated, {
|
||||
billPayment,
|
||||
|
||||
@@ -29,7 +29,7 @@ export class EditBillPayment {
|
||||
|
||||
@Inject(Vendor.name)
|
||||
private readonly vendorModel: TenantModelProxy<typeof Vendor>,
|
||||
) { }
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Edits the details of the given bill payment.
|
||||
@@ -116,20 +116,12 @@ export class EditBillPayment {
|
||||
} as IBillPaymentEditingPayload);
|
||||
|
||||
// Edits the bill payment transaction graph on the storage.
|
||||
await this.billPaymentModel()
|
||||
const billPayment = await this.billPaymentModel()
|
||||
.query(trx)
|
||||
.upsertGraph({
|
||||
.upsertGraphAndFetch({
|
||||
id: billPaymentId,
|
||||
...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.
|
||||
await this.eventPublisher.emitAsync(events.billPayment.onEdited, {
|
||||
billPaymentId,
|
||||
|
||||
@@ -16,6 +16,8 @@ export class BillPaymentsExportable extends Exportable {
|
||||
|
||||
/**
|
||||
* Retrieves the accounts data to exportable sheet.
|
||||
* @param {number} tenantId
|
||||
* @returns
|
||||
*/
|
||||
public async exportable(query: any) {
|
||||
const filterQuery = (builder) => {
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
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,13 +7,9 @@ import { CreditNotesRefundsApplication } from './CreditNotesRefundsApplication.s
|
||||
import { CreditNoteRefundsController } from './CreditNoteRefunds.controller';
|
||||
import { CreditNotesModule } from '../CreditNotes/CreditNotes.module';
|
||||
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({
|
||||
imports: [forwardRef(() => CreditNotesModule), LedgerModule, AccountsModule],
|
||||
imports: [forwardRef(() => CreditNotesModule)],
|
||||
providers: [
|
||||
CreateRefundCreditNoteService,
|
||||
DeleteRefundCreditNoteService,
|
||||
@@ -21,10 +17,8 @@ import { AccountsModule } from '../Accounts/Accounts.module';
|
||||
RefundSyncCreditNoteBalanceService,
|
||||
CreditNotesRefundsApplication,
|
||||
GetCreditNoteRefundsService,
|
||||
RefundCreditNoteGLEntries,
|
||||
RefundCreditNoteGLEntriesSubscriber,
|
||||
],
|
||||
exports: [RefundSyncCreditNoteBalanceService],
|
||||
controllers: [CreditNoteRefundsController],
|
||||
})
|
||||
export class CreditNoteRefundsModule { }
|
||||
export class CreditNoteRefundsModule {}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { ToNumber, IsOptional } from '@/common/decorators/Validators';
|
||||
import { IsDateString, IsNotEmpty, IsPositive, IsString } from 'class-validator';
|
||||
import { IsNotEmpty, IsOptional, IsPositive, IsString } from 'class-validator';
|
||||
import { IsDate } from 'class-validator';
|
||||
import { IsNumber } from 'class-validator';
|
||||
|
||||
@@ -11,13 +10,8 @@ export class CreditNoteRefundDto {
|
||||
description: 'The id of the from account',
|
||||
example: 1,
|
||||
})
|
||||
@ApiProperty({
|
||||
description: 'The id of the from account',
|
||||
example: 1,
|
||||
})
|
||||
fromAccountId: number;
|
||||
|
||||
@ToNumber()
|
||||
@IsNumber()
|
||||
@IsPositive()
|
||||
@IsNotEmpty()
|
||||
@@ -27,7 +21,6 @@ export class CreditNoteRefundDto {
|
||||
})
|
||||
amount: number;
|
||||
|
||||
@ToNumber()
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
@IsPositive()
|
||||
@@ -37,23 +30,23 @@ export class CreditNoteRefundDto {
|
||||
})
|
||||
exchangeRate?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ApiProperty({
|
||||
description: 'The reference number of the credit note refund',
|
||||
example: '123456',
|
||||
})
|
||||
referenceNo: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ApiProperty({
|
||||
description: 'The description of the credit note refund',
|
||||
example: 'Credit note refund',
|
||||
})
|
||||
description: string;
|
||||
|
||||
@IsDateString()
|
||||
@IsDate()
|
||||
@IsNotEmpty()
|
||||
@ApiProperty({
|
||||
description: 'The date of the credit note refund',
|
||||
@@ -61,7 +54,6 @@ export class CreditNoteRefundDto {
|
||||
})
|
||||
date: Date;
|
||||
|
||||
@ToNumber()
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
@ApiProperty({
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { renderCreditNotePaperTemplateHtml } from '@bigcapital/pdf-templates';
|
||||
import { GetCreditNoteService } from './GetCreditNote.service';
|
||||
import { CreditNoteBrandingTemplate } from './CreditNoteBrandingTemplate.service';
|
||||
import { transformCreditNoteToPdfTemplate } from '../utils';
|
||||
import { CreditNote } from '../models/CreditNote';
|
||||
import { ChromiumlyTenancy } from '@/modules/ChromiumlyTenancy/ChromiumlyTenancy.service';
|
||||
import { TemplateInjectable } from '@/modules/TemplateInjectable/TemplateInjectable.service';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { PdfTemplateModel } from '@/modules/PdfTemplate/models/PdfTemplate';
|
||||
import { CreditNotePdfTemplateAttributes } from '../types/CreditNotes.types';
|
||||
@@ -15,6 +15,7 @@ import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
|
||||
export class GetCreditNotePdf {
|
||||
/**
|
||||
* @param {ChromiumlyTenancy} chromiumlyTenancy - Chromiumly tenancy service.
|
||||
* @param {TemplateInjectable} templateInjectable - Template injectable service.
|
||||
* @param {GetCreditNote} getCreditNoteService - Get credit note service.
|
||||
* @param {CreditNoteBrandingTemplate} creditNoteBrandingTemplate - Credit note branding template service.
|
||||
* @param {EventEmitter2} eventPublisher - Event publisher service.
|
||||
@@ -23,6 +24,7 @@ export class GetCreditNotePdf {
|
||||
*/
|
||||
constructor(
|
||||
private readonly chromiumlyTenancy: ChromiumlyTenancy,
|
||||
private readonly templateInjectable: TemplateInjectable,
|
||||
private readonly getCreditNoteService: GetCreditNoteService,
|
||||
private readonly creditNoteBrandingTemplate: CreditNoteBrandingTemplate,
|
||||
private readonly eventPublisher: EventEmitter2,
|
||||
@@ -34,40 +36,23 @@ export class GetCreditNotePdf {
|
||||
private readonly pdfTemplateModel: TenantModelProxy<
|
||||
typeof PdfTemplateModel
|
||||
>,
|
||||
) { }
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Retrieves credit note html content.
|
||||
* @param {number} creditNoteId - Credit note id.
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
public async getCreditNoteHtml(creditNoteId: number): Promise<string> {
|
||||
const brandingAttributes =
|
||||
await this.getCreditNoteBrandingAttributes(creditNoteId);
|
||||
|
||||
// Map attributes to match the React component props
|
||||
// The branding template returns companyLogoUri, but type may have companyLogo
|
||||
const props = {
|
||||
...brandingAttributes,
|
||||
companyLogoUri:
|
||||
(brandingAttributes as any).companyLogoUri ||
|
||||
(brandingAttributes as any).companyLogo ||
|
||||
'',
|
||||
};
|
||||
|
||||
return renderCreditNotePaperTemplateHtml(props);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves credit note pdf content.
|
||||
* Retrieves sale invoice pdf content.
|
||||
* @param {number} creditNoteId - Credit note id.
|
||||
* @returns {Promise<[Buffer, string]>}
|
||||
*/
|
||||
public async getCreditNotePdf(
|
||||
creditNoteId: number,
|
||||
): Promise<[Buffer, string]> {
|
||||
const brandingAttributes =
|
||||
await this.getCreditNoteBrandingAttributes(creditNoteId);
|
||||
const htmlContent = await this.templateInjectable.render(
|
||||
'modules/credit-note-standard',
|
||||
brandingAttributes,
|
||||
);
|
||||
const filename = await this.getCreditNoteFilename(creditNoteId);
|
||||
const htmlContent = await this.getCreditNoteHtml(creditNoteId);
|
||||
|
||||
const document =
|
||||
await this.chromiumlyTenancy.convertHtmlContent(htmlContent);
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
import { FinancialSheet } from '../../common/FinancialSheet';
|
||||
import { JournalSheetRepository } from './JournalSheetRepository';
|
||||
import { ILedgerEntry } from '@/modules/Ledger/types/Ledger.types';
|
||||
import { getTransactionTypeLabel } from '@/modules/BankingTransactions/utils';
|
||||
|
||||
export class JournalSheet extends FinancialSheet {
|
||||
readonly query: IJournalReportQuery;
|
||||
@@ -98,13 +97,10 @@ export class JournalSheet extends FinancialSheet {
|
||||
|
||||
transactionType: groupEntry.transactionType,
|
||||
referenceId: groupEntry.transactionId,
|
||||
referenceTypeFormatted: this.i18n.t(
|
||||
getTransactionTypeLabel(
|
||||
groupEntry.transactionType,
|
||||
groupEntry.transactionSubType,
|
||||
),
|
||||
),
|
||||
referenceTypeFormatted: this.i18n.t(groupEntry.transactionType),
|
||||
|
||||
entries: this.entriesMapper(entriesGroup),
|
||||
|
||||
currencyCode: this.baseCurrency,
|
||||
|
||||
credit: totalCredit,
|
||||
|
||||
@@ -6,7 +6,6 @@ import { SaleInvoice } from '@/modules/SaleInvoices/models/SaleInvoice';
|
||||
import { SaleReceipt } from '@/modules/SaleReceipts/models/SaleReceipt';
|
||||
import { Item } from '@/modules/Items/models/Item';
|
||||
import { BaseModel } from '@/models/Model';
|
||||
import { ItemEntry } from '@/modules/TransactionItemEntry/models/ItemEntry';
|
||||
|
||||
export class InventoryCostLotTracker extends BaseModel {
|
||||
date: Date;
|
||||
@@ -28,7 +27,6 @@ export class InventoryCostLotTracker extends BaseModel {
|
||||
warehouseId: number;
|
||||
|
||||
item?: Item;
|
||||
itemEntry?: ItemEntry;
|
||||
invoice?: SaleInvoice;
|
||||
receipt?: SaleReceipt;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ export class InventoryCostSubscriber {
|
||||
private readonly itemsQuantitySync: InventoryItemsQuantitySyncService,
|
||||
private readonly inventoryService: InventoryComputeCostService,
|
||||
private readonly importAls: ImportAls,
|
||||
) { }
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Sync inventory items quantity once inventory transactions created.
|
||||
@@ -60,7 +60,7 @@ export class InventoryCostSubscriber {
|
||||
* Marks items cost compute running state.
|
||||
*/
|
||||
@OnEvent(events.inventory.onInventoryTransactionsCreated)
|
||||
async markGlobalSettingsComputeItems({ }) {
|
||||
async markGlobalSettingsComputeItems({}) {
|
||||
await this.inventoryService.markItemsCostComputeRunning(true);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ export class InventoryCostSubscriber {
|
||||
* Marks items cost compute as completed.
|
||||
*/
|
||||
@OnEvent(events.inventory.onInventoryCostEntriesWritten)
|
||||
async markGlobalSettingsComputeItemsCompeted({ }) {
|
||||
async markGlobalSettingsComputeItemsCompeted({}) {
|
||||
await this.inventoryService.markItemsCostComputeRunning(false);
|
||||
}
|
||||
|
||||
@@ -80,13 +80,15 @@ export class InventoryCostSubscriber {
|
||||
itemId,
|
||||
startingDate,
|
||||
}: IComputeItemCostJobCompletedPayload) {
|
||||
// Convert startingDate to Date if it's a string
|
||||
const startingDateObj = startingDate instanceof Date
|
||||
? startingDate
|
||||
: new Date(startingDate);
|
||||
|
||||
// Write GL entries for inventory cost lots after cost computation completes
|
||||
await this.saleInvoicesCost.writeCostLotsGLEntries(startingDateObj);
|
||||
// const dependsComputeJobs = await this.agenda.jobs({
|
||||
// name: 'compute-item-cost',
|
||||
// nextRunAt: { $ne: null },
|
||||
// 'data.tenantId': tenantId,
|
||||
// });
|
||||
// // There is no scheduled compute jobs waiting.
|
||||
// if (dependsComputeJobs.length === 0) {
|
||||
// await this.saleInvoicesCost.scheduleWriteJournalEntries(startingDate);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,8 +38,7 @@ export class SaleInvoiceCostGLEntries {
|
||||
.modify('filterDateRange', startingDate)
|
||||
.orderBy('date', 'ASC')
|
||||
.withGraphFetched('invoice')
|
||||
.withGraphFetched('item')
|
||||
.withGraphFetched('itemEntry');
|
||||
.withGraphFetched('item');
|
||||
|
||||
const ledger = this.getInventoryCostLotsLedger(inventoryCostLotTrans);
|
||||
|
||||
@@ -80,9 +79,6 @@ export class SaleInvoiceCostGLEntries {
|
||||
transactionType: inventoryCostLot.transactionType,
|
||||
transactionId: inventoryCostLot.transactionId,
|
||||
|
||||
transactionNumber: inventoryCostLot.invoice.invoiceNo,
|
||||
referenceNumber: inventoryCostLot.invoice.referenceNo,
|
||||
|
||||
date: inventoryCostLot.date,
|
||||
indexGroup: 20,
|
||||
costable: true,
|
||||
@@ -109,9 +105,6 @@ export class SaleInvoiceCostGLEntries {
|
||||
const costAccountId =
|
||||
inventoryCostLot.costAccountId || inventoryCostLot.item.costAccountId;
|
||||
|
||||
// Get description from item entry if available
|
||||
const description = inventoryCostLot.itemEntry?.description || null;
|
||||
|
||||
// XXX Debit - Cost account.
|
||||
const costEntry = {
|
||||
...commonEntry,
|
||||
@@ -119,7 +112,6 @@ export class SaleInvoiceCostGLEntries {
|
||||
accountId: costAccountId,
|
||||
accountNormal: AccountNormal.DEBIT,
|
||||
itemId: inventoryCostLot.itemId,
|
||||
note: description,
|
||||
index: getIndexIncrement(),
|
||||
};
|
||||
// XXX Credit - Inventory account.
|
||||
@@ -129,7 +121,6 @@ export class SaleInvoiceCostGLEntries {
|
||||
accountId: inventoryCostLot.item.inventoryAccountId,
|
||||
accountNormal: AccountNormal.DEBIT,
|
||||
itemId: inventoryCostLot.itemId,
|
||||
note: description,
|
||||
index: getIndexIncrement(),
|
||||
};
|
||||
return [costEntry, inventoryEntry];
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
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 { SaleInvoiceCostGLEntries } from '../SaleInvoiceCostGLEntries';
|
||||
|
||||
@Injectable()
|
||||
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.
|
||||
* @param {IInventoryCostLotsGLEntriesWriteEvent}
|
||||
*/
|
||||
@OnEvent(events.inventory.onCostLotsGLEntriesWrite)
|
||||
async writeInvoicesCostEntriesOnCostLotsWritten({
|
||||
trx,
|
||||
startingDate,
|
||||
|
||||
@@ -2,35 +2,19 @@ import { Injectable } from '@nestjs/common';
|
||||
import { DeleteRefundVendorCreditService } from './commands/DeleteRefundVendorCredit.service';
|
||||
import { RefundVendorCredit } from './models/RefundVendorCredit';
|
||||
import { CreateRefundVendorCredit } from './commands/CreateRefundVendorCredit.service';
|
||||
import { IRefundVendorCreditDTO } from './types/VendorCreditRefund.types';
|
||||
import { RefundVendorCreditDto } from './dtos/RefundVendorCredit.dto';
|
||||
import { GetRefundVendorCreditsService } from './queries/GetRefundVendorCredits.service';
|
||||
import { IRefundVendorCreditPOJO } from './types/VendorCreditRefund.types';
|
||||
|
||||
@Injectable()
|
||||
export class VendorCreditsRefundApplication {
|
||||
/**
|
||||
* @param {CreateRefundVendorCredit} createRefundVendorCreditService
|
||||
* @param {DeleteRefundVendorCreditService} deleteRefundVendorCreditService
|
||||
* @param {GetRefundVendorCreditsService} getRefundVendorCreditsService
|
||||
*/
|
||||
constructor(
|
||||
private readonly createRefundVendorCreditService: CreateRefundVendorCredit,
|
||||
private readonly deleteRefundVendorCreditService: DeleteRefundVendorCreditService,
|
||||
private readonly getRefundVendorCreditsService: GetRefundVendorCreditsService,
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Retrieve the vendor credit refunds graph.
|
||||
* @param {number} vendorCreditId - Vendor credit id.
|
||||
* @returns {Promise<IRefundVendorCreditPOJO[]>}
|
||||
*/
|
||||
public getVendorCreditRefunds(
|
||||
vendorCreditId: number,
|
||||
): Promise<IRefundVendorCreditPOJO[]> {
|
||||
return this.getRefundVendorCreditsService.getVendorCreditRefunds(
|
||||
vendorCreditId,
|
||||
);
|
||||
}
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Creates a refund vendor credit.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Body, Controller, Delete, Get, Param, Post } from '@nestjs/common';
|
||||
import { Body, Controller, Delete, Param, Post } from '@nestjs/common';
|
||||
import { VendorCreditsRefundApplication } from './VendorCreditsRefund.application';
|
||||
import { RefundVendorCredit } from './models/RefundVendorCredit';
|
||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
@@ -9,22 +9,7 @@ import { RefundVendorCreditDto } from './dtos/RefundVendorCredit.dto';
|
||||
export class VendorCreditsRefundController {
|
||||
constructor(
|
||||
private readonly vendorCreditsRefundApplication: VendorCreditsRefundApplication,
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Retrieve the vendor credit refunds graph.
|
||||
* @param {number} vendorCreditId - Vendor credit id.
|
||||
* @returns {Promise<IRefundVendorCreditPOJO[]>}
|
||||
*/
|
||||
@Get(':vendorCreditId/refund')
|
||||
@ApiOperation({ summary: 'Retrieve the vendor credit refunds graph.' })
|
||||
public getVendorCreditRefunds(
|
||||
@Param('vendorCreditId') vendorCreditId: string,
|
||||
) {
|
||||
return this.vendorCreditsRefundApplication.getVendorCreditRefunds(
|
||||
Number(vendorCreditId),
|
||||
);
|
||||
}
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Creates a refund vendor credit.
|
||||
@@ -32,7 +17,7 @@ export class VendorCreditsRefundController {
|
||||
* @param {IRefundVendorCreditDTO} refundVendorCreditDTO
|
||||
* @returns {Promise<RefundVendorCredit>}
|
||||
*/
|
||||
@Post(':vendorCreditId/refund')
|
||||
@Post(':vendorCreditId/refunds')
|
||||
@ApiOperation({ summary: 'Create a refund for the given vendor credit.' })
|
||||
public async createRefundVendorCredit(
|
||||
@Param('vendorCreditId') vendorCreditId: string,
|
||||
|
||||
@@ -6,21 +6,15 @@ import { VendorCreditsRefundApplication } from './VendorCreditsRefund.applicatio
|
||||
import { CreateRefundVendorCredit } from './commands/CreateRefundVendorCredit.service';
|
||||
import { WarehousesModule } from '../Warehouses/Warehouses.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({
|
||||
imports: [WarehousesModule, BranchesModule, LedgerModule, AccountsModule],
|
||||
imports: [WarehousesModule, BranchesModule],
|
||||
providers: [
|
||||
GetRefundVendorCreditsService,
|
||||
DeleteRefundVendorCreditService,
|
||||
CreateRefundVendorCredit,
|
||||
VendorCreditsRefundApplication,
|
||||
RefundVendorCreditGLEntries,
|
||||
RefundVendorCreditGLEntriesSubscriber,
|
||||
VendorCreditsRefundApplication
|
||||
],
|
||||
controllers: [VendorCreditsRefundController],
|
||||
})
|
||||
export class VendorCreditsRefundModule { }
|
||||
export class VendorCreditsRefundModule {}
|
||||
|
||||
@@ -1,172 +1,159 @@
|
||||
import { LedgerStorageService } from '@/modules/Ledger/LedgerStorage.service';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { RefundVendorCredit } from '../models/RefundVendorCredit';
|
||||
import { Ledger } from '@/modules/Ledger/Ledger';
|
||||
import { Knex } from 'knex';
|
||||
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
|
||||
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';
|
||||
// import { Inject, Service } from 'typedi';
|
||||
// import { Knex } from 'knex';
|
||||
// import { AccountNormal, ILedgerEntry } from '@/interfaces';
|
||||
// import { IRefundVendorCredit } from '@/interfaces';
|
||||
// import JournalPosterService from '@/services/Sales/JournalPosterService';
|
||||
// import LedgerRepository from '@/services/Ledger/LedgerRepository';
|
||||
// import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
|
||||
@Injectable()
|
||||
export class RefundVendorCreditGLEntries {
|
||||
constructor(
|
||||
private readonly ledgerStorage: LedgerStorageService,
|
||||
private readonly accountRepository: AccountRepository,
|
||||
// @Service()
|
||||
// export default class RefundVendorCreditGLEntries {
|
||||
// @Inject()
|
||||
// private journalService: JournalPosterService;
|
||||
|
||||
@Inject(Account.name)
|
||||
private readonly accountModel: TenantModelProxy<typeof Account>,
|
||||
// @Inject()
|
||||
// private ledgerRepository: LedgerRepository;
|
||||
|
||||
@Inject(RefundVendorCredit.name)
|
||||
private readonly refundVendorCreditModel: TenantModelProxy<
|
||||
typeof RefundVendorCredit
|
||||
>,
|
||||
) { }
|
||||
// @Inject()
|
||||
// private tenancy: HasTenancyService;
|
||||
|
||||
/**
|
||||
* Retrieves the refund vendor credit common GL entry.
|
||||
* @param {RefundVendorCredit} refundVendorCredit
|
||||
* @returns
|
||||
*/
|
||||
private getRefundVendorCreditCommonGLEntry = (
|
||||
refundVendorCredit: RefundVendorCredit,
|
||||
) => {
|
||||
const model = refundVendorCredit as any;
|
||||
return {
|
||||
currencyCode: refundVendorCredit.currencyCode,
|
||||
exchangeRate: refundVendorCredit.exchangeRate,
|
||||
// /**
|
||||
// * Retrieves the refund credit common GL entry.
|
||||
// * @param {IRefundVendorCredit} refundCredit
|
||||
// */
|
||||
// private getRefundCreditGLCommonEntry = (
|
||||
// refundCredit: IRefundVendorCredit
|
||||
// ) => {
|
||||
// return {
|
||||
// exchangeRate: refundCredit.exchangeRate,
|
||||
// currencyCode: refundCredit.currencyCode,
|
||||
|
||||
transactionType: 'RefundVendorCredit',
|
||||
transactionId: refundVendorCredit.id,
|
||||
date: refundVendorCredit.date,
|
||||
userId: refundVendorCredit.vendorCredit?.userId,
|
||||
// transactionType: 'RefundVendorCredit',
|
||||
// transactionId: refundCredit.id,
|
||||
|
||||
referenceNumber: refundVendorCredit.referenceNo,
|
||||
// date: refundCredit.date,
|
||||
// userId: refundCredit.userId,
|
||||
// referenceNumber: refundCredit.referenceNo,
|
||||
// createdAt: refundCredit.createdAt,
|
||||
// indexGroup: 10,
|
||||
|
||||
createdAt: model.createdAt,
|
||||
indexGroup: 10,
|
||||
// credit: 0,
|
||||
// debit: 0,
|
||||
|
||||
credit: 0,
|
||||
debit: 0,
|
||||
// note: refundCredit.description,
|
||||
// branchId: refundCredit.branchId,
|
||||
// };
|
||||
// };
|
||||
|
||||
note: refundVendorCredit.description,
|
||||
branchId: refundVendorCredit.branchId,
|
||||
};
|
||||
};
|
||||
// /**
|
||||
// * Retrieves the refund credit payable GL entry.
|
||||
// * @param {IRefundVendorCredit} refundCredit
|
||||
// * @param {number} APAccountId
|
||||
// * @returns {ILedgerEntry}
|
||||
// */
|
||||
// private getRefundCreditGLPayableEntry = (
|
||||
// refundCredit: IRefundVendorCredit,
|
||||
// APAccountId: number
|
||||
// ): ILedgerEntry => {
|
||||
// const commonEntry = this.getRefundCreditGLCommonEntry(refundCredit);
|
||||
|
||||
/**
|
||||
* Retrieves the refund vendor credit payable GL entry.
|
||||
* @param {RefundVendorCredit} refundVendorCredit
|
||||
* @param {number} APAccountId
|
||||
* @returns {ILedgerEntry}
|
||||
*/
|
||||
private getRefundVendorCreditGLPayableEntry = (
|
||||
refundVendorCredit: RefundVendorCredit,
|
||||
APAccountId: number,
|
||||
): ILedgerEntry => {
|
||||
const commonEntry = this.getRefundVendorCreditCommonGLEntry(
|
||||
refundVendorCredit,
|
||||
);
|
||||
// return {
|
||||
// ...commonEntry,
|
||||
// credit: refundCredit.amount,
|
||||
// accountId: APAccountId,
|
||||
// contactId: refundCredit.vendorCredit.vendorId,
|
||||
// index: 1,
|
||||
// accountNormal: AccountNormal.CREDIT,
|
||||
// };
|
||||
// };
|
||||
|
||||
return {
|
||||
...commonEntry,
|
||||
credit: refundVendorCredit.amount,
|
||||
accountId: APAccountId,
|
||||
contactId: refundVendorCredit.vendorCredit.vendorId,
|
||||
index: 1,
|
||||
accountNormal: AccountNormal.CREDIT,
|
||||
};
|
||||
};
|
||||
// /**
|
||||
// * Retrieves the refund credit deposit GL entry.
|
||||
// * @param {IRefundVendorCredit} refundCredit
|
||||
// * @returns {ILedgerEntry}
|
||||
// */
|
||||
// private getRefundCreditGLDepositEntry = (
|
||||
// refundCredit: IRefundVendorCredit
|
||||
// ): ILedgerEntry => {
|
||||
// const commonEntry = this.getRefundCreditGLCommonEntry(refundCredit);
|
||||
|
||||
/**
|
||||
* Retrieves the refund vendor credit deposit GL entry.
|
||||
* @param {RefundVendorCredit} refundVendorCredit
|
||||
* @returns {ILedgerEntry}
|
||||
*/
|
||||
private getRefundVendorCreditGLDepositEntry = (
|
||||
refundVendorCredit: RefundVendorCredit,
|
||||
): ILedgerEntry => {
|
||||
const commonEntry = this.getRefundVendorCreditCommonGLEntry(
|
||||
refundVendorCredit,
|
||||
);
|
||||
// return {
|
||||
// ...commonEntry,
|
||||
// debit: refundCredit.amount,
|
||||
// accountId: refundCredit.depositAccountId,
|
||||
// index: 2,
|
||||
// accountNormal: AccountNormal.DEBIT,
|
||||
// };
|
||||
// };
|
||||
|
||||
return {
|
||||
...commonEntry,
|
||||
debit: refundVendorCredit.amount,
|
||||
accountId: refundVendorCredit.depositAccountId,
|
||||
index: 2,
|
||||
accountNormal: AccountNormal.DEBIT,
|
||||
};
|
||||
};
|
||||
// /**
|
||||
// * Retrieve refund vendor credit GL entries.
|
||||
// * @param {IRefundVendorCredit} refundCredit
|
||||
// * @param {number} APAccountId
|
||||
// * @returns {ILedgerEntry[]}
|
||||
// */
|
||||
// public getRefundCreditGLEntries = (
|
||||
// refundCredit: IRefundVendorCredit,
|
||||
// APAccountId: number
|
||||
// ): ILedgerEntry[] => {
|
||||
// const payableEntry = this.getRefundCreditGLPayableEntry(
|
||||
// refundCredit,
|
||||
// APAccountId
|
||||
// );
|
||||
// const depositEntry = this.getRefundCreditGLDepositEntry(refundCredit);
|
||||
|
||||
/**
|
||||
* 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];
|
||||
// };
|
||||
|
||||
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);
|
||||
|
||||
/**
|
||||
* Creates refund vendor credit GL entries.
|
||||
* @param {number} refundVendorCreditId
|
||||
* @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');
|
||||
// // Retireve refund with associated vendor credit entity.
|
||||
// const refundCredit = await RefundVendorCredit.query()
|
||||
// .findById(refundCreditId)
|
||||
// .withGraphFetched('vendorCredit');
|
||||
|
||||
// Retrieve the payable account (A/P) account based on the given currency.
|
||||
const APAccount = await this.accountRepository.findOrCreateAccountsPayable(
|
||||
refundVendorCredit.currencyCode,
|
||||
{},
|
||||
trx,
|
||||
);
|
||||
// const payableAccount = await Account.query().findOne(
|
||||
// 'slug',
|
||||
// 'accounts-payable'
|
||||
// );
|
||||
// // Generates the GL entries of the given refund credit.
|
||||
// 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.
|
||||
const refundGLEntries = this.getRefundVendorCreditGLEntries(
|
||||
refundVendorCredit,
|
||||
APAccount.id,
|
||||
);
|
||||
const ledger = new Ledger(refundGLEntries);
|
||||
|
||||
// Saves refund ledger entries.
|
||||
await this.ledgerStorage.commit(ledger, trx);
|
||||
};
|
||||
|
||||
/**
|
||||
* Reverts refund vendor credit GL entries.
|
||||
* @param {number} refundVendorCreditId
|
||||
* @param {Knex.Transaction} trx
|
||||
*/
|
||||
public revertRefundVendorCreditGLEntries = async (
|
||||
refundVendorCreditId: number,
|
||||
trx?: Knex.Transaction,
|
||||
) => {
|
||||
await this.ledgerStorage.deleteByReference(
|
||||
refundVendorCreditId,
|
||||
'RefundVendorCredit',
|
||||
trx,
|
||||
);
|
||||
};
|
||||
}
|
||||
// /**
|
||||
// * Reverts refund credit note GL entries.
|
||||
// * @param {number} tenantId
|
||||
// * @param {number} refundCreditId
|
||||
// * @param {Knex.Transaction} trx
|
||||
// * @return {Promise<void>}
|
||||
// */
|
||||
// public revertRefundCreditGLEntries = async (
|
||||
// tenantId: number,
|
||||
// refundCreditId: number,
|
||||
// trx?: Knex.Transaction
|
||||
// ) => {
|
||||
// await this.journalService.revertJournalTransactions(
|
||||
// tenantId,
|
||||
// refundCreditId,
|
||||
// 'RefundVendorCredit',
|
||||
// trx
|
||||
// );
|
||||
// };
|
||||
// }
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { IsOptional, ToNumber } from '@/common/decorators/Validators';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsDateString, Min } from 'class-validator';
|
||||
import { Min } from 'class-validator';
|
||||
import { IsString } from 'class-validator';
|
||||
import { IsDate } from 'class-validator';
|
||||
import { IsNotEmpty, IsNumber, IsPositive } from 'class-validator';
|
||||
import { IsNotEmpty, IsNumber, IsOptional, IsPositive } from 'class-validator';
|
||||
|
||||
export class RefundVendorCreditDto {
|
||||
@ToNumber()
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
@Min(0)
|
||||
@@ -34,7 +32,6 @@ export class RefundVendorCreditDto {
|
||||
})
|
||||
depositAccountId: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ApiProperty({
|
||||
@@ -43,7 +40,7 @@ export class RefundVendorCreditDto {
|
||||
})
|
||||
description: string;
|
||||
|
||||
@IsDateString()
|
||||
@IsDate()
|
||||
@IsNotEmpty()
|
||||
@ApiProperty({
|
||||
description: 'The date of the refund',
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import { Controller, Get, Param } from '@nestjs/common';
|
||||
import { WarehousesApplication } from './WarehousesApplication.service';
|
||||
import {
|
||||
ApiOperation,
|
||||
ApiParam,
|
||||
ApiResponse,
|
||||
ApiTags,
|
||||
} from '@nestjs/swagger';
|
||||
import { ApiCommonHeaders } from '@/common/decorators/ApiCommonHeaders';
|
||||
|
||||
@Controller('items')
|
||||
@ApiTags('Warehouses')
|
||||
@ApiCommonHeaders()
|
||||
export class WarehouseItemsController {
|
||||
constructor(private warehousesApplication: WarehousesApplication) { }
|
||||
|
||||
@Get(':id/warehouses')
|
||||
@ApiOperation({
|
||||
summary: 'Retrieves the item associated warehouses.',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description:
|
||||
'The item associated warehouses have been successfully retrieved.',
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'The item not found.' })
|
||||
@ApiParam({
|
||||
name: 'id',
|
||||
required: true,
|
||||
type: Number,
|
||||
description: 'The item id',
|
||||
})
|
||||
getItemWarehouses(@Param('id') itemId: string) {
|
||||
return this.warehousesApplication.getItemWarehouses(Number(itemId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,4 +85,10 @@ export class WarehousesController {
|
||||
markWarehousePrimary(@Param('id') warehouseId: string) {
|
||||
return this.warehousesApplication.markWarehousePrimary(Number(warehouseId));
|
||||
}
|
||||
|
||||
@Get('items/:itemId')
|
||||
@ApiOperation({ summary: 'Get item warehouses' })
|
||||
getItemWarehouses(@Param('itemId') itemId: string) {
|
||||
return this.warehousesApplication.getItemWarehouses(Number(itemId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import { CreateWarehouse } from './commands/CreateWarehouse.service';
|
||||
import { EditWarehouse } from './commands/EditWarehouse.service';
|
||||
import { DeleteWarehouseService } from './commands/DeleteWarehouse.service';
|
||||
import { WarehousesController } from './Warehouses.controller';
|
||||
import { WarehouseItemsController } from './WarehouseItems.controller';
|
||||
import { GetWarehouse } from './queries/GetWarehouse';
|
||||
import { WarehouseMarkPrimary } from './commands/WarehouseMarkPrimary.service';
|
||||
import { GetWarehouses } from './queries/GetWarehouses';
|
||||
@@ -48,7 +47,7 @@ const models = [RegisterTenancyModel(Warehouse)];
|
||||
|
||||
@Module({
|
||||
imports: [TenancyDatabaseModule, ...models],
|
||||
controllers: [WarehousesController, WarehouseItemsController],
|
||||
controllers: [WarehousesController],
|
||||
providers: [
|
||||
CreateWarehouse,
|
||||
EditWarehouse,
|
||||
@@ -91,6 +90,6 @@ const models = [RegisterTenancyModel(Warehouse)];
|
||||
InventoryTransactionsWarehouses,
|
||||
ValidateWarehouseExistance
|
||||
],
|
||||
exports: [WarehousesSettings, WarehouseTransactionDTOTransform, WarehousesApplication, ...models],
|
||||
exports: [WarehousesSettings, WarehouseTransactionDTOTransform, ...models],
|
||||
})
|
||||
export class WarehousesModule {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// @ts-nocheck
|
||||
import React, { useMemo } from 'react';
|
||||
import React from 'react';
|
||||
import { Position, Checkbox, InputGroup } from '@blueprintjs/core';
|
||||
import { DateInput } from '@blueprintjs/datetime';
|
||||
import moment from 'moment';
|
||||
@@ -7,29 +7,23 @@ import intl from 'react-intl-universal';
|
||||
import { isUndefined } from 'lodash';
|
||||
|
||||
import { useAutofocus } from '@/hooks';
|
||||
import { T, Choose } from '@/components';
|
||||
import { Select } from '@/components/Forms';
|
||||
import { T, Choose, ListSelect } from '@/components';
|
||||
import { momentFormatter } from '@/utils';
|
||||
|
||||
function AdvancedFilterEnumerationField({ options, value, ...rest }) {
|
||||
const selectedItem = useMemo(
|
||||
() => options.find((opt) => opt.key === value) || null,
|
||||
[options, value],
|
||||
);
|
||||
|
||||
return (
|
||||
<Select
|
||||
<ListSelect
|
||||
items={options}
|
||||
selectedItem={selectedItem}
|
||||
selectedItem={value}
|
||||
popoverProps={{
|
||||
fill: true,
|
||||
inline: true,
|
||||
minimal: true,
|
||||
captureDismiss: true,
|
||||
}}
|
||||
placeholder={<T id={'filter.select_option'} />}
|
||||
textAccessor={'label'}
|
||||
valueAccessor={'key'}
|
||||
defaultText={<T id={'filter.select_option'} />}
|
||||
textProp={'label'}
|
||||
selectedItemProp={'key'}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -14,3 +14,4 @@ const mapActionsToProps = (dispatch) => ({
|
||||
});
|
||||
|
||||
export const withAccountsTableActions = connect(null, mapActionsToProps);
|
||||
export const withAccountsActions = withAccountsTableActions;
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Intent, Alert } from '@blueprintjs/core';
|
||||
import { queryCache } from 'react-query';
|
||||
import { AppToaster } from '@/components';
|
||||
|
||||
// import { withAccountsActions } from '@/containers/Accounts/withAccountsTableActions';
|
||||
import { withAccountsActions } from '@/containers/Accounts/withAccountsTableActions';
|
||||
import { withAlertStoreConnect } from '@/containers/Alert/withAlertStoreConnect';
|
||||
import { withAlertActions } from '@/containers/Alert/withAlertActions';
|
||||
|
||||
@@ -22,7 +22,7 @@ function AccountBulkInactivateAlert({
|
||||
|
||||
closeAlert,
|
||||
}) {
|
||||
|
||||
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
const selectedRowsCount = 0;
|
||||
|
||||
@@ -41,7 +41,7 @@ function AccountBulkInactivateAlert({
|
||||
});
|
||||
queryCache.invalidateQueries('accounts-table');
|
||||
})
|
||||
.catch((errors) => { })
|
||||
.catch((errors) => {})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
closeAlert(name);
|
||||
@@ -68,5 +68,5 @@ function AccountBulkInactivateAlert({
|
||||
export default compose(
|
||||
withAlertStoreConnect(),
|
||||
withAlertActions,
|
||||
// withAccountsActions,
|
||||
withAccountsActions,
|
||||
)(AccountBulkInactivateAlert);
|
||||
|
||||
@@ -8,7 +8,7 @@ import ReferenceNumberForm from '@/containers/JournalNumber/ReferenceNumberForm'
|
||||
import { withDialogActions } from '@/containers/Dialog/withDialogActions';
|
||||
import { withSettingsActions } from '@/containers/Settings/withSettingsActions';
|
||||
import { withSettings } from '@/containers/Settings/withSettings';
|
||||
import { withBillsActions } from '@/containers/Purchases/Bills/BillsLanding/withBillsActions';
|
||||
import { withBillActions } from '@/containers/Purchases/Bills/BillsLanding/withBillsActions';
|
||||
|
||||
import { compose, optionsMapToArray } from '@/utils';
|
||||
|
||||
@@ -28,7 +28,7 @@ function BillNumberDialogContent({
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
|
||||
// #withBillsActions
|
||||
// #withBillActions
|
||||
setBillNumberChanged,
|
||||
}) {
|
||||
const fetchSettings = useQuery(['settings'], () => requestFetchOptions({}));
|
||||
@@ -76,5 +76,5 @@ export default compose(
|
||||
nextNumber: billsettings?.next_number,
|
||||
numberPrefix: billsettings?.number_prefix,
|
||||
})),
|
||||
withBillsActions,
|
||||
withBillActions,
|
||||
)(BillNumberDialogContent);
|
||||
|
||||
@@ -63,6 +63,7 @@ function ContactDuplicateForm({
|
||||
name={'contact_type'}
|
||||
label={<T id={'contact_type'} />}
|
||||
labelInfo={<FieldRequiredHint />}
|
||||
className={'form-group--select-list'}
|
||||
>
|
||||
<FSelect
|
||||
name={'contact_type'}
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import { Field, ErrorMessage, FastField, useFormikContext } from 'formik';
|
||||
import { Field, ErrorMessage, FastField } from 'formik';
|
||||
import { FormGroup, InputGroup } from '@blueprintjs/core';
|
||||
import { inputIntent, toSafeNumber } from '@/utils';
|
||||
import {
|
||||
Row,
|
||||
Col,
|
||||
MoneyInputGroup,
|
||||
FormattedMessage as T,
|
||||
FMoneyInputGroup,
|
||||
FFormGroup,
|
||||
FInputGroup,
|
||||
} from '@/components';
|
||||
import { Row, Col, MoneyInputGroup, FormattedMessage as T } from '@/components';
|
||||
import { useAutofocus } from '@/hooks';
|
||||
import { decrementQuantity } from './utils';
|
||||
|
||||
@@ -20,19 +12,27 @@ import { decrementQuantity } from './utils';
|
||||
*/
|
||||
function DecrementAdjustmentFields() {
|
||||
const decrementFieldRef = useAutofocus();
|
||||
const { values, setFieldValue } = useFormikContext();
|
||||
|
||||
return (
|
||||
<Row className={'row--decrement-fields'}>
|
||||
{/*------------ Quantity on hand -----------*/}
|
||||
<Col className={'col--quantity-on-hand'}>
|
||||
<FFormGroup name={'quantity_on_hand'} label={<T id={'qty_on_hand'} />}>
|
||||
<FInputGroup
|
||||
name={'quantity_on_hand'}
|
||||
disabled={true}
|
||||
medium={'true'}
|
||||
/>
|
||||
</FFormGroup>
|
||||
<FastField name={'quantity_on_hand'}>
|
||||
{({ field, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={<T id={'qty_on_hand'} />}
|
||||
intent={inputIntent({ error, touched })}
|
||||
helperText={<ErrorMessage name="quantity_on_hand" />}
|
||||
>
|
||||
<InputGroup
|
||||
disabled={true}
|
||||
medium={'true'}
|
||||
intent={inputIntent({ error, touched })}
|
||||
{...field}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
</Col>
|
||||
|
||||
<Col className={'col--sign'}>
|
||||
@@ -41,23 +41,40 @@ function DecrementAdjustmentFields() {
|
||||
|
||||
{/*------------ Decrement -----------*/}
|
||||
<Col className={'col--decrement'}>
|
||||
<FFormGroup name={'quantity'} label={<T id={'decrement'} />} fill>
|
||||
<FMoneyInputGroup
|
||||
name={'quantity'}
|
||||
allowDecimals={false}
|
||||
allowNegativeValue={true}
|
||||
inputRef={(ref) => (decrementFieldRef.current = ref)}
|
||||
onBlurValue={(value) => {
|
||||
setFieldValue(
|
||||
'new_quantity',
|
||||
decrementQuantity(
|
||||
toSafeNumber(value),
|
||||
toSafeNumber(values.quantity_on_hand),
|
||||
),
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</FFormGroup>
|
||||
<Field name={'quantity'}>
|
||||
{({
|
||||
form: { values, setFieldValue },
|
||||
field,
|
||||
meta: { error, touched },
|
||||
}) => (
|
||||
<FormGroup
|
||||
label={<T id={'decrement'} />}
|
||||
intent={inputIntent({ error, touched })}
|
||||
helperText={<ErrorMessage name="quantity" />}
|
||||
fill={true}
|
||||
>
|
||||
<MoneyInputGroup
|
||||
value={field.value}
|
||||
allowDecimals={false}
|
||||
allowNegativeValue={true}
|
||||
inputRef={(ref) => (decrementFieldRef.current = ref)}
|
||||
onChange={(value) => {
|
||||
setFieldValue('quantity', value);
|
||||
}}
|
||||
onBlurValue={(value) => {
|
||||
setFieldValue(
|
||||
'new_quantity',
|
||||
decrementQuantity(
|
||||
toSafeNumber(value),
|
||||
toSafeNumber(values.quantity_on_hand),
|
||||
),
|
||||
);
|
||||
}}
|
||||
intent={inputIntent({ error, touched })}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</Field>
|
||||
</Col>
|
||||
|
||||
<Col className={'col--sign'}>
|
||||
@@ -65,27 +82,38 @@ function DecrementAdjustmentFields() {
|
||||
</Col>
|
||||
{/*------------ New quantity -----------*/}
|
||||
<Col className={'col--quantity'}>
|
||||
<FFormGroup
|
||||
name={'new_quantity'}
|
||||
label={<T id={'new_quantity'} />}
|
||||
fill
|
||||
fastField
|
||||
>
|
||||
<FMoneyInputGroup
|
||||
name={'new_quantity'}
|
||||
allowDecimals={false}
|
||||
allowNegativeValue={true}
|
||||
onBlurValue={(value) => {
|
||||
setFieldValue(
|
||||
'quantity',
|
||||
decrementQuantity(
|
||||
toSafeNumber(value),
|
||||
toSafeNumber(values.quantity_on_hand),
|
||||
),
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</FFormGroup>
|
||||
<Field name={'new_quantity'}>
|
||||
{({
|
||||
form: { values, setFieldValue },
|
||||
field,
|
||||
meta: { error, touched },
|
||||
}) => (
|
||||
<FormGroup
|
||||
label={<T id={'new_quantity'} />}
|
||||
intent={inputIntent({ error, touched })}
|
||||
helperText={<ErrorMessage name="new_quantity" />}
|
||||
>
|
||||
<MoneyInputGroup
|
||||
value={field.value}
|
||||
allowDecimals={false}
|
||||
allowNegativeValue={true}
|
||||
onChange={(value) => {
|
||||
setFieldValue('new_quantity', value);
|
||||
}}
|
||||
onBlurValue={(value) => {
|
||||
setFieldValue(
|
||||
'quantity',
|
||||
decrementQuantity(
|
||||
toSafeNumber(value),
|
||||
toSafeNumber(values.quantity_on_hand),
|
||||
),
|
||||
);
|
||||
}}
|
||||
intent={inputIntent({ error, touched })}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</Field>
|
||||
</Col>
|
||||
</Row>
|
||||
);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
|
||||
|
||||
import '@/style/pages/Items/ItemAdjustmentDialog.scss';
|
||||
|
||||
|
||||
import { InventoryAdjustmentFormProvider } from './InventoryAdjustmentFormProvider';
|
||||
import InventoryAdjustmentForm from './InventoryAdjustmentForm';
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ export default function InventoryAdjustmentFormDialogFields() {
|
||||
name={'adjustment_account_id'}
|
||||
label={<T id={'adjustment_account'} />}
|
||||
labelInfo={<FieldRequiredHint />}
|
||||
fill
|
||||
className={'form-group--adjustment-account'}
|
||||
>
|
||||
<FAccountsSuggestField
|
||||
name={'adjustment_account_id'}
|
||||
@@ -168,8 +168,6 @@ export default function InventoryAdjustmentFormDialogFields() {
|
||||
inputProps={{
|
||||
placeholder: intl.get('select_adjustment_account'),
|
||||
}}
|
||||
fill
|
||||
fastField
|
||||
/>
|
||||
</FFormGroup>
|
||||
|
||||
@@ -187,21 +185,16 @@ export default function InventoryAdjustmentFormDialogFields() {
|
||||
name={'reason'}
|
||||
label={<T id={'adjustment_reasons'} />}
|
||||
labelInfo={<FieldRequiredHint />}
|
||||
fill
|
||||
fastField
|
||||
>
|
||||
<FTextArea name={'reason'} growVertically large fastField fill />
|
||||
<FTextArea name={'reason'} growVertically large fastField />
|
||||
</FFormGroup>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export const FeatureRowDivider = styled.div`
|
||||
--x-color-background: #e9e9e9;
|
||||
.bp4-dark & {
|
||||
--x-color-background: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
height: 2px;
|
||||
background: var(--x-color-background);
|
||||
background: #e9e9e9;
|
||||
margin-bottom: 15px;
|
||||
`;
|
||||
|
||||
@@ -27,12 +27,10 @@ import {
|
||||
FormattedMessage as T,
|
||||
ExchangeRateMutedField,
|
||||
BranchSelect,
|
||||
BranchSelectButton,
|
||||
FeatureCan,
|
||||
FInputGroup,
|
||||
FMoneyInputGroup,
|
||||
FDateInput,
|
||||
FFormGroup,
|
||||
FTextArea,
|
||||
} from '@/components';
|
||||
import {
|
||||
inputIntent,
|
||||
@@ -68,13 +66,16 @@ function RefundCreditNoteFormFields({
|
||||
<FeatureCan feature={Features.Branches}>
|
||||
<Row>
|
||||
<Col xs={5}>
|
||||
<FFormGroup name={'branch_id'} label={<T id={'branch'} />}>
|
||||
<FormGroup
|
||||
label={<T id={'branch'} />}
|
||||
className={classNames('form-group--select-list', Classes.FILL)}
|
||||
>
|
||||
<BranchSelect
|
||||
name={'branch_id'}
|
||||
branches={branches}
|
||||
popoverProps={{ minimal: true }}
|
||||
/>
|
||||
</FFormGroup>
|
||||
</FormGroup>
|
||||
</Col>
|
||||
</Row>
|
||||
<BranchRowDivider />
|
||||
@@ -83,23 +84,29 @@ function RefundCreditNoteFormFields({
|
||||
<Row>
|
||||
<Col xs={5}>
|
||||
{/* ------------- Refund date ------------- */}
|
||||
<FFormGroup
|
||||
name={'date'}
|
||||
label={<T id={'refund_credit_note.dialog.refund_date'} />}
|
||||
labelInfo={<FieldRequiredHint />}
|
||||
fill
|
||||
>
|
||||
<FDateInput
|
||||
name={'date'}
|
||||
{...momentFormatter('YYYY/MM/DD')}
|
||||
popoverProps={{ position: Position.BOTTOM, minimal: true }}
|
||||
inputProps={{
|
||||
leftIcon: <Icon icon={'date-range'} />,
|
||||
}}
|
||||
/>
|
||||
</FFormGroup>
|
||||
<FastField name={'date'}>
|
||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||
<FFormGroup
|
||||
name={'date'}
|
||||
label={<T id={'refund_credit_note.dialog.refund_date'} />}
|
||||
labelInfo={<FieldRequiredHint />}
|
||||
fill
|
||||
>
|
||||
<DateInput
|
||||
{...momentFormatter('YYYY/MM/DD')}
|
||||
value={tansformDateValue(value)}
|
||||
onChange={handleDateChange((formattedDate) => {
|
||||
form.setFieldValue('date', formattedDate);
|
||||
})}
|
||||
popoverProps={{ position: Position.BOTTOM, minimal: true }}
|
||||
inputProps={{
|
||||
leftIcon: <Icon icon={'date-range'} />,
|
||||
}}
|
||||
/>
|
||||
</FFormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
</Col>
|
||||
|
||||
<Col xs={5}>
|
||||
{/* ------------ Form account ------------ */}
|
||||
<FFormGroup
|
||||
@@ -107,7 +114,6 @@ function RefundCreditNoteFormFields({
|
||||
label={<T id={'refund_credit_note.dialog.from_account'} />}
|
||||
labelInfo={<FieldRequiredHint />}
|
||||
fill
|
||||
fastField
|
||||
>
|
||||
<FAccountsSuggestField
|
||||
name={'from_account_id'}
|
||||
@@ -120,7 +126,6 @@ function RefundCreditNoteFormFields({
|
||||
ACCOUNT_TYPE.CASH,
|
||||
ACCOUNT_TYPE.FIXED_ASSET,
|
||||
]}
|
||||
fastField
|
||||
/>
|
||||
</FFormGroup>
|
||||
</Col>
|
||||
@@ -132,7 +137,6 @@ function RefundCreditNoteFormFields({
|
||||
label={<T id={'refund_credit_note.dialog.amount'} />}
|
||||
labelInfo={<FieldRequiredHint />}
|
||||
fill
|
||||
fastField
|
||||
>
|
||||
<ControlGroup>
|
||||
<InputPrependText text={values.currency_code} />
|
||||
@@ -140,7 +144,6 @@ function RefundCreditNoteFormFields({
|
||||
name={'amount'}
|
||||
minimal={true}
|
||||
inputRef={(ref) => (amountFieldRef.current = ref)}
|
||||
|
||||
/>
|
||||
</ControlGroup>
|
||||
</FFormGroup>
|
||||
@@ -158,19 +161,21 @@ function RefundCreditNoteFormFields({
|
||||
</If>
|
||||
|
||||
{/* ------------ Reference No. ------------ */}
|
||||
<FFormGroup name={'reference_no'} label={<T id={'reference_no'} />} fill fastField>
|
||||
<FFormGroup name={'reference_no'} label={<T id={'reference_no'} />} fill>
|
||||
<FInputGroup name={'reference_no'} minimal fill />
|
||||
</FFormGroup>
|
||||
|
||||
{/* --------- Statement --------- */}
|
||||
<FFormGroup
|
||||
name={'description'}
|
||||
label={<T id={'refund_credit_note.dialog.description'} />}
|
||||
fill
|
||||
fastField
|
||||
>
|
||||
<FTextArea name={'description'} growVertically fill fastField />
|
||||
</FFormGroup>
|
||||
<FastField name={'description'}>
|
||||
{({ form, field, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={<T id={'refund_credit_note.dialog.description'} />}
|
||||
className={'form-group--description'}
|
||||
>
|
||||
<TextArea growVertically={true} {...field} />
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -178,12 +183,7 @@ function RefundCreditNoteFormFields({
|
||||
export default compose(withCurrentOrganization())(RefundCreditNoteFormFields);
|
||||
|
||||
export const BranchRowDivider = styled.div`
|
||||
--x-divider-color: #ebf1f6;
|
||||
|
||||
.bp4-dark & {
|
||||
--x-divider-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
height: 1px;
|
||||
background: var(--x-divider-color);
|
||||
background: #ebf1f6;
|
||||
margin-bottom: 13px;
|
||||
`;
|
||||
|
||||
@@ -152,8 +152,8 @@ function RefundVendorCreditFormFields({
|
||||
</FFormGroup>
|
||||
|
||||
{/* --------- Statement --------- */}
|
||||
<FFormGroup name={'description'} label={<T id={'refund_vendor_credit.dialog.description'} />} fill fastField>
|
||||
<FTextArea name={'description'} growVertically fill fastField />
|
||||
<FFormGroup name={'description'} fill fastField>
|
||||
<FTextArea name={'description'} growVertically={true} fastField />
|
||||
</FFormGroup>
|
||||
</div>
|
||||
);
|
||||
@@ -162,12 +162,7 @@ function RefundVendorCreditFormFields({
|
||||
export default compose(withCurrentOrganization())(RefundVendorCreditFormFields);
|
||||
|
||||
export const BranchRowDivider = styled.div`
|
||||
--x-divider-color: #ebf1f6;
|
||||
|
||||
.bp4-dark & {
|
||||
--x-divider-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
height: 1px;
|
||||
background: var(--x-divider-color);
|
||||
background: #ebf1f6;
|
||||
margin-bottom: 13px;
|
||||
`;
|
||||
|
||||
@@ -70,14 +70,9 @@ function AccountDrawerDataTable() {
|
||||
export default compose(withDrawerActions)(AccountDrawerTable);
|
||||
|
||||
const TableFooter = styled.div`
|
||||
--x-border-color: #d2dde2;
|
||||
|
||||
.bp4-dark & {
|
||||
--x-border-color: var(--color-dark-gray5);
|
||||
}
|
||||
padding: 6px 14px;
|
||||
display: block;
|
||||
border-top: 1px solid var(--x-border-color);
|
||||
border-bottom: 1px solid var(--x-border-color);
|
||||
border-top: 1px solid #d2dde2;
|
||||
border-bottom: 1px solid #d2dde2;
|
||||
font-size: 12px;
|
||||
`;
|
||||
|
||||
@@ -9,13 +9,13 @@ import { ItemsCategoriesProvider } from './ItemsCategoriesProvider';
|
||||
|
||||
import ItemCategoriesTable from './ItemCategoriesTable';
|
||||
import ItemsCategoryActionsBar from './ItemsCategoryActionsBar';
|
||||
import { withItemCategories } from './withItemCategories';
|
||||
import { withItemsCategories } from './withItemCategories';
|
||||
|
||||
/**
|
||||
* Item categories list.
|
||||
*/
|
||||
function ItemCategoryList({
|
||||
// #withItemCategories
|
||||
// #withItemsCategories
|
||||
itemsCategoriesTableState
|
||||
}) {
|
||||
return (
|
||||
@@ -32,7 +32,7 @@ function ItemCategoryList({
|
||||
}
|
||||
|
||||
export default R.compose(
|
||||
withItemCategories(({ itemsCategoriesTableState }) => ({
|
||||
withItemsCategories(({ itemsCategoriesTableState }) => ({
|
||||
itemsCategoriesTableState,
|
||||
})),
|
||||
)(ItemCategoryList);
|
||||
|
||||
@@ -15,3 +15,5 @@ export const withItemCategories = (mapState) => {
|
||||
};
|
||||
return connect(mapStateToProps);
|
||||
};
|
||||
|
||||
export const withItemsCategories = withItemCategories;
|
||||
|
||||
@@ -63,12 +63,7 @@ export function PaymentMethodSelectField({
|
||||
}
|
||||
|
||||
const PaymentMethodSelectRoot = styled(Group)`
|
||||
--x-color-border: #d3d8de;
|
||||
|
||||
.bp4-dark & {
|
||||
--x-color-border: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
border: 1px solid var(--x-color-border);
|
||||
border: 1px solid #d3d8de;
|
||||
border-radius: 3px;
|
||||
padding: 8px;
|
||||
gap: 0;
|
||||
@@ -77,23 +72,13 @@ const PaymentMethodSelectRoot = styled(Group)`
|
||||
`;
|
||||
|
||||
const PaymentMethodCheckbox = styled(Checkbox)`
|
||||
--x-color-border: #c5cbd3;
|
||||
|
||||
.bp4-dark & {
|
||||
--x-color-border: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
margin: 0;
|
||||
|
||||
&.bp4-control .bp4-control-indicator {
|
||||
box-shadow: 0 0 0 1px var(--x-color-border);
|
||||
box-shadow: 0 0 0 1px #c5cbd3;
|
||||
}
|
||||
`;
|
||||
|
||||
const PaymentMethodText = styled(Text)`
|
||||
--x-color-text: #404854;
|
||||
|
||||
.bp4-dark & {
|
||||
--x-color-text: var(--color-light-gray4);
|
||||
}
|
||||
color: var(--x-color-text);
|
||||
color: #404854;
|
||||
`;
|
||||
|
||||
@@ -48,5 +48,5 @@ const PaymentMethodsTitle = styled('h6')`
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
margin: 0;
|
||||
color: var(--color-muted-text);
|
||||
color: rgb(95, 107, 124);
|
||||
`;
|
||||
|
||||
@@ -45,7 +45,7 @@ import { isEmpty } from 'lodash';
|
||||
* Bills actions bar.
|
||||
*/
|
||||
function BillActionsBar({
|
||||
// #withBillsActions
|
||||
// #withBillActions
|
||||
setBillsTableState,
|
||||
|
||||
// #withBills
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
import BillsEmptyStatus from './BillsEmptyStatus';
|
||||
|
||||
import { withBills } from './withBills';
|
||||
import { withBillsActions } from './withBillsActions';
|
||||
import { withBillActions } from './withBillsActions';
|
||||
import { withAlertActions } from '@/containers/Alert/withAlertActions';
|
||||
import { withDialogActions } from '@/containers/Dialog/withDialogActions';
|
||||
import { withDrawerActions } from '@/containers/Drawer/withDrawerActions';
|
||||
@@ -163,7 +163,7 @@ function BillsDataTable({
|
||||
|
||||
export default compose(
|
||||
withBills(({ billsTableState }) => ({ billsTableState })),
|
||||
withBillsActions,
|
||||
withBillActions,
|
||||
withAlertActions,
|
||||
withDrawerActions,
|
||||
withDialogActions,
|
||||
|
||||
@@ -6,7 +6,7 @@ import { DashboardViewsTabs } from '@/components';
|
||||
import { useBillsListContext } from './BillsListProvider';
|
||||
|
||||
import { withBills } from './withBills';
|
||||
import { withBillsActions } from './withBillsActions';
|
||||
import { withBillActions } from './withBillsActions';
|
||||
|
||||
import { compose, transfromViewsToTabs } from '@/utils';
|
||||
|
||||
@@ -14,7 +14,7 @@ import { compose, transfromViewsToTabs } from '@/utils';
|
||||
* Bills view tabs.
|
||||
*/
|
||||
function BillViewTabs({
|
||||
// #withBillsActions
|
||||
// #withBillActions
|
||||
setBillsTableState,
|
||||
|
||||
// #withBills
|
||||
@@ -47,7 +47,7 @@ function BillViewTabs({
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withBillsActions,
|
||||
withBillActions,
|
||||
withBills(({ billsTableState }) => ({
|
||||
billsCurrentView: billsTableState.viewSlug,
|
||||
})),
|
||||
|
||||
@@ -14,3 +14,4 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
});
|
||||
|
||||
export const withBillsActions = connect(null, mapDispatchToProps);
|
||||
export const withBillActions = withBillsActions;
|
||||
|
||||
@@ -70,16 +70,16 @@ function VendorCreditNoteForm({
|
||||
() => ({
|
||||
...(!isEmpty(vendorCredit)
|
||||
? {
|
||||
...transformToEditForm(vendorCredit),
|
||||
}
|
||||
...transformToEditForm(vendorCredit),
|
||||
}
|
||||
: {
|
||||
...defaultVendorsCreditNote,
|
||||
...(vendorcreditAutoIncrement && {
|
||||
vendor_credit_number: vendorCreditNumber,
|
||||
...defaultVendorsCreditNote,
|
||||
...(vendorcreditAutoIncrement && {
|
||||
vendor_credit_number: vendorCreditNumber,
|
||||
}),
|
||||
currency_code: base_currency,
|
||||
...newVendorCredit,
|
||||
}),
|
||||
currency_code: base_currency,
|
||||
...newVendorCredit,
|
||||
}),
|
||||
}),
|
||||
[vendorCredit, base_currency],
|
||||
);
|
||||
|
||||
@@ -24,7 +24,6 @@ import {
|
||||
VendorsSelect,
|
||||
Stack,
|
||||
FDateInput,
|
||||
FInputGroup,
|
||||
} from '@/components';
|
||||
import {
|
||||
vendorsFieldShouldUpdate,
|
||||
@@ -75,7 +74,6 @@ function VendorCreditNoteFormHeaderFields({
|
||||
}) {
|
||||
const theme = useTheme();
|
||||
const fieldsClassName = getFieldsStyle(theme);
|
||||
const { values } = useFormikContext();
|
||||
|
||||
// Handle vendor credit number changing.
|
||||
const handleVendorCreditNumberChange = () => {
|
||||
@@ -83,11 +81,10 @@ function VendorCreditNoteFormHeaderFields({
|
||||
};
|
||||
|
||||
// Handle vendor credit no. field blur.
|
||||
const handleVendorCreditNoBlur = (event) => {
|
||||
const handleVendorCreditNoBlur = (form, field) => (event) => {
|
||||
const newValue = event.target.value;
|
||||
const oldValue = values.vendor_credit_number;
|
||||
|
||||
if (oldValue !== newValue && vendorcreditAutoIncrement) {
|
||||
if (field.value !== newValue && vendorcreditAutoIncrement) {
|
||||
openDialog('vendor-credit-form', {
|
||||
initialFormValues: {
|
||||
manualTransactionNo: newValue,
|
||||
@@ -112,6 +109,7 @@ function VendorCreditNoteFormHeaderFields({
|
||||
name={'exchange_rate'}
|
||||
formGroupProps={{ label: ' ', inline: true }}
|
||||
/>
|
||||
|
||||
{/* ------- Vendor Credit date ------- */}
|
||||
<FFormGroup
|
||||
name={'vendor_credit_date'}
|
||||
@@ -132,6 +130,7 @@ function VendorCreditNoteFormHeaderFields({
|
||||
</FFormGroup>
|
||||
|
||||
{/* ----------- Vendor Credit No # ----------- */}
|
||||
|
||||
<FFormGroup
|
||||
name={'vendor_credit_number'}
|
||||
label={<T id={'credit_note.label_credit_note'} />}
|
||||
@@ -164,7 +163,7 @@ function VendorCreditNoteFormHeaderFields({
|
||||
</FFormGroup>
|
||||
|
||||
{/* ----------- Reference ----------- */}
|
||||
<FFormGroup name={'reference_no'} label={<T id={'reference_no'} />} inline={true} fastField>
|
||||
<FFormGroup label={<T id={'reference_no'} />} inline={true} fastField>
|
||||
<FInputGroup name={'reference_no'} minimal={true} fastField />
|
||||
</FFormGroup>
|
||||
</Stack>
|
||||
|
||||
@@ -40,10 +40,10 @@ import { compose } from '@/utils';
|
||||
* Payment made actions bar.
|
||||
*/
|
||||
function PaymentMadeActionsBar({
|
||||
// #withPaymentMadeActions
|
||||
// #withPaymentMadesActions
|
||||
setPaymentMadesTableState,
|
||||
|
||||
// #withPaymentMade
|
||||
// #withPaymentMades
|
||||
paymentMadesFilterConditions,
|
||||
|
||||
// #withSettings
|
||||
@@ -133,7 +133,7 @@ function PaymentMadeActionsBar({
|
||||
icon={<Icon icon={'trash-16'} iconSize={16} />}
|
||||
text={<T id={'delete'} />}
|
||||
intent={Intent.DANGER}
|
||||
// onClick={handleBulkDelete}
|
||||
// onClick={handleBulkDelete}
|
||||
/>
|
||||
</If>
|
||||
<Button
|
||||
|
||||
@@ -8,7 +8,7 @@ import { PaymentMadesListProvider } from './PaymentMadesListProvider';
|
||||
import PaymentMadeActionsBar from './PaymentMadeActionsBar';
|
||||
import PaymentMadesTable from './PaymentMadesTable';
|
||||
|
||||
import { withPaymentMade } from './withPaymentMade';
|
||||
import { withPaymentMades } from './withPaymentMade';
|
||||
import { withPaymentMadeActions } from './withPaymentMadeActions';
|
||||
|
||||
import { compose, transformTableStateToQuery } from '@/utils';
|
||||
@@ -17,7 +17,7 @@ import { compose, transformTableStateToQuery } from '@/utils';
|
||||
* Payment mades list.
|
||||
*/
|
||||
function PaymentMadeList({
|
||||
// #withPaymentMade
|
||||
// #withPaymentMades
|
||||
paymentMadesTableState,
|
||||
paymentsTableStateChanged,
|
||||
|
||||
@@ -47,7 +47,7 @@ function PaymentMadeList({
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withPaymentMade(({ paymentMadesTableState, paymentsTableStateChanged }) => ({
|
||||
withPaymentMades(({ paymentMadesTableState, paymentsTableStateChanged }) => ({
|
||||
paymentMadesTableState,
|
||||
paymentsTableStateChanged,
|
||||
})),
|
||||
|
||||
@@ -15,7 +15,7 @@ import { withPaymentMadeActions } from './withPaymentMadeActions';
|
||||
* Payment made views tabs.
|
||||
*/
|
||||
function PaymentMadeViewTabs({
|
||||
// #withPaymentMadeActions
|
||||
// #withPaymentMadesActions
|
||||
setPaymentMadesTableState,
|
||||
|
||||
// #withPaymentMade
|
||||
|
||||
@@ -18,3 +18,5 @@ export const withPaymentMade = (mapState) => {
|
||||
};
|
||||
return connect(mapStateToProps);
|
||||
};
|
||||
|
||||
export const withPaymentMades = withPaymentMade;
|
||||
|
||||
@@ -29,4 +29,4 @@ const mapDispatchToProps = (dispatch, props) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const withRouteActions = connect(null, mapDispatchToProps);
|
||||
export const withRouteActions = connect(null, mapDispatchToProps)
|
||||
@@ -12,6 +12,7 @@ import { useIsDarkMode } from '@/hooks/useDarkMode';
|
||||
const inputGroupCss = css`
|
||||
& .bp4-input {
|
||||
max-width: 110px;
|
||||
color: rgb(17, 17, 17);
|
||||
padding-left: 8px;
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -13,6 +13,7 @@ import { useIsDarkMode } from '@/hooks/useDarkMode';
|
||||
const inputGroupCss = css`
|
||||
& .bp4-input {
|
||||
max-width: 110px;
|
||||
color: rgb(17, 17, 17);
|
||||
padding-left: 8px;
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -127,7 +127,7 @@ const PaymentOptionsText = styled(Box)`
|
||||
font-size: 13px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
color: var(--color-muted-text);
|
||||
color: #5f6b7c;
|
||||
`;
|
||||
|
||||
const PaymentOptionsButton = styled(Button)`
|
||||
|
||||
@@ -10,7 +10,7 @@ import { SubscriptionPlansPeriod } from '@/store/plans/plans.reducer';
|
||||
import styles from './SetupSubscription.module.scss';
|
||||
|
||||
interface SubscriptionPlansPeriodsSwitchCombinedProps
|
||||
extends WithSubscriptionPlansActionsProps { }
|
||||
extends WithSubscriptionPlansActionsProps {}
|
||||
|
||||
function SubscriptionPlansPeriodSwitcherRoot({
|
||||
// #withSubscriptionPlansActions
|
||||
|
||||
@@ -11,12 +11,13 @@ import {
|
||||
Menu,
|
||||
MenuItem,
|
||||
} from '@blueprintjs/core';
|
||||
import { If, Icon, FormattedMessage as T, Group } from '@/components';
|
||||
import { If, Icon, FormattedMessage as T } from '@/components';
|
||||
import classNames from 'classnames';
|
||||
import { useFormikContext } from 'formik';
|
||||
import { useWarehouseTransferFormContext } from './WarehouseTransferFormProvider';
|
||||
import { CLASSES } from '@/constants/classes';
|
||||
|
||||
import { useWarehouseTransferFormContext } from './WarehouseTransferFormProvider';
|
||||
|
||||
/**
|
||||
* Warehouse transfer floating actions bar.
|
||||
*/
|
||||
@@ -76,101 +77,98 @@ export default function WarehouseTransferFloatingActions() {
|
||||
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
||||
<Group spacing={10}>
|
||||
{/* ----------- Save Intitate & transferred ----------- */}
|
||||
<If condition={!warehouseTransfer || !warehouseTransfer?.is_transferred}>
|
||||
<ButtonGroup>
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
loading={isSubmitting}
|
||||
intent={Intent.PRIMARY}
|
||||
type="submit"
|
||||
onClick={handleSubmitInitiateBtnClick}
|
||||
style={{ minWidth: '85px' }}
|
||||
text={<T id={'warehouse_transfer.save_initiate_transfer'} />}
|
||||
/>
|
||||
<Popover
|
||||
content={
|
||||
<Menu>
|
||||
<MenuItem
|
||||
text={
|
||||
<T id={'warehouse_transfer.save_mark_as_transferred'} />
|
||||
}
|
||||
onClick={handleSubmitTransferredBtnClick}
|
||||
/>
|
||||
</Menu>
|
||||
}
|
||||
minimal={true}
|
||||
interactionKind={PopoverInteractionKind.CLICK}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
>
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
intent={Intent.PRIMARY}
|
||||
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||
/>
|
||||
</Popover>
|
||||
</ButtonGroup>
|
||||
|
||||
{/* ----------- Save As Draft ----------- */}
|
||||
<ButtonGroup>
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
className={'ml1'}
|
||||
onClick={handleSubmitDraftBtnClick}
|
||||
text={<T id={'save_as_draft'} />}
|
||||
/>
|
||||
<Popover
|
||||
content={
|
||||
<Menu>
|
||||
<MenuItem
|
||||
text={<T id={'save_and_new'} />}
|
||||
onClick={handleSubmitDraftAndNewBtnClick}
|
||||
/>
|
||||
<MenuItem
|
||||
text={<T id={'save_continue_editing'} />}
|
||||
onClick={handleSubmitDraftContinueEditingBtnClick}
|
||||
/>
|
||||
</Menu>
|
||||
}
|
||||
minimal={true}
|
||||
interactionKind={PopoverInteractionKind.CLICK}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
>
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||
/>
|
||||
</Popover>
|
||||
</ButtonGroup>
|
||||
</If>
|
||||
<If condition={warehouseTransfer && warehouseTransfer?.is_transferred}>
|
||||
{/* ----------- Save Intitate & transferred ----------- */}
|
||||
<If condition={!warehouseTransfer || !warehouseTransfer?.is_transferred}>
|
||||
<ButtonGroup>
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
loading={isSubmitting}
|
||||
intent={Intent.PRIMARY}
|
||||
onClick={handleSubmitTransferredBtnClick}
|
||||
style={{ minWidth: '100px' }}
|
||||
text={<T id={'save'} />}
|
||||
type="submit"
|
||||
onClick={handleSubmitInitiateBtnClick}
|
||||
style={{ minWidth: '85px' }}
|
||||
text={<T id={'warehouse_transfer.save_initiate_transfer'} />}
|
||||
/>
|
||||
</If>
|
||||
<Popover
|
||||
content={
|
||||
<Menu>
|
||||
<MenuItem
|
||||
text={
|
||||
<T id={'warehouse_transfer.save_mark_as_transferred'} />
|
||||
}
|
||||
onClick={handleSubmitTransferredBtnClick}
|
||||
/>
|
||||
</Menu>
|
||||
}
|
||||
minimal={true}
|
||||
interactionKind={PopoverInteractionKind.CLICK}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
>
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
intent={Intent.PRIMARY}
|
||||
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||
/>
|
||||
</Popover>
|
||||
</ButtonGroup>
|
||||
|
||||
{/* ----------- Clear & Reset----------- */}
|
||||
{/* ----------- Save As Draft ----------- */}
|
||||
<ButtonGroup>
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
className={'ml1'}
|
||||
onClick={handleSubmitDraftBtnClick}
|
||||
text={<T id={'save_as_draft'} />}
|
||||
/>
|
||||
<Popover
|
||||
content={
|
||||
<Menu>
|
||||
<MenuItem
|
||||
text={<T id={'save_and_new'} />}
|
||||
onClick={handleSubmitDraftAndNewBtnClick}
|
||||
/>
|
||||
<MenuItem
|
||||
text={<T id={'save_continue_editing'} />}
|
||||
onClick={handleSubmitDraftContinueEditingBtnClick}
|
||||
/>
|
||||
</Menu>
|
||||
}
|
||||
minimal={true}
|
||||
interactionKind={PopoverInteractionKind.CLICK}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
>
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||
/>
|
||||
</Popover>
|
||||
</ButtonGroup>
|
||||
</If>
|
||||
<If condition={warehouseTransfer && warehouseTransfer?.is_transferred}>
|
||||
<Button
|
||||
className={'ml1'}
|
||||
disabled={isSubmitting}
|
||||
onClick={handleClearBtnClick}
|
||||
text={warehouseTransfer ? <T id={'reset'} /> : <T id={'clear'} />}
|
||||
loading={isSubmitting}
|
||||
intent={Intent.PRIMARY}
|
||||
onClick={handleSubmitTransferredBtnClick}
|
||||
style={{ minWidth: '100px' }}
|
||||
text={<T id={'save'} />}
|
||||
/>
|
||||
</If>
|
||||
{/* ----------- Clear & Reset----------- */}
|
||||
<Button
|
||||
className={'ml1'}
|
||||
disabled={isSubmitting}
|
||||
onClick={handleClearBtnClick}
|
||||
text={warehouseTransfer ? <T id={'reset'} /> : <T id={'clear'} />}
|
||||
/>
|
||||
|
||||
{/* ----------- Cancel ----------- */}
|
||||
<Button
|
||||
className={'ml1'}
|
||||
disabled={isSubmitting}
|
||||
onClick={handleCancelBtnClick}
|
||||
text={<T id={'cancel'} />}
|
||||
/>
|
||||
</Group>
|
||||
{/* ----------- Cancel ----------- */}
|
||||
<Button
|
||||
className={'ml1'}
|
||||
disabled={isSubmitting}
|
||||
onClick={handleCancelBtnClick}
|
||||
text={<T id={'cancel'} />}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,6 @@ function WarehouseTransferFormHeaderFields({
|
||||
inputProps={{
|
||||
leftIcon: <Icon icon={'date-range'} />,
|
||||
}}
|
||||
fill
|
||||
fastField
|
||||
/>
|
||||
</FFormGroup>
|
||||
|
||||
@@ -205,7 +205,7 @@ export function useAccountTransactions(id, props) {
|
||||
[t.ACCOUNT_TRANSACTION, id],
|
||||
{ method: 'get', url: `accounts/transactions?account_id=${id}` },
|
||||
{
|
||||
select: (res) => res.data,
|
||||
select: (res) => res.data.transactions,
|
||||
defaultData: [],
|
||||
...props,
|
||||
},
|
||||
|
||||
@@ -8,19 +8,12 @@
|
||||
|
||||
.avatar.td {
|
||||
.avatar {
|
||||
--x-color-background: #adbcc9;
|
||||
--x-color-text: #fff;
|
||||
|
||||
.bp4-dark & {
|
||||
--x-color-background: rgba(255, 255, 255, 0.2);
|
||||
--x-color-text: #fff;
|
||||
}
|
||||
display: inline-block;
|
||||
background: var(--x-color-background);
|
||||
background: #adbcc9;
|
||||
border-radius: 50%;
|
||||
text-align: center;
|
||||
font-weight: 400;
|
||||
color: var(--x-color-text);
|
||||
color: #fff;
|
||||
|
||||
&[data-size='medium'] {
|
||||
height: 30px;
|
||||
|
||||
@@ -9,19 +9,12 @@
|
||||
|
||||
.avatar.td {
|
||||
.avatar {
|
||||
--x-color-background: #adbcc9;
|
||||
--x-color-text: #fff;
|
||||
|
||||
.bp4-dark & {
|
||||
--x-color-background: rgba(255, 255, 255, 0.2);
|
||||
--x-color-text: #fff;
|
||||
}
|
||||
display: inline-block;
|
||||
background: var(--x-color-background);
|
||||
color: var(--x-color-text);
|
||||
background: #adbcc9;
|
||||
border-radius: 50%;
|
||||
text-align: center;
|
||||
font-weight: 400;
|
||||
color: #fff;
|
||||
|
||||
&[data-size='medium'] {
|
||||
height: 30px;
|
||||
|
||||
@@ -54,11 +54,6 @@ export default defineConfig(({ mode }) => {
|
||||
target: env.VITE_API_PROXY_TARGET || 'http://localhost:3000',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/socket': {
|
||||
target: env.VITE_API_PROXY_TARGET || 'http://localhost:3000',
|
||||
changeOrigin: true,
|
||||
ws: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
build: {
|
||||
|
||||
@@ -1,257 +0,0 @@
|
||||
import {
|
||||
PaperTemplate,
|
||||
PaperTemplateProps,
|
||||
PaperTemplateTotalBorder,
|
||||
} from './PaperTemplate';
|
||||
import { Box } from '../lib/layout/Box';
|
||||
import { Text } from '../lib/text/Text';
|
||||
import { Stack } from '../lib/layout/Stack';
|
||||
import { Group } from '../lib/layout/Group';
|
||||
import {
|
||||
DefaultPdfTemplateTerms,
|
||||
DefaultPdfTemplateItemDescription,
|
||||
DefaultPdfTemplateItemName,
|
||||
DefaultPdfTemplateAddressBilledTo,
|
||||
DefaultPdfTemplateAddressBilledFrom,
|
||||
} from './_constants';
|
||||
|
||||
interface CreditNoteLine {
|
||||
item?: string;
|
||||
description?: string;
|
||||
quantity?: string;
|
||||
rate?: string;
|
||||
total?: string;
|
||||
}
|
||||
|
||||
export interface CreditNotePaperTemplateProps extends PaperTemplateProps {
|
||||
primaryColor?: string;
|
||||
secondaryColor?: string;
|
||||
|
||||
// Company
|
||||
showCompanyLogo?: boolean;
|
||||
companyLogoUri?: string;
|
||||
|
||||
companyName?: string;
|
||||
|
||||
// Credit Note number
|
||||
showCreditNoteNumber?: boolean;
|
||||
creditNoteNumebr?: string;
|
||||
creditNoteNumberLabel?: string;
|
||||
|
||||
// Credit Note date
|
||||
showCreditNoteDate?: boolean;
|
||||
creditNoteDate?: string;
|
||||
creditNoteDateLabel?: string;
|
||||
|
||||
// Address
|
||||
showCustomerAddress?: boolean;
|
||||
customerAddress?: string;
|
||||
|
||||
showCompanyAddress?: boolean;
|
||||
companyAddress?: string;
|
||||
|
||||
billedToLabel?: string;
|
||||
|
||||
// Entries
|
||||
lineItemLabel?: string;
|
||||
lineQuantityLabel?: string;
|
||||
lineRateLabel?: string;
|
||||
lineTotalLabel?: string;
|
||||
|
||||
// Subtotal
|
||||
showSubtotal?: boolean;
|
||||
subtotalLabel?: string;
|
||||
subtotal?: string;
|
||||
|
||||
// Total
|
||||
showTotal?: boolean;
|
||||
totalLabel?: string;
|
||||
total?: string;
|
||||
|
||||
// Customer Note
|
||||
showCustomerNote?: boolean;
|
||||
customerNote?: string;
|
||||
customerNoteLabel?: string;
|
||||
|
||||
// Terms & Conditions
|
||||
showTermsConditions?: boolean;
|
||||
termsConditions?: string;
|
||||
termsConditionsLabel?: string;
|
||||
|
||||
lines?: Array<CreditNoteLine>;
|
||||
}
|
||||
|
||||
export function CreditNotePaperTemplate({
|
||||
// # Colors
|
||||
primaryColor,
|
||||
secondaryColor,
|
||||
|
||||
// # Company
|
||||
companyName = 'Bigcapital Technology, Inc.',
|
||||
|
||||
showCompanyLogo = true,
|
||||
companyLogoUri = '',
|
||||
|
||||
// # Credit Note number
|
||||
creditNoteNumberLabel = 'Credit Note Number',
|
||||
creditNoteNumebr = '346D3D40-0001',
|
||||
showCreditNoteNumber = true,
|
||||
|
||||
// # Credit Note date
|
||||
creditNoteDate = 'September 3, 2024',
|
||||
creditNoteDateLabel = 'Credit Note Date',
|
||||
showCreditNoteDate = true,
|
||||
|
||||
// Address
|
||||
showCustomerAddress = true,
|
||||
customerAddress = DefaultPdfTemplateAddressBilledTo,
|
||||
|
||||
showCompanyAddress = true,
|
||||
companyAddress = DefaultPdfTemplateAddressBilledFrom,
|
||||
|
||||
billedToLabel = 'Billed To',
|
||||
|
||||
// Entries
|
||||
lineItemLabel = 'Item',
|
||||
lineQuantityLabel = 'Qty',
|
||||
lineRateLabel = 'Rate',
|
||||
lineTotalLabel = 'Total',
|
||||
|
||||
// Subtotal
|
||||
subtotalLabel = 'Subtotal',
|
||||
showSubtotal = true,
|
||||
subtotal = '1000.00',
|
||||
|
||||
// Total
|
||||
totalLabel = 'Total',
|
||||
showTotal = true,
|
||||
total = '$1000.00',
|
||||
|
||||
// Customer Note
|
||||
showCustomerNote = true,
|
||||
customerNote = '',
|
||||
customerNoteLabel = 'Customer Note',
|
||||
|
||||
// Terms & Conditions
|
||||
termsConditionsLabel = 'Terms & Conditions',
|
||||
showTermsConditions = true,
|
||||
termsConditions = DefaultPdfTemplateTerms,
|
||||
|
||||
lines = [
|
||||
{
|
||||
item: DefaultPdfTemplateItemName,
|
||||
description: DefaultPdfTemplateItemDescription,
|
||||
rate: '1',
|
||||
quantity: '1000',
|
||||
total: '$1000.00',
|
||||
},
|
||||
],
|
||||
...props
|
||||
}: CreditNotePaperTemplateProps) {
|
||||
return (
|
||||
<PaperTemplate
|
||||
primaryColor={primaryColor}
|
||||
secondaryColor={secondaryColor}
|
||||
{...props}
|
||||
>
|
||||
<Stack spacing={24}>
|
||||
<Group align="start" spacing={10}>
|
||||
<Stack flex={1}>
|
||||
<PaperTemplate.BigTitle title={'Credit Note'} />
|
||||
|
||||
<PaperTemplate.TermsList>
|
||||
{showCreditNoteNumber && (
|
||||
<PaperTemplate.TermsItem label={creditNoteNumberLabel}>
|
||||
{creditNoteNumebr}
|
||||
</PaperTemplate.TermsItem>
|
||||
)}
|
||||
{showCreditNoteDate && (
|
||||
<PaperTemplate.TermsItem label={creditNoteDateLabel}>
|
||||
{creditNoteDate}
|
||||
</PaperTemplate.TermsItem>
|
||||
)}
|
||||
</PaperTemplate.TermsList>
|
||||
</Stack>
|
||||
|
||||
{companyLogoUri && showCompanyLogo && (
|
||||
<PaperTemplate.Logo logoUri={companyLogoUri} />
|
||||
)}
|
||||
</Group>
|
||||
|
||||
<PaperTemplate.AddressesGroup>
|
||||
{showCompanyAddress && (
|
||||
<PaperTemplate.Address>
|
||||
<Box dangerouslySetInnerHTML={{ __html: companyAddress }} />
|
||||
</PaperTemplate.Address>
|
||||
)}
|
||||
{showCustomerAddress && (
|
||||
<PaperTemplate.Address>
|
||||
<strong>{billedToLabel}</strong>
|
||||
<Box dangerouslySetInnerHTML={{ __html: customerAddress }} />
|
||||
</PaperTemplate.Address>
|
||||
)}
|
||||
</PaperTemplate.AddressesGroup>
|
||||
|
||||
<Stack spacing={0}>
|
||||
<PaperTemplate.Table
|
||||
columns={[
|
||||
{
|
||||
label: lineItemLabel,
|
||||
accessor: (data) => (
|
||||
<Stack spacing={2}>
|
||||
<Text>{data.item}</Text>
|
||||
{data.description && (
|
||||
<Text color={'#5f6b7c'} fontSize={12}>
|
||||
{data.description}
|
||||
</Text>
|
||||
)}
|
||||
</Stack>
|
||||
),
|
||||
thStyle: { width: '60%' },
|
||||
},
|
||||
{
|
||||
label: lineQuantityLabel,
|
||||
accessor: 'quantity',
|
||||
align: 'right',
|
||||
},
|
||||
{ label: lineRateLabel, accessor: 'rate', align: 'right' },
|
||||
{ label: lineTotalLabel, accessor: 'total', align: 'right' },
|
||||
]}
|
||||
data={lines}
|
||||
/>
|
||||
<PaperTemplate.Totals>
|
||||
{showSubtotal && (
|
||||
<PaperTemplate.TotalLine
|
||||
label={subtotalLabel}
|
||||
amount={subtotal}
|
||||
border={PaperTemplateTotalBorder.Gray}
|
||||
/>
|
||||
)}
|
||||
{showTotal && (
|
||||
<PaperTemplate.TotalLine
|
||||
label={totalLabel}
|
||||
amount={total}
|
||||
border={PaperTemplateTotalBorder.Dark}
|
||||
style={{ fontWeight: 500 }}
|
||||
/>
|
||||
)}
|
||||
</PaperTemplate.Totals>
|
||||
</Stack>
|
||||
|
||||
<Stack spacing={0}>
|
||||
{showCustomerNote && customerNote && (
|
||||
<PaperTemplate.Statement label={customerNoteLabel}>
|
||||
{customerNote}
|
||||
</PaperTemplate.Statement>
|
||||
)}
|
||||
|
||||
{showTermsConditions && termsConditions && (
|
||||
<PaperTemplate.Statement label={termsConditionsLabel}>
|
||||
{termsConditions}
|
||||
</PaperTemplate.Statement>
|
||||
)}
|
||||
</Stack>
|
||||
</Stack>
|
||||
</PaperTemplate>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
export * from './components/PaperTemplate';
|
||||
export * from './components/InvoicePaperTemplate';
|
||||
export * from './components/CreditNotePaperTemplate';
|
||||
export * from './components/EstimatePaperTemplate';
|
||||
export * from './components/ReceiptPaperTemplate';
|
||||
export * from './components/PaymentReceivedPaperTemplate';
|
||||
@@ -8,7 +7,6 @@ export * from './components/FinancialSheetTemplate';
|
||||
export * from './components/ExportResourceTableTemplate';
|
||||
|
||||
export * from './renders/render-invoice-paper-template';
|
||||
export * from './renders/render-credit-note-paper-template';
|
||||
export * from './renders/render-estimate-paper-template';
|
||||
export * from './renders/render-receipt-paper-template';
|
||||
export * from './renders/render-payment-received-paper-template';
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import {
|
||||
CreditNotePaperTemplate,
|
||||
CreditNotePaperTemplateProps,
|
||||
} from '../components/CreditNotePaperTemplate';
|
||||
import { renderSSR } from './render-ssr';
|
||||
|
||||
/**
|
||||
* Renders credit note paper template html.
|
||||
* @param {CreditNotePaperTemplateProps} props
|
||||
* @returns {string}
|
||||
*/
|
||||
export const renderCreditNotePaperTemplateHtml = (
|
||||
props: CreditNotePaperTemplateProps
|
||||
) => {
|
||||
return renderSSR(<CreditNotePaperTemplate {...props} />);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user