Skip to content

Instantly share code, notes, and snippets.

View bero's full-sized avatar

Roland Bengtsson bero

View GitHub Profile
procedure TForm1.SendActionExecute(Sender: TObject);
var
LWebHook: IMessageBuffer;
LMessage: IMessage;
LStopWatch: TStopWatch;
vAttachment: IAttachment;
vField: IFields;
begin
LStopWatch := TStopWatch.StartNew;
function TInvoicingPool.CreateInvoice(aInvoiceDrawerParty: TDepartment; aCustomerParty: TDepartment): TInvoice;
begin
Assert(Assigned(aInvoiceDrawerParty), 'Invalid parameter (InvoiceOwner missing)');
Assert(Assigned(aCustomerParty), 'Invalid parameter (customer missing)');
Result := GetApplicationKernel.CreateAMObjectByClass(TInvoice) as TInvoice;
with Result do
begin
// systemorg/defaultdept is owner of all the invoices - set defaultdept as owner...
// ...even if user happened to be logged on to some other department when invoice was made...
// ...since only defaultdept has all the required edi-data needed in order to send eInvoices...
unit uEtl;
interface
uses
Generics.Collections;
type
IETL = interface
function Transform(aOld: TDictionary<integer, TList<string>>): TDictionary<string, integer>;
unit uRaindrops;
interface
type
TRainDrop = class
public
function Convert(Value: Integer): string;
end;
@bero
bero / gist:6cf25295d7bf35b50a9a88cc6b632843
Created November 13, 2021 15:07
Example of how to handle memory in a list
unit Unit3;
interface
procedure TestMemory;
implementation
uses
Classes,
@bero
bero / DaylightSaving.pas
Created July 19, 2021 05:32
Some ugly code for daylight saving
function HasNoDaylightTime(aAddress: TAbstractAddress): Boolean;
begin
Result := (aAddress.CountryAlias = 'af') or
(aAddress.CountryAlias = 'dz') or
(aAddress.CountryAlias = 'as') or
(aAddress.CountryAlias = 'ao') or
(aAddress.CountryAlias = 'ai') or
(aAddress.CountryAlias = 'ag') or
(aAddress.CountryAlias = 'ar') or
(aAddress.CountryAlias = 'am') or
unit SystemConfigCommon;
type
TSystemConfigCommon = class
private
function GetUseBatchQueries: Boolean;
public
property UseBatchQueries: Boolean read GetUseBatchQueries;
end;
program Project7;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
DateUtils;
@bero
bero / E2094
Last active October 13, 2019 07:23
E2094 'operator+' not implemented in type 'UnicodeString' for arguments of type 'int'
program Project6;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;