2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 10:58:59 +00:00

Merge pull request #1013 from frappe/fix-hsncode-field

fix: hsncode fieldtype in Item
This commit is contained in:
Akshay 2024-11-05 09:50:28 +05:30 committed by GitHub
commit 2bfe1786a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 34 additions and 16 deletions

View File

@ -0,0 +1,11 @@
import { DatabaseManager } from '../database/manager';
async function execute(dm: DatabaseManager) {
const knexSchema = dm.db?.knex?.schema;
await knexSchema?.alterTable('Item', (table) => {
table.text('hsnCode').alter();
});
}
export default { execute, beforeMigrate: true };

View File

@ -6,6 +6,7 @@ import testPatch from './testPatch';
import updateSchemas from './updateSchemas';
import setPaymentReferenceType from './setPaymentReferenceType';
import fixLedgerDateTime from './v0_21_0/fixLedgerDateTime';
import fixItemHSNField from './fixItemHSNField';
export default [
{ name: 'testPatch', version: '0.5.0-beta.0', patch: testPatch },
@ -40,4 +41,5 @@ export default [
version: '0.21.2',
patch: fixLedgerDateTime,
},
{ name: 'fixItemHSNField', version: '0.24.0', patch: fixItemHSNField },
] as Patch[];

View File

@ -1 +1 @@
[{"name": "Dry-Cleaning", "description": null, "unit": "Unit", "itemType": "Service", "incomeAccount": "Service", "expenseAccount": "Cost of Goods Sold", "tax": "GST-18", "rate": 69, "hsnCode": 999712, "for": "Sales"}, {"name": "Electricity", "description": "Bzz Bzz", "unit": "Day", "itemType": "Service", "incomeAccount": "Service", "expenseAccount": "Utility Expenses", "tax": "GST-0", "rate": 6000, "hsnCode": 271600, "for": "Purchases"}, {"name": "Marketing - Video", "description": "One single video", "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Marketing Expenses", "tax": "GST-18", "rate": 15000, "hsnCode": 998371, "for": "Purchases"}, {"name": "Office Rent", "description": "Rent per day", "unit": "Day", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Office Rent", "tax": "GST-18", "rate": 50000, "hsnCode": 997212, "for": "Purchases"}, {"name": "Office Cleaning", "description": "Cleaning cost per day", "unit": "Day", "itemType": "Service", "incomeAccount": "Service", "expenseAccount": "Office Maintenance Expenses", "tax": "GST-18", "rate": 7500, "hsnCode": 998533, "for": "Purchases"}, {"name": "Social Ads", "description": "Cost per click", "unit": "Unit", "itemType": "Service", "incomeAccount": "Service", "expenseAccount": "Marketing Expenses", "tax": "GST-18", "rate": 50, "hsnCode": 99836, "for": "Purchases"}, {"name": "Cool Cloth", "description": "Some real \ud83c\udd92 cloth", "unit": "Meter", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-18", "rate": 4000, "hsnCode": 59111000, "for": "Both"}, {"name": "611 Jeans - PCH", "description": "Peach coloured 611s", "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-12", "rate": 4499, "hsnCode": 62034990, "for": "Both"}, {"name": "611 Jeans - SHR", "description": "Shark skin 611s", "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-12", "rate": 6499, "hsnCode": 62034990, "for": "Both"}, {"name": "Bominga Shoes", "description": null, "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-18", "rate": 4999, "hsnCode": 640291, "for": "Both"}, {"name": "Cryo Gloves", "description": "Keeps hands cool", "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-18", "rate": 3499, "hsnCode": 611693, "for": "Both"}, {"name": "Epaulettes - 4POR", "description": "Porcelain epaulettes", "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-18", "rate": 2499, "hsnCode": 62179090, "for": "Both"}, {"name": "Full Sleeve - BLK", "description": "Black sleeved", "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-12", "rate": 599, "hsnCode": 100820, "for": "Both"}, {"name": "Full Sleeve - COL", "description": "All color sleeved", "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-12", "rate": 499, "hsnCode": 100820, "for": "Both"}, {"name": "Jacket - RAW", "description": "Raw baby skinned jackets", "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-12", "rate": 8999, "hsnCode": 100820, "for": "Both"}, {"name": "Jade Slippers", "description": null, "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-18", "rate": 2999, "hsnCode": 640520, "for": "Both"}]
[{"name": "Dry-Cleaning", "description": null, "unit": "Unit", "itemType": "Service", "incomeAccount": "Service", "expenseAccount": "Cost of Goods Sold", "tax": "GST-18", "rate": 69, "hsnCode": "999712", "for": "Sales"}, {"name": "Electricity", "description": "Bzz Bzz", "unit": "Day", "itemType": "Service", "incomeAccount": "Service", "expenseAccount": "Utility Expenses", "tax": "GST-0", "rate": 6000, "hsnCode": "271600", "for": "Purchases"}, {"name": "Marketing - Video", "description": "One single video", "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Marketing Expenses", "tax": "GST-18", "rate": 15000, "hsnCode": "998371", "for": "Purchases"}, {"name": "Office Rent", "description": "Rent per day", "unit": "Day", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Office Rent", "tax": "GST-18", "rate": 50000, "hsnCode": "997212", "for": "Purchases"}, {"name": "Office Cleaning", "description": "Cleaning cost per day", "unit": "Day", "itemType": "Service", "incomeAccount": "Service", "expenseAccount": "Office Maintenance Expenses", "tax": "GST-18", "rate": 7500, "hsnCode": "998533", "for": "Purchases"}, {"name": "Social Ads", "description": "Cost per click", "unit": "Unit", "itemType": "Service", "incomeAccount": "Service", "expenseAccount": "Marketing Expenses", "tax": "GST-18", "rate": 50, "hsnCode": "99836", "for": "Purchases"}, {"name": "Cool Cloth", "description": "Some real \ud83c\udd92 cloth", "unit": "Meter", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-18", "rate": 4000, "hsnCode": "59111000", "for": "Both"}, {"name": "611 Jeans - PCH", "description": "Peach coloured 611s", "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-12", "rate": 4499, "hsnCode": "62034990", "for": "Both"}, {"name": "611 Jeans - SHR", "description": "Shark skin 611s", "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-12", "rate": 6499, "hsnCode": "62034990", "for": "Both"}, {"name": "Bominga Shoes", "description": null, "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-18", "rate": 4999, "hsnCode": "640291", "for": "Both"}, {"name": "Cryo Gloves", "description": "Keeps hands cool", "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-18", "rate": 3499, "hsnCode": "611693", "for": "Both"}, {"name": "Epaulettes - 4POR", "description": "Porcelain epaulettes", "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-18", "rate": 2499, "hsnCode": "62179090", "for": "Both"}, {"name": "Full Sleeve - BLK", "description": "Black sleeved", "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-12", "rate": 599, "hsnCode": "100820", "for": "Both"}, {"name": "Full Sleeve - COL", "description": "All color sleeved", "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-12", "rate": 499, "hsnCode": "100820", "for": "Both"}, {"name": "Jacket - RAW", "description": "Raw baby skinned jackets", "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-12", "rate": 8999, "hsnCode": "100820", "for": "Both"}, {"name": "Jade Slippers", "description": null, "unit": "Unit", "itemType": "Product", "incomeAccount": "Sales", "expenseAccount": "Cost of Goods Sold", "tax": "GST-18", "rate": 2999, "hsnCode": "640520", "for": "Both"}]

