mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
feat: add local adjustment and discount properties to SaleInvoice and SaleReceipt interfaces.
This commit is contained in:
@@ -82,9 +82,11 @@ export interface ISaleInvoice {
|
|||||||
paymentMethods?: Array<PaymentIntegrationTransactionLink>;
|
paymentMethods?: Array<PaymentIntegrationTransactionLink>;
|
||||||
|
|
||||||
adjustment?: number;
|
adjustment?: number;
|
||||||
|
adjustmentLocal?: number | null;
|
||||||
|
|
||||||
discount?: number;
|
discount?: number;
|
||||||
discountAmount?: number;
|
discountAmount?: number;
|
||||||
|
discountAmountLocal?: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum DiscountType {
|
export enum DiscountType {
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ export interface ISaleReceipt {
|
|||||||
discountPercentage?: number | null;
|
discountPercentage?: number | null;
|
||||||
|
|
||||||
adjustment?: number;
|
adjustment?: number;
|
||||||
|
adjustmentLocal?: number | null;
|
||||||
|
|
||||||
|
discountAmountLocal?: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISalesReceiptsFilter {
|
export interface ISalesReceiptsFilter {
|
||||||
|
|||||||
@@ -53,15 +53,11 @@ export class BillGLEntries {
|
|||||||
trx
|
trx
|
||||||
);
|
);
|
||||||
// Find or create other expenses account.
|
// Find or create other expenses account.
|
||||||
const otherExpensesAccount = await accountRepository.findOrCreateOtherExpensesAccount(
|
const otherExpensesAccount =
|
||||||
{},
|
await accountRepository.findOrCreateOtherExpensesAccount({}, trx);
|
||||||
trx
|
|
||||||
);
|
|
||||||
// Find or create purchase discount account.
|
// Find or create purchase discount account.
|
||||||
const purchaseDiscountAccount = await accountRepository.findOrCreatePurchaseDiscountAccount(
|
const purchaseDiscountAccount =
|
||||||
{},
|
await accountRepository.findOrCreatePurchaseDiscountAccount({}, trx);
|
||||||
trx
|
|
||||||
);
|
|
||||||
const billLedger = this.getBillLedger(
|
const billLedger = this.getBillLedger(
|
||||||
bill,
|
bill,
|
||||||
APAccount.id,
|
APAccount.id,
|
||||||
@@ -266,7 +262,7 @@ export class BillGLEntries {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...commonEntry,
|
...commonEntry,
|
||||||
credit: bill.discountAmount,
|
credit: bill.discountAmountLocal,
|
||||||
accountId: purchaseDiscountAccountId,
|
accountId: purchaseDiscountAccountId,
|
||||||
accountNormal: AccountNormal.DEBIT,
|
accountNormal: AccountNormal.DEBIT,
|
||||||
index: 1,
|
index: 1,
|
||||||
@@ -288,8 +284,8 @@ export class BillGLEntries {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...commonEntry,
|
...commonEntry,
|
||||||
debit: bill.adjustment < 0 ? bill.adjustment : 0,
|
debit: bill.adjustmentLocal < 0 ? bill.adjustmentLocal : 0,
|
||||||
credit: bill.adjustment > 0 ? bill.adjustment : 0,
|
credit: bill.adjustmentLocal > 0 ? bill.adjustmentLocal : 0,
|
||||||
accountId: otherExpensesAccountId,
|
accountId: otherExpensesAccountId,
|
||||||
accountNormal: AccountNormal.DEBIT,
|
accountNormal: AccountNormal.DEBIT,
|
||||||
index: 1,
|
index: 1,
|
||||||
@@ -325,7 +321,10 @@ export class BillGLEntries {
|
|||||||
bill,
|
bill,
|
||||||
purchaseDiscountAccountId
|
purchaseDiscountAccountId
|
||||||
);
|
);
|
||||||
const adjustmentEntry = this.getAdjustmentEntry(bill, otherExpensesAccountId);
|
const adjustmentEntry = this.getAdjustmentEntry(
|
||||||
|
bill,
|
||||||
|
otherExpensesAccountId
|
||||||
|
);
|
||||||
|
|
||||||
// Allocate cost entries journal entries.
|
// Allocate cost entries journal entries.
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ export class SaleInvoiceGLEntries {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...commonEntry,
|
...commonEntry,
|
||||||
debit: saleInvoice.discountAmount,
|
debit: saleInvoice.discountAmountLocal,
|
||||||
accountId: discountAccountId,
|
accountId: discountAccountId,
|
||||||
accountNormal: AccountNormal.CREDIT,
|
accountNormal: AccountNormal.CREDIT,
|
||||||
index: 1,
|
index: 1,
|
||||||
@@ -299,12 +299,12 @@ export class SaleInvoiceGLEntries {
|
|||||||
otherChargesAccountId: number
|
otherChargesAccountId: number
|
||||||
): ILedgerEntry => {
|
): ILedgerEntry => {
|
||||||
const commonEntry = this.getInvoiceGLCommonEntry(saleInvoice);
|
const commonEntry = this.getInvoiceGLCommonEntry(saleInvoice);
|
||||||
const adjustmentAmount = Math.abs(saleInvoice.adjustment);
|
const adjustmentAmount = Math.abs(saleInvoice.adjustmentLocal);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...commonEntry,
|
...commonEntry,
|
||||||
debit: saleInvoice.adjustment < 0 ? adjustmentAmount : 0,
|
debit: saleInvoice.adjustmentLocal < 0 ? adjustmentAmount : 0,
|
||||||
credit: saleInvoice.adjustment > 0 ? adjustmentAmount : 0,
|
credit: saleInvoice.adjustmentLocal > 0 ? adjustmentAmount : 0,
|
||||||
accountId: otherChargesAccountId,
|
accountId: otherChargesAccountId,
|
||||||
accountNormal: AccountNormal.CREDIT,
|
accountNormal: AccountNormal.CREDIT,
|
||||||
index: 1,
|
index: 1,
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ export class SaleReceiptGLEntries {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...commonEntry,
|
...commonEntry,
|
||||||
debit: saleReceipt.discountAmount,
|
debit: saleReceipt.discountAmountLocal,
|
||||||
accountId: discountAccountId,
|
accountId: discountAccountId,
|
||||||
index: 1,
|
index: 1,
|
||||||
accountNormal: AccountNormal.CREDIT,
|
accountNormal: AccountNormal.CREDIT,
|
||||||
@@ -222,12 +222,12 @@ export class SaleReceiptGLEntries {
|
|||||||
adjustmentAccountId: number
|
adjustmentAccountId: number
|
||||||
): ILedgerEntry => {
|
): ILedgerEntry => {
|
||||||
const commonEntry = this.getIncomeGLCommonEntry(saleReceipt);
|
const commonEntry = this.getIncomeGLCommonEntry(saleReceipt);
|
||||||
const adjustmentAmount = Math.abs(saleReceipt.adjustment);
|
const adjustmentAmount = Math.abs(saleReceipt.adjustmentLocal);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...commonEntry,
|
...commonEntry,
|
||||||
debit: saleReceipt.adjustment < 0 ? adjustmentAmount : 0,
|
debit: saleReceipt.adjustmentLocal < 0 ? adjustmentAmount : 0,
|
||||||
credit: saleReceipt.adjustment > 0 ? adjustmentAmount : 0,
|
credit: saleReceipt.adjustmentLocal > 0 ? adjustmentAmount : 0,
|
||||||
accountId: adjustmentAccountId,
|
accountId: adjustmentAccountId,
|
||||||
accountNormal: AccountNormal.CREDIT,
|
accountNormal: AccountNormal.CREDIT,
|
||||||
index: 1,
|
index: 1,
|
||||||
@@ -253,7 +253,6 @@ export class SaleReceiptGLEntries {
|
|||||||
saleReceipt,
|
saleReceipt,
|
||||||
otherChargesAccountId
|
otherChargesAccountId
|
||||||
);
|
);
|
||||||
|
|
||||||
return [depositEntry, ...creditEntries, discountEntry, adjustmentEntry];
|
return [depositEntry, ...creditEntries, discountEntry, adjustmentEntry];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user