1
0

add SEPA-Mandate entity+repository

This commit is contained in:
Michael Hoennig
2022-10-13 18:53:38 +02:00
parent 7f5b2358d3
commit bece972a4e
8 changed files with 34 additions and 25 deletions

View File

@ -9,7 +9,7 @@ create table if not exists hs_office_sepamandate
uuid uuid unique references RbacObject (uuid) initially deferred,
debitorUuid uuid not null references hs_office_debitor(uuid),
bankAccountUuid uuid not null references hs_office_bankaccount(uuid),
reference varchar(96),
reference varchar(96) not null,
validity daterange not null
);
--//

View File

@ -1,21 +1,21 @@
--liquibase formatted sql
-- ============================================================================
--changeset hs-office-sepaMandate-rbac-OBJECT:1 endDelimiter:--//
--changeset hs-office-sepamandate-rbac-OBJECT:1 endDelimiter:--//
-- ----------------------------------------------------------------------------
call generateRelatedRbacObject('hs_office_sepaMandate');
call generateRelatedRbacObject('hs_office_sepamandate');
--//
-- ============================================================================
--changeset hs-office-sepaMandate-rbac-ROLE-DESCRIPTORS:1 endDelimiter:--//
--changeset hs-office-sepamandate-rbac-ROLE-DESCRIPTORS:1 endDelimiter:--//
-- ----------------------------------------------------------------------------
call generateRbacRoleDescriptors('hsOfficeSepaMandate', 'hs_office_sepaMandate');
call generateRbacRoleDescriptors('hsOfficeSepaMandate', 'hs_office_sepamandate');
--//
-- ============================================================================
--changeset hs-office-sepaMandate-rbac-ROLES-CREATION:1 endDelimiter:--//
--changeset hs-office-sepamandate-rbac-ROLES-CREATION:1 endDelimiter:--//
-- ----------------------------------------------------------------------------
/*
@ -36,10 +36,8 @@ begin
if TG_OP = 'INSERT' then
-- === ATTENTION: code generated from related Mermaid flowchart: ===
perform createRoleWithGrants(
hsOfficeSepaMandateOwner(NEW),
permissions => array['*'],
@ -73,7 +71,6 @@ begin
-- === END of code generated from Mermaid flowchart. ===
else
raise exception 'invalid usage of TRIGGER';
end if;
@ -86,23 +83,23 @@ end; $$;
*/
create trigger createRbacRolesForHsOfficeSepaMandate_Trigger
after insert
on hs_office_sepaMandate
on hs_office_sepamandate
for each row
execute procedure hsOfficeSepaMandateRbacRolesTrigger();
--//
-- ============================================================================
--changeset hs-office-sepaMandate-rbac-IDENTITY-VIEW:1 endDelimiter:--//
--changeset hs-office-sepamandate-rbac-IDENTITY-VIEW:1 endDelimiter:--//
-- ----------------------------------------------------------------------------
call generateRbacIdentityView('hs_office_sepaMandate', idNameExpression => 'target.reference');
call generateRbacIdentityView('hs_office_sepamandate', idNameExpression => 'target.reference');
--//
-- ============================================================================
--changeset hs-office-sepaMandate-rbac-RESTRICTED-VIEW:1 endDelimiter:--//
--changeset hs-office-sepamandate-rbac-RESTRICTED-VIEW:1 endDelimiter:--//
-- ----------------------------------------------------------------------------
call generateRbacRestrictedView('hs_office_sepaMandate',
call generateRbacRestrictedView('hs_office_sepamandate',
orderby => 'target.reference',
columnUpdates => $updates$
validity = new.validity
@ -111,7 +108,7 @@ call generateRbacRestrictedView('hs_office_sepaMandate',
-- ============================================================================
--changeset hs-office-sepaMandate-rbac-NEW-SepaMandate:1 endDelimiter:--//
--changeset hs-office-sepamandate-rbac-NEW-SepaMandate:1 endDelimiter:--//
-- ----------------------------------------------------------------------------
/*
Creates a global permission for new-sepaMandate and assigns it to the hostsharing admins role.
@ -146,9 +143,9 @@ end; $$;
/**
Checks if the user or assumed roles are allowed to create a new customer.
*/
create trigger hs_office_sepaMandate_insert_trigger
create trigger hs_office_sepamandate_insert_trigger
before insert
on hs_office_sepaMandate
on hs_office_sepamandate
for each row
-- TODO.spec: who is allowed to create new sepaMandates
when ( not hasAssumedRole() )

View File

@ -31,7 +31,7 @@ begin
raise notice '- using debitor (%): %', relatedDebitor.uuid, relatedDebitor;
raise notice '- using bankAccount (%): %', relatedBankAccount.uuid, relatedBankAccount;
insert
into hs_office_sepaMandate (uuid, debitoruuid, bankAccountuuid, reference, validity)
into hs_office_sepamandate (uuid, debitoruuid, bankAccountuuid, reference, validity)
values (uuid_generate_v4(), relatedDebitor.uuid, relatedBankAccount.uuid, 'ref'||idName, daterange('20221001' , '20261231', '[]'));
end; $$;
--//