-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformunit.pas
70 lines (51 loc) · 1.55 KB
/
formunit.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
unit FormUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
Spin;
type
{ TLythaPricingUtilsForm }
TLythaPricingUtilsForm = class(TForm)
BasePriceEdit: TFloatSpinEdit;
GroupBox1: TGroupBox;
EtsyFormulaLabel: TLabel;
EtsyPriceLabel: TLabel;
procedure BasePriceEditChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
const
ETSYITEMSALEPERC = 5.0; (* Etsy.com Sales fee - percentage *)
ETSYITEMLISTINGFEE = 0.20; (* Etsy.com Listing fee - flat rate in USD *)
var
LythaPricingUtilsForm: TLythaPricingUtilsForm;
implementation
{$R *.lfm}
{ TLythaPricingUtilsForm }
procedure TLythaPricingUtilsForm.BasePriceEditChange(Sender: TObject);
begin
(* Update item price (caption). *)
EtsyPriceLabel.Caption := '$' +
FloatToStrF(
BasePriceEdit.Value+BasePriceEdit.Value*(ETSYITEMSALEPERC/100)+ETSYITEMLISTINGFEE,
ffFixed,5,2);
end;
procedure TLythaPricingUtilsForm.FormCreate(Sender: TObject);
begin
(* Open on top right of screen. *)
Top := 0;
Left := Screen.Width-Width;
(* Display price formula (caption). *)
EtsyFormulaLabel.Caption := ' + ' +
FloatToStrF(ETSYITEMSALEPERC,ffFixed,2,1) +
'% + $' +
FloatToStrF(ETSYITEMLISTINGFEE,ffFixed,5,2) +
' = ';
(* Calculate initial price based by manually calling event handler. *)
BasePriceEditChange(LythaPricingUtilsForm);
end;
end.