View File

@ -76,6 +76,11 @@ export class Item extends Doc {
throw new ValidationError(this.fyo.t`Rate can't be negative.`);
}
},
hsnCode: (value: DocValue) => {
if (value && !(value as string).match(/^\d{4,8}$/)) {
throw new ValidationError(this.fyo.t`Invalid HSN Code.`);
}
},
};
static getActions(fyo: Fyo): Action[] {

View File

@ -1201,7 +1201,7 @@ export async function updatePricingRule(sinvDoc: SalesInvoice) {
).length;
setTimeout(() => {
(async () => {
void (async () => {
if (appliedPricingRuleCount !== applicablePricingRuleNames?.length) {
await sinvDoc.appendPricingRuleDetail(applicablePricingRuleNames);
await sinvDoc.applyProductDiscount();

View File

@ -113,7 +113,7 @@
{
"fieldname": "hsnCode",
"label": "HSN/SAC",
"fieldtype": "Int",
"fieldtype": "Data",
"placeholder": "HSN/SAC Code",
"section": "Inventory"
},

View File

@ -1,13 +1,13 @@
"Item Name",Description,"Unit Type",Type,For,"Sales Acc.","Purchase Acc.",Tax,Rate,HSN/SAC,Barcode,"Track Item","Created By","Modified By",Created,Modified
Item.name,Item.description,Item.unit,Item.itemType,Item.for,Item.incomeAccount,Item.expenseAccount,Item.tax,Item.rate,Item.hsnCode,Item.barcode,Item.trackItem,Item.createdBy,Item.modifiedBy,Item.created,Item.modified
"Final Item","A final item made from raw items",Unit,Product,Both,Sales,"Stock Received But Not Billed",,500,0,,1,lin@to.co,lin@to.co,2023-01-31T06:46:00.200Z,2023-01-31T06:46:00.200Z
"Raw Two","Another Raw item used to make a final item",Unit,Product,Both,Sales,"Stock Received But Not Billed",,200,0,,1,lin@to.co,lin@to.co,2023-01-31T06:45:32.449Z,2023-01-31T06:45:32.449Z
"Raw One","A raw item used to make a final item.",Unit,Product,Both,Sales,"Stock Received But Not Billed",,100,0,,1,lin@to.co,lin@to.co,2023-01-31T06:44:58.047Z,2023-01-31T06:44:58.047Z
"Test One",,Unit,Product,Both,Sales,"Stock Received But Not Billed",GST-18,200,0,,1,lin@to.co,lin@to.co,2023-01-09T10:46:02.217Z,2023-01-09T10:46:02.217Z
Stuff,"Some stuff.",Unit,Product,Both,Sales,"Stock Received But Not Billed",GST-18,200,101192,,1,lin@to.co,lin@to.co,2023-01-09T07:14:12.208Z,2023-01-09T07:14:12.208Z
"Something Sellable",,Unit,Product,Sales,Sales,"Cost of Goods Sold",,300,0,,0,lin@to.co,lin@to.co,2022-10-11T09:15:15.724Z,2023-01-16T08:49:49.267Z
Ball,"Just a ball..",Unit,Product,Both,Sales,"Cost of Goods Sold",,30,0,,0,Administrator,Administrator,2022-02-24T04:38:09.181Z,2022-02-24T04:38:09.181Z
Bat,"Regular old bat...",Unit,Product,Both,Sales,"Cost of Goods Sold",,129,0,,0,Administrator,Administrator,2022-02-24T04:38:09.174Z,2022-02-24T04:38:09.174Z
"Holy Icon","The holiest of icons.",Unit,Product,Both,Sales,"Cost of Goods Sold",GST-3,330,0,,0,Administrator,Administrator,2022-02-11T11:32:33.342Z,2022-02-11T11:32:33.342Z
"Flower Pot","Just a flower pot.",Unit,Product,Both,Sales,"Cost of Goods Sold",GST-12,200,,,0,Administrator,Administrator,2021-12-16T07:04:08.233Z,2021-12-16T07:04:08.233Z
Flow,"Used to test the flow of operations.",Unit,Product,Both,Sales,"Cost of Goods Sold",GST-12,100,,,0,Administrator,Administrator,2021-12-16T05:42:02.081Z,2021-12-16T05:48:48.203Z
Item Name,Description,Unit Type,Type,For,Sales Acc.,Purchase Acc.,Tax,Rate,HSN/SAC,Barcode,Track Item,Created By,Modified By,Created,Modified
Item.name,Item.description,Item.unit,Item.itemType,Item.for,Item.incomeAccount,Item.expenseAccount,Item.tax,Item.rate,Item.hsnCode,Item.barcode,Item.trackItem,Item.createdBy,Item.modifiedBy,Item.created,Item.modified
Final Item,A final item made from raw items,Unit,Product,Both,Sales,Stock Received But Not Billed,,500,,,1,lin@to.co,lin@to.co,2023-01-31T06:46:00.200Z,2023-01-31T06:46:00.200Z
Raw Two,Another Raw item used to make a final item,Unit,Product,Both,Sales,Stock Received But Not Billed,,200,,,1,lin@to.co,lin@to.co,2023-01-31T06:45:32.449Z,2023-01-31T06:45:32.449Z
Raw One,A raw item used to make a final item.,Unit,Product,Both,Sales,Stock Received But Not Billed,,100,,,1,lin@to.co,lin@to.co,2023-01-31T06:44:58.047Z,2023-01-31T06:44:58.047Z
Test One,,Unit,Product,Both,Sales,Stock Received But Not Billed,GST-18,200,,,1,lin@to.co,lin@to.co,2023-01-09T10:46:02.217Z,2023-01-09T10:46:02.217Z
Stuff,Some stuff.,Unit,Product,Both,Sales,Stock Received But Not Billed,GST-18,200,101192,,1,lin@to.co,lin@to.co,2023-01-09T07:14:12.208Z,2023-01-09T07:14:12.208Z
Something Sellable,,Unit,Product,Sales,Sales,Cost of Goods Sold,,300,,,0,lin@to.co,lin@to.co,2022-10-11T09:15:15.724Z,2023-01-16T08:49:49.267Z
Ball,Just a ball..,Unit,Product,Both,Sales,Cost of Goods Sold,,30,,,0,Administrator,Administrator,2022-02-24T04:38:09.181Z,2022-02-24T04:38:09.181Z
Bat,Regular old bat...,Unit,Product,Both,Sales,Cost of Goods Sold,,129,,,0,Administrator,Administrator,2022-02-24T04:38:09.174Z,2022-02-24T04:38:09.174Z
Holy Icon,The holiest of icons.,Unit,Product,Both,Sales,Cost of Goods Sold,GST-3,330,,,0,Administrator,Administrator,2022-02-11T11:32:33.342Z,2022-02-11T11:32:33.342Z
Flower Pot,Just a flower pot.,Unit,Product,Both,Sales,Cost of Goods Sold,GST-12,200,,,0,Administrator,Administrator,2021-12-16T07:04:08.233Z,2021-12-16T07:04:08.233Z
Flow,Used to test the flow of operations.,Unit,Product,Both,Sales,Cost of Goods Sold,GST-12,100,,,0,Administrator,Administrator,2021-12-16T05:42:02.081Z,2021-12-16T05:48:48.203Z

1 Item Name Description Unit Type Type For Sales Acc. Purchase Acc. Tax Rate HSN/SAC Barcode Track Item Created By Modified By Created Modified
2 Item.name Item.description Item.unit Item.itemType Item.for Item.incomeAccount Item.expenseAccount Item.tax Item.rate Item.hsnCode Item.barcode Item.trackItem Item.createdBy Item.modifiedBy Item.created Item.modified
3 Final Item A final item made from raw items Unit Product Both Sales Stock Received But Not Billed 500 0 1 lin@to.co lin@to.co 2023-01-31T06:46:00.200Z 2023-01-31T06:46:00.200Z
4 Raw Two Another Raw item used to make a final item Unit Product Both Sales Stock Received But Not Billed 200 0 1 lin@to.co lin@to.co 2023-01-31T06:45:32.449Z 2023-01-31T06:45:32.449Z
5 Raw One A raw item used to make a final item. Unit Product Both Sales Stock Received But Not Billed 100 0 1 lin@to.co lin@to.co 2023-01-31T06:44:58.047Z 2023-01-31T06:44:58.047Z
6 Test One Unit Product Both Sales Stock Received But Not Billed GST-18 200 0 1 lin@to.co lin@to.co 2023-01-09T10:46:02.217Z 2023-01-09T10:46:02.217Z
7 Stuff Some stuff. Unit Product Both Sales Stock Received But Not Billed GST-18 200 101192 1 lin@to.co lin@to.co 2023-01-09T07:14:12.208Z 2023-01-09T07:14:12.208Z
8 Something Sellable Unit Product Sales Sales Cost of Goods Sold 300 0 0 lin@to.co lin@to.co 2022-10-11T09:15:15.724Z 2023-01-16T08:49:49.267Z
9 Ball Just a ball.. Unit Product Both Sales Cost of Goods Sold 30 0 0 Administrator Administrator 2022-02-24T04:38:09.181Z 2022-02-24T04:38:09.181Z
10 Bat Regular old bat... Unit Product Both Sales Cost of Goods Sold 129 0 0 Administrator Administrator 2022-02-24T04:38:09.174Z 2022-02-24T04:38:09.174Z
11 Holy Icon The holiest of icons. Unit Product Both Sales Cost of Goods Sold GST-3 330 0 0 Administrator Administrator 2022-02-11T11:32:33.342Z 2022-02-11T11:32:33.342Z
12 Flower Pot Just a flower pot. Unit Product Both Sales Cost of Goods Sold GST-12 200 0 Administrator Administrator 2021-12-16T07:04:08.233Z 2021-12-16T07:04:08.233Z
13 Flow Used to test the flow of operations. Unit Product Both Sales Cost of Goods Sold GST-12 100 0 Administrator Administrator 2021-12-16T05:42:02.081Z 2021-12-16T05:48:48.203Z