Skip to content

Commit 56fb772

Browse files
authored
Default tax class (#405)
* #388 Default tax class when create new product
1 parent bb5ef8d commit 56fb772

File tree

8 files changed

+112
-37
lines changed

8 files changed

+112
-37
lines changed

src/Database/StaticData.sql

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ INSERT [dbo].[Core_AppSetting] ([Id], [Key], [Value], [IsVisibleInCommonSettingP
99
INSERT [dbo].[Core_AppSetting] ([Id], [Key], [Value], [IsVisibleInCommonSettingPage], [Module]) VALUES (8, N'SmtpPassword', N'', 0, N'Core')
1010
INSERT [dbo].[Core_AppSetting] ([Id], [Key], [Value], [IsVisibleInCommonSettingPage], [Module]) VALUES (9, N'Theme', N'Generic', 0, N'Core')
1111
INSERT [dbo].[Core_AppSetting] ([Id], [Key], [Value], [IsVisibleInCommonSettingPage], [Module]) VALUES (10, N'Tax.IsProductPriceIncludeTax', N'true', 1, N'Tax')
12+
INSERT [dbo].[Core_AppSetting] ([Id], [Key], [Value], [IsVisibleInCommonSettingPage], [Module]) VALUES (11, N'Tax.DefaultTaxClassId', N'1', 1, N'Tax')
1213
SET IDENTITY_INSERT [dbo].[Core_AppSetting] OFF
1314
GO
1415

@@ -1230,8 +1231,23 @@ INSERT INTO Core_District (Id, Name, [Type], [Location], StateOrProvinceId) VALU
12301231
SET IDENTITY_INSERT Core_District OFF
12311232
GO
12321233

1234+
SET IDENTITY_INSERT [dbo].[Tax_TaxClass] ON
1235+
INSERT [dbo].[Tax_TaxClass] ([Id], [Name]) VALUES (1, N'Standard VAT')
1236+
SET IDENTITY_INSERT [dbo].[Tax_TaxClass] OFF
1237+
GO
1238+
1239+
SET IDENTITY_INSERT [dbo].[Tax_TaxRate] ON
1240+
INSERT [dbo].[Tax_TaxRate] ([Id], [CountryId], [Name], [Rate], [StateOrProvinceId], [TaxClassId]) VALUES (1, 238, N'Standard VN VAT', CAST(10.00 AS Decimal(18, 2)), NULL, 1)
1241+
SET IDENTITY_INSERT [dbo].[Tax_TaxRate] OFF
1242+
GO
1243+
1244+
SET IDENTITY_INSERT [dbo].[Core_Address] ON
1245+
INSERT [dbo].[Core_Address] ([Id], [AddressLine1], [ContactName], [CountryId], [DistrictId], [Phone], [StateOrProvinceId], [City], [PostalCode]) VALUES (1, NULL, N'SimplCommerce', 238, NULL, NULL, 93, NULL, NULL)
1246+
SET IDENTITY_INSERT [dbo].[Core_Address] OFF
1247+
GO
1248+
12331249
SET IDENTITY_INSERT [dbo].[Inventory_Warehouse] ON
1234-
INSERT [dbo].[Inventory_Warehouse] ([Id], [AddressId], [Name]) VALUES (1, NULL, N'Default warehouse')
1250+
INSERT [dbo].[Inventory_Warehouse] ([Id], [AddressId], [Name]) VALUES (1, 1, N'Default warehouse')
12351251
SET IDENTITY_INSERT [dbo].[Inventory_Warehouse] OFF
12361252
GO
12371253

src/Database/StaticData_PostgreSQL.sql

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ INSERT INTO "Core_AppSetting" ("Id", "Key", "Value", "IsVisibleInCommonSettingPa
88
INSERT INTO "Core_AppSetting" ("Id", "Key", "Value", "IsVisibleInCommonSettingPage", "Module") VALUES (8, 'SmtpPassword', '', false, 'Core');
99
INSERT INTO "Core_AppSetting" ("Id", "Key", "Value", "IsVisibleInCommonSettingPage", "Module") VALUES (9, 'Theme', 'Generic', false, 'Core');
1010
INSERT INTO "Core_AppSetting" ("Id", "Key", "Value", "IsVisibleInCommonSettingPage", "Module") VALUES (10, 'Tax.IsProductPriceIncludeTax', 'true', true, 'Tax');
11-
SELECT pg_catalog.setval('"Core_AppSetting_Id_seq"', 10, true);
11+
INSERT INTO "Core_AppSetting" ("Id", "Key", "Value", "IsVisibleInCommonSettingPage", "Module") VALUES (11, 'Tax.DefaultTaxClassId', '1', true, 'Tax');
12+
SELECT pg_catalog.setval('"Core_AppSetting_Id_seq"', 11, true);
1213

1314
INSERT INTO "Core_Role" ("Id", "ConcurrencyStamp", "Name", "NormalizedName") VALUES (1, 'bd3bee0b-5f1d-482d-b890-ffdc01915da3', 'admin', 'ADMIN');
1415
INSERT INTO "Core_Role" ("Id", "ConcurrencyStamp", "Name", "NormalizedName") VALUES (2, 'bd3bee0b-5f1d-482d-b890-ffdc01915da3', 'customer', 'CUSTOMER');
@@ -83,7 +84,16 @@ INSERT INTO "Core_District" ("Id", "Location", "Name", "StateOrProvinceId", "Typ
8384
INSERT INTO "Core_District" ("Id", "Location", "Name", "StateOrProvinceId", "Type") VALUES (18, NULL, 'Phú Nhuận', 79, NULL);
8485
INSERT INTO "Core_District" ("Id", "Location", "Name", "StateOrProvinceId", "Type") VALUES (19, NULL, 'Bình Chánh', 79, NULL);
8586

86-
INSERT INTO "Inventory_Warehouse" ("Id", "AddressId", "Name") VALUES (1, NULL, 'Default warehouse');
87+
INSERT INTO "Tax_TaxClass" ("Id", "Name") VALUES (1, 'Standard VAT');
88+
SELECT pg_catalog.setval('"Tax_TaxClass_Id_seq"', 1, true);
89+
90+
INSERT INTO "Tax_TaxRate" ("Id", "CountryId", "Name", "Rate", "StateOrProvinceId", "TaxClassId") VALUES (1, 238, 'Standard VN VAT', CAST(10.00 AS Decimal(18, 2)), NULL, 1);
91+
SELECT pg_catalog.setval('"Tax_TaxRate_Id_seq"', 1, true);
92+
93+
INSERT INTO "Core_Address" ("Id", "AddressLine1", "ContactName", "CountryId", "DistrictId", "Phone", "StateOrProvinceId", "City", "PostalCode") VALUES (1, NULL, 'SimplCommerce', 238, NULL, NULL, 93, NULL, NULL);
94+
SELECT pg_catalog.setval('"Core_Address_Id_seq"', 1, true);
95+
96+
INSERT INTO "Inventory_Warehouse" ("Id", "AddressId", "Name") VALUES (1, 1, 'Default warehouse');
8797
SELECT pg_catalog.setval('"Inventory_Warehouse_Id_seq"', 1, true);
8898

8999
INSERT INTO "Shipping_ShippingProvider" ("Id", "AdditionalSettings", "ConfigureUrl", "IsEnabled", "Name", "OnlyCountryIdsString", "OnlyStateOrProvinceIdsString", "ShippingPriceServiceTypeName", "ToAllShippingEnabledCountries", "ToAllShippingEnabledStatesOrProvinces") VALUES (1, N'{MinimumOrderAmount : 10}', N'shipping-free-config', true, N'Free Ship', NULL, NULL, N'SimplCommerce.Module.ShippingFree.Services.FreeShippingServiceProvider,SimplCommerce.Module.ShippingFree', true, true);

src/Modules/SimplCommerce.Module.Catalog/wwwroot/admin/product/product-form.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,21 @@
401401
});
402402
}
403403

404+
function getDefaultTaxClass() {
405+
productService.getDefaultTaxClass().then(function (result) {
406+
if (result.data) {
407+
vm.product.taxClassId = result.data.id;
408+
}
409+
});
410+
}
411+
404412
function init() {
405413
if (vm.isEditMode) {
406414
getProduct();
407415
}
416+
else {
417+
getDefaultTaxClass();
418+
}
408419
getProductOptions();
409420
getProductTemplates();
410421
getAttributes();

src/Modules/SimplCommerce.Module.Catalog/wwwroot/admin/product/product-service.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
getProduct: getProduct,
1818
changeStatus: changeStatus,
1919
deleteProduct: deleteProduct,
20-
getTaxClasses: getTaxClasses
20+
getTaxClasses: getTaxClasses,
21+
getDefaultTaxClass: getDefaultTaxClass
2122
};
2223
return service;
2324

@@ -81,5 +82,9 @@
8182
function getTaxClasses() {
8283
return $http.get('api/tax-classes');
8384
}
85+
86+
function getDefaultTaxClass() {
87+
return $http.get('api/tax-classes/default');
88+
}
8489
}
8590
})();

0 commit comments

Comments
 (0)