From 3a3e57fd63b081d5ded67a29e43c55f845b0a35b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96zt=C3=BCrk?= Date: Mon, 22 Dec 2025 21:56:02 +0300 Subject: [PATCH] =?UTF-8?q?Total=20Amount=20ve=20Material=20onChange=20de?= =?UTF-8?q?=C4=9Fi=C5=9Ftirildi.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Crm.cs | 6 +++--- api/src/Erp.Platform.Domain.Shared/PlatformConsts.cs | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Crm.cs b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Crm.cs index 6e497e44..69a74c76 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Crm.cs +++ b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Crm.cs @@ -2779,9 +2779,9 @@ public class ListFormSeeder_Crm : IDataSeedContributor, ITransientDependency new() { Order=1, ColCount=2, ColSpan=1, ItemType="group", Items =[ new EditingFormItemDto { Order = 1, DataField="MaterialId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox, EditorScript = EditorScriptValues.MaterialOnChange }, - new EditingFormItemDto { Order = 2, DataField="Quantity", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat }, - new EditingFormItemDto { Order = 3, DataField="UnitPrice", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat }, - new EditingFormItemDto { Order = 4, DataField="TotalAmount", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat }, + new EditingFormItemDto { Order = 2, DataField="Quantity", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat, EditorScript = EditorScriptValues.CalcTotalAmount }, + new EditingFormItemDto { Order = 3, DataField="UnitPrice", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat, EditorScript = EditorScriptValues.CalcTotalAmount }, + new EditingFormItemDto { Order = 4, DataField="TotalAmount", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = "{ \"format\": \"fixedPoint\", \"precision\": 2, \"disabled\" : true }" }, new EditingFormItemDto { Order = 5, DataField="UomId", ColSpan = 1, EditorType2 = EditorTypes.dxSelectBox }, new EditingFormItemDto { Order = 6, DataField="DiscountRate", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat }, new EditingFormItemDto { Order = 7, DataField="DiscountAmount", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat }, diff --git a/api/src/Erp.Platform.Domain.Shared/PlatformConsts.cs b/api/src/Erp.Platform.Domain.Shared/PlatformConsts.cs index 76cc162f..31ecd036 100644 --- a/api/src/Erp.Platform.Domain.Shared/PlatformConsts.cs +++ b/api/src/Erp.Platform.Domain.Shared/PlatformConsts.cs @@ -32,8 +32,9 @@ public static class PlatformConsts { public static string CalcTotalDaysFromDates = "(() => {const d=v=>!v?null:(v instanceof Date?v:new Date(v));const nf={...formData,[editor.dataField]:e?.value};const s=d(nf.StartDate),t=d(nf.EndDate);setFormData({...formData,TotalDays: s&&t?Math.max(0,Math.floor((Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())-Date.UTC(s.getFullYear(),s.getMonth(),s.getDate()))/(24*60*60*1000))+1):null});})();"; public static string CalcTotalHoursFromTimes = "(()=>{const toD=v=>!v?null:(v instanceof Date?v:new Date(v));const next={...formData,[e.dataField]:e.value};const s=toD(next.StartTime),t=toD(next.EndTime);let h=null;if(s&&t){h=(t-s)/36e5;if(h<0)h+=24;h=Math.round(h*10)/10;}setFormData({...next,TotalHours:h});})();"; - public static string MaterialOnChange = "(() => { const p = e.component.option('selectedItem'); setFormData({ ...formData, Quantity: p.Quantity, UnitPrice: p.UnitPrice, UomId: p.UomId } ) })();"; - } + public static string MaterialOnChange = "(() => { const p = e.component.option('selectedItem'); const q = parseFloat(p?.Quantity) || 0; const u = parseFloat(p?.UnitPrice) || 0; const t = Math.round(q * u * 100) / 100; setFormData({ ...formData, Quantity: q, UnitPrice: u, UomId: p.UomId, TotalAmount: t }); })();"; + public static string CalcTotalAmount = "(() => { const next={...formData,[e.dataField]:e.value}; const q=parseFloat(next.Quantity)||0; const p=parseFloat(next.UnitPrice)||0; const t=Math.round(q*p*100)/100; setFormData({...next,TotalAmount:t}); })();"; + } public static class Prefix {