Browse Source

Merge remote-tracking branch 'origin/frank' into kenric

Kenric Nugteren 11 months ago
parent
commit
53f8ab56e4

+ 1 - 1
prs.classes/Entities/Invoice/Invoice.cs

@@ -111,7 +111,7 @@ namespace Comal.Classes
         
         [EditorSequence(14)]
         [DateEditor(Visible = Visible.Default, TodayVisible = true)]
-        public DateTime DueDate { get; set; }
+        public DateTime DueDate { get; set; } = DateTime.Today;
         
         [EditorSequence(15)]
         public SalesGLCodeLink SellGL { get; set; }

+ 33 - 1
prs.classes/Entities/Job/Requisitions/JobRequisitionItem.cs

@@ -180,7 +180,39 @@ namespace Comal.Classes
         [DoubleEditor(Editable = Editable.Disabled)]
         [EditorSequence(12)]
         public double OnOrder { get; set; }
-
+        
+        
+        private class GeneralOrderFormula : ComplexFormulaGenerator<JobRequisitionItem, double>
+        {
+            public override IComplexFormulaNode<JobRequisitionItem, double> GetFormula() =>
+                Formula(
+                    FormulaOperator.Divide,
+                    Formula(
+                        FormulaOperator.Add,
+
+                        Aggregate<PurchaseOrderItem>(
+                                AggregateCalculation.Sum,
+                                x => x.Property(x => x.Unallocated),
+                                new Filter<PurchaseOrderItem>(x => x.ReceivedDate).IsEqualTo(null)
+                                    .And(x => x.Job.ID).IsEqualTo(Guid.Empty)
+                            )
+                            .WithLink(x => x.Product.ID, x => x.Product.ID),
+                        
+                            
+                        Aggregate<PurchaseOrderItemAllocation>(
+                            AggregateCalculation.Sum,
+                            x => x.Property(x => x.Quantity),
+                            new Filter<PurchaseOrderItemAllocation>(x => x.Item.ReceivedDate).IsEqualTo(null)
+                                .And(x => x.Job.ID).IsEqualTo(Guid.Empty)
+                            ).WithLink(x => x.Item.Product.ID, x => x.Product.ID)
+                    ),
+                    Property(x => x.Dimensions.Value)
+                );
+        }
+        [ComplexFormula(typeof(GeneralOrderFormula))]
+        [DoubleEditor(Editable = Editable.Hidden)]
+        public double GeneralOrder { get; set; }
+        
         private class TreatmentRequiredFormula : ComplexFormulaGenerator<JobRequisitionItem, double>
         {
             public override IComplexFormulaNode<JobRequisitionItem, double> GetFormula() =>

+ 32 - 0
prs.classes/Entities/PurchaseOrder/PurchaseOrderItem.cs

@@ -56,6 +56,38 @@ namespace Comal.Classes
         [EditorSequence(7)]
         public double Qty { get; set; } = 1;
         
+        private class AllocatedFormula : ComplexFormulaGenerator<PurchaseOrderItem, double>
+        {
+            public override IComplexFormulaNode<PurchaseOrderItem, double> GetFormula() =>
+                Aggregate<PurchaseOrderItemAllocation>(
+                        AggregateCalculation.Sum,
+                        x => x.Property(x => x.Quantity))
+                    .WithLink(x => x.Item.ID, x => x.ID);
+        }
+        
+        [ComplexFormula(typeof(AllocatedFormula))]
+        [DoubleEditor(Editable = Editable.Hidden)]
+        public double Allocated { get; set; }
+        
+        private class UnallocatedFormula : ComplexFormulaGenerator<PurchaseOrderItem, double>
+        {
+            public override IComplexFormulaNode<PurchaseOrderItem, double> GetFormula() =>
+                Formula(
+                    FormulaOperator.Subtract,
+                    Formula(
+                        FormulaOperator.Multiply,
+                        Property(x=>x.Qty),
+                        Property(x=>x.Dimensions.Value)
+                    ),
+                    Property(x=>x.Allocated)
+                );
+        }
+        
+        [ComplexFormula(typeof(UnallocatedFormula))]
+        [DoubleEditor(Editable = Editable.Hidden)]
+        public double Unallocated { get; set; }
+        
+        
         [CurrencyEditor(Visible = Visible.Optional)]
         [EditorSequence(8)]
         public double ForeignCurrencyCost { get; set; }

+ 1 - 0
prs.desktop/Panels/Invoices/InvoiceGrid.cs

@@ -102,6 +102,7 @@ namespace PRSDesktop
                     var invoice = new Invoice();
                     invoice.Type = InvoiceType.ProgressClaim;
                     invoice.Description = $"Progress claim for {DateTime.Today:MMM yyyy}";
+                    //invoice.Date = DateTime.Today;
                     invoice.JobLink.CopyFrom(Master);
                     if (Master.Account.ID != Guid.Empty) 
                         invoice.CustomerLink.CopyFrom(Master.Account);

+ 8 - 0
prs.desktop/Panels/Jobs/ProjectsGrid.cs

@@ -53,6 +53,10 @@ public class ProjectsGrid : DynamicDataGrid<Job>
         HiddenColumns.Add(x => x.Customer.ID);
         HiddenColumns.Add(x => x.Customer.Code);
         HiddenColumns.Add(x => x.Customer.Name);
+        HiddenColumns.Add(x => x.Customer.Terms.ID);
+        HiddenColumns.Add(x => x.Customer.Terms.Code);
+        HiddenColumns.Add(x => x.Customer.Terms.Description);
+        HiddenColumns.Add(x => x.Customer.Terms.Calculation);
         HiddenColumns.Add(x => x.SiteAddress.Street);
         HiddenColumns.Add(x => x.SiteAddress.City);
         HiddenColumns.Add(x => x.SiteAddress.State);
@@ -60,6 +64,10 @@ public class ProjectsGrid : DynamicDataGrid<Job>
         HiddenColumns.Add(x => x.Account.ID);
         HiddenColumns.Add(x => x.Account.Code);
         HiddenColumns.Add(x => x.Account.Name);
+        HiddenColumns.Add(x => x.Account.Terms.ID);
+        HiddenColumns.Add(x => x.Account.Terms.Code);
+        HiddenColumns.Add(x => x.Account.Terms.Description);
+        HiddenColumns.Add(x => x.Account.Terms.Calculation);
         HiddenColumns.Add(x => x.Notes);
         HiddenColumns.Add(x => x.JobStatus.ID);
         HiddenColumns.Add(x => x.JobStatus.Active);

+ 3 - 3
prs.desktop/prsdesktop.iss

@@ -8,7 +8,7 @@
 #define public Dependency_Path_NetCoreCheck "dependencies\"
 
 #define MyAppName "PRS Desktop"
-#define MyAppVersion "8.25"
+#define MyAppVersion "8.25b"
 #define MyAppPublisher "PRS Digital"
 #define MyAppURL "https://www.prs-software.com.au"
 #define MyAppExeName "PRSDesktop.exe"
@@ -28,8 +28,8 @@ AppSupportURL={#MyAppURL}
 AppUpdatesURL={#MyAppURL}
 DefaultDirName={userpf}\{#MyAppName}
 DisableProgramGroupPage=yes
-OutputDir=C:\Development\prs\prs.server\bin\Debug\net8.0-windows\update
-SourceDir=C:\Development\prs\prs.server\..\prs.desktop\
+OutputDir=C:\development\prs\prs.server\bin\Debug\net8.0-windows\update
+SourceDir=C:\development\prs\prs.server\..\prs.desktop\
 OutputBaseFilename=PRSDesktopSetup
 Compression=lzma
 SolidCompression=yes

+ 3 - 3
prs.licensing/PRSLicensing.iss

@@ -8,7 +8,7 @@
 #define public Dependency_Path_NetCoreCheck "dependencies\"
 
 #define MyAppName "PRS Licensing"
-#define MyAppVersion "8.25"
+#define MyAppVersion "8.25b"
 #define MyAppPublisher "PRS Digital"
 #define MyAppURL "https://www.prs-software.com.au"
 #define MyAppExeName "PRSLicensing.exe"
@@ -27,8 +27,8 @@ AppSupportURL={#MyAppURL}
 AppUpdatesURL={#MyAppURL}
 DefaultDirName={pf}\{#MyAppName}
 DisableProgramGroupPage=yes
-OutputDir=C:\Development\prs\prs.server\bin\Debug\net8.0-windows\update
-SourceDir=C:\Development\prs\prs.server\..\prs.licensing\
+OutputDir=C:\development\prs\prs.server\bin\Debug\net8.0-windows\update
+SourceDir=C:\development\prs\prs.server\..\prs.licensing\
 OutputBaseFilename=PRSLicensingSetup
 Compression=lzma
 SolidCompression=yes

+ 3 - 3
prs.server/PRSServer.iss

@@ -8,7 +8,7 @@
 #define public Dependency_Path_NetCoreCheck "dependencies\"
 
 #define MyAppName "PRS Server"
-#define MyAppVersion "8.25"
+#define MyAppVersion "8.25b"
 #define MyAppPublisher "PRS Digital"
 #define MyAppURL "https://www.prs-software.com.au"
 #define MyAppExeName "PRSServer.exe"
@@ -27,8 +27,8 @@ AppSupportURL={#MyAppURL}
 AppUpdatesURL={#MyAppURL}
 DefaultDirName={pf}\{#MyAppName}
 DisableProgramGroupPage=yes
-OutputDir=C:\Development\prs\prs.server\
-SourceDir=C:\Development\prs\prs.server\
+OutputDir=C:\development\prs\prs.server\
+SourceDir=C:\development\prs\prs.server\
 OutputBaseFilename=PRSServerSetup
 Compression=lzma
 SolidCompression=yes

+ 4 - 0
prs.server/install.bat

@@ -39,5 +39,9 @@ powershell -Command "(gc ../prs.licensing/prslicensing.iss) -replace 'OutputDir=
 powershell -Command "(gc ../prs.licensing/prslicensing.iss) -replace 'SourceDir=[^\""]*', 'SourceDir=%~dp0..\prs.licensing\' | Out-File -encoding ASCII ../prs.licensing/prslicensing.iss"
 "C:\Program Files (x86)\Inno Setup 6\iscc.exe" /Qp /O"." /F"PRSLicensing" ../prs.licensing/prslicensing.iss 
 
+echo Cleaning Up...
+del bin\Debug\net8.0-windows\update\version.txt
+del bin\Debug\net8.0-windows\version.txt
+
 echo.
 echo All Done! PRS v%version_number% Installer can be found at %~dp0PRSSetup.exe 

+ 6 - 0
prs.shared/Posters/MYOB/BillMYOBPoster.cs

@@ -11,6 +11,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using MYOB.AccountRight.SDK.Contracts.Version2;
 using MYOBBill = MYOB.AccountRight.SDK.Contracts.Version2.Purchase.ServiceBill;
 using MYOBBillLine = MYOB.AccountRight.SDK.Contracts.Version2.Purchase.ServiceBillLine;
 using MYOBTaxCode = MYOB.AccountRight.SDK.Contracts.Version2.GeneralLedger.TaxCode;
@@ -95,6 +96,7 @@ public class BillMYOBPoster : IMYOBPoster<Bill, BillMYOBPosterSettings>
             .Add(x => x.PostedReference)
             .Add(x => x.Number)
             .Add(x => x.AccountingDate)
+            .Add(x => x.PaymentDate)
             .Add(x => x.SupplierLink.ID)
             .Add(x => x.Description);
     }
@@ -163,6 +165,10 @@ public class BillMYOBPoster : IMYOBPoster<Bill, BillMYOBPosterSettings>
 
             // Probably configure which date.
             myobBill.Date = bill.AccountingDate;
+
+            myobBill.Terms ??= new();
+            myobBill.Terms.PaymentIsDue = TermsPaymentType.InAGivenNumberOfDays;
+            myobBill.Terms.BalanceDueDate = (bill.PaymentDate.Date - bill.BillDate.Date).Days + 1;
             myobBill.SupplierInvoiceNumber = bill.Number.Truncate(255);
 
             if(suppliers.TryGetValue(bill.SupplierLink.ID, out var supplier))

+ 7 - 0
prs.shared/Posters/MYOB/InvoiceMYOBPoster.cs

@@ -11,6 +11,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using MYOB.AccountRight.SDK.Contracts.Version2;
 using Invoice = Comal.Classes.Invoice;
 using InvoiceLine = Comal.Classes.InvoiceLine;
 using MYOBAccount = MYOB.AccountRight.SDK.Contracts.Version2.GeneralLedger.Account;
@@ -95,6 +96,7 @@ public class InvoiceMYOBPoster : IMYOBPoster<Invoice, InvoiceMYOBPosterSettings>
             .Add(x => x.PostedReference)
             .Add(x => x.Number)
             .Add(x => x.Date)
+            .Add(x => x.DueDate)
             .Add(x => x.CustomerLink.ID)
             .Add(x => x.Description);
     }
@@ -153,6 +155,11 @@ public class InvoiceMYOBPoster : IMYOBPoster<Invoice, InvoiceMYOBPosterSettings>
 
             myobInvoice.Number = invoice.Number.ToString().Truncate(13);
             myobInvoice.Date = invoice.Date;
+            
+            myobInvoice.Terms ??= new();
+            myobInvoice.Terms.PaymentIsDue = TermsPaymentType.InAGivenNumberOfDays;
+            myobInvoice.Terms.BalanceDueDate = (invoice.DueDate.Date - invoice.Date.Date).Days + 1;
+            
             // myobInvoice.CustomerPurchaseOrderNumber = 
 
             if(customers.TryGetValue(invoice.CustomerLink.ID, out var customer))

+ 11 - 4
prs.stores/GPSTrackerLocationStore.cs

@@ -50,11 +50,18 @@ namespace Comal.Stores
             var tuple = _addresses.FirstOrDefault(x => Equals(x.Item1, latitude) && Equals(x.Item2, longitude));
             if (tuple == null)
             {
-                var address = StoreUtils.ReverseGeocode(latitude, longitude);
-                if (!string.IsNullOrWhiteSpace(address))
+                try
                 {
-                    tuple = new Tuple<double, double, string>(latitude, longitude, address);
-                    _addresses.Add(tuple);
+                    var address = StoreUtils.ReverseGeocode(latitude, longitude);
+                    if (!string.IsNullOrWhiteSpace(address))
+                    {
+                        tuple = new Tuple<double, double, string>(latitude, longitude, address);
+                        _addresses.Add(tuple);
+                    }
+                }
+                catch (Exception e)
+                {
+                    Logger.Send(LogType.Error, "", e.ToString());
                 }
             }