- 19


SELECT Street FROM PhonesOwners

WHERE (PKey = :NOwner) AND (:ADate BETWEEN PhonesOwners.BegDate AND PhonesOwners.EndDate)

INTO :AStreet;

IF (:AStreet IS NOT NULL) THEN

BEGIN

EXECUTE PROCEDURE PrGenPhonesKeys RETURNING_VALUES :APhone;

INSERT INTO PhonesKeys (Code)

VALUES (:APhone);

INSERT INTO Phones(Owner, PKey, PhoneNmb, Street, InstallDate, RemoveDate, BegDate, EndDate)

VALUES (:NOwner, :APhone, :APhoneNmb, :AStreet, :ADate, "12.12.2222", :ADate, "12.12.2222");

END

END

END ^

CREATE PROCEDURE TalksGetTax

AS

BEGIN

EXIT;

END ^

CREATE PROCEDURE TalksGetPay (APhone INTEGER, ADay DATE, ACallTime INTEGER, AHowLong INTEGER)

RETURNS (APay FLOAT, ACalculated SMALLINT, IsLgot SMALLINT)

AS

DECLARE VARIABLE ATax FLOAT;

DECLARE VARIABLE AProcNach FLOAT;

DECLARE VARIABLE ATalksUsl INTEGER;

DECLARE VARIABLE AOwner INTEGER;

DECLARE VARIABLE ANalog FLOAT;

BEGIN

ACalculated = 0;

SELECT TimeTalksUsl FROM SysSettings INTO :ATalksUsl;

IF (:ATalksUsl IS NULL) THEN EXIT;

SELECT Owner FROM Phones WHERE (PKey = :APhone) AND (:ADay BETWEEN BegDate AND EndDate)

INTO :AOwner;

IF (:AOwner IS NULL) THEN EXIT;

EXECUTE PROCEDURE UslGetOwnerTax(:AOwner, :ATalksUsl, :ADay)

RETURNING_VALUES :ATax, :AProcNach, :ANalog;

IF (:ATax IS NULL) THEN EXIT;

APay = ATax*AHowLong*AProcNach/3000;

ACalculated = 1;

END ^

CREATE PROCEDURE TalksCallBilling (APhone INTEGER, ACallDate DATE, ACallTime INTEGER, AHowLong INTEGER)

RETURNS (ATalksPayCode INTEGER, ACalculated SMALLINT)

AS

DECLARE VARIABLE APay FLOAT;

DECLARE VARIABLE PayCode INTEGER;