-
-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #289 from bigcapitalhq/big-80-entering-decimal-amo…
…unt-in-salepurchase-transactions fix(server): allow decimal amount in sale/purchase transactions.
- Loading branch information
Showing
32 changed files
with
239 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/server/src/database/migrations/20231202124014_change_item_entries_rate_to_float.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
exports.up = function (knex) { | ||
return knex.schema.alterTable('items_entries', (table) => { | ||
table.decimal('rate', 15, 5).alter(); | ||
}); | ||
}; | ||
|
||
exports.down = function (knex) { | ||
return knex.table('items_entries', (table) => {}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/server/src/services/Purchases/BillPayments/BillPaymentEntryTransformer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Transformer } from '@/lib/Transformer/Transformer'; | ||
import { formatNumber } from '@/utils'; | ||
|
||
export class BillPaymentEntryTransformer extends Transformer { | ||
/** | ||
* Include these attributes to bill payment object. | ||
* @returns {Array} | ||
*/ | ||
public includeAttributes = (): string[] => { | ||
return ['paymentAmountFormatted']; | ||
}; | ||
|
||
/** | ||
* Retreives the payment amount formatted. | ||
* @returns {string} | ||
*/ | ||
protected paymentAmountFormatted(entry) { | ||
return formatNumber(entry.paymentAmount, { money: false }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/server/src/services/Sales/Invoices/ItemEntryTransformer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { IItemEntry } from '@/interfaces'; | ||
import { Transformer } from '@/lib/Transformer/Transformer'; | ||
import { formatNumber } from '@/utils'; | ||
|
||
export class ItemEntryTransformer extends Transformer { | ||
/** | ||
* Include these attributes to item entry object. | ||
* @returns {Array} | ||
*/ | ||
public includeAttributes = (): string[] => { | ||
return ['rateFormatted', 'totalFormatted']; | ||
}; | ||
|
||
/** | ||
* Retrieves the formatted rate of item entry. | ||
* @param {IItemEntry} itemEntry - | ||
* @returns {string} | ||
*/ | ||
protected rateFormatted = (entry: IItemEntry): string => { | ||
return formatNumber(entry.rate, { | ||
currencyCode: this.context.currencyCode, | ||
money: false, | ||
}); | ||
}; | ||
|
||
/** | ||
* Retrieves the formatted total of item entry. | ||
* @param {IItemEntry} entry | ||
* @returns {string} | ||
*/ | ||
protected totalFormatted = (entry: IItemEntry): string => { | ||
return formatNumber(entry.total, { | ||
currencyCode: this.context.currencyCode, | ||
money: false, | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/server/src/services/Sales/PaymentReceives/GetPaymentReceiveInvoices.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/server/src/services/Sales/PaymentReceives/PaymentReceiveEntryTransformer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Transformer } from '@/lib/Transformer/Transformer'; | ||
import { SaleInvoiceTransformer } from '../Invoices/SaleInvoiceTransformer'; | ||
import { formatNumber } from '@/utils'; | ||
|
||
export class PaymentReceiveEntryTransfromer extends Transformer { | ||
/** | ||
* Include these attributes to payment receive entry object. | ||
* @returns {Array} | ||
*/ | ||
public includeAttributes = (): string[] => { | ||
return ['paymentAmountFormatted', 'entry']; | ||
}; | ||
|
||
/** | ||
* Retreives the payment amount formatted. | ||
* @param entry | ||
* @returns {string} | ||
*/ | ||
protected paymentAmountFormatted(entry) { | ||
return formatNumber(entry.paymentAmount, { money: false }); | ||
} | ||
|
||
/** | ||
* Retreives the transformed invoice. | ||
*/ | ||
protected invoice(entry) { | ||
return this.item(entry.invoice, new SaleInvoiceTransformer()); | ||
} | ||
} |
Oops, something went wrong.